diff --git a/javagen/src/main/java/com/azure/autorest/mapper/ClientMethodMapper.java b/javagen/src/main/java/com/azure/autorest/mapper/ClientMethodMapper.java index d1301d455b..00a8692384 100644 --- a/javagen/src/main/java/com/azure/autorest/mapper/ClientMethodMapper.java +++ b/javagen/src/main/java/com/azure/autorest/mapper/ClientMethodMapper.java @@ -1594,7 +1594,7 @@ protected static String returnTypeDescription(Operation operation, IType returnT String description = null; // try the description of the operation if (operation.getLanguage() != null && operation.getLanguage().getDefault() != null) { - String operationDescription = operation.getLanguage().getDefault().getDescription(); + 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; diff --git a/typespec-extension/changelog.md b/typespec-extension/changelog.md index 4b81a73fce..a6934b42b6 100644 --- a/typespec-extension/changelog.md +++ b/typespec-extension/changelog.md @@ -1,5 +1,13 @@ # Release History +## 0.20.0 (2024-08-26) + +Compatible with compiler 0.59. + +- Adopt TCGC `sdkPackage`. +- Always allow override `endpoint` parameter in `Builder`. +- Client method parameters' order changes when define the method parameters using spread in TypeSpec. + ## 0.19.3 (2024-08-21) Compatible with compiler 0.59. diff --git a/typespec-extension/package.json b/typespec-extension/package.json index c2ccc1a59f..5bc10de3b7 100644 --- a/typespec-extension/package.json +++ b/typespec-extension/package.json @@ -1,6 +1,6 @@ { "name": "@azure-tools/typespec-java", - "version": "0.19.3", + "version": "0.20.0", "description": "TypeSpec library for emitting Java client from the TypeSpec REST protocol binding", "keywords": [ "TypeSpec" diff --git a/typespec-extension/src/code-model-builder.ts b/typespec-extension/src/code-model-builder.ts index dcfea8bf20..9c34f62f4f 100644 --- a/typespec-extension/src/code-model-builder.ts +++ b/typespec-extension/src/code-model-builder.ts @@ -41,12 +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, @@ -54,27 +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, - getHttpOperationWithCache, getWireName, isApiVersion, isSdkBuiltInKind, isSdkIntKind, - listClients, - listOperationGroups, - listOperationsInOperationGroup, - shouldGenerateConvenient, - shouldGenerateProtocol, - getHttpOperationExamples, } from "@azure-tools/typespec-client-generator-core"; import { EmitContext, @@ -84,41 +84,29 @@ 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, getPathParamName, getQueryParamName, - getServers, - getStatusCodeDescription, isBody, isBodyRoot, isHeader, @@ -126,8 +114,8 @@ import { 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 { Client as CodeModelClient, CrossLanguageDefinition, EncodedSchema } from "./common/client.js"; @@ -143,6 +131,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, @@ -162,15 +151,18 @@ import { getNonNullSdkType, getUnionDescription, getUsage, - hasScalarAsBase, - isArmCommonType, - isModelReferredInTemplate, - isNullableType, isStable, modelIs, pushDistinct, } from "./type-utils.js"; -import { getNamespace, logWarning, pascalCase, stringArrayContainsIgnoreCase, trace } from "./utils.js"; +import { + getNamespace, + logWarning, + pascalCase, + removeClientSuffix, + stringArrayContainsIgnoreCase, + trace, +} from "./utils.js"; const { isEqual } = pkg; export class CodeModelBuilder { @@ -191,7 +183,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; @@ -248,7 +240,9 @@ export class CodeModelBuilder { } public async build(): Promise { - this.sdkContext = await createSdkContext(this.emitterContext, "@azure-tools/typespec-java"); + this.sdkContext = await createSdkContext(this.emitterContext, "@azure-tools/typespec-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 @@ -263,9 +257,9 @@ export class CodeModelBuilder { this.options["group-etag-headers"] = false; } - const clients = this.processClients(); + this.processClients(); - this.processModels(clients); + this.processModels(); this.processSchemaUsage(); @@ -278,68 +272,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; - - 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: { - // TODO: deprecate this logic of string/url for x-ms-skip-url-encoding - "x-ms-skip-url-encoding": schema instanceof UriSchema, + 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, }, - // // make the logic same as TCGC, which takes the server-side default of host as client-side default - // clientDefaultValue: getDefaultValue(it.defaultValue), - }); - } + }, + // 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)); + }); - 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) { @@ -401,16 +367,7 @@ export class CodeModelBuilder { return !this.options["flavor"] || this.options["flavor"].toLocaleLowerCase() === "azure"; } - private isInternal(operation: Operation): boolean { - const access = getAccess(operation); - if (access) { - return access === "internal"; - } else { - return false; - } - } - - private processModels(clients: SdkClient[]) { + private processModels() { const processedSdkModels: Set = new Set(); // lambda to mark model as public @@ -516,26 +473,24 @@ 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) { - let clientName: string = client.name; - let clientSubNamespace: string | undefined = undefined; + 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)!; - clientSubNamespace = clientNameSegments.slice(0, -1).join("."); + const clientSubNamespace = clientNameSegments.slice(0, -1).join("."); javaNamespace = this.getJavaNamespace(this.namespace + "." + clientSubNamespace); } - const codeModelClient = new CodeModelClient(clientName, this.getDoc(client.type), { - summary: this.getSummary(client.type), - + const codeModelClient = new CodeModelClient(clientName, client.details ?? "", { + summary: client.description, language: { default: { namespace: this.namespace, @@ -551,13 +506,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); } @@ -566,108 +520,146 @@ 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) { - // groupPath would be in format of "[.].Chat.Completions" - let operationGroupPath = operationGroup.groupPath; - if (clientSubNamespace && operationGroup.groupPath.startsWith(clientSubNamespace + ".")) { - // remove SubNamespace - operationGroupPath = operationGroupPath.slice((clientSubNamespace + ".").length); - } - const groupPath = operationGroupPath.split("."); - let operationGroupName: string; - if (groupPath.length > 1) { - // remove ClientName - operationGroupName = groupPath.slice(1).join(""); - } else { - operationGroupName = groupPath[0]; - } - codeModelGroup = new OperationGroup(operationGroupName); - for (const operation of operations) { - if (!this.needToSkipProcessingOperation(operation, clientContext)) { - codeModelGroup.addOperation(this.processOperation(operationGroupName, 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(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); + // 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) { - 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); + } + } } } - 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); + } + + 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; + } - return clients; + private listServiceMethodsUnderClient(client: SdkClientType): SdkServiceMethod[] { + const methods: SdkServiceMethod[] = []; + for (const method of client.methods) { + if (method.kind !== "clientaccessor") { + methods.push(method); + } + } + return methods; } /** @@ -679,10 +671,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; } @@ -691,21 +683,12 @@ 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, clientContext: ClientContext): boolean { + private needToSkipProcessingOperation(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`); return true; @@ -720,8 +703,8 @@ 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) { @@ -731,8 +714,7 @@ export class CodeModelBuilder { // 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; + operationExamples[operationExample.title ?? operationExample.operationId ?? sdkMethod.name] = operationExample; } return operationExamples; } else { @@ -740,64 +722,53 @@ export class CodeModelBuilder { } } - private processOperation(groupName: string, operation: Operation, clientContext: ClientContext): CodeModelOperation { - const op = getHttpOperationWithCache(this.sdkContext, operation); - + private processOperation( + sdkMethod: SdkServiceMethod, + clientContext: ClientContext, + groupName: string, + ): CodeModelOperation { + 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(operation); + (codeModelOperation as CrossLanguageDefinition).crossLanguageDefinitionId = 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) && this.options["stream-style-serialization"] === false) { + } else if (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); @@ -814,8 +785,8 @@ export class CodeModelBuilder { new Request({ protocol: { http: { - path: op.path, - method: op.verb, + path: httpOperation.path, + method: httpOperation.verb, uri: clientContext.baseUri, }, }, @@ -824,72 +795,81 @@ 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); + // 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; } - } 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); + } + // 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) => { @@ -897,7 +877,6 @@ export class CodeModelBuilder { this.trackSchemaUsage(r.schema, { usage: [SchemaContext.Paged] }); } }); - break; } } @@ -905,12 +884,13 @@ export class CodeModelBuilder { } } - private processLroMetadata(op: CodeModelOperation, httpOperation: HttpOperation): LongRunningMetadata { - const operation = httpOperation.operation; - + private processLroMetadata( + op: CodeModelOperation, + sdkMethod: SdkLroServiceMethod | SdkLroPagingServiceMethod, + ): LongRunningMetadata { 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; @@ -919,8 +899,8 @@ 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({ @@ -999,8 +979,7 @@ export class CodeModelBuilder { private processRouteForLongRunning( op: CodeModelOperation, - operation: Operation, - responses: HttpOperationResponse[], + responses: Map, lroMetadata: LongRunningMetadata, ) { if (lroMetadata.longRunning) { @@ -1008,75 +987,52 @@ 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, clientContext: ClientContext) { + private processParameter( + op: CodeModelOperation, + param: SdkQueryParameter | SdkPathParameter | SdkHeaderParameter, + clientContext: ClientContext, + ) { if (clientContext.apiVersions && isApiVersion(this.sdkContext, param)) { // pre-condition for "isApiVersion": the client supports ApiVersions 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); } op.addParameter(this._armApiVersionParameter); } else { - const parameter = param.type === "query" ? this.apiVersionParameter : this.apiVersionParameterInPath; + const parameter = 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); let extensions: { [id: string]: any } | undefined = undefined; - // skip-url-encoding - if (param.type === "path") { + if (param.kind === "path") { if (param.allowReserved) { extensions = extensions ?? {}; extensions["x-ms-skip-url-encoding"] = true; @@ -1084,17 +1040,17 @@ export class CodeModelBuilder { } // 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 = 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); @@ -1104,68 +1060,64 @@ 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") { - // eslint-disable-next-line deprecation/deprecation - const queryParamFormat = param?.format; - if (queryParamFormat) { - switch (queryParamFormat) { - case "csv": - style = SerializationStyle.Simple; - break; - - case "ssv": - style = SerializationStyle.SpaceDelimited; - break; - - case "tsv": - style = SerializationStyle.TabDelimited; - break; - - case "pipes": - style = SerializationStyle.PipeDelimited; - break; - - case "multi": - style = SerializationStyle.Form; - explode = true; - break; - - default: - this.logWarning(`Unrecognized query parameter format: '${queryParamFormat}'.`); - break; - } + if (sdkType.kind === "array") { + if (param.kind === "query") { + const format = param.collectionFormat; + switch (format) { + case "csv": + case "simple": + style = SerializationStyle.Simple; + break; + + case "ssv": + style = SerializationStyle.SpaceDelimited; + break; + + case "tsv": + style = SerializationStyle.TabDelimited; + break; + + case "pipes": + style = SerializationStyle.PipeDelimited; + break; + + case "multi": + case "form": + style = SerializationStyle.Form; + explode = true; + break; } - } else if (param.type === "header") { - if (param.format) { - switch (param.format) { - case "csv": - style = SerializationStyle.Simple; - break; - - default: - this.logWarning(`Unrecognized header parameter format: '${param.format}'.`); - break; - } + } else if (param.kind === "header") { + const format = param.collectionFormat; + switch (format) { + case "csv": + style = SerializationStyle.Simple; + break; + + default: + 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, @@ -1180,53 +1132,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", @@ -1288,7 +1194,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." @@ -1361,42 +1267,35 @@ export class CodeModelBuilder { } } - private processParameterBody(op: CodeModelOperation, httpOperation: HttpOperation, body: ModelProperty | Model) { + private processParameterBody( + op: CodeModelOperation, + 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), }, @@ -1410,16 +1309,20 @@ export class CodeModelBuilder { this.trackSchemaUsage(schema, { usage: [op.internalApi ? SchemaContext.Internal : SchemaContext.Public] }); } - 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"; @@ -1428,7 +1331,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; @@ -1444,63 +1347,17 @@ export class CodeModelBuilder { request.parameters = []; op.convenienceApi.requests.push(request); - for (const [_, opParameter] of parameters.properties) { - const serializedName = this.getSerializedName(opParameter); - const paramLocation = this.getParameterLocation(opParameter); - let existParameter: Parameter | undefined; - if (paramLocation === "BodyProperty") { - // property of body, it won't match existing parameter (whose paramLocation be body, path, query, header) - existParameter = undefined; - } else { - existParameter = op.parameters.find((it) => { - const sameParamLocation = paramLocation === it.protocol.http?.in; - const sameSerializedName = it.language.default.serializedName === serializedName; - if (paramLocation === ParameterLocation.Body) { - // body, same paramLocation, as there could only be 1 body in operation - return sameParamLocation; - } else { - // path, query, header, require same serializedName and same paramLocation - return sameParamLocation && sameSerializedName; + // header/query/path params + for (const opParameter of parameters) { + this.addParameterOrBodyPropertyToCodeModelRequest(opParameter, op, request, schema, parameter); + } + // 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); } - }); - } - 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, - }, - ), - ); } } } @@ -1509,7 +1366,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`, { @@ -1563,114 +1420,164 @@ 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); } - private processResponse(op: CodeModelOperation, resp: HttpOperationResponse, longRunning: boolean) { + private processResponse( + op: CodeModelOperation, + 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, - }, + }, + }); + } 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: this.getResponseDescription(resp), - }, + }, + 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) { @@ -1706,14 +1613,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."); } @@ -2206,10 +2105,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, }), ); } @@ -2317,34 +2216,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); @@ -2427,10 +2298,10 @@ 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; } @@ -2559,19 +2430,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/typespec-extension/src/operation-utils.ts b/typespec-extension/src/operation-utils.ts index 4675d723b2..012f669990 100644 --- a/typespec-extension/src/operation-utils.ts +++ b/typespec-extension/src/operation-utils.ts @@ -6,6 +6,7 @@ import { Client as CodeModelClient, ServiceVersion } from "./common/client.js"; import { CodeModel } from "./common/code-model.js"; import { getNamespace, pascalCase } from "./utils.js"; import { modelIs, unionReferredByType } from "./type-utils.js"; +import { SdkHttpOperation } from "@azure-tools/typespec-client-generator-core"; export const SPECIAL_HEADER_NAMES = new Set([ "repeatability-request-id", @@ -17,7 +18,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([ @@ -41,18 +42,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; } } @@ -60,14 +61,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/typespec-extension/src/type-utils.ts b/typespec-extension/src/type-utils.ts index 71bb07dc97..3e47fe807b 100644 --- a/typespec-extension/src/type-utils.ts +++ b/typespec-extension/src/type-utils.ts @@ -1,7 +1,6 @@ import { DecoratedType, DecoratorApplication, - EncodeData, EnumMember, IntrinsicScalarName, Model, @@ -24,7 +23,6 @@ import { DurationSchema } from "./common/schemas/time.js"; import { getNamespace } from "./utils.js"; import { getUnionAsEnum } from "@azure-tools/typespec-azure-core"; import { SdkDurationType, SdkType, isSdkFloatKind, isSdkIntKind } from "@azure-tools/typespec-client-generator-core"; -import { Version } from "@typespec/versioning"; /** Acts as a cache for processing inputs. * @@ -51,8 +49,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 @@ -110,22 +108,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/typespec-extension/src/utils.ts b/typespec-extension/src/utils.ts index a21d5ceedc..60676b8a8c 100644 --- a/typespec-extension/src/utils.ts +++ b/typespec-extension/src/utils.ts @@ -39,3 +39,8 @@ export function getNamespace(type: Type | undefined): string | 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/typespec-tests/package.json b/typespec-tests/package.json index fbc58e28e1..0ab1c13dd3 100644 --- a/typespec-tests/package.json +++ b/typespec-tests/package.json @@ -10,7 +10,7 @@ }, "dependencies": { "@azure-tools/cadl-ranch-specs": "0.36.1", - "@azure-tools/typespec-java": "file:/../typespec-extension/azure-tools-typespec-java-0.19.3.tgz" + "@azure-tools/typespec-java": "file:/../typespec-extension/azure-tools-typespec-java-0.20.0.tgz" }, "devDependencies": { "@typespec/prettier-plugin-typespec": "~0.59.0", diff --git a/typespec-tests/src/main/java/com/_specs_/azure/clientgenerator/core/access/AccessClientBuilder.java b/typespec-tests/src/main/java/com/_specs_/azure/clientgenerator/core/access/AccessClientBuilder.java index 39003a1f55..3ce73c56e6 100644 --- a/typespec-tests/src/main/java/com/_specs_/azure/clientgenerator/core/access/AccessClientBuilder.java +++ b/typespec-tests/src/main/java/com/_specs_/azure/clientgenerator/core/access/AccessClientBuilder.java @@ -8,6 +8,7 @@ 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; @@ -49,8 +50,8 @@ InternalOperationAsyncClient.class, SharedModelInOperationAsyncClient.class, RelativeModelInOperationAsyncClient.class }) -public final class AccessClientBuilder - implements HttpTrait, ConfigurationTrait { +public final class AccessClientBuilder implements HttpTrait, + ConfigurationTrait, EndpointTrait { @Generated private static final String SDK_NAME = "name"; @@ -182,6 +183,22 @@ public AccessClientBuilder configuration(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. */ @@ -209,7 +226,9 @@ public AccessClientBuilder retryPolicy(RetryPolicy retryPolicy) { private AccessClientImpl buildInnerClient() { this.validateClient(); HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); - AccessClientImpl client = new AccessClientImpl(localPipeline, JacksonAdapter.createDefaultSerializerAdapter()); + String localEndpoint = (endpoint != null) ? endpoint : "http://localhost:3000"; + AccessClientImpl client + = new AccessClientImpl(localPipeline, JacksonAdapter.createDefaultSerializerAdapter(), localEndpoint); return client; } diff --git a/typespec-tests/src/main/java/com/_specs_/azure/clientgenerator/core/access/implementation/AccessClientImpl.java b/typespec-tests/src/main/java/com/_specs_/azure/clientgenerator/core/access/implementation/AccessClientImpl.java index e5f1fc646c..ae5fdc17a5 100644 --- a/typespec-tests/src/main/java/com/_specs_/azure/clientgenerator/core/access/implementation/AccessClientImpl.java +++ b/typespec-tests/src/main/java/com/_specs_/azure/clientgenerator/core/access/implementation/AccessClientImpl.java @@ -15,6 +15,20 @@ * 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. */ @@ -101,19 +115,22 @@ public RelativeModelInOperationsImpl getRelativeModelInOperations() { /** * Initializes an instance of AccessClient client. + * + * @param endpoint Service host. */ - public AccessClientImpl() { + public AccessClientImpl(String endpoint) { this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), - JacksonAdapter.createDefaultSerializerAdapter()); + 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) { - this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter()); + public AccessClientImpl(HttpPipeline httpPipeline, String endpoint) { + this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint); } /** @@ -121,10 +138,12 @@ public AccessClientImpl(HttpPipeline httpPipeline) { * * @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) { + 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); diff --git a/typespec-tests/src/main/java/com/_specs_/azure/clientgenerator/core/access/implementation/InternalOperationsImpl.java b/typespec-tests/src/main/java/com/_specs_/azure/clientgenerator/core/access/implementation/InternalOperationsImpl.java index 1f546b3b79..d1cec38a8d 100644 --- a/typespec-tests/src/main/java/com/_specs_/azure/clientgenerator/core/access/implementation/InternalOperationsImpl.java +++ b/typespec-tests/src/main/java/com/_specs_/azure/clientgenerator/core/access/implementation/InternalOperationsImpl.java @@ -8,6 +8,7 @@ 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; @@ -54,7 +55,7 @@ public final class InternalOperationsImpl { * The interface defining all the services for AccessClientInternalOperations to be used by the proxy service to * perform REST calls. */ - @Host("http://localhost:3000") + @Host("{endpoint}") @ServiceInterface(name = "AccessClientInternal") public interface InternalOperationsService { @Get("/azure/client-generator-core/access/internalOperation/noDecoratorInInternal") @@ -63,8 +64,9 @@ public interface InternalOperationsService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> noDecoratorInInternal(@QueryParam("name") String name, - @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + 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 }) @@ -72,8 +74,9 @@ Mono> noDecoratorInInternal(@QueryParam("name") String name @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response noDecoratorInInternalSync(@QueryParam("name") String name, - @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + 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 }) @@ -81,8 +84,9 @@ Response noDecoratorInInternalSync(@QueryParam("name") String name, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> internalDecoratorInInternal(@QueryParam("name") String name, - @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + 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 }) @@ -90,8 +94,9 @@ Mono> internalDecoratorInInternal(@QueryParam("name") Strin @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response internalDecoratorInInternalSync(@QueryParam("name") String name, - @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + 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 }) @@ -99,8 +104,9 @@ Response internalDecoratorInInternalSync(@QueryParam("name") String @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> publicDecoratorInInternal(@QueryParam("name") String name, - @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + 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 }) @@ -108,8 +114,9 @@ Mono> publicDecoratorInInternal(@QueryParam("name") String @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response publicDecoratorInInternalSync(@QueryParam("name") String name, - @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + Response publicDecoratorInInternalSync(@HostParam("endpoint") String endpoint, + @QueryParam("name") String name, @HeaderParam("Accept") String accept, RequestOptions requestOptions, + Context context); } /** @@ -135,7 +142,8 @@ Response publicDecoratorInInternalSync(@QueryParam("name") String na public Mono> noDecoratorInInternalWithResponseAsync(String name, RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.noDecoratorInInternal(name, accept, requestOptions, context)); + return FluxUtil.withContext( + context -> service.noDecoratorInInternal(this.client.getEndpoint(), name, accept, requestOptions, context)); } /** @@ -159,7 +167,7 @@ public Mono> noDecoratorInInternalWithResponseAsync(String @ServiceMethod(returns = ReturnType.SINGLE) public Response noDecoratorInInternalWithResponse(String name, RequestOptions requestOptions) { final String accept = "application/json"; - return service.noDecoratorInInternalSync(name, accept, requestOptions, Context.NONE); + return service.noDecoratorInInternalSync(this.client.getEndpoint(), name, accept, requestOptions, Context.NONE); } /** @@ -185,8 +193,8 @@ public Response noDecoratorInInternalWithResponse(String name, Reque public Mono> internalDecoratorInInternalWithResponseAsync(String name, RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil - .withContext(context -> service.internalDecoratorInInternal(name, accept, requestOptions, context)); + return FluxUtil.withContext(context -> service.internalDecoratorInInternal(this.client.getEndpoint(), name, + accept, requestOptions, context)); } /** @@ -210,7 +218,8 @@ public Mono> internalDecoratorInInternalWithResponseAsync(S @ServiceMethod(returns = ReturnType.SINGLE) public Response internalDecoratorInInternalWithResponse(String name, RequestOptions requestOptions) { final String accept = "application/json"; - return service.internalDecoratorInInternalSync(name, accept, requestOptions, Context.NONE); + return service.internalDecoratorInInternalSync(this.client.getEndpoint(), name, accept, requestOptions, + Context.NONE); } /** @@ -236,8 +245,8 @@ public Response internalDecoratorInInternalWithResponse(String name, public Mono> publicDecoratorInInternalWithResponseAsync(String name, RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil - .withContext(context -> service.publicDecoratorInInternal(name, accept, requestOptions, context)); + return FluxUtil.withContext(context -> service.publicDecoratorInInternal(this.client.getEndpoint(), name, + accept, requestOptions, context)); } /** @@ -262,6 +271,7 @@ public Mono> publicDecoratorInInternalWithResponseAsync(Str @ServiceMethod(returns = ReturnType.SINGLE) public Response publicDecoratorInInternalWithResponse(String name, RequestOptions requestOptions) { final String accept = "application/json"; - return service.publicDecoratorInInternalSync(name, accept, requestOptions, Context.NONE); + return service.publicDecoratorInInternalSync(this.client.getEndpoint(), name, accept, requestOptions, + Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/_specs_/azure/clientgenerator/core/access/implementation/PublicOperationsImpl.java b/typespec-tests/src/main/java/com/_specs_/azure/clientgenerator/core/access/implementation/PublicOperationsImpl.java index 3c5b2aec41..e6aaefc24a 100644 --- a/typespec-tests/src/main/java/com/_specs_/azure/clientgenerator/core/access/implementation/PublicOperationsImpl.java +++ b/typespec-tests/src/main/java/com/_specs_/azure/clientgenerator/core/access/implementation/PublicOperationsImpl.java @@ -8,6 +8,7 @@ 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; @@ -54,7 +55,7 @@ public final class PublicOperationsImpl { * The interface defining all the services for AccessClientPublicOperations to be used by the proxy service to * perform REST calls. */ - @Host("http://localhost:3000") + @Host("{endpoint}") @ServiceInterface(name = "AccessClientPublicOp") public interface PublicOperationsService { @Get("/azure/client-generator-core/access/publicOperation/noDecoratorInPublic") @@ -63,8 +64,9 @@ public interface PublicOperationsService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> noDecoratorInPublic(@QueryParam("name") String name, - @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + 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 }) @@ -72,8 +74,9 @@ Mono> noDecoratorInPublic(@QueryParam("name") String name, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response noDecoratorInPublicSync(@QueryParam("name") String name, - @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + 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 }) @@ -81,8 +84,9 @@ Response noDecoratorInPublicSync(@QueryParam("name") String name, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> publicDecoratorInPublic(@QueryParam("name") String name, - @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + 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 }) @@ -90,8 +94,9 @@ Mono> publicDecoratorInPublic(@QueryParam("name") String na @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response publicDecoratorInPublicSync(@QueryParam("name") String name, - @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + Response publicDecoratorInPublicSync(@HostParam("endpoint") String endpoint, + @QueryParam("name") String name, @HeaderParam("Accept") String accept, RequestOptions requestOptions, + Context context); } /** @@ -116,7 +121,8 @@ Response publicDecoratorInPublicSync(@QueryParam("name") String name @ServiceMethod(returns = ReturnType.SINGLE) public Mono> noDecoratorInPublicWithResponseAsync(String name, RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.noDecoratorInPublic(name, accept, requestOptions, context)); + return FluxUtil.withContext( + context -> service.noDecoratorInPublic(this.client.getEndpoint(), name, accept, requestOptions, context)); } /** @@ -140,7 +146,7 @@ public Mono> noDecoratorInPublicWithResponseAsync(String na @ServiceMethod(returns = ReturnType.SINGLE) public Response noDecoratorInPublicWithResponse(String name, RequestOptions requestOptions) { final String accept = "application/json"; - return service.noDecoratorInPublicSync(name, accept, requestOptions, Context.NONE); + return service.noDecoratorInPublicSync(this.client.getEndpoint(), name, accept, requestOptions, Context.NONE); } /** @@ -166,7 +172,8 @@ public Response noDecoratorInPublicWithResponse(String name, Request public Mono> publicDecoratorInPublicWithResponseAsync(String name, RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.publicDecoratorInPublic(name, accept, requestOptions, context)); + return FluxUtil.withContext(context -> service.publicDecoratorInPublic(this.client.getEndpoint(), name, accept, + requestOptions, context)); } /** @@ -190,6 +197,7 @@ public Mono> publicDecoratorInPublicWithResponseAsync(Strin @ServiceMethod(returns = ReturnType.SINGLE) public Response publicDecoratorInPublicWithResponse(String name, RequestOptions requestOptions) { final String accept = "application/json"; - return service.publicDecoratorInPublicSync(name, accept, requestOptions, Context.NONE); + return service.publicDecoratorInPublicSync(this.client.getEndpoint(), name, accept, requestOptions, + Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/_specs_/azure/clientgenerator/core/access/implementation/RelativeModelInOperationsImpl.java b/typespec-tests/src/main/java/com/_specs_/azure/clientgenerator/core/access/implementation/RelativeModelInOperationsImpl.java index ecd6b80784..4f77f36c60 100644 --- a/typespec-tests/src/main/java/com/_specs_/azure/clientgenerator/core/access/implementation/RelativeModelInOperationsImpl.java +++ b/typespec-tests/src/main/java/com/_specs_/azure/clientgenerator/core/access/implementation/RelativeModelInOperationsImpl.java @@ -8,6 +8,7 @@ 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; @@ -54,7 +55,7 @@ public final class RelativeModelInOperationsImpl { * The interface defining all the services for AccessClientRelativeModelInOperations to be used by the proxy service * to perform REST calls. */ - @Host("http://localhost:3000") + @Host("{endpoint}") @ServiceInterface(name = "AccessClientRelative") public interface RelativeModelInOperationsService { @Get("/azure/client-generator-core/access/relativeModelInOperation/operation") @@ -63,8 +64,8 @@ public interface RelativeModelInOperationsService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> operation(@QueryParam("name") String name, @HeaderParam("accept") String accept, - RequestOptions requestOptions, Context context); + 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 }) @@ -72,8 +73,8 @@ Mono> operation(@QueryParam("name") String name, @HeaderPar @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response operationSync(@QueryParam("name") String name, @HeaderParam("accept") String accept, - RequestOptions requestOptions, Context context); + 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 }) @@ -81,8 +82,9 @@ Response operationSync(@QueryParam("name") String name, @HeaderParam @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> discriminator(@QueryParam("kind") String kind, @HeaderParam("accept") String accept, - RequestOptions requestOptions, Context context); + 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 }) @@ -90,8 +92,8 @@ Mono> discriminator(@QueryParam("kind") String kind, @Heade @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response discriminatorSync(@QueryParam("kind") String kind, @HeaderParam("accept") String accept, - RequestOptions requestOptions, Context context); + Response discriminatorSync(@HostParam("endpoint") String endpoint, @QueryParam("kind") String kind, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); } /** @@ -129,7 +131,8 @@ Response discriminatorSync(@QueryParam("kind") String kind, @HeaderP @ServiceMethod(returns = ReturnType.SINGLE) public Mono> operationWithResponseAsync(String name, RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.operation(name, accept, requestOptions, context)); + return FluxUtil.withContext( + context -> service.operation(this.client.getEndpoint(), name, accept, requestOptions, context)); } /** @@ -166,7 +169,7 @@ public Mono> operationWithResponseAsync(String name, Reques @ServiceMethod(returns = ReturnType.SINGLE) public Response operationWithResponse(String name, RequestOptions requestOptions) { final String accept = "application/json"; - return service.operationSync(name, accept, requestOptions, Context.NONE); + return service.operationSync(this.client.getEndpoint(), name, accept, requestOptions, Context.NONE); } /** @@ -199,7 +202,8 @@ public Response operationWithResponse(String name, RequestOptions re @ServiceMethod(returns = ReturnType.SINGLE) public Mono> discriminatorWithResponseAsync(String kind, RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.discriminator(kind, accept, requestOptions, context)); + return FluxUtil.withContext( + context -> service.discriminator(this.client.getEndpoint(), kind, accept, requestOptions, context)); } /** @@ -231,6 +235,6 @@ public Mono> discriminatorWithResponseAsync(String kind, Re @ServiceMethod(returns = ReturnType.SINGLE) public Response discriminatorWithResponse(String kind, RequestOptions requestOptions) { final String accept = "application/json"; - return service.discriminatorSync(kind, accept, requestOptions, Context.NONE); + return service.discriminatorSync(this.client.getEndpoint(), kind, accept, requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/_specs_/azure/clientgenerator/core/access/implementation/SharedModelInOperationsImpl.java b/typespec-tests/src/main/java/com/_specs_/azure/clientgenerator/core/access/implementation/SharedModelInOperationsImpl.java index cd3684b45b..62910d08de 100644 --- a/typespec-tests/src/main/java/com/_specs_/azure/clientgenerator/core/access/implementation/SharedModelInOperationsImpl.java +++ b/typespec-tests/src/main/java/com/_specs_/azure/clientgenerator/core/access/implementation/SharedModelInOperationsImpl.java @@ -8,6 +8,7 @@ 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; @@ -54,7 +55,7 @@ public final class SharedModelInOperationsImpl { * The interface defining all the services for AccessClientSharedModelInOperations to be used by the proxy service * to perform REST calls. */ - @Host("http://localhost:3000") + @Host("{endpoint}") @ServiceInterface(name = "AccessClientSharedMo") public interface SharedModelInOperationsService { @Get("/azure/client-generator-core/access/sharedModelInOperation/public") @@ -63,8 +64,8 @@ public interface SharedModelInOperationsService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> publicMethod(@QueryParam("name") String name, @HeaderParam("accept") String accept, - RequestOptions requestOptions, Context context); + 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 }) @@ -72,8 +73,8 @@ Mono> publicMethod(@QueryParam("name") String name, @Header @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response publicMethodSync(@QueryParam("name") String name, @HeaderParam("accept") String accept, - RequestOptions requestOptions, Context context); + 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 }) @@ -81,8 +82,8 @@ Response publicMethodSync(@QueryParam("name") String name, @HeaderPa @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> internal(@QueryParam("name") String name, @HeaderParam("accept") String accept, - RequestOptions requestOptions, Context context); + 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 }) @@ -90,8 +91,8 @@ Mono> internal(@QueryParam("name") String name, @HeaderPara @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response internalSync(@QueryParam("name") String name, @HeaderParam("accept") String accept, - RequestOptions requestOptions, Context context); + Response internalSync(@HostParam("endpoint") String endpoint, @QueryParam("name") String name, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); } /** @@ -116,7 +117,8 @@ Response internalSync(@QueryParam("name") String name, @HeaderParam( @ServiceMethod(returns = ReturnType.SINGLE) public Mono> publicMethodWithResponseAsync(String name, RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.publicMethod(name, accept, requestOptions, context)); + return FluxUtil.withContext( + context -> service.publicMethod(this.client.getEndpoint(), name, accept, requestOptions, context)); } /** @@ -140,7 +142,7 @@ public Mono> publicMethodWithResponseAsync(String name, Req @ServiceMethod(returns = ReturnType.SINGLE) public Response publicMethodWithResponse(String name, RequestOptions requestOptions) { final String accept = "application/json"; - return service.publicMethodSync(name, accept, requestOptions, Context.NONE); + return service.publicMethodSync(this.client.getEndpoint(), name, accept, requestOptions, Context.NONE); } /** @@ -165,7 +167,8 @@ public Response publicMethodWithResponse(String name, RequestOptions @ServiceMethod(returns = ReturnType.SINGLE) public Mono> internalWithResponseAsync(String name, RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.internal(name, accept, requestOptions, context)); + return FluxUtil + .withContext(context -> service.internal(this.client.getEndpoint(), name, accept, requestOptions, context)); } /** @@ -189,6 +192,6 @@ public Mono> internalWithResponseAsync(String name, Request @ServiceMethod(returns = ReturnType.SINGLE) public Response internalWithResponse(String name, RequestOptions requestOptions) { final String accept = "application/json"; - return service.internalSync(name, accept, requestOptions, Context.NONE); + return service.internalSync(this.client.getEndpoint(), name, accept, requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/_specs_/azure/clientgenerator/core/usage/UsageClientBuilder.java b/typespec-tests/src/main/java/com/_specs_/azure/clientgenerator/core/usage/UsageClientBuilder.java index 2c0f549df6..16d7b3ae9c 100644 --- a/typespec-tests/src/main/java/com/_specs_/azure/clientgenerator/core/usage/UsageClientBuilder.java +++ b/typespec-tests/src/main/java/com/_specs_/azure/clientgenerator/core/usage/UsageClientBuilder.java @@ -8,6 +8,7 @@ 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; @@ -40,7 +41,8 @@ * A builder for creating a new instance of the UsageClient type. */ @ServiceClientBuilder(serviceClients = { UsageClient.class, UsageAsyncClient.class }) -public final class UsageClientBuilder implements HttpTrait, ConfigurationTrait { +public final class UsageClientBuilder implements HttpTrait, ConfigurationTrait, + EndpointTrait { @Generated private static final String SDK_NAME = "name"; @@ -172,6 +174,22 @@ public UsageClientBuilder configuration(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. */ @@ -199,7 +217,9 @@ public UsageClientBuilder retryPolicy(RetryPolicy retryPolicy) { private UsageClientImpl buildInnerClient() { this.validateClient(); HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); - UsageClientImpl client = new UsageClientImpl(localPipeline, JacksonAdapter.createDefaultSerializerAdapter()); + String localEndpoint = (endpoint != null) ? endpoint : "http://localhost:3000"; + UsageClientImpl client + = new UsageClientImpl(localPipeline, JacksonAdapter.createDefaultSerializerAdapter(), localEndpoint); return client; } diff --git a/typespec-tests/src/main/java/com/_specs_/azure/clientgenerator/core/usage/implementation/ModelInOperationsImpl.java b/typespec-tests/src/main/java/com/_specs_/azure/clientgenerator/core/usage/implementation/ModelInOperationsImpl.java index a7ae1be7ef..4c8f3a930b 100644 --- a/typespec-tests/src/main/java/com/_specs_/azure/clientgenerator/core/usage/implementation/ModelInOperationsImpl.java +++ b/typespec-tests/src/main/java/com/_specs_/azure/clientgenerator/core/usage/implementation/ModelInOperationsImpl.java @@ -9,6 +9,7 @@ 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; @@ -56,7 +57,7 @@ public final class ModelInOperationsImpl { * The interface defining all the services for UsageClientModelInOperations to be used by the proxy service to * perform REST calls. */ - @Host("http://localhost:3000") + @Host("{endpoint}") @ServiceInterface(name = "UsageClientModelInOp") public interface ModelInOperationsService { @Post("/azure/client-generator-core/usage/inputToInputOutput") @@ -65,8 +66,9 @@ public interface ModelInOperationsService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> inputToInputOutput(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + 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 }) @@ -74,8 +76,9 @@ Mono> inputToInputOutput(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response inputToInputOutputSync(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + 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 }) @@ -83,8 +86,8 @@ Response inputToInputOutputSync(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> outputToInputOutput(@HeaderParam("accept") String accept, - RequestOptions requestOptions, Context context); + Mono> outputToInputOutput(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Get("/azure/client-generator-core/usage/outputToInputOutput") @ExpectedResponses({ 200 }) @@ -92,8 +95,8 @@ Mono> outputToInputOutput(@HeaderParam("accept") String acc @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response outputToInputOutputSync(@HeaderParam("accept") String accept, - RequestOptions requestOptions, Context context); + Response outputToInputOutputSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Put("/azure/client-generator-core/usage/modelInReadOnlyProperty") @ExpectedResponses({ 200 }) @@ -101,7 +104,8 @@ Response outputToInputOutputSync(@HeaderParam("accept") String accep @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> modelInReadOnlyProperty(@HeaderParam("accept") String accept, + 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") @@ -110,7 +114,8 @@ Mono> modelInReadOnlyProperty(@HeaderParam("accept") String @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response modelInReadOnlyPropertySync(@HeaderParam("accept") String accept, + Response modelInReadOnlyPropertySync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); } @@ -139,8 +144,9 @@ Response modelInReadOnlyPropertySync(@HeaderParam("accept") String a */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> inputToInputOutputWithResponseAsync(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.inputToInputOutput(accept, body, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil.withContext(context -> service.inputToInputOutput(this.client.getEndpoint(), contentType, body, + requestOptions, context)); } /** @@ -168,8 +174,9 @@ public Mono> inputToInputOutputWithResponseAsync(BinaryData body, */ @ServiceMethod(returns = ReturnType.SINGLE) public Response inputToInputOutputWithResponse(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.inputToInputOutputSync(accept, body, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.inputToInputOutputSync(this.client.getEndpoint(), contentType, body, requestOptions, + Context.NONE); } /** @@ -197,7 +204,8 @@ public Response inputToInputOutputWithResponse(BinaryData body, RequestOpt @ServiceMethod(returns = ReturnType.SINGLE) public Mono> outputToInputOutputWithResponseAsync(RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.outputToInputOutput(accept, requestOptions, context)); + return FluxUtil.withContext( + context -> service.outputToInputOutput(this.client.getEndpoint(), accept, requestOptions, context)); } /** @@ -225,7 +233,7 @@ public Mono> outputToInputOutputWithResponseAsync(RequestOp @ServiceMethod(returns = ReturnType.SINGLE) public Response outputToInputOutputWithResponse(RequestOptions requestOptions) { final String accept = "application/json"; - return service.outputToInputOutputSync(accept, requestOptions, Context.NONE); + return service.outputToInputOutputSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); } /** @@ -276,8 +284,10 @@ public Response outputToInputOutputWithResponse(RequestOptions reque @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(accept, body, requestOptions, context)); + return FluxUtil.withContext(context -> service.modelInReadOnlyProperty(this.client.getEndpoint(), contentType, + accept, body, requestOptions, context)); } /** @@ -327,7 +337,9 @@ public Mono> modelInReadOnlyPropertyWithResponseAsync(Binar */ @ServiceMethod(returns = ReturnType.SINGLE) public Response modelInReadOnlyPropertyWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; final String accept = "application/json"; - return service.modelInReadOnlyPropertySync(accept, body, requestOptions, Context.NONE); + return service.modelInReadOnlyPropertySync(this.client.getEndpoint(), contentType, accept, body, requestOptions, + Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/_specs_/azure/clientgenerator/core/usage/implementation/UsageClientImpl.java b/typespec-tests/src/main/java/com/_specs_/azure/clientgenerator/core/usage/implementation/UsageClientImpl.java index 98db3aa8b3..72ec8e251a 100644 --- a/typespec-tests/src/main/java/com/_specs_/azure/clientgenerator/core/usage/implementation/UsageClientImpl.java +++ b/typespec-tests/src/main/java/com/_specs_/azure/clientgenerator/core/usage/implementation/UsageClientImpl.java @@ -15,6 +15,20 @@ * 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. */ @@ -59,19 +73,22 @@ public ModelInOperationsImpl getModelInOperations() { /** * Initializes an instance of UsageClient client. + * + * @param endpoint Service host. */ - public UsageClientImpl() { + public UsageClientImpl(String endpoint) { this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), - JacksonAdapter.createDefaultSerializerAdapter()); + 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) { - this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter()); + public UsageClientImpl(HttpPipeline httpPipeline, String endpoint) { + this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint); } /** @@ -79,10 +96,12 @@ public UsageClientImpl(HttpPipeline httpPipeline) { * * @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) { + 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/typespec-tests/src/main/java/com/_specs_/azure/core/basic/BasicAsyncClient.java b/typespec-tests/src/main/java/com/_specs_/azure/core/basic/BasicAsyncClient.java index 2aef4c727d..fb9519930c 100644 --- a/typespec-tests/src/main/java/com/_specs_/azure/core/basic/BasicAsyncClient.java +++ b/typespec-tests/src/main/java/com/_specs_/azure/core/basic/BasicAsyncClient.java @@ -180,7 +180,9 @@ public Mono> createOrReplaceWithResponse(int id, BinaryData * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. * @throws ResourceNotFoundException thrown if the 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 along with {@link Response} on successful completion of {@link Mono}. + * @return a user. + * + * Gets a User along with {@link Response} on successful completion of {@link Mono}. */ @Generated @ServiceMethod(returns = ReturnType.SINGLE) @@ -359,7 +361,9 @@ public Mono createOrReplace(int id, User resource) { * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. * @throws ResourceModifiedException thrown if the request 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 on successful completion of {@link Mono}. + * @return a user. + * + * Gets a User on successful completion of {@link Mono}. */ @Generated @ServiceMethod(returns = ReturnType.SINGLE) diff --git a/typespec-tests/src/main/java/com/_specs_/azure/core/basic/BasicClient.java b/typespec-tests/src/main/java/com/_specs_/azure/core/basic/BasicClient.java index d85ff77d03..5dec8c6178 100644 --- a/typespec-tests/src/main/java/com/_specs_/azure/core/basic/BasicClient.java +++ b/typespec-tests/src/main/java/com/_specs_/azure/core/basic/BasicClient.java @@ -173,7 +173,9 @@ public Response createOrReplaceWithResponse(int id, BinaryData resou * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. * @throws ResourceNotFoundException thrown if the 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 along with {@link Response}. + * @return a user. + * + * Gets a User along with {@link Response}. */ @Generated @ServiceMethod(returns = ReturnType.SINGLE) @@ -350,7 +352,9 @@ public User createOrReplace(int id, User resource) { * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. * @throws ResourceModifiedException thrown if the request 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. + * @return a user. + * + * Gets a User. */ @Generated @ServiceMethod(returns = ReturnType.SINGLE) diff --git a/typespec-tests/src/main/java/com/_specs_/azure/core/basic/BasicClientBuilder.java b/typespec-tests/src/main/java/com/_specs_/azure/core/basic/BasicClientBuilder.java index 4ad1db38c1..8afed75e1f 100644 --- a/typespec-tests/src/main/java/com/_specs_/azure/core/basic/BasicClientBuilder.java +++ b/typespec-tests/src/main/java/com/_specs_/azure/core/basic/BasicClientBuilder.java @@ -8,6 +8,7 @@ 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; @@ -40,7 +41,8 @@ * A builder for creating a new instance of the BasicClient type. */ @ServiceClientBuilder(serviceClients = { BasicClient.class, BasicAsyncClient.class }) -public final class BasicClientBuilder implements HttpTrait, ConfigurationTrait { +public final class BasicClientBuilder implements HttpTrait, ConfigurationTrait, + EndpointTrait { @Generated private static final String SDK_NAME = "name"; @@ -172,6 +174,22 @@ public BasicClientBuilder configuration(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 */ @@ -217,10 +235,11 @@ public BasicClientBuilder retryPolicy(RetryPolicy retryPolicy) { 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(), localServiceVersion); + BasicClientImpl client = new BasicClientImpl(localPipeline, JacksonAdapter.createDefaultSerializerAdapter(), + localEndpoint, localServiceVersion); return client; } diff --git a/typespec-tests/src/main/java/com/_specs_/azure/core/basic/implementation/BasicClientImpl.java b/typespec-tests/src/main/java/com/_specs_/azure/core/basic/implementation/BasicClientImpl.java index 0f21b5cd49..20ae11448b 100644 --- a/typespec-tests/src/main/java/com/_specs_/azure/core/basic/implementation/BasicClientImpl.java +++ b/typespec-tests/src/main/java/com/_specs_/azure/core/basic/implementation/BasicClientImpl.java @@ -11,6 +11,7 @@ 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; @@ -55,6 +56,20 @@ public final class BasicClientImpl { */ 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. */ @@ -100,21 +115,23 @@ public SerializerAdapter getSerializerAdapter() { /** * Initializes an instance of BasicClient client. * + * @param endpoint Service host. * @param serviceVersion Service version. */ - public BasicClientImpl(BasicServiceVersion serviceVersion) { + public BasicClientImpl(String endpoint, BasicServiceVersion serviceVersion) { this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), - JacksonAdapter.createDefaultSerializerAdapter(), serviceVersion); + 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, BasicServiceVersion serviceVersion) { - this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), serviceVersion); + public BasicClientImpl(HttpPipeline httpPipeline, String endpoint, BasicServiceVersion serviceVersion) { + this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint, serviceVersion); } /** @@ -122,12 +139,14 @@ public BasicClientImpl(HttpPipeline httpPipeline, BasicServiceVersion serviceVer * * @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, + 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()); } @@ -135,7 +154,7 @@ public BasicClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAd /** * The interface defining all the services for BasicClient to be used by the proxy service to perform REST calls. */ - @Host("http://localhost:3000") + @Host("{endpoint}") @ServiceInterface(name = "BasicClient") public interface BasicClientService { @Patch("/azure/core/basic/users/{id}") @@ -144,8 +163,9 @@ public interface BasicClientService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> createOrUpdate(@QueryParam("api-version") String apiVersion, @PathParam("id") int id, - @HeaderParam("Content-Type") String contentType, @HeaderParam("accept") String accept, + 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); @@ -155,8 +175,9 @@ Mono> createOrUpdate(@QueryParam("api-version") String apiV @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response createOrUpdateSync(@QueryParam("api-version") String apiVersion, @PathParam("id") int id, - @HeaderParam("Content-Type") String contentType, @HeaderParam("accept") String accept, + 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); @@ -166,8 +187,9 @@ Response createOrUpdateSync(@QueryParam("api-version") String apiVer @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> createOrReplace(@QueryParam("api-version") String apiVersion, - @PathParam("id") int id, @HeaderParam("accept") String accept, + 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}") @@ -176,9 +198,10 @@ Mono> createOrReplace(@QueryParam("api-version") String api @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response createOrReplaceSync(@QueryParam("api-version") String apiVersion, @PathParam("id") int id, - @HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData resource, - RequestOptions requestOptions, Context context); + 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 }) @@ -186,8 +209,9 @@ Response createOrReplaceSync(@QueryParam("api-version") String apiVe @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> get(@QueryParam("api-version") String apiVersion, @PathParam("id") int id, - @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + 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 }) @@ -195,8 +219,9 @@ Mono> get(@QueryParam("api-version") String apiVersion, @Pa @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response getSync(@QueryParam("api-version") String apiVersion, @PathParam("id") int id, - @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + 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 }) @@ -204,8 +229,9 @@ Response getSync(@QueryParam("api-version") String apiVersion, @Path @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> list(@QueryParam("api-version") String apiVersion, - @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + 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 }) @@ -213,8 +239,9 @@ Mono> list(@QueryParam("api-version") String apiVersion, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response listSync(@QueryParam("api-version") String apiVersion, - @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + 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 }) @@ -222,8 +249,9 @@ Response listSync(@QueryParam("api-version") String apiVersion, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> delete(@QueryParam("api-version") String apiVersion, @PathParam("id") int id, - @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + 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 }) @@ -231,8 +259,9 @@ Mono> delete(@QueryParam("api-version") String apiVersion, @PathP @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response deleteSync(@QueryParam("api-version") String apiVersion, @PathParam("id") int id, - @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + 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 }) @@ -240,9 +269,9 @@ Response deleteSync(@QueryParam("api-version") String apiVersion, @PathPar @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> export(@QueryParam("api-version") String apiVersion, @PathParam("id") int id, - @QueryParam("format") String format, @HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + 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 }) @@ -250,9 +279,9 @@ Mono> export(@QueryParam("api-version") String apiVersion, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response exportSync(@QueryParam("api-version") String apiVersion, @PathParam("id") int id, - @QueryParam("format") String format, @HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + 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 }) @@ -261,7 +290,8 @@ Response exportSync(@QueryParam("api-version") String apiVersion, @P @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Mono> listNext(@PathParam(value = "nextLink", encoded = true) String nextLink, - @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + @HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, RequestOptions requestOptions, + Context context); @Get("{nextLink}") @ExpectedResponses({ 200 }) @@ -270,7 +300,8 @@ Mono> listNext(@PathParam(value = "nextLink", encoded = tru @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Response listNextSync(@PathParam(value = "nextLink", encoded = true) String nextLink, - @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + @HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, RequestOptions requestOptions, + Context context); } /** @@ -325,8 +356,8 @@ public Mono> createOrUpdateWithResponseAsync(int id, Binary RequestOptions requestOptions) { final String contentType = "application/merge-patch+json"; final String accept = "application/json"; - return FluxUtil.withContext(context -> service.createOrUpdate(this.getServiceVersion().getVersion(), id, - contentType, accept, resource, requestOptions, context)); + return FluxUtil.withContext(context -> service.createOrUpdate(this.getEndpoint(), + this.getServiceVersion().getVersion(), id, contentType, accept, resource, requestOptions, context)); } /** @@ -380,8 +411,8 @@ public Mono> createOrUpdateWithResponseAsync(int id, Binary 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.getServiceVersion().getVersion(), id, contentType, accept, resource, - requestOptions, Context.NONE); + return service.createOrUpdateSync(this.getEndpoint(), this.getServiceVersion().getVersion(), id, contentType, + accept, resource, requestOptions, Context.NONE); } /** @@ -434,9 +465,10 @@ public Response createOrUpdateWithResponse(int id, BinaryData resour @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.getServiceVersion().getVersion(), id, - accept, resource, requestOptions, context)); + return FluxUtil.withContext(context -> service.createOrReplace(this.getEndpoint(), + this.getServiceVersion().getVersion(), id, contentType, accept, resource, requestOptions, context)); } /** @@ -489,9 +521,10 @@ public Mono> createOrReplaceWithResponseAsync(int id, Binar @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.getServiceVersion().getVersion(), id, accept, resource, requestOptions, - Context.NONE); + return service.createOrReplaceSync(this.getEndpoint(), this.getServiceVersion().getVersion(), id, contentType, + accept, resource, requestOptions, Context.NONE); } /** @@ -521,13 +554,15 @@ public Response createOrReplaceWithResponse(int id, BinaryData resou * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. * @throws ResourceNotFoundException thrown if the 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 along with {@link Response} on successful completion of {@link Mono}. + * @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.getServiceVersion().getVersion(), id, accept, requestOptions, context)); + return FluxUtil.withContext(context -> service.get(this.getEndpoint(), this.getServiceVersion().getVersion(), + id, accept, requestOptions, context)); } /** @@ -557,12 +592,15 @@ public Mono> getWithResponseAsync(int id, RequestOptions re * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. * @throws ResourceNotFoundException thrown if the 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 along with {@link Response}. + * @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.getServiceVersion().getVersion(), id, accept, requestOptions, Context.NONE); + return service.getSync(this.getEndpoint(), this.getServiceVersion().getVersion(), id, accept, requestOptions, + Context.NONE); } /** @@ -613,8 +651,8 @@ public Response getWithResponse(int id, RequestOptions requestOption private Mono> listSinglePageAsync(RequestOptions requestOptions) { final String accept = "application/json"; return FluxUtil - .withContext( - context -> service.list(this.getServiceVersion().getVersion(), accept, requestOptions, context)) + .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)); } @@ -739,8 +777,8 @@ public PagedFlux listAsync(RequestOptions requestOptions) { @ServiceMethod(returns = ReturnType.SINGLE) private PagedResponse listSinglePage(RequestOptions requestOptions) { final String accept = "application/json"; - Response res - = service.listSync(this.getServiceVersion().getVersion(), accept, requestOptions, Context.NONE); + 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); } @@ -834,8 +872,8 @@ public PagedIterable list(RequestOptions requestOptions) { @ServiceMethod(returns = ReturnType.SINGLE) public Mono> deleteWithResponseAsync(int id, RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext( - context -> service.delete(this.getServiceVersion().getVersion(), id, accept, requestOptions, context)); + return FluxUtil.withContext(context -> service.delete(this.getEndpoint(), this.getServiceVersion().getVersion(), + id, accept, requestOptions, context)); } /** @@ -854,7 +892,8 @@ public Mono> deleteWithResponseAsync(int id, RequestOptions reque @ServiceMethod(returns = ReturnType.SINGLE) public Response deleteWithResponse(int id, RequestOptions requestOptions) { final String accept = "application/json"; - return service.deleteSync(this.getServiceVersion().getVersion(), id, accept, requestOptions, Context.NONE); + return service.deleteSync(this.getEndpoint(), this.getServiceVersion().getVersion(), id, accept, requestOptions, + Context.NONE); } /** @@ -890,8 +929,8 @@ public Response deleteWithResponse(int id, RequestOptions requestOptions) @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.getServiceVersion().getVersion(), id, format, accept, - requestOptions, context)); + return FluxUtil.withContext(context -> service.export(this.getEndpoint(), this.getServiceVersion().getVersion(), + id, format, accept, requestOptions, context)); } /** @@ -927,8 +966,8 @@ public Mono> exportWithResponseAsync(int id, String format, @ServiceMethod(returns = ReturnType.SINGLE) public Response exportWithResponse(int id, String format, RequestOptions requestOptions) { final String accept = "application/json"; - return service.exportSync(this.getServiceVersion().getVersion(), id, format, accept, requestOptions, - Context.NONE); + return service.exportSync(this.getEndpoint(), this.getServiceVersion().getVersion(), id, format, accept, + requestOptions, Context.NONE); } /** @@ -963,7 +1002,8 @@ public Response exportWithResponse(int id, String format, RequestOpt @ServiceMethod(returns = ReturnType.SINGLE) private Mono> listNextSinglePageAsync(String nextLink, RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.listNext(nextLink, accept, requestOptions, context)) + 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)); } @@ -1000,7 +1040,8 @@ private Mono> listNextSinglePageAsync(String nextLink, @ServiceMethod(returns = ReturnType.SINGLE) private PagedResponse listNextSinglePage(String nextLink, RequestOptions requestOptions) { final String accept = "application/json"; - Response res = service.listNextSync(nextLink, accept, requestOptions, Context.NONE); + 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); } diff --git a/typespec-tests/src/main/java/com/_specs_/azure/core/lro/rpc/RpcClientBuilder.java b/typespec-tests/src/main/java/com/_specs_/azure/core/lro/rpc/RpcClientBuilder.java index 681162180a..7bb66a0108 100644 --- a/typespec-tests/src/main/java/com/_specs_/azure/core/lro/rpc/RpcClientBuilder.java +++ b/typespec-tests/src/main/java/com/_specs_/azure/core/lro/rpc/RpcClientBuilder.java @@ -8,6 +8,7 @@ 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; @@ -40,7 +41,8 @@ * A builder for creating a new instance of the RpcClient type. */ @ServiceClientBuilder(serviceClients = { RpcClient.class, RpcAsyncClient.class }) -public final class RpcClientBuilder implements HttpTrait, ConfigurationTrait { +public final class RpcClientBuilder + implements HttpTrait, ConfigurationTrait, EndpointTrait { @Generated private static final String SDK_NAME = "name"; @@ -172,6 +174,22 @@ public RpcClientBuilder configuration(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 */ @@ -217,10 +235,11 @@ public RpcClientBuilder retryPolicy(RetryPolicy retryPolicy) { 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(), localServiceVersion); + RpcClientImpl client = new RpcClientImpl(localPipeline, JacksonAdapter.createDefaultSerializerAdapter(), + localEndpoint, localServiceVersion); return client; } diff --git a/typespec-tests/src/main/java/com/_specs_/azure/core/lro/rpc/implementation/RpcClientImpl.java b/typespec-tests/src/main/java/com/_specs_/azure/core/lro/rpc/implementation/RpcClientImpl.java index f45eb321ed..c8f5a11840 100644 --- a/typespec-tests/src/main/java/com/_specs_/azure/core/lro/rpc/implementation/RpcClientImpl.java +++ b/typespec-tests/src/main/java/com/_specs_/azure/core/lro/rpc/implementation/RpcClientImpl.java @@ -10,6 +10,7 @@ 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; @@ -49,6 +50,20 @@ public final class RpcClientImpl { */ 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. */ @@ -94,21 +109,23 @@ public SerializerAdapter getSerializerAdapter() { /** * Initializes an instance of RpcClient client. * + * @param endpoint Service host. * @param serviceVersion Service version. */ - public RpcClientImpl(RpcServiceVersion serviceVersion) { + public RpcClientImpl(String endpoint, RpcServiceVersion serviceVersion) { this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), - JacksonAdapter.createDefaultSerializerAdapter(), serviceVersion); + 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, RpcServiceVersion serviceVersion) { - this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), serviceVersion); + public RpcClientImpl(HttpPipeline httpPipeline, String endpoint, RpcServiceVersion serviceVersion) { + this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint, serviceVersion); } /** @@ -116,12 +133,14 @@ public RpcClientImpl(HttpPipeline httpPipeline, RpcServiceVersion serviceVersion * * @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, + 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()); } @@ -129,7 +148,7 @@ public RpcClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdap /** * The interface defining all the services for RpcClient to be used by the proxy service to perform REST calls. */ - @Host("http://localhost:3000") + @Host("{endpoint}") @ServiceInterface(name = "RpcClient") public interface RpcClientService { @Post("/azure/core/lro/rpc/generations:submit") @@ -138,8 +157,9 @@ public interface RpcClientService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> longRunningRpc(@QueryParam("api-version") String apiVersion, - @HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, + 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") @@ -148,8 +168,9 @@ Mono> longRunningRpc(@QueryParam("api-version") String apiV @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response longRunningRpcSync(@QueryParam("api-version") String apiVersion, - @HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, + 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); } @@ -194,9 +215,10 @@ Response longRunningRpcSync(@QueryParam("api-version") String apiVer */ @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.getServiceVersion().getVersion(), accept, - body, requestOptions, context)); + return FluxUtil.withContext(context -> service.longRunningRpc(this.getEndpoint(), + this.getServiceVersion().getVersion(), contentType, accept, body, requestOptions, context)); } /** @@ -239,9 +261,10 @@ private Mono> longRunningRpcWithResponseAsync(BinaryData bo */ @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.getServiceVersion().getVersion(), accept, body, requestOptions, - Context.NONE); + return service.longRunningRpcSync(this.getEndpoint(), this.getServiceVersion().getVersion(), contentType, + accept, body, requestOptions, Context.NONE); } /** @@ -288,7 +311,7 @@ public PollerFlux beginLongRunningRpcAsync(BinaryData bo () -> 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) @@ -341,7 +364,7 @@ public SyncPoller beginLongRunningRpc(BinaryData body, R () -> 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) @@ -395,7 +418,7 @@ public PollerFlux beginLongRunningRpcWit () -> 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) @@ -450,7 +473,7 @@ public SyncPoller beginLongRunningRpcWit () -> 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) diff --git a/typespec-tests/src/main/java/com/_specs_/azure/core/lro/standard/StandardClientBuilder.java b/typespec-tests/src/main/java/com/_specs_/azure/core/lro/standard/StandardClientBuilder.java index 6ab779db9e..82da25b875 100644 --- a/typespec-tests/src/main/java/com/_specs_/azure/core/lro/standard/StandardClientBuilder.java +++ b/typespec-tests/src/main/java/com/_specs_/azure/core/lro/standard/StandardClientBuilder.java @@ -8,6 +8,7 @@ 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; @@ -40,8 +41,8 @@ * A builder for creating a new instance of the StandardClient type. */ @ServiceClientBuilder(serviceClients = { StandardClient.class, StandardAsyncClient.class }) -public final class StandardClientBuilder - implements HttpTrait, ConfigurationTrait { +public final class StandardClientBuilder implements HttpTrait, + ConfigurationTrait, EndpointTrait { @Generated private static final String SDK_NAME = "name"; @@ -173,6 +174,22 @@ public StandardClientBuilder configuration(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 */ @@ -218,10 +235,11 @@ public StandardClientBuilder retryPolicy(RetryPolicy retryPolicy) { 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(), localServiceVersion); + JacksonAdapter.createDefaultSerializerAdapter(), localEndpoint, localServiceVersion); return client; } diff --git a/typespec-tests/src/main/java/com/_specs_/azure/core/lro/standard/implementation/StandardClientImpl.java b/typespec-tests/src/main/java/com/_specs_/azure/core/lro/standard/implementation/StandardClientImpl.java index f66dfb0fe8..f7e54a273b 100644 --- a/typespec-tests/src/main/java/com/_specs_/azure/core/lro/standard/implementation/StandardClientImpl.java +++ b/typespec-tests/src/main/java/com/_specs_/azure/core/lro/standard/implementation/StandardClientImpl.java @@ -12,6 +12,7 @@ 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; @@ -53,6 +54,20 @@ public final class StandardClientImpl { */ 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. */ @@ -98,21 +113,23 @@ public SerializerAdapter getSerializerAdapter() { /** * Initializes an instance of StandardClient client. * + * @param endpoint Service host. * @param serviceVersion Service version. */ - public StandardClientImpl(StandardServiceVersion serviceVersion) { + public StandardClientImpl(String endpoint, StandardServiceVersion serviceVersion) { this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), - JacksonAdapter.createDefaultSerializerAdapter(), serviceVersion); + 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, StandardServiceVersion serviceVersion) { - this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), serviceVersion); + public StandardClientImpl(HttpPipeline httpPipeline, String endpoint, StandardServiceVersion serviceVersion) { + this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint, serviceVersion); } /** @@ -120,12 +137,14 @@ public StandardClientImpl(HttpPipeline httpPipeline, StandardServiceVersion serv * * @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, + 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()); } @@ -133,7 +152,7 @@ public StandardClientImpl(HttpPipeline httpPipeline, SerializerAdapter serialize /** * The interface defining all the services for StandardClient to be used by the proxy service to perform REST calls. */ - @Host("http://localhost:3000") + @Host("{endpoint}") @ServiceInterface(name = "StandardClient") public interface StandardClientService { @Put("/azure/core/lro/standard/users/{name}") @@ -142,8 +161,9 @@ public interface StandardClientService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> createOrReplace(@QueryParam("api-version") String apiVersion, - @PathParam("name") String name, @HeaderParam("accept") String accept, + 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}") @@ -152,8 +172,9 @@ Mono> createOrReplace(@QueryParam("api-version") String api @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response createOrReplaceSync(@QueryParam("api-version") String apiVersion, - @PathParam("name") String name, @HeaderParam("accept") String accept, + 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}") @@ -162,8 +183,9 @@ Response createOrReplaceSync(@QueryParam("api-version") String apiVe @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> delete(@QueryParam("api-version") String apiVersion, @PathParam("name") String name, - @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + 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 }) @@ -171,8 +193,9 @@ Mono> delete(@QueryParam("api-version") String apiVersion, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response deleteSync(@QueryParam("api-version") String apiVersion, @PathParam("name") String name, - @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + 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 }) @@ -180,8 +203,9 @@ Response deleteSync(@QueryParam("api-version") String apiVersion, @P @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> export(@QueryParam("api-version") String apiVersion, @PathParam("name") String name, - @QueryParam("format") String format, @HeaderParam("accept") String accept, RequestOptions requestOptions, + 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") @@ -190,8 +214,9 @@ Mono> export(@QueryParam("api-version") String apiVersion, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response exportSync(@QueryParam("api-version") String apiVersion, @PathParam("name") String name, - @QueryParam("format") String format, @HeaderParam("accept") String accept, RequestOptions requestOptions, + 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); } @@ -229,9 +254,10 @@ Response exportSync(@QueryParam("api-version") String apiVersion, @P @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.getServiceVersion().getVersion(), name, - accept, resource, requestOptions, context)); + return FluxUtil.withContext(context -> service.createOrReplace(this.getEndpoint(), + this.getServiceVersion().getVersion(), name, contentType, accept, resource, requestOptions, context)); } /** @@ -268,9 +294,10 @@ private Mono> createOrReplaceWithResponseAsync(String name, @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.getServiceVersion().getVersion(), name, accept, resource, - requestOptions, Context.NONE); + return service.createOrReplaceSync(this.getEndpoint(), this.getServiceVersion().getVersion(), name, contentType, + accept, resource, requestOptions, Context.NONE); } /** @@ -311,7 +338,7 @@ public PollerFlux beginCreateOrReplaceAsync(String name, () -> 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) @@ -357,7 +384,7 @@ public SyncPoller beginCreateOrReplace(String name, Bina () -> 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) @@ -403,7 +430,7 @@ public PollerFlux beginCreateOrReplaceWithModelAsync () -> 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) @@ -449,7 +476,7 @@ public SyncPoller beginCreateOrReplaceWithModel(Stri () -> 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) @@ -490,8 +517,8 @@ public SyncPoller beginCreateOrReplaceWithModel(Stri @ServiceMethod(returns = ReturnType.SINGLE) private Mono> deleteWithResponseAsync(String name, RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext( - context -> service.delete(this.getServiceVersion().getVersion(), name, accept, requestOptions, context)); + return FluxUtil.withContext(context -> service.delete(this.getEndpoint(), this.getServiceVersion().getVersion(), + name, accept, requestOptions, context)); } /** @@ -526,7 +553,8 @@ private Mono> deleteWithResponseAsync(String name, RequestO @ServiceMethod(returns = ReturnType.SINGLE) private Response deleteWithResponse(String name, RequestOptions requestOptions) { final String accept = "application/json"; - return service.deleteSync(this.getServiceVersion().getVersion(), name, accept, requestOptions, Context.NONE); + return service.deleteSync(this.getEndpoint(), this.getServiceVersion().getVersion(), name, accept, + requestOptions, Context.NONE); } /** @@ -563,7 +591,7 @@ public PollerFlux beginDeleteAsync(String name, 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) @@ -605,7 +633,7 @@ public SyncPoller beginDelete(String name, RequestOptions requ 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) @@ -648,7 +676,7 @@ public PollerFlux beginDeleteWithModelAsync(String n 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) @@ -690,7 +718,7 @@ public SyncPoller beginDeleteWithModel(String name, 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) @@ -737,8 +765,8 @@ public SyncPoller beginDeleteWithModel(String name, private Mono> exportWithResponseAsync(String name, String format, RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.export(this.getServiceVersion().getVersion(), name, format, - accept, requestOptions, context)); + return FluxUtil.withContext(context -> service.export(this.getEndpoint(), this.getServiceVersion().getVersion(), + name, format, accept, requestOptions, context)); } /** @@ -778,8 +806,8 @@ private Mono> exportWithResponseAsync(String name, String f @ServiceMethod(returns = ReturnType.SINGLE) private Response exportWithResponse(String name, String format, RequestOptions requestOptions) { final String accept = "application/json"; - return service.exportSync(this.getServiceVersion().getVersion(), name, format, accept, requestOptions, - Context.NONE); + return service.exportSync(this.getEndpoint(), this.getServiceVersion().getVersion(), name, format, accept, + requestOptions, Context.NONE); } /** @@ -823,7 +851,7 @@ public PollerFlux beginExportAsync(String name, String f () -> 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) @@ -872,7 +900,7 @@ public SyncPoller beginExport(String name, String format () -> 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) @@ -922,7 +950,7 @@ public PollerFlux beginExportWithModelAsync( () -> 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) @@ -972,7 +1000,7 @@ public SyncPoller beginExportWithModel(Strin () -> 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) diff --git a/typespec-tests/src/main/java/com/_specs_/azure/core/model/ModelClientBuilder.java b/typespec-tests/src/main/java/com/_specs_/azure/core/model/ModelClientBuilder.java index 24a5ebd756..50e42f831f 100644 --- a/typespec-tests/src/main/java/com/_specs_/azure/core/model/ModelClientBuilder.java +++ b/typespec-tests/src/main/java/com/_specs_/azure/core/model/ModelClientBuilder.java @@ -8,6 +8,7 @@ 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; @@ -40,7 +41,8 @@ * A builder for creating a new instance of the ModelClient type. */ @ServiceClientBuilder(serviceClients = { ModelClient.class, ModelAsyncClient.class }) -public final class ModelClientBuilder implements HttpTrait, ConfigurationTrait { +public final class ModelClientBuilder implements HttpTrait, ConfigurationTrait, + EndpointTrait { @Generated private static final String SDK_NAME = "name"; @@ -172,6 +174,22 @@ public ModelClientBuilder configuration(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 */ @@ -217,10 +235,11 @@ public ModelClientBuilder retryPolicy(RetryPolicy retryPolicy) { 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(), localServiceVersion); + ModelClientImpl client = new ModelClientImpl(localPipeline, JacksonAdapter.createDefaultSerializerAdapter(), + localEndpoint, localServiceVersion); return client; } diff --git a/typespec-tests/src/main/java/com/_specs_/azure/core/model/implementation/AzureCoreEmbeddingVectorsImpl.java b/typespec-tests/src/main/java/com/_specs_/azure/core/model/implementation/AzureCoreEmbeddingVectorsImpl.java index 1d5e9da27b..ae6979705b 100644 --- a/typespec-tests/src/main/java/com/_specs_/azure/core/model/implementation/AzureCoreEmbeddingVectorsImpl.java +++ b/typespec-tests/src/main/java/com/_specs_/azure/core/model/implementation/AzureCoreEmbeddingVectorsImpl.java @@ -10,6 +10,7 @@ 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; @@ -66,7 +67,7 @@ public ModelServiceVersion getServiceVersion() { * The interface defining all the services for ModelClientAzureCoreEmbeddingVectors to be used by the proxy service * to perform REST calls. */ - @Host("http://localhost:3000") + @Host("{endpoint}") @ServiceInterface(name = "ModelClientAzureCore") public interface AzureCoreEmbeddingVectorsService { @Get("/azure/core/model/embeddingVector") @@ -75,8 +76,8 @@ public interface AzureCoreEmbeddingVectorsService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> get(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Get("/azure/core/model/embeddingVector") @ExpectedResponses({ 200 }) @@ -84,8 +85,8 @@ Mono> get(@HeaderParam("accept") String accept, RequestOpti @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response getSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Put("/azure/core/model/embeddingVector") @ExpectedResponses({ 204 }) @@ -93,7 +94,8 @@ Response getSync(@HeaderParam("accept") String accept, RequestOption @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> put(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, + 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") @@ -102,8 +104,8 @@ Mono> put(@HeaderParam("accept") String accept, @BodyParam("appli @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response putSync(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, - RequestOptions requestOptions, Context context); + 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 }) @@ -111,7 +113,8 @@ Response putSync(@HeaderParam("accept") String accept, @BodyParam("applica @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> post(@HeaderParam("accept") String accept, + 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") @@ -120,7 +123,8 @@ Mono> post(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response postSync(@HeaderParam("accept") String accept, + Response postSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); } @@ -144,7 +148,7 @@ Response postSync(@HeaderParam("accept") String accept, @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getWithResponseAsync(RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.get(accept, requestOptions, context)); + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); } /** @@ -167,7 +171,7 @@ public Mono> getWithResponseAsync(RequestOptions requestOpt @ServiceMethod(returns = ReturnType.SINGLE) public Response getWithResponse(RequestOptions requestOptions) { final String accept = "application/json"; - return service.getSync(accept, requestOptions, Context.NONE); + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); } /** @@ -190,8 +194,9 @@ public Response getWithResponse(RequestOptions requestOptions) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> putWithResponseAsync(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.put(accept, body, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.put(this.client.getEndpoint(), contentType, body, requestOptions, context)); } /** @@ -214,8 +219,8 @@ public Mono> putWithResponseAsync(BinaryData body, RequestOptions */ @ServiceMethod(returns = ReturnType.SINGLE) public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.putSync(accept, body, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); } /** @@ -250,8 +255,10 @@ public Response putWithResponse(BinaryData body, RequestOptions requestOpt */ @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(accept, body, requestOptions, context)); + return FluxUtil.withContext( + context -> service.post(this.client.getEndpoint(), contentType, accept, body, requestOptions, context)); } /** @@ -286,7 +293,8 @@ public Mono> postWithResponseAsync(BinaryData body, Request */ @ServiceMethod(returns = ReturnType.SINGLE) public Response postWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; final String accept = "application/json"; - return service.postSync(accept, body, requestOptions, Context.NONE); + return service.postSync(this.client.getEndpoint(), contentType, accept, body, requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/_specs_/azure/core/model/implementation/ModelClientImpl.java b/typespec-tests/src/main/java/com/_specs_/azure/core/model/implementation/ModelClientImpl.java index 1453d155e2..5ea0743ef4 100644 --- a/typespec-tests/src/main/java/com/_specs_/azure/core/model/implementation/ModelClientImpl.java +++ b/typespec-tests/src/main/java/com/_specs_/azure/core/model/implementation/ModelClientImpl.java @@ -16,6 +16,20 @@ * 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. */ @@ -75,21 +89,23 @@ public AzureCoreEmbeddingVectorsImpl getAzureCoreEmbeddingVectors() { /** * Initializes an instance of ModelClient client. * + * @param endpoint Service host. * @param serviceVersion Service version. */ - public ModelClientImpl(ModelServiceVersion serviceVersion) { + public ModelClientImpl(String endpoint, ModelServiceVersion serviceVersion) { this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), - JacksonAdapter.createDefaultSerializerAdapter(), serviceVersion); + 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, ModelServiceVersion serviceVersion) { - this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), serviceVersion); + public ModelClientImpl(HttpPipeline httpPipeline, String endpoint, ModelServiceVersion serviceVersion) { + this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint, serviceVersion); } /** @@ -97,12 +113,14 @@ public ModelClientImpl(HttpPipeline httpPipeline, ModelServiceVersion serviceVer * * @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, + 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/typespec-tests/src/main/java/com/_specs_/azure/core/page/PageClientBuilder.java b/typespec-tests/src/main/java/com/_specs_/azure/core/page/PageClientBuilder.java index 177bf2dab8..80b9dd8cec 100644 --- a/typespec-tests/src/main/java/com/_specs_/azure/core/page/PageClientBuilder.java +++ b/typespec-tests/src/main/java/com/_specs_/azure/core/page/PageClientBuilder.java @@ -8,6 +8,7 @@ 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; @@ -45,7 +46,8 @@ TwoModelsAsPageItemClient.class, PageAsyncClient.class, TwoModelsAsPageItemAsyncClient.class }) -public final class PageClientBuilder implements HttpTrait, ConfigurationTrait { +public final class PageClientBuilder + implements HttpTrait, ConfigurationTrait, EndpointTrait { @Generated private static final String SDK_NAME = "name"; @@ -176,6 +178,22 @@ public PageClientBuilder configuration(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 */ @@ -221,10 +239,11 @@ public PageClientBuilder retryPolicy(RetryPolicy retryPolicy) { 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(), localServiceVersion); + PageClientImpl client = new PageClientImpl(localPipeline, JacksonAdapter.createDefaultSerializerAdapter(), + localEndpoint, localServiceVersion); return client; } diff --git a/typespec-tests/src/main/java/com/_specs_/azure/core/page/implementation/PageClientImpl.java b/typespec-tests/src/main/java/com/_specs_/azure/core/page/implementation/PageClientImpl.java index 2993827597..63bf4c0cc1 100644 --- a/typespec-tests/src/main/java/com/_specs_/azure/core/page/implementation/PageClientImpl.java +++ b/typespec-tests/src/main/java/com/_specs_/azure/core/page/implementation/PageClientImpl.java @@ -10,6 +10,7 @@ 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; @@ -50,6 +51,20 @@ public final class PageClientImpl { */ 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. */ @@ -109,21 +124,23 @@ public TwoModelsAsPageItemsImpl getTwoModelsAsPageItems() { /** * Initializes an instance of PageClient client. * + * @param endpoint Service host. * @param serviceVersion Service version. */ - public PageClientImpl(PageServiceVersion serviceVersion) { + public PageClientImpl(String endpoint, PageServiceVersion serviceVersion) { this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), - JacksonAdapter.createDefaultSerializerAdapter(), serviceVersion); + 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, PageServiceVersion serviceVersion) { - this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), serviceVersion); + public PageClientImpl(HttpPipeline httpPipeline, String endpoint, PageServiceVersion serviceVersion) { + this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint, serviceVersion); } /** @@ -131,12 +148,14 @@ public PageClientImpl(HttpPipeline httpPipeline, PageServiceVersion serviceVersi * * @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, + 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()); @@ -145,7 +164,7 @@ public PageClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAda /** * The interface defining all the services for PageClient to be used by the proxy service to perform REST calls. */ - @Host("http://localhost:3000") + @Host("{endpoint}") @ServiceInterface(name = "PageClient") public interface PageClientService { @Get("/azure/core/page/page") @@ -154,8 +173,9 @@ public interface PageClientService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> listWithPage(@QueryParam("api-version") String apiVersion, - @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + 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 }) @@ -163,8 +183,9 @@ Mono> listWithPage(@QueryParam("api-version") String apiVer @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response listWithPageSync(@QueryParam("api-version") String apiVersion, - @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + 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 }) @@ -172,9 +193,9 @@ Response listWithPageSync(@QueryParam("api-version") String apiVersi @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> listWithParameters(@QueryParam("api-version") String apiVersion, - @HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData bodyInput, - RequestOptions requestOptions, Context context); + 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 }) @@ -182,9 +203,9 @@ Mono> listWithParameters(@QueryParam("api-version") String @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response listWithParametersSync(@QueryParam("api-version") String apiVersion, - @HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData bodyInput, - RequestOptions requestOptions, Context context); + 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 }) @@ -192,8 +213,9 @@ Response listWithParametersSync(@QueryParam("api-version") String ap @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> listWithCustomPageModel(@QueryParam("api-version") String apiVersion, - @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + 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 }) @@ -201,8 +223,9 @@ Mono> listWithCustomPageModel(@QueryParam("api-version") St @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response listWithCustomPageModelSync(@QueryParam("api-version") String apiVersion, - @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + Response listWithCustomPageModelSync(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Get("{nextLink}") @ExpectedResponses({ 200 }) @@ -211,7 +234,8 @@ Response listWithCustomPageModelSync(@QueryParam("api-version") Stri @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Mono> listWithPageNext(@PathParam(value = "nextLink", encoded = true) String nextLink, - @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + @HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, RequestOptions requestOptions, + Context context); @Get("{nextLink}") @ExpectedResponses({ 200 }) @@ -220,7 +244,8 @@ Mono> listWithPageNext(@PathParam(value = "nextLink", encod @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Response listWithPageNextSync(@PathParam(value = "nextLink", encoded = true) String nextLink, - @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + @HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, RequestOptions requestOptions, + Context context); @Get("{nextLink}") @ExpectedResponses({ 200 }) @@ -229,8 +254,8 @@ Response listWithPageNextSync(@PathParam(value = "nextLink", encoded @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Mono> listWithParametersNext( - @PathParam(value = "nextLink", encoded = true) String nextLink, @HeaderParam("accept") String accept, - RequestOptions requestOptions, Context context); + @PathParam(value = "nextLink", encoded = true) String nextLink, @HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Get("{nextLink}") @ExpectedResponses({ 200 }) @@ -239,7 +264,8 @@ Mono> listWithParametersNext( @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Response listWithParametersNextSync(@PathParam(value = "nextLink", encoded = true) String nextLink, - @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + @HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, RequestOptions requestOptions, + Context context); @Get("{nextLink}") @ExpectedResponses({ 200 }) @@ -248,8 +274,8 @@ Response listWithParametersNextSync(@PathParam(value = "nextLink", e @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Mono> listWithCustomPageModelNext( - @PathParam(value = "nextLink", encoded = true) String nextLink, @HeaderParam("accept") String accept, - RequestOptions requestOptions, Context context); + @PathParam(value = "nextLink", encoded = true) String nextLink, @HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Get("{nextLink}") @ExpectedResponses({ 200 }) @@ -258,8 +284,8 @@ Mono> listWithCustomPageModelNext( @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Response listWithCustomPageModelNextSync( - @PathParam(value = "nextLink", encoded = true) String nextLink, @HeaderParam("accept") String accept, - RequestOptions requestOptions, Context context); + @PathParam(value = "nextLink", encoded = true) String nextLink, @HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); } /** @@ -292,8 +318,8 @@ Response listWithCustomPageModelNextSync( private Mono> listWithPageSinglePageAsync(RequestOptions requestOptions) { final String accept = "application/json"; return FluxUtil - .withContext( - context -> service.listWithPage(this.getServiceVersion().getVersion(), accept, requestOptions, context)) + .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)); } @@ -362,8 +388,8 @@ public PagedFlux listWithPageAsync(RequestOptions requestOptions) { @ServiceMethod(returns = ReturnType.SINGLE) private PagedResponse listWithPageSinglePage(RequestOptions requestOptions) { final String accept = "application/json"; - Response res - = service.listWithPageSync(this.getServiceVersion().getVersion(), accept, requestOptions, Context.NONE); + 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); } @@ -451,8 +477,8 @@ private Mono> listWithParametersSinglePageAsync(Binary RequestOptions requestOptions) { final String accept = "application/json"; return FluxUtil - .withContext(context -> service.listWithParameters(this.getServiceVersion().getVersion(), accept, bodyInput, - requestOptions, context)) + .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)); } @@ -556,8 +582,8 @@ public PagedFlux listWithParametersAsync(BinaryData bodyInput, Reque private PagedResponse listWithParametersSinglePage(BinaryData bodyInput, RequestOptions requestOptions) { final String accept = "application/json"; - Response res = service.listWithParametersSync(this.getServiceVersion().getVersion(), accept, - bodyInput, requestOptions, Context.NONE); + 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); } @@ -644,8 +670,8 @@ public PagedIterable listWithParameters(BinaryData bodyInput, Reques private Mono> listWithCustomPageModelSinglePageAsync(RequestOptions requestOptions) { final String accept = "application/json"; return FluxUtil - .withContext(context -> service.listWithCustomPageModel(this.getServiceVersion().getVersion(), accept, - requestOptions, context)) + .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)); } @@ -714,8 +740,8 @@ public PagedFlux listWithCustomPageModelAsync(RequestOptions request @ServiceMethod(returns = ReturnType.SINGLE) private PagedResponse listWithCustomPageModelSinglePage(RequestOptions requestOptions) { final String accept = "application/json"; - Response res = service.listWithCustomPageModelSync(this.getServiceVersion().getVersion(), accept, - requestOptions, Context.NONE); + 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); } @@ -756,6 +782,8 @@ public PagedIterable listWithCustomPageModel(RequestOptions requestO } /** + * List with Azure.Core.Page<>. + * * Get the next page of items. *

Response Body Schema

* @@ -786,12 +814,16 @@ public PagedIterable listWithCustomPageModel(RequestOptions requestO private Mono> listWithPageNextSinglePageAsync(String nextLink, RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.listWithPageNext(nextLink, accept, requestOptions, context)) + 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

* @@ -821,12 +853,15 @@ private Mono> listWithPageNextSinglePageAsync(String n @ServiceMethod(returns = ReturnType.SINGLE) private PagedResponse listWithPageNextSinglePage(String nextLink, RequestOptions requestOptions) { final String accept = "application/json"; - Response res = service.listWithPageNextSync(nextLink, accept, requestOptions, Context.NONE); + 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

* @@ -857,13 +892,15 @@ private PagedResponse listWithPageNextSinglePage(String nextLink, Re private Mono> listWithParametersNextSinglePageAsync(String nextLink, RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil - .withContext(context -> service.listWithParametersNext(nextLink, accept, requestOptions, context)) + 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

* @@ -893,12 +930,15 @@ private Mono> listWithParametersNextSinglePageAsync(St @ServiceMethod(returns = ReturnType.SINGLE) private PagedResponse listWithParametersNextSinglePage(String nextLink, RequestOptions requestOptions) { final String accept = "application/json"; - Response res = service.listWithParametersNextSync(nextLink, accept, requestOptions, Context.NONE); + 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

* @@ -930,12 +970,15 @@ private Mono> listWithCustomPageModelNextSinglePageAsy RequestOptions requestOptions) { final String accept = "application/json"; return FluxUtil - .withContext(context -> service.listWithCustomPageModelNext(nextLink, accept, requestOptions, context)) + .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

* @@ -966,8 +1009,8 @@ private Mono> listWithCustomPageModelNextSinglePageAsy private PagedResponse listWithCustomPageModelNextSinglePage(String nextLink, RequestOptions requestOptions) { final String accept = "application/json"; - Response res - = service.listWithCustomPageModelNextSync(nextLink, accept, requestOptions, Context.NONE); + 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); } diff --git a/typespec-tests/src/main/java/com/_specs_/azure/core/page/implementation/TwoModelsAsPageItemsImpl.java b/typespec-tests/src/main/java/com/_specs_/azure/core/page/implementation/TwoModelsAsPageItemsImpl.java index 0fb71fd65c..239ad70130 100644 --- a/typespec-tests/src/main/java/com/_specs_/azure/core/page/implementation/TwoModelsAsPageItemsImpl.java +++ b/typespec-tests/src/main/java/com/_specs_/azure/core/page/implementation/TwoModelsAsPageItemsImpl.java @@ -9,6 +9,7 @@ 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; @@ -72,7 +73,7 @@ public PageServiceVersion getServiceVersion() { * The interface defining all the services for PageClientTwoModelsAsPageItems to be used by the proxy service to * perform REST calls. */ - @Host("http://localhost:3000") + @Host("{endpoint}") @ServiceInterface(name = "PageClientTwoModelsA") public interface TwoModelsAsPageItemsService { @Get("/azure/core/page/first-item") @@ -81,8 +82,9 @@ public interface TwoModelsAsPageItemsService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> listFirstItem(@QueryParam("api-version") String apiVersion, - @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + 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 }) @@ -90,8 +92,9 @@ Mono> listFirstItem(@QueryParam("api-version") String apiVe @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response listFirstItemSync(@QueryParam("api-version") String apiVersion, - @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + 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 }) @@ -99,8 +102,9 @@ Response listFirstItemSync(@QueryParam("api-version") String apiVers @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> listSecondItem(@QueryParam("api-version") String apiVersion, - @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + 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 }) @@ -108,8 +112,9 @@ Mono> listSecondItem(@QueryParam("api-version") String apiV @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response listSecondItemSync(@QueryParam("api-version") String apiVersion, - @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + Response listSecondItemSync(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Get("{nextLink}") @ExpectedResponses({ 200 }) @@ -118,7 +123,8 @@ Response listSecondItemSync(@QueryParam("api-version") String apiVer @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Mono> listFirstItemNext(@PathParam(value = "nextLink", encoded = true) String nextLink, - @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + @HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, RequestOptions requestOptions, + Context context); @Get("{nextLink}") @ExpectedResponses({ 200 }) @@ -127,7 +133,8 @@ Mono> listFirstItemNext(@PathParam(value = "nextLink", enco @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Response listFirstItemNextSync(@PathParam(value = "nextLink", encoded = true) String nextLink, - @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + @HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, RequestOptions requestOptions, + Context context); @Get("{nextLink}") @ExpectedResponses({ 200 }) @@ -136,7 +143,8 @@ Response listFirstItemNextSync(@PathParam(value = "nextLink", encode @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Mono> listSecondItemNext(@PathParam(value = "nextLink", encoded = true) String nextLink, - @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + @HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, RequestOptions requestOptions, + Context context); @Get("{nextLink}") @ExpectedResponses({ 200 }) @@ -145,7 +153,8 @@ Mono> listSecondItemNext(@PathParam(value = "nextLink", enc @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Response listSecondItemNextSync(@PathParam(value = "nextLink", encoded = true) String nextLink, - @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + @HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, RequestOptions requestOptions, + Context context); } /** @@ -171,8 +180,8 @@ Response listSecondItemNextSync(@PathParam(value = "nextLink", encod private Mono> listFirstItemSinglePageAsync(RequestOptions requestOptions) { final String accept = "application/json"; return FluxUtil - .withContext(context -> service.listFirstItem(this.client.getServiceVersion().getVersion(), accept, - requestOptions, context)) + .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)); } @@ -225,8 +234,8 @@ public PagedFlux listFirstItemAsync(RequestOptions requestOptions) { @ServiceMethod(returns = ReturnType.SINGLE) private PagedResponse listFirstItemSinglePage(RequestOptions requestOptions) { final String accept = "application/json"; - Response res = service.listFirstItemSync(this.client.getServiceVersion().getVersion(), accept, - requestOptions, Context.NONE); + 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); } @@ -281,8 +290,8 @@ public PagedIterable listFirstItem(RequestOptions requestOptions) { private Mono> listSecondItemSinglePageAsync(RequestOptions requestOptions) { final String accept = "application/json"; return FluxUtil - .withContext(context -> service.listSecondItem(this.client.getServiceVersion().getVersion(), accept, - requestOptions, context)) + .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)); } @@ -335,8 +344,8 @@ public PagedFlux listSecondItemAsync(RequestOptions requestOptions) @ServiceMethod(returns = ReturnType.SINGLE) private PagedResponse listSecondItemSinglePage(RequestOptions requestOptions) { final String accept = "application/json"; - Response res = service.listSecondItemSync(this.client.getServiceVersion().getVersion(), accept, - requestOptions, Context.NONE); + 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); } @@ -369,6 +378,9 @@ public PagedIterable listSecondItem(RequestOptions requestOptions) { } /** + * 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

* @@ -391,12 +403,16 @@ public PagedIterable listSecondItem(RequestOptions requestOptions) { private Mono> listFirstItemNextSinglePageAsync(String nextLink, RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.listFirstItemNext(nextLink, accept, requestOptions, context)) + 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

* @@ -417,12 +433,16 @@ private Mono> listFirstItemNextSinglePageAsync(String @ServiceMethod(returns = ReturnType.SINGLE) private PagedResponse listFirstItemNextSinglePage(String nextLink, RequestOptions requestOptions) { final String accept = "application/json"; - Response res = service.listFirstItemNextSync(nextLink, accept, requestOptions, Context.NONE); + 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

* @@ -445,12 +465,16 @@ private PagedResponse listFirstItemNextSinglePage(String nextLink, R private Mono> listSecondItemNextSinglePageAsync(String nextLink, RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.listSecondItemNext(nextLink, accept, requestOptions, context)) + 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

* @@ -471,7 +495,8 @@ private Mono> listSecondItemNextSinglePageAsync(String @ServiceMethod(returns = ReturnType.SINGLE) private PagedResponse listSecondItemNextSinglePage(String nextLink, RequestOptions requestOptions) { final String accept = "application/json"; - Response res = service.listSecondItemNextSync(nextLink, accept, requestOptions, Context.NONE); + 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); } diff --git a/typespec-tests/src/main/java/com/_specs_/azure/core/scalar/ScalarClientBuilder.java b/typespec-tests/src/main/java/com/_specs_/azure/core/scalar/ScalarClientBuilder.java index 5fa4135934..e6b649b449 100644 --- a/typespec-tests/src/main/java/com/_specs_/azure/core/scalar/ScalarClientBuilder.java +++ b/typespec-tests/src/main/java/com/_specs_/azure/core/scalar/ScalarClientBuilder.java @@ -8,6 +8,7 @@ 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; @@ -40,8 +41,8 @@ * A builder for creating a new instance of the ScalarClient type. */ @ServiceClientBuilder(serviceClients = { ScalarClient.class, ScalarAsyncClient.class }) -public final class ScalarClientBuilder - implements HttpTrait, ConfigurationTrait { +public final class ScalarClientBuilder implements HttpTrait, + ConfigurationTrait, EndpointTrait { @Generated private static final String SDK_NAME = "name"; @@ -173,6 +174,22 @@ public ScalarClientBuilder configuration(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 */ @@ -218,10 +235,11 @@ public ScalarClientBuilder retryPolicy(RetryPolicy retryPolicy) { 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(), localServiceVersion); + ScalarClientImpl client = new ScalarClientImpl(localPipeline, JacksonAdapter.createDefaultSerializerAdapter(), + localEndpoint, localServiceVersion); return client; } diff --git a/typespec-tests/src/main/java/com/_specs_/azure/core/scalar/implementation/AzureLocationScalarsImpl.java b/typespec-tests/src/main/java/com/_specs_/azure/core/scalar/implementation/AzureLocationScalarsImpl.java index 8ff921c07c..ad6f9f9f66 100644 --- a/typespec-tests/src/main/java/com/_specs_/azure/core/scalar/implementation/AzureLocationScalarsImpl.java +++ b/typespec-tests/src/main/java/com/_specs_/azure/core/scalar/implementation/AzureLocationScalarsImpl.java @@ -10,6 +10,7 @@ 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; @@ -67,7 +68,7 @@ public ScalarServiceVersion getServiceVersion() { * The interface defining all the services for ScalarClientAzureLocationScalars to be used by the proxy service to * perform REST calls. */ - @Host("http://localhost:3000") + @Host("{endpoint}") @ServiceInterface(name = "ScalarClientAzureLoc") public interface AzureLocationScalarsService { @Get("/azure/core/scalar/azureLocation") @@ -76,8 +77,8 @@ public interface AzureLocationScalarsService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> get(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Get("/azure/core/scalar/azureLocation") @ExpectedResponses({ 200 }) @@ -85,8 +86,8 @@ Mono> get(@HeaderParam("accept") String accept, RequestOpti @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response getSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Put("/azure/core/scalar/azureLocation") @ExpectedResponses({ 204 }) @@ -94,7 +95,8 @@ Response getSync(@HeaderParam("accept") String accept, RequestOption @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> put(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, + 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") @@ -103,8 +105,8 @@ Mono> put(@HeaderParam("accept") String accept, @BodyParam("appli @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response putSync(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, - RequestOptions requestOptions, Context context); + 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 }) @@ -112,7 +114,8 @@ Response putSync(@HeaderParam("accept") String accept, @BodyParam("applica @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> post(@HeaderParam("accept") String accept, + 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") @@ -121,7 +124,8 @@ Mono> post(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response postSync(@HeaderParam("accept") String accept, + 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") @@ -130,7 +134,7 @@ Response postSync(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> headerMethod(@HeaderParam("region") String region, @HeaderParam("accept") String accept, + Mono> headerMethod(@HostParam("endpoint") String endpoint, @HeaderParam("region") String region, RequestOptions requestOptions, Context context); @Post("/azure/core/scalar/azureLocation/header") @@ -139,7 +143,7 @@ Mono> headerMethod(@HeaderParam("region") String region, @HeaderP @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response headerMethodSync(@HeaderParam("region") String region, @HeaderParam("accept") String accept, + Response headerMethodSync(@HostParam("endpoint") String endpoint, @HeaderParam("region") String region, RequestOptions requestOptions, Context context); @Post("/azure/core/scalar/azureLocation/query") @@ -148,7 +152,7 @@ Response headerMethodSync(@HeaderParam("region") String region, @HeaderPar @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> query(@QueryParam("region") String region, @HeaderParam("accept") String accept, + Mono> query(@HostParam("endpoint") String endpoint, @QueryParam("region") String region, RequestOptions requestOptions, Context context); @Post("/azure/core/scalar/azureLocation/query") @@ -157,7 +161,7 @@ Mono> query(@QueryParam("region") String region, @HeaderParam("ac @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response querySync(@QueryParam("region") String region, @HeaderParam("accept") String accept, + Response querySync(@HostParam("endpoint") String endpoint, @QueryParam("region") String region, RequestOptions requestOptions, Context context); } @@ -179,7 +183,7 @@ Response querySync(@QueryParam("region") String region, @HeaderParam("acce @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getWithResponseAsync(RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.get(accept, requestOptions, context)); + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); } /** @@ -200,7 +204,7 @@ public Mono> getWithResponseAsync(RequestOptions requestOpt @ServiceMethod(returns = ReturnType.SINGLE) public Response getWithResponse(RequestOptions requestOptions) { final String accept = "application/json"; - return service.getSync(accept, requestOptions, Context.NONE); + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); } /** @@ -221,8 +225,9 @@ public Response getWithResponse(RequestOptions requestOptions) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> putWithResponseAsync(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.put(accept, body, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.put(this.client.getEndpoint(), contentType, body, requestOptions, context)); } /** @@ -243,8 +248,8 @@ public Mono> putWithResponseAsync(BinaryData body, RequestOptions */ @ServiceMethod(returns = ReturnType.SINGLE) public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.putSync(accept, body, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); } /** @@ -275,8 +280,10 @@ public Response putWithResponse(BinaryData body, RequestOptions requestOpt */ @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(accept, body, requestOptions, context)); + return FluxUtil.withContext( + context -> service.post(this.client.getEndpoint(), contentType, accept, body, requestOptions, context)); } /** @@ -307,8 +314,9 @@ public Mono> postWithResponseAsync(BinaryData body, Request */ @ServiceMethod(returns = ReturnType.SINGLE) public Response postWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; final String accept = "application/json"; - return service.postSync(accept, body, requestOptions, Context.NONE); + return service.postSync(this.client.getEndpoint(), contentType, accept, body, requestOptions, Context.NONE); } /** @@ -324,8 +332,8 @@ public Response postWithResponse(BinaryData body, RequestOptions req */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> headerMethodWithResponseAsync(String region, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.headerMethod(region, accept, requestOptions, context)); + return FluxUtil + .withContext(context -> service.headerMethod(this.client.getEndpoint(), region, requestOptions, context)); } /** @@ -341,8 +349,7 @@ public Mono> headerMethodWithResponseAsync(String region, Request */ @ServiceMethod(returns = ReturnType.SINGLE) public Response headerMethodWithResponse(String region, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.headerMethodSync(region, accept, requestOptions, Context.NONE); + return service.headerMethodSync(this.client.getEndpoint(), region, requestOptions, Context.NONE); } /** @@ -358,8 +365,8 @@ public Response headerMethodWithResponse(String region, RequestOptions req */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> queryWithResponseAsync(String region, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.query(region, accept, requestOptions, context)); + return FluxUtil + .withContext(context -> service.query(this.client.getEndpoint(), region, requestOptions, context)); } /** @@ -375,7 +382,6 @@ public Mono> queryWithResponseAsync(String region, RequestOptions */ @ServiceMethod(returns = ReturnType.SINGLE) public Response queryWithResponse(String region, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.querySync(region, accept, requestOptions, Context.NONE); + return service.querySync(this.client.getEndpoint(), region, requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/_specs_/azure/core/scalar/implementation/ScalarClientImpl.java b/typespec-tests/src/main/java/com/_specs_/azure/core/scalar/implementation/ScalarClientImpl.java index 936a53c98f..8571d3943f 100644 --- a/typespec-tests/src/main/java/com/_specs_/azure/core/scalar/implementation/ScalarClientImpl.java +++ b/typespec-tests/src/main/java/com/_specs_/azure/core/scalar/implementation/ScalarClientImpl.java @@ -16,6 +16,20 @@ * 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. */ @@ -75,21 +89,23 @@ public AzureLocationScalarsImpl getAzureLocationScalars() { /** * Initializes an instance of ScalarClient client. * + * @param endpoint Service host. * @param serviceVersion Service version. */ - public ScalarClientImpl(ScalarServiceVersion serviceVersion) { + public ScalarClientImpl(String endpoint, ScalarServiceVersion serviceVersion) { this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), - JacksonAdapter.createDefaultSerializerAdapter(), serviceVersion); + 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, ScalarServiceVersion serviceVersion) { - this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), serviceVersion); + public ScalarClientImpl(HttpPipeline httpPipeline, String endpoint, ScalarServiceVersion serviceVersion) { + this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint, serviceVersion); } /** @@ -97,12 +113,14 @@ public ScalarClientImpl(HttpPipeline httpPipeline, ScalarServiceVersion serviceV * * @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, + 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/typespec-tests/src/main/java/com/_specs_/azure/core/traits/TraitsClientBuilder.java b/typespec-tests/src/main/java/com/_specs_/azure/core/traits/TraitsClientBuilder.java index e272cf2955..fd180f21ec 100644 --- a/typespec-tests/src/main/java/com/_specs_/azure/core/traits/TraitsClientBuilder.java +++ b/typespec-tests/src/main/java/com/_specs_/azure/core/traits/TraitsClientBuilder.java @@ -8,6 +8,7 @@ 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; @@ -40,8 +41,8 @@ * A builder for creating a new instance of the TraitsClient type. */ @ServiceClientBuilder(serviceClients = { TraitsClient.class, TraitsAsyncClient.class }) -public final class TraitsClientBuilder - implements HttpTrait, ConfigurationTrait { +public final class TraitsClientBuilder implements HttpTrait, + ConfigurationTrait, EndpointTrait { @Generated private static final String SDK_NAME = "name"; @@ -173,6 +174,22 @@ public TraitsClientBuilder configuration(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 */ @@ -218,10 +235,11 @@ public TraitsClientBuilder retryPolicy(RetryPolicy retryPolicy) { 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(), localServiceVersion); + TraitsClientImpl client = new TraitsClientImpl(localPipeline, JacksonAdapter.createDefaultSerializerAdapter(), + localEndpoint, localServiceVersion); return client; } diff --git a/typespec-tests/src/main/java/com/_specs_/azure/core/traits/implementation/TraitsClientImpl.java b/typespec-tests/src/main/java/com/_specs_/azure/core/traits/implementation/TraitsClientImpl.java index b551a4fe00..fe021b1fc9 100644 --- a/typespec-tests/src/main/java/com/_specs_/azure/core/traits/implementation/TraitsClientImpl.java +++ b/typespec-tests/src/main/java/com/_specs_/azure/core/traits/implementation/TraitsClientImpl.java @@ -10,6 +10,7 @@ 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; @@ -48,6 +49,20 @@ public final class TraitsClientImpl { */ 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. */ @@ -93,21 +108,23 @@ public SerializerAdapter getSerializerAdapter() { /** * Initializes an instance of TraitsClient client. * + * @param endpoint Service host. * @param serviceVersion Service version. */ - public TraitsClientImpl(TraitsServiceVersion serviceVersion) { + public TraitsClientImpl(String endpoint, TraitsServiceVersion serviceVersion) { this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), - JacksonAdapter.createDefaultSerializerAdapter(), serviceVersion); + 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, TraitsServiceVersion serviceVersion) { - this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), serviceVersion); + public TraitsClientImpl(HttpPipeline httpPipeline, String endpoint, TraitsServiceVersion serviceVersion) { + this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint, serviceVersion); } /** @@ -115,12 +132,14 @@ public TraitsClientImpl(HttpPipeline httpPipeline, TraitsServiceVersion serviceV * * @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, + 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()); } @@ -128,7 +147,7 @@ public TraitsClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerA /** * The interface defining all the services for TraitsClient to be used by the proxy service to perform REST calls. */ - @Host("http://localhost:3000") + @Host("{endpoint}") @ServiceInterface(name = "TraitsClient") public interface TraitsClientService { @Get("/azure/core/traits/user/{id}") @@ -137,9 +156,9 @@ public interface TraitsClientService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> smokeTest(@QueryParam("api-version") String apiVersion, @PathParam("id") int id, - @HeaderParam("foo") String foo, @HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + 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 }) @@ -147,9 +166,9 @@ Mono> smokeTest(@QueryParam("api-version") String apiVersio @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response smokeTestSync(@QueryParam("api-version") String apiVersion, @PathParam("id") int id, - @HeaderParam("foo") String foo, @HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + 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 }) @@ -157,8 +176,9 @@ Response smokeTestSync(@QueryParam("api-version") String apiVersion, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> repeatableAction(@QueryParam("api-version") String apiVersion, - @PathParam("id") int id, @HeaderParam("accept") String accept, + 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") @@ -167,9 +187,10 @@ Mono> repeatableAction(@QueryParam("api-version") String ap @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response repeatableActionSync(@QueryParam("api-version") String apiVersion, @PathParam("id") int id, - @HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, - RequestOptions requestOptions, Context context); + 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); } /** @@ -210,8 +231,8 @@ Response repeatableActionSync(@QueryParam("api-version") String apiV @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.getServiceVersion().getVersion(), id, foo, accept, - requestOptions, context)); + return FluxUtil.withContext(context -> service.smokeTest(this.getEndpoint(), + this.getServiceVersion().getVersion(), id, foo, accept, requestOptions, context)); } /** @@ -251,8 +272,8 @@ public Mono> smokeTestWithResponseAsync(int id, String foo, @ServiceMethod(returns = ReturnType.SINGLE) public Response smokeTestWithResponse(int id, String foo, RequestOptions requestOptions) { final String accept = "application/json"; - return service.smokeTestSync(this.getServiceVersion().getVersion(), id, foo, accept, requestOptions, - Context.NONE); + return service.smokeTestSync(this.getEndpoint(), this.getServiceVersion().getVersion(), id, foo, accept, + requestOptions, Context.NONE); } /** @@ -294,6 +315,7 @@ public Response smokeTestWithResponse(int id, String foo, RequestOpt @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 -> { @@ -309,8 +331,8 @@ public Mono> repeatableActionWithResponseAsync(int id, Bina DateTimeRfc1123.toRfc1123String(OffsetDateTime.now())); } }); - return FluxUtil.withContext(context -> service.repeatableAction(this.getServiceVersion().getVersion(), id, - accept, body, requestOptionsLocal, context)); + return FluxUtil.withContext(context -> service.repeatableAction(this.getEndpoint(), + this.getServiceVersion().getVersion(), id, contentType, accept, body, requestOptionsLocal, context)); } /** @@ -351,6 +373,7 @@ public Mono> repeatableActionWithResponseAsync(int id, Bina */ @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 -> { @@ -366,7 +389,7 @@ public Response repeatableActionWithResponse(int id, BinaryData body DateTimeRfc1123.toRfc1123String(OffsetDateTime.now())); } }); - return service.repeatableActionSync(this.getServiceVersion().getVersion(), id, accept, body, - requestOptionsLocal, Context.NONE); + return service.repeatableActionSync(this.getEndpoint(), this.getServiceVersion().getVersion(), id, contentType, + accept, body, requestOptionsLocal, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/_specs_/azure/example/basic/AzureExampleClientBuilder.java b/typespec-tests/src/main/java/com/_specs_/azure/example/basic/AzureExampleClientBuilder.java index fde603e181..1222fc74f1 100644 --- a/typespec-tests/src/main/java/com/_specs_/azure/example/basic/AzureExampleClientBuilder.java +++ b/typespec-tests/src/main/java/com/_specs_/azure/example/basic/AzureExampleClientBuilder.java @@ -8,6 +8,7 @@ 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; @@ -40,8 +41,8 @@ * A builder for creating a new instance of the AzureExampleClient type. */ @ServiceClientBuilder(serviceClients = { AzureExampleClient.class, AzureExampleAsyncClient.class }) -public final class AzureExampleClientBuilder - implements HttpTrait, ConfigurationTrait { +public final class AzureExampleClientBuilder implements HttpTrait, + ConfigurationTrait, EndpointTrait { @Generated private static final String SDK_NAME = "name"; @@ -173,6 +174,22 @@ public AzureExampleClientBuilder configuration(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 */ @@ -218,10 +235,11 @@ public AzureExampleClientBuilder retryPolicy(RetryPolicy retryPolicy) { 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(), localServiceVersion); + JacksonAdapter.createDefaultSerializerAdapter(), localEndpoint, localServiceVersion); return client; } diff --git a/typespec-tests/src/main/java/com/_specs_/azure/example/basic/implementation/AzureExampleClientImpl.java b/typespec-tests/src/main/java/com/_specs_/azure/example/basic/implementation/AzureExampleClientImpl.java index eab336edd8..fa748ec0a3 100644 --- a/typespec-tests/src/main/java/com/_specs_/azure/example/basic/implementation/AzureExampleClientImpl.java +++ b/typespec-tests/src/main/java/com/_specs_/azure/example/basic/implementation/AzureExampleClientImpl.java @@ -9,6 +9,7 @@ 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; @@ -42,6 +43,20 @@ public final class AzureExampleClientImpl { */ 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. */ @@ -87,21 +102,23 @@ public SerializerAdapter getSerializerAdapter() { /** * Initializes an instance of AzureExampleClient client. * + * @param endpoint Service host. * @param serviceVersion Service version. */ - public AzureExampleClientImpl(BasicServiceVersion serviceVersion) { + public AzureExampleClientImpl(String endpoint, BasicServiceVersion serviceVersion) { this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), - JacksonAdapter.createDefaultSerializerAdapter(), serviceVersion); + 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, BasicServiceVersion serviceVersion) { - this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), serviceVersion); + public AzureExampleClientImpl(HttpPipeline httpPipeline, String endpoint, BasicServiceVersion serviceVersion) { + this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint, serviceVersion); } /** @@ -109,12 +126,14 @@ public AzureExampleClientImpl(HttpPipeline httpPipeline, BasicServiceVersion ser * * @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, + 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()); @@ -124,7 +143,7 @@ public AzureExampleClientImpl(HttpPipeline httpPipeline, SerializerAdapter seria * The interface defining all the services for AzureExampleClient to be used by the proxy service to perform REST * calls. */ - @Host("http://localhost:3000") + @Host("{endpoint}") @ServiceInterface(name = "AzureExampleClient") public interface AzureExampleClientService { @Post("/azure/example/basic/basic") @@ -133,9 +152,10 @@ public interface AzureExampleClientService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> basicAction(@QueryParam("api-version") String apiVersion, - @QueryParam("query-param") String queryParam, @HeaderParam("header-param") String headerParam, - @HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, + 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") @@ -144,9 +164,10 @@ Mono> basicAction(@QueryParam("api-version") String apiVers @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response basicActionSync(@QueryParam("api-version") String apiVersion, - @QueryParam("query-param") String queryParam, @HeaderParam("header-param") String headerParam, - @HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, + 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); } @@ -203,9 +224,11 @@ Response basicActionSync(@QueryParam("api-version") String apiVersio @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.getServiceVersion().getVersion(), queryParam, - headerParam, accept, body, requestOptions, context)); + return FluxUtil + .withContext(context -> service.basicAction(this.getEndpoint(), this.getServiceVersion().getVersion(), + queryParam, headerParam, contentType, accept, body, requestOptions, context)); } /** @@ -261,8 +284,9 @@ public Mono> basicActionWithResponseAsync(String queryParam @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.getServiceVersion().getVersion(), queryParam, headerParam, accept, body, - requestOptions, Context.NONE); + return service.basicActionSync(this.getEndpoint(), this.getServiceVersion().getVersion(), queryParam, + headerParam, contentType, accept, body, requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/authentication/apikey/ApiKeyClientBuilder.java b/typespec-tests/src/main/java/com/authentication/apikey/ApiKeyClientBuilder.java index c916fc6e2d..12c654d41d 100644 --- a/typespec-tests/src/main/java/com/authentication/apikey/ApiKeyClientBuilder.java +++ b/typespec-tests/src/main/java/com/authentication/apikey/ApiKeyClientBuilder.java @@ -8,6 +8,7 @@ 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; @@ -43,8 +44,9 @@ * 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 { +public final class ApiKeyClientBuilder + implements HttpTrait, ConfigurationTrait, + KeyCredentialTrait, EndpointTrait { @Generated private static final String SDK_NAME = "name"; @@ -191,6 +193,22 @@ public ApiKeyClientBuilder credential(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. */ @@ -218,7 +236,9 @@ public ApiKeyClientBuilder retryPolicy(RetryPolicy retryPolicy) { private ApiKeyClientImpl buildInnerClient() { this.validateClient(); HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); - ApiKeyClientImpl client = new ApiKeyClientImpl(localPipeline, JacksonAdapter.createDefaultSerializerAdapter()); + String localEndpoint = (endpoint != null) ? endpoint : "http://localhost:3000"; + ApiKeyClientImpl client + = new ApiKeyClientImpl(localPipeline, JacksonAdapter.createDefaultSerializerAdapter(), localEndpoint); return client; } diff --git a/typespec-tests/src/main/java/com/authentication/apikey/implementation/ApiKeyClientImpl.java b/typespec-tests/src/main/java/com/authentication/apikey/implementation/ApiKeyClientImpl.java index e0b97150e8..57f30be3a5 100644 --- a/typespec-tests/src/main/java/com/authentication/apikey/implementation/ApiKeyClientImpl.java +++ b/typespec-tests/src/main/java/com/authentication/apikey/implementation/ApiKeyClientImpl.java @@ -8,6 +8,7 @@ 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; @@ -38,6 +39,20 @@ public final class ApiKeyClientImpl { */ 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. */ @@ -68,19 +83,22 @@ public SerializerAdapter getSerializerAdapter() { /** * Initializes an instance of ApiKeyClient client. + * + * @param endpoint Service host. */ - public ApiKeyClientImpl() { + public ApiKeyClientImpl(String endpoint) { this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), - JacksonAdapter.createDefaultSerializerAdapter()); + 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) { - this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter()); + public ApiKeyClientImpl(HttpPipeline httpPipeline, String endpoint) { + this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint); } /** @@ -88,17 +106,19 @@ public ApiKeyClientImpl(HttpPipeline httpPipeline) { * * @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) { + 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("http://localhost:3000") + @Host("{endpoint}") @ServiceInterface(name = "ApiKeyClient") public interface ApiKeyClientService { @Get("/authentication/api-key/valid") @@ -107,7 +127,7 @@ public interface ApiKeyClientService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> valid(@HeaderParam("accept") String accept, RequestOptions requestOptions, + Mono> valid(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, Context context); @Get("/authentication/api-key/valid") @@ -116,7 +136,8 @@ Mono> valid(@HeaderParam("accept") String accept, RequestOptions @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response validSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + Response validSync(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, + Context context); @Get("/authentication/api-key/invalid") @ExpectedResponses({ 204 }) @@ -124,8 +145,8 @@ Mono> valid(@HeaderParam("accept") String accept, RequestOptions @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> invalid(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Mono> invalid(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Get("/authentication/api-key/invalid") @ExpectedResponses({ 204 }) @@ -133,8 +154,8 @@ Mono> invalid(@HeaderParam("accept") String accept, RequestOption @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response invalidSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Response invalidSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); } /** @@ -149,8 +170,7 @@ Response invalidSync(@HeaderParam("accept") String accept, RequestOptions */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> validWithResponseAsync(RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.valid(accept, requestOptions, context)); + return FluxUtil.withContext(context -> service.valid(this.getEndpoint(), requestOptions, context)); } /** @@ -165,8 +185,7 @@ public Mono> validWithResponseAsync(RequestOptions requestOptions */ @ServiceMethod(returns = ReturnType.SINGLE) public Response validWithResponse(RequestOptions requestOptions) { - final String accept = "application/json"; - return service.validSync(accept, requestOptions, Context.NONE); + return service.validSync(this.getEndpoint(), requestOptions, Context.NONE); } /** @@ -182,7 +201,7 @@ public Response validWithResponse(RequestOptions requestOptions) { @ServiceMethod(returns = ReturnType.SINGLE) public Mono> invalidWithResponseAsync(RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.invalid(accept, requestOptions, context)); + return FluxUtil.withContext(context -> service.invalid(this.getEndpoint(), accept, requestOptions, context)); } /** @@ -198,6 +217,6 @@ public Mono> invalidWithResponseAsync(RequestOptions requestOptio @ServiceMethod(returns = ReturnType.SINGLE) public Response invalidWithResponse(RequestOptions requestOptions) { final String accept = "application/json"; - return service.invalidSync(accept, requestOptions, Context.NONE); + return service.invalidSync(this.getEndpoint(), accept, requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/authentication/http/custom/CustomClientBuilder.java b/typespec-tests/src/main/java/com/authentication/http/custom/CustomClientBuilder.java index e387c89a64..2242889e36 100644 --- a/typespec-tests/src/main/java/com/authentication/http/custom/CustomClientBuilder.java +++ b/typespec-tests/src/main/java/com/authentication/http/custom/CustomClientBuilder.java @@ -8,6 +8,7 @@ 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; @@ -43,8 +44,9 @@ * 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 { +public final class CustomClientBuilder + implements HttpTrait, ConfigurationTrait, + KeyCredentialTrait, EndpointTrait { @Generated private static final String SDK_NAME = "name"; @@ -192,6 +194,22 @@ public CustomClientBuilder credential(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. */ @@ -219,7 +237,9 @@ public CustomClientBuilder retryPolicy(RetryPolicy retryPolicy) { private CustomClientImpl buildInnerClient() { this.validateClient(); HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); - CustomClientImpl client = new CustomClientImpl(localPipeline, JacksonAdapter.createDefaultSerializerAdapter()); + String localEndpoint = (endpoint != null) ? endpoint : "http://localhost:3000"; + CustomClientImpl client + = new CustomClientImpl(localPipeline, JacksonAdapter.createDefaultSerializerAdapter(), localEndpoint); return client; } diff --git a/typespec-tests/src/main/java/com/authentication/http/custom/implementation/CustomClientImpl.java b/typespec-tests/src/main/java/com/authentication/http/custom/implementation/CustomClientImpl.java index a1249585f5..f61eee8d7c 100644 --- a/typespec-tests/src/main/java/com/authentication/http/custom/implementation/CustomClientImpl.java +++ b/typespec-tests/src/main/java/com/authentication/http/custom/implementation/CustomClientImpl.java @@ -8,6 +8,7 @@ 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; @@ -38,6 +39,20 @@ public final class CustomClientImpl { */ 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. */ @@ -68,19 +83,22 @@ public SerializerAdapter getSerializerAdapter() { /** * Initializes an instance of CustomClient client. + * + * @param endpoint Service host. */ - public CustomClientImpl() { + public CustomClientImpl(String endpoint) { this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), - JacksonAdapter.createDefaultSerializerAdapter()); + 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) { - this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter()); + public CustomClientImpl(HttpPipeline httpPipeline, String endpoint) { + this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint); } /** @@ -88,17 +106,19 @@ public CustomClientImpl(HttpPipeline httpPipeline) { * * @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) { + 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("http://localhost:3000") + @Host("{endpoint}") @ServiceInterface(name = "CustomClient") public interface CustomClientService { @Get("/authentication/http/custom/valid") @@ -107,7 +127,7 @@ public interface CustomClientService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> valid(@HeaderParam("accept") String accept, RequestOptions requestOptions, + Mono> valid(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, Context context); @Get("/authentication/http/custom/valid") @@ -116,7 +136,8 @@ Mono> valid(@HeaderParam("accept") String accept, RequestOptions @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response validSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + Response validSync(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, + Context context); @Get("/authentication/http/custom/invalid") @ExpectedResponses({ 204 }) @@ -124,8 +145,8 @@ Mono> valid(@HeaderParam("accept") String accept, RequestOptions @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> invalid(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Mono> invalid(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Get("/authentication/http/custom/invalid") @ExpectedResponses({ 204 }) @@ -133,8 +154,8 @@ Mono> invalid(@HeaderParam("accept") String accept, RequestOption @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response invalidSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Response invalidSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); } /** @@ -149,8 +170,7 @@ Response invalidSync(@HeaderParam("accept") String accept, RequestOptions */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> validWithResponseAsync(RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.valid(accept, requestOptions, context)); + return FluxUtil.withContext(context -> service.valid(this.getEndpoint(), requestOptions, context)); } /** @@ -165,8 +185,7 @@ public Mono> validWithResponseAsync(RequestOptions requestOptions */ @ServiceMethod(returns = ReturnType.SINGLE) public Response validWithResponse(RequestOptions requestOptions) { - final String accept = "application/json"; - return service.validSync(accept, requestOptions, Context.NONE); + return service.validSync(this.getEndpoint(), requestOptions, Context.NONE); } /** @@ -182,7 +201,7 @@ public Response validWithResponse(RequestOptions requestOptions) { @ServiceMethod(returns = ReturnType.SINGLE) public Mono> invalidWithResponseAsync(RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.invalid(accept, requestOptions, context)); + return FluxUtil.withContext(context -> service.invalid(this.getEndpoint(), accept, requestOptions, context)); } /** @@ -198,6 +217,6 @@ public Mono> invalidWithResponseAsync(RequestOptions requestOptio @ServiceMethod(returns = ReturnType.SINGLE) public Response invalidWithResponse(RequestOptions requestOptions) { final String accept = "application/json"; - return service.invalidSync(accept, requestOptions, Context.NONE); + return service.invalidSync(this.getEndpoint(), accept, requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/authentication/oauth2/OAuth2ClientBuilder.java b/typespec-tests/src/main/java/com/authentication/oauth2/OAuth2ClientBuilder.java index f36beec9e4..4c713e4cfa 100644 --- a/typespec-tests/src/main/java/com/authentication/oauth2/OAuth2ClientBuilder.java +++ b/typespec-tests/src/main/java/com/authentication/oauth2/OAuth2ClientBuilder.java @@ -8,6 +8,7 @@ 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; @@ -43,8 +44,9 @@ * 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 { +public final class OAuth2ClientBuilder + implements HttpTrait, ConfigurationTrait, + TokenCredentialTrait, EndpointTrait { @Generated private static final String SDK_NAME = "name"; @@ -194,6 +196,22 @@ public OAuth2ClientBuilder credential(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. */ @@ -221,7 +239,9 @@ public OAuth2ClientBuilder retryPolicy(RetryPolicy retryPolicy) { private OAuth2ClientImpl buildInnerClient() { this.validateClient(); HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); - OAuth2ClientImpl client = new OAuth2ClientImpl(localPipeline, JacksonAdapter.createDefaultSerializerAdapter()); + String localEndpoint = (endpoint != null) ? endpoint : "http://localhost:3000"; + OAuth2ClientImpl client + = new OAuth2ClientImpl(localPipeline, JacksonAdapter.createDefaultSerializerAdapter(), localEndpoint); return client; } diff --git a/typespec-tests/src/main/java/com/authentication/oauth2/implementation/OAuth2ClientImpl.java b/typespec-tests/src/main/java/com/authentication/oauth2/implementation/OAuth2ClientImpl.java index 6b58a78ce2..a603f8e20c 100644 --- a/typespec-tests/src/main/java/com/authentication/oauth2/implementation/OAuth2ClientImpl.java +++ b/typespec-tests/src/main/java/com/authentication/oauth2/implementation/OAuth2ClientImpl.java @@ -8,6 +8,7 @@ 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; @@ -38,6 +39,20 @@ public final class OAuth2ClientImpl { */ 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. */ @@ -68,19 +83,22 @@ public SerializerAdapter getSerializerAdapter() { /** * Initializes an instance of OAuth2Client client. + * + * @param endpoint Service host. */ - public OAuth2ClientImpl() { + public OAuth2ClientImpl(String endpoint) { this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), - JacksonAdapter.createDefaultSerializerAdapter()); + 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) { - this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter()); + public OAuth2ClientImpl(HttpPipeline httpPipeline, String endpoint) { + this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint); } /** @@ -88,17 +106,19 @@ public OAuth2ClientImpl(HttpPipeline httpPipeline) { * * @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) { + 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("http://localhost:3000") + @Host("{endpoint}") @ServiceInterface(name = "OAuth2Client") public interface OAuth2ClientService { @Get("/authentication/oauth2/valid") @@ -107,7 +127,7 @@ public interface OAuth2ClientService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> valid(@HeaderParam("accept") String accept, RequestOptions requestOptions, + Mono> valid(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, Context context); @Get("/authentication/oauth2/valid") @@ -116,7 +136,8 @@ Mono> valid(@HeaderParam("accept") String accept, RequestOptions @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response validSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + Response validSync(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, + Context context); @Get("/authentication/oauth2/invalid") @ExpectedResponses({ 204 }) @@ -124,8 +145,8 @@ Mono> valid(@HeaderParam("accept") String accept, RequestOptions @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> invalid(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Mono> invalid(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Get("/authentication/oauth2/invalid") @ExpectedResponses({ 204 }) @@ -133,8 +154,8 @@ Mono> invalid(@HeaderParam("accept") String accept, RequestOption @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response invalidSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Response invalidSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); } /** @@ -149,8 +170,7 @@ Response invalidSync(@HeaderParam("accept") String accept, RequestOptions */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> validWithResponseAsync(RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.valid(accept, requestOptions, context)); + return FluxUtil.withContext(context -> service.valid(this.getEndpoint(), requestOptions, context)); } /** @@ -165,8 +185,7 @@ public Mono> validWithResponseAsync(RequestOptions requestOptions */ @ServiceMethod(returns = ReturnType.SINGLE) public Response validWithResponse(RequestOptions requestOptions) { - final String accept = "application/json"; - return service.validSync(accept, requestOptions, Context.NONE); + return service.validSync(this.getEndpoint(), requestOptions, Context.NONE); } /** @@ -182,7 +201,7 @@ public Response validWithResponse(RequestOptions requestOptions) { @ServiceMethod(returns = ReturnType.SINGLE) public Mono> invalidWithResponseAsync(RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.invalid(accept, requestOptions, context)); + return FluxUtil.withContext(context -> service.invalid(this.getEndpoint(), accept, requestOptions, context)); } /** @@ -198,6 +217,6 @@ public Mono> invalidWithResponseAsync(RequestOptions requestOptio @ServiceMethod(returns = ReturnType.SINGLE) public Response invalidWithResponse(RequestOptions requestOptions) { final String accept = "application/json"; - return service.invalidSync(accept, requestOptions, Context.NONE); + return service.invalidSync(this.getEndpoint(), accept, requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/authentication/union/UnionClientBuilder.java b/typespec-tests/src/main/java/com/authentication/union/UnionClientBuilder.java index 6a7464872a..30aa7abda3 100644 --- a/typespec-tests/src/main/java/com/authentication/union/UnionClientBuilder.java +++ b/typespec-tests/src/main/java/com/authentication/union/UnionClientBuilder.java @@ -8,6 +8,7 @@ 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; @@ -47,7 +48,8 @@ */ @ServiceClientBuilder(serviceClients = { UnionClient.class, UnionAsyncClient.class }) public final class UnionClientBuilder implements HttpTrait, ConfigurationTrait, - TokenCredentialTrait, KeyCredentialTrait { + TokenCredentialTrait, KeyCredentialTrait, + EndpointTrait { @Generated private static final String SDK_NAME = "name"; @@ -213,6 +215,22 @@ public UnionClientBuilder credential(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. */ @@ -240,7 +258,9 @@ public UnionClientBuilder retryPolicy(RetryPolicy retryPolicy) { private UnionClientImpl buildInnerClient() { this.validateClient(); HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); - UnionClientImpl client = new UnionClientImpl(localPipeline, JacksonAdapter.createDefaultSerializerAdapter()); + String localEndpoint = (endpoint != null) ? endpoint : "http://localhost:3000"; + UnionClientImpl client + = new UnionClientImpl(localPipeline, JacksonAdapter.createDefaultSerializerAdapter(), localEndpoint); return client; } diff --git a/typespec-tests/src/main/java/com/authentication/union/implementation/UnionClientImpl.java b/typespec-tests/src/main/java/com/authentication/union/implementation/UnionClientImpl.java index e0b863d25e..c09b8c5c1a 100644 --- a/typespec-tests/src/main/java/com/authentication/union/implementation/UnionClientImpl.java +++ b/typespec-tests/src/main/java/com/authentication/union/implementation/UnionClientImpl.java @@ -6,8 +6,8 @@ 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; @@ -38,6 +38,20 @@ public final class UnionClientImpl { */ 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. */ @@ -68,19 +82,22 @@ public SerializerAdapter getSerializerAdapter() { /** * Initializes an instance of UnionClient client. + * + * @param endpoint Service host. */ - public UnionClientImpl() { + public UnionClientImpl(String endpoint) { this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), - JacksonAdapter.createDefaultSerializerAdapter()); + 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) { - this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter()); + public UnionClientImpl(HttpPipeline httpPipeline, String endpoint) { + this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint); } /** @@ -88,17 +105,19 @@ public UnionClientImpl(HttpPipeline httpPipeline) { * * @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) { + 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("http://localhost:3000") + @Host("{endpoint}") @ServiceInterface(name = "UnionClient") public interface UnionClientService { @Get("/authentication/union/validkey") @@ -107,7 +126,7 @@ public interface UnionClientService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> validKey(@HeaderParam("accept") String accept, RequestOptions requestOptions, + Mono> validKey(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, Context context); @Get("/authentication/union/validkey") @@ -116,7 +135,7 @@ Mono> validKey(@HeaderParam("accept") String accept, RequestOptio @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response validKeySync(@HeaderParam("accept") String accept, RequestOptions requestOptions, + Response validKeySync(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, Context context); @Get("/authentication/union/validtoken") @@ -125,7 +144,7 @@ Response validKeySync(@HeaderParam("accept") String accept, RequestOptions @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> validToken(@HeaderParam("accept") String accept, RequestOptions requestOptions, + Mono> validToken(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, Context context); @Get("/authentication/union/validtoken") @@ -134,7 +153,7 @@ Mono> validToken(@HeaderParam("accept") String accept, RequestOpt @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response validTokenSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, + Response validTokenSync(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, Context context); } @@ -150,8 +169,7 @@ Response validTokenSync(@HeaderParam("accept") String accept, RequestOptio */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> validKeyWithResponseAsync(RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.validKey(accept, requestOptions, context)); + return FluxUtil.withContext(context -> service.validKey(this.getEndpoint(), requestOptions, context)); } /** @@ -166,8 +184,7 @@ public Mono> validKeyWithResponseAsync(RequestOptions requestOpti */ @ServiceMethod(returns = ReturnType.SINGLE) public Response validKeyWithResponse(RequestOptions requestOptions) { - final String accept = "application/json"; - return service.validKeySync(accept, requestOptions, Context.NONE); + return service.validKeySync(this.getEndpoint(), requestOptions, Context.NONE); } /** @@ -182,8 +199,7 @@ public Response validKeyWithResponse(RequestOptions requestOptions) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> validTokenWithResponseAsync(RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.validToken(accept, requestOptions, context)); + return FluxUtil.withContext(context -> service.validToken(this.getEndpoint(), requestOptions, context)); } /** @@ -198,7 +214,6 @@ public Mono> validTokenWithResponseAsync(RequestOptions requestOp */ @ServiceMethod(returns = ReturnType.SINGLE) public Response validTokenWithResponse(RequestOptions requestOptions) { - final String accept = "application/json"; - return service.validTokenSync(accept, requestOptions, Context.NONE); + return service.validTokenSync(this.getEndpoint(), requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/azure/clientgenerator/core/flattenproperty/FlattenPropertyClientBuilder.java b/typespec-tests/src/main/java/com/azure/clientgenerator/core/flattenproperty/FlattenPropertyClientBuilder.java index 422c23abbd..08b80bc950 100644 --- a/typespec-tests/src/main/java/com/azure/clientgenerator/core/flattenproperty/FlattenPropertyClientBuilder.java +++ b/typespec-tests/src/main/java/com/azure/clientgenerator/core/flattenproperty/FlattenPropertyClientBuilder.java @@ -8,6 +8,7 @@ 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; @@ -40,8 +41,8 @@ * A builder for creating a new instance of the FlattenPropertyClient type. */ @ServiceClientBuilder(serviceClients = { FlattenPropertyClient.class, FlattenPropertyAsyncClient.class }) -public final class FlattenPropertyClientBuilder - implements HttpTrait, ConfigurationTrait { +public final class FlattenPropertyClientBuilder implements HttpTrait, + ConfigurationTrait, EndpointTrait { @Generated private static final String SDK_NAME = "name"; @@ -173,6 +174,22 @@ public FlattenPropertyClientBuilder configuration(Configuration configuration) { return this; } + /* + * The service endpoint + */ + @Generated + private String endpoint; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public FlattenPropertyClientBuilder endpoint(String endpoint) { + this.endpoint = endpoint; + return this; + } + /* * The retry policy that will attempt to retry failed requests, if applicable. */ @@ -200,8 +217,9 @@ public FlattenPropertyClientBuilder retryPolicy(RetryPolicy retryPolicy) { private FlattenPropertyClientImpl buildInnerClient() { this.validateClient(); HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); - FlattenPropertyClientImpl client - = new FlattenPropertyClientImpl(localPipeline, JacksonAdapter.createDefaultSerializerAdapter()); + String localEndpoint = (endpoint != null) ? endpoint : "http://localhost:3000"; + FlattenPropertyClientImpl client = new FlattenPropertyClientImpl(localPipeline, + JacksonAdapter.createDefaultSerializerAdapter(), localEndpoint); return client; } diff --git a/typespec-tests/src/main/java/com/azure/clientgenerator/core/flattenproperty/implementation/FlattenPropertyClientImpl.java b/typespec-tests/src/main/java/com/azure/clientgenerator/core/flattenproperty/implementation/FlattenPropertyClientImpl.java index 18de092add..7444598c17 100644 --- a/typespec-tests/src/main/java/com/azure/clientgenerator/core/flattenproperty/implementation/FlattenPropertyClientImpl.java +++ b/typespec-tests/src/main/java/com/azure/clientgenerator/core/flattenproperty/implementation/FlattenPropertyClientImpl.java @@ -8,6 +8,7 @@ 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; @@ -40,6 +41,20 @@ public final class FlattenPropertyClientImpl { */ private final FlattenPropertyClientService 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. */ @@ -70,19 +85,22 @@ public SerializerAdapter getSerializerAdapter() { /** * Initializes an instance of FlattenPropertyClient client. + * + * @param endpoint Service host. */ - public FlattenPropertyClientImpl() { + public FlattenPropertyClientImpl(String endpoint) { this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), - JacksonAdapter.createDefaultSerializerAdapter()); + JacksonAdapter.createDefaultSerializerAdapter(), endpoint); } /** * Initializes an instance of FlattenPropertyClient client. * * @param httpPipeline The HTTP pipeline to send requests through. + * @param endpoint Service host. */ - public FlattenPropertyClientImpl(HttpPipeline httpPipeline) { - this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter()); + public FlattenPropertyClientImpl(HttpPipeline httpPipeline, String endpoint) { + this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint); } /** @@ -90,10 +108,12 @@ public FlattenPropertyClientImpl(HttpPipeline httpPipeline) { * * @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 FlattenPropertyClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter) { + public FlattenPropertyClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, String endpoint) { this.httpPipeline = httpPipeline; this.serializerAdapter = serializerAdapter; + this.endpoint = endpoint; this.service = RestProxy.create(FlattenPropertyClientService.class, this.httpPipeline, this.getSerializerAdapter()); } @@ -102,7 +122,7 @@ public FlattenPropertyClientImpl(HttpPipeline httpPipeline, SerializerAdapter se * The interface defining all the services for FlattenPropertyClient to be used by the proxy service to perform REST * calls. */ - @Host("http://localhost:3000") + @Host("{endpoint}") @ServiceInterface(name = "FlattenPropertyClien") public interface FlattenPropertyClientService { @Put("/azure/client-generator-core/flatten-property/flattenModel") @@ -111,7 +131,8 @@ public interface FlattenPropertyClientService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> putFlattenModel(@HeaderParam("accept") String accept, + 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("/azure/client-generator-core/flatten-property/flattenModel") @@ -120,7 +141,8 @@ Mono> putFlattenModel(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response putFlattenModelSync(@HeaderParam("accept") String accept, + 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("/azure/client-generator-core/flatten-property/nestedFlattenModel") @@ -129,7 +151,8 @@ Response putFlattenModelSync(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> putNestedFlattenModel(@HeaderParam("accept") String accept, + 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("/azure/client-generator-core/flatten-property/nestedFlattenModel") @@ -138,7 +161,8 @@ Mono> putNestedFlattenModel(@HeaderParam("accept") String a @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response putNestedFlattenModelSync(@HeaderParam("accept") String accept, + Response putNestedFlattenModelSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, @BodyParam("application/json") BinaryData input, RequestOptions requestOptions, Context context); } @@ -180,8 +204,10 @@ Response putNestedFlattenModelSync(@HeaderParam("accept") String acc @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(accept, input, requestOptions, context)); + return FluxUtil.withContext(context -> service.putFlattenModel(this.getEndpoint(), contentType, accept, input, + requestOptions, context)); } /** @@ -220,8 +246,10 @@ public Mono> putFlattenModelWithResponseAsync(BinaryData in */ @ServiceMethod(returns = ReturnType.SINGLE) public Response putFlattenModelWithResponse(BinaryData input, RequestOptions requestOptions) { + final String contentType = "application/json"; final String accept = "application/json"; - return service.putFlattenModelSync(accept, input, requestOptions, Context.NONE); + return service.putFlattenModelSync(this.getEndpoint(), contentType, accept, input, requestOptions, + Context.NONE); } /** @@ -268,8 +296,10 @@ public Response putFlattenModelWithResponse(BinaryData input, Reques @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(accept, input, requestOptions, context)); + return FluxUtil.withContext(context -> service.putNestedFlattenModel(this.getEndpoint(), contentType, accept, + input, requestOptions, context)); } /** @@ -314,7 +344,9 @@ public Mono> putNestedFlattenModelWithResponseAsync(BinaryD */ @ServiceMethod(returns = ReturnType.SINGLE) public Response putNestedFlattenModelWithResponse(BinaryData input, RequestOptions requestOptions) { + final String contentType = "application/json"; final String accept = "application/json"; - return service.putNestedFlattenModelSync(accept, input, requestOptions, Context.NONE); + return service.putNestedFlattenModelSync(this.getEndpoint(), contentType, accept, input, requestOptions, + Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/azure/resourcemanager/models/commontypes/managedidentity/fluent/ManagedIdentityClient.java b/typespec-tests/src/main/java/com/azure/resourcemanager/models/commontypes/managedidentity/fluent/ManagedIdentityClient.java index c19097c9f5..f0a5e6ccd7 100644 --- a/typespec-tests/src/main/java/com/azure/resourcemanager/models/commontypes/managedidentity/fluent/ManagedIdentityClient.java +++ b/typespec-tests/src/main/java/com/azure/resourcemanager/models/commontypes/managedidentity/fluent/ManagedIdentityClient.java @@ -12,7 +12,7 @@ */ public interface ManagedIdentityClient { /** - * Gets Server parameter. + * Gets Service host. * * @return the endpoint value. */ diff --git a/typespec-tests/src/main/java/com/azure/resourcemanager/models/commontypes/managedidentity/implementation/ManagedIdentityClientBuilder.java b/typespec-tests/src/main/java/com/azure/resourcemanager/models/commontypes/managedidentity/implementation/ManagedIdentityClientBuilder.java index 6ef09dff90..ded7cbf3a7 100644 --- a/typespec-tests/src/main/java/com/azure/resourcemanager/models/commontypes/managedidentity/implementation/ManagedIdentityClientBuilder.java +++ b/typespec-tests/src/main/java/com/azure/resourcemanager/models/commontypes/managedidentity/implementation/ManagedIdentityClientBuilder.java @@ -20,12 +20,12 @@ @ServiceClientBuilder(serviceClients = { ManagedIdentityClientImpl.class }) public final class ManagedIdentityClientBuilder { /* - * Server parameter + * Service host */ private String endpoint; /** - * Sets Server parameter. + * Sets Service host. * * @param endpoint the endpoint value. * @return the ManagedIdentityClientBuilder. @@ -121,6 +121,7 @@ public ManagedIdentityClientBuilder serializerAdapter(SerializerAdapter serializ * @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 @@ -131,7 +132,7 @@ public ManagedIdentityClientImpl buildClient() { ? serializerAdapter : SerializerFactory.createDefaultManagementSerializerAdapter(); ManagedIdentityClientImpl client = new ManagedIdentityClientImpl(localPipeline, localSerializerAdapter, - localDefaultPollInterval, localEnvironment, this.endpoint, this.subscriptionId); + localDefaultPollInterval, localEnvironment, localEndpoint, this.subscriptionId); return client; } } diff --git a/typespec-tests/src/main/java/com/azure/resourcemanager/models/commontypes/managedidentity/implementation/ManagedIdentityClientImpl.java b/typespec-tests/src/main/java/com/azure/resourcemanager/models/commontypes/managedidentity/implementation/ManagedIdentityClientImpl.java index 817cf50246..7ca7ea19a0 100644 --- a/typespec-tests/src/main/java/com/azure/resourcemanager/models/commontypes/managedidentity/implementation/ManagedIdentityClientImpl.java +++ b/typespec-tests/src/main/java/com/azure/resourcemanager/models/commontypes/managedidentity/implementation/ManagedIdentityClientImpl.java @@ -40,12 +40,12 @@ @ServiceClient(builder = ManagedIdentityClientBuilder.class) public final class ManagedIdentityClientImpl implements ManagedIdentityClient { /** - * Server parameter. + * Service host. */ private final String endpoint; /** - * Gets Server parameter. + * Gets Service host. * * @return the endpoint value. */ @@ -144,7 +144,7 @@ public ManagedIdentityTrackedResourcesClient getManagedIdentityTrackedResources( * @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 Server parameter. + * @param endpoint Service host. * @param subscriptionId The ID of the target subscription. The value must be an UUID. */ ManagedIdentityClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, diff --git a/typespec-tests/src/main/java/com/azure/resourcemanager/models/commontypes/managedidentity/implementation/ManagedIdentityTrackedResourcesClientImpl.java b/typespec-tests/src/main/java/com/azure/resourcemanager/models/commontypes/managedidentity/implementation/ManagedIdentityTrackedResourcesClientImpl.java index cc106bfcbe..bd271c409a 100644 --- a/typespec-tests/src/main/java/com/azure/resourcemanager/models/commontypes/managedidentity/implementation/ManagedIdentityTrackedResourcesClientImpl.java +++ b/typespec-tests/src/main/java/com/azure/resourcemanager/models/commontypes/managedidentity/implementation/ManagedIdentityTrackedResourcesClientImpl.java @@ -68,9 +68,8 @@ Mono> getByResourceGroup(@HostPara @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId, @PathParam("resourceGroupName") String resourceGroupName, @PathParam("managedIdentityTrackedResourceName") String managedIdentityTrackedResourceName, - @HeaderParam("accept") String accept, Context context); + @HeaderParam("Accept") String accept, Context context); - @Headers({ "Content-Type: application/json" }) @Put("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.Models.CommonTypes.ManagedIdentity/managedIdentityTrackedResources/{managedIdentityTrackedResourceName}") @ExpectedResponses({ 200, 201 }) @UnexpectedResponseExceptionType(ManagementException.class) @@ -79,10 +78,9 @@ Mono> createWithSystemAssigned( @PathParam("subscriptionId") String subscriptionId, @PathParam("resourceGroupName") String resourceGroupName, @PathParam("managedIdentityTrackedResourceName") String managedIdentityTrackedResourceName, - @HeaderParam("accept") String accept, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, @BodyParam("application/json") ManagedIdentityTrackedResourceInner resource, Context context); - @Headers({ "Content-Type: application/json" }) @Patch("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.Models.CommonTypes.ManagedIdentity/managedIdentityTrackedResources/{managedIdentityTrackedResourceName}") @ExpectedResponses({ 200 }) @UnexpectedResponseExceptionType(ManagementException.class) @@ -91,7 +89,7 @@ Mono> updateWithUserAssignedAndSys @PathParam("subscriptionId") String subscriptionId, @PathParam("resourceGroupName") String resourceGroupName, @PathParam("managedIdentityTrackedResourceName") String managedIdentityTrackedResourceName, - @HeaderParam("accept") String accept, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, @BodyParam("application/json") ManagedIdentityTrackedResourceInner properties, Context context); } @@ -257,11 +255,12 @@ private Mono> createWithSystemAssi } 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, accept, resource, context)) + managedIdentityTrackedResourceName, contentType, accept, resource, context)) .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); } @@ -303,11 +302,12 @@ private Mono> createWithSystemAssi } 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, accept, resource, - context); + this.client.getSubscriptionId(), resourceGroupName, managedIdentityTrackedResourceName, contentType, accept, + resource, context); } /** @@ -404,11 +404,12 @@ public ManagedIdentityTrackedResourceInner createWithSystemAssigned(String resou } 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, accept, properties, context)) + managedIdentityTrackedResourceName, contentType, accept, properties, context)) .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); } @@ -451,11 +452,12 @@ public ManagedIdentityTrackedResourceInner createWithSystemAssigned(String resou } 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, accept, properties, - context); + this.client.getSubscriptionId(), resourceGroupName, managedIdentityTrackedResourceName, contentType, accept, + properties, context); } /** diff --git a/typespec-tests/src/main/java/com/azure/resourcemanager/models/resources/fluent/ResourcesClient.java b/typespec-tests/src/main/java/com/azure/resourcemanager/models/resources/fluent/ResourcesClient.java index 39a2825d08..eef0d18124 100644 --- a/typespec-tests/src/main/java/com/azure/resourcemanager/models/resources/fluent/ResourcesClient.java +++ b/typespec-tests/src/main/java/com/azure/resourcemanager/models/resources/fluent/ResourcesClient.java @@ -12,7 +12,7 @@ */ public interface ResourcesClient { /** - * Gets Server parameter. + * Gets Service host. * * @return the endpoint value. */ diff --git a/typespec-tests/src/main/java/com/azure/resourcemanager/models/resources/implementation/NestedProxyResourcesClientImpl.java b/typespec-tests/src/main/java/com/azure/resourcemanager/models/resources/implementation/NestedProxyResourcesClientImpl.java index f51f2eaa59..2ec2e1afe4 100644 --- a/typespec-tests/src/main/java/com/azure/resourcemanager/models/resources/implementation/NestedProxyResourcesClientImpl.java +++ b/typespec-tests/src/main/java/com/azure/resourcemanager/models/resources/implementation/NestedProxyResourcesClientImpl.java @@ -79,10 +79,9 @@ Mono> get(@HostParam("endpoint") String endpo @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, + @PathParam("nextedProxyResourceName") String nextedProxyResourceName, @HeaderParam("Accept") String accept, Context context); - @Headers({ "Content-Type: application/json" }) @Put("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.Models.Resources/topLevelTrackedResources/{topLevelTrackedResourceName}/nestedProxyResources/{nextedProxyResourceName}") @ExpectedResponses({ 200, 201 }) @UnexpectedResponseExceptionType(ManagementException.class) @@ -90,10 +89,10 @@ Mono>> createOrReplace(@HostParam("endpoint") String e @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, + @PathParam("nextedProxyResourceName") String nextedProxyResourceName, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, @BodyParam("application/json") NestedProxyResourceInner resource, Context context); - @Headers({ "Content-Type: application/json" }) @Patch("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.Models.Resources/topLevelTrackedResources/{topLevelTrackedResourceName}/nestedProxyResources/{nextedProxyResourceName}") @ExpectedResponses({ 200, 202 }) @UnexpectedResponseExceptionType(ManagementException.class) @@ -101,7 +100,8 @@ 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("accept") String accept, + @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" }) @@ -112,7 +112,7 @@ 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, + @PathParam("nextedProxyResourceName") String nextedProxyResourceName, @HeaderParam("Accept") String accept, Context context); @Headers({ "Content-Type: application/json" }) @@ -124,7 +124,7 @@ Mono> listByTopLevelTrackedResource( @PathParam("subscriptionId") String subscriptionId, @PathParam("resourceGroupName") String resourceGroupName, @PathParam("topLevelTrackedResourceName") String topLevelTrackedResourceName, - @HeaderParam("accept") String accept, Context context); + @HeaderParam("Accept") String accept, Context context); @Headers({ "Content-Type: application/json" }) @Get("{nextLink}") @@ -132,7 +132,7 @@ Mono> listByTopLevelTrackedResource( @UnexpectedResponseExceptionType(ManagementException.class) Mono> listByTopLevelTrackedResourceNext( @PathParam(value = "nextLink", encoded = true) String nextLink, @HostParam("endpoint") String endpoint, - @HeaderParam("accept") String accept, Context context); + @HeaderParam("Accept") String accept, Context context); } /** @@ -314,11 +314,12 @@ private Mono>> createOrReplaceWithResponseAsync(String } 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, accept, resource, context)) + nextedProxyResourceName, contentType, accept, resource, context)) .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); } @@ -365,11 +366,12 @@ private Mono>> createOrReplaceWithResponseAsync(String } 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, - accept, resource, context); + contentType, accept, resource, context); } /** @@ -584,11 +586,12 @@ private Mono>> updateWithResponseAsync(String resource } 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, accept, properties, context)) + nextedProxyResourceName, contentType, accept, properties, context)) .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); } @@ -635,10 +638,12 @@ private Mono>> updateWithResponseAsync(String resource } 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, accept, properties, context); + resourceGroupName, topLevelTrackedResourceName, nextedProxyResourceName, contentType, accept, properties, + context); } /** @@ -1193,6 +1198,8 @@ public PagedIterable listByTopLevelTrackedResource(Str } /** + * List NestedProxyResource resources by TopLevelTrackedResource + * * Get the next page of items. * * @param nextLink The URL to get the next list of items. @@ -1221,6 +1228,8 @@ public PagedIterable listByTopLevelTrackedResource(Str } /** + * List NestedProxyResource resources by TopLevelTrackedResource + * * Get the next page of items. * * @param nextLink The URL to get the next list of items. diff --git a/typespec-tests/src/main/java/com/azure/resourcemanager/models/resources/implementation/ResourcesClientBuilder.java b/typespec-tests/src/main/java/com/azure/resourcemanager/models/resources/implementation/ResourcesClientBuilder.java index cf7d091351..0e78a1b9e2 100644 --- a/typespec-tests/src/main/java/com/azure/resourcemanager/models/resources/implementation/ResourcesClientBuilder.java +++ b/typespec-tests/src/main/java/com/azure/resourcemanager/models/resources/implementation/ResourcesClientBuilder.java @@ -20,12 +20,12 @@ @ServiceClientBuilder(serviceClients = { ResourcesClientImpl.class }) public final class ResourcesClientBuilder { /* - * Server parameter + * Service host */ private String endpoint; /** - * Sets Server parameter. + * Sets Service host. * * @param endpoint the endpoint value. * @return the ResourcesClientBuilder. @@ -121,6 +121,7 @@ public ResourcesClientBuilder serializerAdapter(SerializerAdapter serializerAdap * @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 @@ -131,7 +132,7 @@ public ResourcesClientImpl buildClient() { ? serializerAdapter : SerializerFactory.createDefaultManagementSerializerAdapter(); ResourcesClientImpl client = new ResourcesClientImpl(localPipeline, localSerializerAdapter, - localDefaultPollInterval, localEnvironment, this.endpoint, this.subscriptionId); + localDefaultPollInterval, localEnvironment, localEndpoint, this.subscriptionId); return client; } } diff --git a/typespec-tests/src/main/java/com/azure/resourcemanager/models/resources/implementation/ResourcesClientImpl.java b/typespec-tests/src/main/java/com/azure/resourcemanager/models/resources/implementation/ResourcesClientImpl.java index 2d864ad3f2..9589bb096d 100644 --- a/typespec-tests/src/main/java/com/azure/resourcemanager/models/resources/implementation/ResourcesClientImpl.java +++ b/typespec-tests/src/main/java/com/azure/resourcemanager/models/resources/implementation/ResourcesClientImpl.java @@ -41,12 +41,12 @@ @ServiceClient(builder = ResourcesClientBuilder.class) public final class ResourcesClientImpl implements ResourcesClient { /** - * Server parameter. + * Service host. */ private final String endpoint; /** - * Gets Server parameter. + * Gets Service host. * * @return the endpoint value. */ @@ -159,7 +159,7 @@ public NestedProxyResourcesClient getNestedProxyResources() { * @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 Server parameter. + * @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, diff --git a/typespec-tests/src/main/java/com/azure/resourcemanager/models/resources/implementation/TopLevelTrackedResourcesClientImpl.java b/typespec-tests/src/main/java/com/azure/resourcemanager/models/resources/implementation/TopLevelTrackedResourcesClientImpl.java index 7250350c1b..4ce32888f2 100644 --- a/typespec-tests/src/main/java/com/azure/resourcemanager/models/resources/implementation/TopLevelTrackedResourcesClientImpl.java +++ b/typespec-tests/src/main/java/com/azure/resourcemanager/models/resources/implementation/TopLevelTrackedResourcesClientImpl.java @@ -81,9 +81,8 @@ Mono> getByResourceGroup(@HostParam("endp @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId, @PathParam("resourceGroupName") String resourceGroupName, @PathParam("topLevelTrackedResourceName") String topLevelTrackedResourceName, - @HeaderParam("accept") String accept, Context context); + @HeaderParam("Accept") String accept, Context context); - @Headers({ "Content-Type: application/json" }) @Put("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.Models.Resources/topLevelTrackedResources/{topLevelTrackedResourceName}") @ExpectedResponses({ 200, 201 }) @UnexpectedResponseExceptionType(ManagementException.class) @@ -91,10 +90,9 @@ Mono>> createOrReplace(@HostParam("endpoint") String e @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId, @PathParam("resourceGroupName") String resourceGroupName, @PathParam("topLevelTrackedResourceName") String topLevelTrackedResourceName, - @HeaderParam("accept") String accept, @BodyParam("application/json") TopLevelTrackedResourceInner resource, - Context context); + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") TopLevelTrackedResourceInner resource, Context context); - @Headers({ "Content-Type: application/json" }) @Patch("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.Models.Resources/topLevelTrackedResources/{topLevelTrackedResourceName}") @ExpectedResponses({ 200, 202 }) @UnexpectedResponseExceptionType(ManagementException.class) @@ -102,7 +100,7 @@ Mono>> update(@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, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, @BodyParam("application/json") TopLevelTrackedResourceInner properties, Context context); @Headers({ "Content-Type: application/json" }) @@ -113,7 +111,7 @@ 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); + @HeaderParam("Accept") String accept, Context context); @Headers({ "Content-Type: application/json" }) @Get("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.Models.Resources/topLevelTrackedResources") @@ -121,7 +119,7 @@ Mono>> delete(@HostParam("endpoint") String endpoint, @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, + @PathParam("resourceGroupName") String resourceGroupName, @HeaderParam("Accept") String accept, Context context); @Headers({ "Content-Type: application/json" }) @@ -130,9 +128,8 @@ Mono> listByResourceGroup(@HostParam @UnexpectedResponseExceptionType(ManagementException.class) Mono> list(@HostParam("endpoint") String endpoint, @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId, - @HeaderParam("accept") String accept, Context context); + @HeaderParam("Accept") String accept, Context context); - @Headers({ "Content-Type: application/json" }) @Post("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.Models.Resources/topLevelTrackedResources/{topLevelTrackedResourceName}/actionSync") @ExpectedResponses({ 204 }) @UnexpectedResponseExceptionType(ManagementException.class) @@ -140,8 +137,8 @@ Mono> actionSync(@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, @BodyParam("application/json") NotificationDetails body, - Context context); + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") NotificationDetails body, Context context); @Headers({ "Content-Type: application/json" }) @Get("{nextLink}") @@ -149,7 +146,7 @@ Mono> actionSync(@HostParam("endpoint") String endpoint, @UnexpectedResponseExceptionType(ManagementException.class) Mono> listByResourceGroupNext( @PathParam(value = "nextLink", encoded = true) String nextLink, @HostParam("endpoint") String endpoint, - @HeaderParam("accept") String accept, Context context); + @HeaderParam("Accept") String accept, Context context); @Headers({ "Content-Type: application/json" }) @Get("{nextLink}") @@ -157,7 +154,7 @@ Mono> listByResourceGroupNext( @UnexpectedResponseExceptionType(ManagementException.class) Mono> listBySubscriptionNext( @PathParam(value = "nextLink", encoded = true) String nextLink, @HostParam("endpoint") String endpoint, - @HeaderParam("accept") String accept, Context context); + @HeaderParam("Accept") String accept, Context context); } /** @@ -318,11 +315,12 @@ private Mono>> createOrReplaceWithResponseAsync(String } 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, accept, resource, - context)) + this.client.getSubscriptionId(), resourceGroupName, topLevelTrackedResourceName, contentType, accept, + resource, context)) .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); } @@ -363,10 +361,12 @@ private Mono>> createOrReplaceWithResponseAsync(String } 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, accept, resource, context); + this.client.getSubscriptionId(), resourceGroupName, topLevelTrackedResourceName, contentType, accept, + resource, context); } /** @@ -566,11 +566,12 @@ private Mono>> updateWithResponseAsync(String resource } 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, accept, properties, - context)) + this.client.getSubscriptionId(), resourceGroupName, topLevelTrackedResourceName, contentType, accept, + properties, context)) .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); } @@ -611,10 +612,11 @@ private Mono>> updateWithResponseAsync(String resource } 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, accept, properties, context); + resourceGroupName, topLevelTrackedResourceName, contentType, accept, properties, context); } /** @@ -1262,10 +1264,12 @@ private Mono> actionSyncWithResponseAsync(String resourceGroupNam } else { body.validate(); } + final String contentType = "application/json"; final String accept = "application/json"; return FluxUtil .withContext(context -> service.actionSync(this.client.getEndpoint(), this.client.getApiVersion(), - this.client.getSubscriptionId(), resourceGroupName, topLevelTrackedResourceName, accept, body, context)) + this.client.getSubscriptionId(), resourceGroupName, topLevelTrackedResourceName, contentType, accept, + body, context)) .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); } @@ -1305,10 +1309,12 @@ private Mono> actionSyncWithResponseAsync(String resourceGroupNam } else { body.validate(); } + final String contentType = "application/json"; final String accept = "application/json"; context = this.client.mergeContext(context); return service.actionSync(this.client.getEndpoint(), this.client.getApiVersion(), - this.client.getSubscriptionId(), resourceGroupName, topLevelTrackedResourceName, accept, body, context); + this.client.getSubscriptionId(), resourceGroupName, topLevelTrackedResourceName, contentType, accept, body, + context); } /** @@ -1363,6 +1369,8 @@ public void actionSync(String resourceGroupName, String topLevelTrackedResourceN } /** + * List TopLevelTrackedResource resources by resource group + * * Get the next page of items. * * @param nextLink The URL to get the next list of items. @@ -1391,6 +1399,8 @@ private Mono> listByResourceGroupNex } /** + * List TopLevelTrackedResource resources by resource group + * * Get the next page of items. * * @param nextLink The URL to get the next list of items. @@ -1419,6 +1429,8 @@ private Mono> listByResourceGroupNex } /** + * List TopLevelTrackedResource resources by subscription ID + * * Get the next page of items. * * @param nextLink The URL to get the next list of items. @@ -1447,6 +1459,8 @@ private Mono> listBySubscriptionNext } /** + * List TopLevelTrackedResource resources by subscription ID + * * Get the next page of items. * * @param nextLink The URL to get the next list of items. diff --git a/typespec-tests/src/main/java/com/azure/specialheaders/xmsclientrequestid/XmsClientRequestIdClientBuilder.java b/typespec-tests/src/main/java/com/azure/specialheaders/xmsclientrequestid/XmsClientRequestIdClientBuilder.java index 940ee6b158..2fe64474b2 100644 --- a/typespec-tests/src/main/java/com/azure/specialheaders/xmsclientrequestid/XmsClientRequestIdClientBuilder.java +++ b/typespec-tests/src/main/java/com/azure/specialheaders/xmsclientrequestid/XmsClientRequestIdClientBuilder.java @@ -7,6 +7,7 @@ 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; @@ -40,8 +41,8 @@ * A builder for creating a new instance of the XmsClientRequestIdClient type. */ @ServiceClientBuilder(serviceClients = { XmsClientRequestIdClient.class, XmsClientRequestIdAsyncClient.class }) -public final class XmsClientRequestIdClientBuilder - implements HttpTrait, ConfigurationTrait { +public final class XmsClientRequestIdClientBuilder implements HttpTrait, + ConfigurationTrait, EndpointTrait { @Generated private static final String SDK_NAME = "name"; @@ -173,6 +174,22 @@ public XmsClientRequestIdClientBuilder configuration(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. */ @@ -200,8 +217,9 @@ public XmsClientRequestIdClientBuilder retryPolicy(RetryPolicy retryPolicy) { private XmsClientRequestIdClientImpl buildInnerClient() { this.validateClient(); HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); - XmsClientRequestIdClientImpl client - = new XmsClientRequestIdClientImpl(localPipeline, JacksonAdapter.createDefaultSerializerAdapter()); + String localEndpoint = (endpoint != null) ? endpoint : "http://localhost:3000"; + XmsClientRequestIdClientImpl client = new XmsClientRequestIdClientImpl(localPipeline, + JacksonAdapter.createDefaultSerializerAdapter(), localEndpoint); return client; } diff --git a/typespec-tests/src/main/java/com/azure/specialheaders/xmsclientrequestid/implementation/XmsClientRequestIdClientImpl.java b/typespec-tests/src/main/java/com/azure/specialheaders/xmsclientrequestid/implementation/XmsClientRequestIdClientImpl.java index d492df3332..d416106f38 100644 --- a/typespec-tests/src/main/java/com/azure/specialheaders/xmsclientrequestid/implementation/XmsClientRequestIdClientImpl.java +++ b/typespec-tests/src/main/java/com/azure/specialheaders/xmsclientrequestid/implementation/XmsClientRequestIdClientImpl.java @@ -6,8 +6,8 @@ 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; @@ -38,6 +38,20 @@ public final class XmsClientRequestIdClientImpl { */ 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. */ @@ -68,19 +82,22 @@ public SerializerAdapter getSerializerAdapter() { /** * Initializes an instance of XmsClientRequestIdClient client. + * + * @param endpoint Service host. */ - public XmsClientRequestIdClientImpl() { + public XmsClientRequestIdClientImpl(String endpoint) { this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), - JacksonAdapter.createDefaultSerializerAdapter()); + 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) { - this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter()); + public XmsClientRequestIdClientImpl(HttpPipeline httpPipeline, String endpoint) { + this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint); } /** @@ -88,10 +105,13 @@ public XmsClientRequestIdClientImpl(HttpPipeline httpPipeline) { * * @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) { + 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()); } @@ -100,7 +120,7 @@ public XmsClientRequestIdClientImpl(HttpPipeline httpPipeline, SerializerAdapter * The interface defining all the services for XmsClientRequestIdClient to be used by the proxy service to perform * REST calls. */ - @Host("http://localhost:3000") + @Host("{endpoint}") @ServiceInterface(name = "XmsClientRequestIdCl") public interface XmsClientRequestIdClientService { @Get("/azure/special-headers/x-ms-client-request-id/") @@ -109,7 +129,8 @@ public interface XmsClientRequestIdClientService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> get(@HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + Mono> get(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, + Context context); @Get("/azure/special-headers/x-ms-client-request-id/") @ExpectedResponses({ 204 }) @@ -117,7 +138,7 @@ public interface XmsClientRequestIdClientService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response getSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + Response getSync(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, Context context); } /** @@ -133,8 +154,7 @@ public interface XmsClientRequestIdClientService { */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getWithResponseAsync(RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.get(accept, requestOptions, context)); + return FluxUtil.withContext(context -> service.get(this.getEndpoint(), requestOptions, context)); } /** @@ -149,7 +169,6 @@ public Mono> getWithResponseAsync(RequestOptions requestOptions) */ @ServiceMethod(returns = ReturnType.SINGLE) public Response getWithResponse(RequestOptions requestOptions) { - final String accept = "application/json"; - return service.getSync(accept, requestOptions, Context.NONE); + return service.getSync(this.getEndpoint(), requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/cadl/armresourceprovider/fluent/ArmResourceProviderClient.java b/typespec-tests/src/main/java/com/cadl/armresourceprovider/fluent/ArmResourceProviderClient.java index 3bd6f9112f..aabdbaebb3 100644 --- a/typespec-tests/src/main/java/com/cadl/armresourceprovider/fluent/ArmResourceProviderClient.java +++ b/typespec-tests/src/main/java/com/cadl/armresourceprovider/fluent/ArmResourceProviderClient.java @@ -12,7 +12,7 @@ */ public interface ArmResourceProviderClient { /** - * Gets Server parameter. + * Gets Service host. * * @return the endpoint value. */ diff --git a/typespec-tests/src/main/java/com/cadl/armresourceprovider/implementation/ArmResourceProviderClientBuilder.java b/typespec-tests/src/main/java/com/cadl/armresourceprovider/implementation/ArmResourceProviderClientBuilder.java index 2b36c77e05..2a1cab1217 100644 --- a/typespec-tests/src/main/java/com/cadl/armresourceprovider/implementation/ArmResourceProviderClientBuilder.java +++ b/typespec-tests/src/main/java/com/cadl/armresourceprovider/implementation/ArmResourceProviderClientBuilder.java @@ -20,12 +20,12 @@ @ServiceClientBuilder(serviceClients = { ArmResourceProviderClientImpl.class }) public final class ArmResourceProviderClientBuilder { /* - * Server parameter + * Service host */ private String endpoint; /** - * Sets Server parameter. + * Sets Service host. * * @param endpoint the endpoint value. * @return the ArmResourceProviderClientBuilder. @@ -121,6 +121,7 @@ public ArmResourceProviderClientBuilder serializerAdapter(SerializerAdapter seri * @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 @@ -131,7 +132,7 @@ public ArmResourceProviderClientImpl buildClient() { ? serializerAdapter : SerializerFactory.createDefaultManagementSerializerAdapter(); ArmResourceProviderClientImpl client = new ArmResourceProviderClientImpl(localPipeline, localSerializerAdapter, - localDefaultPollInterval, localEnvironment, this.endpoint, this.subscriptionId); + localDefaultPollInterval, localEnvironment, localEndpoint, this.subscriptionId); return client; } } diff --git a/typespec-tests/src/main/java/com/cadl/armresourceprovider/implementation/ArmResourceProviderClientImpl.java b/typespec-tests/src/main/java/com/cadl/armresourceprovider/implementation/ArmResourceProviderClientImpl.java index 4e9ca21142..e4703c14c4 100644 --- a/typespec-tests/src/main/java/com/cadl/armresourceprovider/implementation/ArmResourceProviderClientImpl.java +++ b/typespec-tests/src/main/java/com/cadl/armresourceprovider/implementation/ArmResourceProviderClientImpl.java @@ -44,12 +44,12 @@ @ServiceClient(builder = ArmResourceProviderClientBuilder.class) public final class ArmResourceProviderClientImpl implements ArmResourceProviderClient { /** - * Server parameter. + * Service host. */ private final String endpoint; /** - * Gets Server parameter. + * Gets Service host. * * @return the endpoint value. */ @@ -204,7 +204,7 @@ public ChildExtensionResourceInterfacesClient getChildExtensionResourceInterface * @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 Server parameter. + * @param endpoint Service host. * @param subscriptionId The ID of the target subscription. The value must be an UUID. */ ArmResourceProviderClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, diff --git a/typespec-tests/src/main/java/com/cadl/armresourceprovider/implementation/ChildExtensionResourceInterfacesClientImpl.java b/typespec-tests/src/main/java/com/cadl/armresourceprovider/implementation/ChildExtensionResourceInterfacesClientImpl.java index 9acc1ad080..26aab67662 100644 --- a/typespec-tests/src/main/java/com/cadl/armresourceprovider/implementation/ChildExtensionResourceInterfacesClientImpl.java +++ b/typespec-tests/src/main/java/com/cadl/armresourceprovider/implementation/ChildExtensionResourceInterfacesClientImpl.java @@ -80,9 +80,8 @@ Mono> get(@HostParam("endpoint") String en @QueryParam("api-version") String apiVersion, @PathParam("resourceUri") String resourceUri, @PathParam("topLevelArmResourceName") String topLevelArmResourceName, @PathParam("childExtensionResourceName") String childExtensionResourceName, - @HeaderParam("accept") String accept, Context context); + @HeaderParam("Accept") String accept, Context context); - @Headers({ "Content-Type: application/json" }) @Put("/{resourceUri}/providers/Cadl.ArmResourceProvider/topLevelArmResources/{topLevelArmResourceName}/childExtensionResources/{childExtensionResourceName}") @ExpectedResponses({ 200, 201 }) @UnexpectedResponseExceptionType(ManagementException.class) @@ -90,10 +89,9 @@ Mono>> createOrUpdate(@HostParam("endpoint") String en @QueryParam("api-version") String apiVersion, @PathParam("resourceUri") String resourceUri, @PathParam("topLevelArmResourceName") String topLevelArmResourceName, @PathParam("childExtensionResourceName") String childExtensionResourceName, - @HeaderParam("accept") String accept, @BodyParam("application/json") ChildExtensionResourceInner resource, - Context context); + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") ChildExtensionResourceInner resource, Context context); - @Headers({ "Content-Type: application/json" }) @Patch("/{resourceUri}/providers/Cadl.ArmResourceProvider/topLevelArmResources/{topLevelArmResourceName}/childExtensionResources/{childExtensionResourceName}") @ExpectedResponses({ 200 }) @UnexpectedResponseExceptionType(ManagementException.class) @@ -101,7 +99,7 @@ Mono> update(@HostParam("endpoint") String @QueryParam("api-version") String apiVersion, @PathParam("resourceUri") String resourceUri, @PathParam("topLevelArmResourceName") String topLevelArmResourceName, @PathParam("childExtensionResourceName") String childExtensionResourceName, - @HeaderParam("accept") String accept, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, @BodyParam("application/json") ChildExtensionResourceUpdate properties, Context context); @Headers({ "Content-Type: application/json" }) @@ -112,7 +110,7 @@ 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); + @HeaderParam("Accept") String accept, Context context); @Headers({ "Content-Type: application/json" }) @Get("/{resourceUri}/providers/Cadl.ArmResourceProvider/topLevelArmResources/{topLevelArmResourceName}/childExtensionResources") @@ -121,7 +119,7 @@ Mono>> delete(@HostParam("endpoint") String endpoint, Mono> listByTopLevelArmResource( @HostParam("endpoint") String endpoint, @QueryParam("api-version") String apiVersion, @PathParam("resourceUri") String resourceUri, - @PathParam("topLevelArmResourceName") String topLevelArmResourceName, @HeaderParam("accept") String accept, + @PathParam("topLevelArmResourceName") String topLevelArmResourceName, @HeaderParam("Accept") String accept, Context context); @Headers({ "Content-Type: application/json" }) @@ -130,7 +128,7 @@ Mono> listByTopLevelArmResource( @UnexpectedResponseExceptionType(ManagementException.class) Mono> listByTopLevelArmResourceNext( @PathParam(value = "nextLink", encoded = true) String nextLink, @HostParam("endpoint") String endpoint, - @HeaderParam("accept") String accept, Context context); + @HeaderParam("Accept") String accept, Context context); } /** @@ -295,10 +293,12 @@ private Mono>> createOrUpdateWithResponseAsync(String } 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, accept, resource, context)) + .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())); } @@ -340,10 +340,11 @@ private Mono>> createOrUpdateWithResponseAsync(String } 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, accept, resource, context); + topLevelArmResourceName, childExtensionResourceName, contentType, accept, resource, context); } /** @@ -551,10 +552,11 @@ private Mono> updateWithResponseAsync(Stri } 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, accept, properties, context)) + topLevelArmResourceName, childExtensionResourceName, contentType, accept, properties, context)) .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); } @@ -596,10 +598,11 @@ private Mono> updateWithResponseAsync(Stri } 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, accept, properties, context); + topLevelArmResourceName, childExtensionResourceName, contentType, accept, properties, context); } /** @@ -1018,6 +1021,8 @@ public PagedIterable listByTopLevelArmResource(Stri } /** + * List ChildExtensionResource resources by TopLevelArmResource + * * Get the next page of items. * * @param nextLink The URL to get the next list of items. @@ -1047,6 +1052,8 @@ public PagedIterable listByTopLevelArmResource(Stri } /** + * List ChildExtensionResource resources by TopLevelArmResource + * * Get the next page of items. * * @param nextLink The URL to get the next list of items. diff --git a/typespec-tests/src/main/java/com/cadl/armresourceprovider/implementation/ChildResourcesInterfacesClientImpl.java b/typespec-tests/src/main/java/com/cadl/armresourceprovider/implementation/ChildResourcesInterfacesClientImpl.java index ecbd02657b..ec02ebc5f6 100644 --- a/typespec-tests/src/main/java/com/cadl/armresourceprovider/implementation/ChildResourcesInterfacesClientImpl.java +++ b/typespec-tests/src/main/java/com/cadl/armresourceprovider/implementation/ChildResourcesInterfacesClientImpl.java @@ -81,10 +81,9 @@ 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, + @PathParam("childResourceName") String childResourceName, @HeaderParam("Accept") String accept, Context context); - @Headers({ "Content-Type: application/json" }) @Put("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Cadl.ArmResourceProvider/topLevelArmResources/{topLevelArmResourceName}/childResources/{childResourceName}") @ExpectedResponses({ 200, 201 }) @UnexpectedResponseExceptionType(ManagementException.class) @@ -92,10 +91,10 @@ Mono>> createOrUpdate(@HostParam("endpoint") String en @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, - @BodyParam("application/json") ChildResourceInner resource, Context context); + @PathParam("childResourceName") String childResourceName, @HeaderParam("Content-Type") String contentType, + @HeaderParam("Accept") String accept, @BodyParam("application/json") ChildResourceInner resource, + Context context); - @Headers({ "Content-Type: application/json" }) @Patch("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Cadl.ArmResourceProvider/topLevelArmResources/{topLevelArmResourceName}/childResources/{childResourceName}") @ExpectedResponses({ 200 }) @UnexpectedResponseExceptionType(ManagementException.class) @@ -103,8 +102,9 @@ 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("accept") String accept, - @BodyParam("application/json") ChildResourceUpdate properties, Context context); + @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}") @@ -114,7 +114,7 @@ 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, + @PathParam("childResourceName") String childResourceName, @HeaderParam("Accept") String accept, Context context); @Headers({ "Content-Type: application/json" }) @@ -124,7 +124,7 @@ Mono>> delete(@HostParam("endpoint") String endpoint, 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, + @PathParam("topLevelArmResourceName") String topLevelArmResourceName, @HeaderParam("Accept") String accept, Context context); @Headers({ "Content-Type: application/json" }) @@ -135,7 +135,7 @@ Mono>> actionWithoutBody(@HostParam("endpoint") String @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, + @PathParam("childResourceName") String childResourceName, @HeaderParam("Accept") String accept, Context context); @Headers({ "Content-Type: application/json" }) @@ -144,7 +144,7 @@ Mono>> actionWithoutBody(@HostParam("endpoint") String @UnexpectedResponseExceptionType(ManagementException.class) Mono> listByTopLevelArmResourceNext( @PathParam(value = "nextLink", encoded = true) String nextLink, @HostParam("endpoint") String endpoint, - @HeaderParam("accept") String accept, Context context); + @HeaderParam("Accept") String accept, Context context); } /** @@ -323,11 +323,12 @@ private Mono>> createOrUpdateWithResponseAsync(String } 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, accept, - resource, context)) + this.client.getSubscriptionId(), resourceGroupName, topLevelArmResourceName, childResourceName, + contentType, accept, resource, context)) .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); } @@ -373,11 +374,12 @@ private Mono>> createOrUpdateWithResponseAsync(String } 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, accept, - resource, context); + this.client.getSubscriptionId(), resourceGroupName, topLevelArmResourceName, childResourceName, contentType, + accept, resource, context); } /** @@ -584,11 +586,12 @@ private Mono> updateWithResponseAsync(String resour } 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, accept, - properties, context)) + this.client.getSubscriptionId(), resourceGroupName, topLevelArmResourceName, childResourceName, + contentType, accept, properties, context)) .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); } @@ -634,10 +637,11 @@ private Mono> updateWithResponseAsync(String resour } 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, accept, properties, context); + resourceGroupName, topLevelArmResourceName, childResourceName, contentType, accept, properties, context); } /** @@ -1311,6 +1315,8 @@ public void actionWithoutBody(String resourceGroupName, String topLevelArmResour } /** + * List ChildResource resources by TopLevelArmResource + * * Get the next page of items. * * @param nextLink The URL to get the next list of items. @@ -1339,6 +1345,8 @@ private Mono> listByTopLevelArmResourceNextSin } /** + * List ChildResource resources by TopLevelArmResource + * * Get the next page of items. * * @param nextLink The URL to get the next list of items. diff --git a/typespec-tests/src/main/java/com/cadl/armresourceprovider/implementation/CustomTemplateResourceInterfacesClientImpl.java b/typespec-tests/src/main/java/com/cadl/armresourceprovider/implementation/CustomTemplateResourceInterfacesClientImpl.java index f7e3bf336b..8b208a8563 100644 --- a/typespec-tests/src/main/java/com/cadl/armresourceprovider/implementation/CustomTemplateResourceInterfacesClientImpl.java +++ b/typespec-tests/src/main/java/com/cadl/armresourceprovider/implementation/CustomTemplateResourceInterfacesClientImpl.java @@ -7,7 +7,6 @@ import com.azure.core.annotation.BodyParam; import com.azure.core.annotation.ExpectedResponses; 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; @@ -65,7 +64,6 @@ public final class CustomTemplateResourceInterfacesClientImpl implements CustomT @Host("{endpoint}") @ServiceInterface(name = "ArmResourceProviderC") public interface CustomTemplateResourceInterfacesService { - @Headers({ "Content-Type: application/json" }) @Put("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Cadl.ArmResourceProvider/customTemplateResources/{customTemplateResourceName}") @ExpectedResponses({ 200, 201 }) @UnexpectedResponseExceptionType(ManagementException.class) @@ -74,10 +72,9 @@ Mono>> createOrUpdate(@HostParam("endpoint") String en @PathParam("resourceGroupName") String resourceGroupName, @HeaderParam("If-Match") String ifMatch, @HeaderParam("If-None-Match") String ifNoneMatch, @PathParam("customTemplateResourceName") String customTemplateResourceName, - @HeaderParam("accept") String accept, @BodyParam("application/json") CustomTemplateResourceInner resource, - Context context); + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") CustomTemplateResourceInner resource, Context context); - @Headers({ "Content-Type: application/json" }) @Patch("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Cadl.ArmResourceProvider/customTemplateResources/{customTemplateResourceName}") @ExpectedResponses({ 200, 202 }) @UnexpectedResponseExceptionType(ManagementException.class) @@ -85,8 +82,8 @@ Mono>> updateLongRunning(@HostParam("endpoint") String @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId, @PathParam("resourceGroupName") String resourceGroupName, @PathParam("customTemplateResourceName") String customTemplateResourceName, - @HeaderParam("accept") String accept, @BodyParam("application/json") CustomTemplateResourcePatch properties, - Context context); + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") CustomTemplateResourcePatch properties, Context context); } /** @@ -127,11 +124,12 @@ private Mono>> createOrUpdateWithResponseAsync(String } 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, - accept, resource, context)) + contentType, accept, resource, context)) .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); } @@ -175,11 +173,12 @@ private Mono>> createOrUpdateWithResponseAsync(String } 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, - accept, resource, context); + contentType, accept, resource, context); } /** @@ -449,11 +448,12 @@ private Mono>> updateLongRunningWithResponseAsync(Stri } 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, accept, properties, - context)) + this.client.getSubscriptionId(), resourceGroupName, customTemplateResourceName, contentType, accept, + properties, context)) .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); } @@ -494,11 +494,12 @@ private Mono>> updateLongRunningWithResponseAsync(Stri } 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, accept, properties, - context); + this.client.getSubscriptionId(), resourceGroupName, customTemplateResourceName, contentType, accept, + properties, context); } /** diff --git a/typespec-tests/src/main/java/com/cadl/armresourceprovider/implementation/OperationsClientImpl.java b/typespec-tests/src/main/java/com/cadl/armresourceprovider/implementation/OperationsClientImpl.java index a41589074e..0c2de7e03f 100644 --- a/typespec-tests/src/main/java/com/cadl/armresourceprovider/implementation/OperationsClientImpl.java +++ b/typespec-tests/src/main/java/com/cadl/armresourceprovider/implementation/OperationsClientImpl.java @@ -67,14 +67,14 @@ public interface OperationsService { @ExpectedResponses({ 200 }) @UnexpectedResponseExceptionType(ManagementException.class) Mono> list(@HostParam("endpoint") String endpoint, - @QueryParam("api-version") String apiVersion, @HeaderParam("accept") String accept, Context context); + @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); + @HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, Context context); } /** @@ -181,6 +181,8 @@ public PagedIterable list(Context context) { } /** + * List the operations for the provider + * * Get the next page of items. * * @param nextLink The URL to get the next list of items. @@ -207,6 +209,8 @@ private Mono> listNextSinglePageAsync(String nextL } /** + * List the operations for the provider + * * Get the next page of items. * * @param nextLink The URL to get the next list of items. diff --git a/typespec-tests/src/main/java/com/cadl/armresourceprovider/implementation/TopLevelArmResourceInterfacesClientImpl.java b/typespec-tests/src/main/java/com/cadl/armresourceprovider/implementation/TopLevelArmResourceInterfacesClientImpl.java index e1ebb896ef..7b5b9ce130 100644 --- a/typespec-tests/src/main/java/com/cadl/armresourceprovider/implementation/TopLevelArmResourceInterfacesClientImpl.java +++ b/typespec-tests/src/main/java/com/cadl/armresourceprovider/implementation/TopLevelArmResourceInterfacesClientImpl.java @@ -81,27 +81,27 @@ public interface TopLevelArmResourceInterfacesService { 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, + @PathParam("topLevelArmResourceName") String topLevelArmResourceName, @HeaderParam("Accept") String accept, Context context); - @Headers({ "Content-Type: application/json" }) @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("accept") String accept, + @PathParam("topLevelArmResourceName") String topLevelArmResourceName, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, @BodyParam("application/json") TopLevelArmResourceInner resource, Context context); - @Headers({ "Content-Type: application/json" }) @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("accept") String accept, + @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" }) @@ -111,7 +111,7 @@ Mono> update(@HostParam("endpoint") String en 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, + @PathParam("topLevelArmResourceName") String topLevelArmResourceName, @HeaderParam("Accept") String accept, Context context); @Headers({ "Content-Type: application/json" }) @@ -120,7 +120,7 @@ Mono>> delete(@HostParam("endpoint") String endpoint, @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, + @PathParam("resourceGroupName") String resourceGroupName, @HeaderParam("Accept") String accept, Context context); @Headers({ "Content-Type: application/json" }) @@ -129,7 +129,7 @@ Mono> listByResourceGroup(@HostParam("en @UnexpectedResponseExceptionType(ManagementException.class) Mono> list(@HostParam("endpoint") String endpoint, @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId, - @HeaderParam("accept") String accept, Context context); + @HeaderParam("Accept") String accept, Context context); @Headers({ "Content-Type: application/json" }) @Post("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Cadl.ArmResourceProvider/topLevelArmResources/{topLevelArmResourceName}/action") @@ -138,7 +138,7 @@ Mono> list(@HostParam("endpoint") String 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, + @PathParam("topLevelArmResourceName") String topLevelArmResourceName, @HeaderParam("Accept") String accept, Context context); @Headers({ "Content-Type: application/json" }) @@ -147,7 +147,7 @@ Mono>> action(@HostParam("endpoint") String endpoint, @UnexpectedResponseExceptionType(ManagementException.class) Mono> listByResourceGroupNext( @PathParam(value = "nextLink", encoded = true) String nextLink, @HostParam("endpoint") String endpoint, - @HeaderParam("accept") String accept, Context context); + @HeaderParam("Accept") String accept, Context context); @Headers({ "Content-Type: application/json" }) @Get("{nextLink}") @@ -155,7 +155,7 @@ Mono> listByResourceGroupNext( @UnexpectedResponseExceptionType(ManagementException.class) Mono> listBySubscriptionNext( @PathParam(value = "nextLink", encoded = true) String nextLink, @HostParam("endpoint") String endpoint, - @HeaderParam("accept") String accept, Context context); + @HeaderParam("Accept") String accept, Context context); } /** @@ -315,10 +315,12 @@ private Mono>> createOrUpdateWithResponseAsync(String } 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, accept, resource, context)) + this.client.getSubscriptionId(), resourceGroupName, topLevelArmResourceName, contentType, accept, + resource, context)) .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); } @@ -359,10 +361,12 @@ private Mono>> createOrUpdateWithResponseAsync(String } 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, accept, resource, context); + this.client.getSubscriptionId(), resourceGroupName, topLevelArmResourceName, contentType, accept, resource, + context); } /** @@ -558,9 +562,12 @@ private Mono> updateWithResponseAsync(String } 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, accept, properties, context)) + 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())); } @@ -601,10 +608,11 @@ private Mono> updateWithResponseAsync(String } 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, accept, properties, context); + resourceGroupName, topLevelArmResourceName, contentType, accept, properties, context); } /** @@ -1314,6 +1322,8 @@ public ResultInner action(String resourceGroupName, String topLevelArmResourceNa } /** + * List TopLevelArmResource resources by resource group + * * Get the next page of items. * * @param nextLink The URL to get the next list of items. @@ -1342,6 +1352,8 @@ private Mono> listByResourceGroupNextSin } /** + * List TopLevelArmResource resources by resource group + * * Get the next page of items. * * @param nextLink The URL to get the next list of items. @@ -1370,6 +1382,8 @@ private Mono> listByResourceGroupNextSin } /** + * List TopLevelArmResource resources by subscription ID + * * Get the next page of items. * * @param nextLink The URL to get the next list of items. @@ -1398,6 +1412,8 @@ private Mono> listBySubscriptionNextSing } /** + * List TopLevelArmResource resources by subscription ID + * * Get the next page of items. * * @param nextLink The URL to get the next list of items. diff --git a/typespec-tests/src/main/java/com/cadl/armstreamstyleserialization/fluent/ArmStreamStyleSerializationClient.java b/typespec-tests/src/main/java/com/cadl/armstreamstyleserialization/fluent/ArmStreamStyleSerializationClient.java index ce27e1bede..ce6c002ee6 100644 --- a/typespec-tests/src/main/java/com/cadl/armstreamstyleserialization/fluent/ArmStreamStyleSerializationClient.java +++ b/typespec-tests/src/main/java/com/cadl/armstreamstyleserialization/fluent/ArmStreamStyleSerializationClient.java @@ -12,7 +12,7 @@ */ public interface ArmStreamStyleSerializationClient { /** - * Gets Server parameter. + * Gets Service host. * * @return the endpoint value. */ diff --git a/typespec-tests/src/main/java/com/cadl/armstreamstyleserialization/implementation/ArmStreamStyleSerializationClientBuilder.java b/typespec-tests/src/main/java/com/cadl/armstreamstyleserialization/implementation/ArmStreamStyleSerializationClientBuilder.java index 9b10cf2326..035c58e4cd 100644 --- a/typespec-tests/src/main/java/com/cadl/armstreamstyleserialization/implementation/ArmStreamStyleSerializationClientBuilder.java +++ b/typespec-tests/src/main/java/com/cadl/armstreamstyleserialization/implementation/ArmStreamStyleSerializationClientBuilder.java @@ -20,12 +20,12 @@ @ServiceClientBuilder(serviceClients = { ArmStreamStyleSerializationClientImpl.class }) public final class ArmStreamStyleSerializationClientBuilder { /* - * Server parameter + * Service host */ private String endpoint; /** - * Sets Server parameter. + * Sets Service host. * * @param endpoint the endpoint value. * @return the ArmStreamStyleSerializationClientBuilder. @@ -121,6 +121,7 @@ public ArmStreamStyleSerializationClientBuilder serializerAdapter(SerializerAdap * @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 @@ -131,7 +132,7 @@ public ArmStreamStyleSerializationClientImpl buildClient() { ? serializerAdapter : SerializerFactory.createDefaultManagementSerializerAdapter(); ArmStreamStyleSerializationClientImpl client = new ArmStreamStyleSerializationClientImpl(localPipeline, - localSerializerAdapter, localDefaultPollInterval, localEnvironment, this.endpoint, this.subscriptionId); + localSerializerAdapter, localDefaultPollInterval, localEnvironment, localEndpoint, this.subscriptionId); return client; } } diff --git a/typespec-tests/src/main/java/com/cadl/armstreamstyleserialization/implementation/ArmStreamStyleSerializationClientImpl.java b/typespec-tests/src/main/java/com/cadl/armstreamstyleserialization/implementation/ArmStreamStyleSerializationClientImpl.java index 29c56c88aa..5abcf9e421 100644 --- a/typespec-tests/src/main/java/com/cadl/armstreamstyleserialization/implementation/ArmStreamStyleSerializationClientImpl.java +++ b/typespec-tests/src/main/java/com/cadl/armstreamstyleserialization/implementation/ArmStreamStyleSerializationClientImpl.java @@ -41,12 +41,12 @@ @ServiceClient(builder = ArmStreamStyleSerializationClientBuilder.class) public final class ArmStreamStyleSerializationClientImpl implements ArmStreamStyleSerializationClient { /** - * Server parameter. + * Service host. */ private final String endpoint; /** - * Gets Server parameter. + * Gets Service host. * * @return the endpoint value. */ @@ -159,7 +159,7 @@ public TopLevelArmResourcesClient getTopLevelArmResources() { * @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 Server parameter. + * @param endpoint Service host. * @param subscriptionId The ID of the target subscription. The value must be an UUID. */ ArmStreamStyleSerializationClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, diff --git a/typespec-tests/src/main/java/com/cadl/armstreamstyleserialization/implementation/FishesClientImpl.java b/typespec-tests/src/main/java/com/cadl/armstreamstyleserialization/implementation/FishesClientImpl.java index 73f6f44239..e3fea3a3e8 100644 --- a/typespec-tests/src/main/java/com/cadl/armstreamstyleserialization/implementation/FishesClientImpl.java +++ b/typespec-tests/src/main/java/com/cadl/armstreamstyleserialization/implementation/FishesClientImpl.java @@ -63,14 +63,14 @@ public interface FishesService { @Get("/model") @ExpectedResponses({ 200 }) @UnexpectedResponseExceptionType(ErrorException.class) - Mono> getModel(@HostParam("endpoint") String endpoint, @HeaderParam("accept") String accept, + Mono> getModel(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, Context context); - @Headers({ "Content-Type: application/json" }) @Put("/model") @ExpectedResponses({ 200 }) @UnexpectedResponseExceptionType(ErrorMinException.class) - Mono> putModel(@HostParam("endpoint") String endpoint, @HeaderParam("accept") String accept, + 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" }) @@ -78,7 +78,7 @@ Mono> putModel(@HostParam("endpoint") String endpoint, @Head @ExpectedResponses({ 200 }) @UnexpectedResponseExceptionType(ManagementException.class) Mono> getOutputOnlyModel(@HostParam("endpoint") String endpoint, - @HeaderParam("accept") String accept, Context context); + @HeaderParam("Accept") String accept, Context context); } /** @@ -182,8 +182,10 @@ private Mono> putModelWithResponseAsync(FishInner fish) { } else { fish.validate(); } + final String contentType = "application/json"; final String accept = "application/json"; - return FluxUtil.withContext(context -> service.putModel(this.client.getEndpoint(), accept, fish, context)) + return FluxUtil + .withContext(context -> service.putModel(this.client.getEndpoint(), contentType, accept, fish, context)) .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); } @@ -209,9 +211,10 @@ private Mono> putModelWithResponseAsync(FishInner fish, Cont } else { fish.validate(); } + final String contentType = "application/json"; final String accept = "application/json"; context = this.client.mergeContext(context); - return service.putModel(this.client.getEndpoint(), accept, fish, context); + return service.putModel(this.client.getEndpoint(), contentType, accept, fish, context); } /** diff --git a/typespec-tests/src/main/java/com/cadl/armstreamstyleserialization/implementation/TopLevelArmResourcesClientImpl.java b/typespec-tests/src/main/java/com/cadl/armstreamstyleserialization/implementation/TopLevelArmResourcesClientImpl.java index 7088f30ffd..9392abb7bc 100644 --- a/typespec-tests/src/main/java/com/cadl/armstreamstyleserialization/implementation/TopLevelArmResourcesClientImpl.java +++ b/typespec-tests/src/main/java/com/cadl/armstreamstyleserialization/implementation/TopLevelArmResourcesClientImpl.java @@ -7,7 +7,6 @@ import com.azure.core.annotation.BodyParam; import com.azure.core.annotation.ExpectedResponses; 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; @@ -64,14 +63,14 @@ public final class TopLevelArmResourcesClientImpl implements TopLevelArmResource @Host("{endpoint}") @ServiceInterface(name = "ArmStreamStyleSerial") public interface TopLevelArmResourcesService { - @Headers({ "Content-Type: application/json" }) @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("accept") String accept, + @PathParam("topLevelArmResourceName") String topLevelArmResourceName, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, @BodyParam("application/json") TopLevelArmResourceTagsUpdate properties, Context context); } @@ -111,9 +110,12 @@ private Mono>> updateWithResponseAsync(String resource } 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, accept, properties, context)) + 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())); } @@ -154,10 +156,11 @@ private Mono>> updateWithResponseAsync(String resource } 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, accept, properties, context); + resourceGroupName, topLevelArmResourceName, contentType, accept, properties, context); } /** diff --git a/typespec-tests/src/main/java/com/cadl/builtin/implementation/BuiltinClientImpl.java b/typespec-tests/src/main/java/com/cadl/builtin/implementation/BuiltinClientImpl.java index 169d20a90e..5bfa379806 100644 --- a/typespec-tests/src/main/java/com/cadl/builtin/implementation/BuiltinClientImpl.java +++ b/typespec-tests/src/main/java/com/cadl/builtin/implementation/BuiltinClientImpl.java @@ -16,12 +16,12 @@ */ public final class BuiltinClientImpl { /** - * Server parameter. + * Service host. */ private final String endpoint; /** - * Gets Server parameter. + * Gets Service host. * * @return the endpoint value. */ @@ -74,7 +74,7 @@ public BuiltinOpsImpl getBuiltinOps() { /** * Initializes an instance of BuiltinClient client. * - * @param endpoint Server parameter. + * @param endpoint Service host. */ public BuiltinClientImpl(String endpoint) { this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), @@ -85,7 +85,7 @@ public BuiltinClientImpl(String endpoint) { * Initializes an instance of BuiltinClient client. * * @param httpPipeline The HTTP pipeline to send requests through. - * @param endpoint Server parameter. + * @param endpoint Service host. */ public BuiltinClientImpl(HttpPipeline httpPipeline, String endpoint) { this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint); @@ -96,7 +96,7 @@ public BuiltinClientImpl(HttpPipeline httpPipeline, String endpoint) { * * @param httpPipeline The HTTP pipeline to send requests through. * @param serializerAdapter The serializer to serialize an object into a string. - * @param endpoint Server parameter. + * @param endpoint Service host. */ public BuiltinClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, String endpoint) { this.httpPipeline = httpPipeline; diff --git a/typespec-tests/src/main/java/com/cadl/builtin/implementation/BuiltinOpsImpl.java b/typespec-tests/src/main/java/com/cadl/builtin/implementation/BuiltinOpsImpl.java index f16cba11b6..7ea2c40fd9 100644 --- a/typespec-tests/src/main/java/com/cadl/builtin/implementation/BuiltinOpsImpl.java +++ b/typespec-tests/src/main/java/com/cadl/builtin/implementation/BuiltinOpsImpl.java @@ -68,7 +68,7 @@ public interface BuiltinOpsService { @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); + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Get("/builtin") @ExpectedResponses({ 200 }) @@ -78,7 +78,7 @@ Mono> read(@HostParam("endpoint") String endpoint, @QueryPa @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); + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Post("/builtin") @ExpectedResponses({ 200 }) @@ -86,8 +86,9 @@ Response readSync(@HostParam("endpoint") String endpoint, @QueryPara @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> write(@HostParam("endpoint") String endpoint, @HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + Mono> write(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); @Post("/builtin") @ExpectedResponses({ 200 }) @@ -95,8 +96,9 @@ Mono> write(@HostParam("endpoint") String endpoint, @HeaderParam( @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response writeSync(@HostParam("endpoint") String endpoint, @HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + Response writeSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); } /** @@ -295,9 +297,9 @@ public Response readWithResponse(String queryParam, String queryPara */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> writeWithResponseAsync(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil - .withContext(context -> service.write(this.client.getEndpoint(), accept, body, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.write(this.client.getEndpoint(), contentType, body, requestOptions, context)); } /** @@ -350,7 +352,7 @@ public Mono> writeWithResponseAsync(BinaryData body, RequestOptio */ @ServiceMethod(returns = ReturnType.SINGLE) public Response writeWithResponse(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.writeSync(this.client.getEndpoint(), accept, body, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.writeSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/cadl/enumservice/implementation/EnumServiceClientImpl.java b/typespec-tests/src/main/java/com/cadl/enumservice/implementation/EnumServiceClientImpl.java index 23979b9a52..12b6c27112 100644 --- a/typespec-tests/src/main/java/com/cadl/enumservice/implementation/EnumServiceClientImpl.java +++ b/typespec-tests/src/main/java/com/cadl/enumservice/implementation/EnumServiceClientImpl.java @@ -47,12 +47,12 @@ public final class EnumServiceClientImpl { private final EnumServiceClientService service; /** - * Server parameter. + * Service host. */ private final String endpoint; /** - * Gets Server parameter. + * Gets Service host. * * @return the endpoint value. */ @@ -91,7 +91,7 @@ public SerializerAdapter getSerializerAdapter() { /** * Initializes an instance of EnumServiceClient client. * - * @param endpoint Server parameter. + * @param endpoint Service host. */ public EnumServiceClientImpl(String endpoint) { this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), @@ -102,7 +102,7 @@ public EnumServiceClientImpl(String endpoint) { * Initializes an instance of EnumServiceClient client. * * @param httpPipeline The HTTP pipeline to send requests through. - * @param endpoint Server parameter. + * @param endpoint Service host. */ public EnumServiceClientImpl(HttpPipeline httpPipeline, String endpoint) { this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint); @@ -113,7 +113,7 @@ public EnumServiceClientImpl(HttpPipeline httpPipeline, String endpoint) { * * @param httpPipeline The HTTP pipeline to send requests through. * @param serializerAdapter The serializer to serialize an object into a string. - * @param endpoint Server parameter. + * @param endpoint Service host. */ public EnumServiceClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, String endpoint) { this.httpPipeline = httpPipeline; @@ -136,7 +136,7 @@ public interface EnumServiceClientService { @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Mono> getColor(@HostParam("endpoint") String endpoint, - @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Get("/enum/color") @ExpectedResponses({ 200 }) @@ -144,7 +144,7 @@ Mono> getColor(@HostParam("endpoint") String endpoint, @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, + Response getColorSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Get("/enum/colormodel") @@ -154,7 +154,7 @@ Response getColorSync(@HostParam("endpoint") String endpoint, @Heade @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Mono> getColorModel(@HostParam("endpoint") String endpoint, - @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Get("/enum/colormodel") @ExpectedResponses({ 200 }) @@ -163,7 +163,7 @@ Mono> getColorModel(@HostParam("endpoint") String endpoint, @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Response getColorModelSync(@HostParam("endpoint") String endpoint, - @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Post("/enum/operation/colormodel") @ExpectedResponses({ 200 }) @@ -172,7 +172,7 @@ Response getColorModelSync(@HostParam("endpoint") String endpoint, @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, + @QueryParam("color") String color, @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Post("/enum/operation/colormodel") @@ -182,7 +182,7 @@ Mono> setColorModel(@HostParam("endpoint") String endpoint, @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, + @QueryParam("color") String color, @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Post("/enum/operation/priority") @@ -192,7 +192,7 @@ Response setColorModelSync(@HostParam("endpoint") String endpoint, @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Mono> setPriority(@HostParam("endpoint") String endpoint, - @QueryParam("priority") String priority, @HeaderParam("accept") String accept, + @QueryParam("priority") String priority, @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Post("/enum/operation/priority") @@ -202,7 +202,7 @@ Mono> setPriority(@HostParam("endpoint") String endpoint, @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Response setPrioritySync(@HostParam("endpoint") String endpoint, - @QueryParam("priority") String priority, @HeaderParam("accept") String accept, + @QueryParam("priority") String priority, @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Get("/enum/operation/state/running") @@ -212,7 +212,7 @@ Response setPrioritySync(@HostParam("endpoint") String endpoint, @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, + @QueryParam("state") String state, @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Get("/enum/operation/state/running") @@ -222,7 +222,7 @@ Mono> getRunningOperation(@HostParam("endpoint") String end @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, + @QueryParam("state") String state, @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Get("/enum/operation/state") @@ -232,7 +232,7 @@ Response getRunningOperationSync(@HostParam("endpoint") String endpo @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, + @QueryParam("state") String state, @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Get("/enum/operation/state") @@ -242,7 +242,7 @@ Mono> getOperation(@HostParam("endpoint") String endpoint, @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); + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Post("/enum/operation/stringenumarray") @ExpectedResponses({ 200 }) @@ -251,7 +251,7 @@ Response getOperationSync(@HostParam("endpoint") String endpoint, @Q @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Mono> setStringEnumArray(@HostParam("endpoint") String endpoint, - @QueryParam("colorArray") String colorArray, @HeaderParam("accept") String accept, + @QueryParam("colorArray") String colorArray, @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Post("/enum/operation/stringenumarray") @@ -261,7 +261,7 @@ Mono> setStringEnumArray(@HostParam("endpoint") String endp @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Response setStringEnumArraySync(@HostParam("endpoint") String endpoint, - @QueryParam("colorArray") String colorArray, @HeaderParam("accept") String accept, + @QueryParam("colorArray") String colorArray, @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Post("/enum/operation/intenumarray") @@ -271,7 +271,7 @@ Response setStringEnumArraySync(@HostParam("endpoint") String endpoi @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Mono> setIntEnumArray(@HostParam("endpoint") String endpoint, - @QueryParam("priorityArray") String priorityArray, @HeaderParam("accept") String accept, + @QueryParam("priorityArray") String priorityArray, @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Post("/enum/operation/intenumarray") @@ -281,7 +281,7 @@ Mono> setIntEnumArray(@HostParam("endpoint") String endpoin @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Response setIntEnumArraySync(@HostParam("endpoint") String endpoint, - @QueryParam("priorityArray") String priorityArray, @HeaderParam("accept") String accept, + @QueryParam("priorityArray") String priorityArray, @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Post("/enum/operation/stringarray") @@ -291,7 +291,7 @@ Response setIntEnumArraySync(@HostParam("endpoint") String endpoint, @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Mono> setStringArray(@HostParam("endpoint") String endpoint, - @QueryParam("stringArray") String stringArray, @HeaderParam("accept") String accept, + @QueryParam("stringArray") String stringArray, @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Post("/enum/operation/stringarray") @@ -301,7 +301,7 @@ Mono> setStringArray(@HostParam("endpoint") String endpoint @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Response setStringArraySync(@HostParam("endpoint") String endpoint, - @QueryParam("stringArray") String stringArray, @HeaderParam("accept") String accept, + @QueryParam("stringArray") String stringArray, @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Post("/enum/operation/intarray") @@ -311,7 +311,7 @@ Response setStringArraySync(@HostParam("endpoint") String endpoint, @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Mono> setIntArray(@HostParam("endpoint") String endpoint, - @QueryParam("intArray") String intArray, @HeaderParam("accept") String accept, + @QueryParam("intArray") String intArray, @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Post("/enum/operation/intarray") @@ -321,7 +321,7 @@ Mono> setIntArray(@HostParam("endpoint") String endpoint, @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Response setIntArraySync(@HostParam("endpoint") String endpoint, - @QueryParam("intArray") String intArray, @HeaderParam("accept") String accept, + @QueryParam("intArray") String intArray, @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Post("/enum/operation/stringenummulti") @@ -332,7 +332,7 @@ Response setIntArraySync(@HostParam("endpoint") String endpoint, @UnexpectedResponseExceptionType(HttpResponseException.class) Mono> setStringEnumMulti(@HostParam("endpoint") String endpoint, @QueryParam(value = "colorArray", multipleQueryParams = true) List colorArray, - @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Post("/enum/operation/stringenummulti") @ExpectedResponses({ 200 }) @@ -342,7 +342,7 @@ Mono> setStringEnumMulti(@HostParam("endpoint") String endp @UnexpectedResponseExceptionType(HttpResponseException.class) Response setStringEnumMultiSync(@HostParam("endpoint") String endpoint, @QueryParam(value = "colorArray", multipleQueryParams = true) List colorArray, - @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Post("/enum/operation/intenummulti") @ExpectedResponses({ 200 }) @@ -352,7 +352,7 @@ Response setStringEnumMultiSync(@HostParam("endpoint") String endpoi @UnexpectedResponseExceptionType(HttpResponseException.class) Mono> setIntEnumMulti(@HostParam("endpoint") String endpoint, @QueryParam(value = "priorityArray", multipleQueryParams = true) List priorityArray, - @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Post("/enum/operation/intenummulti") @ExpectedResponses({ 200 }) @@ -362,7 +362,7 @@ Mono> setIntEnumMulti(@HostParam("endpoint") String endpoin @UnexpectedResponseExceptionType(HttpResponseException.class) Response setIntEnumMultiSync(@HostParam("endpoint") String endpoint, @QueryParam(value = "priorityArray", multipleQueryParams = true) List priorityArray, - @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Post("/enum/operation/stringmulti") @ExpectedResponses({ 200 }) @@ -372,7 +372,7 @@ Response setIntEnumMultiSync(@HostParam("endpoint") String endpoint, @UnexpectedResponseExceptionType(HttpResponseException.class) Mono> setStringMulti(@HostParam("endpoint") String endpoint, @QueryParam(value = "stringArray", multipleQueryParams = true) List stringArray, - @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Post("/enum/operation/stringmulti") @ExpectedResponses({ 200 }) @@ -382,7 +382,7 @@ Mono> setStringMulti(@HostParam("endpoint") String endpoint @UnexpectedResponseExceptionType(HttpResponseException.class) Response setStringMultiSync(@HostParam("endpoint") String endpoint, @QueryParam(value = "stringArray", multipleQueryParams = true) List stringArray, - @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Post("/enum/operation/intmulti") @ExpectedResponses({ 200 }) @@ -392,7 +392,7 @@ Response setStringMultiSync(@HostParam("endpoint") String endpoint, @UnexpectedResponseExceptionType(HttpResponseException.class) Mono> setIntMulti(@HostParam("endpoint") String endpoint, @QueryParam(value = "intArray", multipleQueryParams = true) List intArray, - @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Post("/enum/operation/intmulti") @ExpectedResponses({ 200 }) @@ -402,7 +402,7 @@ Mono> setIntMulti(@HostParam("endpoint") String endpoint, @UnexpectedResponseExceptionType(HttpResponseException.class) Response setIntMultiSync(@HostParam("endpoint") String endpoint, @QueryParam(value = "intArray", multipleQueryParams = true) List intArray, - @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Post("/enum/operation/stringenumarrayheader") @ExpectedResponses({ 200 }) @@ -411,7 +411,7 @@ Response setIntMultiSync(@HostParam("endpoint") String endpoint, @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Mono> setStringEnumArrayHeader(@HostParam("endpoint") String endpoint, - @HeaderParam("color-array") String colorArray, @HeaderParam("accept") String accept, + @HeaderParam("color-array") String colorArray, @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Post("/enum/operation/stringenumarrayheader") @@ -421,7 +421,7 @@ Mono> setStringEnumArrayHeader(@HostParam("endpoint") Strin @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Response setStringEnumArrayHeaderSync(@HostParam("endpoint") String endpoint, - @HeaderParam("color-array") String colorArray, @HeaderParam("accept") String accept, + @HeaderParam("color-array") String colorArray, @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); } diff --git a/typespec-tests/src/main/java/com/cadl/errormodel/ErrorModelAsyncClient.java b/typespec-tests/src/main/java/com/cadl/errormodel/ErrorModelAsyncClient.java index 602e578228..dc5951a021 100644 --- a/typespec-tests/src/main/java/com/cadl/errormodel/ErrorModelAsyncClient.java +++ b/typespec-tests/src/main/java/com/cadl/errormodel/ErrorModelAsyncClient.java @@ -73,6 +73,39 @@ public Mono> readWithResponse(RequestOptions requestOptions return this.serviceClient.readWithResponseAsync(requestOptions); } + /** + * The readWithCustomizedError 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 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> readWithCustomizedErrorWithResponse(RequestOptions requestOptions) { + return this.serviceClient.readWithCustomizedErrorWithResponseAsync(requestOptions); + } + /** * The read operation. * @@ -91,4 +124,21 @@ public Mono read() { return readWithResponse(requestOptions).flatMap(FluxUtil::toMono) .map(protocolMethodData -> protocolMethodData.toObject(Diagnostic.class)); } + + /** + * The readWithCustomizedError operation. + * + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ResourceModifiedException thrown if the request is 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 readWithCustomizedError() { + // Generated convenience method for readWithCustomizedErrorWithResponse + RequestOptions requestOptions = new RequestOptions(); + return readWithCustomizedErrorWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(Diagnostic.class)); + } } diff --git a/typespec-tests/src/main/java/com/cadl/errormodel/ErrorModelClient.java b/typespec-tests/src/main/java/com/cadl/errormodel/ErrorModelClient.java index 979c6a833b..445a1a992f 100644 --- a/typespec-tests/src/main/java/com/cadl/errormodel/ErrorModelClient.java +++ b/typespec-tests/src/main/java/com/cadl/errormodel/ErrorModelClient.java @@ -71,6 +71,39 @@ public Response readWithResponse(RequestOptions requestOptions) { return this.serviceClient.readWithResponse(requestOptions); } + /** + * The readWithCustomizedError 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 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 readWithCustomizedErrorWithResponse(RequestOptions requestOptions) { + return this.serviceClient.readWithCustomizedErrorWithResponse(requestOptions); + } + /** * The read operation. * @@ -88,4 +121,20 @@ public Diagnostic read() { RequestOptions requestOptions = new RequestOptions(); return readWithResponse(requestOptions).getValue().toObject(Diagnostic.class); } + + /** + * The readWithCustomizedError operation. + * + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ResourceModifiedException thrown if the request is 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 readWithCustomizedError() { + // Generated convenience method for readWithCustomizedErrorWithResponse + RequestOptions requestOptions = new RequestOptions(); + return readWithCustomizedErrorWithResponse(requestOptions).getValue().toObject(Diagnostic.class); + } } diff --git a/typespec-tests/src/main/java/com/cadl/errormodel/implementation/ErrorModelClientImpl.java b/typespec-tests/src/main/java/com/cadl/errormodel/implementation/ErrorModelClientImpl.java index 8274dc5b1a..ba7a4d34da 100644 --- a/typespec-tests/src/main/java/com/cadl/errormodel/implementation/ErrorModelClientImpl.java +++ b/typespec-tests/src/main/java/com/cadl/errormodel/implementation/ErrorModelClientImpl.java @@ -16,12 +16,12 @@ */ public final class ErrorModelClientImpl { /** - * Server parameter. + * Service host. */ private final String endpoint; /** - * Gets Server parameter. + * Gets Service host. * * @return the endpoint value. */ @@ -74,7 +74,7 @@ public ErrorOpsImpl getErrorOps() { /** * Initializes an instance of ErrorModelClient client. * - * @param endpoint Server parameter. + * @param endpoint Service host. */ public ErrorModelClientImpl(String endpoint) { this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), @@ -85,7 +85,7 @@ public ErrorModelClientImpl(String endpoint) { * Initializes an instance of ErrorModelClient client. * * @param httpPipeline The HTTP pipeline to send requests through. - * @param endpoint Server parameter. + * @param endpoint Service host. */ public ErrorModelClientImpl(HttpPipeline httpPipeline, String endpoint) { this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint); @@ -96,7 +96,7 @@ public ErrorModelClientImpl(HttpPipeline httpPipeline, String endpoint) { * * @param httpPipeline The HTTP pipeline to send requests through. * @param serializerAdapter The serializer to serialize an object into a string. - * @param endpoint Server parameter. + * @param endpoint Service host. */ public ErrorModelClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, String endpoint) { this.httpPipeline = httpPipeline; diff --git a/typespec-tests/src/main/java/com/cadl/errormodel/implementation/ErrorOpsImpl.java b/typespec-tests/src/main/java/com/cadl/errormodel/implementation/ErrorOpsImpl.java index d422ad091e..ccb93122ef 100644 --- a/typespec-tests/src/main/java/com/cadl/errormodel/implementation/ErrorOpsImpl.java +++ b/typespec-tests/src/main/java/com/cadl/errormodel/implementation/ErrorOpsImpl.java @@ -62,7 +62,7 @@ public interface ErrorOpsService { @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, + Mono> read(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Get("/error") @@ -71,8 +71,22 @@ Mono> read(@HostParam("endpoint") String endpoint, @HeaderP @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, + Response readSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/error/statuscoderange") + @ExpectedResponses({ 200, 201, 400, 401, 402, 403, 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> readWithCustomizedError(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/error/statuscoderange") + @ExpectedResponses({ 200, 201, 400, 401, 402, 403, 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response readWithCustomizedErrorSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); } /** @@ -145,4 +159,71 @@ public Response readWithResponse(RequestOptions requestOptions) { final String accept = "application/json"; return service.readSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); } + + /** + * The readWithCustomizedError 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 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> readWithCustomizedErrorWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext( + context -> service.readWithCustomizedError(this.client.getEndpoint(), accept, requestOptions, context)); + } + + /** + * The readWithCustomizedError 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 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 readWithCustomizedErrorWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.readWithCustomizedErrorSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); + } } diff --git a/typespec-tests/src/main/java/com/cadl/flatten/implementation/FlattenClientImpl.java b/typespec-tests/src/main/java/com/cadl/flatten/implementation/FlattenClientImpl.java index 1bcc2ee18d..ce2c7b9c4d 100644 --- a/typespec-tests/src/main/java/com/cadl/flatten/implementation/FlattenClientImpl.java +++ b/typespec-tests/src/main/java/com/cadl/flatten/implementation/FlattenClientImpl.java @@ -153,7 +153,7 @@ public interface FlattenClientService { @UnexpectedResponseExceptionType(HttpResponseException.class) Mono> send(@HostParam("endpoint") String endpoint, @QueryParam("id") String id, @QueryParam("constantQueryParam") String constantQueryParam, @QueryParam("api-version") String apiVersion, - @HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData sendRequest, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData sendRequest, RequestOptions requestOptions, Context context); @Post("/flatten/send") @@ -164,7 +164,7 @@ Mono> send(@HostParam("endpoint") String endpoint, @QueryParam("i @UnexpectedResponseExceptionType(HttpResponseException.class) Response sendSync(@HostParam("endpoint") String endpoint, @QueryParam("id") String id, @QueryParam("constantQueryParam") String constantQueryParam, @QueryParam("api-version") String apiVersion, - @HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData sendRequest, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData sendRequest, RequestOptions requestOptions, Context context); @Post("/flatten/send-projected-name") @@ -174,8 +174,9 @@ Response sendSync(@HostParam("endpoint") String endpoint, @QueryParam("id" @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Mono> sendProjectedName(@HostParam("endpoint") String endpoint, @QueryParam("id") String id, - @HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData sendProjectedNameRequest, - RequestOptions requestOptions, Context context); + @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData sendProjectedNameRequest, RequestOptions requestOptions, + Context context); @Post("/flatten/send-projected-name") @ExpectedResponses({ 200 }) @@ -184,8 +185,9 @@ Mono> sendProjectedName(@HostParam("endpoint") String endpoint, @ @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Response sendProjectedNameSync(@HostParam("endpoint") String endpoint, @QueryParam("id") String id, - @HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData sendProjectedNameRequest, - RequestOptions requestOptions, Context context); + @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData sendProjectedNameRequest, RequestOptions requestOptions, + Context context); @Post("/flatten/send-long") @ExpectedResponses({ 200 }) @@ -194,7 +196,7 @@ Response sendProjectedNameSync(@HostParam("endpoint") String endpoint, @Qu @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("accept") String accept, + @QueryParam("api-version") String apiVersion, @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData sendLongRequest, RequestOptions requestOptions, Context context); @Post("/flatten/send-long") @@ -204,7 +206,7 @@ Mono> sendLong(@HostParam("endpoint") String endpoint, @QueryPara @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("accept") String accept, + @QueryParam("api-version") String apiVersion, @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData sendLongRequest, RequestOptions requestOptions, Context context); @Patch("/flatten/patch/{id}") @@ -215,7 +217,7 @@ Response sendLongSync(@HostParam("endpoint") String endpoint, @QueryParam( @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, + @HeaderParam("Accept") String accept, @BodyParam("application/merge-patch+json") BinaryData updateRequest, RequestOptions requestOptions, Context context); @Patch("/flatten/patch/{id}") @@ -226,7 +228,7 @@ Mono> update(@HostParam("endpoint") String endpoint, @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, + @HeaderParam("Accept") String accept, @BodyParam("application/merge-patch+json") BinaryData updateRequest, RequestOptions requestOptions, Context context); // @Multipart not supported by RestProxy @@ -237,7 +239,7 @@ Response updateSync(@HostParam("endpoint") String endpoint, @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Mono> uploadFile(@HostParam("endpoint") String endpoint, @PathParam("name") String name, - @HeaderParam("content-type") String contentType, @HeaderParam("accept") String accept, + @HeaderParam("content-type") String contentType, @BodyParam("multipart/form-data") BinaryData uploadFileRequest, RequestOptions requestOptions, Context context); @@ -249,7 +251,7 @@ Mono> uploadFile(@HostParam("endpoint") String endpoint, @PathPar @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Response uploadFileSync(@HostParam("endpoint") String endpoint, @PathParam("name") String name, - @HeaderParam("content-type") String contentType, @HeaderParam("accept") String accept, + @HeaderParam("content-type") String contentType, @BodyParam("multipart/form-data") BinaryData uploadFileRequest, RequestOptions requestOptions, Context context); @@ -261,7 +263,7 @@ Response uploadFileSync(@HostParam("endpoint") String endpoint, @PathParam @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Mono> uploadTodo(@HostParam("endpoint") String endpoint, - @HeaderParam("content-type") String contentType, @HeaderParam("accept") String accept, + @HeaderParam("content-type") String contentType, @BodyParam("multipart/form-data") BinaryData uploadTodoRequest, RequestOptions requestOptions, Context context); @@ -273,7 +275,7 @@ Mono> uploadTodo(@HostParam("endpoint") String endpoint, @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Response uploadTodoSync(@HostParam("endpoint") String endpoint, - @HeaderParam("content-type") String contentType, @HeaderParam("accept") String accept, + @HeaderParam("content-type") String contentType, @BodyParam("multipart/form-data") BinaryData uploadTodoRequest, RequestOptions requestOptions, Context context); } @@ -306,9 +308,9 @@ Response uploadTodoSync(@HostParam("endpoint") String endpoint, public Mono> sendWithResponseAsync(String id, BinaryData sendRequest, RequestOptions requestOptions) { final String constantQueryParam = "constant"; - final String accept = "application/json"; + final String contentType = "application/json"; return FluxUtil.withContext(context -> service.send(this.getEndpoint(), id, constantQueryParam, - this.getServiceVersion().getVersion(), accept, sendRequest, requestOptions, context)); + this.getServiceVersion().getVersion(), contentType, sendRequest, requestOptions, context)); } /** @@ -338,9 +340,9 @@ public Mono> sendWithResponseAsync(String id, BinaryData sendRequ @ServiceMethod(returns = ReturnType.SINGLE) public Response sendWithResponse(String id, BinaryData sendRequest, RequestOptions requestOptions) { final String constantQueryParam = "constant"; - final String accept = "application/json"; + final String contentType = "application/json"; return service.sendSync(this.getEndpoint(), id, constantQueryParam, this.getServiceVersion().getVersion(), - accept, sendRequest, requestOptions, Context.NONE); + contentType, sendRequest, requestOptions, Context.NONE); } /** @@ -365,8 +367,8 @@ public Response sendWithResponse(String id, BinaryData sendRequest, Reques @ServiceMethod(returns = ReturnType.SINGLE) public Mono> sendProjectedNameWithResponseAsync(String id, BinaryData sendProjectedNameRequest, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.sendProjectedName(this.getEndpoint(), id, accept, + final String contentType = "application/json"; + return FluxUtil.withContext(context -> service.sendProjectedName(this.getEndpoint(), id, contentType, sendProjectedNameRequest, requestOptions, context)); } @@ -392,9 +394,9 @@ public Mono> sendProjectedNameWithResponseAsync(String id, Binary @ServiceMethod(returns = ReturnType.SINGLE) public Response sendProjectedNameWithResponse(String id, BinaryData sendProjectedNameRequest, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.sendProjectedNameSync(this.getEndpoint(), id, accept, sendProjectedNameRequest, requestOptions, - Context.NONE); + final String contentType = "application/json"; + return service.sendProjectedNameSync(this.getEndpoint(), id, contentType, sendProjectedNameRequest, + requestOptions, Context.NONE); } /** @@ -438,9 +440,9 @@ public Response sendProjectedNameWithResponse(String id, BinaryData sendPr @ServiceMethod(returns = ReturnType.SINGLE) public Mono> sendLongWithResponseAsync(String name, BinaryData sendLongRequest, RequestOptions requestOptions) { - final String accept = "application/json"; + final String contentType = "application/json"; return FluxUtil.withContext(context -> service.sendLong(this.getEndpoint(), name, - this.getServiceVersion().getVersion(), accept, sendLongRequest, requestOptions, context)); + this.getServiceVersion().getVersion(), contentType, sendLongRequest, requestOptions, context)); } /** @@ -483,8 +485,8 @@ public Mono> sendLongWithResponseAsync(String name, BinaryData se */ @ServiceMethod(returns = ReturnType.SINGLE) public Response sendLongWithResponse(String name, BinaryData sendLongRequest, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.sendLongSync(this.getEndpoint(), name, this.getServiceVersion().getVersion(), accept, + final String contentType = "application/json"; + return service.sendLongSync(this.getEndpoint(), name, this.getServiceVersion().getVersion(), contentType, sendLongRequest, requestOptions, Context.NONE); } @@ -597,8 +599,7 @@ public Response updateWithResponse(long id, BinaryData updateRequest public Mono> uploadFileWithResponseAsync(String name, BinaryData uploadFileRequest, RequestOptions requestOptions) { final String contentType = "multipart/form-data"; - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.uploadFile(this.getEndpoint(), name, contentType, accept, + return FluxUtil.withContext(context -> service.uploadFile(this.getEndpoint(), name, contentType, uploadFileRequest, requestOptions, context)); } @@ -618,8 +619,7 @@ public Mono> uploadFileWithResponseAsync(String name, BinaryData public Response uploadFileWithResponse(String name, BinaryData uploadFileRequest, RequestOptions requestOptions) { final String contentType = "multipart/form-data"; - final String accept = "application/json"; - return service.uploadFileSync(this.getEndpoint(), name, contentType, accept, uploadFileRequest, requestOptions, + return service.uploadFileSync(this.getEndpoint(), name, contentType, uploadFileRequest, requestOptions, Context.NONE); } @@ -638,9 +638,8 @@ public Response uploadFileWithResponse(String name, BinaryData uploadFileR public Mono> uploadTodoWithResponseAsync(BinaryData uploadTodoRequest, RequestOptions requestOptions) { final String contentType = "multipart/form-data"; - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.uploadTodo(this.getEndpoint(), contentType, accept, - uploadTodoRequest, requestOptions, context)); + return FluxUtil.withContext( + context -> service.uploadTodo(this.getEndpoint(), contentType, uploadTodoRequest, requestOptions, context)); } /** @@ -657,8 +656,6 @@ public Mono> uploadTodoWithResponseAsync(BinaryData uploadTodoReq @ServiceMethod(returns = ReturnType.SINGLE) public Response uploadTodoWithResponse(BinaryData uploadTodoRequest, RequestOptions requestOptions) { final String contentType = "multipart/form-data"; - final String accept = "application/json"; - return service.uploadTodoSync(this.getEndpoint(), contentType, accept, uploadTodoRequest, requestOptions, - Context.NONE); + return service.uploadTodoSync(this.getEndpoint(), contentType, uploadTodoRequest, requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/cadl/internal/implementation/InternalClientImpl.java b/typespec-tests/src/main/java/com/cadl/internal/implementation/InternalClientImpl.java index aa279b79f4..d7f1cee9ee 100644 --- a/typespec-tests/src/main/java/com/cadl/internal/implementation/InternalClientImpl.java +++ b/typespec-tests/src/main/java/com/cadl/internal/implementation/InternalClientImpl.java @@ -16,12 +16,12 @@ */ public final class InternalClientImpl { /** - * Server parameter. + * Service host. */ private final String endpoint; /** - * Gets Server parameter. + * Gets Service host. * * @return the endpoint value. */ @@ -74,7 +74,7 @@ public InternalOpsImpl getInternalOps() { /** * Initializes an instance of InternalClient client. * - * @param endpoint Server parameter. + * @param endpoint Service host. */ public InternalClientImpl(String endpoint) { this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), @@ -85,7 +85,7 @@ public InternalClientImpl(String endpoint) { * Initializes an instance of InternalClient client. * * @param httpPipeline The HTTP pipeline to send requests through. - * @param endpoint Server parameter. + * @param endpoint Service host. */ public InternalClientImpl(HttpPipeline httpPipeline, String endpoint) { this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint); @@ -96,7 +96,7 @@ public InternalClientImpl(HttpPipeline httpPipeline, String endpoint) { * * @param httpPipeline The HTTP pipeline to send requests through. * @param serializerAdapter The serializer to serialize an object into a string. - * @param endpoint Server parameter. + * @param endpoint Service host. */ public InternalClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, String endpoint) { this.httpPipeline = httpPipeline; diff --git a/typespec-tests/src/main/java/com/cadl/internal/implementation/InternalOpsImpl.java b/typespec-tests/src/main/java/com/cadl/internal/implementation/InternalOpsImpl.java index 091af0d13c..cfa0189417 100644 --- a/typespec-tests/src/main/java/com/cadl/internal/implementation/InternalOpsImpl.java +++ b/typespec-tests/src/main/java/com/cadl/internal/implementation/InternalOpsImpl.java @@ -66,8 +66,8 @@ public interface InternalOpsService { @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Mono> postInternal(@HostParam("endpoint") String endpoint, - @HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, - RequestOptions requestOptions, Context context); + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); @Post("/internal") @ExpectedResponses({ 200 }) @@ -76,8 +76,8 @@ Mono> postInternal(@HostParam("endpoint") String endpoint, @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Response postInternalSync(@HostParam("endpoint") String endpoint, - @HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, - RequestOptions requestOptions, Context context); + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); @Get("/internal") @ExpectedResponses({ 200 }) @@ -86,7 +86,7 @@ Response postInternalSync(@HostParam("endpoint") String endpoint, @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Mono> getInternal(@HostParam("endpoint") String endpoint, - @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Get("/internal") @ExpectedResponses({ 200 }) @@ -95,7 +95,7 @@ Mono> getInternal(@HostParam("endpoint") String endpoint, @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Response getInternalSync(@HostParam("endpoint") String endpoint, - @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Post("/internal/protocal-internal") @ExpectedResponses({ 204 }) @@ -104,7 +104,7 @@ Response getInternalSync(@HostParam("endpoint") String endpoint, @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Mono> postProtocalInternal(@HostParam("endpoint") String endpoint, - @HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); @Post("/internal/protocal-internal") @@ -114,7 +114,7 @@ Mono> postProtocalInternal(@HostParam("endpoint") String endpoint @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Response postProtocalInternalSync(@HostParam("endpoint") String endpoint, - @HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); } @@ -150,9 +150,10 @@ Response postProtocalInternalSync(@HostParam("endpoint") String endpoint, */ @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(), accept, body, requestOptions, context)); + return FluxUtil.withContext(context -> service.postInternal(this.client.getEndpoint(), contentType, accept, + body, requestOptions, context)); } /** @@ -187,8 +188,10 @@ public Mono> postInternalWithResponseAsync(BinaryData body, */ @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(), accept, body, requestOptions, Context.NONE); + return service.postInternalSync(this.client.getEndpoint(), contentType, accept, body, requestOptions, + Context.NONE); } /** @@ -258,9 +261,9 @@ public Response getInternalWithResponse(RequestOptions requestOption */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> postProtocalInternalWithResponseAsync(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext( - context -> service.postProtocalInternal(this.client.getEndpoint(), accept, body, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil.withContext(context -> service.postProtocalInternal(this.client.getEndpoint(), contentType, + body, requestOptions, context)); } /** @@ -283,7 +286,8 @@ public Mono> postProtocalInternalWithResponseAsync(BinaryData bod */ @ServiceMethod(returns = ReturnType.SINGLE) public Response postProtocalInternalWithResponse(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.postProtocalInternalSync(this.client.getEndpoint(), accept, body, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.postProtocalInternalSync(this.client.getEndpoint(), contentType, body, requestOptions, + Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/cadl/literalservice/implementation/LiteralOpsImpl.java b/typespec-tests/src/main/java/com/cadl/literalservice/implementation/LiteralOpsImpl.java index 081273e360..a216e21bd5 100644 --- a/typespec-tests/src/main/java/com/cadl/literalservice/implementation/LiteralOpsImpl.java +++ b/typespec-tests/src/main/java/com/cadl/literalservice/implementation/LiteralOpsImpl.java @@ -66,8 +66,9 @@ public interface LiteralOpsService { @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Mono> put(@HostParam("endpoint") String endpoint, - @QueryParam("literalParam") String literalParam, @HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + @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 }) @@ -76,8 +77,9 @@ Mono> put(@HostParam("endpoint") String endpoint, @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Response putSync(@HostParam("endpoint") String endpoint, - @QueryParam("literalParam") String literalParam, @HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + @QueryParam("literalParam") String literalParam, @HeaderParam("Content-Type") String contentType, + @HeaderParam("Accept") String accept, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); } /** @@ -119,9 +121,10 @@ Response putSync(@HostParam("endpoint") String endpoint, @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, accept, body, requestOptions, context)); + return FluxUtil.withContext(context -> service.put(this.client.getEndpoint(), literalParam, contentType, accept, + body, requestOptions, context)); } /** @@ -163,7 +166,9 @@ public Mono> putWithResponseAsync(BinaryData body, RequestO @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, accept, body, requestOptions, Context.NONE); + return service.putSync(this.client.getEndpoint(), literalParam, contentType, accept, body, requestOptions, + Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/cadl/literalservice/implementation/LiteralServiceClientImpl.java b/typespec-tests/src/main/java/com/cadl/literalservice/implementation/LiteralServiceClientImpl.java index a872510809..b0a0178bf1 100644 --- a/typespec-tests/src/main/java/com/cadl/literalservice/implementation/LiteralServiceClientImpl.java +++ b/typespec-tests/src/main/java/com/cadl/literalservice/implementation/LiteralServiceClientImpl.java @@ -16,12 +16,12 @@ */ public final class LiteralServiceClientImpl { /** - * Server parameter. + * Service host. */ private final String endpoint; /** - * Gets Server parameter. + * Gets Service host. * * @return the endpoint value. */ @@ -74,7 +74,7 @@ public LiteralOpsImpl getLiteralOps() { /** * Initializes an instance of LiteralServiceClient client. * - * @param endpoint Server parameter. + * @param endpoint Service host. */ public LiteralServiceClientImpl(String endpoint) { this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), @@ -85,7 +85,7 @@ public LiteralServiceClientImpl(String endpoint) { * Initializes an instance of LiteralServiceClient client. * * @param httpPipeline The HTTP pipeline to send requests through. - * @param endpoint Server parameter. + * @param endpoint Service host. */ public LiteralServiceClientImpl(HttpPipeline httpPipeline, String endpoint) { this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint); @@ -96,7 +96,7 @@ public LiteralServiceClientImpl(HttpPipeline httpPipeline, String endpoint) { * * @param httpPipeline The HTTP pipeline to send requests through. * @param serializerAdapter The serializer to serialize an object into a string. - * @param endpoint Server parameter. + * @param endpoint Service host. */ public LiteralServiceClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, String endpoint) { this.httpPipeline = httpPipeline; diff --git a/typespec-tests/src/main/java/com/cadl/longrunning/implementation/LongRunningClientImpl.java b/typespec-tests/src/main/java/com/cadl/longrunning/implementation/LongRunningClientImpl.java index 619909975b..7445d31042 100644 --- a/typespec-tests/src/main/java/com/cadl/longrunning/implementation/LongRunningClientImpl.java +++ b/typespec-tests/src/main/java/com/cadl/longrunning/implementation/LongRunningClientImpl.java @@ -60,12 +60,12 @@ public final class LongRunningClientImpl { private final LongRunningClientService service; /** - * Server parameter. + * Service host. */ private final String endpoint; /** - * Gets Server parameter. + * Gets Service host. * * @return the endpoint value. */ @@ -118,7 +118,7 @@ public SerializerAdapter getSerializerAdapter() { /** * Initializes an instance of LongRunningClient client. * - * @param endpoint Server parameter. + * @param endpoint Service host. * @param serviceVersion Service version. */ public LongRunningClientImpl(String endpoint, LongRunningServiceVersion serviceVersion) { @@ -130,7 +130,7 @@ public LongRunningClientImpl(String endpoint, LongRunningServiceVersion serviceV * Initializes an instance of LongRunningClient client. * * @param httpPipeline The HTTP pipeline to send requests through. - * @param endpoint Server parameter. + * @param endpoint Service host. * @param serviceVersion Service version. */ public LongRunningClientImpl(HttpPipeline httpPipeline, String endpoint, LongRunningServiceVersion serviceVersion) { @@ -142,7 +142,7 @@ public LongRunningClientImpl(HttpPipeline httpPipeline, String endpoint, LongRun * * @param httpPipeline The HTTP pipeline to send requests through. * @param serializerAdapter The serializer to serialize an object into a string. - * @param endpoint Server parameter. + * @param endpoint Service host. * @param serviceVersion Service version. */ public LongRunningClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, String endpoint, @@ -167,8 +167,8 @@ public interface LongRunningClientService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> longRunning(@HostParam("endpoint") String endpoint, @HeaderParam("accept") String accept, - RequestOptions requestOptions, Context context); + Mono> longRunning(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, + Context context); @Post("/long-running/post") @ExpectedResponses({ 202 }) @@ -176,8 +176,8 @@ Mono> longRunning(@HostParam("endpoint") String endpoint, @Header @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response longRunningSync(@HostParam("endpoint") String endpoint, @HeaderParam("accept") String accept, - RequestOptions requestOptions, Context context); + Response longRunningSync(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, + Context context); @Get("/long-running/jobs/{id}") @ExpectedResponses({ 200 }) @@ -187,7 +187,7 @@ Response longRunningSync(@HostParam("endpoint") String endpoint, @HeaderPa @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); + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Get("/long-running/jobs/{id}") @ExpectedResponses({ 200 }) @@ -197,7 +197,7 @@ Mono> getJob(@HostParam("endpoint") String endpoint, @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); + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Post("/long-running/jobs") @ExpectedResponses({ 202 }) @@ -206,8 +206,9 @@ Response getJobSync(@HostParam("endpoint") String endpoint, @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Mono> createJob(@HostParam("endpoint") String endpoint, - @QueryParam("api-version") String apiVersion, @HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + @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 }) @@ -216,8 +217,9 @@ Mono> createJob(@HostParam("endpoint") String endpoint, @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Response createJobSync(@HostParam("endpoint") String endpoint, - @QueryParam("api-version") String apiVersion, @HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + @QueryParam("api-version") String apiVersion, @HeaderParam("Content-Type") String contentType, + @HeaderParam("Accept") String accept, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); } /** @@ -232,9 +234,7 @@ Response createJobSync(@HostParam("endpoint") String endpoint, */ @ServiceMethod(returns = ReturnType.SINGLE) private Mono> longRunningWithResponseAsync(RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil - .withContext(context -> service.longRunning(this.getEndpoint(), accept, requestOptions, context)); + return FluxUtil.withContext(context -> service.longRunning(this.getEndpoint(), requestOptions, context)); } /** @@ -249,8 +249,7 @@ private Mono> longRunningWithResponseAsync(RequestOptions request */ @ServiceMethod(returns = ReturnType.SINGLE) private Response longRunningWithResponse(RequestOptions requestOptions) { - final String accept = "application/json"; - return service.longRunningSync(this.getEndpoint(), accept, requestOptions, Context.NONE); + return service.longRunningSync(this.getEndpoint(), requestOptions, Context.NONE); } /** @@ -481,6 +480,7 @@ public Response getJobWithResponse(String id, RequestOptions request */ @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 -> { @@ -497,7 +497,7 @@ private Mono> createJobWithResponseAsync(BinaryData body, R } }); return FluxUtil.withContext(context -> service.createJob(this.getEndpoint(), - this.getServiceVersion().getVersion(), accept, body, requestOptionsLocal, context)); + this.getServiceVersion().getVersion(), contentType, accept, body, requestOptionsLocal, context)); } /** @@ -556,6 +556,7 @@ private Mono> createJobWithResponseAsync(BinaryData body, R */ @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 -> { @@ -571,8 +572,8 @@ private Response createJobWithResponse(BinaryData body, RequestOptio DateTimeRfc1123.toRfc1123String(OffsetDateTime.now())); } }); - return service.createJobSync(this.getEndpoint(), this.getServiceVersion().getVersion(), accept, body, - requestOptionsLocal, Context.NONE); + return service.createJobSync(this.getEndpoint(), this.getServiceVersion().getVersion(), contentType, accept, + body, requestOptionsLocal, Context.NONE); } /** diff --git a/typespec-tests/src/main/java/com/cadl/model/implementation/ModelClientImpl.java b/typespec-tests/src/main/java/com/cadl/model/implementation/ModelClientImpl.java index 82b8db3db3..9063724024 100644 --- a/typespec-tests/src/main/java/com/cadl/model/implementation/ModelClientImpl.java +++ b/typespec-tests/src/main/java/com/cadl/model/implementation/ModelClientImpl.java @@ -16,12 +16,12 @@ */ public final class ModelClientImpl { /** - * Server parameter. + * Service host. */ private final String endpoint; /** - * Gets Server parameter. + * Gets Service host. * * @return the endpoint value. */ @@ -74,7 +74,7 @@ public ModelOpsImpl getModelOps() { /** * Initializes an instance of ModelClient client. * - * @param endpoint Server parameter. + * @param endpoint Service host. */ public ModelClientImpl(String endpoint) { this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), @@ -85,7 +85,7 @@ public ModelClientImpl(String endpoint) { * Initializes an instance of ModelClient client. * * @param httpPipeline The HTTP pipeline to send requests through. - * @param endpoint Server parameter. + * @param endpoint Service host. */ public ModelClientImpl(HttpPipeline httpPipeline, String endpoint) { this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint); @@ -96,7 +96,7 @@ public ModelClientImpl(HttpPipeline httpPipeline, String endpoint) { * * @param httpPipeline The HTTP pipeline to send requests through. * @param serializerAdapter The serializer to serialize an object into a string. - * @param endpoint Server parameter. + * @param endpoint Service host. */ public ModelClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, String endpoint) { this.httpPipeline = httpPipeline; diff --git a/typespec-tests/src/main/java/com/cadl/model/implementation/ModelOpsImpl.java b/typespec-tests/src/main/java/com/cadl/model/implementation/ModelOpsImpl.java index b21c38e620..a9173a6cc1 100644 --- a/typespec-tests/src/main/java/com/cadl/model/implementation/ModelOpsImpl.java +++ b/typespec-tests/src/main/java/com/cadl/model/implementation/ModelOpsImpl.java @@ -64,7 +64,8 @@ public interface ModelOpsService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> put1(@HostParam("endpoint") String endpoint, @HeaderParam("accept") String accept, + 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") @@ -73,7 +74,8 @@ Mono> put1(@HostParam("endpoint") String endpoint, @HeaderP @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response put1Sync(@HostParam("endpoint") String endpoint, @HeaderParam("accept") String accept, + 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") @@ -82,7 +84,8 @@ Response put1Sync(@HostParam("endpoint") String endpoint, @HeaderPar @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> put2(@HostParam("endpoint") String endpoint, @HeaderParam("accept") String accept, + 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") @@ -91,7 +94,8 @@ Mono> put2(@HostParam("endpoint") String endpoint, @HeaderP @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response put2Sync(@HostParam("endpoint") String endpoint, @HeaderParam("accept") String accept, + 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") @@ -100,7 +104,7 @@ Response put2Sync(@HostParam("endpoint") String endpoint, @HeaderPar @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, + Mono> get3(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Get("/model/resource3") @@ -109,7 +113,7 @@ Mono> get3(@HostParam("endpoint") String endpoint, @HeaderP @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, + Response get3Sync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Get("/model/nested") @@ -119,8 +123,8 @@ Response get3Sync(@HostParam("endpoint") String endpoint, @HeaderPar @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Mono> putNested(@HostParam("endpoint") String endpoint, - @HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, - RequestOptions requestOptions, Context context); + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); @Get("/model/nested") @ExpectedResponses({ 200 }) @@ -128,7 +132,8 @@ Mono> putNested(@HostParam("endpoint") String endpoint, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response putNestedSync(@HostParam("endpoint") String endpoint, @HeaderParam("accept") String accept, + Response putNestedSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); } @@ -172,9 +177,10 @@ Response putNestedSync(@HostParam("endpoint") String endpoint, @Head */ @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(), accept, body, requestOptions, context)); + return FluxUtil.withContext( + context -> service.put1(this.client.getEndpoint(), contentType, accept, body, requestOptions, context)); } /** @@ -217,8 +223,9 @@ public Mono> put1WithResponseAsync(BinaryData body, Request */ @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(), accept, body, requestOptions, Context.NONE); + return service.put1Sync(this.client.getEndpoint(), contentType, accept, body, requestOptions, Context.NONE); } /** @@ -255,9 +262,10 @@ public Response put1WithResponse(BinaryData body, RequestOptions req */ @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(), accept, body, requestOptions, context)); + return FluxUtil.withContext( + context -> service.put2(this.client.getEndpoint(), contentType, accept, body, requestOptions, context)); } /** @@ -294,8 +302,9 @@ public Mono> put2WithResponseAsync(BinaryData body, Request */ @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(), accept, body, requestOptions, Context.NONE); + return service.put2Sync(this.client.getEndpoint(), contentType, accept, body, requestOptions, Context.NONE); } /** @@ -387,9 +396,10 @@ public Response get3WithResponse(RequestOptions requestOptions) { */ @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(), accept, body, requestOptions, context)); + return FluxUtil.withContext(context -> service.putNested(this.client.getEndpoint(), contentType, accept, body, + requestOptions, context)); } /** @@ -428,7 +438,9 @@ public Mono> putNestedWithResponseAsync(BinaryData body, Re */ @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(), accept, body, requestOptions, Context.NONE); + return service.putNestedSync(this.client.getEndpoint(), contentType, accept, body, requestOptions, + Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/cadl/multicontenttypes/implementation/MultiContentTypesClientImpl.java b/typespec-tests/src/main/java/com/cadl/multicontenttypes/implementation/MultiContentTypesClientImpl.java index ee1a36ecb4..cf7ce9bb35 100644 --- a/typespec-tests/src/main/java/com/cadl/multicontenttypes/implementation/MultiContentTypesClientImpl.java +++ b/typespec-tests/src/main/java/com/cadl/multicontenttypes/implementation/MultiContentTypesClientImpl.java @@ -42,12 +42,12 @@ public final class MultiContentTypesClientImpl { private final MultiContentTypesClientService service; /** - * Server parameter. + * Service host. */ private final String endpoint; /** - * Gets Server parameter. + * Gets Service host. * * @return the endpoint value. */ @@ -114,7 +114,7 @@ public MultipleContentTypesOnRequestsImpl getMultipleContentTypesOnRequests() { /** * Initializes an instance of MultiContentTypesClient client. * - * @param endpoint Server parameter. + * @param endpoint Service host. */ public MultiContentTypesClientImpl(String endpoint) { this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), @@ -125,7 +125,7 @@ public MultiContentTypesClientImpl(String endpoint) { * Initializes an instance of MultiContentTypesClient client. * * @param httpPipeline The HTTP pipeline to send requests through. - * @param endpoint Server parameter. + * @param endpoint Service host. */ public MultiContentTypesClientImpl(HttpPipeline httpPipeline, String endpoint) { this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint); @@ -136,7 +136,7 @@ public MultiContentTypesClientImpl(HttpPipeline httpPipeline, String endpoint) { * * @param httpPipeline The HTTP pipeline to send requests through. * @param serializerAdapter The serializer to serialize an object into a string. - * @param endpoint Server parameter. + * @param endpoint Service host. */ public MultiContentTypesClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, String endpoint) { @@ -163,8 +163,8 @@ public interface MultiContentTypesClientService { @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Mono> uploadWithOverload(@HostParam("endpoint") String endpoint, - @HeaderParam("content-type") String contentType, @HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData data, RequestOptions requestOptions, Context context); + @HeaderParam("content-type") String contentType, @BodyParam("application/json") BinaryData data, + RequestOptions requestOptions, Context context); @Post("/upload/overload/multi-body-types") @ExpectedResponses({ 204 }) @@ -173,8 +173,8 @@ Mono> uploadWithOverload(@HostParam("endpoint") String endpoint, @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Response uploadWithOverloadSync(@HostParam("endpoint") String endpoint, - @HeaderParam("content-type") String contentType, @HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData data, RequestOptions requestOptions, Context context); + @HeaderParam("content-type") String contentType, @BodyParam("application/json") BinaryData data, + RequestOptions requestOptions, Context context); } /** @@ -198,9 +198,8 @@ Response uploadWithOverloadSync(@HostParam("endpoint") String endpoint, @ServiceMethod(returns = ReturnType.SINGLE) public Mono> uploadWithOverloadWithResponseAsync(String contentType, BinaryData data, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.uploadWithOverload(this.getEndpoint(), contentType, accept, data, - requestOptions, context)); + return FluxUtil.withContext( + context -> service.uploadWithOverload(this.getEndpoint(), contentType, data, requestOptions, context)); } /** @@ -224,8 +223,6 @@ public Mono> uploadWithOverloadWithResponseAsync(String contentTy @ServiceMethod(returns = ReturnType.SINGLE) public Response uploadWithOverloadWithResponse(String contentType, BinaryData data, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.uploadWithOverloadSync(this.getEndpoint(), contentType, accept, data, requestOptions, - Context.NONE); + return service.uploadWithOverloadSync(this.getEndpoint(), contentType, data, requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/cadl/multicontenttypes/implementation/MultipleContentTypesOnRequestsImpl.java b/typespec-tests/src/main/java/com/cadl/multicontenttypes/implementation/MultipleContentTypesOnRequestsImpl.java index 7c1fac05ab..ddbc56d4da 100644 --- a/typespec-tests/src/main/java/com/cadl/multicontenttypes/implementation/MultipleContentTypesOnRequestsImpl.java +++ b/typespec-tests/src/main/java/com/cadl/multicontenttypes/implementation/MultipleContentTypesOnRequestsImpl.java @@ -65,8 +65,8 @@ public interface MultipleContentTypesOnRequestsService { @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Mono> uploadBytesWithSingleBodyTypeForMultiContentTypes(@HostParam("endpoint") String endpoint, - @HeaderParam("content-type") String contentType, @HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData data, RequestOptions requestOptions, Context context); + @HeaderParam("content-type") String contentType, @BodyParam("application/json") BinaryData data, + RequestOptions requestOptions, Context context); @Post("/multiple/sharedroute/request/upload/single-body-type") @ExpectedResponses({ 204 }) @@ -75,8 +75,8 @@ Mono> uploadBytesWithSingleBodyTypeForMultiContentTypes(@HostPara @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Response uploadBytesWithSingleBodyTypeForMultiContentTypesSync(@HostParam("endpoint") String endpoint, - @HeaderParam("content-type") String contentType, @HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData data, RequestOptions requestOptions, Context context); + @HeaderParam("content-type") String contentType, @BodyParam("application/json") BinaryData data, + RequestOptions requestOptions, Context context); @Post("/multiple/sharedroute/request/upload/multi-body-types") @ExpectedResponses({ 204 }) @@ -85,8 +85,8 @@ Response uploadBytesWithSingleBodyTypeForMultiContentTypesSync(@HostParam( @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Mono> uploadBytesWithMultiBodyTypesForMultiContentTypes(@HostParam("endpoint") String endpoint, - @HeaderParam("content-type") String contentType, @HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData data, RequestOptions requestOptions, Context context); + @HeaderParam("content-type") String contentType, @BodyParam("application/json") BinaryData data, + RequestOptions requestOptions, Context context); @Post("/multiple/sharedroute/request/upload/multi-body-types") @ExpectedResponses({ 204 }) @@ -95,8 +95,8 @@ Mono> uploadBytesWithMultiBodyTypesForMultiContentTypes(@HostPara @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Response uploadBytesWithMultiBodyTypesForMultiContentTypesSync(@HostParam("endpoint") String endpoint, - @HeaderParam("content-type") String contentType, @HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData data, RequestOptions requestOptions, Context context); + @HeaderParam("content-type") String contentType, @BodyParam("application/json") BinaryData data, + RequestOptions requestOptions, Context context); @Post("/multiple/sharedroute/request/upload/multi-body-types") @ExpectedResponses({ 204 }) @@ -105,8 +105,8 @@ Response uploadBytesWithMultiBodyTypesForMultiContentTypesSync(@HostParam( @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Mono> uploadJsonWithMultiBodyTypesForMultiContentTypes(@HostParam("endpoint") String endpoint, - @HeaderParam("content-type") String contentType, @HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData data, RequestOptions requestOptions, Context context); + @HeaderParam("content-type") String contentType, @BodyParam("application/json") BinaryData data, + RequestOptions requestOptions, Context context); @Post("/multiple/sharedroute/request/upload/multi-body-types") @ExpectedResponses({ 204 }) @@ -115,8 +115,8 @@ Mono> uploadJsonWithMultiBodyTypesForMultiContentTypes(@HostParam @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Response uploadJsonWithMultiBodyTypesForMultiContentTypesSync(@HostParam("endpoint") String endpoint, - @HeaderParam("content-type") String contentType, @HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData data, RequestOptions requestOptions, Context context); + @HeaderParam("content-type") String contentType, @BodyParam("application/json") BinaryData data, + RequestOptions requestOptions, Context context); @Post("/multiple/sharedroute/request/upload/multi-body-types") @ExpectedResponses({ 204 }) @@ -126,8 +126,7 @@ Response uploadJsonWithMultiBodyTypesForMultiContentTypesSync(@HostParam(" @UnexpectedResponseExceptionType(HttpResponseException.class) Mono> uploadJsonOrBytesWithMultiBodyTypesForMultiContentTypes( @HostParam("endpoint") String endpoint, @HeaderParam("content-type") String contentType, - @HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData data, - RequestOptions requestOptions, Context context); + @BodyParam("application/json") BinaryData data, RequestOptions requestOptions, Context context); @Post("/multiple/sharedroute/request/upload/multi-body-types") @ExpectedResponses({ 204 }) @@ -137,8 +136,7 @@ Mono> uploadJsonOrBytesWithMultiBodyTypesForMultiContentTypes( @UnexpectedResponseExceptionType(HttpResponseException.class) Response uploadJsonOrBytesWithMultiBodyTypesForMultiContentTypesSync( @HostParam("endpoint") String endpoint, @HeaderParam("content-type") String contentType, - @HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData data, - RequestOptions requestOptions, Context context); + @BodyParam("application/json") BinaryData data, RequestOptions requestOptions, Context context); } /** @@ -162,10 +160,9 @@ Response uploadJsonOrBytesWithMultiBodyTypesForMultiContentTypesSync( @ServiceMethod(returns = ReturnType.SINGLE) public Mono> uploadBytesWithSingleBodyTypeForMultiContentTypesWithResponseAsync(String contentType, BinaryData data, RequestOptions requestOptions) { - final String accept = "application/json"; return FluxUtil .withContext(context -> service.uploadBytesWithSingleBodyTypeForMultiContentTypes(this.client.getEndpoint(), - contentType, accept, data, requestOptions, context)); + contentType, data, requestOptions, context)); } /** @@ -189,9 +186,8 @@ public Mono> uploadBytesWithSingleBodyTypeForMultiContentTypesWit @ServiceMethod(returns = ReturnType.SINGLE) public Response uploadBytesWithSingleBodyTypeForMultiContentTypesWithResponse(String contentType, BinaryData data, RequestOptions requestOptions) { - final String accept = "application/json"; return service.uploadBytesWithSingleBodyTypeForMultiContentTypesSync(this.client.getEndpoint(), contentType, - accept, data, requestOptions, Context.NONE); + data, requestOptions, Context.NONE); } /** @@ -215,10 +211,9 @@ public Response uploadBytesWithSingleBodyTypeForMultiContentTypesWithRespo @ServiceMethod(returns = ReturnType.SINGLE) public Mono> uploadBytesWithMultiBodyTypesForMultiContentTypesWithResponseAsync(String contentType, BinaryData data, RequestOptions requestOptions) { - final String accept = "application/json"; return FluxUtil .withContext(context -> service.uploadBytesWithMultiBodyTypesForMultiContentTypes(this.client.getEndpoint(), - contentType, accept, data, requestOptions, context)); + contentType, data, requestOptions, context)); } /** @@ -242,9 +237,8 @@ public Mono> uploadBytesWithMultiBodyTypesForMultiContentTypesWit @ServiceMethod(returns = ReturnType.SINGLE) public Response uploadBytesWithMultiBodyTypesForMultiContentTypesWithResponse(String contentType, BinaryData data, RequestOptions requestOptions) { - final String accept = "application/json"; return service.uploadBytesWithMultiBodyTypesForMultiContentTypesSync(this.client.getEndpoint(), contentType, - accept, data, requestOptions, Context.NONE); + data, requestOptions, Context.NONE); } /** @@ -270,10 +264,9 @@ public Response uploadBytesWithMultiBodyTypesForMultiContentTypesWithRespo public Mono> uploadJsonWithMultiBodyTypesForMultiContentTypesWithResponseAsync(BinaryData data, RequestOptions requestOptions) { final String contentType = "application/json"; - final String accept = "application/json"; return FluxUtil .withContext(context -> service.uploadJsonWithMultiBodyTypesForMultiContentTypes(this.client.getEndpoint(), - contentType, accept, data, requestOptions, context)); + contentType, data, requestOptions, context)); } /** @@ -299,9 +292,8 @@ public Mono> uploadJsonWithMultiBodyTypesForMultiContentTypesWith public Response uploadJsonWithMultiBodyTypesForMultiContentTypesWithResponse(BinaryData data, RequestOptions requestOptions) { final String contentType = "application/json"; - final String accept = "application/json"; return service.uploadJsonWithMultiBodyTypesForMultiContentTypesSync(this.client.getEndpoint(), contentType, - accept, data, requestOptions, Context.NONE); + data, requestOptions, Context.NONE); } /** @@ -325,9 +317,8 @@ public Response uploadJsonWithMultiBodyTypesForMultiContentTypesWithRespon @ServiceMethod(returns = ReturnType.SINGLE) public Mono> uploadJsonOrBytesWithMultiBodyTypesForMultiContentTypesWithResponseAsync( String contentType, BinaryData data, RequestOptions requestOptions) { - final String accept = "application/json"; return FluxUtil.withContext(context -> service.uploadJsonOrBytesWithMultiBodyTypesForMultiContentTypes( - this.client.getEndpoint(), contentType, accept, data, requestOptions, context)); + this.client.getEndpoint(), contentType, data, requestOptions, context)); } /** @@ -351,8 +342,7 @@ public Mono> uploadJsonOrBytesWithMultiBodyTypesForMultiContentTy @ServiceMethod(returns = ReturnType.SINGLE) public Response uploadJsonOrBytesWithMultiBodyTypesForMultiContentTypesWithResponse(String contentType, BinaryData data, RequestOptions requestOptions) { - final String accept = "application/json"; return service.uploadJsonOrBytesWithMultiBodyTypesForMultiContentTypesSync(this.client.getEndpoint(), - contentType, accept, data, requestOptions, Context.NONE); + contentType, data, requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/cadl/multicontenttypes/implementation/SingleContentTypesImpl.java b/typespec-tests/src/main/java/com/cadl/multicontenttypes/implementation/SingleContentTypesImpl.java index 1d5a4aae4a..5ed3adbc93 100644 --- a/typespec-tests/src/main/java/com/cadl/multicontenttypes/implementation/SingleContentTypesImpl.java +++ b/typespec-tests/src/main/java/com/cadl/multicontenttypes/implementation/SingleContentTypesImpl.java @@ -66,7 +66,7 @@ public interface SingleContentTypesService { @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Mono> downloadImageForSingleContentType(@HostParam("endpoint") String endpoint, - @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Get("/single/request/download/image") @ExpectedResponses({ 200 }) @@ -75,7 +75,7 @@ Mono> downloadImageForSingleContentType(@HostParam("endpoin @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Response downloadImageForSingleContentTypeSync(@HostParam("endpoint") String endpoint, - @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Post("/single/request/upload/image") @ExpectedResponses({ 204 }) @@ -84,8 +84,8 @@ Response downloadImageForSingleContentTypeSync(@HostParam("endpoint" @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Mono> uploadImageForSingleContentType(@HostParam("endpoint") String endpoint, - @HeaderParam("content-type") String contentType, @HeaderParam("accept") String accept, - @BodyParam("image/png") BinaryData data, RequestOptions requestOptions, Context context); + @HeaderParam("content-type") String contentType, @BodyParam("image/png") BinaryData data, + RequestOptions requestOptions, Context context); @Post("/single/request/upload/image") @ExpectedResponses({ 204 }) @@ -94,8 +94,8 @@ Mono> uploadImageForSingleContentType(@HostParam("endpoint") Stri @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Response uploadImageForSingleContentTypeSync(@HostParam("endpoint") String endpoint, - @HeaderParam("content-type") String contentType, @HeaderParam("accept") String accept, - @BodyParam("image/png") BinaryData data, RequestOptions requestOptions, Context context); + @HeaderParam("content-type") String contentType, @BodyParam("image/png") BinaryData data, + RequestOptions requestOptions, Context context); } /** @@ -163,9 +163,8 @@ public Response downloadImageForSingleContentTypeWithResponse(Reques public Mono> uploadImageForSingleContentTypeWithResponseAsync(BinaryData data, RequestOptions requestOptions) { final String contentType = "image/png"; - final String accept = "application/json"; return FluxUtil.withContext(context -> service.uploadImageForSingleContentType(this.client.getEndpoint(), - contentType, accept, data, requestOptions, context)); + contentType, data, requestOptions, context)); } /** @@ -187,8 +186,7 @@ public Mono> uploadImageForSingleContentTypeWithResponseAsync(Bin @ServiceMethod(returns = ReturnType.SINGLE) public Response uploadImageForSingleContentTypeWithResponse(BinaryData data, RequestOptions requestOptions) { final String contentType = "image/png"; - final String accept = "application/json"; - return service.uploadImageForSingleContentTypeSync(this.client.getEndpoint(), contentType, accept, data, - requestOptions, Context.NONE); + return service.uploadImageForSingleContentTypeSync(this.client.getEndpoint(), contentType, data, requestOptions, + Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/cadl/multipart/implementation/MultipartClientImpl.java b/typespec-tests/src/main/java/com/cadl/multipart/implementation/MultipartClientImpl.java index 4fb2f3255e..c0b1c87530 100644 --- a/typespec-tests/src/main/java/com/cadl/multipart/implementation/MultipartClientImpl.java +++ b/typespec-tests/src/main/java/com/cadl/multipart/implementation/MultipartClientImpl.java @@ -43,12 +43,12 @@ public final class MultipartClientImpl { private final MultipartClientService service; /** - * Server parameter. + * Service host. */ private final String endpoint; /** - * Gets Server parameter. + * Gets Service host. * * @return the endpoint value. */ @@ -87,7 +87,7 @@ public SerializerAdapter getSerializerAdapter() { /** * Initializes an instance of MultipartClient client. * - * @param endpoint Server parameter. + * @param endpoint Service host. */ public MultipartClientImpl(String endpoint) { this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), @@ -98,7 +98,7 @@ public MultipartClientImpl(String endpoint) { * Initializes an instance of MultipartClient client. * * @param httpPipeline The HTTP pipeline to send requests through. - * @param endpoint Server parameter. + * @param endpoint Service host. */ public MultipartClientImpl(HttpPipeline httpPipeline, String endpoint) { this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint); @@ -109,7 +109,7 @@ public MultipartClientImpl(HttpPipeline httpPipeline, String endpoint) { * * @param httpPipeline The HTTP pipeline to send requests through. * @param serializerAdapter The serializer to serialize an object into a string. - * @param endpoint Server parameter. + * @param endpoint Service host. */ public MultipartClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, String endpoint) { this.httpPipeline = httpPipeline; @@ -133,8 +133,8 @@ public interface MultipartClientService { @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Mono> upload(@HostParam("endpoint") String endpoint, @PathParam("name") String name, - @HeaderParam("content-type") String contentType, @HeaderParam("accept") String accept, - @BodyParam("multipart/form-data") BinaryData data, RequestOptions requestOptions, Context context); + @HeaderParam("content-type") String contentType, @BodyParam("multipart/form-data") BinaryData data, + RequestOptions requestOptions, Context context); // @Multipart not supported by RestProxy @Post("/upload/images/{name}") @@ -144,8 +144,8 @@ Mono> upload(@HostParam("endpoint") String endpoint, @PathParam(" @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Response uploadSync(@HostParam("endpoint") String endpoint, @PathParam("name") String name, - @HeaderParam("content-type") String contentType, @HeaderParam("accept") String accept, - @BodyParam("multipart/form-data") BinaryData data, RequestOptions requestOptions, Context context); + @HeaderParam("content-type") String contentType, @BodyParam("multipart/form-data") BinaryData data, + RequestOptions requestOptions, Context context); // @Multipart not supported by RestProxy @Post("/uploadHttpPart/images/{name}") @@ -155,8 +155,8 @@ Response uploadSync(@HostParam("endpoint") String endpoint, @PathParam("na @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Mono> uploadHttpPart(@HostParam("endpoint") String endpoint, @PathParam("name") String name, - @HeaderParam("content-type") String contentType, @HeaderParam("accept") String accept, - @BodyParam("multipart/form-data") BinaryData body, RequestOptions requestOptions, Context context); + @HeaderParam("content-type") String contentType, @BodyParam("multipart/form-data") BinaryData body, + RequestOptions requestOptions, Context context); // @Multipart not supported by RestProxy @Post("/uploadHttpPart/images/{name}") @@ -166,8 +166,8 @@ Mono> uploadHttpPart(@HostParam("endpoint") String endpoint, @Pat @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Response uploadHttpPartSync(@HostParam("endpoint") String endpoint, @PathParam("name") String name, - @HeaderParam("content-type") String contentType, @HeaderParam("accept") String accept, - @BodyParam("multipart/form-data") BinaryData body, RequestOptions requestOptions, Context context); + @HeaderParam("content-type") String contentType, @BodyParam("multipart/form-data") BinaryData body, + RequestOptions requestOptions, Context context); } /** @@ -192,9 +192,8 @@ Response uploadHttpPartSync(@HostParam("endpoint") String endpoint, @PathP @ServiceMethod(returns = ReturnType.SINGLE) public Mono> uploadWithResponseAsync(String name, BinaryData data, RequestOptions requestOptions) { final String contentType = "multipart/form-data"; - final String accept = "application/json"; return FluxUtil.withContext( - context -> service.upload(this.getEndpoint(), name, contentType, accept, data, requestOptions, context)); + context -> service.upload(this.getEndpoint(), name, contentType, data, requestOptions, context)); } /** @@ -219,8 +218,7 @@ public Mono> uploadWithResponseAsync(String name, BinaryData data @ServiceMethod(returns = ReturnType.SINGLE) public Response uploadWithResponse(String name, BinaryData data, RequestOptions requestOptions) { final String contentType = "multipart/form-data"; - final String accept = "application/json"; - return service.uploadSync(this.getEndpoint(), name, contentType, accept, data, requestOptions, Context.NONE); + return service.uploadSync(this.getEndpoint(), name, contentType, data, requestOptions, Context.NONE); } /** @@ -246,9 +244,8 @@ public Response uploadWithResponse(String name, BinaryData data, RequestOp public Mono> uploadHttpPartWithResponseAsync(String name, BinaryData body, RequestOptions requestOptions) { final String contentType = "multipart/form-data"; - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.uploadHttpPart(this.getEndpoint(), name, contentType, accept, - body, requestOptions, context)); + return FluxUtil.withContext( + context -> service.uploadHttpPart(this.getEndpoint(), name, contentType, body, requestOptions, context)); } /** @@ -273,8 +270,6 @@ public Mono> uploadHttpPartWithResponseAsync(String name, BinaryD @ServiceMethod(returns = ReturnType.SINGLE) public Response uploadHttpPartWithResponse(String name, BinaryData body, RequestOptions requestOptions) { final String contentType = "multipart/form-data"; - final String accept = "application/json"; - return service.uploadHttpPartSync(this.getEndpoint(), name, contentType, accept, body, requestOptions, - Context.NONE); + return service.uploadHttpPartSync(this.getEndpoint(), name, contentType, body, requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/cadl/multipleapiversion/implementation/FirstClientImpl.java b/typespec-tests/src/main/java/com/cadl/multipleapiversion/implementation/FirstClientImpl.java index bf980a08cd..72350c4d9d 100644 --- a/typespec-tests/src/main/java/com/cadl/multipleapiversion/implementation/FirstClientImpl.java +++ b/typespec-tests/src/main/java/com/cadl/multipleapiversion/implementation/FirstClientImpl.java @@ -44,12 +44,12 @@ public final class FirstClientImpl { private final FirstClientService service; /** - * Server parameter. + * Service host. */ private final String endpoint; /** - * Gets Server parameter. + * Gets Service host. * * @return the endpoint value. */ @@ -102,7 +102,7 @@ public SerializerAdapter getSerializerAdapter() { /** * Initializes an instance of FirstClient client. * - * @param endpoint Server parameter. + * @param endpoint Service host. * @param serviceVersion Service version. */ public FirstClientImpl(String endpoint, FirstServiceVersion serviceVersion) { @@ -114,7 +114,7 @@ public FirstClientImpl(String endpoint, FirstServiceVersion serviceVersion) { * Initializes an instance of FirstClient client. * * @param httpPipeline The HTTP pipeline to send requests through. - * @param endpoint Server parameter. + * @param endpoint Service host. * @param serviceVersion Service version. */ public FirstClientImpl(HttpPipeline httpPipeline, String endpoint, FirstServiceVersion serviceVersion) { @@ -126,7 +126,7 @@ public FirstClientImpl(HttpPipeline httpPipeline, String endpoint, FirstServiceV * * @param httpPipeline The HTTP pipeline to send requests through. * @param serializerAdapter The serializer to serialize an object into a string. - * @param endpoint Server parameter. + * @param endpoint Service host. * @param serviceVersion Service version. */ public FirstClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, String endpoint, @@ -152,7 +152,7 @@ public interface FirstClientService { @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); + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Get("/client1/resources/{name}") @ExpectedResponses({ 200 }) @@ -162,7 +162,7 @@ Mono> get(@HostParam("endpoint") String endpoint, @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); + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); } /** diff --git a/typespec-tests/src/main/java/com/cadl/multipleapiversion/implementation/NoApiVersionClientImpl.java b/typespec-tests/src/main/java/com/cadl/multipleapiversion/implementation/NoApiVersionClientImpl.java index 12ebd54b91..bd0eb8a1b1 100644 --- a/typespec-tests/src/main/java/com/cadl/multipleapiversion/implementation/NoApiVersionClientImpl.java +++ b/typespec-tests/src/main/java/com/cadl/multipleapiversion/implementation/NoApiVersionClientImpl.java @@ -5,7 +5,6 @@ package com.cadl.multipleapiversion.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.Post; @@ -41,12 +40,12 @@ public final class NoApiVersionClientImpl { private final NoApiVersionClientService service; /** - * Server parameter. + * Service host. */ private final String endpoint; /** - * Gets Server parameter. + * Gets Service host. * * @return the endpoint value. */ @@ -99,7 +98,7 @@ public SerializerAdapter getSerializerAdapter() { /** * Initializes an instance of NoApiVersionClient client. * - * @param endpoint Server parameter. + * @param endpoint Service host. * @param serviceVersion Service version. */ public NoApiVersionClientImpl(String endpoint, NoApiVersionServiceVersion serviceVersion) { @@ -111,7 +110,7 @@ public NoApiVersionClientImpl(String endpoint, NoApiVersionServiceVersion servic * Initializes an instance of NoApiVersionClient client. * * @param httpPipeline The HTTP pipeline to send requests through. - * @param endpoint Server parameter. + * @param endpoint Service host. * @param serviceVersion Service version. */ public NoApiVersionClientImpl(HttpPipeline httpPipeline, String endpoint, @@ -124,7 +123,7 @@ public NoApiVersionClientImpl(HttpPipeline httpPipeline, String endpoint, * * @param httpPipeline The HTTP pipeline to send requests through. * @param serializerAdapter The serializer to serialize an object into a string. - * @param endpoint Server parameter. + * @param endpoint Service host. * @param serviceVersion Service version. */ public NoApiVersionClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, String endpoint, @@ -150,8 +149,8 @@ public interface NoApiVersionClientService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> action(@HostParam("endpoint") String endpoint, @HeaderParam("accept") String accept, - RequestOptions requestOptions, Context context); + Mono> action(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, + Context context); @Post("/client3") @ExpectedResponses({ 200 }) @@ -159,8 +158,8 @@ Mono> action(@HostParam("endpoint") String endpoint, @HeaderParam @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response actionSync(@HostParam("endpoint") String endpoint, @HeaderParam("accept") String accept, - RequestOptions requestOptions, Context context); + Response actionSync(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, + Context context); } /** @@ -182,8 +181,7 @@ Response actionSync(@HostParam("endpoint") String endpoint, @HeaderParam(" */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> actionWithResponseAsync(RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.action(this.getEndpoint(), accept, requestOptions, context)); + return FluxUtil.withContext(context -> service.action(this.getEndpoint(), requestOptions, context)); } /** @@ -205,7 +203,6 @@ public Mono> actionWithResponseAsync(RequestOptions requestOption */ @ServiceMethod(returns = ReturnType.SINGLE) public Response actionWithResponse(RequestOptions requestOptions) { - final String accept = "application/json"; - return service.actionSync(this.getEndpoint(), accept, requestOptions, Context.NONE); + return service.actionSync(this.getEndpoint(), requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/cadl/multipleapiversion/implementation/SecondClientImpl.java b/typespec-tests/src/main/java/com/cadl/multipleapiversion/implementation/SecondClientImpl.java index 71cbdd9fb9..0e29c7149b 100644 --- a/typespec-tests/src/main/java/com/cadl/multipleapiversion/implementation/SecondClientImpl.java +++ b/typespec-tests/src/main/java/com/cadl/multipleapiversion/implementation/SecondClientImpl.java @@ -44,12 +44,12 @@ public final class SecondClientImpl { private final SecondClientService service; /** - * Server parameter. + * Service host. */ private final String endpoint; /** - * Gets Server parameter. + * Gets Service host. * * @return the endpoint value. */ @@ -102,7 +102,7 @@ public SerializerAdapter getSerializerAdapter() { /** * Initializes an instance of SecondClient client. * - * @param endpoint Server parameter. + * @param endpoint Service host. * @param serviceVersion Service version. */ public SecondClientImpl(String endpoint, SecondServiceVersion serviceVersion) { @@ -114,7 +114,7 @@ public SecondClientImpl(String endpoint, SecondServiceVersion serviceVersion) { * Initializes an instance of SecondClient client. * * @param httpPipeline The HTTP pipeline to send requests through. - * @param endpoint Server parameter. + * @param endpoint Service host. * @param serviceVersion Service version. */ public SecondClientImpl(HttpPipeline httpPipeline, String endpoint, SecondServiceVersion serviceVersion) { @@ -126,7 +126,7 @@ public SecondClientImpl(HttpPipeline httpPipeline, String endpoint, SecondServic * * @param httpPipeline The HTTP pipeline to send requests through. * @param serializerAdapter The serializer to serialize an object into a string. - * @param endpoint Server parameter. + * @param endpoint Service host. * @param serviceVersion Service version. */ public SecondClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, String endpoint, @@ -152,7 +152,7 @@ public interface SecondClientService { @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); + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Get("/client2/resources/{name}") @ExpectedResponses({ 200 }) @@ -162,7 +162,7 @@ Mono> get(@HostParam("endpoint") String endpoint, @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); + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); } /** diff --git a/typespec-tests/src/main/java/com/cadl/naming/implementation/NamingClientImpl.java b/typespec-tests/src/main/java/com/cadl/naming/implementation/NamingClientImpl.java index 0c0c5b717d..e45bea2aea 100644 --- a/typespec-tests/src/main/java/com/cadl/naming/implementation/NamingClientImpl.java +++ b/typespec-tests/src/main/java/com/cadl/naming/implementation/NamingClientImpl.java @@ -16,12 +16,12 @@ */ public final class NamingClientImpl { /** - * Server parameter. + * Service host. */ private final String endpoint; /** - * Gets Server parameter. + * Gets Service host. * * @return the endpoint value. */ @@ -74,7 +74,7 @@ public NamingOpsImpl getNamingOps() { /** * Initializes an instance of NamingClient client. * - * @param endpoint Server parameter. + * @param endpoint Service host. */ public NamingClientImpl(String endpoint) { this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), @@ -85,7 +85,7 @@ public NamingClientImpl(String endpoint) { * Initializes an instance of NamingClient client. * * @param httpPipeline The HTTP pipeline to send requests through. - * @param endpoint Server parameter. + * @param endpoint Service host. */ public NamingClientImpl(HttpPipeline httpPipeline, String endpoint) { this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint); @@ -96,7 +96,7 @@ public NamingClientImpl(HttpPipeline httpPipeline, String endpoint) { * * @param httpPipeline The HTTP pipeline to send requests through. * @param serializerAdapter The serializer to serialize an object into a string. - * @param endpoint Server parameter. + * @param endpoint Service host. */ public NamingClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, String endpoint) { this.httpPipeline = httpPipeline; diff --git a/typespec-tests/src/main/java/com/cadl/naming/implementation/NamingOpsImpl.java b/typespec-tests/src/main/java/com/cadl/naming/implementation/NamingOpsImpl.java index 7099e00ac3..5ec21c69f9 100644 --- a/typespec-tests/src/main/java/com/cadl/naming/implementation/NamingOpsImpl.java +++ b/typespec-tests/src/main/java/com/cadl/naming/implementation/NamingOpsImpl.java @@ -67,8 +67,8 @@ public interface NamingOpsService { @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Mono> post(@HostParam("endpoint") String endpoint, @QueryParam("name") String name, - @HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, - RequestOptions requestOptions, Context context); + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); @Post("/naming") @ExpectedResponses({ 200 }) @@ -77,8 +77,8 @@ Mono> post(@HostParam("endpoint") String endpoint, @QueryPa @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Response postSync(@HostParam("endpoint") String endpoint, @QueryParam("name") String name, - @HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, - RequestOptions requestOptions, Context context); + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); @Get("/naming") @ExpectedResponses({ 200 }) @@ -87,7 +87,7 @@ Response postSync(@HostParam("endpoint") String endpoint, @QueryPara @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Mono> getAnonymous(@HostParam("endpoint") String endpoint, - @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Get("/naming") @ExpectedResponses({ 200 }) @@ -96,7 +96,7 @@ Mono> getAnonymous(@HostParam("endpoint") String endpoint, @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Response getAnonymousSync(@HostParam("endpoint") String endpoint, - @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); } /** @@ -156,9 +156,10 @@ Response getAnonymousSync(@HostParam("endpoint") String endpoint, @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, accept, body, requestOptions, context)); + return FluxUtil.withContext(context -> service.post(this.client.getEndpoint(), name, contentType, accept, body, + requestOptions, context)); } /** @@ -217,8 +218,10 @@ public Mono> postWithResponseAsync(String name, BinaryData */ @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, accept, body, requestOptions, Context.NONE); + return service.postSync(this.client.getEndpoint(), name, contentType, accept, body, requestOptions, + Context.NONE); } /** diff --git a/typespec-tests/src/main/java/com/cadl/optional/implementation/OptionalClientImpl.java b/typespec-tests/src/main/java/com/cadl/optional/implementation/OptionalClientImpl.java index 8eee8db184..9d1063ffad 100644 --- a/typespec-tests/src/main/java/com/cadl/optional/implementation/OptionalClientImpl.java +++ b/typespec-tests/src/main/java/com/cadl/optional/implementation/OptionalClientImpl.java @@ -16,12 +16,12 @@ */ public final class OptionalClientImpl { /** - * Server parameter. + * Service host. */ private final String endpoint; /** - * Gets Server parameter. + * Gets Service host. * * @return the endpoint value. */ @@ -74,7 +74,7 @@ public OptionalOpsImpl getOptionalOps() { /** * Initializes an instance of OptionalClient client. * - * @param endpoint Server parameter. + * @param endpoint Service host. */ public OptionalClientImpl(String endpoint) { this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), @@ -85,7 +85,7 @@ public OptionalClientImpl(String endpoint) { * Initializes an instance of OptionalClient client. * * @param httpPipeline The HTTP pipeline to send requests through. - * @param endpoint Server parameter. + * @param endpoint Service host. */ public OptionalClientImpl(HttpPipeline httpPipeline, String endpoint) { this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint); @@ -96,7 +96,7 @@ public OptionalClientImpl(HttpPipeline httpPipeline, String endpoint) { * * @param httpPipeline The HTTP pipeline to send requests through. * @param serializerAdapter The serializer to serialize an object into a string. - * @param endpoint Server parameter. + * @param endpoint Service host. */ public OptionalClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, String endpoint) { this.httpPipeline = httpPipeline; diff --git a/typespec-tests/src/main/java/com/cadl/optional/implementation/OptionalOpsImpl.java b/typespec-tests/src/main/java/com/cadl/optional/implementation/OptionalOpsImpl.java index 3631cec7da..df25fa882e 100644 --- a/typespec-tests/src/main/java/com/cadl/optional/implementation/OptionalOpsImpl.java +++ b/typespec-tests/src/main/java/com/cadl/optional/implementation/OptionalOpsImpl.java @@ -70,7 +70,7 @@ Mono> put(@HostParam("endpoint") String endpoint, @QueryParam("booleanRequired") boolean booleanRequired, @QueryParam("booleanRequiredNullable") Boolean booleanRequiredNullable, @QueryParam("stringRequired") String stringRequired, - @QueryParam("stringRequiredNullable") String stringRequiredNullable, @HeaderParam("accept") String accept, + @QueryParam("stringRequiredNullable") String stringRequiredNullable, @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Put("/optional/put") @@ -84,7 +84,7 @@ Response putSync(@HostParam("endpoint") String endpoint, @QueryParam("booleanRequired") boolean booleanRequired, @QueryParam("booleanRequiredNullable") Boolean booleanRequiredNullable, @QueryParam("stringRequired") String stringRequired, - @QueryParam("stringRequiredNullable") String stringRequiredNullable, @HeaderParam("accept") String accept, + @QueryParam("stringRequiredNullable") String stringRequiredNullable, @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); } diff --git a/typespec-tests/src/main/java/com/cadl/partialupdate/implementation/PartialUpdateClientImpl.java b/typespec-tests/src/main/java/com/cadl/partialupdate/implementation/PartialUpdateClientImpl.java index dec63b0243..b845d53aad 100644 --- a/typespec-tests/src/main/java/com/cadl/partialupdate/implementation/PartialUpdateClientImpl.java +++ b/typespec-tests/src/main/java/com/cadl/partialupdate/implementation/PartialUpdateClientImpl.java @@ -41,12 +41,12 @@ public final class PartialUpdateClientImpl { private final PartialUpdateClientService service; /** - * Server parameter. + * Service host. */ private final String endpoint; /** - * Gets Server parameter. + * Gets Service host. * * @return the endpoint value. */ @@ -85,7 +85,7 @@ public SerializerAdapter getSerializerAdapter() { /** * Initializes an instance of PartialUpdateClient client. * - * @param endpoint Server parameter. + * @param endpoint Service host. */ public PartialUpdateClientImpl(String endpoint) { this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), @@ -96,7 +96,7 @@ public PartialUpdateClientImpl(String endpoint) { * Initializes an instance of PartialUpdateClient client. * * @param httpPipeline The HTTP pipeline to send requests through. - * @param endpoint Server parameter. + * @param endpoint Service host. */ public PartialUpdateClientImpl(HttpPipeline httpPipeline, String endpoint) { this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint); @@ -107,7 +107,7 @@ public PartialUpdateClientImpl(HttpPipeline httpPipeline, String endpoint) { * * @param httpPipeline The HTTP pipeline to send requests through. * @param serializerAdapter The serializer to serialize an object into a string. - * @param endpoint Server parameter. + * @param endpoint Service host. */ public PartialUpdateClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, String endpoint) { this.httpPipeline = httpPipeline; @@ -130,7 +130,7 @@ public interface PartialUpdateClientService { @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, + Mono> read(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Get("/partialupdate") @@ -139,7 +139,7 @@ Mono> read(@HostParam("endpoint") String endpoint, @HeaderP @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, + Response readSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); } diff --git a/typespec-tests/src/main/java/com/cadl/patch/PatchAsyncClient.java b/typespec-tests/src/main/java/com/cadl/patch/PatchAsyncClient.java index 698b8f12aa..4dea94aaf7 100644 --- a/typespec-tests/src/main/java/com/cadl/patch/PatchAsyncClient.java +++ b/typespec-tests/src/main/java/com/cadl/patch/PatchAsyncClient.java @@ -119,6 +119,14 @@ public Mono> createOrUpdateResourceWithResponse(BinaryData /** * 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
diff --git a/typespec-tests/src/main/java/com/cadl/patch/PatchClient.java b/typespec-tests/src/main/java/com/cadl/patch/PatchClient.java
index ed6c380398..05d6446056 100644
--- a/typespec-tests/src/main/java/com/cadl/patch/PatchClient.java
+++ b/typespec-tests/src/main/java/com/cadl/patch/PatchClient.java
@@ -116,6 +116,14 @@ public Response createOrUpdateResourceWithResponse(BinaryData resour
 
     /**
      * 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
diff --git a/typespec-tests/src/main/java/com/cadl/patch/implementation/PatchClientImpl.java b/typespec-tests/src/main/java/com/cadl/patch/implementation/PatchClientImpl.java
index 87497b2dbd..e6cdd0a91f 100644
--- a/typespec-tests/src/main/java/com/cadl/patch/implementation/PatchClientImpl.java
+++ b/typespec-tests/src/main/java/com/cadl/patch/implementation/PatchClientImpl.java
@@ -16,12 +16,12 @@
  */
 public final class PatchClientImpl {
     /**
-     * Server parameter.
+     * Service host.
      */
     private final String endpoint;
 
     /**
-     * Gets Server parameter.
+     * Gets Service host.
      * 
      * @return the endpoint value.
      */
@@ -74,7 +74,7 @@ public PatchesImpl getPatches() {
     /**
      * Initializes an instance of PatchClient client.
      * 
-     * @param endpoint Server parameter.
+     * @param endpoint Service host.
      */
     public PatchClientImpl(String endpoint) {
         this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(),
@@ -85,7 +85,7 @@ public PatchClientImpl(String endpoint) {
      * Initializes an instance of PatchClient client.
      * 
      * @param httpPipeline The HTTP pipeline to send requests through.
-     * @param endpoint Server parameter.
+     * @param endpoint Service host.
      */
     public PatchClientImpl(HttpPipeline httpPipeline, String endpoint) {
         this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint);
@@ -96,7 +96,7 @@ public PatchClientImpl(HttpPipeline httpPipeline, String endpoint) {
      * 
      * @param httpPipeline The HTTP pipeline to send requests through.
      * @param serializerAdapter The serializer to serialize an object into a string.
-     * @param endpoint Server parameter.
+     * @param endpoint Service host.
      */
     public PatchClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, String endpoint) {
         this.httpPipeline = httpPipeline;
diff --git a/typespec-tests/src/main/java/com/cadl/patch/implementation/PatchesImpl.java b/typespec-tests/src/main/java/com/cadl/patch/implementation/PatchesImpl.java
index e3e46aed12..4c05f57d8a 100644
--- a/typespec-tests/src/main/java/com/cadl/patch/implementation/PatchesImpl.java
+++ b/typespec-tests/src/main/java/com/cadl/patch/implementation/PatchesImpl.java
@@ -65,7 +65,7 @@ public interface PatchesService {
         @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 })
         @UnexpectedResponseExceptionType(HttpResponseException.class)
         Mono> createOrUpdateResource(@HostParam("endpoint") String endpoint,
-            @HeaderParam("content-type") String contentType, @HeaderParam("accept") String accept,
+            @HeaderParam("content-type") String contentType, @HeaderParam("Accept") String accept,
             @BodyParam("application/merge-patch+json") BinaryData resource, RequestOptions requestOptions,
             Context context);
 
@@ -76,7 +76,7 @@ Mono> createOrUpdateResource(@HostParam("endpoint") String
         @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 })
         @UnexpectedResponseExceptionType(HttpResponseException.class)
         Response createOrUpdateResourceSync(@HostParam("endpoint") String endpoint,
-            @HeaderParam("content-type") String contentType, @HeaderParam("accept") String accept,
+            @HeaderParam("content-type") String contentType, @HeaderParam("Accept") String accept,
             @BodyParam("application/merge-patch+json") BinaryData resource, RequestOptions requestOptions,
             Context context);
 
@@ -87,8 +87,7 @@ Response createOrUpdateResourceSync(@HostParam("endpoint") String en
         @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 })
         @UnexpectedResponseExceptionType(HttpResponseException.class)
         Mono> createOrUpdateOptionalResource(@HostParam("endpoint") String endpoint,
-            @HeaderParam("content-type") String contentType, @HeaderParam("accept") String accept,
-            RequestOptions requestOptions, Context context);
+            @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context);
 
         @Patch("/patch/resource/optional")
         @ExpectedResponses({ 200 })
@@ -97,8 +96,7 @@ Mono> createOrUpdateOptionalResource(@HostParam("endpoint")
         @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 })
         @UnexpectedResponseExceptionType(HttpResponseException.class)
         Response createOrUpdateOptionalResourceSync(@HostParam("endpoint") String endpoint,
-            @HeaderParam("content-type") String contentType, @HeaderParam("accept") String accept,
-            RequestOptions requestOptions, Context context);
+            @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context);
 
         @Patch("/patch/fish")
         @ExpectedResponses({ 200 })
@@ -107,7 +105,7 @@ Response createOrUpdateOptionalResourceSync(@HostParam("endpoint") S
         @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 })
         @UnexpectedResponseExceptionType(HttpResponseException.class)
         Mono> createOrUpdateFish(@HostParam("endpoint") String endpoint,
-            @HeaderParam("content-type") String contentType, @HeaderParam("accept") String accept,
+            @HeaderParam("content-type") String contentType, @HeaderParam("Accept") String accept,
             @BodyParam("application/merge-patch+json") BinaryData fish, RequestOptions requestOptions, Context context);
 
         @Patch("/patch/fish")
@@ -117,7 +115,7 @@ Mono> createOrUpdateFish(@HostParam("endpoint") String endp
         @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 })
         @UnexpectedResponseExceptionType(HttpResponseException.class)
         Response createOrUpdateFishSync(@HostParam("endpoint") String endpoint,
-            @HeaderParam("content-type") String contentType, @HeaderParam("accept") String accept,
+            @HeaderParam("content-type") String contentType, @HeaderParam("Accept") String accept,
             @BodyParam("application/merge-patch+json") BinaryData fish, RequestOptions requestOptions, Context context);
     }
 
@@ -280,6 +278,14 @@ public Response createOrUpdateResourceWithResponse(BinaryData resour
 
     /**
      * 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
@@ -349,7 +355,6 @@ public Response createOrUpdateResourceWithResponse(BinaryData resour
      */
     @ServiceMethod(returns = ReturnType.SINGLE)
     public Mono> createOrUpdateOptionalResourceWithResponseAsync(RequestOptions requestOptions) {
-        final String contentType = "application/merge-patch+json";
         final String accept = "application/json";
         RequestOptions requestOptionsLocal = requestOptions == null ? new RequestOptions() : requestOptions;
         requestOptionsLocal.addRequestCallback(requestLocal -> {
@@ -357,12 +362,20 @@ public Mono> createOrUpdateOptionalResourceWithResponseAsyn
                 requestLocal.getHeaders().set(HttpHeaderName.CONTENT_TYPE, "application/merge-patch+json");
             }
         });
-        return FluxUtil.withContext(context -> service.createOrUpdateOptionalResource(this.client.getEndpoint(),
-            contentType, accept, requestOptionsLocal, context));
+        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
@@ -432,7 +445,6 @@ public Mono> createOrUpdateOptionalResourceWithResponseAsyn
      */
     @ServiceMethod(returns = ReturnType.SINGLE)
     public Response createOrUpdateOptionalResourceWithResponse(RequestOptions requestOptions) {
-        final String contentType = "application/merge-patch+json";
         final String accept = "application/json";
         RequestOptions requestOptionsLocal = requestOptions == null ? new RequestOptions() : requestOptions;
         requestOptionsLocal.addRequestCallback(requestLocal -> {
@@ -440,8 +452,8 @@ public Response createOrUpdateOptionalResourceWithResponse(RequestOp
                 requestLocal.getHeaders().set(HttpHeaderName.CONTENT_TYPE, "application/merge-patch+json");
             }
         });
-        return service.createOrUpdateOptionalResourceSync(this.client.getEndpoint(), contentType, accept,
-            requestOptionsLocal, Context.NONE);
+        return service.createOrUpdateOptionalResourceSync(this.client.getEndpoint(), accept, requestOptionsLocal,
+            Context.NONE);
     }
 
     /**
diff --git a/typespec-tests/src/main/java/com/cadl/protocolandconvenient/implementation/ProtocolAndConvenienceOpsImpl.java b/typespec-tests/src/main/java/com/cadl/protocolandconvenient/implementation/ProtocolAndConvenienceOpsImpl.java
index aefc9d2a6a..2e3b98433e 100644
--- a/typespec-tests/src/main/java/com/cadl/protocolandconvenient/implementation/ProtocolAndConvenienceOpsImpl.java
+++ b/typespec-tests/src/main/java/com/cadl/protocolandconvenient/implementation/ProtocolAndConvenienceOpsImpl.java
@@ -94,8 +94,8 @@ public interface ProtocolAndConvenienceOpsService {
         @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 })
         @UnexpectedResponseExceptionType(HttpResponseException.class)
         Mono> onlyConvenient(@HostParam("endpoint") String endpoint,
-            @HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body,
-            RequestOptions requestOptions, Context context);
+            @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept,
+            @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context);
 
         @Post("/protocolandconvenient/onlyConvenient")
         @ExpectedResponses({ 200 })
@@ -104,8 +104,8 @@ Mono> onlyConvenient(@HostParam("endpoint") String endpoint
         @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 })
         @UnexpectedResponseExceptionType(HttpResponseException.class)
         Response onlyConvenientSync(@HostParam("endpoint") String endpoint,
-            @HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body,
-            RequestOptions requestOptions, Context context);
+            @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept,
+            @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context);
 
         @Post("/protocolandconvenient/onlyProtocol")
         @ExpectedResponses({ 200 })
@@ -114,8 +114,8 @@ Response onlyConvenientSync(@HostParam("endpoint") String endpoint,
         @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 })
         @UnexpectedResponseExceptionType(HttpResponseException.class)
         Mono> onlyProtocol(@HostParam("endpoint") String endpoint,
-            @HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body,
-            RequestOptions requestOptions, Context context);
+            @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept,
+            @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context);
 
         @Post("/protocolandconvenient/onlyProtocol")
         @ExpectedResponses({ 200 })
@@ -124,8 +124,8 @@ Mono> onlyProtocol(@HostParam("endpoint") String endpoint,
         @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 })
         @UnexpectedResponseExceptionType(HttpResponseException.class)
         Response onlyProtocolSync(@HostParam("endpoint") String endpoint,
-            @HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body,
-            RequestOptions requestOptions, Context context);
+            @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept,
+            @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context);
 
         @Post("/protocolandconvenient/bothConvenientAndProtocol")
         @ExpectedResponses({ 200 })
@@ -134,8 +134,8 @@ Response onlyProtocolSync(@HostParam("endpoint") String endpoint,
         @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 })
         @UnexpectedResponseExceptionType(HttpResponseException.class)
         Mono> bothConvenientAndProtocol(@HostParam("endpoint") String endpoint,
-            @HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body,
-            RequestOptions requestOptions, Context context);
+            @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept,
+            @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context);
 
         @Post("/protocolandconvenient/bothConvenientAndProtocol")
         @ExpectedResponses({ 200 })
@@ -144,8 +144,8 @@ Mono> bothConvenientAndProtocol(@HostParam("endpoint") Stri
         @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 })
         @UnexpectedResponseExceptionType(HttpResponseException.class)
         Response bothConvenientAndProtocolSync(@HostParam("endpoint") String endpoint,
-            @HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body,
-            RequestOptions requestOptions, Context context);
+            @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept,
+            @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context);
 
         @Post("/protocolandconvenient/errorSetting")
         @ExpectedResponses({ 200 })
@@ -154,8 +154,8 @@ Response bothConvenientAndProtocolSync(@HostParam("endpoint") String
         @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 })
         @UnexpectedResponseExceptionType(HttpResponseException.class)
         Mono> errorSetting(@HostParam("endpoint") String endpoint,
-            @HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body,
-            RequestOptions requestOptions, Context context);
+            @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept,
+            @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context);
 
         @Post("/protocolandconvenient/errorSetting")
         @ExpectedResponses({ 200 })
@@ -164,8 +164,8 @@ Mono> errorSetting(@HostParam("endpoint") String endpoint,
         @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 })
         @UnexpectedResponseExceptionType(HttpResponseException.class)
         Response errorSettingSync(@HostParam("endpoint") String endpoint,
-            @HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body,
-            RequestOptions requestOptions, Context context);
+            @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 })
@@ -175,8 +175,8 @@ Response errorSettingSync(@HostParam("endpoint") String endpoint,
         @UnexpectedResponseExceptionType(HttpResponseException.class)
         Mono> createOrReplace(@HostParam("endpoint") String endpoint,
             @QueryParam("api-version") String apiVersion, @PathParam("name") String name,
-            @HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData resource,
-            RequestOptions requestOptions, Context context);
+            @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 })
@@ -186,8 +186,8 @@ Mono> createOrReplace(@HostParam("endpoint") String endpoin
         @UnexpectedResponseExceptionType(HttpResponseException.class)
         Response createOrReplaceSync(@HostParam("endpoint") String endpoint,
             @QueryParam("api-version") String apiVersion, @PathParam("name") String name,
-            @HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData resource,
-            RequestOptions requestOptions, Context context);
+            @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept,
+            @BodyParam("application/json") BinaryData resource, RequestOptions requestOptions, Context context);
 
         @Get("/protocolandconvenient/resources")
         @ExpectedResponses({ 200 })
@@ -196,7 +196,7 @@ Response createOrReplaceSync(@HostParam("endpoint") String endpoint,
         @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 })
         @UnexpectedResponseExceptionType(HttpResponseException.class)
         Mono> list(@HostParam("endpoint") String endpoint,
-            @QueryParam("api-version") String apiVersion, @HeaderParam("accept") String accept,
+            @QueryParam("api-version") String apiVersion, @HeaderParam("Accept") String accept,
             RequestOptions requestOptions, Context context);
 
         @Get("/protocolandconvenient/resources")
@@ -206,7 +206,7 @@ Mono> list(@HostParam("endpoint") String endpoint,
         @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 })
         @UnexpectedResponseExceptionType(HttpResponseException.class)
         Response listSync(@HostParam("endpoint") String endpoint,
-            @QueryParam("api-version") String apiVersion, @HeaderParam("accept") String accept,
+            @QueryParam("api-version") String apiVersion, @HeaderParam("Accept") String accept,
             RequestOptions requestOptions, Context context);
 
         @Get("{nextLink}")
@@ -216,7 +216,7 @@ Response listSync(@HostParam("endpoint") String endpoint,
         @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,
+            @HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, RequestOptions requestOptions,
             Context context);
 
         @Get("{nextLink}")
@@ -226,7 +226,7 @@ Mono> listNext(@PathParam(value = "nextLink", encoded = tru
         @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,
+            @HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, RequestOptions requestOptions,
             Context context);
     }
 
@@ -260,9 +260,10 @@ Response listNextSync(@PathParam(value = "nextLink", encoded = true)
      */
     @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(), accept, body, requestOptions, context));
+        return FluxUtil.withContext(context -> service.onlyConvenient(this.client.getEndpoint(), contentType, accept,
+            body, requestOptions, context));
     }
 
     /**
@@ -295,8 +296,10 @@ public Mono> onlyConvenientWithResponseAsync(BinaryData bod
      */
     @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(), accept, body, requestOptions, Context.NONE);
+        return service.onlyConvenientSync(this.client.getEndpoint(), contentType, accept, body, requestOptions,
+            Context.NONE);
     }
 
     /**
@@ -330,9 +333,10 @@ public Response onlyConvenientWithResponse(BinaryData body, RequestO
      */
     @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(), accept, body, requestOptions, context));
+        return FluxUtil.withContext(context -> service.onlyProtocol(this.client.getEndpoint(), contentType, accept,
+            body, requestOptions, context));
     }
 
     /**
@@ -366,8 +370,10 @@ public Mono> onlyProtocolWithResponseAsync(BinaryData body,
      */
     @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(), accept, body, requestOptions, Context.NONE);
+        return service.onlyProtocolSync(this.client.getEndpoint(), contentType, accept, body, requestOptions,
+            Context.NONE);
     }
 
     /**
@@ -401,9 +407,10 @@ public Response onlyProtocolWithResponse(BinaryData body, RequestOpt
     @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(), accept,
-            body, requestOptions, context));
+        return FluxUtil.withContext(context -> service.bothConvenientAndProtocol(this.client.getEndpoint(), contentType,
+            accept, body, requestOptions, context));
     }
 
     /**
@@ -436,9 +443,10 @@ public Mono> bothConvenientAndProtocolWithResponseAsync(Bin
      */
     @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(), accept, body, requestOptions,
-            Context.NONE);
+        return service.bothConvenientAndProtocolSync(this.client.getEndpoint(), contentType, accept, body,
+            requestOptions, Context.NONE);
     }
 
     /**
@@ -471,9 +479,10 @@ public Response bothConvenientAndProtocolWithResponse(BinaryData bod
      */
     @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(), accept, body, requestOptions, context));
+        return FluxUtil.withContext(context -> service.errorSetting(this.client.getEndpoint(), contentType, accept,
+            body, requestOptions, context));
     }
 
     /**
@@ -506,8 +515,10 @@ public Mono> errorSettingWithResponseAsync(BinaryData body,
      */
     @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(), accept, body, requestOptions, Context.NONE);
+        return service.errorSettingSync(this.client.getEndpoint(), contentType, accept, body, requestOptions,
+            Context.NONE);
     }
 
     /**
@@ -544,9 +555,11 @@ public Response errorSettingWithResponse(BinaryData body, RequestOpt
     @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, accept, resource, requestOptions, context));
+        return FluxUtil.withContext(
+            context -> service.createOrReplace(this.client.getEndpoint(), this.client.getServiceVersion().getVersion(),
+                name, contentType, accept, resource, requestOptions, context));
     }
 
     /**
@@ -583,9 +596,10 @@ private Mono> createOrReplaceWithResponseAsync(String name,
     @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, accept, resource, requestOptions, Context.NONE);
+            name, contentType, accept, resource, requestOptions, Context.NONE);
     }
 
     /**
@@ -955,6 +969,8 @@ public PagedIterable list(RequestOptions requestOptions) {
     }
 
     /**
+     * Paging operation
+     * 
      * Get the next page of items.
      * 

Response Body Schema

* @@ -986,6 +1002,8 @@ private Mono> listNextSinglePageAsync(String nextLink, } /** + * Paging operation + * * Get the next page of items. *

Response Body Schema

* diff --git a/typespec-tests/src/main/java/com/cadl/protocolandconvenient/implementation/ProtocolAndConvenientClientImpl.java b/typespec-tests/src/main/java/com/cadl/protocolandconvenient/implementation/ProtocolAndConvenientClientImpl.java index b11dcbcb44..8c75e79e39 100644 --- a/typespec-tests/src/main/java/com/cadl/protocolandconvenient/implementation/ProtocolAndConvenientClientImpl.java +++ b/typespec-tests/src/main/java/com/cadl/protocolandconvenient/implementation/ProtocolAndConvenientClientImpl.java @@ -17,12 +17,12 @@ */ public final class ProtocolAndConvenientClientImpl { /** - * Server parameter. + * Service host. */ private final String endpoint; /** - * Gets Server parameter. + * Gets Service host. * * @return the endpoint value. */ @@ -89,7 +89,7 @@ public ProtocolAndConvenienceOpsImpl getProtocolAndConvenienceOps() { /** * Initializes an instance of ProtocolAndConvenientClient client. * - * @param endpoint Server parameter. + * @param endpoint Service host. * @param serviceVersion Service version. */ public ProtocolAndConvenientClientImpl(String endpoint, ProtocolAndConvenientServiceVersion serviceVersion) { @@ -101,7 +101,7 @@ public ProtocolAndConvenientClientImpl(String endpoint, ProtocolAndConvenientSer * Initializes an instance of ProtocolAndConvenientClient client. * * @param httpPipeline The HTTP pipeline to send requests through. - * @param endpoint Server parameter. + * @param endpoint Service host. * @param serviceVersion Service version. */ public ProtocolAndConvenientClientImpl(HttpPipeline httpPipeline, String endpoint, @@ -114,7 +114,7 @@ public ProtocolAndConvenientClientImpl(HttpPipeline httpPipeline, String endpoin * * @param httpPipeline The HTTP pipeline to send requests through. * @param serializerAdapter The serializer to serialize an object into a string. - * @param endpoint Server parameter. + * @param endpoint Service host. * @param serviceVersion Service version. */ public ProtocolAndConvenientClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, diff --git a/typespec-tests/src/main/java/com/cadl/response/implementation/ResponseClientImpl.java b/typespec-tests/src/main/java/com/cadl/response/implementation/ResponseClientImpl.java index 570b2805b4..e9bd3194c3 100644 --- a/typespec-tests/src/main/java/com/cadl/response/implementation/ResponseClientImpl.java +++ b/typespec-tests/src/main/java/com/cadl/response/implementation/ResponseClientImpl.java @@ -64,12 +64,12 @@ public final class ResponseClientImpl { private final ResponseClientService service; /** - * Server parameter. + * Service host. */ private final String endpoint; /** - * Gets Server parameter. + * Gets Service host. * * @return the endpoint value. */ @@ -122,7 +122,7 @@ public SerializerAdapter getSerializerAdapter() { /** * Initializes an instance of ResponseClient client. * - * @param endpoint Server parameter. + * @param endpoint Service host. * @param serviceVersion Service version. */ public ResponseClientImpl(String endpoint, ResponseServiceVersion serviceVersion) { @@ -134,7 +134,7 @@ public ResponseClientImpl(String endpoint, ResponseServiceVersion serviceVersion * Initializes an instance of ResponseClient client. * * @param httpPipeline The HTTP pipeline to send requests through. - * @param endpoint Server parameter. + * @param endpoint Service host. * @param serviceVersion Service version. */ public ResponseClientImpl(HttpPipeline httpPipeline, String endpoint, ResponseServiceVersion serviceVersion) { @@ -146,7 +146,7 @@ public ResponseClientImpl(HttpPipeline httpPipeline, String endpoint, ResponseSe * * @param httpPipeline The HTTP pipeline to send requests through. * @param serializerAdapter The serializer to serialize an object into a string. - * @param endpoint Server parameter. + * @param endpoint Service host. * @param serviceVersion Service version. */ public ResponseClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, String endpoint, @@ -171,7 +171,7 @@ public interface ResponseClientService { @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Mono> getBinary(@HostParam("endpoint") String endpoint, - @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Get("/response/get-binary") @ExpectedResponses({ 200 }) @@ -179,7 +179,7 @@ Mono> getBinary(@HostParam("endpoint") String endpoint, @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, + Response getBinarySync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Get("/response/get-array") @@ -189,7 +189,7 @@ Response getBinarySync(@HostParam("endpoint") String endpoint, @Head @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Mono> getArray(@HostParam("endpoint") String endpoint, - @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Get("/response/get-array") @ExpectedResponses({ 200 }) @@ -197,7 +197,7 @@ Mono> getArray(@HostParam("endpoint") String endpoint, @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, + Response getArraySync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Get("/response/get-another-array") @@ -207,7 +207,7 @@ Response getArraySync(@HostParam("endpoint") String endpoint, @Heade @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Mono> getAnotherArray(@HostParam("endpoint") String endpoint, - @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Get("/response/get-another-array") @ExpectedResponses({ 200 }) @@ -216,7 +216,7 @@ Mono> getAnotherArray(@HostParam("endpoint") String endpoin @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Response getAnotherArraySync(@HostParam("endpoint") String endpoint, - @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Put("/response/create-with-headers") @ExpectedResponses({ 201 }) @@ -225,7 +225,7 @@ Response getAnotherArraySync(@HostParam("endpoint") String endpoint, @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Mono> createWithHeaders(@HostParam("endpoint") String endpoint, - @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Put("/response/create-with-headers") @ExpectedResponses({ 201 }) @@ -234,7 +234,7 @@ Mono> createWithHeaders(@HostParam("endpoint") String endpo @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Response createWithHeadersSync(@HostParam("endpoint") String endpoint, - @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Delete("/response/delete-with-headers") @ExpectedResponses({ 204 }) @@ -242,8 +242,8 @@ Response createWithHeadersSync(@HostParam("endpoint") String endpoin @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> deleteWithHeaders(@HostParam("endpoint") String endpoint, - @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + Mono> deleteWithHeaders(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, + Context context); @Delete("/response/delete-with-headers") @ExpectedResponses({ 204 }) @@ -251,8 +251,8 @@ Mono> deleteWithHeaders(@HostParam("endpoint") String endpoint, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response deleteWithHeadersSync(@HostParam("endpoint") String endpoint, - @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + Response deleteWithHeadersSync(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, + Context context); @Head("/response/exists") @ExpectedResponses({ 200, 404 }) @@ -260,7 +260,7 @@ Response deleteWithHeadersSync(@HostParam("endpoint") String endpoint, @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Mono> exists(@HostParam("endpoint") String endpoint, - @QueryParam("api-version") String apiVersion, @HeaderParam("accept") String accept, + @QueryParam("api-version") String apiVersion, @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Head("/response/exists") @@ -269,7 +269,7 @@ Mono> exists(@HostParam("endpoint") String endpoint, @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Response existsSync(@HostParam("endpoint") String endpoint, - @QueryParam("api-version") String apiVersion, @HeaderParam("accept") String accept, + @QueryParam("api-version") String apiVersion, @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Post("/response/lro-invalid-poll-response") @@ -279,8 +279,9 @@ Response existsSync(@HostParam("endpoint") String endpoint, @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Mono> lroInvalidPollResponse(@HostParam("endpoint") String endpoint, - @QueryParam("api-version") String apiVersion, @HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData request, RequestOptions requestOptions, Context context); + @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 }) @@ -289,8 +290,9 @@ Mono> lroInvalidPollResponse(@HostParam("endpoint") String endpoi @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Response lroInvalidPollResponseSync(@HostParam("endpoint") String endpoint, - @QueryParam("api-version") String apiVersion, @HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData request, RequestOptions requestOptions, Context context); + @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 }) @@ -299,8 +301,9 @@ Response lroInvalidPollResponseSync(@HostParam("endpoint") String endpoint @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Mono> lroInvalidResult(@HostParam("endpoint") String endpoint, - @QueryParam("api-version") String apiVersion, @HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData request, RequestOptions requestOptions, Context context); + @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 }) @@ -309,8 +312,9 @@ Mono> lroInvalidResult(@HostParam("endpoint") String endpoint, @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Response lroInvalidResultSync(@HostParam("endpoint") String endpoint, - @QueryParam("api-version") String apiVersion, @HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData request, RequestOptions requestOptions, Context context); + @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 }) @@ -319,7 +323,7 @@ Response lroInvalidResultSync(@HostParam("endpoint") String endpoint, @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Mono> listStrings(@HostParam("endpoint") String endpoint, - @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Get("/response/paged-string") @ExpectedResponses({ 200 }) @@ -328,7 +332,7 @@ Mono> listStrings(@HostParam("endpoint") String endpoint, @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Response listStringsSync(@HostParam("endpoint") String endpoint, - @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Get("/response/paged-int32") @ExpectedResponses({ 200 }) @@ -337,7 +341,7 @@ Response listStringsSync(@HostParam("endpoint") String endpoint, @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Mono> listIntegers(@HostParam("endpoint") String endpoint, - @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Get("/response/paged-int32") @ExpectedResponses({ 200 }) @@ -346,7 +350,7 @@ Mono> listIntegers(@HostParam("endpoint") String endpoint, @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Response listIntegersSync(@HostParam("endpoint") String endpoint, - @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Get("/response/json-utf8-response") @ExpectedResponses({ 200 }) @@ -355,7 +359,7 @@ Response listIntegersSync(@HostParam("endpoint") String endpoint, @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Mono> getJsonUtf8Response(@HostParam("endpoint") String endpoint, - @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Get("/response/json-utf8-response") @ExpectedResponses({ 200 }) @@ -364,7 +368,7 @@ Mono> getJsonUtf8Response(@HostParam("endpoint") String end @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Response getJsonUtf8ResponseSync(@HostParam("endpoint") String endpoint, - @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Get("/response/plus-json-response") @ExpectedResponses({ 200 }) @@ -373,7 +377,7 @@ Response getJsonUtf8ResponseSync(@HostParam("endpoint") String endpo @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Mono> getPlusJsonResponse(@HostParam("endpoint") String endpoint, - @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Get("/response/plus-json-response") @ExpectedResponses({ 200 }) @@ -382,7 +386,7 @@ Mono> getPlusJsonResponse(@HostParam("endpoint") String end @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Response getPlusJsonResponseSync(@HostParam("endpoint") String endpoint, - @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Get("{nextLink}") @ExpectedResponses({ 200 }) @@ -391,7 +395,7 @@ Response getPlusJsonResponseSync(@HostParam("endpoint") String endpo @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, + @HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Get("{nextLink}") @@ -401,7 +405,7 @@ Mono> listStringsNext(@PathParam(value = "nextLink", encode @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, + @HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Get("{nextLink}") @@ -411,7 +415,7 @@ Response listStringsNextSync(@PathParam(value = "nextLink", encoded @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, + @HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Get("{nextLink}") @@ -421,7 +425,7 @@ Mono> listIntegersNext(@PathParam(value = "nextLink", encod @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, + @HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); } @@ -645,9 +649,7 @@ public Response createWithHeadersWithResponse(RequestOptions request */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> deleteWithHeadersWithResponseAsync(RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil - .withContext(context -> service.deleteWithHeaders(this.getEndpoint(), accept, requestOptions, context)); + return FluxUtil.withContext(context -> service.deleteWithHeaders(this.getEndpoint(), requestOptions, context)); } /** @@ -662,8 +664,7 @@ public Mono> deleteWithHeadersWithResponseAsync(RequestOptions re */ @ServiceMethod(returns = ReturnType.SINGLE) public Response deleteWithHeadersWithResponse(RequestOptions requestOptions) { - final String accept = "application/json"; - return service.deleteWithHeadersSync(this.getEndpoint(), accept, requestOptions, Context.NONE); + return service.deleteWithHeadersSync(this.getEndpoint(), requestOptions, Context.NONE); } /** @@ -732,9 +733,10 @@ public Response existsWithResponse(RequestOptions requestOptions) { @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(), accept, request, requestOptions, context)); + this.getServiceVersion().getVersion(), contentType, accept, request, requestOptions, context)); } /** @@ -760,9 +762,10 @@ private Mono> lroInvalidPollResponseWithResponseAsync(BinaryData */ @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(), accept, - request, requestOptions, Context.NONE); + return service.lroInvalidPollResponseSync(this.getEndpoint(), this.getServiceVersion().getVersion(), + contentType, accept, request, requestOptions, Context.NONE); } /** @@ -936,9 +939,10 @@ public SyncPoller beginLroInvalidPollResponseWithMo */ @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(), accept, request, requestOptions, context)); + this.getServiceVersion().getVersion(), contentType, accept, request, requestOptions, context)); } /** @@ -964,9 +968,10 @@ private Mono> lroInvalidResultWithResponseAsync(BinaryData reques */ @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(), accept, request, - requestOptions, Context.NONE); + return service.lroInvalidResultSync(this.getEndpoint(), this.getServiceVersion().getVersion(), contentType, + accept, request, requestOptions, Context.NONE); } /** diff --git a/typespec-tests/src/main/java/com/cadl/server/HttpbinClientBuilder.java b/typespec-tests/src/main/java/com/cadl/server/HttpbinClientBuilder.java index dadfb38252..dae54e3b35 100644 --- a/typespec-tests/src/main/java/com/cadl/server/HttpbinClientBuilder.java +++ b/typespec-tests/src/main/java/com/cadl/server/HttpbinClientBuilder.java @@ -253,8 +253,10 @@ public HttpbinClientBuilder retryPolicy(RetryPolicy retryPolicy) { 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(), - this.domain, this.tld, this.relativePath); + localDomain, localTld, this.relativePath); return client; } @@ -262,8 +264,7 @@ private HttpbinClientImpl buildInnerClient() { 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(domain, "'domain' cannot be null."); - Objects.requireNonNull(tld, "'tld' cannot be null."); + Objects.requireNonNull(relativePath, "'relativePath' cannot be null."); } @Generated diff --git a/typespec-tests/src/main/java/com/cadl/server/implementation/ContosoClientImpl.java b/typespec-tests/src/main/java/com/cadl/server/implementation/ContosoClientImpl.java index ef7a6aa8f1..10740ce1d6 100644 --- a/typespec-tests/src/main/java/com/cadl/server/implementation/ContosoClientImpl.java +++ b/typespec-tests/src/main/java/com/cadl/server/implementation/ContosoClientImpl.java @@ -6,7 +6,6 @@ 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; @@ -149,8 +148,7 @@ public interface ContosoClientService { @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, @HeaderParam("accept") String accept, - RequestOptions requestOptions, Context context); + @PathParam(value = "group", encoded = true) String group, RequestOptions requestOptions, Context context); @Get("/contoso/{group}") @ExpectedResponses({ 200, 204 }) @@ -159,8 +157,7 @@ Mono> get(@HostParam("Endpoint") String endpoint, @HostParam("Api @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, @HeaderParam("accept") String accept, - RequestOptions requestOptions, Context context); + @PathParam(value = "group", encoded = true) String group, RequestOptions requestOptions, Context context); } /** @@ -176,9 +173,8 @@ Response getSync(@HostParam("Endpoint") String endpoint, @HostParam("ApiVe */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getWithResponseAsync(String group, RequestOptions requestOptions) { - final String accept = "application/json"; return FluxUtil.withContext(context -> service.get(this.getEndpoint(), this.getServiceVersion().getVersion(), - group, accept, requestOptions, context)); + group, requestOptions, context)); } /** @@ -194,8 +190,7 @@ public Mono> getWithResponseAsync(String group, RequestOptions re */ @ServiceMethod(returns = ReturnType.SINGLE) public Response getWithResponse(String group, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.getSync(this.getEndpoint(), this.getServiceVersion().getVersion(), group, accept, requestOptions, + return service.getSync(this.getEndpoint(), this.getServiceVersion().getVersion(), group, requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/cadl/server/implementation/HttpbinClientImpl.java b/typespec-tests/src/main/java/com/cadl/server/implementation/HttpbinClientImpl.java index 95fc0c5668..20c3a71dc2 100644 --- a/typespec-tests/src/main/java/com/cadl/server/implementation/HttpbinClientImpl.java +++ b/typespec-tests/src/main/java/com/cadl/server/implementation/HttpbinClientImpl.java @@ -6,7 +6,6 @@ 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; @@ -166,8 +165,8 @@ public interface HttpbinClientService { @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, - @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + @HostParam("relative-path") String relativePath, @PathParam("code") int code, RequestOptions requestOptions, + Context context); @Get("/status/{code}") @ExpectedResponses({ 200, 204 }) @@ -176,8 +175,8 @@ Mono> status(@HostParam("domain") String domain, @HostParam("tld" @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, - @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + @HostParam("relative-path") String relativePath, @PathParam("code") int code, RequestOptions requestOptions, + Context context); } /** @@ -193,9 +192,8 @@ Response statusSync(@HostParam("domain") String domain, @HostParam("tld") */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> statusWithResponseAsync(int code, RequestOptions requestOptions) { - final String accept = "application/json"; return FluxUtil.withContext(context -> service.status(this.getDomain(), this.getTld(), this.getRelativePath(), - code, accept, requestOptions, context)); + code, requestOptions, context)); } /** @@ -211,8 +209,7 @@ public Mono> statusWithResponseAsync(int code, RequestOptions req */ @ServiceMethod(returns = ReturnType.SINGLE) public Response statusWithResponse(int code, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.statusSync(this.getDomain(), this.getTld(), this.getRelativePath(), code, accept, requestOptions, + return service.statusSync(this.getDomain(), this.getTld(), this.getRelativePath(), code, requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/cadl/specialchars/implementation/BuiltinOpsImpl.java b/typespec-tests/src/main/java/com/cadl/specialchars/implementation/BuiltinOpsImpl.java index 5392d88b0a..95933ed802 100644 --- a/typespec-tests/src/main/java/com/cadl/specialchars/implementation/BuiltinOpsImpl.java +++ b/typespec-tests/src/main/java/com/cadl/specialchars/implementation/BuiltinOpsImpl.java @@ -64,7 +64,8 @@ public interface BuiltinOpsService { @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, + 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") @@ -73,7 +74,8 @@ Mono> read(@HostParam("endpoint") String endpoint, @HeaderP @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, + Response readSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, @BodyParam("application/json") BinaryData readRequest, RequestOptions requestOptions, Context context); } @@ -109,9 +111,10 @@ Response readSync(@HostParam("endpoint") String endpoint, @HeaderPar */ @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(), accept, readRequest, requestOptions, context)); + return FluxUtil.withContext(context -> service.read(this.client.getEndpoint(), contentType, accept, readRequest, + requestOptions, context)); } /** @@ -146,7 +149,9 @@ public Mono> readWithResponseAsync(BinaryData readRequest, */ @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(), accept, readRequest, requestOptions, Context.NONE); + return service.readSync(this.client.getEndpoint(), contentType, accept, readRequest, requestOptions, + Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/cadl/specialchars/implementation/SpecialCharsClientImpl.java b/typespec-tests/src/main/java/com/cadl/specialchars/implementation/SpecialCharsClientImpl.java index 156eeb1699..a451aefaac 100644 --- a/typespec-tests/src/main/java/com/cadl/specialchars/implementation/SpecialCharsClientImpl.java +++ b/typespec-tests/src/main/java/com/cadl/specialchars/implementation/SpecialCharsClientImpl.java @@ -16,12 +16,12 @@ */ public final class SpecialCharsClientImpl { /** - * Server parameter. + * Service host. */ private final String endpoint; /** - * Gets Server parameter. + * Gets Service host. * * @return the endpoint value. */ @@ -74,7 +74,7 @@ public BuiltinOpsImpl getBuiltinOps() { /** * Initializes an instance of SpecialCharsClient client. * - * @param endpoint Server parameter. + * @param endpoint Service host. */ public SpecialCharsClientImpl(String endpoint) { this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), @@ -85,7 +85,7 @@ public SpecialCharsClientImpl(String endpoint) { * Initializes an instance of SpecialCharsClient client. * * @param httpPipeline The HTTP pipeline to send requests through. - * @param endpoint Server parameter. + * @param endpoint Service host. */ public SpecialCharsClientImpl(HttpPipeline httpPipeline, String endpoint) { this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint); @@ -96,7 +96,7 @@ public SpecialCharsClientImpl(HttpPipeline httpPipeline, String endpoint) { * * @param httpPipeline The HTTP pipeline to send requests through. * @param serializerAdapter The serializer to serialize an object into a string. - * @param endpoint Server parameter. + * @param endpoint Service host. */ public SpecialCharsClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, String endpoint) { this.httpPipeline = httpPipeline; diff --git a/typespec-tests/src/main/java/com/cadl/specialheaders/implementation/EtagHeadersImpl.java b/typespec-tests/src/main/java/com/cadl/specialheaders/implementation/EtagHeadersImpl.java index c3b31aafc6..18b60b8531 100644 --- a/typespec-tests/src/main/java/com/cadl/specialheaders/implementation/EtagHeadersImpl.java +++ b/typespec-tests/src/main/java/com/cadl/specialheaders/implementation/EtagHeadersImpl.java @@ -87,8 +87,8 @@ public interface EtagHeadersService { @UnexpectedResponseExceptionType(HttpResponseException.class) Mono> putWithRequestHeaders(@HostParam("endpoint") String endpoint, @QueryParam("api-version") String apiVersion, @PathParam("name") String name, - @HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData resource, - RequestOptions requestOptions, Context context); + @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 }) @@ -98,8 +98,8 @@ Mono> putWithRequestHeaders(@HostParam("endpoint") String e @UnexpectedResponseExceptionType(HttpResponseException.class) Response putWithRequestHeadersSync(@HostParam("endpoint") String endpoint, @QueryParam("api-version") String apiVersion, @PathParam("name") String name, - @HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData resource, - RequestOptions requestOptions, Context context); + @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 }) @@ -109,7 +109,7 @@ Response putWithRequestHeadersSync(@HostParam("endpoint") String end @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, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, @BodyParam("application/merge-patch+json") BinaryData resource, RequestOptions requestOptions, Context context); @@ -121,7 +121,7 @@ Mono> patchWithMatchHeaders(@HostParam("endpoint") String e @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, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, @BodyParam("application/merge-patch+json") BinaryData resource, RequestOptions requestOptions, Context context); @@ -132,7 +132,7 @@ Response patchWithMatchHeadersSync(@HostParam("endpoint") String end @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Mono> listWithEtag(@HostParam("endpoint") String endpoint, - @QueryParam("api-version") String apiVersion, @HeaderParam("accept") String accept, + @QueryParam("api-version") String apiVersion, @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Get("/etag-headers/resources") @@ -142,7 +142,7 @@ Mono> listWithEtag(@HostParam("endpoint") String endpoint, @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Response listWithEtagSync(@HostParam("endpoint") String endpoint, - @QueryParam("api-version") String apiVersion, @HeaderParam("accept") String accept, + @QueryParam("api-version") String apiVersion, @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Get("{nextLink}") @@ -152,7 +152,7 @@ Response listWithEtagSync(@HostParam("endpoint") String endpoint, @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, + @HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Get("{nextLink}") @@ -162,7 +162,7 @@ Mono> listWithEtagNext(@PathParam(value = "nextLink", encod @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, + @HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); } @@ -216,9 +216,11 @@ Response listWithEtagNextSync(@PathParam(value = "nextLink", encoded @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, accept, resource, requestOptions, context)); + this.client.getServiceVersion().getVersion(), name, contentType, accept, resource, requestOptions, + context)); } /** @@ -271,9 +273,11 @@ public Mono> putWithRequestHeadersWithResponseAsync(String @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, accept, resource, requestOptions, Context.NONE); + this.client.getServiceVersion().getVersion(), name, contentType, accept, resource, requestOptions, + Context.NONE); } /** @@ -501,6 +505,8 @@ public PagedIterable listWithEtag(RequestOptions requestOptions) { } /** + * Resource list operation template. + * * Get the next page of items. *

Response Body Schema

* @@ -533,6 +539,8 @@ private Mono> listWithEtagNextSinglePageAsync(String n } /** + * Resource list operation template. + * * Get the next page of items. *

Response Body Schema

* diff --git a/typespec-tests/src/main/java/com/cadl/specialheaders/implementation/EtagHeadersOptionalBodiesImpl.java b/typespec-tests/src/main/java/com/cadl/specialheaders/implementation/EtagHeadersOptionalBodiesImpl.java index eb05187da8..ec32792dc2 100644 --- a/typespec-tests/src/main/java/com/cadl/specialheaders/implementation/EtagHeadersOptionalBodiesImpl.java +++ b/typespec-tests/src/main/java/com/cadl/specialheaders/implementation/EtagHeadersOptionalBodiesImpl.java @@ -76,7 +76,7 @@ public interface EtagHeadersOptionalBodiesService { @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, + @QueryParam("format") String format, @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Put("/etag-headers-optional-body") @@ -86,7 +86,7 @@ Mono> putWithOptionalBody(@HostParam("endpoint") String end @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, + @QueryParam("format") String format, @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); } diff --git a/typespec-tests/src/main/java/com/cadl/specialheaders/implementation/RepeatabilityHeadersImpl.java b/typespec-tests/src/main/java/com/cadl/specialheaders/implementation/RepeatabilityHeadersImpl.java index 5af6d742a1..b45fdf9a70 100644 --- a/typespec-tests/src/main/java/com/cadl/specialheaders/implementation/RepeatabilityHeadersImpl.java +++ b/typespec-tests/src/main/java/com/cadl/specialheaders/implementation/RepeatabilityHeadersImpl.java @@ -92,7 +92,7 @@ public interface RepeatabilityHeadersService { @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); + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Get("/repeatability-headers/resources/{name}") @ExpectedResponses({ 200 }) @@ -102,7 +102,7 @@ Mono> get(@HostParam("endpoint") String endpoint, @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); + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Put("/repeatability-headers/resources/{name}") @ExpectedResponses({ 200, 201 }) @@ -112,8 +112,8 @@ Response getSync(@HostParam("endpoint") String endpoint, @UnexpectedResponseExceptionType(HttpResponseException.class) Mono> put(@HostParam("endpoint") String endpoint, @QueryParam("api-version") String apiVersion, @PathParam("name") String name, - @HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData resource, - RequestOptions requestOptions, Context context); + @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 }) @@ -123,8 +123,8 @@ Mono> put(@HostParam("endpoint") String endpoint, @UnexpectedResponseExceptionType(HttpResponseException.class) Response putSync(@HostParam("endpoint") String endpoint, @QueryParam("api-version") String apiVersion, @PathParam("name") String name, - @HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData resource, - RequestOptions requestOptions, Context context); + @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 }) @@ -134,7 +134,7 @@ Response putSync(@HostParam("endpoint") String endpoint, @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); + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Post("/repeatability-headers/resources/{name}:post") @ExpectedResponses({ 200 }) @@ -144,7 +144,7 @@ Mono> post(@HostParam("endpoint") String endpoint, @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); + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Patch("/repeatability-headers/resources/{name}") @ExpectedResponses({ 200, 201 }) @@ -154,7 +154,7 @@ Response postSync(@HostParam("endpoint") String endpoint, @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, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, @BodyParam("application/merge-patch+json") BinaryData resource, RequestOptions requestOptions, Context context); @@ -166,7 +166,7 @@ Mono> createLro(@HostParam("endpoint") String endpoint, @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, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, @BodyParam("application/merge-patch+json") BinaryData resource, RequestOptions requestOptions, Context context); } @@ -272,6 +272,7 @@ public Response getWithResponse(String name, RequestOptions requestO @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 -> { @@ -287,8 +288,9 @@ public Mono> putWithResponseAsync(String name, BinaryData r DateTimeRfc1123.toRfc1123String(OffsetDateTime.now())); } }); - return FluxUtil.withContext(context -> service.put(this.client.getEndpoint(), - this.client.getServiceVersion().getVersion(), name, accept, resource, requestOptionsLocal, context)); + return FluxUtil + .withContext(context -> service.put(this.client.getEndpoint(), this.client.getServiceVersion().getVersion(), + name, contentType, accept, resource, requestOptionsLocal, context)); } /** @@ -335,6 +337,7 @@ public Mono> putWithResponseAsync(String name, BinaryData r */ @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 -> { @@ -350,8 +353,8 @@ public Response putWithResponse(String name, BinaryData resource, Re DateTimeRfc1123.toRfc1123String(OffsetDateTime.now())); } }); - return service.putSync(this.client.getEndpoint(), this.client.getServiceVersion().getVersion(), name, accept, - resource, requestOptionsLocal, Context.NONE); + return service.putSync(this.client.getEndpoint(), this.client.getServiceVersion().getVersion(), name, + contentType, accept, resource, requestOptionsLocal, Context.NONE); } /** diff --git a/typespec-tests/src/main/java/com/cadl/specialheaders/implementation/SkipSpecialHeadersImpl.java b/typespec-tests/src/main/java/com/cadl/specialheaders/implementation/SkipSpecialHeadersImpl.java index fe882ab8ec..0903fb3eeb 100644 --- a/typespec-tests/src/main/java/com/cadl/specialheaders/implementation/SkipSpecialHeadersImpl.java +++ b/typespec-tests/src/main/java/com/cadl/specialheaders/implementation/SkipSpecialHeadersImpl.java @@ -76,7 +76,7 @@ public interface SkipSpecialHeadersService { @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, + @HeaderParam("foo") String foo, @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Delete("/skip-special-headers/resources/{name}") @@ -87,7 +87,7 @@ Mono> deleteWithSpecialHeaders(@HostParam("endpoint") String endp @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, + @HeaderParam("foo") String foo, @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); } diff --git a/typespec-tests/src/main/java/com/cadl/specialheaders/implementation/SpecialHeadersClientImpl.java b/typespec-tests/src/main/java/com/cadl/specialheaders/implementation/SpecialHeadersClientImpl.java index 55e36167c3..fd88cb4588 100644 --- a/typespec-tests/src/main/java/com/cadl/specialheaders/implementation/SpecialHeadersClientImpl.java +++ b/typespec-tests/src/main/java/com/cadl/specialheaders/implementation/SpecialHeadersClientImpl.java @@ -17,12 +17,12 @@ */ public final class SpecialHeadersClientImpl { /** - * Server parameter. + * Service host. */ private final String endpoint; /** - * Gets Server parameter. + * Gets Service host. * * @return the endpoint value. */ @@ -131,7 +131,7 @@ public SkipSpecialHeadersImpl getSkipSpecialHeaders() { /** * Initializes an instance of SpecialHeadersClient client. * - * @param endpoint Server parameter. + * @param endpoint Service host. * @param serviceVersion Service version. */ public SpecialHeadersClientImpl(String endpoint, SpecialHeadersServiceVersion serviceVersion) { @@ -143,7 +143,7 @@ public SpecialHeadersClientImpl(String endpoint, SpecialHeadersServiceVersion se * Initializes an instance of SpecialHeadersClient client. * * @param httpPipeline The HTTP pipeline to send requests through. - * @param endpoint Server parameter. + * @param endpoint Service host. * @param serviceVersion Service version. */ public SpecialHeadersClientImpl(HttpPipeline httpPipeline, String endpoint, @@ -156,7 +156,7 @@ public SpecialHeadersClientImpl(HttpPipeline httpPipeline, String endpoint, * * @param httpPipeline The HTTP pipeline to send requests through. * @param serializerAdapter The serializer to serialize an object into a string. - * @param endpoint Server parameter. + * @param endpoint Service host. * @param serviceVersion Service version. */ public SpecialHeadersClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, String endpoint, diff --git a/typespec-tests/src/main/java/com/cadl/union/implementation/UnionFlattenOpsImpl.java b/typespec-tests/src/main/java/com/cadl/union/implementation/UnionFlattenOpsImpl.java index dfd7cce30e..9a7ee5cd53 100644 --- a/typespec-tests/src/main/java/com/cadl/union/implementation/UnionFlattenOpsImpl.java +++ b/typespec-tests/src/main/java/com/cadl/union/implementation/UnionFlattenOpsImpl.java @@ -84,7 +84,7 @@ public interface UnionFlattenOpsService { @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("accept") String accept, + @QueryParam("api-version") String apiVersion, @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData sendRequest, RequestOptions requestOptions, Context context); @Post("/union/send") @@ -94,7 +94,7 @@ Mono> send(@HostParam("endpoint") String endpoint, @QueryParam("i @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("accept") String accept, + @QueryParam("api-version") String apiVersion, @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData sendRequest, RequestOptions requestOptions, Context context); @Post("/union/send-long") @@ -104,7 +104,7 @@ Response sendSync(@HostParam("endpoint") String endpoint, @QueryParam("id" @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("accept") String accept, + @QueryParam("api-version") String apiVersion, @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData sendLongRequest, RequestOptions requestOptions, Context context); @Post("/union/send-long") @@ -114,7 +114,7 @@ Mono> sendLong(@HostParam("endpoint") String endpoint, @QueryPara @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("accept") String accept, + @QueryParam("api-version") String apiVersion, @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData sendLongRequest, RequestOptions requestOptions, Context context); @Get("/union/param") @@ -123,8 +123,8 @@ Response sendLongSync(@HostParam("endpoint") String endpoint, @QueryParam( @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); + Mono> get(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, + Context context); @Get("/union/param") @ExpectedResponses({ 200 }) @@ -132,8 +132,7 @@ Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("a @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); + Response getSync(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, Context context); @Post("/union/generate") @ExpectedResponses({ 202 }) @@ -142,7 +141,7 @@ Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("acc @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Mono> generate(@HostParam("endpoint") String endpoint, - @QueryParam("api-version") String apiVersion, @HeaderParam("accept") String accept, + @QueryParam("api-version") String apiVersion, @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Post("/union/generate") @@ -152,7 +151,7 @@ Mono> generate(@HostParam("endpoint") String endpoint, @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Response generateSync(@HostParam("endpoint") String endpoint, - @QueryParam("api-version") String apiVersion, @HeaderParam("accept") String accept, + @QueryParam("api-version") String apiVersion, @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); } @@ -181,9 +180,9 @@ Response generateSync(@HostParam("endpoint") String endpoint, @ServiceMethod(returns = ReturnType.SINGLE) public Mono> sendWithResponseAsync(String id, BinaryData sendRequest, RequestOptions requestOptions) { - final String accept = "application/json"; + final String contentType = "application/json"; return FluxUtil.withContext(context -> service.send(this.client.getEndpoint(), id, - this.client.getServiceVersion().getVersion(), accept, sendRequest, requestOptions, context)); + this.client.getServiceVersion().getVersion(), contentType, sendRequest, requestOptions, context)); } /** @@ -210,9 +209,9 @@ public Mono> sendWithResponseAsync(String id, BinaryData sendRequ */ @ServiceMethod(returns = ReturnType.SINGLE) public Response sendWithResponse(String id, BinaryData sendRequest, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.sendSync(this.client.getEndpoint(), id, this.client.getServiceVersion().getVersion(), accept, - sendRequest, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.sendSync(this.client.getEndpoint(), id, this.client.getServiceVersion().getVersion(), + contentType, sendRequest, requestOptions, Context.NONE); } /** @@ -251,9 +250,9 @@ public Response sendWithResponse(String id, BinaryData sendRequest, Reques @ServiceMethod(returns = ReturnType.SINGLE) public Mono> sendLongWithResponseAsync(String id, BinaryData sendLongRequest, RequestOptions requestOptions) { - final String accept = "application/json"; + final String contentType = "application/json"; return FluxUtil.withContext(context -> service.sendLong(this.client.getEndpoint(), id, - this.client.getServiceVersion().getVersion(), accept, sendLongRequest, requestOptions, context)); + this.client.getServiceVersion().getVersion(), contentType, sendLongRequest, requestOptions, context)); } /** @@ -291,9 +290,9 @@ public Mono> sendLongWithResponseAsync(String id, BinaryData send */ @ServiceMethod(returns = ReturnType.SINGLE) public Response sendLongWithResponse(String id, BinaryData sendLongRequest, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.sendLongSync(this.client.getEndpoint(), id, this.client.getServiceVersion().getVersion(), accept, - sendLongRequest, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.sendLongSync(this.client.getEndpoint(), id, this.client.getServiceVersion().getVersion(), + contentType, sendLongRequest, requestOptions, Context.NONE); } /** @@ -315,8 +314,7 @@ public Response sendLongWithResponse(String id, BinaryData sendLongRequest */ @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)); + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), requestOptions, context)); } /** @@ -338,8 +336,7 @@ public Mono> getWithResponseAsync(RequestOptions requestOptions) */ @ServiceMethod(returns = ReturnType.SINGLE) public Response getWithResponse(RequestOptions requestOptions) { - final String accept = "application/json"; - return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); + return service.getSync(this.client.getEndpoint(), requestOptions, Context.NONE); } /** diff --git a/typespec-tests/src/main/java/com/cadl/versioning/implementation/VersioningClientImpl.java b/typespec-tests/src/main/java/com/cadl/versioning/implementation/VersioningClientImpl.java index 52829b6d51..b64dbb93fa 100644 --- a/typespec-tests/src/main/java/com/cadl/versioning/implementation/VersioningClientImpl.java +++ b/typespec-tests/src/main/java/com/cadl/versioning/implementation/VersioningClientImpl.java @@ -17,12 +17,12 @@ */ public final class VersioningClientImpl { /** - * Server parameter. + * Service host. */ private final String endpoint; /** - * Gets Server parameter. + * Gets Service host. * * @return the endpoint value. */ @@ -89,7 +89,7 @@ public VersioningOpsImpl getVersioningOps() { /** * Initializes an instance of VersioningClient client. * - * @param endpoint Server parameter. + * @param endpoint Service host. * @param serviceVersion Service version. */ public VersioningClientImpl(String endpoint, VersioningServiceVersion serviceVersion) { @@ -101,7 +101,7 @@ public VersioningClientImpl(String endpoint, VersioningServiceVersion serviceVer * Initializes an instance of VersioningClient client. * * @param httpPipeline The HTTP pipeline to send requests through. - * @param endpoint Server parameter. + * @param endpoint Service host. * @param serviceVersion Service version. */ public VersioningClientImpl(HttpPipeline httpPipeline, String endpoint, VersioningServiceVersion serviceVersion) { @@ -113,7 +113,7 @@ public VersioningClientImpl(HttpPipeline httpPipeline, String endpoint, Versioni * * @param httpPipeline The HTTP pipeline to send requests through. * @param serializerAdapter The serializer to serialize an object into a string. - * @param endpoint Server parameter. + * @param endpoint Service host. * @param serviceVersion Service version. */ public VersioningClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, String endpoint, diff --git a/typespec-tests/src/main/java/com/cadl/versioning/implementation/VersioningOpsImpl.java b/typespec-tests/src/main/java/com/cadl/versioning/implementation/VersioningOpsImpl.java index dda7074b57..e32901663d 100644 --- a/typespec-tests/src/main/java/com/cadl/versioning/implementation/VersioningOpsImpl.java +++ b/typespec-tests/src/main/java/com/cadl/versioning/implementation/VersioningOpsImpl.java @@ -95,7 +95,7 @@ public interface VersioningOpsService { @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); + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Post("/versioning/resources/{name}:export") @ExpectedResponses({ 202 }) @@ -105,7 +105,7 @@ Mono> export(@HostParam("endpoint") String endpoint, @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); + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Get("/versioning/resources") @ExpectedResponses({ 200 }) @@ -114,7 +114,7 @@ Response exportSync(@HostParam("endpoint") String endpoint, @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Mono> list(@HostParam("endpoint") String endpoint, - @QueryParam("api-version") String apiVersion, @HeaderParam("accept") String accept, + @QueryParam("api-version") String apiVersion, @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Get("/versioning/resources") @@ -124,7 +124,7 @@ Mono> list(@HostParam("endpoint") String endpoint, @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Response listSync(@HostParam("endpoint") String endpoint, - @QueryParam("api-version") String apiVersion, @HeaderParam("accept") String accept, + @QueryParam("api-version") String apiVersion, @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Put("/versioning/resources/{name}") @@ -135,8 +135,8 @@ Response listSync(@HostParam("endpoint") String endpoint, @UnexpectedResponseExceptionType(HttpResponseException.class) Mono> createLongRunning(@HostParam("endpoint") String endpoint, @QueryParam("api-version") String apiVersion, @PathParam("name") String name, - @HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData resource, - RequestOptions requestOptions, Context context); + @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 }) @@ -146,8 +146,8 @@ Mono> createLongRunning(@HostParam("endpoint") String endpo @UnexpectedResponseExceptionType(HttpResponseException.class) Response createLongRunningSync(@HostParam("endpoint") String endpoint, @QueryParam("api-version") String apiVersion, @PathParam("name") String name, - @HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData resource, - RequestOptions requestOptions, Context context); + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") BinaryData resource, RequestOptions requestOptions, Context context); @Get("{nextLink}") @ExpectedResponses({ 200 }) @@ -156,7 +156,7 @@ Response createLongRunningSync(@HostParam("endpoint") String endpoin @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, + @HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Get("{nextLink}") @@ -166,7 +166,7 @@ Mono> listNext(@PathParam(value = "nextLink", encoded = tru @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, + @HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); } @@ -657,9 +657,11 @@ public PagedIterable list(RequestOptions requestOptions) { @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, accept, resource, requestOptions, context)); + this.client.getServiceVersion().getVersion(), name, contentType, accept, resource, requestOptions, + context)); } /** @@ -696,9 +698,10 @@ private Mono> createLongRunningWithResponseAsync(String nam @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, accept, resource, requestOptions, Context.NONE); + name, contentType, accept, resource, requestOptions, Context.NONE); } /** @@ -886,6 +889,8 @@ public SyncPoller beginCreateLongRunningWithMode } /** + * Resource list operation template. + * * Get the next page of items. *

Response Body Schema

* @@ -917,6 +922,8 @@ private Mono> listNextSinglePageAsync(String nextLink, } /** + * Resource list operation template. + * * Get the next page of items. *

Response Body Schema

* diff --git a/typespec-tests/src/main/java/com/cadl/visibility/implementation/VisibilityClientImpl.java b/typespec-tests/src/main/java/com/cadl/visibility/implementation/VisibilityClientImpl.java index e5b08514f9..e7e9451941 100644 --- a/typespec-tests/src/main/java/com/cadl/visibility/implementation/VisibilityClientImpl.java +++ b/typespec-tests/src/main/java/com/cadl/visibility/implementation/VisibilityClientImpl.java @@ -44,12 +44,12 @@ public final class VisibilityClientImpl { private final VisibilityClientService service; /** - * Server parameter. + * Service host. */ private final String endpoint; /** - * Gets Server parameter. + * Gets Service host. * * @return the endpoint value. */ @@ -116,7 +116,7 @@ public VisibilityWritesImpl getVisibilityWrites() { /** * Initializes an instance of VisibilityClient client. * - * @param endpoint Server parameter. + * @param endpoint Service host. */ public VisibilityClientImpl(String endpoint) { this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), @@ -127,7 +127,7 @@ public VisibilityClientImpl(String endpoint) { * Initializes an instance of VisibilityClient client. * * @param httpPipeline The HTTP pipeline to send requests through. - * @param endpoint Server parameter. + * @param endpoint Service host. */ public VisibilityClientImpl(HttpPipeline httpPipeline, String endpoint) { this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint); @@ -138,7 +138,7 @@ public VisibilityClientImpl(HttpPipeline httpPipeline, String endpoint) { * * @param httpPipeline The HTTP pipeline to send requests through. * @param serializerAdapter The serializer to serialize an object into a string. - * @param endpoint Server parameter. + * @param endpoint Service host. */ public VisibilityClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, String endpoint) { this.httpPipeline = httpPipeline; @@ -162,7 +162,7 @@ public interface VisibilityClientService { @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, + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Get("/visibility/read") @@ -171,7 +171,7 @@ Mono> get(@HostParam("endpoint") String endpoint, @HeaderPa @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, + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Put("/visibility/write") @@ -180,7 +180,8 @@ Response getSync(@HostParam("endpoint") String endpoint, @HeaderPara @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> create(@HostParam("endpoint") String endpoint, @HeaderParam("accept") String accept, + 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") @@ -189,7 +190,8 @@ Mono> create(@HostParam("endpoint") String endpoint, @Heade @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response createSync(@HostParam("endpoint") String endpoint, @HeaderParam("accept") String accept, + 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") @@ -198,7 +200,8 @@ Response createSync(@HostParam("endpoint") String endpoint, @HeaderP @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> query(@HostParam("endpoint") String endpoint, @HeaderParam("accept") String accept, + 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") @@ -207,7 +210,8 @@ Mono> query(@HostParam("endpoint") String endpoint, @Header @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response querySync(@HostParam("endpoint") String endpoint, @HeaderParam("accept") String accept, + 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") @@ -217,8 +221,8 @@ Response querySync(@HostParam("endpoint") String endpoint, @HeaderPa @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Mono> roundtrip(@HostParam("endpoint") String endpoint, - @HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, - RequestOptions requestOptions, Context context); + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); @Put("/visibility/roundtrip") @ExpectedResponses({ 200 }) @@ -226,7 +230,8 @@ Mono> roundtrip(@HostParam("endpoint") String endpoint, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response roundtripSync(@HostParam("endpoint") String endpoint, @HeaderParam("accept") String accept, + Response roundtripSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); } @@ -310,9 +315,10 @@ public Response getWithResponse(RequestOptions requestOptions) { */ @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(), accept, dog, requestOptions, context)); + return FluxUtil.withContext( + context -> service.create(this.getEndpoint(), contentType, accept, dog, requestOptions, context)); } /** @@ -345,8 +351,9 @@ public Mono> createWithResponseAsync(BinaryData dog, Reques */ @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(), accept, dog, requestOptions, Context.NONE); + return service.createSync(this.getEndpoint(), contentType, accept, dog, requestOptions, Context.NONE); } /** @@ -380,8 +387,10 @@ public Response createWithResponse(BinaryData dog, RequestOptions re */ @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(), accept, dog, requestOptions, context)); + return FluxUtil.withContext( + context -> service.query(this.getEndpoint(), contentType, accept, dog, requestOptions, context)); } /** @@ -415,8 +424,9 @@ public Mono> queryWithResponseAsync(BinaryData dog, Request */ @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(), accept, dog, requestOptions, Context.NONE); + return service.querySync(this.getEndpoint(), contentType, accept, dog, requestOptions, Context.NONE); } /** @@ -449,9 +459,10 @@ public Response queryWithResponse(BinaryData dog, RequestOptions req */ @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(), accept, body, requestOptions, context)); + return FluxUtil.withContext( + context -> service.roundtrip(this.getEndpoint(), contentType, accept, body, requestOptions, context)); } /** @@ -484,7 +495,8 @@ public Mono> roundtripWithResponseAsync(BinaryData body, Re */ @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(), accept, body, requestOptions, Context.NONE); + return service.roundtripSync(this.getEndpoint(), contentType, accept, body, requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/cadl/visibility/implementation/VisibilityReadsImpl.java b/typespec-tests/src/main/java/com/cadl/visibility/implementation/VisibilityReadsImpl.java index 1f963da1e5..0cc46f0a42 100644 --- a/typespec-tests/src/main/java/com/cadl/visibility/implementation/VisibilityReadsImpl.java +++ b/typespec-tests/src/main/java/com/cadl/visibility/implementation/VisibilityReadsImpl.java @@ -63,7 +63,7 @@ public interface VisibilityReadsService { @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, + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Get("/read") @@ -72,7 +72,7 @@ Mono> get(@HostParam("endpoint") String endpoint, @HeaderPa @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, + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); } diff --git a/typespec-tests/src/main/java/com/cadl/visibility/implementation/VisibilityWritesImpl.java b/typespec-tests/src/main/java/com/cadl/visibility/implementation/VisibilityWritesImpl.java index f9949728ad..19648f316f 100644 --- a/typespec-tests/src/main/java/com/cadl/visibility/implementation/VisibilityWritesImpl.java +++ b/typespec-tests/src/main/java/com/cadl/visibility/implementation/VisibilityWritesImpl.java @@ -64,7 +64,8 @@ public interface VisibilityWritesService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> create(@HostParam("endpoint") String endpoint, @HeaderParam("accept") String accept, + 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") @@ -73,7 +74,8 @@ Mono> create(@HostParam("endpoint") String endpoint, @Heade @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response createSync(@HostParam("endpoint") String endpoint, @HeaderParam("accept") String accept, + Response createSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, @BodyParam("application/json") BinaryData dog, RequestOptions requestOptions, Context context); } @@ -107,9 +109,10 @@ Response createSync(@HostParam("endpoint") String endpoint, @HeaderP */ @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(), accept, dog, requestOptions, context)); + return FluxUtil.withContext( + context -> service.create(this.client.getEndpoint(), contentType, accept, dog, requestOptions, context)); } /** @@ -142,7 +145,8 @@ public Mono> createWithResponseAsync(BinaryData dog, Reques */ @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(), accept, dog, requestOptions, Context.NONE); + return service.createSync(this.client.getEndpoint(), contentType, accept, dog, requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/cadl/wiretype/implementation/WireTypeClientImpl.java b/typespec-tests/src/main/java/com/cadl/wiretype/implementation/WireTypeClientImpl.java index f6f76dd425..8a6e2a8d30 100644 --- a/typespec-tests/src/main/java/com/cadl/wiretype/implementation/WireTypeClientImpl.java +++ b/typespec-tests/src/main/java/com/cadl/wiretype/implementation/WireTypeClientImpl.java @@ -16,12 +16,12 @@ */ public final class WireTypeClientImpl { /** - * Server parameter. + * Service host. */ private final String endpoint; /** - * Gets Server parameter. + * Gets Service host. * * @return the endpoint value. */ @@ -74,7 +74,7 @@ public WireTypeOpsImpl getWireTypeOps() { /** * Initializes an instance of WireTypeClient client. * - * @param endpoint Server parameter. + * @param endpoint Service host. */ public WireTypeClientImpl(String endpoint) { this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), @@ -85,7 +85,7 @@ public WireTypeClientImpl(String endpoint) { * Initializes an instance of WireTypeClient client. * * @param httpPipeline The HTTP pipeline to send requests through. - * @param endpoint Server parameter. + * @param endpoint Service host. */ public WireTypeClientImpl(HttpPipeline httpPipeline, String endpoint) { this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint); @@ -96,7 +96,7 @@ public WireTypeClientImpl(HttpPipeline httpPipeline, String endpoint) { * * @param httpPipeline The HTTP pipeline to send requests through. * @param serializerAdapter The serializer to serialize an object into a string. - * @param endpoint Server parameter. + * @param endpoint Service host. */ public WireTypeClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, String endpoint) { this.httpPipeline = httpPipeline; diff --git a/typespec-tests/src/main/java/com/cadl/wiretype/implementation/WireTypeOpsImpl.java b/typespec-tests/src/main/java/com/cadl/wiretype/implementation/WireTypeOpsImpl.java index ef9a7b989f..2670cb132f 100644 --- a/typespec-tests/src/main/java/com/cadl/wiretype/implementation/WireTypeOpsImpl.java +++ b/typespec-tests/src/main/java/com/cadl/wiretype/implementation/WireTypeOpsImpl.java @@ -65,8 +65,8 @@ public interface WireTypeOpsService { @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Mono> superClassMismatch(@HostParam("endpoint") String endpoint, - @HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, - RequestOptions requestOptions, Context context); + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); @Put("/wireType/superClassMismatch") @ExpectedResponses({ 200 }) @@ -75,8 +75,8 @@ Mono> superClassMismatch(@HostParam("endpoint") String endp @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Response superClassMismatchSync(@HostParam("endpoint") String endpoint, - @HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, - RequestOptions requestOptions, Context context); + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); @Put("/wireType/subClassMismatch") @ExpectedResponses({ 200 }) @@ -85,8 +85,8 @@ Response superClassMismatchSync(@HostParam("endpoint") String endpoi @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Mono> subClassMismatch(@HostParam("endpoint") String endpoint, - @HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, - RequestOptions requestOptions, Context context); + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); @Put("/wireType/subClassMismatch") @ExpectedResponses({ 200 }) @@ -95,8 +95,8 @@ Mono> subClassMismatch(@HostParam("endpoint") String endpoi @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Response subClassMismatchSync(@HostParam("endpoint") String endpoint, - @HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, - RequestOptions requestOptions, Context context); + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); @Put("/wireType/bothClassMismatch") @ExpectedResponses({ 200 }) @@ -105,8 +105,8 @@ Response subClassMismatchSync(@HostParam("endpoint") String endpoint @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Mono> bothClassMismatch(@HostParam("endpoint") String endpoint, - @HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, - RequestOptions requestOptions, Context context); + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); @Put("/wireType/bothClassMismatch") @ExpectedResponses({ 200 }) @@ -115,8 +115,8 @@ Mono> bothClassMismatch(@HostParam("endpoint") String endpo @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Response bothClassMismatchSync(@HostParam("endpoint") String endpoint, - @HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, - RequestOptions requestOptions, Context context); + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); } /** @@ -150,9 +150,10 @@ Response bothClassMismatchSync(@HostParam("endpoint") String endpoin @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(), accept, body, requestOptions, context)); + return FluxUtil.withContext(context -> service.superClassMismatch(this.client.getEndpoint(), contentType, + accept, body, requestOptions, context)); } /** @@ -185,8 +186,10 @@ public Mono> superClassMismatchWithResponseAsync(BinaryData */ @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(), accept, body, requestOptions, Context.NONE); + return service.superClassMismatchSync(this.client.getEndpoint(), contentType, accept, body, requestOptions, + Context.NONE); } /** @@ -220,9 +223,10 @@ public Response superClassMismatchWithResponse(BinaryData body, Requ @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(), accept, body, requestOptions, context)); + return FluxUtil.withContext(context -> service.subClassMismatch(this.client.getEndpoint(), contentType, accept, + body, requestOptions, context)); } /** @@ -255,8 +259,10 @@ public Mono> subClassMismatchWithResponseAsync(BinaryData b */ @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(), accept, body, requestOptions, Context.NONE); + return service.subClassMismatchSync(this.client.getEndpoint(), contentType, accept, body, requestOptions, + Context.NONE); } /** @@ -290,9 +296,10 @@ public Response subClassMismatchWithResponse(BinaryData body, Reques @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(), accept, body, requestOptions, context)); + return FluxUtil.withContext(context -> service.bothClassMismatch(this.client.getEndpoint(), contentType, accept, + body, requestOptions, context)); } /** @@ -325,7 +332,9 @@ public Mono> bothClassMismatchWithResponseAsync(BinaryData */ @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(), accept, body, requestOptions, Context.NONE); + return service.bothClassMismatchSync(this.client.getEndpoint(), contentType, accept, body, requestOptions, + Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/client/naming/NamingClientBuilder.java b/typespec-tests/src/main/java/com/client/naming/NamingClientBuilder.java index dfeb2c86c9..87c6004abd 100644 --- a/typespec-tests/src/main/java/com/client/naming/NamingClientBuilder.java +++ b/typespec-tests/src/main/java/com/client/naming/NamingClientBuilder.java @@ -7,6 +7,7 @@ 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; @@ -47,8 +48,8 @@ NamingAsyncClient.class, ClientModelAsyncClient.class, UnionEnumAsyncClient.class }) -public final class NamingClientBuilder - implements HttpTrait, ConfigurationTrait { +public final class NamingClientBuilder implements HttpTrait, + ConfigurationTrait, EndpointTrait { @Generated private static final String SDK_NAME = "name"; @@ -179,6 +180,22 @@ public NamingClientBuilder configuration(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. */ @@ -206,7 +223,9 @@ public NamingClientBuilder retryPolicy(RetryPolicy retryPolicy) { private NamingClientImpl buildInnerClient() { this.validateClient(); HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); - NamingClientImpl client = new NamingClientImpl(localPipeline, JacksonAdapter.createDefaultSerializerAdapter()); + String localEndpoint = (endpoint != null) ? endpoint : "http://localhost:3000"; + NamingClientImpl client + = new NamingClientImpl(localPipeline, JacksonAdapter.createDefaultSerializerAdapter(), localEndpoint); return client; } diff --git a/typespec-tests/src/main/java/com/client/naming/implementation/ClientModelsImpl.java b/typespec-tests/src/main/java/com/client/naming/implementation/ClientModelsImpl.java index a1cf0ec689..8e2403e6b8 100644 --- a/typespec-tests/src/main/java/com/client/naming/implementation/ClientModelsImpl.java +++ b/typespec-tests/src/main/java/com/client/naming/implementation/ClientModelsImpl.java @@ -8,6 +8,7 @@ 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; @@ -54,7 +55,7 @@ public final class ClientModelsImpl { * The interface defining all the services for NamingClientClientModels to be used by the proxy service to perform * REST calls. */ - @Host("http://localhost:3000") + @Host("{endpoint}") @ServiceInterface(name = "NamingClientClientMo") public interface ClientModelsService { @Post("/client/naming/model/client") @@ -63,8 +64,9 @@ public interface ClientModelsService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> client(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + 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 }) @@ -72,7 +74,8 @@ Mono> client(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response clientSync(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, + 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") @@ -81,8 +84,9 @@ Response clientSync(@HeaderParam("accept") String accept, @BodyParam("appl @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> language(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + 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 }) @@ -90,8 +94,9 @@ Mono> language(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response languageSync(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + Response languageSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); } /** @@ -114,8 +119,9 @@ Response languageSync(@HeaderParam("accept") String accept, */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> clientWithResponseAsync(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.client(accept, body, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.client(this.client.getEndpoint(), contentType, body, requestOptions, context)); } /** @@ -138,8 +144,8 @@ public Mono> clientWithResponseAsync(BinaryData body, RequestOpti */ @ServiceMethod(returns = ReturnType.SINGLE) public Response clientWithResponse(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.clientSync(accept, body, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.clientSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); } /** @@ -162,8 +168,9 @@ public Response clientWithResponse(BinaryData body, RequestOptions request */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> languageWithResponseAsync(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.language(accept, body, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.language(this.client.getEndpoint(), contentType, body, requestOptions, context)); } /** @@ -186,7 +193,7 @@ public Mono> languageWithResponseAsync(BinaryData body, RequestOp */ @ServiceMethod(returns = ReturnType.SINGLE) public Response languageWithResponse(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.languageSync(accept, body, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.languageSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/client/naming/implementation/NamingClientImpl.java b/typespec-tests/src/main/java/com/client/naming/implementation/NamingClientImpl.java index b302925913..2b80eddc75 100644 --- a/typespec-tests/src/main/java/com/client/naming/implementation/NamingClientImpl.java +++ b/typespec-tests/src/main/java/com/client/naming/implementation/NamingClientImpl.java @@ -9,6 +9,7 @@ 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; @@ -42,6 +43,20 @@ public final class NamingClientImpl { */ 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. */ @@ -100,19 +115,22 @@ public UnionEnumsImpl getUnionEnums() { /** * Initializes an instance of NamingClient client. + * + * @param endpoint Service host. */ - public NamingClientImpl() { + public NamingClientImpl(String endpoint) { this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), - JacksonAdapter.createDefaultSerializerAdapter()); + 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) { - this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter()); + public NamingClientImpl(HttpPipeline httpPipeline, String endpoint) { + this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint); } /** @@ -120,10 +138,12 @@ public NamingClientImpl(HttpPipeline httpPipeline) { * * @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) { + 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()); @@ -132,7 +152,7 @@ public NamingClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerA /** * The interface defining all the services for NamingClient to be used by the proxy service to perform REST calls. */ - @Host("http://localhost:3000") + @Host("{endpoint}") @ServiceInterface(name = "NamingClient") public interface NamingClientService { @Post("/client/naming/operation") @@ -141,7 +161,7 @@ public interface NamingClientService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> clientName(@HeaderParam("accept") String accept, RequestOptions requestOptions, + Mono> clientName(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, Context context); @Post("/client/naming/operation") @@ -150,7 +170,7 @@ Mono> clientName(@HeaderParam("accept") String accept, RequestOpt @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response clientNameSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, + Response clientNameSync(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, Context context); @Post("/client/naming/parameter") @@ -159,8 +179,8 @@ Response clientNameSync(@HeaderParam("accept") String accept, RequestOptio @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> parameter(@QueryParam("defaultName") String clientName, - @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + Mono> parameter(@HostParam("endpoint") String endpoint, + @QueryParam("defaultName") String clientName, RequestOptions requestOptions, Context context); @Post("/client/naming/parameter") @ExpectedResponses({ 204 }) @@ -168,8 +188,8 @@ Mono> parameter(@QueryParam("defaultName") String clientName, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response parameterSync(@QueryParam("defaultName") String clientName, @HeaderParam("accept") String accept, - RequestOptions requestOptions, Context context); + Response parameterSync(@HostParam("endpoint") String endpoint, + @QueryParam("defaultName") String clientName, RequestOptions requestOptions, Context context); @Post("/client/naming/property/client") @ExpectedResponses({ 204 }) @@ -177,8 +197,9 @@ Response parameterSync(@QueryParam("defaultName") String clientName, @Head @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> client(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + 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 }) @@ -186,7 +207,8 @@ Mono> client(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response clientSync(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, + 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") @@ -195,8 +217,9 @@ Response clientSync(@HeaderParam("accept") String accept, @BodyParam("appl @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> language(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + 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 }) @@ -204,8 +227,9 @@ Mono> language(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response languageSync(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + 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 }) @@ -213,8 +237,9 @@ Response languageSync(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> compatibleWithEncodedName(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + 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 }) @@ -222,8 +247,9 @@ Mono> compatibleWithEncodedName(@HeaderParam("accept") String acc @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response compatibleWithEncodedNameSync(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + 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 }) @@ -231,8 +257,8 @@ Response compatibleWithEncodedNameSync(@HeaderParam("accept") String accep @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> request(@HeaderParam("default-name") String clientName, - @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + Mono> request(@HostParam("endpoint") String endpoint, + @HeaderParam("default-name") String clientName, RequestOptions requestOptions, Context context); @Post("/client/naming/header") @ExpectedResponses({ 204 }) @@ -240,8 +266,8 @@ Mono> request(@HeaderParam("default-name") String clientName, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response requestSync(@HeaderParam("default-name") String clientName, @HeaderParam("accept") String accept, - RequestOptions requestOptions, Context context); + Response requestSync(@HostParam("endpoint") String endpoint, + @HeaderParam("default-name") String clientName, RequestOptions requestOptions, Context context); @Get("/client/naming/header") @ExpectedResponses({ 204 }) @@ -249,7 +275,7 @@ Response requestSync(@HeaderParam("default-name") String clientName, @Head @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> response(@HeaderParam("accept") String accept, RequestOptions requestOptions, + Mono> response(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, Context context); @Get("/client/naming/header") @@ -258,7 +284,7 @@ Mono> response(@HeaderParam("accept") String accept, RequestOptio @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response responseSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, + Response responseSync(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, Context context); } @@ -274,8 +300,7 @@ Response responseSync(@HeaderParam("accept") String accept, RequestOptions */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> clientNameWithResponseAsync(RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.clientName(accept, requestOptions, context)); + return FluxUtil.withContext(context -> service.clientName(this.getEndpoint(), requestOptions, context)); } /** @@ -290,8 +315,7 @@ public Mono> clientNameWithResponseAsync(RequestOptions requestOp */ @ServiceMethod(returns = ReturnType.SINGLE) public Response clientNameWithResponse(RequestOptions requestOptions) { - final String accept = "application/json"; - return service.clientNameSync(accept, requestOptions, Context.NONE); + return service.clientNameSync(this.getEndpoint(), requestOptions, Context.NONE); } /** @@ -307,8 +331,8 @@ public Response clientNameWithResponse(RequestOptions requestOptions) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> parameterWithResponseAsync(String clientName, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.parameter(clientName, accept, requestOptions, context)); + return FluxUtil + .withContext(context -> service.parameter(this.getEndpoint(), clientName, requestOptions, context)); } /** @@ -324,8 +348,7 @@ public Mono> parameterWithResponseAsync(String clientName, Reques */ @ServiceMethod(returns = ReturnType.SINGLE) public Response parameterWithResponse(String clientName, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.parameterSync(clientName, accept, requestOptions, Context.NONE); + return service.parameterSync(this.getEndpoint(), clientName, requestOptions, Context.NONE); } /** @@ -348,8 +371,9 @@ public Response parameterWithResponse(String clientName, RequestOptions re */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> clientWithResponseAsync(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.client(accept, body, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.client(this.getEndpoint(), contentType, body, requestOptions, context)); } /** @@ -372,8 +396,8 @@ public Mono> clientWithResponseAsync(BinaryData body, RequestOpti */ @ServiceMethod(returns = ReturnType.SINGLE) public Response clientWithResponse(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.clientSync(accept, body, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.clientSync(this.getEndpoint(), contentType, body, requestOptions, Context.NONE); } /** @@ -396,8 +420,9 @@ public Response clientWithResponse(BinaryData body, RequestOptions request */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> languageWithResponseAsync(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.language(accept, body, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.language(this.getEndpoint(), contentType, body, requestOptions, context)); } /** @@ -420,8 +445,8 @@ public Mono> languageWithResponseAsync(BinaryData body, RequestOp */ @ServiceMethod(returns = ReturnType.SINGLE) public Response languageWithResponse(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.languageSync(accept, body, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.languageSync(this.getEndpoint(), contentType, body, requestOptions, Context.NONE); } /** @@ -445,9 +470,9 @@ public Response languageWithResponse(BinaryData body, RequestOptions reque @ServiceMethod(returns = ReturnType.SINGLE) public Mono> compatibleWithEncodedNameWithResponseAsync(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil - .withContext(context -> service.compatibleWithEncodedName(accept, body, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil.withContext(context -> service.compatibleWithEncodedName(this.getEndpoint(), contentType, body, + requestOptions, context)); } /** @@ -470,8 +495,9 @@ public Mono> compatibleWithEncodedNameWithResponseAsync(BinaryDat */ @ServiceMethod(returns = ReturnType.SINGLE) public Response compatibleWithEncodedNameWithResponse(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.compatibleWithEncodedNameSync(accept, body, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.compatibleWithEncodedNameSync(this.getEndpoint(), contentType, body, requestOptions, + Context.NONE); } /** @@ -487,8 +513,8 @@ public Response compatibleWithEncodedNameWithResponse(BinaryData body, Req */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> requestWithResponseAsync(String clientName, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.request(clientName, accept, requestOptions, context)); + return FluxUtil + .withContext(context -> service.request(this.getEndpoint(), clientName, requestOptions, context)); } /** @@ -504,8 +530,7 @@ public Mono> requestWithResponseAsync(String clientName, RequestO */ @ServiceMethod(returns = ReturnType.SINGLE) public Response requestWithResponse(String clientName, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.requestSync(clientName, accept, requestOptions, Context.NONE); + return service.requestSync(this.getEndpoint(), clientName, requestOptions, Context.NONE); } /** @@ -520,8 +545,7 @@ public Response requestWithResponse(String clientName, RequestOptions requ */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> responseWithResponseAsync(RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.response(accept, requestOptions, context)); + return FluxUtil.withContext(context -> service.response(this.getEndpoint(), requestOptions, context)); } /** @@ -536,7 +560,6 @@ public Mono> responseWithResponseAsync(RequestOptions requestOpti */ @ServiceMethod(returns = ReturnType.SINGLE) public Response responseWithResponse(RequestOptions requestOptions) { - final String accept = "application/json"; - return service.responseSync(accept, requestOptions, Context.NONE); + return service.responseSync(this.getEndpoint(), requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/client/naming/implementation/UnionEnumsImpl.java b/typespec-tests/src/main/java/com/client/naming/implementation/UnionEnumsImpl.java index 5e4fab48e7..ed4791a76e 100644 --- a/typespec-tests/src/main/java/com/client/naming/implementation/UnionEnumsImpl.java +++ b/typespec-tests/src/main/java/com/client/naming/implementation/UnionEnumsImpl.java @@ -8,6 +8,7 @@ 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; @@ -54,7 +55,7 @@ public final class UnionEnumsImpl { * The interface defining all the services for NamingClientUnionEnums to be used by the proxy service to perform * REST calls. */ - @Host("http://localhost:3000") + @Host("{endpoint}") @ServiceInterface(name = "NamingClientUnionEnu") public interface UnionEnumsService { @Post("/client/naming/union-enum/union-enum-name") @@ -63,8 +64,9 @@ public interface UnionEnumsService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> unionEnumName(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + 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 }) @@ -72,8 +74,9 @@ Mono> unionEnumName(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response unionEnumNameSync(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + 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 }) @@ -81,8 +84,9 @@ Response unionEnumNameSync(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> unionEnumMemberName(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + 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 }) @@ -90,8 +94,9 @@ Mono> unionEnumMemberName(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response unionEnumMemberNameSync(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + Response unionEnumMemberNameSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); } /** @@ -112,8 +117,9 @@ Response unionEnumMemberNameSync(@HeaderParam("accept") String accept, */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> unionEnumNameWithResponseAsync(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.unionEnumName(accept, body, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.unionEnumName(this.client.getEndpoint(), contentType, body, requestOptions, context)); } /** @@ -134,8 +140,8 @@ public Mono> unionEnumNameWithResponseAsync(BinaryData body, Requ */ @ServiceMethod(returns = ReturnType.SINGLE) public Response unionEnumNameWithResponse(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.unionEnumNameSync(accept, body, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.unionEnumNameSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); } /** @@ -156,8 +162,9 @@ public Response unionEnumNameWithResponse(BinaryData body, RequestOptions */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> unionEnumMemberNameWithResponseAsync(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.unionEnumMemberName(accept, body, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil.withContext(context -> service.unionEnumMemberName(this.client.getEndpoint(), contentType, body, + requestOptions, context)); } /** @@ -178,7 +185,8 @@ public Mono> unionEnumMemberNameWithResponseAsync(BinaryData body */ @ServiceMethod(returns = ReturnType.SINGLE) public Response unionEnumMemberNameWithResponse(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.unionEnumMemberNameSync(accept, body, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.unionEnumMemberNameSync(this.client.getEndpoint(), contentType, body, requestOptions, + Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/client/structure/service/implementation/BarsImpl.java b/typespec-tests/src/main/java/com/client/structure/service/implementation/BarsImpl.java index 310679abf4..cbaaebe088 100644 --- a/typespec-tests/src/main/java/com/client/structure/service/implementation/BarsImpl.java +++ b/typespec-tests/src/main/java/com/client/structure/service/implementation/BarsImpl.java @@ -5,7 +5,6 @@ package com.client.structure.service.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.Post; @@ -62,7 +61,7 @@ public interface BarsService { @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Mono> five(@HostParam("endpoint") String endpoint, @HostParam("client") String client, - @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + RequestOptions requestOptions, Context context); @Post("/five") @ExpectedResponses({ 204 }) @@ -71,7 +70,7 @@ Mono> five(@HostParam("endpoint") String endpoint, @HostParam("cl @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Response fiveSync(@HostParam("endpoint") String endpoint, @HostParam("client") String client, - @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + RequestOptions requestOptions, Context context); @Post("/six") @ExpectedResponses({ 204 }) @@ -80,7 +79,7 @@ Response fiveSync(@HostParam("endpoint") String endpoint, @HostParam("clie @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Mono> six(@HostParam("endpoint") String endpoint, @HostParam("client") String client, - @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + RequestOptions requestOptions, Context context); @Post("/six") @ExpectedResponses({ 204 }) @@ -89,7 +88,7 @@ Mono> six(@HostParam("endpoint") String endpoint, @HostParam("cli @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Response sixSync(@HostParam("endpoint") String endpoint, @HostParam("client") String client, - @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + RequestOptions requestOptions, Context context); } /** @@ -104,9 +103,8 @@ Response sixSync(@HostParam("endpoint") String endpoint, @HostParam("clien */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> fiveWithResponseAsync(RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.five(this.client.getEndpoint(), this.client.getClient(), accept, - requestOptions, context)); + return FluxUtil.withContext( + context -> service.five(this.client.getEndpoint(), this.client.getClient(), requestOptions, context)); } /** @@ -121,9 +119,7 @@ public Mono> fiveWithResponseAsync(RequestOptions requestOptions) */ @ServiceMethod(returns = ReturnType.SINGLE) public Response fiveWithResponse(RequestOptions requestOptions) { - final String accept = "application/json"; - return service.fiveSync(this.client.getEndpoint(), this.client.getClient(), accept, requestOptions, - Context.NONE); + return service.fiveSync(this.client.getEndpoint(), this.client.getClient(), requestOptions, Context.NONE); } /** @@ -138,9 +134,8 @@ public Response fiveWithResponse(RequestOptions requestOptions) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> sixWithResponseAsync(RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.six(this.client.getEndpoint(), this.client.getClient(), accept, - requestOptions, context)); + return FluxUtil.withContext( + context -> service.six(this.client.getEndpoint(), this.client.getClient(), requestOptions, context)); } /** @@ -155,8 +150,6 @@ public Mono> sixWithResponseAsync(RequestOptions requestOptions) */ @ServiceMethod(returns = ReturnType.SINGLE) public Response sixWithResponse(RequestOptions requestOptions) { - final String accept = "application/json"; - return service.sixSync(this.client.getEndpoint(), this.client.getClient(), accept, requestOptions, - Context.NONE); + return service.sixSync(this.client.getEndpoint(), this.client.getClient(), requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/client/structure/service/implementation/BazFoosImpl.java b/typespec-tests/src/main/java/com/client/structure/service/implementation/BazFoosImpl.java index 93f545ee85..4fec7b0a1c 100644 --- a/typespec-tests/src/main/java/com/client/structure/service/implementation/BazFoosImpl.java +++ b/typespec-tests/src/main/java/com/client/structure/service/implementation/BazFoosImpl.java @@ -5,7 +5,6 @@ package com.client.structure.service.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.Post; @@ -62,7 +61,7 @@ public interface BazFoosService { @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Mono> seven(@HostParam("endpoint") String endpoint, @HostParam("client") String client, - @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + RequestOptions requestOptions, Context context); @Post("/seven") @ExpectedResponses({ 204 }) @@ -71,7 +70,7 @@ Mono> seven(@HostParam("endpoint") String endpoint, @HostParam("c @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Response sevenSync(@HostParam("endpoint") String endpoint, @HostParam("client") String client, - @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + RequestOptions requestOptions, Context context); } /** @@ -86,9 +85,8 @@ Response sevenSync(@HostParam("endpoint") String endpoint, @HostParam("cli */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> sevenWithResponseAsync(RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.seven(this.client.getEndpoint(), this.client.getClient(), accept, - requestOptions, context)); + return FluxUtil.withContext( + context -> service.seven(this.client.getEndpoint(), this.client.getClient(), requestOptions, context)); } /** @@ -103,8 +101,6 @@ public Mono> sevenWithResponseAsync(RequestOptions requestOptions */ @ServiceMethod(returns = ReturnType.SINGLE) public Response sevenWithResponse(RequestOptions requestOptions) { - final String accept = "application/json"; - return service.sevenSync(this.client.getEndpoint(), this.client.getClient(), accept, requestOptions, - Context.NONE); + return service.sevenSync(this.client.getEndpoint(), this.client.getClient(), requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/client/structure/service/implementation/ClientAClientImpl.java b/typespec-tests/src/main/java/com/client/structure/service/implementation/ClientAClientImpl.java index b0d94bf2d0..0522be5c4f 100644 --- a/typespec-tests/src/main/java/com/client/structure/service/implementation/ClientAClientImpl.java +++ b/typespec-tests/src/main/java/com/client/structure/service/implementation/ClientAClientImpl.java @@ -5,7 +5,6 @@ package com.client.structure.service.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.Post; @@ -147,7 +146,7 @@ public interface ClientAClientService { @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Mono> renamedOne(@HostParam("endpoint") String endpoint, @HostParam("client") String client, - @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + RequestOptions requestOptions, Context context); @Post("/one") @ExpectedResponses({ 204 }) @@ -156,7 +155,7 @@ Mono> renamedOne(@HostParam("endpoint") String endpoint, @HostPar @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Response renamedOneSync(@HostParam("endpoint") String endpoint, @HostParam("client") String client, - @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + RequestOptions requestOptions, Context context); @Post("/three") @ExpectedResponses({ 204 }) @@ -165,7 +164,7 @@ Response renamedOneSync(@HostParam("endpoint") String endpoint, @HostParam @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Mono> renamedThree(@HostParam("endpoint") String endpoint, @HostParam("client") String client, - @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + RequestOptions requestOptions, Context context); @Post("/three") @ExpectedResponses({ 204 }) @@ -174,7 +173,7 @@ Mono> renamedThree(@HostParam("endpoint") String endpoint, @HostP @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Response renamedThreeSync(@HostParam("endpoint") String endpoint, @HostParam("client") String client, - @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + RequestOptions requestOptions, Context context); @Post("/five") @ExpectedResponses({ 204 }) @@ -183,7 +182,7 @@ Response renamedThreeSync(@HostParam("endpoint") String endpoint, @HostPar @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Mono> renamedFive(@HostParam("endpoint") String endpoint, @HostParam("client") String client, - @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + RequestOptions requestOptions, Context context); @Post("/five") @ExpectedResponses({ 204 }) @@ -192,7 +191,7 @@ Mono> renamedFive(@HostParam("endpoint") String endpoint, @HostPa @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Response renamedFiveSync(@HostParam("endpoint") String endpoint, @HostParam("client") String client, - @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + RequestOptions requestOptions, Context context); } /** @@ -207,9 +206,8 @@ Response renamedFiveSync(@HostParam("endpoint") String endpoint, @HostPara */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> renamedOneWithResponseAsync(RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext( - context -> service.renamedOne(this.getEndpoint(), this.getClient(), accept, requestOptions, context)); + return FluxUtil + .withContext(context -> service.renamedOne(this.getEndpoint(), this.getClient(), requestOptions, context)); } /** @@ -224,8 +222,7 @@ public Mono> renamedOneWithResponseAsync(RequestOptions requestOp */ @ServiceMethod(returns = ReturnType.SINGLE) public Response renamedOneWithResponse(RequestOptions requestOptions) { - final String accept = "application/json"; - return service.renamedOneSync(this.getEndpoint(), this.getClient(), accept, requestOptions, Context.NONE); + return service.renamedOneSync(this.getEndpoint(), this.getClient(), requestOptions, Context.NONE); } /** @@ -240,9 +237,8 @@ public Response renamedOneWithResponse(RequestOptions requestOptions) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> renamedThreeWithResponseAsync(RequestOptions requestOptions) { - final String accept = "application/json"; return FluxUtil.withContext( - context -> service.renamedThree(this.getEndpoint(), this.getClient(), accept, requestOptions, context)); + context -> service.renamedThree(this.getEndpoint(), this.getClient(), requestOptions, context)); } /** @@ -257,8 +253,7 @@ public Mono> renamedThreeWithResponseAsync(RequestOptions request */ @ServiceMethod(returns = ReturnType.SINGLE) public Response renamedThreeWithResponse(RequestOptions requestOptions) { - final String accept = "application/json"; - return service.renamedThreeSync(this.getEndpoint(), this.getClient(), accept, requestOptions, Context.NONE); + return service.renamedThreeSync(this.getEndpoint(), this.getClient(), requestOptions, Context.NONE); } /** @@ -273,9 +268,8 @@ public Response renamedThreeWithResponse(RequestOptions requestOptions) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> renamedFiveWithResponseAsync(RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext( - context -> service.renamedFive(this.getEndpoint(), this.getClient(), accept, requestOptions, context)); + return FluxUtil + .withContext(context -> service.renamedFive(this.getEndpoint(), this.getClient(), requestOptions, context)); } /** @@ -290,7 +284,6 @@ public Mono> renamedFiveWithResponseAsync(RequestOptions requestO */ @ServiceMethod(returns = ReturnType.SINGLE) public Response renamedFiveWithResponse(RequestOptions requestOptions) { - final String accept = "application/json"; - return service.renamedFiveSync(this.getEndpoint(), this.getClient(), accept, requestOptions, Context.NONE); + return service.renamedFiveSync(this.getEndpoint(), this.getClient(), requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/client/structure/service/implementation/ClientBClientImpl.java b/typespec-tests/src/main/java/com/client/structure/service/implementation/ClientBClientImpl.java index 15a1ba56f1..e52b68219d 100644 --- a/typespec-tests/src/main/java/com/client/structure/service/implementation/ClientBClientImpl.java +++ b/typespec-tests/src/main/java/com/client/structure/service/implementation/ClientBClientImpl.java @@ -5,7 +5,6 @@ package com.client.structure.service.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.Post; @@ -147,7 +146,7 @@ public interface ClientBClientService { @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Mono> renamedTwo(@HostParam("endpoint") String endpoint, @HostParam("client") String client, - @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + RequestOptions requestOptions, Context context); @Post("/two") @ExpectedResponses({ 204 }) @@ -156,7 +155,7 @@ Mono> renamedTwo(@HostParam("endpoint") String endpoint, @HostPar @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Response renamedTwoSync(@HostParam("endpoint") String endpoint, @HostParam("client") String client, - @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + RequestOptions requestOptions, Context context); @Post("/four") @ExpectedResponses({ 204 }) @@ -165,7 +164,7 @@ Response renamedTwoSync(@HostParam("endpoint") String endpoint, @HostParam @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Mono> renamedFour(@HostParam("endpoint") String endpoint, @HostParam("client") String client, - @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + RequestOptions requestOptions, Context context); @Post("/four") @ExpectedResponses({ 204 }) @@ -174,7 +173,7 @@ Mono> renamedFour(@HostParam("endpoint") String endpoint, @HostPa @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Response renamedFourSync(@HostParam("endpoint") String endpoint, @HostParam("client") String client, - @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + RequestOptions requestOptions, Context context); @Post("/six") @ExpectedResponses({ 204 }) @@ -183,7 +182,7 @@ Response renamedFourSync(@HostParam("endpoint") String endpoint, @HostPara @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Mono> renamedSix(@HostParam("endpoint") String endpoint, @HostParam("client") String client, - @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + RequestOptions requestOptions, Context context); @Post("/six") @ExpectedResponses({ 204 }) @@ -192,7 +191,7 @@ Mono> renamedSix(@HostParam("endpoint") String endpoint, @HostPar @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Response renamedSixSync(@HostParam("endpoint") String endpoint, @HostParam("client") String client, - @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + RequestOptions requestOptions, Context context); } /** @@ -207,9 +206,8 @@ Response renamedSixSync(@HostParam("endpoint") String endpoint, @HostParam */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> renamedTwoWithResponseAsync(RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext( - context -> service.renamedTwo(this.getEndpoint(), this.getClient(), accept, requestOptions, context)); + return FluxUtil + .withContext(context -> service.renamedTwo(this.getEndpoint(), this.getClient(), requestOptions, context)); } /** @@ -224,8 +222,7 @@ public Mono> renamedTwoWithResponseAsync(RequestOptions requestOp */ @ServiceMethod(returns = ReturnType.SINGLE) public Response renamedTwoWithResponse(RequestOptions requestOptions) { - final String accept = "application/json"; - return service.renamedTwoSync(this.getEndpoint(), this.getClient(), accept, requestOptions, Context.NONE); + return service.renamedTwoSync(this.getEndpoint(), this.getClient(), requestOptions, Context.NONE); } /** @@ -240,9 +237,8 @@ public Response renamedTwoWithResponse(RequestOptions requestOptions) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> renamedFourWithResponseAsync(RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext( - context -> service.renamedFour(this.getEndpoint(), this.getClient(), accept, requestOptions, context)); + return FluxUtil + .withContext(context -> service.renamedFour(this.getEndpoint(), this.getClient(), requestOptions, context)); } /** @@ -257,8 +253,7 @@ public Mono> renamedFourWithResponseAsync(RequestOptions requestO */ @ServiceMethod(returns = ReturnType.SINGLE) public Response renamedFourWithResponse(RequestOptions requestOptions) { - final String accept = "application/json"; - return service.renamedFourSync(this.getEndpoint(), this.getClient(), accept, requestOptions, Context.NONE); + return service.renamedFourSync(this.getEndpoint(), this.getClient(), requestOptions, Context.NONE); } /** @@ -273,9 +268,8 @@ public Response renamedFourWithResponse(RequestOptions requestOptions) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> renamedSixWithResponseAsync(RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext( - context -> service.renamedSix(this.getEndpoint(), this.getClient(), accept, requestOptions, context)); + return FluxUtil + .withContext(context -> service.renamedSix(this.getEndpoint(), this.getClient(), requestOptions, context)); } /** @@ -290,7 +284,6 @@ public Mono> renamedSixWithResponseAsync(RequestOptions requestOp */ @ServiceMethod(returns = ReturnType.SINGLE) public Response renamedSixWithResponse(RequestOptions requestOptions) { - final String accept = "application/json"; - return service.renamedSixSync(this.getEndpoint(), this.getClient(), accept, requestOptions, Context.NONE); + return service.renamedSixSync(this.getEndpoint(), this.getClient(), requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/client/structure/service/implementation/FirstClientImpl.java b/typespec-tests/src/main/java/com/client/structure/service/implementation/FirstClientImpl.java index 972b7ef996..eb816c9671 100644 --- a/typespec-tests/src/main/java/com/client/structure/service/implementation/FirstClientImpl.java +++ b/typespec-tests/src/main/java/com/client/structure/service/implementation/FirstClientImpl.java @@ -5,7 +5,6 @@ package com.client.structure.service.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.Post; @@ -177,7 +176,7 @@ public interface FirstClientService { @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Mono> one(@HostParam("endpoint") String endpoint, @HostParam("client") String client, - @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + RequestOptions requestOptions, Context context); @Post("/one") @ExpectedResponses({ 204 }) @@ -186,7 +185,7 @@ Mono> one(@HostParam("endpoint") String endpoint, @HostParam("cli @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Response oneSync(@HostParam("endpoint") String endpoint, @HostParam("client") String client, - @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + RequestOptions requestOptions, Context context); } /** @@ -201,9 +200,8 @@ Response oneSync(@HostParam("endpoint") String endpoint, @HostParam("clien */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> oneWithResponseAsync(RequestOptions requestOptions) { - final String accept = "application/json"; return FluxUtil - .withContext(context -> service.one(this.getEndpoint(), this.getClient(), accept, requestOptions, context)); + .withContext(context -> service.one(this.getEndpoint(), this.getClient(), requestOptions, context)); } /** @@ -218,7 +216,6 @@ public Mono> oneWithResponseAsync(RequestOptions requestOptions) */ @ServiceMethod(returns = ReturnType.SINGLE) public Response oneWithResponse(RequestOptions requestOptions) { - final String accept = "application/json"; - return service.oneSync(this.getEndpoint(), this.getClient(), accept, requestOptions, Context.NONE); + return service.oneSync(this.getEndpoint(), this.getClient(), requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/client/structure/service/implementation/FoosImpl.java b/typespec-tests/src/main/java/com/client/structure/service/implementation/FoosImpl.java index 424e5a6589..e83cf6bf78 100644 --- a/typespec-tests/src/main/java/com/client/structure/service/implementation/FoosImpl.java +++ b/typespec-tests/src/main/java/com/client/structure/service/implementation/FoosImpl.java @@ -5,7 +5,6 @@ package com.client.structure.service.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.Post; @@ -62,7 +61,7 @@ public interface FoosService { @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Mono> three(@HostParam("endpoint") String endpoint, @HostParam("client") String client, - @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + RequestOptions requestOptions, Context context); @Post("/three") @ExpectedResponses({ 204 }) @@ -71,7 +70,7 @@ Mono> three(@HostParam("endpoint") String endpoint, @HostParam("c @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Response threeSync(@HostParam("endpoint") String endpoint, @HostParam("client") String client, - @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + RequestOptions requestOptions, Context context); @Post("/four") @ExpectedResponses({ 204 }) @@ -80,7 +79,7 @@ Response threeSync(@HostParam("endpoint") String endpoint, @HostParam("cli @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Mono> four(@HostParam("endpoint") String endpoint, @HostParam("client") String client, - @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + RequestOptions requestOptions, Context context); @Post("/four") @ExpectedResponses({ 204 }) @@ -89,7 +88,7 @@ Mono> four(@HostParam("endpoint") String endpoint, @HostParam("cl @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Response fourSync(@HostParam("endpoint") String endpoint, @HostParam("client") String client, - @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + RequestOptions requestOptions, Context context); } /** @@ -104,9 +103,8 @@ Response fourSync(@HostParam("endpoint") String endpoint, @HostParam("clie */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> threeWithResponseAsync(RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.three(this.client.getEndpoint(), this.client.getClient(), accept, - requestOptions, context)); + return FluxUtil.withContext( + context -> service.three(this.client.getEndpoint(), this.client.getClient(), requestOptions, context)); } /** @@ -121,9 +119,7 @@ public Mono> threeWithResponseAsync(RequestOptions requestOptions */ @ServiceMethod(returns = ReturnType.SINGLE) public Response threeWithResponse(RequestOptions requestOptions) { - final String accept = "application/json"; - return service.threeSync(this.client.getEndpoint(), this.client.getClient(), accept, requestOptions, - Context.NONE); + return service.threeSync(this.client.getEndpoint(), this.client.getClient(), requestOptions, Context.NONE); } /** @@ -138,9 +134,8 @@ public Response threeWithResponse(RequestOptions requestOptions) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> fourWithResponseAsync(RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.four(this.client.getEndpoint(), this.client.getClient(), accept, - requestOptions, context)); + return FluxUtil.withContext( + context -> service.four(this.client.getEndpoint(), this.client.getClient(), requestOptions, context)); } /** @@ -155,8 +150,6 @@ public Mono> fourWithResponseAsync(RequestOptions requestOptions) */ @ServiceMethod(returns = ReturnType.SINGLE) public Response fourWithResponse(RequestOptions requestOptions) { - final String accept = "application/json"; - return service.fourSync(this.client.getEndpoint(), this.client.getClient(), accept, requestOptions, - Context.NONE); + return service.fourSync(this.client.getEndpoint(), this.client.getClient(), requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/client/structure/service/implementation/Group1sImpl.java b/typespec-tests/src/main/java/com/client/structure/service/implementation/Group1sImpl.java index 68238b8d42..bdd1938e5b 100644 --- a/typespec-tests/src/main/java/com/client/structure/service/implementation/Group1sImpl.java +++ b/typespec-tests/src/main/java/com/client/structure/service/implementation/Group1sImpl.java @@ -5,7 +5,6 @@ package com.client.structure.service.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.Post; @@ -62,7 +61,7 @@ public interface Group1sService { @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Mono> one(@HostParam("endpoint") String endpoint, @HostParam("client") String client, - @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + RequestOptions requestOptions, Context context); @Post("/one") @ExpectedResponses({ 204 }) @@ -71,7 +70,7 @@ Mono> one(@HostParam("endpoint") String endpoint, @HostParam("cli @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Response oneSync(@HostParam("endpoint") String endpoint, @HostParam("client") String client, - @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + RequestOptions requestOptions, Context context); @Post("/three") @ExpectedResponses({ 204 }) @@ -80,7 +79,7 @@ Response oneSync(@HostParam("endpoint") String endpoint, @HostParam("clien @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Mono> three(@HostParam("endpoint") String endpoint, @HostParam("client") String client, - @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + RequestOptions requestOptions, Context context); @Post("/three") @ExpectedResponses({ 204 }) @@ -89,7 +88,7 @@ Mono> three(@HostParam("endpoint") String endpoint, @HostParam("c @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Response threeSync(@HostParam("endpoint") String endpoint, @HostParam("client") String client, - @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + RequestOptions requestOptions, Context context); @Post("/four") @ExpectedResponses({ 204 }) @@ -98,7 +97,7 @@ Response threeSync(@HostParam("endpoint") String endpoint, @HostParam("cli @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Mono> four(@HostParam("endpoint") String endpoint, @HostParam("client") String client, - @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + RequestOptions requestOptions, Context context); @Post("/four") @ExpectedResponses({ 204 }) @@ -107,7 +106,7 @@ Mono> four(@HostParam("endpoint") String endpoint, @HostParam("cl @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Response fourSync(@HostParam("endpoint") String endpoint, @HostParam("client") String client, - @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + RequestOptions requestOptions, Context context); } /** @@ -122,9 +121,8 @@ Response fourSync(@HostParam("endpoint") String endpoint, @HostParam("clie */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> oneWithResponseAsync(RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.one(this.client.getEndpoint(), this.client.getClient(), accept, - requestOptions, context)); + return FluxUtil.withContext( + context -> service.one(this.client.getEndpoint(), this.client.getClient(), requestOptions, context)); } /** @@ -139,9 +137,7 @@ public Mono> oneWithResponseAsync(RequestOptions requestOptions) */ @ServiceMethod(returns = ReturnType.SINGLE) public Response oneWithResponse(RequestOptions requestOptions) { - final String accept = "application/json"; - return service.oneSync(this.client.getEndpoint(), this.client.getClient(), accept, requestOptions, - Context.NONE); + return service.oneSync(this.client.getEndpoint(), this.client.getClient(), requestOptions, Context.NONE); } /** @@ -156,9 +152,8 @@ public Response oneWithResponse(RequestOptions requestOptions) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> threeWithResponseAsync(RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.three(this.client.getEndpoint(), this.client.getClient(), accept, - requestOptions, context)); + return FluxUtil.withContext( + context -> service.three(this.client.getEndpoint(), this.client.getClient(), requestOptions, context)); } /** @@ -173,9 +168,7 @@ public Mono> threeWithResponseAsync(RequestOptions requestOptions */ @ServiceMethod(returns = ReturnType.SINGLE) public Response threeWithResponse(RequestOptions requestOptions) { - final String accept = "application/json"; - return service.threeSync(this.client.getEndpoint(), this.client.getClient(), accept, requestOptions, - Context.NONE); + return service.threeSync(this.client.getEndpoint(), this.client.getClient(), requestOptions, Context.NONE); } /** @@ -190,9 +183,8 @@ public Response threeWithResponse(RequestOptions requestOptions) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> fourWithResponseAsync(RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.four(this.client.getEndpoint(), this.client.getClient(), accept, - requestOptions, context)); + return FluxUtil.withContext( + context -> service.four(this.client.getEndpoint(), this.client.getClient(), requestOptions, context)); } /** @@ -207,8 +199,6 @@ public Mono> fourWithResponseAsync(RequestOptions requestOptions) */ @ServiceMethod(returns = ReturnType.SINGLE) public Response fourWithResponse(RequestOptions requestOptions) { - final String accept = "application/json"; - return service.fourSync(this.client.getEndpoint(), this.client.getClient(), accept, requestOptions, - Context.NONE); + return service.fourSync(this.client.getEndpoint(), this.client.getClient(), requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/client/structure/service/implementation/Group2sImpl.java b/typespec-tests/src/main/java/com/client/structure/service/implementation/Group2sImpl.java index 44db47a66c..01e5b55919 100644 --- a/typespec-tests/src/main/java/com/client/structure/service/implementation/Group2sImpl.java +++ b/typespec-tests/src/main/java/com/client/structure/service/implementation/Group2sImpl.java @@ -5,7 +5,6 @@ package com.client.structure.service.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.Post; @@ -62,7 +61,7 @@ public interface Group2sService { @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Mono> two(@HostParam("endpoint") String endpoint, @HostParam("client") String client, - @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + RequestOptions requestOptions, Context context); @Post("/two") @ExpectedResponses({ 204 }) @@ -71,7 +70,7 @@ Mono> two(@HostParam("endpoint") String endpoint, @HostParam("cli @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Response twoSync(@HostParam("endpoint") String endpoint, @HostParam("client") String client, - @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + RequestOptions requestOptions, Context context); @Post("/five") @ExpectedResponses({ 204 }) @@ -80,7 +79,7 @@ Response twoSync(@HostParam("endpoint") String endpoint, @HostParam("clien @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Mono> five(@HostParam("endpoint") String endpoint, @HostParam("client") String client, - @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + RequestOptions requestOptions, Context context); @Post("/five") @ExpectedResponses({ 204 }) @@ -89,7 +88,7 @@ Mono> five(@HostParam("endpoint") String endpoint, @HostParam("cl @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Response fiveSync(@HostParam("endpoint") String endpoint, @HostParam("client") String client, - @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + RequestOptions requestOptions, Context context); @Post("/six") @ExpectedResponses({ 204 }) @@ -98,7 +97,7 @@ Response fiveSync(@HostParam("endpoint") String endpoint, @HostParam("clie @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Mono> six(@HostParam("endpoint") String endpoint, @HostParam("client") String client, - @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + RequestOptions requestOptions, Context context); @Post("/six") @ExpectedResponses({ 204 }) @@ -107,7 +106,7 @@ Mono> six(@HostParam("endpoint") String endpoint, @HostParam("cli @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Response sixSync(@HostParam("endpoint") String endpoint, @HostParam("client") String client, - @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + RequestOptions requestOptions, Context context); } /** @@ -122,9 +121,8 @@ Response sixSync(@HostParam("endpoint") String endpoint, @HostParam("clien */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> twoWithResponseAsync(RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.two(this.client.getEndpoint(), this.client.getClient(), accept, - requestOptions, context)); + return FluxUtil.withContext( + context -> service.two(this.client.getEndpoint(), this.client.getClient(), requestOptions, context)); } /** @@ -139,9 +137,7 @@ public Mono> twoWithResponseAsync(RequestOptions requestOptions) */ @ServiceMethod(returns = ReturnType.SINGLE) public Response twoWithResponse(RequestOptions requestOptions) { - final String accept = "application/json"; - return service.twoSync(this.client.getEndpoint(), this.client.getClient(), accept, requestOptions, - Context.NONE); + return service.twoSync(this.client.getEndpoint(), this.client.getClient(), requestOptions, Context.NONE); } /** @@ -156,9 +152,8 @@ public Response twoWithResponse(RequestOptions requestOptions) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> fiveWithResponseAsync(RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.five(this.client.getEndpoint(), this.client.getClient(), accept, - requestOptions, context)); + return FluxUtil.withContext( + context -> service.five(this.client.getEndpoint(), this.client.getClient(), requestOptions, context)); } /** @@ -173,9 +168,7 @@ public Mono> fiveWithResponseAsync(RequestOptions requestOptions) */ @ServiceMethod(returns = ReturnType.SINGLE) public Response fiveWithResponse(RequestOptions requestOptions) { - final String accept = "application/json"; - return service.fiveSync(this.client.getEndpoint(), this.client.getClient(), accept, requestOptions, - Context.NONE); + return service.fiveSync(this.client.getEndpoint(), this.client.getClient(), requestOptions, Context.NONE); } /** @@ -190,9 +183,8 @@ public Response fiveWithResponse(RequestOptions requestOptions) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> sixWithResponseAsync(RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.six(this.client.getEndpoint(), this.client.getClient(), accept, - requestOptions, context)); + return FluxUtil.withContext( + context -> service.six(this.client.getEndpoint(), this.client.getClient(), requestOptions, context)); } /** @@ -207,8 +199,6 @@ public Mono> sixWithResponseAsync(RequestOptions requestOptions) */ @ServiceMethod(returns = ReturnType.SINGLE) public Response sixWithResponse(RequestOptions requestOptions) { - final String accept = "application/json"; - return service.sixSync(this.client.getEndpoint(), this.client.getClient(), accept, requestOptions, - Context.NONE); + return service.sixSync(this.client.getEndpoint(), this.client.getClient(), requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/client/structure/service/implementation/Group3sImpl.java b/typespec-tests/src/main/java/com/client/structure/service/implementation/Group3sImpl.java index 19df9b6a82..f24593118f 100644 --- a/typespec-tests/src/main/java/com/client/structure/service/implementation/Group3sImpl.java +++ b/typespec-tests/src/main/java/com/client/structure/service/implementation/Group3sImpl.java @@ -5,7 +5,6 @@ package com.client.structure.service.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.Post; @@ -62,7 +61,7 @@ public interface Group3sService { @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Mono> two(@HostParam("endpoint") String endpoint, @HostParam("client") String client, - @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + RequestOptions requestOptions, Context context); @Post("/two") @ExpectedResponses({ 204 }) @@ -71,7 +70,7 @@ Mono> two(@HostParam("endpoint") String endpoint, @HostParam("cli @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Response twoSync(@HostParam("endpoint") String endpoint, @HostParam("client") String client, - @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + RequestOptions requestOptions, Context context); @Post("/three") @ExpectedResponses({ 204 }) @@ -80,7 +79,7 @@ Response twoSync(@HostParam("endpoint") String endpoint, @HostParam("clien @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Mono> three(@HostParam("endpoint") String endpoint, @HostParam("client") String client, - @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + RequestOptions requestOptions, Context context); @Post("/three") @ExpectedResponses({ 204 }) @@ -89,7 +88,7 @@ Mono> three(@HostParam("endpoint") String endpoint, @HostParam("c @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Response threeSync(@HostParam("endpoint") String endpoint, @HostParam("client") String client, - @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + RequestOptions requestOptions, Context context); } /** @@ -104,9 +103,8 @@ Response threeSync(@HostParam("endpoint") String endpoint, @HostParam("cli */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> twoWithResponseAsync(RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.two(this.client.getEndpoint(), this.client.getClient(), accept, - requestOptions, context)); + return FluxUtil.withContext( + context -> service.two(this.client.getEndpoint(), this.client.getClient(), requestOptions, context)); } /** @@ -121,9 +119,7 @@ public Mono> twoWithResponseAsync(RequestOptions requestOptions) */ @ServiceMethod(returns = ReturnType.SINGLE) public Response twoWithResponse(RequestOptions requestOptions) { - final String accept = "application/json"; - return service.twoSync(this.client.getEndpoint(), this.client.getClient(), accept, requestOptions, - Context.NONE); + return service.twoSync(this.client.getEndpoint(), this.client.getClient(), requestOptions, Context.NONE); } /** @@ -138,9 +134,8 @@ public Response twoWithResponse(RequestOptions requestOptions) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> threeWithResponseAsync(RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.three(this.client.getEndpoint(), this.client.getClient(), accept, - requestOptions, context)); + return FluxUtil.withContext( + context -> service.three(this.client.getEndpoint(), this.client.getClient(), requestOptions, context)); } /** @@ -155,8 +150,6 @@ public Mono> threeWithResponseAsync(RequestOptions requestOptions */ @ServiceMethod(returns = ReturnType.SINGLE) public Response threeWithResponse(RequestOptions requestOptions) { - final String accept = "application/json"; - return service.threeSync(this.client.getEndpoint(), this.client.getClient(), accept, requestOptions, - Context.NONE); + return service.threeSync(this.client.getEndpoint(), this.client.getClient(), requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/client/structure/service/implementation/Group4sImpl.java b/typespec-tests/src/main/java/com/client/structure/service/implementation/Group4sImpl.java index 0f1e01d3aa..e7c54920b9 100644 --- a/typespec-tests/src/main/java/com/client/structure/service/implementation/Group4sImpl.java +++ b/typespec-tests/src/main/java/com/client/structure/service/implementation/Group4sImpl.java @@ -5,7 +5,6 @@ package com.client.structure.service.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.Post; @@ -62,7 +61,7 @@ public interface Group4sService { @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Mono> four(@HostParam("endpoint") String endpoint, @HostParam("client") String client, - @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + RequestOptions requestOptions, Context context); @Post("/four") @ExpectedResponses({ 204 }) @@ -71,7 +70,7 @@ Mono> four(@HostParam("endpoint") String endpoint, @HostParam("cl @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Response fourSync(@HostParam("endpoint") String endpoint, @HostParam("client") String client, - @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + RequestOptions requestOptions, Context context); } /** @@ -86,9 +85,8 @@ Response fourSync(@HostParam("endpoint") String endpoint, @HostParam("clie */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> fourWithResponseAsync(RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.four(this.client.getEndpoint(), this.client.getClient(), accept, - requestOptions, context)); + return FluxUtil.withContext( + context -> service.four(this.client.getEndpoint(), this.client.getClient(), requestOptions, context)); } /** @@ -103,8 +101,6 @@ public Mono> fourWithResponseAsync(RequestOptions requestOptions) */ @ServiceMethod(returns = ReturnType.SINGLE) public Response fourWithResponse(RequestOptions requestOptions) { - final String accept = "application/json"; - return service.fourSync(this.client.getEndpoint(), this.client.getClient(), accept, requestOptions, - Context.NONE); + return service.fourSync(this.client.getEndpoint(), this.client.getClient(), requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/client/structure/service/implementation/Group5sImpl.java b/typespec-tests/src/main/java/com/client/structure/service/implementation/Group5sImpl.java index 354453123a..30f45f556a 100644 --- a/typespec-tests/src/main/java/com/client/structure/service/implementation/Group5sImpl.java +++ b/typespec-tests/src/main/java/com/client/structure/service/implementation/Group5sImpl.java @@ -5,7 +5,6 @@ package com.client.structure.service.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.Post; @@ -62,7 +61,7 @@ public interface Group5sService { @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Mono> six(@HostParam("endpoint") String endpoint, @HostParam("client") String client, - @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + RequestOptions requestOptions, Context context); @Post("/six") @ExpectedResponses({ 204 }) @@ -71,7 +70,7 @@ Mono> six(@HostParam("endpoint") String endpoint, @HostParam("cli @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Response sixSync(@HostParam("endpoint") String endpoint, @HostParam("client") String client, - @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + RequestOptions requestOptions, Context context); } /** @@ -86,9 +85,8 @@ Response sixSync(@HostParam("endpoint") String endpoint, @HostParam("clien */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> sixWithResponseAsync(RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.six(this.client.getEndpoint(), this.client.getClient(), accept, - requestOptions, context)); + return FluxUtil.withContext( + context -> service.six(this.client.getEndpoint(), this.client.getClient(), requestOptions, context)); } /** @@ -103,8 +101,6 @@ public Mono> sixWithResponseAsync(RequestOptions requestOptions) */ @ServiceMethod(returns = ReturnType.SINGLE) public Response sixWithResponse(RequestOptions requestOptions) { - final String accept = "application/json"; - return service.sixSync(this.client.getEndpoint(), this.client.getClient(), accept, requestOptions, - Context.NONE); + return service.sixSync(this.client.getEndpoint(), this.client.getClient(), requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/client/structure/service/implementation/GroupsImpl.java b/typespec-tests/src/main/java/com/client/structure/service/implementation/GroupsImpl.java index a2b4164e04..3d53989732 100644 --- a/typespec-tests/src/main/java/com/client/structure/service/implementation/GroupsImpl.java +++ b/typespec-tests/src/main/java/com/client/structure/service/implementation/GroupsImpl.java @@ -5,7 +5,6 @@ package com.client.structure.service.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.Post; @@ -62,7 +61,7 @@ public interface GroupsService { @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Mono> renamedTwo(@HostParam("endpoint") String endpoint, @HostParam("client") String client, - @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + RequestOptions requestOptions, Context context); @Post("/two") @ExpectedResponses({ 204 }) @@ -71,7 +70,7 @@ Mono> renamedTwo(@HostParam("endpoint") String endpoint, @HostPar @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Response renamedTwoSync(@HostParam("endpoint") String endpoint, @HostParam("client") String client, - @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + RequestOptions requestOptions, Context context); @Post("/four") @ExpectedResponses({ 204 }) @@ -80,7 +79,7 @@ Response renamedTwoSync(@HostParam("endpoint") String endpoint, @HostParam @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Mono> renamedFour(@HostParam("endpoint") String endpoint, @HostParam("client") String client, - @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + RequestOptions requestOptions, Context context); @Post("/four") @ExpectedResponses({ 204 }) @@ -89,7 +88,7 @@ Mono> renamedFour(@HostParam("endpoint") String endpoint, @HostPa @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Response renamedFourSync(@HostParam("endpoint") String endpoint, @HostParam("client") String client, - @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + RequestOptions requestOptions, Context context); @Post("/six") @ExpectedResponses({ 204 }) @@ -98,7 +97,7 @@ Response renamedFourSync(@HostParam("endpoint") String endpoint, @HostPara @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Mono> renamedSix(@HostParam("endpoint") String endpoint, @HostParam("client") String client, - @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + RequestOptions requestOptions, Context context); @Post("/six") @ExpectedResponses({ 204 }) @@ -107,7 +106,7 @@ Mono> renamedSix(@HostParam("endpoint") String endpoint, @HostPar @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Response renamedSixSync(@HostParam("endpoint") String endpoint, @HostParam("client") String client, - @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + RequestOptions requestOptions, Context context); } /** @@ -122,9 +121,8 @@ Response renamedSixSync(@HostParam("endpoint") String endpoint, @HostParam */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> renamedTwoWithResponseAsync(RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.renamedTwo(this.client.getEndpoint(), this.client.getClient(), - accept, requestOptions, context)); + return FluxUtil.withContext( + context -> service.renamedTwo(this.client.getEndpoint(), this.client.getClient(), requestOptions, context)); } /** @@ -139,9 +137,7 @@ public Mono> renamedTwoWithResponseAsync(RequestOptions requestOp */ @ServiceMethod(returns = ReturnType.SINGLE) public Response renamedTwoWithResponse(RequestOptions requestOptions) { - final String accept = "application/json"; - return service.renamedTwoSync(this.client.getEndpoint(), this.client.getClient(), accept, requestOptions, - Context.NONE); + return service.renamedTwoSync(this.client.getEndpoint(), this.client.getClient(), requestOptions, Context.NONE); } /** @@ -156,9 +152,8 @@ public Response renamedTwoWithResponse(RequestOptions requestOptions) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> renamedFourWithResponseAsync(RequestOptions requestOptions) { - final String accept = "application/json"; return FluxUtil.withContext(context -> service.renamedFour(this.client.getEndpoint(), this.client.getClient(), - accept, requestOptions, context)); + requestOptions, context)); } /** @@ -173,8 +168,7 @@ public Mono> renamedFourWithResponseAsync(RequestOptions requestO */ @ServiceMethod(returns = ReturnType.SINGLE) public Response renamedFourWithResponse(RequestOptions requestOptions) { - final String accept = "application/json"; - return service.renamedFourSync(this.client.getEndpoint(), this.client.getClient(), accept, requestOptions, + return service.renamedFourSync(this.client.getEndpoint(), this.client.getClient(), requestOptions, Context.NONE); } @@ -190,9 +184,8 @@ public Response renamedFourWithResponse(RequestOptions requestOptions) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> renamedSixWithResponseAsync(RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.renamedSix(this.client.getEndpoint(), this.client.getClient(), - accept, requestOptions, context)); + return FluxUtil.withContext( + context -> service.renamedSix(this.client.getEndpoint(), this.client.getClient(), requestOptions, context)); } /** @@ -207,8 +200,6 @@ public Mono> renamedSixWithResponseAsync(RequestOptions requestOp */ @ServiceMethod(returns = ReturnType.SINGLE) public Response renamedSixWithResponse(RequestOptions requestOptions) { - final String accept = "application/json"; - return service.renamedSixSync(this.client.getEndpoint(), this.client.getClient(), accept, requestOptions, - Context.NONE); + return service.renamedSixSync(this.client.getEndpoint(), this.client.getClient(), requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/client/structure/service/implementation/QuxBarsImpl.java b/typespec-tests/src/main/java/com/client/structure/service/implementation/QuxBarsImpl.java index 04b716e90d..c1fd91c812 100644 --- a/typespec-tests/src/main/java/com/client/structure/service/implementation/QuxBarsImpl.java +++ b/typespec-tests/src/main/java/com/client/structure/service/implementation/QuxBarsImpl.java @@ -5,7 +5,6 @@ package com.client.structure.service.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.Post; @@ -62,7 +61,7 @@ public interface QuxBarsService { @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Mono> nine(@HostParam("endpoint") String endpoint, @HostParam("client") String client, - @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + RequestOptions requestOptions, Context context); @Post("/nine") @ExpectedResponses({ 204 }) @@ -71,7 +70,7 @@ Mono> nine(@HostParam("endpoint") String endpoint, @HostParam("cl @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Response nineSync(@HostParam("endpoint") String endpoint, @HostParam("client") String client, - @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + RequestOptions requestOptions, Context context); } /** @@ -86,9 +85,8 @@ Response nineSync(@HostParam("endpoint") String endpoint, @HostParam("clie */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> nineWithResponseAsync(RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.nine(this.client.getEndpoint(), this.client.getClient(), accept, - requestOptions, context)); + return FluxUtil.withContext( + context -> service.nine(this.client.getEndpoint(), this.client.getClient(), requestOptions, context)); } /** @@ -103,8 +101,6 @@ public Mono> nineWithResponseAsync(RequestOptions requestOptions) */ @ServiceMethod(returns = ReturnType.SINGLE) public Response nineWithResponse(RequestOptions requestOptions) { - final String accept = "application/json"; - return service.nineSync(this.client.getEndpoint(), this.client.getClient(), accept, requestOptions, - Context.NONE); + return service.nineSync(this.client.getEndpoint(), this.client.getClient(), requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/client/structure/service/implementation/QuxesImpl.java b/typespec-tests/src/main/java/com/client/structure/service/implementation/QuxesImpl.java index 4ef2e29bea..7ef995cdaf 100644 --- a/typespec-tests/src/main/java/com/client/structure/service/implementation/QuxesImpl.java +++ b/typespec-tests/src/main/java/com/client/structure/service/implementation/QuxesImpl.java @@ -5,7 +5,6 @@ package com.client.structure.service.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.Post; @@ -62,7 +61,7 @@ public interface QuxesService { @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Mono> eight(@HostParam("endpoint") String endpoint, @HostParam("client") String client, - @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + RequestOptions requestOptions, Context context); @Post("/eight") @ExpectedResponses({ 204 }) @@ -71,7 +70,7 @@ Mono> eight(@HostParam("endpoint") String endpoint, @HostParam("c @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Response eightSync(@HostParam("endpoint") String endpoint, @HostParam("client") String client, - @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + RequestOptions requestOptions, Context context); } /** @@ -86,9 +85,8 @@ Response eightSync(@HostParam("endpoint") String endpoint, @HostParam("cli */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> eightWithResponseAsync(RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.eight(this.client.getEndpoint(), this.client.getClient(), accept, - requestOptions, context)); + return FluxUtil.withContext( + context -> service.eight(this.client.getEndpoint(), this.client.getClient(), requestOptions, context)); } /** @@ -103,8 +101,6 @@ public Mono> eightWithResponseAsync(RequestOptions requestOptions */ @ServiceMethod(returns = ReturnType.SINGLE) public Response eightWithResponse(RequestOptions requestOptions) { - final String accept = "application/json"; - return service.eightSync(this.client.getEndpoint(), this.client.getClient(), accept, requestOptions, - Context.NONE); + return service.eightSync(this.client.getEndpoint(), this.client.getClient(), requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/client/structure/service/implementation/RenamedOperationClientImpl.java b/typespec-tests/src/main/java/com/client/structure/service/implementation/RenamedOperationClientImpl.java index 2c13fe09ce..a0727fb3f3 100644 --- a/typespec-tests/src/main/java/com/client/structure/service/implementation/RenamedOperationClientImpl.java +++ b/typespec-tests/src/main/java/com/client/structure/service/implementation/RenamedOperationClientImpl.java @@ -5,7 +5,6 @@ package com.client.structure.service.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.Post; @@ -164,7 +163,7 @@ public interface RenamedOperationClientService { @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Mono> renamedOne(@HostParam("endpoint") String endpoint, @HostParam("client") String client, - @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + RequestOptions requestOptions, Context context); @Post("/one") @ExpectedResponses({ 204 }) @@ -173,7 +172,7 @@ Mono> renamedOne(@HostParam("endpoint") String endpoint, @HostPar @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Response renamedOneSync(@HostParam("endpoint") String endpoint, @HostParam("client") String client, - @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + RequestOptions requestOptions, Context context); @Post("/three") @ExpectedResponses({ 204 }) @@ -182,7 +181,7 @@ Response renamedOneSync(@HostParam("endpoint") String endpoint, @HostParam @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Mono> renamedThree(@HostParam("endpoint") String endpoint, @HostParam("client") String client, - @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + RequestOptions requestOptions, Context context); @Post("/three") @ExpectedResponses({ 204 }) @@ -191,7 +190,7 @@ Mono> renamedThree(@HostParam("endpoint") String endpoint, @HostP @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Response renamedThreeSync(@HostParam("endpoint") String endpoint, @HostParam("client") String client, - @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + RequestOptions requestOptions, Context context); @Post("/five") @ExpectedResponses({ 204 }) @@ -200,7 +199,7 @@ Response renamedThreeSync(@HostParam("endpoint") String endpoint, @HostPar @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Mono> renamedFive(@HostParam("endpoint") String endpoint, @HostParam("client") String client, - @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + RequestOptions requestOptions, Context context); @Post("/five") @ExpectedResponses({ 204 }) @@ -209,7 +208,7 @@ Mono> renamedFive(@HostParam("endpoint") String endpoint, @HostPa @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Response renamedFiveSync(@HostParam("endpoint") String endpoint, @HostParam("client") String client, - @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + RequestOptions requestOptions, Context context); } /** @@ -224,9 +223,8 @@ Response renamedFiveSync(@HostParam("endpoint") String endpoint, @HostPara */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> renamedOneWithResponseAsync(RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext( - context -> service.renamedOne(this.getEndpoint(), this.getClient(), accept, requestOptions, context)); + return FluxUtil + .withContext(context -> service.renamedOne(this.getEndpoint(), this.getClient(), requestOptions, context)); } /** @@ -241,8 +239,7 @@ public Mono> renamedOneWithResponseAsync(RequestOptions requestOp */ @ServiceMethod(returns = ReturnType.SINGLE) public Response renamedOneWithResponse(RequestOptions requestOptions) { - final String accept = "application/json"; - return service.renamedOneSync(this.getEndpoint(), this.getClient(), accept, requestOptions, Context.NONE); + return service.renamedOneSync(this.getEndpoint(), this.getClient(), requestOptions, Context.NONE); } /** @@ -257,9 +254,8 @@ public Response renamedOneWithResponse(RequestOptions requestOptions) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> renamedThreeWithResponseAsync(RequestOptions requestOptions) { - final String accept = "application/json"; return FluxUtil.withContext( - context -> service.renamedThree(this.getEndpoint(), this.getClient(), accept, requestOptions, context)); + context -> service.renamedThree(this.getEndpoint(), this.getClient(), requestOptions, context)); } /** @@ -274,8 +270,7 @@ public Mono> renamedThreeWithResponseAsync(RequestOptions request */ @ServiceMethod(returns = ReturnType.SINGLE) public Response renamedThreeWithResponse(RequestOptions requestOptions) { - final String accept = "application/json"; - return service.renamedThreeSync(this.getEndpoint(), this.getClient(), accept, requestOptions, Context.NONE); + return service.renamedThreeSync(this.getEndpoint(), this.getClient(), requestOptions, Context.NONE); } /** @@ -290,9 +285,8 @@ public Response renamedThreeWithResponse(RequestOptions requestOptions) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> renamedFiveWithResponseAsync(RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext( - context -> service.renamedFive(this.getEndpoint(), this.getClient(), accept, requestOptions, context)); + return FluxUtil + .withContext(context -> service.renamedFive(this.getEndpoint(), this.getClient(), requestOptions, context)); } /** @@ -307,7 +301,6 @@ public Mono> renamedFiveWithResponseAsync(RequestOptions requestO */ @ServiceMethod(returns = ReturnType.SINGLE) public Response renamedFiveWithResponse(RequestOptions requestOptions) { - final String accept = "application/json"; - return service.renamedFiveSync(this.getEndpoint(), this.getClient(), accept, requestOptions, Context.NONE); + return service.renamedFiveSync(this.getEndpoint(), this.getClient(), requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/client/structure/service/implementation/SecondClientImpl.java b/typespec-tests/src/main/java/com/client/structure/service/implementation/SecondClientImpl.java index 8b81a40577..89bb2a6ada 100644 --- a/typespec-tests/src/main/java/com/client/structure/service/implementation/SecondClientImpl.java +++ b/typespec-tests/src/main/java/com/client/structure/service/implementation/SecondClientImpl.java @@ -5,7 +5,6 @@ package com.client.structure.service.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.Post; @@ -162,7 +161,7 @@ public interface SecondClientService { @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Mono> five(@HostParam("endpoint") String endpoint, @HostParam("client") String client, - @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + RequestOptions requestOptions, Context context); @Post("/five") @ExpectedResponses({ 204 }) @@ -171,7 +170,7 @@ Mono> five(@HostParam("endpoint") String endpoint, @HostParam("cl @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Response fiveSync(@HostParam("endpoint") String endpoint, @HostParam("client") String client, - @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + RequestOptions requestOptions, Context context); } /** @@ -186,9 +185,8 @@ Response fiveSync(@HostParam("endpoint") String endpoint, @HostParam("clie */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> fiveWithResponseAsync(RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext( - context -> service.five(this.getEndpoint(), this.getClient(), accept, requestOptions, context)); + return FluxUtil + .withContext(context -> service.five(this.getEndpoint(), this.getClient(), requestOptions, context)); } /** @@ -203,7 +201,6 @@ public Mono> fiveWithResponseAsync(RequestOptions requestOptions) */ @ServiceMethod(returns = ReturnType.SINGLE) public Response fiveWithResponse(RequestOptions requestOptions) { - final String accept = "application/json"; - return service.fiveSync(this.getEndpoint(), this.getClient(), accept, requestOptions, Context.NONE); + return service.fiveSync(this.getEndpoint(), this.getClient(), requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/client/structure/service/implementation/ServiceClientClientImpl.java b/typespec-tests/src/main/java/com/client/structure/service/implementation/ServiceClientClientImpl.java index 83b972b012..ffe7896433 100644 --- a/typespec-tests/src/main/java/com/client/structure/service/implementation/ServiceClientClientImpl.java +++ b/typespec-tests/src/main/java/com/client/structure/service/implementation/ServiceClientClientImpl.java @@ -5,7 +5,6 @@ package com.client.structure.service.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.Post; @@ -224,7 +223,7 @@ public interface ServiceClientClientService { @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Mono> one(@HostParam("endpoint") String endpoint, @HostParam("client") String client, - @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + RequestOptions requestOptions, Context context); @Post("/one") @ExpectedResponses({ 204 }) @@ -233,7 +232,7 @@ Mono> one(@HostParam("endpoint") String endpoint, @HostParam("cli @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Response oneSync(@HostParam("endpoint") String endpoint, @HostParam("client") String client, - @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + RequestOptions requestOptions, Context context); @Post("/two") @ExpectedResponses({ 204 }) @@ -242,7 +241,7 @@ Response oneSync(@HostParam("endpoint") String endpoint, @HostParam("clien @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Mono> two(@HostParam("endpoint") String endpoint, @HostParam("client") String client, - @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + RequestOptions requestOptions, Context context); @Post("/two") @ExpectedResponses({ 204 }) @@ -251,7 +250,7 @@ Mono> two(@HostParam("endpoint") String endpoint, @HostParam("cli @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Response twoSync(@HostParam("endpoint") String endpoint, @HostParam("client") String client, - @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + RequestOptions requestOptions, Context context); } /** @@ -266,9 +265,8 @@ Response twoSync(@HostParam("endpoint") String endpoint, @HostParam("clien */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> oneWithResponseAsync(RequestOptions requestOptions) { - final String accept = "application/json"; return FluxUtil - .withContext(context -> service.one(this.getEndpoint(), this.getClient(), accept, requestOptions, context)); + .withContext(context -> service.one(this.getEndpoint(), this.getClient(), requestOptions, context)); } /** @@ -283,8 +281,7 @@ public Mono> oneWithResponseAsync(RequestOptions requestOptions) */ @ServiceMethod(returns = ReturnType.SINGLE) public Response oneWithResponse(RequestOptions requestOptions) { - final String accept = "application/json"; - return service.oneSync(this.getEndpoint(), this.getClient(), accept, requestOptions, Context.NONE); + return service.oneSync(this.getEndpoint(), this.getClient(), requestOptions, Context.NONE); } /** @@ -299,9 +296,8 @@ public Response oneWithResponse(RequestOptions requestOptions) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> twoWithResponseAsync(RequestOptions requestOptions) { - final String accept = "application/json"; return FluxUtil - .withContext(context -> service.two(this.getEndpoint(), this.getClient(), accept, requestOptions, context)); + .withContext(context -> service.two(this.getEndpoint(), this.getClient(), requestOptions, context)); } /** @@ -316,7 +312,6 @@ public Mono> twoWithResponseAsync(RequestOptions requestOptions) */ @ServiceMethod(returns = ReturnType.SINGLE) public Response twoWithResponse(RequestOptions requestOptions) { - final String accept = "application/json"; - return service.twoSync(this.getEndpoint(), this.getClient(), accept, requestOptions, Context.NONE); + return service.twoSync(this.getEndpoint(), this.getClient(), requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/encode/bytes/BytesClientBuilder.java b/typespec-tests/src/main/java/com/encode/bytes/BytesClientBuilder.java index aab04fcddc..df2b8d0061 100644 --- a/typespec-tests/src/main/java/com/encode/bytes/BytesClientBuilder.java +++ b/typespec-tests/src/main/java/com/encode/bytes/BytesClientBuilder.java @@ -7,6 +7,7 @@ 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; @@ -51,7 +52,8 @@ HeaderAsyncClient.class, RequestBodyAsyncClient.class, ResponseBodyAsyncClient.class }) -public final class BytesClientBuilder implements HttpTrait, ConfigurationTrait { +public final class BytesClientBuilder implements HttpTrait, ConfigurationTrait, + EndpointTrait { @Generated private static final String SDK_NAME = "name"; @@ -182,6 +184,22 @@ public BytesClientBuilder configuration(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. */ @@ -209,7 +227,9 @@ public BytesClientBuilder retryPolicy(RetryPolicy retryPolicy) { private BytesClientImpl buildInnerClient() { this.validateClient(); HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); - BytesClientImpl client = new BytesClientImpl(localPipeline, JacksonAdapter.createDefaultSerializerAdapter()); + String localEndpoint = (endpoint != null) ? endpoint : "http://localhost:3000"; + BytesClientImpl client + = new BytesClientImpl(localPipeline, JacksonAdapter.createDefaultSerializerAdapter(), localEndpoint); return client; } diff --git a/typespec-tests/src/main/java/com/encode/bytes/implementation/BytesClientImpl.java b/typespec-tests/src/main/java/com/encode/bytes/implementation/BytesClientImpl.java index 99e008537a..e6da811f4e 100644 --- a/typespec-tests/src/main/java/com/encode/bytes/implementation/BytesClientImpl.java +++ b/typespec-tests/src/main/java/com/encode/bytes/implementation/BytesClientImpl.java @@ -15,6 +15,20 @@ * 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. */ @@ -115,19 +129,22 @@ public ResponseBodiesImpl getResponseBodies() { /** * Initializes an instance of BytesClient client. + * + * @param endpoint Service host. */ - public BytesClientImpl() { + public BytesClientImpl(String endpoint) { this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), - JacksonAdapter.createDefaultSerializerAdapter()); + 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) { - this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter()); + public BytesClientImpl(HttpPipeline httpPipeline, String endpoint) { + this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint); } /** @@ -135,10 +152,12 @@ public BytesClientImpl(HttpPipeline httpPipeline) { * * @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) { + 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); diff --git a/typespec-tests/src/main/java/com/encode/bytes/implementation/HeadersImpl.java b/typespec-tests/src/main/java/com/encode/bytes/implementation/HeadersImpl.java index ade2fdb28e..583636ef74 100644 --- a/typespec-tests/src/main/java/com/encode/bytes/implementation/HeadersImpl.java +++ b/typespec-tests/src/main/java/com/encode/bytes/implementation/HeadersImpl.java @@ -8,6 +8,7 @@ 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; @@ -57,7 +58,7 @@ public final class HeadersImpl { * The interface defining all the services for BytesClientHeaders to be used by the proxy service to perform REST * calls. */ - @Host("http://localhost:3000") + @Host("{endpoint}") @ServiceInterface(name = "BytesClientHeaders") public interface HeadersService { @Get("/encode/bytes/header/default") @@ -66,7 +67,7 @@ public interface HeadersService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> defaultMethod(@HeaderParam("value") String value, @HeaderParam("accept") String accept, + Mono> defaultMethod(@HostParam("endpoint") String endpoint, @HeaderParam("value") String value, RequestOptions requestOptions, Context context); @Get("/encode/bytes/header/default") @@ -75,7 +76,7 @@ Mono> defaultMethod(@HeaderParam("value") String value, @HeaderPa @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response defaultMethodSync(@HeaderParam("value") String value, @HeaderParam("accept") String accept, + Response defaultMethodSync(@HostParam("endpoint") String endpoint, @HeaderParam("value") String value, RequestOptions requestOptions, Context context); @Get("/encode/bytes/header/base64") @@ -84,7 +85,7 @@ Response defaultMethodSync(@HeaderParam("value") String value, @HeaderPara @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> base64(@HeaderParam("value") String value, @HeaderParam("accept") String accept, + Mono> base64(@HostParam("endpoint") String endpoint, @HeaderParam("value") String value, RequestOptions requestOptions, Context context); @Get("/encode/bytes/header/base64") @@ -93,7 +94,7 @@ Mono> base64(@HeaderParam("value") String value, @HeaderParam("ac @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response base64Sync(@HeaderParam("value") String value, @HeaderParam("accept") String accept, + Response base64Sync(@HostParam("endpoint") String endpoint, @HeaderParam("value") String value, RequestOptions requestOptions, Context context); @Get("/encode/bytes/header/base64url") @@ -102,7 +103,7 @@ Response base64Sync(@HeaderParam("value") String value, @HeaderParam("acce @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> base64url(@HeaderParam("value") Base64Url value, @HeaderParam("accept") String accept, + Mono> base64url(@HostParam("endpoint") String endpoint, @HeaderParam("value") Base64Url value, RequestOptions requestOptions, Context context); @Get("/encode/bytes/header/base64url") @@ -111,7 +112,7 @@ Mono> base64url(@HeaderParam("value") Base64Url value, @HeaderPar @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response base64urlSync(@HeaderParam("value") Base64Url value, @HeaderParam("accept") String accept, + Response base64urlSync(@HostParam("endpoint") String endpoint, @HeaderParam("value") Base64Url value, RequestOptions requestOptions, Context context); @Get("/encode/bytes/header/base64url-array") @@ -120,7 +121,7 @@ Response base64urlSync(@HeaderParam("value") Base64Url value, @HeaderParam @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> base64urlArray(@HeaderParam("value") String value, @HeaderParam("accept") String accept, + Mono> base64urlArray(@HostParam("endpoint") String endpoint, @HeaderParam("value") String value, RequestOptions requestOptions, Context context); @Get("/encode/bytes/header/base64url-array") @@ -129,7 +130,7 @@ Mono> base64urlArray(@HeaderParam("value") String value, @HeaderP @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response base64urlArraySync(@HeaderParam("value") String value, @HeaderParam("accept") String accept, + Response base64urlArraySync(@HostParam("endpoint") String endpoint, @HeaderParam("value") String value, RequestOptions requestOptions, Context context); } @@ -146,9 +147,9 @@ Response base64urlArraySync(@HeaderParam("value") String value, @HeaderPar */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> defaultMethodWithResponseAsync(byte[] value, RequestOptions requestOptions) { - final String accept = "application/json"; String valueConverted = Base64Util.encodeToString(value); - return FluxUtil.withContext(context -> service.defaultMethod(valueConverted, accept, requestOptions, context)); + return FluxUtil.withContext( + context -> service.defaultMethod(this.client.getEndpoint(), valueConverted, requestOptions, context)); } /** @@ -164,9 +165,8 @@ public Mono> defaultMethodWithResponseAsync(byte[] value, Request */ @ServiceMethod(returns = ReturnType.SINGLE) public Response defaultMethodWithResponse(byte[] value, RequestOptions requestOptions) { - final String accept = "application/json"; String valueConverted = Base64Util.encodeToString(value); - return service.defaultMethodSync(valueConverted, accept, requestOptions, Context.NONE); + return service.defaultMethodSync(this.client.getEndpoint(), valueConverted, requestOptions, Context.NONE); } /** @@ -182,9 +182,9 @@ public Response defaultMethodWithResponse(byte[] value, RequestOptions req */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> base64WithResponseAsync(byte[] value, RequestOptions requestOptions) { - final String accept = "application/json"; String valueConverted = Base64Util.encodeToString(value); - return FluxUtil.withContext(context -> service.base64(valueConverted, accept, requestOptions, context)); + return FluxUtil + .withContext(context -> service.base64(this.client.getEndpoint(), valueConverted, requestOptions, context)); } /** @@ -200,9 +200,8 @@ public Mono> base64WithResponseAsync(byte[] value, RequestOptions */ @ServiceMethod(returns = ReturnType.SINGLE) public Response base64WithResponse(byte[] value, RequestOptions requestOptions) { - final String accept = "application/json"; String valueConverted = Base64Util.encodeToString(value); - return service.base64Sync(valueConverted, accept, requestOptions, Context.NONE); + return service.base64Sync(this.client.getEndpoint(), valueConverted, requestOptions, Context.NONE); } /** @@ -218,9 +217,9 @@ public Response base64WithResponse(byte[] value, RequestOptions requestOpt */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> base64urlWithResponseAsync(byte[] value, RequestOptions requestOptions) { - final String accept = "application/json"; Base64Url valueConverted = Base64Url.encode(value); - return FluxUtil.withContext(context -> service.base64url(valueConverted, accept, requestOptions, context)); + return FluxUtil.withContext( + context -> service.base64url(this.client.getEndpoint(), valueConverted, requestOptions, context)); } /** @@ -236,9 +235,8 @@ public Mono> base64urlWithResponseAsync(byte[] value, RequestOpti */ @ServiceMethod(returns = ReturnType.SINGLE) public Response base64urlWithResponse(byte[] value, RequestOptions requestOptions) { - final String accept = "application/json"; Base64Url valueConverted = Base64Url.encode(value); - return service.base64urlSync(valueConverted, accept, requestOptions, Context.NONE); + return service.base64urlSync(this.client.getEndpoint(), valueConverted, requestOptions, Context.NONE); } /** @@ -254,12 +252,12 @@ public Response base64urlWithResponse(byte[] value, RequestOptions request */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> base64urlArrayWithResponseAsync(List value, RequestOptions requestOptions) { - final String accept = "application/json"; String valueConverted = JacksonAdapter.createDefaultSerializerAdapter() .serializeIterable( value.stream().map(paramItemValue -> Base64Url.encode(paramItemValue)).collect(Collectors.toList()), CollectionFormat.CSV); - return FluxUtil.withContext(context -> service.base64urlArray(valueConverted, accept, requestOptions, context)); + return FluxUtil.withContext( + context -> service.base64urlArray(this.client.getEndpoint(), valueConverted, requestOptions, context)); } /** @@ -275,11 +273,10 @@ public Mono> base64urlArrayWithResponseAsync(List value, */ @ServiceMethod(returns = ReturnType.SINGLE) public Response base64urlArrayWithResponse(List value, RequestOptions requestOptions) { - final String accept = "application/json"; String valueConverted = JacksonAdapter.createDefaultSerializerAdapter() .serializeIterable( value.stream().map(paramItemValue -> Base64Url.encode(paramItemValue)).collect(Collectors.toList()), CollectionFormat.CSV); - return service.base64urlArraySync(valueConverted, accept, requestOptions, Context.NONE); + return service.base64urlArraySync(this.client.getEndpoint(), valueConverted, requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/encode/bytes/implementation/PropertiesImpl.java b/typespec-tests/src/main/java/com/encode/bytes/implementation/PropertiesImpl.java index bbf7991a31..cf13e81e8d 100644 --- a/typespec-tests/src/main/java/com/encode/bytes/implementation/PropertiesImpl.java +++ b/typespec-tests/src/main/java/com/encode/bytes/implementation/PropertiesImpl.java @@ -8,6 +8,7 @@ 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; @@ -54,7 +55,7 @@ public final class PropertiesImpl { * The interface defining all the services for BytesClientProperties to be used by the proxy service to perform REST * calls. */ - @Host("http://localhost:3000") + @Host("{endpoint}") @ServiceInterface(name = "BytesClientPropertie") public interface PropertiesService { @Post("/encode/bytes/property/default") @@ -63,7 +64,8 @@ public interface PropertiesService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> defaultMethod(@HeaderParam("accept") String accept, + 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") @@ -72,7 +74,8 @@ Mono> defaultMethod(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response defaultMethodSync(@HeaderParam("accept") String accept, + 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") @@ -81,7 +84,8 @@ Response defaultMethodSync(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> base64(@HeaderParam("accept") String accept, + 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") @@ -90,7 +94,8 @@ Mono> base64(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response base64Sync(@HeaderParam("accept") String accept, + 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") @@ -99,7 +104,8 @@ Response base64Sync(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> base64url(@HeaderParam("accept") String accept, + 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") @@ -108,7 +114,8 @@ Mono> base64url(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response base64urlSync(@HeaderParam("accept") String accept, + 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") @@ -117,7 +124,8 @@ Response base64urlSync(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> base64urlArray(@HeaderParam("accept") String accept, + 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") @@ -126,7 +134,8 @@ Mono> base64urlArray(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response base64urlArraySync(@HeaderParam("accept") String accept, + Response base64urlArraySync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); } @@ -158,8 +167,10 @@ Response base64urlArraySync(@HeaderParam("accept") String accept, */ @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(accept, body, requestOptions, context)); + return FluxUtil.withContext(context -> service.defaultMethod(this.client.getEndpoint(), contentType, accept, + body, requestOptions, context)); } /** @@ -190,8 +201,10 @@ public Mono> defaultMethodWithResponseAsync(BinaryData body */ @ServiceMethod(returns = ReturnType.SINGLE) public Response defaultMethodWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; final String accept = "application/json"; - return service.defaultMethodSync(accept, body, requestOptions, Context.NONE); + return service.defaultMethodSync(this.client.getEndpoint(), contentType, accept, body, requestOptions, + Context.NONE); } /** @@ -222,8 +235,10 @@ public Response defaultMethodWithResponse(BinaryData body, RequestOp */ @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(accept, body, requestOptions, context)); + return FluxUtil.withContext( + context -> service.base64(this.client.getEndpoint(), contentType, accept, body, requestOptions, context)); } /** @@ -254,8 +269,9 @@ public Mono> base64WithResponseAsync(BinaryData body, Reque */ @ServiceMethod(returns = ReturnType.SINGLE) public Response base64WithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; final String accept = "application/json"; - return service.base64Sync(accept, body, requestOptions, Context.NONE); + return service.base64Sync(this.client.getEndpoint(), contentType, accept, body, requestOptions, Context.NONE); } /** @@ -286,8 +302,10 @@ public Response base64WithResponse(BinaryData body, RequestOptions r */ @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(accept, body, requestOptions, context)); + return FluxUtil.withContext(context -> service.base64url(this.client.getEndpoint(), contentType, accept, body, + requestOptions, context)); } /** @@ -318,8 +336,10 @@ public Mono> base64urlWithResponseAsync(BinaryData body, Re */ @ServiceMethod(returns = ReturnType.SINGLE) public Response base64urlWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; final String accept = "application/json"; - return service.base64urlSync(accept, body, requestOptions, Context.NONE); + return service.base64urlSync(this.client.getEndpoint(), contentType, accept, body, requestOptions, + Context.NONE); } /** @@ -354,8 +374,10 @@ public Response base64urlWithResponse(BinaryData body, RequestOption */ @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(accept, body, requestOptions, context)); + return FluxUtil.withContext(context -> service.base64urlArray(this.client.getEndpoint(), contentType, accept, + body, requestOptions, context)); } /** @@ -390,7 +412,9 @@ public Mono> base64urlArrayWithResponseAsync(BinaryData bod */ @ServiceMethod(returns = ReturnType.SINGLE) public Response base64urlArrayWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; final String accept = "application/json"; - return service.base64urlArraySync(accept, body, requestOptions, Context.NONE); + return service.base64urlArraySync(this.client.getEndpoint(), contentType, accept, body, requestOptions, + Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/encode/bytes/implementation/QueriesImpl.java b/typespec-tests/src/main/java/com/encode/bytes/implementation/QueriesImpl.java index a902ff21d0..238ac4a189 100644 --- a/typespec-tests/src/main/java/com/encode/bytes/implementation/QueriesImpl.java +++ b/typespec-tests/src/main/java/com/encode/bytes/implementation/QueriesImpl.java @@ -6,8 +6,8 @@ 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; @@ -58,7 +58,7 @@ public final class QueriesImpl { * The interface defining all the services for BytesClientQueries to be used by the proxy service to perform REST * calls. */ - @Host("http://localhost:3000") + @Host("{endpoint}") @ServiceInterface(name = "BytesClientQueries") public interface QueriesService { @Get("/encode/bytes/query/default") @@ -67,7 +67,7 @@ public interface QueriesService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> defaultMethod(@QueryParam("value") String value, @HeaderParam("accept") String accept, + Mono> defaultMethod(@HostParam("endpoint") String endpoint, @QueryParam("value") String value, RequestOptions requestOptions, Context context); @Get("/encode/bytes/query/default") @@ -76,7 +76,7 @@ Mono> defaultMethod(@QueryParam("value") String value, @HeaderPar @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response defaultMethodSync(@QueryParam("value") String value, @HeaderParam("accept") String accept, + Response defaultMethodSync(@HostParam("endpoint") String endpoint, @QueryParam("value") String value, RequestOptions requestOptions, Context context); @Get("/encode/bytes/query/base64") @@ -85,7 +85,7 @@ Response defaultMethodSync(@QueryParam("value") String value, @HeaderParam @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> base64(@QueryParam("value") String value, @HeaderParam("accept") String accept, + Mono> base64(@HostParam("endpoint") String endpoint, @QueryParam("value") String value, RequestOptions requestOptions, Context context); @Get("/encode/bytes/query/base64") @@ -94,7 +94,7 @@ Mono> base64(@QueryParam("value") String value, @HeaderParam("acc @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response base64Sync(@QueryParam("value") String value, @HeaderParam("accept") String accept, + Response base64Sync(@HostParam("endpoint") String endpoint, @QueryParam("value") String value, RequestOptions requestOptions, Context context); @Get("/encode/bytes/query/base64url") @@ -103,7 +103,7 @@ Response base64Sync(@QueryParam("value") String value, @HeaderParam("accep @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> base64url(@QueryParam("value") Base64Url value, @HeaderParam("accept") String accept, + Mono> base64url(@HostParam("endpoint") String endpoint, @QueryParam("value") Base64Url value, RequestOptions requestOptions, Context context); @Get("/encode/bytes/query/base64url") @@ -112,7 +112,7 @@ Mono> base64url(@QueryParam("value") Base64Url value, @HeaderPara @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response base64urlSync(@QueryParam("value") Base64Url value, @HeaderParam("accept") String accept, + Response base64urlSync(@HostParam("endpoint") String endpoint, @QueryParam("value") Base64Url value, RequestOptions requestOptions, Context context); @Get("/encode/bytes/query/base64url-array") @@ -121,7 +121,7 @@ Response base64urlSync(@QueryParam("value") Base64Url value, @HeaderParam( @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> base64urlArray(@QueryParam("value") String value, @HeaderParam("accept") String accept, + Mono> base64urlArray(@HostParam("endpoint") String endpoint, @QueryParam("value") String value, RequestOptions requestOptions, Context context); @Get("/encode/bytes/query/base64url-array") @@ -130,7 +130,7 @@ Mono> base64urlArray(@QueryParam("value") String value, @HeaderPa @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response base64urlArraySync(@QueryParam("value") String value, @HeaderParam("accept") String accept, + Response base64urlArraySync(@HostParam("endpoint") String endpoint, @QueryParam("value") String value, RequestOptions requestOptions, Context context); } @@ -147,9 +147,9 @@ Response base64urlArraySync(@QueryParam("value") String value, @HeaderPara */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> defaultMethodWithResponseAsync(byte[] value, RequestOptions requestOptions) { - final String accept = "application/json"; String valueConverted = Base64Util.encodeToString(value); - return FluxUtil.withContext(context -> service.defaultMethod(valueConverted, accept, requestOptions, context)); + return FluxUtil.withContext( + context -> service.defaultMethod(this.client.getEndpoint(), valueConverted, requestOptions, context)); } /** @@ -165,9 +165,8 @@ public Mono> defaultMethodWithResponseAsync(byte[] value, Request */ @ServiceMethod(returns = ReturnType.SINGLE) public Response defaultMethodWithResponse(byte[] value, RequestOptions requestOptions) { - final String accept = "application/json"; String valueConverted = Base64Util.encodeToString(value); - return service.defaultMethodSync(valueConverted, accept, requestOptions, Context.NONE); + return service.defaultMethodSync(this.client.getEndpoint(), valueConverted, requestOptions, Context.NONE); } /** @@ -183,9 +182,9 @@ public Response defaultMethodWithResponse(byte[] value, RequestOptions req */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> base64WithResponseAsync(byte[] value, RequestOptions requestOptions) { - final String accept = "application/json"; String valueConverted = Base64Util.encodeToString(value); - return FluxUtil.withContext(context -> service.base64(valueConverted, accept, requestOptions, context)); + return FluxUtil + .withContext(context -> service.base64(this.client.getEndpoint(), valueConverted, requestOptions, context)); } /** @@ -201,9 +200,8 @@ public Mono> base64WithResponseAsync(byte[] value, RequestOptions */ @ServiceMethod(returns = ReturnType.SINGLE) public Response base64WithResponse(byte[] value, RequestOptions requestOptions) { - final String accept = "application/json"; String valueConverted = Base64Util.encodeToString(value); - return service.base64Sync(valueConverted, accept, requestOptions, Context.NONE); + return service.base64Sync(this.client.getEndpoint(), valueConverted, requestOptions, Context.NONE); } /** @@ -219,9 +217,9 @@ public Response base64WithResponse(byte[] value, RequestOptions requestOpt */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> base64urlWithResponseAsync(byte[] value, RequestOptions requestOptions) { - final String accept = "application/json"; Base64Url valueConverted = Base64Url.encode(value); - return FluxUtil.withContext(context -> service.base64url(valueConverted, accept, requestOptions, context)); + return FluxUtil.withContext( + context -> service.base64url(this.client.getEndpoint(), valueConverted, requestOptions, context)); } /** @@ -237,9 +235,8 @@ public Mono> base64urlWithResponseAsync(byte[] value, RequestOpti */ @ServiceMethod(returns = ReturnType.SINGLE) public Response base64urlWithResponse(byte[] value, RequestOptions requestOptions) { - final String accept = "application/json"; Base64Url valueConverted = Base64Url.encode(value); - return service.base64urlSync(valueConverted, accept, requestOptions, Context.NONE); + return service.base64urlSync(this.client.getEndpoint(), valueConverted, requestOptions, Context.NONE); } /** @@ -255,12 +252,12 @@ public Response base64urlWithResponse(byte[] value, RequestOptions request */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> base64urlArrayWithResponseAsync(List value, RequestOptions requestOptions) { - final String accept = "application/json"; String valueConverted = JacksonAdapter.createDefaultSerializerAdapter() .serializeIterable( value.stream().map(paramItemValue -> Base64Url.encode(paramItemValue)).collect(Collectors.toList()), CollectionFormat.CSV); - return FluxUtil.withContext(context -> service.base64urlArray(valueConverted, accept, requestOptions, context)); + return FluxUtil.withContext( + context -> service.base64urlArray(this.client.getEndpoint(), valueConverted, requestOptions, context)); } /** @@ -276,11 +273,10 @@ public Mono> base64urlArrayWithResponseAsync(List value, */ @ServiceMethod(returns = ReturnType.SINGLE) public Response base64urlArrayWithResponse(List value, RequestOptions requestOptions) { - final String accept = "application/json"; String valueConverted = JacksonAdapter.createDefaultSerializerAdapter() .serializeIterable( value.stream().map(paramItemValue -> Base64Url.encode(paramItemValue)).collect(Collectors.toList()), CollectionFormat.CSV); - return service.base64urlArraySync(valueConverted, accept, requestOptions, Context.NONE); + return service.base64urlArraySync(this.client.getEndpoint(), valueConverted, requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/encode/bytes/implementation/RequestBodiesImpl.java b/typespec-tests/src/main/java/com/encode/bytes/implementation/RequestBodiesImpl.java index 257247ebad..87b035b669 100644 --- a/typespec-tests/src/main/java/com/encode/bytes/implementation/RequestBodiesImpl.java +++ b/typespec-tests/src/main/java/com/encode/bytes/implementation/RequestBodiesImpl.java @@ -8,6 +8,7 @@ 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; @@ -54,7 +55,7 @@ public final class RequestBodiesImpl { * The interface defining all the services for BytesClientRequestBodies to be used by the proxy service to perform * REST calls. */ - @Host("http://localhost:3000") + @Host("{endpoint}") @ServiceInterface(name = "BytesClientRequestBo") public interface RequestBodiesService { @Post("/encode/bytes/body/request/default") @@ -63,8 +64,9 @@ public interface RequestBodiesService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> defaultMethod(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData value, RequestOptions requestOptions, Context context); + 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 }) @@ -72,8 +74,9 @@ Mono> defaultMethod(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response defaultMethodSync(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData value, RequestOptions requestOptions, Context context); + 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 }) @@ -81,8 +84,8 @@ Response defaultMethodSync(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> octetStream(@HeaderParam("content-type") String contentType, - @HeaderParam("accept") String accept, @BodyParam("application/octet-stream") BinaryData value, + 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") @@ -91,8 +94,8 @@ Mono> octetStream(@HeaderParam("content-type") String contentType @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response octetStreamSync(@HeaderParam("content-type") String contentType, - @HeaderParam("accept") String accept, @BodyParam("application/octet-stream") BinaryData value, + 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") @@ -101,8 +104,8 @@ Response octetStreamSync(@HeaderParam("content-type") String contentType, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> customContentType(@HeaderParam("content-type") String contentType, - @HeaderParam("accept") String accept, @BodyParam("image/png") BinaryData value, + 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") @@ -111,8 +114,8 @@ Mono> customContentType(@HeaderParam("content-type") String conte @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response customContentTypeSync(@HeaderParam("content-type") String contentType, - @HeaderParam("accept") String accept, @BodyParam("image/png") BinaryData value, + 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") @@ -121,8 +124,9 @@ Response customContentTypeSync(@HeaderParam("content-type") String content @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> base64(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData value, RequestOptions requestOptions, Context context); + 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 }) @@ -130,7 +134,8 @@ Mono> base64(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response base64Sync(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData value, + 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") @@ -139,8 +144,9 @@ Response base64Sync(@HeaderParam("accept") String accept, @BodyParam("appl @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> base64url(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData value, RequestOptions requestOptions, Context context); + 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 }) @@ -148,8 +154,9 @@ Mono> base64url(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response base64urlSync(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData value, RequestOptions requestOptions, Context context); + Response base64urlSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData value, + RequestOptions requestOptions, Context context); } /** @@ -170,8 +177,9 @@ Response base64urlSync(@HeaderParam("accept") String accept, */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> defaultMethodWithResponseAsync(BinaryData value, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.defaultMethod(accept, value, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.defaultMethod(this.client.getEndpoint(), contentType, value, requestOptions, context)); } /** @@ -192,8 +200,8 @@ public Mono> defaultMethodWithResponseAsync(BinaryData value, Req */ @ServiceMethod(returns = ReturnType.SINGLE) public Response defaultMethodWithResponse(BinaryData value, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.defaultMethodSync(accept, value, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.defaultMethodSync(this.client.getEndpoint(), contentType, value, requestOptions, Context.NONE); } /** @@ -215,9 +223,8 @@ public Response defaultMethodWithResponse(BinaryData value, RequestOptions @ServiceMethod(returns = ReturnType.SINGLE) public Mono> octetStreamWithResponseAsync(BinaryData value, RequestOptions requestOptions) { final String contentType = "application/octet-stream"; - final String accept = "application/json"; - return FluxUtil - .withContext(context -> service.octetStream(contentType, accept, value, requestOptions, context)); + return FluxUtil.withContext( + context -> service.octetStream(this.client.getEndpoint(), contentType, value, requestOptions, context)); } /** @@ -239,8 +246,7 @@ public Mono> octetStreamWithResponseAsync(BinaryData value, Reque @ServiceMethod(returns = ReturnType.SINGLE) public Response octetStreamWithResponse(BinaryData value, RequestOptions requestOptions) { final String contentType = "application/octet-stream"; - final String accept = "application/json"; - return service.octetStreamSync(contentType, accept, value, requestOptions, Context.NONE); + return service.octetStreamSync(this.client.getEndpoint(), contentType, value, requestOptions, Context.NONE); } /** @@ -262,9 +268,8 @@ public Response octetStreamWithResponse(BinaryData value, RequestOptions r @ServiceMethod(returns = ReturnType.SINGLE) public Mono> customContentTypeWithResponseAsync(BinaryData value, RequestOptions requestOptions) { final String contentType = "image/png"; - final String accept = "application/json"; - return FluxUtil - .withContext(context -> service.customContentType(contentType, accept, value, requestOptions, context)); + return FluxUtil.withContext(context -> service.customContentType(this.client.getEndpoint(), contentType, value, + requestOptions, context)); } /** @@ -286,8 +291,8 @@ public Mono> customContentTypeWithResponseAsync(BinaryData value, @ServiceMethod(returns = ReturnType.SINGLE) public Response customContentTypeWithResponse(BinaryData value, RequestOptions requestOptions) { final String contentType = "image/png"; - final String accept = "application/json"; - return service.customContentTypeSync(contentType, accept, value, requestOptions, Context.NONE); + return service.customContentTypeSync(this.client.getEndpoint(), contentType, value, requestOptions, + Context.NONE); } /** @@ -308,8 +313,9 @@ public Response customContentTypeWithResponse(BinaryData value, RequestOpt */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> base64WithResponseAsync(BinaryData value, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.base64(accept, value, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.base64(this.client.getEndpoint(), contentType, value, requestOptions, context)); } /** @@ -330,8 +336,8 @@ public Mono> base64WithResponseAsync(BinaryData value, RequestOpt */ @ServiceMethod(returns = ReturnType.SINGLE) public Response base64WithResponse(BinaryData value, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.base64Sync(accept, value, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.base64Sync(this.client.getEndpoint(), contentType, value, requestOptions, Context.NONE); } /** @@ -352,8 +358,9 @@ public Response base64WithResponse(BinaryData value, RequestOptions reques */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> base64urlWithResponseAsync(BinaryData value, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.base64url(accept, value, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.base64url(this.client.getEndpoint(), contentType, value, requestOptions, context)); } /** @@ -374,7 +381,7 @@ public Mono> base64urlWithResponseAsync(BinaryData value, Request */ @ServiceMethod(returns = ReturnType.SINGLE) public Response base64urlWithResponse(BinaryData value, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.base64urlSync(accept, value, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.base64urlSync(this.client.getEndpoint(), contentType, value, requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/encode/bytes/implementation/ResponseBodiesImpl.java b/typespec-tests/src/main/java/com/encode/bytes/implementation/ResponseBodiesImpl.java index 771602d9f8..8f84bfe688 100644 --- a/typespec-tests/src/main/java/com/encode/bytes/implementation/ResponseBodiesImpl.java +++ b/typespec-tests/src/main/java/com/encode/bytes/implementation/ResponseBodiesImpl.java @@ -8,6 +8,7 @@ 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; @@ -53,7 +54,7 @@ public final class ResponseBodiesImpl { * The interface defining all the services for BytesClientResponseBodies to be used by the proxy service to perform * REST calls. */ - @Host("http://localhost:3000") + @Host("{endpoint}") @ServiceInterface(name = "BytesClientResponseB") public interface ResponseBodiesService { @Get("/encode/bytes/body/response/default") @@ -62,8 +63,8 @@ public interface ResponseBodiesService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> defaultMethod(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Mono> defaultMethod(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Get("/encode/bytes/body/response/default") @ExpectedResponses({ 200 }) @@ -71,8 +72,8 @@ Mono> defaultMethod(@HeaderParam("accept") String accept, R @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response defaultMethodSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Response defaultMethodSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Get("/encode/bytes/body/response/octet-stream") @ExpectedResponses({ 200 }) @@ -80,8 +81,8 @@ Response defaultMethodSync(@HeaderParam("accept") String accept, Req @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> octetStream(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Mono> octetStream(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Get("/encode/bytes/body/response/octet-stream") @ExpectedResponses({ 200 }) @@ -89,8 +90,8 @@ Mono> octetStream(@HeaderParam("accept") String accept, Req @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response octetStreamSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Response octetStreamSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Get("/encode/bytes/body/response/custom-content-type") @ExpectedResponses({ 200 }) @@ -98,8 +99,8 @@ Response octetStreamSync(@HeaderParam("accept") String accept, Reque @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> customContentType(@HeaderParam("accept") String accept, - RequestOptions requestOptions, Context context); + Mono> customContentType(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Get("/encode/bytes/body/response/custom-content-type") @ExpectedResponses({ 200 }) @@ -107,8 +108,8 @@ Mono> customContentType(@HeaderParam("accept") String accep @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response customContentTypeSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Response customContentTypeSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Get("/encode/bytes/body/response/base64") @ExpectedResponses({ 200 }) @@ -116,8 +117,8 @@ Response customContentTypeSync(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> base64(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Mono> base64(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Get("/encode/bytes/body/response/base64") @ExpectedResponses({ 200 }) @@ -125,8 +126,8 @@ Mono> base64(@HeaderParam("accept") String accept, RequestO @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response base64Sync(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Response base64Sync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Get("/encode/bytes/body/response/base64url") @ExpectedResponses({ 200 }) @@ -134,8 +135,8 @@ Response base64Sync(@HeaderParam("accept") String accept, RequestOpt @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> base64url(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Mono> base64url(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Get("/encode/bytes/body/response/base64url") @ExpectedResponses({ 200 }) @@ -143,8 +144,8 @@ Mono> base64url(@HeaderParam("accept") String accept, Reque @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response base64urlSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Response base64urlSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); } /** @@ -165,7 +166,8 @@ Response base64urlSync(@HeaderParam("accept") String accept, Request @ServiceMethod(returns = ReturnType.SINGLE) public Mono> defaultMethodWithResponseAsync(RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.defaultMethod(accept, requestOptions, context)); + return FluxUtil + .withContext(context -> service.defaultMethod(this.client.getEndpoint(), accept, requestOptions, context)); } /** @@ -186,7 +188,7 @@ public Mono> defaultMethodWithResponseAsync(RequestOptions @ServiceMethod(returns = ReturnType.SINGLE) public Response defaultMethodWithResponse(RequestOptions requestOptions) { final String accept = "application/json"; - return service.defaultMethodSync(accept, requestOptions, Context.NONE); + return service.defaultMethodSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); } /** @@ -207,7 +209,8 @@ public Response defaultMethodWithResponse(RequestOptions requestOpti @ServiceMethod(returns = ReturnType.SINGLE) public Mono> octetStreamWithResponseAsync(RequestOptions requestOptions) { final String accept = "application/octet-stream"; - return FluxUtil.withContext(context -> service.octetStream(accept, requestOptions, context)); + return FluxUtil + .withContext(context -> service.octetStream(this.client.getEndpoint(), accept, requestOptions, context)); } /** @@ -228,7 +231,7 @@ public Mono> octetStreamWithResponseAsync(RequestOptions re @ServiceMethod(returns = ReturnType.SINGLE) public Response octetStreamWithResponse(RequestOptions requestOptions) { final String accept = "application/octet-stream"; - return service.octetStreamSync(accept, requestOptions, Context.NONE); + return service.octetStreamSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); } /** @@ -249,7 +252,8 @@ public Response octetStreamWithResponse(RequestOptions requestOption @ServiceMethod(returns = ReturnType.SINGLE) public Mono> customContentTypeWithResponseAsync(RequestOptions requestOptions) { final String accept = "image/png"; - return FluxUtil.withContext(context -> service.customContentType(accept, requestOptions, context)); + return FluxUtil.withContext( + context -> service.customContentType(this.client.getEndpoint(), accept, requestOptions, context)); } /** @@ -270,7 +274,7 @@ public Mono> customContentTypeWithResponseAsync(RequestOpti @ServiceMethod(returns = ReturnType.SINGLE) public Response customContentTypeWithResponse(RequestOptions requestOptions) { final String accept = "image/png"; - return service.customContentTypeSync(accept, requestOptions, Context.NONE); + return service.customContentTypeSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); } /** @@ -291,7 +295,8 @@ public Response customContentTypeWithResponse(RequestOptions request @ServiceMethod(returns = ReturnType.SINGLE) public Mono> base64WithResponseAsync(RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.base64(accept, requestOptions, context)); + return FluxUtil + .withContext(context -> service.base64(this.client.getEndpoint(), accept, requestOptions, context)); } /** @@ -312,7 +317,7 @@ public Mono> base64WithResponseAsync(RequestOptions request @ServiceMethod(returns = ReturnType.SINGLE) public Response base64WithResponse(RequestOptions requestOptions) { final String accept = "application/json"; - return service.base64Sync(accept, requestOptions, Context.NONE); + return service.base64Sync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); } /** @@ -333,7 +338,8 @@ public Response base64WithResponse(RequestOptions requestOptions) { @ServiceMethod(returns = ReturnType.SINGLE) public Mono> base64urlWithResponseAsync(RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.base64url(accept, requestOptions, context)); + return FluxUtil + .withContext(context -> service.base64url(this.client.getEndpoint(), accept, requestOptions, context)); } /** @@ -354,6 +360,6 @@ public Mono> base64urlWithResponseAsync(RequestOptions requ @ServiceMethod(returns = ReturnType.SINGLE) public Response base64urlWithResponse(RequestOptions requestOptions) { final String accept = "application/json"; - return service.base64urlSync(accept, requestOptions, Context.NONE); + return service.base64urlSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/encode/datetime/DatetimeClientBuilder.java b/typespec-tests/src/main/java/com/encode/datetime/DatetimeClientBuilder.java index 515fde9d94..d228837b6a 100644 --- a/typespec-tests/src/main/java/com/encode/datetime/DatetimeClientBuilder.java +++ b/typespec-tests/src/main/java/com/encode/datetime/DatetimeClientBuilder.java @@ -7,6 +7,7 @@ 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; @@ -49,8 +50,8 @@ PropertyAsyncClient.class, HeaderAsyncClient.class, ResponseHeaderAsyncClient.class }) -public final class DatetimeClientBuilder - implements HttpTrait, ConfigurationTrait { +public final class DatetimeClientBuilder implements HttpTrait, + ConfigurationTrait, EndpointTrait { @Generated private static final String SDK_NAME = "name"; @@ -181,6 +182,22 @@ public DatetimeClientBuilder configuration(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. */ @@ -208,8 +225,9 @@ public DatetimeClientBuilder retryPolicy(RetryPolicy retryPolicy) { 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()); + = new DatetimeClientImpl(localPipeline, JacksonAdapter.createDefaultSerializerAdapter(), localEndpoint); return client; } diff --git a/typespec-tests/src/main/java/com/encode/datetime/implementation/DatetimeClientImpl.java b/typespec-tests/src/main/java/com/encode/datetime/implementation/DatetimeClientImpl.java index 9dd82ddfe9..7074d58795 100644 --- a/typespec-tests/src/main/java/com/encode/datetime/implementation/DatetimeClientImpl.java +++ b/typespec-tests/src/main/java/com/encode/datetime/implementation/DatetimeClientImpl.java @@ -15,6 +15,20 @@ * 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. */ @@ -101,19 +115,22 @@ public ResponseHeadersImpl getResponseHeaders() { /** * Initializes an instance of DatetimeClient client. + * + * @param endpoint Service host. */ - public DatetimeClientImpl() { + public DatetimeClientImpl(String endpoint) { this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), - JacksonAdapter.createDefaultSerializerAdapter()); + 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) { - this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter()); + public DatetimeClientImpl(HttpPipeline httpPipeline, String endpoint) { + this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint); } /** @@ -121,10 +138,12 @@ public DatetimeClientImpl(HttpPipeline httpPipeline) { * * @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) { + 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); diff --git a/typespec-tests/src/main/java/com/encode/datetime/implementation/HeadersImpl.java b/typespec-tests/src/main/java/com/encode/datetime/implementation/HeadersImpl.java index 1df2acf9e8..b3357760fe 100644 --- a/typespec-tests/src/main/java/com/encode/datetime/implementation/HeadersImpl.java +++ b/typespec-tests/src/main/java/com/encode/datetime/implementation/HeadersImpl.java @@ -8,6 +8,7 @@ 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; @@ -57,7 +58,7 @@ public final class HeadersImpl { * The interface defining all the services for DatetimeClientHeaders to be used by the proxy service to perform REST * calls. */ - @Host("http://localhost:3000") + @Host("{endpoint}") @ServiceInterface(name = "DatetimeClientHeader") public interface HeadersService { @Get("/encode/datetime/header/default") @@ -66,8 +67,8 @@ public interface HeadersService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> defaultMethod(@HeaderParam("value") DateTimeRfc1123 value, - @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + Mono> defaultMethod(@HostParam("endpoint") String endpoint, + @HeaderParam("value") DateTimeRfc1123 value, RequestOptions requestOptions, Context context); @Get("/encode/datetime/header/default") @ExpectedResponses({ 204 }) @@ -75,8 +76,8 @@ Mono> defaultMethod(@HeaderParam("value") DateTimeRfc1123 value, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response defaultMethodSync(@HeaderParam("value") DateTimeRfc1123 value, - @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + Response defaultMethodSync(@HostParam("endpoint") String endpoint, + @HeaderParam("value") DateTimeRfc1123 value, RequestOptions requestOptions, Context context); @Get("/encode/datetime/header/rfc3339") @ExpectedResponses({ 204 }) @@ -84,7 +85,7 @@ Response defaultMethodSync(@HeaderParam("value") DateTimeRfc1123 value, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> rfc3339(@HeaderParam("value") OffsetDateTime value, @HeaderParam("accept") String accept, + Mono> rfc3339(@HostParam("endpoint") String endpoint, @HeaderParam("value") OffsetDateTime value, RequestOptions requestOptions, Context context); @Get("/encode/datetime/header/rfc3339") @@ -93,7 +94,7 @@ Mono> rfc3339(@HeaderParam("value") OffsetDateTime value, @Header @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response rfc3339Sync(@HeaderParam("value") OffsetDateTime value, @HeaderParam("accept") String accept, + Response rfc3339Sync(@HostParam("endpoint") String endpoint, @HeaderParam("value") OffsetDateTime value, RequestOptions requestOptions, Context context); @Get("/encode/datetime/header/rfc7231") @@ -102,8 +103,8 @@ Response rfc3339Sync(@HeaderParam("value") OffsetDateTime value, @HeaderPa @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> rfc7231(@HeaderParam("value") DateTimeRfc1123 value, @HeaderParam("accept") String accept, - RequestOptions requestOptions, Context context); + Mono> rfc7231(@HostParam("endpoint") String endpoint, + @HeaderParam("value") DateTimeRfc1123 value, RequestOptions requestOptions, Context context); @Get("/encode/datetime/header/rfc7231") @ExpectedResponses({ 204 }) @@ -111,7 +112,7 @@ Mono> rfc7231(@HeaderParam("value") DateTimeRfc1123 value, @Heade @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response rfc7231Sync(@HeaderParam("value") DateTimeRfc1123 value, @HeaderParam("accept") String accept, + Response rfc7231Sync(@HostParam("endpoint") String endpoint, @HeaderParam("value") DateTimeRfc1123 value, RequestOptions requestOptions, Context context); @Get("/encode/datetime/header/unix-timestamp") @@ -120,7 +121,7 @@ Response rfc7231Sync(@HeaderParam("value") DateTimeRfc1123 value, @HeaderP @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> unixTimestamp(@HeaderParam("value") long value, @HeaderParam("accept") String accept, + Mono> unixTimestamp(@HostParam("endpoint") String endpoint, @HeaderParam("value") long value, RequestOptions requestOptions, Context context); @Get("/encode/datetime/header/unix-timestamp") @@ -129,7 +130,7 @@ Mono> unixTimestamp(@HeaderParam("value") long value, @HeaderPara @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response unixTimestampSync(@HeaderParam("value") long value, @HeaderParam("accept") String accept, + Response unixTimestampSync(@HostParam("endpoint") String endpoint, @HeaderParam("value") long value, RequestOptions requestOptions, Context context); @Get("/encode/datetime/header/unix-timestamp-array") @@ -138,8 +139,8 @@ Response unixTimestampSync(@HeaderParam("value") long value, @HeaderParam( @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> unixTimestampArray(@HeaderParam("value") String value, - @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + Mono> unixTimestampArray(@HostParam("endpoint") String endpoint, + @HeaderParam("value") String value, RequestOptions requestOptions, Context context); @Get("/encode/datetime/header/unix-timestamp-array") @ExpectedResponses({ 204 }) @@ -147,8 +148,8 @@ Mono> unixTimestampArray(@HeaderParam("value") String value, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response unixTimestampArraySync(@HeaderParam("value") String value, @HeaderParam("accept") String accept, - RequestOptions requestOptions, Context context); + Response unixTimestampArraySync(@HostParam("endpoint") String endpoint, + @HeaderParam("value") String value, RequestOptions requestOptions, Context context); } /** @@ -164,9 +165,9 @@ Response unixTimestampArraySync(@HeaderParam("value") String value, @Heade */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> defaultMethodWithResponseAsync(OffsetDateTime value, RequestOptions requestOptions) { - final String accept = "application/json"; DateTimeRfc1123 valueConverted = new DateTimeRfc1123(value); - return FluxUtil.withContext(context -> service.defaultMethod(valueConverted, accept, requestOptions, context)); + return FluxUtil.withContext( + context -> service.defaultMethod(this.client.getEndpoint(), valueConverted, requestOptions, context)); } /** @@ -182,9 +183,8 @@ public Mono> defaultMethodWithResponseAsync(OffsetDateTime value, */ @ServiceMethod(returns = ReturnType.SINGLE) public Response defaultMethodWithResponse(OffsetDateTime value, RequestOptions requestOptions) { - final String accept = "application/json"; DateTimeRfc1123 valueConverted = new DateTimeRfc1123(value); - return service.defaultMethodSync(valueConverted, accept, requestOptions, Context.NONE); + return service.defaultMethodSync(this.client.getEndpoint(), valueConverted, requestOptions, Context.NONE); } /** @@ -200,8 +200,8 @@ public Response defaultMethodWithResponse(OffsetDateTime value, RequestOpt */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> rfc3339WithResponseAsync(OffsetDateTime value, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.rfc3339(value, accept, requestOptions, context)); + return FluxUtil + .withContext(context -> service.rfc3339(this.client.getEndpoint(), value, requestOptions, context)); } /** @@ -217,8 +217,7 @@ public Mono> rfc3339WithResponseAsync(OffsetDateTime value, Reque */ @ServiceMethod(returns = ReturnType.SINGLE) public Response rfc3339WithResponse(OffsetDateTime value, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.rfc3339Sync(value, accept, requestOptions, Context.NONE); + return service.rfc3339Sync(this.client.getEndpoint(), value, requestOptions, Context.NONE); } /** @@ -234,9 +233,9 @@ public Response rfc3339WithResponse(OffsetDateTime value, RequestOptions r */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> rfc7231WithResponseAsync(OffsetDateTime value, RequestOptions requestOptions) { - final String accept = "application/json"; DateTimeRfc1123 valueConverted = new DateTimeRfc1123(value); - return FluxUtil.withContext(context -> service.rfc7231(valueConverted, accept, requestOptions, context)); + return FluxUtil.withContext( + context -> service.rfc7231(this.client.getEndpoint(), valueConverted, requestOptions, context)); } /** @@ -252,9 +251,8 @@ public Mono> rfc7231WithResponseAsync(OffsetDateTime value, Reque */ @ServiceMethod(returns = ReturnType.SINGLE) public Response rfc7231WithResponse(OffsetDateTime value, RequestOptions requestOptions) { - final String accept = "application/json"; DateTimeRfc1123 valueConverted = new DateTimeRfc1123(value); - return service.rfc7231Sync(valueConverted, accept, requestOptions, Context.NONE); + return service.rfc7231Sync(this.client.getEndpoint(), valueConverted, requestOptions, Context.NONE); } /** @@ -270,9 +268,9 @@ public Response rfc7231WithResponse(OffsetDateTime value, RequestOptions r */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> unixTimestampWithResponseAsync(OffsetDateTime value, RequestOptions requestOptions) { - final String accept = "application/json"; long valueConverted = value.toEpochSecond(); - return FluxUtil.withContext(context -> service.unixTimestamp(valueConverted, accept, requestOptions, context)); + return FluxUtil.withContext( + context -> service.unixTimestamp(this.client.getEndpoint(), valueConverted, requestOptions, context)); } /** @@ -288,9 +286,8 @@ public Mono> unixTimestampWithResponseAsync(OffsetDateTime value, */ @ServiceMethod(returns = ReturnType.SINGLE) public Response unixTimestampWithResponse(OffsetDateTime value, RequestOptions requestOptions) { - final String accept = "application/json"; long valueConverted = value.toEpochSecond(); - return service.unixTimestampSync(valueConverted, accept, requestOptions, Context.NONE); + return service.unixTimestampSync(this.client.getEndpoint(), valueConverted, requestOptions, Context.NONE); } /** @@ -307,13 +304,12 @@ public Response unixTimestampWithResponse(OffsetDateTime value, RequestOpt @ServiceMethod(returns = ReturnType.SINGLE) public Mono> unixTimestampArrayWithResponseAsync(List value, RequestOptions requestOptions) { - final String accept = "application/json"; String valueConverted = JacksonAdapter.createDefaultSerializerAdapter() .serializeIterable( value.stream().map(paramItemValue -> paramItemValue.toEpochSecond()).collect(Collectors.toList()), CollectionFormat.CSV); - return FluxUtil - .withContext(context -> service.unixTimestampArray(valueConverted, accept, requestOptions, context)); + return FluxUtil.withContext( + context -> service.unixTimestampArray(this.client.getEndpoint(), valueConverted, requestOptions, context)); } /** @@ -329,11 +325,10 @@ public Mono> unixTimestampArrayWithResponseAsync(List unixTimestampArrayWithResponse(List value, RequestOptions requestOptions) { - final String accept = "application/json"; String valueConverted = JacksonAdapter.createDefaultSerializerAdapter() .serializeIterable( value.stream().map(paramItemValue -> paramItemValue.toEpochSecond()).collect(Collectors.toList()), CollectionFormat.CSV); - return service.unixTimestampArraySync(valueConverted, accept, requestOptions, Context.NONE); + return service.unixTimestampArraySync(this.client.getEndpoint(), valueConverted, requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/encode/datetime/implementation/PropertiesImpl.java b/typespec-tests/src/main/java/com/encode/datetime/implementation/PropertiesImpl.java index 6fed967c47..0ee32e70e6 100644 --- a/typespec-tests/src/main/java/com/encode/datetime/implementation/PropertiesImpl.java +++ b/typespec-tests/src/main/java/com/encode/datetime/implementation/PropertiesImpl.java @@ -8,6 +8,7 @@ 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; @@ -54,7 +55,7 @@ public final class PropertiesImpl { * The interface defining all the services for DatetimeClientProperties to be used by the proxy service to perform * REST calls. */ - @Host("http://localhost:3000") + @Host("{endpoint}") @ServiceInterface(name = "DatetimeClientProper") public interface PropertiesService { @Post("/encode/datetime/property/default") @@ -63,7 +64,8 @@ public interface PropertiesService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> defaultMethod(@HeaderParam("accept") String accept, + 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") @@ -72,7 +74,8 @@ Mono> defaultMethod(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response defaultMethodSync(@HeaderParam("accept") String accept, + 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") @@ -81,7 +84,8 @@ Response defaultMethodSync(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> rfc3339(@HeaderParam("accept") String accept, + 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") @@ -90,7 +94,8 @@ Mono> rfc3339(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response rfc3339Sync(@HeaderParam("accept") String accept, + 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") @@ -99,7 +104,8 @@ Response rfc3339Sync(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> rfc7231(@HeaderParam("accept") String accept, + 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") @@ -108,7 +114,8 @@ Mono> rfc7231(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response rfc7231Sync(@HeaderParam("accept") String accept, + 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") @@ -117,7 +124,8 @@ Response rfc7231Sync(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> unixTimestamp(@HeaderParam("accept") String accept, + 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") @@ -126,7 +134,8 @@ Mono> unixTimestamp(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response unixTimestampSync(@HeaderParam("accept") String accept, + 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") @@ -135,7 +144,8 @@ Response unixTimestampSync(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> unixTimestampArray(@HeaderParam("accept") String accept, + 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") @@ -144,7 +154,8 @@ Mono> unixTimestampArray(@HeaderParam("accept") String acce @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response unixTimestampArraySync(@HeaderParam("accept") String accept, + Response unixTimestampArraySync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); } @@ -176,8 +187,10 @@ Response unixTimestampArraySync(@HeaderParam("accept") String accept */ @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(accept, body, requestOptions, context)); + return FluxUtil.withContext(context -> service.defaultMethod(this.client.getEndpoint(), contentType, accept, + body, requestOptions, context)); } /** @@ -208,8 +221,10 @@ public Mono> defaultMethodWithResponseAsync(BinaryData body */ @ServiceMethod(returns = ReturnType.SINGLE) public Response defaultMethodWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; final String accept = "application/json"; - return service.defaultMethodSync(accept, body, requestOptions, Context.NONE); + return service.defaultMethodSync(this.client.getEndpoint(), contentType, accept, body, requestOptions, + Context.NONE); } /** @@ -240,8 +255,10 @@ public Response defaultMethodWithResponse(BinaryData body, RequestOp */ @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(accept, body, requestOptions, context)); + return FluxUtil.withContext( + context -> service.rfc3339(this.client.getEndpoint(), contentType, accept, body, requestOptions, context)); } /** @@ -272,8 +289,9 @@ public Mono> rfc3339WithResponseAsync(BinaryData body, Requ */ @ServiceMethod(returns = ReturnType.SINGLE) public Response rfc3339WithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; final String accept = "application/json"; - return service.rfc3339Sync(accept, body, requestOptions, Context.NONE); + return service.rfc3339Sync(this.client.getEndpoint(), contentType, accept, body, requestOptions, Context.NONE); } /** @@ -304,8 +322,10 @@ public Response rfc3339WithResponse(BinaryData body, RequestOptions */ @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(accept, body, requestOptions, context)); + return FluxUtil.withContext( + context -> service.rfc7231(this.client.getEndpoint(), contentType, accept, body, requestOptions, context)); } /** @@ -336,8 +356,9 @@ public Mono> rfc7231WithResponseAsync(BinaryData body, Requ */ @ServiceMethod(returns = ReturnType.SINGLE) public Response rfc7231WithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; final String accept = "application/json"; - return service.rfc7231Sync(accept, body, requestOptions, Context.NONE); + return service.rfc7231Sync(this.client.getEndpoint(), contentType, accept, body, requestOptions, Context.NONE); } /** @@ -368,8 +389,10 @@ public Response rfc7231WithResponse(BinaryData body, RequestOptions */ @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(accept, body, requestOptions, context)); + return FluxUtil.withContext(context -> service.unixTimestamp(this.client.getEndpoint(), contentType, accept, + body, requestOptions, context)); } /** @@ -400,8 +423,10 @@ public Mono> unixTimestampWithResponseAsync(BinaryData body */ @ServiceMethod(returns = ReturnType.SINGLE) public Response unixTimestampWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; final String accept = "application/json"; - return service.unixTimestampSync(accept, body, requestOptions, Context.NONE); + return service.unixTimestampSync(this.client.getEndpoint(), contentType, accept, body, requestOptions, + Context.NONE); } /** @@ -437,8 +462,10 @@ public Response unixTimestampWithResponse(BinaryData body, RequestOp @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(accept, body, requestOptions, context)); + return FluxUtil.withContext(context -> service.unixTimestampArray(this.client.getEndpoint(), contentType, + accept, body, requestOptions, context)); } /** @@ -473,7 +500,9 @@ public Mono> unixTimestampArrayWithResponseAsync(BinaryData */ @ServiceMethod(returns = ReturnType.SINGLE) public Response unixTimestampArrayWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; final String accept = "application/json"; - return service.unixTimestampArraySync(accept, body, requestOptions, Context.NONE); + return service.unixTimestampArraySync(this.client.getEndpoint(), contentType, accept, body, requestOptions, + Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/encode/datetime/implementation/QueriesImpl.java b/typespec-tests/src/main/java/com/encode/datetime/implementation/QueriesImpl.java index 9aa4c27e97..3d1d80eb68 100644 --- a/typespec-tests/src/main/java/com/encode/datetime/implementation/QueriesImpl.java +++ b/typespec-tests/src/main/java/com/encode/datetime/implementation/QueriesImpl.java @@ -6,8 +6,8 @@ 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; @@ -58,7 +58,7 @@ public final class QueriesImpl { * The interface defining all the services for DatetimeClientQueries to be used by the proxy service to perform REST * calls. */ - @Host("http://localhost:3000") + @Host("{endpoint}") @ServiceInterface(name = "DatetimeClientQuerie") public interface QueriesService { @Get("/encode/datetime/query/default") @@ -67,8 +67,8 @@ public interface QueriesService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> defaultMethod(@QueryParam("value") OffsetDateTime value, - @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + Mono> defaultMethod(@HostParam("endpoint") String endpoint, + @QueryParam("value") OffsetDateTime value, RequestOptions requestOptions, Context context); @Get("/encode/datetime/query/default") @ExpectedResponses({ 204 }) @@ -76,8 +76,8 @@ Mono> defaultMethod(@QueryParam("value") OffsetDateTime value, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response defaultMethodSync(@QueryParam("value") OffsetDateTime value, - @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + Response defaultMethodSync(@HostParam("endpoint") String endpoint, + @QueryParam("value") OffsetDateTime value, RequestOptions requestOptions, Context context); @Get("/encode/datetime/query/rfc3339") @ExpectedResponses({ 204 }) @@ -85,7 +85,7 @@ Response defaultMethodSync(@QueryParam("value") OffsetDateTime value, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> rfc3339(@QueryParam("value") OffsetDateTime value, @HeaderParam("accept") String accept, + Mono> rfc3339(@HostParam("endpoint") String endpoint, @QueryParam("value") OffsetDateTime value, RequestOptions requestOptions, Context context); @Get("/encode/datetime/query/rfc3339") @@ -94,7 +94,7 @@ Mono> rfc3339(@QueryParam("value") OffsetDateTime value, @HeaderP @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response rfc3339Sync(@QueryParam("value") OffsetDateTime value, @HeaderParam("accept") String accept, + Response rfc3339Sync(@HostParam("endpoint") String endpoint, @QueryParam("value") OffsetDateTime value, RequestOptions requestOptions, Context context); @Get("/encode/datetime/query/rfc7231") @@ -103,7 +103,7 @@ Response rfc3339Sync(@QueryParam("value") OffsetDateTime value, @HeaderPar @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> rfc7231(@QueryParam("value") DateTimeRfc1123 value, @HeaderParam("accept") String accept, + Mono> rfc7231(@HostParam("endpoint") String endpoint, @QueryParam("value") DateTimeRfc1123 value, RequestOptions requestOptions, Context context); @Get("/encode/datetime/query/rfc7231") @@ -112,7 +112,7 @@ Mono> rfc7231(@QueryParam("value") DateTimeRfc1123 value, @Header @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response rfc7231Sync(@QueryParam("value") DateTimeRfc1123 value, @HeaderParam("accept") String accept, + Response rfc7231Sync(@HostParam("endpoint") String endpoint, @QueryParam("value") DateTimeRfc1123 value, RequestOptions requestOptions, Context context); @Get("/encode/datetime/query/unix-timestamp") @@ -121,7 +121,7 @@ Response rfc7231Sync(@QueryParam("value") DateTimeRfc1123 value, @HeaderPa @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> unixTimestamp(@QueryParam("value") long value, @HeaderParam("accept") String accept, + Mono> unixTimestamp(@HostParam("endpoint") String endpoint, @QueryParam("value") long value, RequestOptions requestOptions, Context context); @Get("/encode/datetime/query/unix-timestamp") @@ -130,7 +130,7 @@ Mono> unixTimestamp(@QueryParam("value") long value, @HeaderParam @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response unixTimestampSync(@QueryParam("value") long value, @HeaderParam("accept") String accept, + Response unixTimestampSync(@HostParam("endpoint") String endpoint, @QueryParam("value") long value, RequestOptions requestOptions, Context context); @Get("/encode/datetime/query/unix-timestamp-array") @@ -139,8 +139,8 @@ Response unixTimestampSync(@QueryParam("value") long value, @HeaderParam(" @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> unixTimestampArray(@QueryParam("value") String value, @HeaderParam("accept") String accept, - RequestOptions requestOptions, Context context); + Mono> unixTimestampArray(@HostParam("endpoint") String endpoint, + @QueryParam("value") String value, RequestOptions requestOptions, Context context); @Get("/encode/datetime/query/unix-timestamp-array") @ExpectedResponses({ 204 }) @@ -148,7 +148,7 @@ Mono> unixTimestampArray(@QueryParam("value") String value, @Head @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response unixTimestampArraySync(@QueryParam("value") String value, @HeaderParam("accept") String accept, + Response unixTimestampArraySync(@HostParam("endpoint") String endpoint, @QueryParam("value") String value, RequestOptions requestOptions, Context context); } @@ -165,8 +165,8 @@ Response unixTimestampArraySync(@QueryParam("value") String value, @Header */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> defaultMethodWithResponseAsync(OffsetDateTime value, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.defaultMethod(value, accept, requestOptions, context)); + return FluxUtil + .withContext(context -> service.defaultMethod(this.client.getEndpoint(), value, requestOptions, context)); } /** @@ -182,8 +182,7 @@ public Mono> defaultMethodWithResponseAsync(OffsetDateTime value, */ @ServiceMethod(returns = ReturnType.SINGLE) public Response defaultMethodWithResponse(OffsetDateTime value, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.defaultMethodSync(value, accept, requestOptions, Context.NONE); + return service.defaultMethodSync(this.client.getEndpoint(), value, requestOptions, Context.NONE); } /** @@ -199,8 +198,8 @@ public Response defaultMethodWithResponse(OffsetDateTime value, RequestOpt */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> rfc3339WithResponseAsync(OffsetDateTime value, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.rfc3339(value, accept, requestOptions, context)); + return FluxUtil + .withContext(context -> service.rfc3339(this.client.getEndpoint(), value, requestOptions, context)); } /** @@ -216,8 +215,7 @@ public Mono> rfc3339WithResponseAsync(OffsetDateTime value, Reque */ @ServiceMethod(returns = ReturnType.SINGLE) public Response rfc3339WithResponse(OffsetDateTime value, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.rfc3339Sync(value, accept, requestOptions, Context.NONE); + return service.rfc3339Sync(this.client.getEndpoint(), value, requestOptions, Context.NONE); } /** @@ -233,9 +231,9 @@ public Response rfc3339WithResponse(OffsetDateTime value, RequestOptions r */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> rfc7231WithResponseAsync(OffsetDateTime value, RequestOptions requestOptions) { - final String accept = "application/json"; DateTimeRfc1123 valueConverted = new DateTimeRfc1123(value); - return FluxUtil.withContext(context -> service.rfc7231(valueConverted, accept, requestOptions, context)); + return FluxUtil.withContext( + context -> service.rfc7231(this.client.getEndpoint(), valueConverted, requestOptions, context)); } /** @@ -251,9 +249,8 @@ public Mono> rfc7231WithResponseAsync(OffsetDateTime value, Reque */ @ServiceMethod(returns = ReturnType.SINGLE) public Response rfc7231WithResponse(OffsetDateTime value, RequestOptions requestOptions) { - final String accept = "application/json"; DateTimeRfc1123 valueConverted = new DateTimeRfc1123(value); - return service.rfc7231Sync(valueConverted, accept, requestOptions, Context.NONE); + return service.rfc7231Sync(this.client.getEndpoint(), valueConverted, requestOptions, Context.NONE); } /** @@ -269,9 +266,9 @@ public Response rfc7231WithResponse(OffsetDateTime value, RequestOptions r */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> unixTimestampWithResponseAsync(OffsetDateTime value, RequestOptions requestOptions) { - final String accept = "application/json"; long valueConverted = value.toEpochSecond(); - return FluxUtil.withContext(context -> service.unixTimestamp(valueConverted, accept, requestOptions, context)); + return FluxUtil.withContext( + context -> service.unixTimestamp(this.client.getEndpoint(), valueConverted, requestOptions, context)); } /** @@ -287,9 +284,8 @@ public Mono> unixTimestampWithResponseAsync(OffsetDateTime value, */ @ServiceMethod(returns = ReturnType.SINGLE) public Response unixTimestampWithResponse(OffsetDateTime value, RequestOptions requestOptions) { - final String accept = "application/json"; long valueConverted = value.toEpochSecond(); - return service.unixTimestampSync(valueConverted, accept, requestOptions, Context.NONE); + return service.unixTimestampSync(this.client.getEndpoint(), valueConverted, requestOptions, Context.NONE); } /** @@ -306,13 +302,12 @@ public Response unixTimestampWithResponse(OffsetDateTime value, RequestOpt @ServiceMethod(returns = ReturnType.SINGLE) public Mono> unixTimestampArrayWithResponseAsync(List value, RequestOptions requestOptions) { - final String accept = "application/json"; String valueConverted = JacksonAdapter.createDefaultSerializerAdapter() .serializeIterable( value.stream().map(paramItemValue -> paramItemValue.toEpochSecond()).collect(Collectors.toList()), CollectionFormat.CSV); - return FluxUtil - .withContext(context -> service.unixTimestampArray(valueConverted, accept, requestOptions, context)); + return FluxUtil.withContext( + context -> service.unixTimestampArray(this.client.getEndpoint(), valueConverted, requestOptions, context)); } /** @@ -328,11 +323,10 @@ public Mono> unixTimestampArrayWithResponseAsync(List unixTimestampArrayWithResponse(List value, RequestOptions requestOptions) { - final String accept = "application/json"; String valueConverted = JacksonAdapter.createDefaultSerializerAdapter() .serializeIterable( value.stream().map(paramItemValue -> paramItemValue.toEpochSecond()).collect(Collectors.toList()), CollectionFormat.CSV); - return service.unixTimestampArraySync(valueConverted, accept, requestOptions, Context.NONE); + return service.unixTimestampArraySync(this.client.getEndpoint(), valueConverted, requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/encode/datetime/implementation/ResponseHeadersImpl.java b/typespec-tests/src/main/java/com/encode/datetime/implementation/ResponseHeadersImpl.java index c731513bbb..b1a994d44e 100644 --- a/typespec-tests/src/main/java/com/encode/datetime/implementation/ResponseHeadersImpl.java +++ b/typespec-tests/src/main/java/com/encode/datetime/implementation/ResponseHeadersImpl.java @@ -6,8 +6,8 @@ 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; @@ -52,7 +52,7 @@ public final class ResponseHeadersImpl { * The interface defining all the services for DatetimeClientResponseHeaders to be used by the proxy service to * perform REST calls. */ - @Host("http://localhost:3000") + @Host("{endpoint}") @ServiceInterface(name = "DatetimeClientRespon") public interface ResponseHeadersService { @Get("/encode/datetime/responseheader/default") @@ -61,7 +61,7 @@ public interface ResponseHeadersService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> defaultMethod(@HeaderParam("accept") String accept, RequestOptions requestOptions, + Mono> defaultMethod(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, Context context); @Get("/encode/datetime/responseheader/default") @@ -70,7 +70,7 @@ Mono> defaultMethod(@HeaderParam("accept") String accept, Request @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response defaultMethodSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, + Response defaultMethodSync(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, Context context); @Get("/encode/datetime/responseheader/rfc3339") @@ -79,7 +79,7 @@ Response defaultMethodSync(@HeaderParam("accept") String accept, RequestOp @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> rfc3339(@HeaderParam("accept") String accept, RequestOptions requestOptions, + Mono> rfc3339(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, Context context); @Get("/encode/datetime/responseheader/rfc3339") @@ -88,7 +88,7 @@ Mono> rfc3339(@HeaderParam("accept") String accept, RequestOption @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response rfc3339Sync(@HeaderParam("accept") String accept, RequestOptions requestOptions, + Response rfc3339Sync(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, Context context); @Get("/encode/datetime/responseheader/rfc7231") @@ -97,7 +97,7 @@ Response rfc3339Sync(@HeaderParam("accept") String accept, RequestOptions @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> rfc7231(@HeaderParam("accept") String accept, RequestOptions requestOptions, + Mono> rfc7231(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, Context context); @Get("/encode/datetime/responseheader/rfc7231") @@ -106,7 +106,7 @@ Mono> rfc7231(@HeaderParam("accept") String accept, RequestOption @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response rfc7231Sync(@HeaderParam("accept") String accept, RequestOptions requestOptions, + Response rfc7231Sync(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, Context context); @Get("/encode/datetime/responseheader/unix-timestamp") @@ -115,7 +115,7 @@ Response rfc7231Sync(@HeaderParam("accept") String accept, RequestOptions @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> unixTimestamp(@HeaderParam("accept") String accept, RequestOptions requestOptions, + Mono> unixTimestamp(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, Context context); @Get("/encode/datetime/responseheader/unix-timestamp") @@ -124,7 +124,7 @@ Mono> unixTimestamp(@HeaderParam("accept") String accept, Request @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response unixTimestampSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, + Response unixTimestampSync(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, Context context); } @@ -140,8 +140,8 @@ Response unixTimestampSync(@HeaderParam("accept") String accept, RequestOp */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> defaultMethodWithResponseAsync(RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.defaultMethod(accept, requestOptions, context)); + return FluxUtil + .withContext(context -> service.defaultMethod(this.client.getEndpoint(), requestOptions, context)); } /** @@ -156,8 +156,7 @@ public Mono> defaultMethodWithResponseAsync(RequestOptions reques */ @ServiceMethod(returns = ReturnType.SINGLE) public Response defaultMethodWithResponse(RequestOptions requestOptions) { - final String accept = "application/json"; - return service.defaultMethodSync(accept, requestOptions, Context.NONE); + return service.defaultMethodSync(this.client.getEndpoint(), requestOptions, Context.NONE); } /** @@ -172,8 +171,7 @@ public Response defaultMethodWithResponse(RequestOptions requestOptions) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> rfc3339WithResponseAsync(RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.rfc3339(accept, requestOptions, context)); + return FluxUtil.withContext(context -> service.rfc3339(this.client.getEndpoint(), requestOptions, context)); } /** @@ -188,8 +186,7 @@ public Mono> rfc3339WithResponseAsync(RequestOptions requestOptio */ @ServiceMethod(returns = ReturnType.SINGLE) public Response rfc3339WithResponse(RequestOptions requestOptions) { - final String accept = "application/json"; - return service.rfc3339Sync(accept, requestOptions, Context.NONE); + return service.rfc3339Sync(this.client.getEndpoint(), requestOptions, Context.NONE); } /** @@ -204,8 +201,7 @@ public Response rfc3339WithResponse(RequestOptions requestOptions) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> rfc7231WithResponseAsync(RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.rfc7231(accept, requestOptions, context)); + return FluxUtil.withContext(context -> service.rfc7231(this.client.getEndpoint(), requestOptions, context)); } /** @@ -220,8 +216,7 @@ public Mono> rfc7231WithResponseAsync(RequestOptions requestOptio */ @ServiceMethod(returns = ReturnType.SINGLE) public Response rfc7231WithResponse(RequestOptions requestOptions) { - final String accept = "application/json"; - return service.rfc7231Sync(accept, requestOptions, Context.NONE); + return service.rfc7231Sync(this.client.getEndpoint(), requestOptions, Context.NONE); } /** @@ -236,8 +231,8 @@ public Response rfc7231WithResponse(RequestOptions requestOptions) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> unixTimestampWithResponseAsync(RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.unixTimestamp(accept, requestOptions, context)); + return FluxUtil + .withContext(context -> service.unixTimestamp(this.client.getEndpoint(), requestOptions, context)); } /** @@ -252,7 +247,6 @@ public Mono> unixTimestampWithResponseAsync(RequestOptions reques */ @ServiceMethod(returns = ReturnType.SINGLE) public Response unixTimestampWithResponse(RequestOptions requestOptions) { - final String accept = "application/json"; - return service.unixTimestampSync(accept, requestOptions, Context.NONE); + return service.unixTimestampSync(this.client.getEndpoint(), requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/encode/duration/DurationClientBuilder.java b/typespec-tests/src/main/java/com/encode/duration/DurationClientBuilder.java index be49f60039..502799aad5 100644 --- a/typespec-tests/src/main/java/com/encode/duration/DurationClientBuilder.java +++ b/typespec-tests/src/main/java/com/encode/duration/DurationClientBuilder.java @@ -7,6 +7,7 @@ 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; @@ -47,8 +48,8 @@ QueryAsyncClient.class, PropertyAsyncClient.class, HeaderAsyncClient.class }) -public final class DurationClientBuilder - implements HttpTrait, ConfigurationTrait { +public final class DurationClientBuilder implements HttpTrait, + ConfigurationTrait, EndpointTrait { @Generated private static final String SDK_NAME = "name"; @@ -179,6 +180,22 @@ public DurationClientBuilder configuration(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. */ @@ -206,8 +223,9 @@ public DurationClientBuilder retryPolicy(RetryPolicy retryPolicy) { 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()); + = new DurationClientImpl(localPipeline, JacksonAdapter.createDefaultSerializerAdapter(), localEndpoint); return client; } diff --git a/typespec-tests/src/main/java/com/encode/duration/implementation/DurationClientImpl.java b/typespec-tests/src/main/java/com/encode/duration/implementation/DurationClientImpl.java index e8411d2aff..9d731a2bda 100644 --- a/typespec-tests/src/main/java/com/encode/duration/implementation/DurationClientImpl.java +++ b/typespec-tests/src/main/java/com/encode/duration/implementation/DurationClientImpl.java @@ -15,6 +15,20 @@ * 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. */ @@ -87,19 +101,22 @@ public HeadersImpl getHeaders() { /** * Initializes an instance of DurationClient client. + * + * @param endpoint Service host. */ - public DurationClientImpl() { + public DurationClientImpl(String endpoint) { this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), - JacksonAdapter.createDefaultSerializerAdapter()); + 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) { - this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter()); + public DurationClientImpl(HttpPipeline httpPipeline, String endpoint) { + this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint); } /** @@ -107,10 +124,12 @@ public DurationClientImpl(HttpPipeline httpPipeline) { * * @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) { + 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/typespec-tests/src/main/java/com/encode/duration/implementation/HeadersImpl.java b/typespec-tests/src/main/java/com/encode/duration/implementation/HeadersImpl.java index 602448ae71..a966e154f0 100644 --- a/typespec-tests/src/main/java/com/encode/duration/implementation/HeadersImpl.java +++ b/typespec-tests/src/main/java/com/encode/duration/implementation/HeadersImpl.java @@ -8,6 +8,7 @@ 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; @@ -55,7 +56,7 @@ public final class HeadersImpl { * The interface defining all the services for DurationClientHeaders to be used by the proxy service to perform REST * calls. */ - @Host("http://localhost:3000") + @Host("{endpoint}") @ServiceInterface(name = "DurationClientHeader") public interface HeadersService { @Get("/encode/duration/header/default") @@ -64,8 +65,8 @@ public interface HeadersService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> defaultMethod(@HeaderParam("duration") Duration duration, - @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + Mono> defaultMethod(@HostParam("endpoint") String endpoint, + @HeaderParam("duration") Duration duration, RequestOptions requestOptions, Context context); @Get("/encode/duration/header/default") @ExpectedResponses({ 204 }) @@ -73,8 +74,8 @@ Mono> defaultMethod(@HeaderParam("duration") Duration duration, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response defaultMethodSync(@HeaderParam("duration") Duration duration, - @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + Response defaultMethodSync(@HostParam("endpoint") String endpoint, + @HeaderParam("duration") Duration duration, RequestOptions requestOptions, Context context); @Get("/encode/duration/header/iso8601") @ExpectedResponses({ 204 }) @@ -82,7 +83,7 @@ Response defaultMethodSync(@HeaderParam("duration") Duration duration, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> iso8601(@HeaderParam("duration") Duration duration, @HeaderParam("accept") String accept, + Mono> iso8601(@HostParam("endpoint") String endpoint, @HeaderParam("duration") Duration duration, RequestOptions requestOptions, Context context); @Get("/encode/duration/header/iso8601") @@ -91,7 +92,7 @@ Mono> iso8601(@HeaderParam("duration") Duration duration, @Header @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response iso8601Sync(@HeaderParam("duration") Duration duration, @HeaderParam("accept") String accept, + Response iso8601Sync(@HostParam("endpoint") String endpoint, @HeaderParam("duration") Duration duration, RequestOptions requestOptions, Context context); @Get("/encode/duration/header/iso8601-array") @@ -100,8 +101,8 @@ Response iso8601Sync(@HeaderParam("duration") Duration duration, @HeaderPa @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> iso8601Array(@HeaderParam("duration") String duration, - @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + Mono> iso8601Array(@HostParam("endpoint") String endpoint, + @HeaderParam("duration") String duration, RequestOptions requestOptions, Context context); @Get("/encode/duration/header/iso8601-array") @ExpectedResponses({ 204 }) @@ -109,8 +110,8 @@ Mono> iso8601Array(@HeaderParam("duration") String duration, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response iso8601ArraySync(@HeaderParam("duration") String duration, @HeaderParam("accept") String accept, - RequestOptions requestOptions, Context context); + Response iso8601ArraySync(@HostParam("endpoint") String endpoint, + @HeaderParam("duration") String duration, RequestOptions requestOptions, Context context); @Get("/encode/duration/header/int32-seconds") @ExpectedResponses({ 204 }) @@ -118,8 +119,8 @@ Response iso8601ArraySync(@HeaderParam("duration") String duration, @Heade @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> int32Seconds(@HeaderParam("duration") long duration, @HeaderParam("accept") String accept, - RequestOptions requestOptions, Context context); + Mono> int32Seconds(@HostParam("endpoint") String endpoint, + @HeaderParam("duration") long duration, RequestOptions requestOptions, Context context); @Get("/encode/duration/header/int32-seconds") @ExpectedResponses({ 204 }) @@ -127,7 +128,7 @@ Mono> int32Seconds(@HeaderParam("duration") long duration, @Heade @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response int32SecondsSync(@HeaderParam("duration") long duration, @HeaderParam("accept") String accept, + Response int32SecondsSync(@HostParam("endpoint") String endpoint, @HeaderParam("duration") long duration, RequestOptions requestOptions, Context context); @Get("/encode/duration/header/float-seconds") @@ -136,8 +137,8 @@ Response int32SecondsSync(@HeaderParam("duration") long duration, @HeaderP @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> floatSeconds(@HeaderParam("duration") double duration, - @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + Mono> floatSeconds(@HostParam("endpoint") String endpoint, + @HeaderParam("duration") double duration, RequestOptions requestOptions, Context context); @Get("/encode/duration/header/float-seconds") @ExpectedResponses({ 204 }) @@ -145,8 +146,8 @@ Mono> floatSeconds(@HeaderParam("duration") double duration, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response floatSecondsSync(@HeaderParam("duration") double duration, @HeaderParam("accept") String accept, - RequestOptions requestOptions, Context context); + Response floatSecondsSync(@HostParam("endpoint") String endpoint, + @HeaderParam("duration") double duration, RequestOptions requestOptions, Context context); @Get("/encode/duration/header/float64-seconds") @ExpectedResponses({ 204 }) @@ -154,8 +155,8 @@ Response floatSecondsSync(@HeaderParam("duration") double duration, @Heade @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> float64Seconds(@HeaderParam("duration") double duration, - @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + Mono> float64Seconds(@HostParam("endpoint") String endpoint, + @HeaderParam("duration") double duration, RequestOptions requestOptions, Context context); @Get("/encode/duration/header/float64-seconds") @ExpectedResponses({ 204 }) @@ -163,8 +164,8 @@ Mono> float64Seconds(@HeaderParam("duration") double duration, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response float64SecondsSync(@HeaderParam("duration") double duration, - @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + Response float64SecondsSync(@HostParam("endpoint") String endpoint, + @HeaderParam("duration") double duration, RequestOptions requestOptions, Context context); } /** @@ -180,8 +181,8 @@ Response float64SecondsSync(@HeaderParam("duration") double duration, */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> defaultMethodWithResponseAsync(Duration duration, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.defaultMethod(duration, accept, requestOptions, context)); + return FluxUtil.withContext( + context -> service.defaultMethod(this.client.getEndpoint(), duration, requestOptions, context)); } /** @@ -197,8 +198,7 @@ public Mono> defaultMethodWithResponseAsync(Duration duration, Re */ @ServiceMethod(returns = ReturnType.SINGLE) public Response defaultMethodWithResponse(Duration duration, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.defaultMethodSync(duration, accept, requestOptions, Context.NONE); + return service.defaultMethodSync(this.client.getEndpoint(), duration, requestOptions, Context.NONE); } /** @@ -214,8 +214,8 @@ public Response defaultMethodWithResponse(Duration duration, RequestOption */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> iso8601WithResponseAsync(Duration duration, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.iso8601(duration, accept, requestOptions, context)); + return FluxUtil + .withContext(context -> service.iso8601(this.client.getEndpoint(), duration, requestOptions, context)); } /** @@ -231,8 +231,7 @@ public Mono> iso8601WithResponseAsync(Duration duration, RequestO */ @ServiceMethod(returns = ReturnType.SINGLE) public Response iso8601WithResponse(Duration duration, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.iso8601Sync(duration, accept, requestOptions, Context.NONE); + return service.iso8601Sync(this.client.getEndpoint(), duration, requestOptions, Context.NONE); } /** @@ -248,11 +247,10 @@ public Response iso8601WithResponse(Duration duration, RequestOptions requ */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> iso8601ArrayWithResponseAsync(List duration, RequestOptions requestOptions) { - final String accept = "application/json"; String durationConverted = JacksonAdapter.createDefaultSerializerAdapter().serializeIterable(duration, CollectionFormat.CSV); - return FluxUtil - .withContext(context -> service.iso8601Array(durationConverted, accept, requestOptions, context)); + return FluxUtil.withContext( + context -> service.iso8601Array(this.client.getEndpoint(), durationConverted, requestOptions, context)); } /** @@ -268,10 +266,9 @@ public Mono> iso8601ArrayWithResponseAsync(List duratio */ @ServiceMethod(returns = ReturnType.SINGLE) public Response iso8601ArrayWithResponse(List duration, RequestOptions requestOptions) { - final String accept = "application/json"; String durationConverted = JacksonAdapter.createDefaultSerializerAdapter().serializeIterable(duration, CollectionFormat.CSV); - return service.iso8601ArraySync(durationConverted, accept, requestOptions, Context.NONE); + return service.iso8601ArraySync(this.client.getEndpoint(), durationConverted, requestOptions, Context.NONE); } /** @@ -287,10 +284,9 @@ public Response iso8601ArrayWithResponse(List duration, RequestO */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> int32SecondsWithResponseAsync(Duration duration, RequestOptions requestOptions) { - final String accept = "application/json"; long durationConverted = duration.getSeconds(); - return FluxUtil - .withContext(context -> service.int32Seconds(durationConverted, accept, requestOptions, context)); + return FluxUtil.withContext( + context -> service.int32Seconds(this.client.getEndpoint(), durationConverted, requestOptions, context)); } /** @@ -306,9 +302,8 @@ public Mono> int32SecondsWithResponseAsync(Duration duration, Req */ @ServiceMethod(returns = ReturnType.SINGLE) public Response int32SecondsWithResponse(Duration duration, RequestOptions requestOptions) { - final String accept = "application/json"; long durationConverted = duration.getSeconds(); - return service.int32SecondsSync(durationConverted, accept, requestOptions, Context.NONE); + return service.int32SecondsSync(this.client.getEndpoint(), durationConverted, requestOptions, Context.NONE); } /** @@ -324,10 +319,9 @@ public Response int32SecondsWithResponse(Duration duration, RequestOptions */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> floatSecondsWithResponseAsync(Duration duration, RequestOptions requestOptions) { - final String accept = "application/json"; double durationConverted = (double) duration.toNanos() / 1000_000_000L; - return FluxUtil - .withContext(context -> service.floatSeconds(durationConverted, accept, requestOptions, context)); + return FluxUtil.withContext( + context -> service.floatSeconds(this.client.getEndpoint(), durationConverted, requestOptions, context)); } /** @@ -343,9 +337,8 @@ public Mono> floatSecondsWithResponseAsync(Duration duration, Req */ @ServiceMethod(returns = ReturnType.SINGLE) public Response floatSecondsWithResponse(Duration duration, RequestOptions requestOptions) { - final String accept = "application/json"; double durationConverted = (double) duration.toNanos() / 1000_000_000L; - return service.floatSecondsSync(durationConverted, accept, requestOptions, Context.NONE); + return service.floatSecondsSync(this.client.getEndpoint(), durationConverted, requestOptions, Context.NONE); } /** @@ -361,10 +354,9 @@ public Response floatSecondsWithResponse(Duration duration, RequestOptions */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> float64SecondsWithResponseAsync(Duration duration, RequestOptions requestOptions) { - final String accept = "application/json"; double durationConverted = (double) duration.toNanos() / 1000_000_000L; - return FluxUtil - .withContext(context -> service.float64Seconds(durationConverted, accept, requestOptions, context)); + return FluxUtil.withContext( + context -> service.float64Seconds(this.client.getEndpoint(), durationConverted, requestOptions, context)); } /** @@ -380,8 +372,7 @@ public Mono> float64SecondsWithResponseAsync(Duration duration, R */ @ServiceMethod(returns = ReturnType.SINGLE) public Response float64SecondsWithResponse(Duration duration, RequestOptions requestOptions) { - final String accept = "application/json"; double durationConverted = (double) duration.toNanos() / 1000_000_000L; - return service.float64SecondsSync(durationConverted, accept, requestOptions, Context.NONE); + return service.float64SecondsSync(this.client.getEndpoint(), durationConverted, requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/encode/duration/implementation/PropertiesImpl.java b/typespec-tests/src/main/java/com/encode/duration/implementation/PropertiesImpl.java index b21e32a5c1..d3f98e0853 100644 --- a/typespec-tests/src/main/java/com/encode/duration/implementation/PropertiesImpl.java +++ b/typespec-tests/src/main/java/com/encode/duration/implementation/PropertiesImpl.java @@ -8,6 +8,7 @@ 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; @@ -54,7 +55,7 @@ public final class PropertiesImpl { * The interface defining all the services for DurationClientProperties to be used by the proxy service to perform * REST calls. */ - @Host("http://localhost:3000") + @Host("{endpoint}") @ServiceInterface(name = "DurationClientProper") public interface PropertiesService { @Post("/encode/duration/property/default") @@ -63,7 +64,8 @@ public interface PropertiesService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> defaultMethod(@HeaderParam("accept") String accept, + 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") @@ -72,7 +74,8 @@ Mono> defaultMethod(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response defaultMethodSync(@HeaderParam("accept") String accept, + 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") @@ -81,7 +84,8 @@ Response defaultMethodSync(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> iso8601(@HeaderParam("accept") String accept, + 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") @@ -90,7 +94,8 @@ Mono> iso8601(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response iso8601Sync(@HeaderParam("accept") String accept, + 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") @@ -99,7 +104,8 @@ Response iso8601Sync(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> int32Seconds(@HeaderParam("accept") String accept, + 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") @@ -108,7 +114,8 @@ Mono> int32Seconds(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response int32SecondsSync(@HeaderParam("accept") String accept, + 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") @@ -117,7 +124,8 @@ Response int32SecondsSync(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> floatSeconds(@HeaderParam("accept") String accept, + 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") @@ -126,7 +134,8 @@ Mono> floatSeconds(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response floatSecondsSync(@HeaderParam("accept") String accept, + 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") @@ -135,7 +144,8 @@ Response floatSecondsSync(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> float64Seconds(@HeaderParam("accept") String accept, + 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") @@ -144,7 +154,8 @@ Mono> float64Seconds(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response float64SecondsSync(@HeaderParam("accept") String accept, + 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") @@ -153,7 +164,8 @@ Response float64SecondsSync(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> floatSecondsArray(@HeaderParam("accept") String accept, + 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") @@ -162,7 +174,8 @@ Mono> floatSecondsArray(@HeaderParam("accept") String accep @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response floatSecondsArraySync(@HeaderParam("accept") String accept, + Response floatSecondsArraySync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); } @@ -194,8 +207,10 @@ Response floatSecondsArraySync(@HeaderParam("accept") String accept, */ @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(accept, body, requestOptions, context)); + return FluxUtil.withContext(context -> service.defaultMethod(this.client.getEndpoint(), contentType, accept, + body, requestOptions, context)); } /** @@ -226,8 +241,10 @@ public Mono> defaultMethodWithResponseAsync(BinaryData body */ @ServiceMethod(returns = ReturnType.SINGLE) public Response defaultMethodWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; final String accept = "application/json"; - return service.defaultMethodSync(accept, body, requestOptions, Context.NONE); + return service.defaultMethodSync(this.client.getEndpoint(), contentType, accept, body, requestOptions, + Context.NONE); } /** @@ -258,8 +275,10 @@ public Response defaultMethodWithResponse(BinaryData body, RequestOp */ @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(accept, body, requestOptions, context)); + return FluxUtil.withContext( + context -> service.iso8601(this.client.getEndpoint(), contentType, accept, body, requestOptions, context)); } /** @@ -290,8 +309,9 @@ public Mono> iso8601WithResponseAsync(BinaryData body, Requ */ @ServiceMethod(returns = ReturnType.SINGLE) public Response iso8601WithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; final String accept = "application/json"; - return service.iso8601Sync(accept, body, requestOptions, Context.NONE); + return service.iso8601Sync(this.client.getEndpoint(), contentType, accept, body, requestOptions, Context.NONE); } /** @@ -322,8 +342,10 @@ public Response iso8601WithResponse(BinaryData body, RequestOptions */ @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(accept, body, requestOptions, context)); + return FluxUtil.withContext(context -> service.int32Seconds(this.client.getEndpoint(), contentType, accept, + body, requestOptions, context)); } /** @@ -354,8 +376,10 @@ public Mono> int32SecondsWithResponseAsync(BinaryData body, */ @ServiceMethod(returns = ReturnType.SINGLE) public Response int32SecondsWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; final String accept = "application/json"; - return service.int32SecondsSync(accept, body, requestOptions, Context.NONE); + return service.int32SecondsSync(this.client.getEndpoint(), contentType, accept, body, requestOptions, + Context.NONE); } /** @@ -386,8 +410,10 @@ public Response int32SecondsWithResponse(BinaryData body, RequestOpt */ @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(accept, body, requestOptions, context)); + return FluxUtil.withContext(context -> service.floatSeconds(this.client.getEndpoint(), contentType, accept, + body, requestOptions, context)); } /** @@ -418,8 +444,10 @@ public Mono> floatSecondsWithResponseAsync(BinaryData body, */ @ServiceMethod(returns = ReturnType.SINGLE) public Response floatSecondsWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; final String accept = "application/json"; - return service.floatSecondsSync(accept, body, requestOptions, Context.NONE); + return service.floatSecondsSync(this.client.getEndpoint(), contentType, accept, body, requestOptions, + Context.NONE); } /** @@ -450,8 +478,10 @@ public Response floatSecondsWithResponse(BinaryData body, RequestOpt */ @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(accept, body, requestOptions, context)); + return FluxUtil.withContext(context -> service.float64Seconds(this.client.getEndpoint(), contentType, accept, + body, requestOptions, context)); } /** @@ -482,8 +512,10 @@ public Mono> float64SecondsWithResponseAsync(BinaryData bod */ @ServiceMethod(returns = ReturnType.SINGLE) public Response float64SecondsWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; final String accept = "application/json"; - return service.float64SecondsSync(accept, body, requestOptions, Context.NONE); + return service.float64SecondsSync(this.client.getEndpoint(), contentType, accept, body, requestOptions, + Context.NONE); } /** @@ -519,8 +551,10 @@ public Response float64SecondsWithResponse(BinaryData body, RequestO @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(accept, body, requestOptions, context)); + return FluxUtil.withContext(context -> service.floatSecondsArray(this.client.getEndpoint(), contentType, accept, + body, requestOptions, context)); } /** @@ -555,7 +589,9 @@ public Mono> floatSecondsArrayWithResponseAsync(BinaryData */ @ServiceMethod(returns = ReturnType.SINGLE) public Response floatSecondsArrayWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; final String accept = "application/json"; - return service.floatSecondsArraySync(accept, body, requestOptions, Context.NONE); + return service.floatSecondsArraySync(this.client.getEndpoint(), contentType, accept, body, requestOptions, + Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/encode/duration/implementation/QueriesImpl.java b/typespec-tests/src/main/java/com/encode/duration/implementation/QueriesImpl.java index ad2e6d2387..ce7f88f870 100644 --- a/typespec-tests/src/main/java/com/encode/duration/implementation/QueriesImpl.java +++ b/typespec-tests/src/main/java/com/encode/duration/implementation/QueriesImpl.java @@ -6,8 +6,8 @@ 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; @@ -57,7 +57,7 @@ public final class QueriesImpl { * The interface defining all the services for DurationClientQueries to be used by the proxy service to perform REST * calls. */ - @Host("http://localhost:3000") + @Host("{endpoint}") @ServiceInterface(name = "DurationClientQuerie") public interface QueriesService { @Get("/encode/duration/query/default") @@ -66,7 +66,7 @@ public interface QueriesService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> defaultMethod(@QueryParam("input") Duration input, @HeaderParam("accept") String accept, + Mono> defaultMethod(@HostParam("endpoint") String endpoint, @QueryParam("input") Duration input, RequestOptions requestOptions, Context context); @Get("/encode/duration/query/default") @@ -75,7 +75,7 @@ Mono> defaultMethod(@QueryParam("input") Duration input, @HeaderP @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response defaultMethodSync(@QueryParam("input") Duration input, @HeaderParam("accept") String accept, + Response defaultMethodSync(@HostParam("endpoint") String endpoint, @QueryParam("input") Duration input, RequestOptions requestOptions, Context context); @Get("/encode/duration/query/iso8601") @@ -84,7 +84,7 @@ Response defaultMethodSync(@QueryParam("input") Duration input, @HeaderPar @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> iso8601(@QueryParam("input") Duration input, @HeaderParam("accept") String accept, + Mono> iso8601(@HostParam("endpoint") String endpoint, @QueryParam("input") Duration input, RequestOptions requestOptions, Context context); @Get("/encode/duration/query/iso8601") @@ -93,7 +93,7 @@ Mono> iso8601(@QueryParam("input") Duration input, @HeaderParam(" @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response iso8601Sync(@QueryParam("input") Duration input, @HeaderParam("accept") String accept, + Response iso8601Sync(@HostParam("endpoint") String endpoint, @QueryParam("input") Duration input, RequestOptions requestOptions, Context context); @Get("/encode/duration/query/int32-seconds") @@ -102,7 +102,7 @@ Response iso8601Sync(@QueryParam("input") Duration input, @HeaderParam("ac @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> int32Seconds(@QueryParam("input") long input, @HeaderParam("accept") String accept, + Mono> int32Seconds(@HostParam("endpoint") String endpoint, @QueryParam("input") long input, RequestOptions requestOptions, Context context); @Get("/encode/duration/query/int32-seconds") @@ -111,7 +111,7 @@ Mono> int32Seconds(@QueryParam("input") long input, @HeaderParam( @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response int32SecondsSync(@QueryParam("input") long input, @HeaderParam("accept") String accept, + Response int32SecondsSync(@HostParam("endpoint") String endpoint, @QueryParam("input") long input, RequestOptions requestOptions, Context context); @Get("/encode/duration/query/float-seconds") @@ -120,7 +120,7 @@ Response int32SecondsSync(@QueryParam("input") long input, @HeaderParam("a @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> floatSeconds(@QueryParam("input") double input, @HeaderParam("accept") String accept, + Mono> floatSeconds(@HostParam("endpoint") String endpoint, @QueryParam("input") double input, RequestOptions requestOptions, Context context); @Get("/encode/duration/query/float-seconds") @@ -129,7 +129,7 @@ Mono> floatSeconds(@QueryParam("input") double input, @HeaderPara @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response floatSecondsSync(@QueryParam("input") double input, @HeaderParam("accept") String accept, + Response floatSecondsSync(@HostParam("endpoint") String endpoint, @QueryParam("input") double input, RequestOptions requestOptions, Context context); @Get("/encode/duration/query/float64-seconds") @@ -138,7 +138,7 @@ Response floatSecondsSync(@QueryParam("input") double input, @HeaderParam( @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> float64Seconds(@QueryParam("input") double input, @HeaderParam("accept") String accept, + Mono> float64Seconds(@HostParam("endpoint") String endpoint, @QueryParam("input") double input, RequestOptions requestOptions, Context context); @Get("/encode/duration/query/float64-seconds") @@ -147,7 +147,7 @@ Mono> float64Seconds(@QueryParam("input") double input, @HeaderPa @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response float64SecondsSync(@QueryParam("input") double input, @HeaderParam("accept") String accept, + Response float64SecondsSync(@HostParam("endpoint") String endpoint, @QueryParam("input") double input, RequestOptions requestOptions, Context context); @Get("/encode/duration/query/int32-seconds-array") @@ -156,8 +156,8 @@ Response float64SecondsSync(@QueryParam("input") double input, @HeaderPara @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> int32SecondsArray(@QueryParam("input") String input, @HeaderParam("accept") String accept, - RequestOptions requestOptions, Context context); + Mono> int32SecondsArray(@HostParam("endpoint") String endpoint, + @QueryParam("input") String input, RequestOptions requestOptions, Context context); @Get("/encode/duration/query/int32-seconds-array") @ExpectedResponses({ 204 }) @@ -165,7 +165,7 @@ Mono> int32SecondsArray(@QueryParam("input") String input, @Heade @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response int32SecondsArraySync(@QueryParam("input") String input, @HeaderParam("accept") String accept, + Response int32SecondsArraySync(@HostParam("endpoint") String endpoint, @QueryParam("input") String input, RequestOptions requestOptions, Context context); } @@ -182,8 +182,8 @@ Response int32SecondsArraySync(@QueryParam("input") String input, @HeaderP */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> defaultMethodWithResponseAsync(Duration input, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.defaultMethod(input, accept, requestOptions, context)); + return FluxUtil + .withContext(context -> service.defaultMethod(this.client.getEndpoint(), input, requestOptions, context)); } /** @@ -199,8 +199,7 @@ public Mono> defaultMethodWithResponseAsync(Duration input, Reque */ @ServiceMethod(returns = ReturnType.SINGLE) public Response defaultMethodWithResponse(Duration input, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.defaultMethodSync(input, accept, requestOptions, Context.NONE); + return service.defaultMethodSync(this.client.getEndpoint(), input, requestOptions, Context.NONE); } /** @@ -216,8 +215,8 @@ public Response defaultMethodWithResponse(Duration input, RequestOptions r */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> iso8601WithResponseAsync(Duration input, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.iso8601(input, accept, requestOptions, context)); + return FluxUtil + .withContext(context -> service.iso8601(this.client.getEndpoint(), input, requestOptions, context)); } /** @@ -233,8 +232,7 @@ public Mono> iso8601WithResponseAsync(Duration input, RequestOpti */ @ServiceMethod(returns = ReturnType.SINGLE) public Response iso8601WithResponse(Duration input, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.iso8601Sync(input, accept, requestOptions, Context.NONE); + return service.iso8601Sync(this.client.getEndpoint(), input, requestOptions, Context.NONE); } /** @@ -250,9 +248,9 @@ public Response iso8601WithResponse(Duration input, RequestOptions request */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> int32SecondsWithResponseAsync(Duration input, RequestOptions requestOptions) { - final String accept = "application/json"; long inputConverted = input.getSeconds(); - return FluxUtil.withContext(context -> service.int32Seconds(inputConverted, accept, requestOptions, context)); + return FluxUtil.withContext( + context -> service.int32Seconds(this.client.getEndpoint(), inputConverted, requestOptions, context)); } /** @@ -268,9 +266,8 @@ public Mono> int32SecondsWithResponseAsync(Duration input, Reques */ @ServiceMethod(returns = ReturnType.SINGLE) public Response int32SecondsWithResponse(Duration input, RequestOptions requestOptions) { - final String accept = "application/json"; long inputConverted = input.getSeconds(); - return service.int32SecondsSync(inputConverted, accept, requestOptions, Context.NONE); + return service.int32SecondsSync(this.client.getEndpoint(), inputConverted, requestOptions, Context.NONE); } /** @@ -286,9 +283,9 @@ public Response int32SecondsWithResponse(Duration input, RequestOptions re */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> floatSecondsWithResponseAsync(Duration input, RequestOptions requestOptions) { - final String accept = "application/json"; double inputConverted = (double) input.toNanos() / 1000_000_000L; - return FluxUtil.withContext(context -> service.floatSeconds(inputConverted, accept, requestOptions, context)); + return FluxUtil.withContext( + context -> service.floatSeconds(this.client.getEndpoint(), inputConverted, requestOptions, context)); } /** @@ -304,9 +301,8 @@ public Mono> floatSecondsWithResponseAsync(Duration input, Reques */ @ServiceMethod(returns = ReturnType.SINGLE) public Response floatSecondsWithResponse(Duration input, RequestOptions requestOptions) { - final String accept = "application/json"; double inputConverted = (double) input.toNanos() / 1000_000_000L; - return service.floatSecondsSync(inputConverted, accept, requestOptions, Context.NONE); + return service.floatSecondsSync(this.client.getEndpoint(), inputConverted, requestOptions, Context.NONE); } /** @@ -322,9 +318,9 @@ public Response floatSecondsWithResponse(Duration input, RequestOptions re */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> float64SecondsWithResponseAsync(Duration input, RequestOptions requestOptions) { - final String accept = "application/json"; double inputConverted = (double) input.toNanos() / 1000_000_000L; - return FluxUtil.withContext(context -> service.float64Seconds(inputConverted, accept, requestOptions, context)); + return FluxUtil.withContext( + context -> service.float64Seconds(this.client.getEndpoint(), inputConverted, requestOptions, context)); } /** @@ -340,9 +336,8 @@ public Mono> float64SecondsWithResponseAsync(Duration input, Requ */ @ServiceMethod(returns = ReturnType.SINGLE) public Response float64SecondsWithResponse(Duration input, RequestOptions requestOptions) { - final String accept = "application/json"; double inputConverted = (double) input.toNanos() / 1000_000_000L; - return service.float64SecondsSync(inputConverted, accept, requestOptions, Context.NONE); + return service.float64SecondsSync(this.client.getEndpoint(), inputConverted, requestOptions, Context.NONE); } /** @@ -359,13 +354,12 @@ public Response float64SecondsWithResponse(Duration input, RequestOptions @ServiceMethod(returns = ReturnType.SINGLE) public Mono> int32SecondsArrayWithResponseAsync(List input, RequestOptions requestOptions) { - final String accept = "application/json"; String inputConverted = JacksonAdapter.createDefaultSerializerAdapter() .serializeIterable( input.stream().map(paramItemValue -> paramItemValue.getSeconds()).collect(Collectors.toList()), CollectionFormat.CSV); - return FluxUtil - .withContext(context -> service.int32SecondsArray(inputConverted, accept, requestOptions, context)); + return FluxUtil.withContext( + context -> service.int32SecondsArray(this.client.getEndpoint(), inputConverted, requestOptions, context)); } /** @@ -381,11 +375,10 @@ public Mono> int32SecondsArrayWithResponseAsync(List in */ @ServiceMethod(returns = ReturnType.SINGLE) public Response int32SecondsArrayWithResponse(List input, RequestOptions requestOptions) { - final String accept = "application/json"; String inputConverted = JacksonAdapter.createDefaultSerializerAdapter() .serializeIterable( input.stream().map(paramItemValue -> paramItemValue.getSeconds()).collect(Collectors.toList()), CollectionFormat.CSV); - return service.int32SecondsArraySync(inputConverted, accept, requestOptions, Context.NONE); + return service.int32SecondsArraySync(this.client.getEndpoint(), inputConverted, requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/encode/numeric/NumericClientBuilder.java b/typespec-tests/src/main/java/com/encode/numeric/NumericClientBuilder.java index 10b5459239..e227406f3c 100644 --- a/typespec-tests/src/main/java/com/encode/numeric/NumericClientBuilder.java +++ b/typespec-tests/src/main/java/com/encode/numeric/NumericClientBuilder.java @@ -7,6 +7,7 @@ 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; @@ -40,8 +41,8 @@ * A builder for creating a new instance of the NumericClient type. */ @ServiceClientBuilder(serviceClients = { NumericClient.class, NumericAsyncClient.class }) -public final class NumericClientBuilder - implements HttpTrait, ConfigurationTrait { +public final class NumericClientBuilder implements HttpTrait, + ConfigurationTrait, EndpointTrait { @Generated private static final String SDK_NAME = "name"; @@ -172,6 +173,22 @@ public NumericClientBuilder configuration(Configuration configuration) { return this; } + /* + * The service endpoint + */ + @Generated + private String endpoint; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public NumericClientBuilder endpoint(String endpoint) { + this.endpoint = endpoint; + return this; + } + /* * The retry policy that will attempt to retry failed requests, if applicable. */ @@ -199,8 +216,9 @@ public NumericClientBuilder retryPolicy(RetryPolicy retryPolicy) { private NumericClientImpl buildInnerClient() { this.validateClient(); HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); + String localEndpoint = (endpoint != null) ? endpoint : "http://localhost:3000"; NumericClientImpl client - = new NumericClientImpl(localPipeline, JacksonAdapter.createDefaultSerializerAdapter()); + = new NumericClientImpl(localPipeline, JacksonAdapter.createDefaultSerializerAdapter(), localEndpoint); return client; } diff --git a/typespec-tests/src/main/java/com/encode/numeric/implementation/NumericClientImpl.java b/typespec-tests/src/main/java/com/encode/numeric/implementation/NumericClientImpl.java index 233fd3eaa9..8f00a5a257 100644 --- a/typespec-tests/src/main/java/com/encode/numeric/implementation/NumericClientImpl.java +++ b/typespec-tests/src/main/java/com/encode/numeric/implementation/NumericClientImpl.java @@ -15,6 +15,20 @@ * Initializes a new instance of the NumericClient type. */ public final class NumericClientImpl { + /** + * 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. */ @@ -59,19 +73,22 @@ public PropertiesImpl getProperties() { /** * Initializes an instance of NumericClient client. + * + * @param endpoint Service host. */ - public NumericClientImpl() { + public NumericClientImpl(String endpoint) { this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), - JacksonAdapter.createDefaultSerializerAdapter()); + JacksonAdapter.createDefaultSerializerAdapter(), endpoint); } /** * Initializes an instance of NumericClient client. * * @param httpPipeline The HTTP pipeline to send requests through. + * @param endpoint Service host. */ - public NumericClientImpl(HttpPipeline httpPipeline) { - this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter()); + public NumericClientImpl(HttpPipeline httpPipeline, String endpoint) { + this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint); } /** @@ -79,10 +96,12 @@ public NumericClientImpl(HttpPipeline httpPipeline) { * * @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 NumericClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter) { + public NumericClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, String endpoint) { this.httpPipeline = httpPipeline; this.serializerAdapter = serializerAdapter; + this.endpoint = endpoint; this.properties = new PropertiesImpl(this); } } diff --git a/typespec-tests/src/main/java/com/encode/numeric/implementation/PropertiesImpl.java b/typespec-tests/src/main/java/com/encode/numeric/implementation/PropertiesImpl.java index 5122f7a0ac..072d8ed024 100644 --- a/typespec-tests/src/main/java/com/encode/numeric/implementation/PropertiesImpl.java +++ b/typespec-tests/src/main/java/com/encode/numeric/implementation/PropertiesImpl.java @@ -8,6 +8,7 @@ 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; @@ -54,7 +55,7 @@ public final class PropertiesImpl { * The interface defining all the services for NumericClientProperties to be used by the proxy service to perform * REST calls. */ - @Host("http://localhost:3000") + @Host("{endpoint}") @ServiceInterface(name = "NumericClientPropert") public interface PropertiesService { @Post("/encode/numeric/property/safeint") @@ -63,7 +64,8 @@ public interface PropertiesService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> safeintAsString(@HeaderParam("accept") String accept, + Mono> safeintAsString(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); @Post("/encode/numeric/property/safeint") @@ -72,7 +74,8 @@ Mono> safeintAsString(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response safeintAsStringSync(@HeaderParam("accept") String accept, + Response safeintAsStringSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); @Post("/encode/numeric/property/uint32") @@ -81,7 +84,8 @@ Response safeintAsStringSync(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> uint32AsStringOptional(@HeaderParam("accept") String accept, + Mono> uint32AsStringOptional(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); @Post("/encode/numeric/property/uint32") @@ -90,7 +94,8 @@ Mono> uint32AsStringOptional(@HeaderParam("accept") String @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response uint32AsStringOptionalSync(@HeaderParam("accept") String accept, + Response uint32AsStringOptionalSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); } @@ -122,8 +127,10 @@ Response uint32AsStringOptionalSync(@HeaderParam("accept") String ac */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> safeintAsStringWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; final String accept = "application/json"; - return FluxUtil.withContext(context -> service.safeintAsString(accept, body, requestOptions, context)); + return FluxUtil.withContext(context -> service.safeintAsString(this.client.getEndpoint(), contentType, accept, + body, requestOptions, context)); } /** @@ -154,8 +161,10 @@ public Mono> safeintAsStringWithResponseAsync(BinaryData bo */ @ServiceMethod(returns = ReturnType.SINGLE) public Response safeintAsStringWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; final String accept = "application/json"; - return service.safeintAsStringSync(accept, body, requestOptions, Context.NONE); + return service.safeintAsStringSync(this.client.getEndpoint(), contentType, accept, body, requestOptions, + Context.NONE); } /** @@ -187,8 +196,10 @@ public Response safeintAsStringWithResponse(BinaryData body, Request @ServiceMethod(returns = ReturnType.SINGLE) public Mono> uint32AsStringOptionalWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; final String accept = "application/json"; - return FluxUtil.withContext(context -> service.uint32AsStringOptional(accept, body, requestOptions, context)); + return FluxUtil.withContext(context -> service.uint32AsStringOptional(this.client.getEndpoint(), contentType, + accept, body, requestOptions, context)); } /** @@ -219,7 +230,9 @@ public Mono> uint32AsStringOptionalWithResponseAsync(Binary */ @ServiceMethod(returns = ReturnType.SINGLE) public Response uint32AsStringOptionalWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; final String accept = "application/json"; - return service.uint32AsStringOptionalSync(accept, body, requestOptions, Context.NONE); + return service.uint32AsStringOptionalSync(this.client.getEndpoint(), contentType, accept, body, requestOptions, + Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/parameters/basic/BasicClientBuilder.java b/typespec-tests/src/main/java/com/parameters/basic/BasicClientBuilder.java index 6384f456a6..db9f8484e1 100644 --- a/typespec-tests/src/main/java/com/parameters/basic/BasicClientBuilder.java +++ b/typespec-tests/src/main/java/com/parameters/basic/BasicClientBuilder.java @@ -7,6 +7,7 @@ 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; @@ -45,7 +46,8 @@ ImplicitBodyClient.class, ExplicitBodyAsyncClient.class, ImplicitBodyAsyncClient.class }) -public final class BasicClientBuilder implements HttpTrait, ConfigurationTrait { +public final class BasicClientBuilder implements HttpTrait, ConfigurationTrait, + EndpointTrait { @Generated private static final String SDK_NAME = "name"; @@ -176,6 +178,22 @@ public BasicClientBuilder configuration(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. */ @@ -203,7 +221,9 @@ public BasicClientBuilder retryPolicy(RetryPolicy retryPolicy) { private BasicClientImpl buildInnerClient() { this.validateClient(); HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); - BasicClientImpl client = new BasicClientImpl(localPipeline, JacksonAdapter.createDefaultSerializerAdapter()); + String localEndpoint = (endpoint != null) ? endpoint : "http://localhost:3000"; + BasicClientImpl client + = new BasicClientImpl(localPipeline, JacksonAdapter.createDefaultSerializerAdapter(), localEndpoint); return client; } diff --git a/typespec-tests/src/main/java/com/parameters/basic/implementation/BasicClientImpl.java b/typespec-tests/src/main/java/com/parameters/basic/implementation/BasicClientImpl.java index 67dae32ce8..d1abd782b8 100644 --- a/typespec-tests/src/main/java/com/parameters/basic/implementation/BasicClientImpl.java +++ b/typespec-tests/src/main/java/com/parameters/basic/implementation/BasicClientImpl.java @@ -15,6 +15,20 @@ * 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. */ @@ -73,19 +87,22 @@ public ImplicitBodiesImpl getImplicitBodies() { /** * Initializes an instance of BasicClient client. + * + * @param endpoint Service host. */ - public BasicClientImpl() { + public BasicClientImpl(String endpoint) { this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), - JacksonAdapter.createDefaultSerializerAdapter()); + 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) { - this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter()); + public BasicClientImpl(HttpPipeline httpPipeline, String endpoint) { + this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint); } /** @@ -93,10 +110,12 @@ public BasicClientImpl(HttpPipeline httpPipeline) { * * @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) { + 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/typespec-tests/src/main/java/com/parameters/basic/implementation/ExplicitBodiesImpl.java b/typespec-tests/src/main/java/com/parameters/basic/implementation/ExplicitBodiesImpl.java index 0da230c5da..1d8fb58927 100644 --- a/typespec-tests/src/main/java/com/parameters/basic/implementation/ExplicitBodiesImpl.java +++ b/typespec-tests/src/main/java/com/parameters/basic/implementation/ExplicitBodiesImpl.java @@ -8,6 +8,7 @@ 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; @@ -54,7 +55,7 @@ public final class ExplicitBodiesImpl { * The interface defining all the services for BasicClientExplicitBodies to be used by the proxy service to perform * REST calls. */ - @Host("http://localhost:3000") + @Host("{endpoint}") @ServiceInterface(name = "BasicClientExplicitB") public interface ExplicitBodiesService { @Put("/parameters/basic/explicit-body/simple") @@ -63,8 +64,9 @@ public interface ExplicitBodiesService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> simple(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + 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 }) @@ -72,7 +74,8 @@ Mono> simple(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response simpleSync(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, + Response simpleSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); } @@ -96,8 +99,9 @@ Response simpleSync(@HeaderParam("accept") String accept, @BodyParam("appl */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> simpleWithResponseAsync(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.simple(accept, body, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.simple(this.client.getEndpoint(), contentType, body, requestOptions, context)); } /** @@ -120,7 +124,7 @@ public Mono> simpleWithResponseAsync(BinaryData body, RequestOpti */ @ServiceMethod(returns = ReturnType.SINGLE) public Response simpleWithResponse(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.simpleSync(accept, body, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.simpleSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/parameters/basic/implementation/ImplicitBodiesImpl.java b/typespec-tests/src/main/java/com/parameters/basic/implementation/ImplicitBodiesImpl.java index e6488ff8c4..1278afcded 100644 --- a/typespec-tests/src/main/java/com/parameters/basic/implementation/ImplicitBodiesImpl.java +++ b/typespec-tests/src/main/java/com/parameters/basic/implementation/ImplicitBodiesImpl.java @@ -8,6 +8,7 @@ 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; @@ -54,7 +55,7 @@ public final class ImplicitBodiesImpl { * The interface defining all the services for BasicClientImplicitBodies to be used by the proxy service to perform * REST calls. */ - @Host("http://localhost:3000") + @Host("{endpoint}") @ServiceInterface(name = "BasicClientImplicitB") public interface ImplicitBodiesService { @Put("/parameters/basic/implicit-body/simple") @@ -63,8 +64,9 @@ public interface ImplicitBodiesService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> simple(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData simpleRequest, RequestOptions requestOptions, Context context); + 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 }) @@ -72,8 +74,9 @@ Mono> simple(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response simpleSync(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData simpleRequest, RequestOptions requestOptions, Context context); + Response simpleSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData simpleRequest, + RequestOptions requestOptions, Context context); } /** @@ -96,8 +99,9 @@ Response simpleSync(@HeaderParam("accept") String accept, */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> simpleWithResponseAsync(BinaryData simpleRequest, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.simple(accept, simpleRequest, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.simple(this.client.getEndpoint(), contentType, simpleRequest, requestOptions, context)); } /** @@ -120,7 +124,7 @@ public Mono> simpleWithResponseAsync(BinaryData simpleRequest, Re */ @ServiceMethod(returns = ReturnType.SINGLE) public Response simpleWithResponse(BinaryData simpleRequest, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.simpleSync(accept, simpleRequest, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.simpleSync(this.client.getEndpoint(), contentType, simpleRequest, requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/parameters/bodyoptionality/BodyOptionalityClientBuilder.java b/typespec-tests/src/main/java/com/parameters/bodyoptionality/BodyOptionalityClientBuilder.java index 0c6daba8e4..8ff3dc9c93 100644 --- a/typespec-tests/src/main/java/com/parameters/bodyoptionality/BodyOptionalityClientBuilder.java +++ b/typespec-tests/src/main/java/com/parameters/bodyoptionality/BodyOptionalityClientBuilder.java @@ -7,6 +7,7 @@ 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; @@ -45,8 +46,8 @@ OptionalExplicitClient.class, BodyOptionalityAsyncClient.class, OptionalExplicitAsyncClient.class }) -public final class BodyOptionalityClientBuilder - implements HttpTrait, ConfigurationTrait { +public final class BodyOptionalityClientBuilder implements HttpTrait, + ConfigurationTrait, EndpointTrait { @Generated private static final String SDK_NAME = "name"; @@ -178,6 +179,22 @@ public BodyOptionalityClientBuilder configuration(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. */ @@ -205,8 +222,9 @@ public BodyOptionalityClientBuilder retryPolicy(RetryPolicy retryPolicy) { private BodyOptionalityClientImpl buildInnerClient() { this.validateClient(); HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); - BodyOptionalityClientImpl client - = new BodyOptionalityClientImpl(localPipeline, JacksonAdapter.createDefaultSerializerAdapter()); + String localEndpoint = (endpoint != null) ? endpoint : "http://localhost:3000"; + BodyOptionalityClientImpl client = new BodyOptionalityClientImpl(localPipeline, + JacksonAdapter.createDefaultSerializerAdapter(), localEndpoint); return client; } diff --git a/typespec-tests/src/main/java/com/parameters/bodyoptionality/implementation/BodyOptionalityClientImpl.java b/typespec-tests/src/main/java/com/parameters/bodyoptionality/implementation/BodyOptionalityClientImpl.java index 9e11573ccc..56a73fd13b 100644 --- a/typespec-tests/src/main/java/com/parameters/bodyoptionality/implementation/BodyOptionalityClientImpl.java +++ b/typespec-tests/src/main/java/com/parameters/bodyoptionality/implementation/BodyOptionalityClientImpl.java @@ -8,6 +8,7 @@ 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; @@ -40,6 +41,20 @@ public final class BodyOptionalityClientImpl { */ 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. */ @@ -84,19 +99,22 @@ public OptionalExplicitsImpl getOptionalExplicits() { /** * Initializes an instance of BodyOptionalityClient client. + * + * @param endpoint Service host. */ - public BodyOptionalityClientImpl() { + public BodyOptionalityClientImpl(String endpoint) { this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), - JacksonAdapter.createDefaultSerializerAdapter()); + 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) { - this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter()); + public BodyOptionalityClientImpl(HttpPipeline httpPipeline, String endpoint) { + this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint); } /** @@ -104,10 +122,12 @@ public BodyOptionalityClientImpl(HttpPipeline httpPipeline) { * * @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) { + 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()); @@ -117,7 +137,7 @@ public BodyOptionalityClientImpl(HttpPipeline httpPipeline, SerializerAdapter se * The interface defining all the services for BodyOptionalityClient to be used by the proxy service to perform REST * calls. */ - @Host("http://localhost:3000") + @Host("{endpoint}") @ServiceInterface(name = "BodyOptionalityClien") public interface BodyOptionalityClientService { @Post("/parameters/body-optionality/required-explicit") @@ -126,8 +146,9 @@ public interface BodyOptionalityClientService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> requiredExplicit(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + 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 }) @@ -135,8 +156,9 @@ Mono> requiredExplicit(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response requiredExplicitSync(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + 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 }) @@ -144,7 +166,8 @@ Response requiredExplicitSync(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> requiredImplicit(@HeaderParam("accept") String accept, + Mono> requiredImplicit(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData requiredImplicitRequest, RequestOptions requestOptions, Context context); @@ -154,7 +177,8 @@ Mono> requiredImplicit(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response requiredImplicitSync(@HeaderParam("accept") String accept, + Response requiredImplicitSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData requiredImplicitRequest, RequestOptions requestOptions, Context context); } @@ -179,8 +203,9 @@ Response requiredImplicitSync(@HeaderParam("accept") String accept, */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> requiredExplicitWithResponseAsync(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.requiredExplicit(accept, body, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.requiredExplicit(this.getEndpoint(), contentType, body, requestOptions, context)); } /** @@ -203,8 +228,8 @@ public Mono> requiredExplicitWithResponseAsync(BinaryData body, R */ @ServiceMethod(returns = ReturnType.SINGLE) public Response requiredExplicitWithResponse(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.requiredExplicitSync(accept, body, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.requiredExplicitSync(this.getEndpoint(), contentType, body, requestOptions, Context.NONE); } /** @@ -228,9 +253,9 @@ public Response requiredExplicitWithResponse(BinaryData body, RequestOptio @ServiceMethod(returns = ReturnType.SINGLE) public Mono> requiredImplicitWithResponseAsync(BinaryData requiredImplicitRequest, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil - .withContext(context -> service.requiredImplicit(accept, requiredImplicitRequest, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil.withContext(context -> service.requiredImplicit(this.getEndpoint(), contentType, + requiredImplicitRequest, requestOptions, context)); } /** @@ -254,7 +279,8 @@ public Mono> requiredImplicitWithResponseAsync(BinaryData require @ServiceMethod(returns = ReturnType.SINGLE) public Response requiredImplicitWithResponse(BinaryData requiredImplicitRequest, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.requiredImplicitSync(accept, requiredImplicitRequest, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.requiredImplicitSync(this.getEndpoint(), contentType, requiredImplicitRequest, requestOptions, + Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/parameters/bodyoptionality/implementation/OptionalExplicitsImpl.java b/typespec-tests/src/main/java/com/parameters/bodyoptionality/implementation/OptionalExplicitsImpl.java index 91b84dee3f..cb4d687e7b 100644 --- a/typespec-tests/src/main/java/com/parameters/bodyoptionality/implementation/OptionalExplicitsImpl.java +++ b/typespec-tests/src/main/java/com/parameters/bodyoptionality/implementation/OptionalExplicitsImpl.java @@ -5,8 +5,8 @@ package com.parameters.bodyoptionality.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.Post; import com.azure.core.annotation.ReturnType; import com.azure.core.annotation.ServiceInterface; @@ -53,7 +53,7 @@ public final class OptionalExplicitsImpl { * The interface defining all the services for BodyOptionalityClientOptionalExplicits to be used by the proxy * service to perform REST calls. */ - @Host("http://localhost:3000") + @Host("{endpoint}") @ServiceInterface(name = "BodyOptionalityClien") public interface OptionalExplicitsService { @Post("/parameters/body-optionality/optional-explicit/set") @@ -62,7 +62,8 @@ public interface OptionalExplicitsService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> set(@HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + Mono> set(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, + Context context); @Post("/parameters/body-optionality/optional-explicit/set") @ExpectedResponses({ 204 }) @@ -70,7 +71,7 @@ public interface OptionalExplicitsService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response setSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + Response setSync(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, Context context); @Post("/parameters/body-optionality/optional-explicit/omit") @ExpectedResponses({ 204 }) @@ -78,7 +79,8 @@ public interface OptionalExplicitsService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> omit(@HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + Mono> omit(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, + Context context); @Post("/parameters/body-optionality/optional-explicit/omit") @ExpectedResponses({ 204 }) @@ -86,7 +88,7 @@ public interface OptionalExplicitsService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response omitSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + Response omitSync(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, Context context); } /** @@ -116,14 +118,13 @@ public interface OptionalExplicitsService { */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> setWithResponseAsync(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.set(accept, requestOptionsLocal, context)); + return FluxUtil.withContext(context -> service.set(this.client.getEndpoint(), requestOptionsLocal, context)); } /** @@ -153,14 +154,13 @@ public Mono> setWithResponseAsync(RequestOptions requestOptions) */ @ServiceMethod(returns = ReturnType.SINGLE) public Response setWithResponse(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.setSync(accept, requestOptionsLocal, Context.NONE); + return service.setSync(this.client.getEndpoint(), requestOptionsLocal, Context.NONE); } /** @@ -190,14 +190,13 @@ public Response setWithResponse(RequestOptions requestOptions) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> omitWithResponseAsync(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.omit(accept, requestOptionsLocal, context)); + return FluxUtil.withContext(context -> service.omit(this.client.getEndpoint(), requestOptionsLocal, context)); } /** @@ -227,13 +226,12 @@ public Mono> omitWithResponseAsync(RequestOptions requestOptions) */ @ServiceMethod(returns = ReturnType.SINGLE) public Response omitWithResponse(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.omitSync(accept, requestOptionsLocal, Context.NONE); + return service.omitSync(this.client.getEndpoint(), requestOptionsLocal, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/parameters/collectionformat/CollectionFormatClientBuilder.java b/typespec-tests/src/main/java/com/parameters/collectionformat/CollectionFormatClientBuilder.java index 0d251b6a5b..f029cc7b92 100644 --- a/typespec-tests/src/main/java/com/parameters/collectionformat/CollectionFormatClientBuilder.java +++ b/typespec-tests/src/main/java/com/parameters/collectionformat/CollectionFormatClientBuilder.java @@ -7,6 +7,7 @@ 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; @@ -41,8 +42,8 @@ */ @ServiceClientBuilder( serviceClients = { QueryClient.class, HeaderClient.class, QueryAsyncClient.class, HeaderAsyncClient.class }) -public final class CollectionFormatClientBuilder - implements HttpTrait, ConfigurationTrait { +public final class CollectionFormatClientBuilder implements HttpTrait, + ConfigurationTrait, EndpointTrait { @Generated private static final String SDK_NAME = "name"; @@ -174,6 +175,22 @@ public CollectionFormatClientBuilder configuration(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. */ @@ -201,8 +218,9 @@ public CollectionFormatClientBuilder retryPolicy(RetryPolicy retryPolicy) { private CollectionFormatClientImpl buildInnerClient() { this.validateClient(); HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); - CollectionFormatClientImpl client - = new CollectionFormatClientImpl(localPipeline, JacksonAdapter.createDefaultSerializerAdapter()); + String localEndpoint = (endpoint != null) ? endpoint : "http://localhost:3000"; + CollectionFormatClientImpl client = new CollectionFormatClientImpl(localPipeline, + JacksonAdapter.createDefaultSerializerAdapter(), localEndpoint); return client; } diff --git a/typespec-tests/src/main/java/com/parameters/collectionformat/implementation/CollectionFormatClientImpl.java b/typespec-tests/src/main/java/com/parameters/collectionformat/implementation/CollectionFormatClientImpl.java index 24d094c116..aa16ca784b 100644 --- a/typespec-tests/src/main/java/com/parameters/collectionformat/implementation/CollectionFormatClientImpl.java +++ b/typespec-tests/src/main/java/com/parameters/collectionformat/implementation/CollectionFormatClientImpl.java @@ -15,6 +15,20 @@ * 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. */ @@ -73,19 +87,22 @@ public HeadersImpl getHeaders() { /** * Initializes an instance of CollectionFormatClient client. + * + * @param endpoint Service host. */ - public CollectionFormatClientImpl() { + public CollectionFormatClientImpl(String endpoint) { this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), - JacksonAdapter.createDefaultSerializerAdapter()); + 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) { - this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter()); + public CollectionFormatClientImpl(HttpPipeline httpPipeline, String endpoint) { + this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint); } /** @@ -93,10 +110,12 @@ public CollectionFormatClientImpl(HttpPipeline httpPipeline) { * * @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) { + 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/typespec-tests/src/main/java/com/parameters/collectionformat/implementation/HeadersImpl.java b/typespec-tests/src/main/java/com/parameters/collectionformat/implementation/HeadersImpl.java index 267582535c..49f15aeacb 100644 --- a/typespec-tests/src/main/java/com/parameters/collectionformat/implementation/HeadersImpl.java +++ b/typespec-tests/src/main/java/com/parameters/collectionformat/implementation/HeadersImpl.java @@ -8,6 +8,7 @@ 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; @@ -54,7 +55,7 @@ public final class HeadersImpl { * The interface defining all the services for CollectionFormatClientHeaders to be used by the proxy service to * perform REST calls. */ - @Host("http://localhost:3000") + @Host("{endpoint}") @ServiceInterface(name = "CollectionFormatClie") public interface HeadersService { @Get("/parameters/collection-format/header/csv") @@ -63,7 +64,7 @@ public interface HeadersService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> csv(@HeaderParam("colors") String colors, @HeaderParam("accept") String accept, + Mono> csv(@HostParam("endpoint") String endpoint, @HeaderParam("colors") String colors, RequestOptions requestOptions, Context context); @Get("/parameters/collection-format/header/csv") @@ -72,7 +73,7 @@ Mono> csv(@HeaderParam("colors") String colors, @HeaderParam("acc @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response csvSync(@HeaderParam("colors") String colors, @HeaderParam("accept") String accept, + Response csvSync(@HostParam("endpoint") String endpoint, @HeaderParam("colors") String colors, RequestOptions requestOptions, Context context); } @@ -89,11 +90,11 @@ Response csvSync(@HeaderParam("colors") String colors, @HeaderParam("accep */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> csvWithResponseAsync(List colors, RequestOptions requestOptions) { - final String accept = "application/json"; String colorsConverted = colors.stream() .map(paramItemValue -> Objects.toString(paramItemValue, "")) .collect(Collectors.joining(",")); - return FluxUtil.withContext(context -> service.csv(colorsConverted, accept, requestOptions, context)); + return FluxUtil + .withContext(context -> service.csv(this.client.getEndpoint(), colorsConverted, requestOptions, context)); } /** @@ -109,10 +110,9 @@ public Mono> csvWithResponseAsync(List colors, RequestOpt */ @ServiceMethod(returns = ReturnType.SINGLE) public Response csvWithResponse(List colors, RequestOptions requestOptions) { - final String accept = "application/json"; String colorsConverted = colors.stream() .map(paramItemValue -> Objects.toString(paramItemValue, "")) .collect(Collectors.joining(",")); - return service.csvSync(colorsConverted, accept, requestOptions, Context.NONE); + return service.csvSync(this.client.getEndpoint(), colorsConverted, requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/parameters/collectionformat/implementation/QueriesImpl.java b/typespec-tests/src/main/java/com/parameters/collectionformat/implementation/QueriesImpl.java index b55f7842f8..b68ab56256 100644 --- a/typespec-tests/src/main/java/com/parameters/collectionformat/implementation/QueriesImpl.java +++ b/typespec-tests/src/main/java/com/parameters/collectionformat/implementation/QueriesImpl.java @@ -6,8 +6,8 @@ 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; @@ -55,7 +55,7 @@ public final class QueriesImpl { * The interface defining all the services for CollectionFormatClientQueries to be used by the proxy service to * perform REST calls. */ - @Host("http://localhost:3000") + @Host("{endpoint}") @ServiceInterface(name = "CollectionFormatClie") public interface QueriesService { @Get("/parameters/collection-format/query/multi") @@ -64,8 +64,9 @@ public interface QueriesService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> multi(@QueryParam(value = "colors", multipleQueryParams = true) List colors, - @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + 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 }) @@ -73,8 +74,9 @@ Mono> multi(@QueryParam(value = "colors", multipleQueryParams = t @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response multiSync(@QueryParam(value = "colors", multipleQueryParams = true) List colors, - @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + 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 }) @@ -82,7 +84,7 @@ Response multiSync(@QueryParam(value = "colors", multipleQueryParams = tru @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> ssv(@QueryParam("colors") String colors, @HeaderParam("accept") String accept, + Mono> ssv(@HostParam("endpoint") String endpoint, @QueryParam("colors") String colors, RequestOptions requestOptions, Context context); @Get("/parameters/collection-format/query/ssv") @@ -91,7 +93,7 @@ Mono> ssv(@QueryParam("colors") String colors, @HeaderParam("acce @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response ssvSync(@QueryParam("colors") String colors, @HeaderParam("accept") String accept, + Response ssvSync(@HostParam("endpoint") String endpoint, @QueryParam("colors") String colors, RequestOptions requestOptions, Context context); @Get("/parameters/collection-format/query/tsv") @@ -100,7 +102,7 @@ Response ssvSync(@QueryParam("colors") String colors, @HeaderParam("accept @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> tsv(@QueryParam("colors") String colors, @HeaderParam("accept") String accept, + Mono> tsv(@HostParam("endpoint") String endpoint, @QueryParam("colors") String colors, RequestOptions requestOptions, Context context); @Get("/parameters/collection-format/query/tsv") @@ -109,7 +111,7 @@ Mono> tsv(@QueryParam("colors") String colors, @HeaderParam("acce @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response tsvSync(@QueryParam("colors") String colors, @HeaderParam("accept") String accept, + Response tsvSync(@HostParam("endpoint") String endpoint, @QueryParam("colors") String colors, RequestOptions requestOptions, Context context); @Get("/parameters/collection-format/query/pipes") @@ -118,7 +120,7 @@ Response tsvSync(@QueryParam("colors") String colors, @HeaderParam("accept @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> pipes(@QueryParam("colors") String colors, @HeaderParam("accept") String accept, + Mono> pipes(@HostParam("endpoint") String endpoint, @QueryParam("colors") String colors, RequestOptions requestOptions, Context context); @Get("/parameters/collection-format/query/pipes") @@ -127,7 +129,7 @@ Mono> pipes(@QueryParam("colors") String colors, @HeaderParam("ac @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response pipesSync(@QueryParam("colors") String colors, @HeaderParam("accept") String accept, + Response pipesSync(@HostParam("endpoint") String endpoint, @QueryParam("colors") String colors, RequestOptions requestOptions, Context context); @Get("/parameters/collection-format/query/csv") @@ -136,7 +138,7 @@ Response pipesSync(@QueryParam("colors") String colors, @HeaderParam("acce @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> csv(@QueryParam("colors") String colors, @HeaderParam("accept") String accept, + Mono> csv(@HostParam("endpoint") String endpoint, @QueryParam("colors") String colors, RequestOptions requestOptions, Context context); @Get("/parameters/collection-format/query/csv") @@ -145,7 +147,7 @@ Mono> csv(@QueryParam("colors") String colors, @HeaderParam("acce @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response csvSync(@QueryParam("colors") String colors, @HeaderParam("accept") String accept, + Response csvSync(@HostParam("endpoint") String endpoint, @QueryParam("colors") String colors, RequestOptions requestOptions, Context context); } @@ -162,10 +164,10 @@ Response csvSync(@QueryParam("colors") String colors, @HeaderParam("accept */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> multiWithResponseAsync(List colors, RequestOptions requestOptions) { - final String accept = "application/json"; List colorsConverted = colors.stream().map(item -> Objects.toString(item, "")).collect(Collectors.toList()); - return FluxUtil.withContext(context -> service.multi(colorsConverted, accept, requestOptions, context)); + return FluxUtil + .withContext(context -> service.multi(this.client.getEndpoint(), colorsConverted, requestOptions, context)); } /** @@ -181,10 +183,9 @@ public Mono> multiWithResponseAsync(List colors, RequestO */ @ServiceMethod(returns = ReturnType.SINGLE) public Response multiWithResponse(List colors, RequestOptions requestOptions) { - final String accept = "application/json"; List colorsConverted = colors.stream().map(item -> Objects.toString(item, "")).collect(Collectors.toList()); - return service.multiSync(colorsConverted, accept, requestOptions, Context.NONE); + return service.multiSync(this.client.getEndpoint(), colorsConverted, requestOptions, Context.NONE); } /** @@ -200,11 +201,11 @@ public Response multiWithResponse(List colors, RequestOptions requ */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> ssvWithResponseAsync(List colors, RequestOptions requestOptions) { - final String accept = "application/json"; String colorsConverted = colors.stream() .map(paramItemValue -> Objects.toString(paramItemValue, "")) .collect(Collectors.joining(" ")); - return FluxUtil.withContext(context -> service.ssv(colorsConverted, accept, requestOptions, context)); + return FluxUtil + .withContext(context -> service.ssv(this.client.getEndpoint(), colorsConverted, requestOptions, context)); } /** @@ -220,11 +221,10 @@ public Mono> ssvWithResponseAsync(List colors, RequestOpt */ @ServiceMethod(returns = ReturnType.SINGLE) public Response ssvWithResponse(List colors, RequestOptions requestOptions) { - final String accept = "application/json"; String colorsConverted = colors.stream() .map(paramItemValue -> Objects.toString(paramItemValue, "")) .collect(Collectors.joining(" ")); - return service.ssvSync(colorsConverted, accept, requestOptions, Context.NONE); + return service.ssvSync(this.client.getEndpoint(), colorsConverted, requestOptions, Context.NONE); } /** @@ -240,11 +240,11 @@ public Response ssvWithResponse(List colors, RequestOptions reques */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> tsvWithResponseAsync(List colors, RequestOptions requestOptions) { - final String accept = "application/json"; String colorsConverted = colors.stream() .map(paramItemValue -> Objects.toString(paramItemValue, "")) .collect(Collectors.joining("\t")); - return FluxUtil.withContext(context -> service.tsv(colorsConverted, accept, requestOptions, context)); + return FluxUtil + .withContext(context -> service.tsv(this.client.getEndpoint(), colorsConverted, requestOptions, context)); } /** @@ -260,11 +260,10 @@ public Mono> tsvWithResponseAsync(List colors, RequestOpt */ @ServiceMethod(returns = ReturnType.SINGLE) public Response tsvWithResponse(List colors, RequestOptions requestOptions) { - final String accept = "application/json"; String colorsConverted = colors.stream() .map(paramItemValue -> Objects.toString(paramItemValue, "")) .collect(Collectors.joining("\t")); - return service.tsvSync(colorsConverted, accept, requestOptions, Context.NONE); + return service.tsvSync(this.client.getEndpoint(), colorsConverted, requestOptions, Context.NONE); } /** @@ -280,11 +279,11 @@ public Response tsvWithResponse(List colors, RequestOptions reques */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> pipesWithResponseAsync(List colors, RequestOptions requestOptions) { - final String accept = "application/json"; String colorsConverted = colors.stream() .map(paramItemValue -> Objects.toString(paramItemValue, "")) .collect(Collectors.joining("|")); - return FluxUtil.withContext(context -> service.pipes(colorsConverted, accept, requestOptions, context)); + return FluxUtil + .withContext(context -> service.pipes(this.client.getEndpoint(), colorsConverted, requestOptions, context)); } /** @@ -300,11 +299,10 @@ public Mono> pipesWithResponseAsync(List colors, RequestO */ @ServiceMethod(returns = ReturnType.SINGLE) public Response pipesWithResponse(List colors, RequestOptions requestOptions) { - final String accept = "application/json"; String colorsConverted = colors.stream() .map(paramItemValue -> Objects.toString(paramItemValue, "")) .collect(Collectors.joining("|")); - return service.pipesSync(colorsConverted, accept, requestOptions, Context.NONE); + return service.pipesSync(this.client.getEndpoint(), colorsConverted, requestOptions, Context.NONE); } /** @@ -320,11 +318,11 @@ public Response pipesWithResponse(List colors, RequestOptions requ */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> csvWithResponseAsync(List colors, RequestOptions requestOptions) { - final String accept = "application/json"; String colorsConverted = colors.stream() .map(paramItemValue -> Objects.toString(paramItemValue, "")) .collect(Collectors.joining(",")); - return FluxUtil.withContext(context -> service.csv(colorsConverted, accept, requestOptions, context)); + return FluxUtil + .withContext(context -> service.csv(this.client.getEndpoint(), colorsConverted, requestOptions, context)); } /** @@ -340,10 +338,9 @@ public Mono> csvWithResponseAsync(List colors, RequestOpt */ @ServiceMethod(returns = ReturnType.SINGLE) public Response csvWithResponse(List colors, RequestOptions requestOptions) { - final String accept = "application/json"; String colorsConverted = colors.stream() .map(paramItemValue -> Objects.toString(paramItemValue, "")) .collect(Collectors.joining(",")); - return service.csvSync(colorsConverted, accept, requestOptions, Context.NONE); + return service.csvSync(this.client.getEndpoint(), colorsConverted, requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/parameters/spread/AliasAsyncClient.java b/typespec-tests/src/main/java/com/parameters/spread/AliasAsyncClient.java index 3abdd2fdf6..cfd77d351b 100644 --- a/typespec-tests/src/main/java/com/parameters/spread/AliasAsyncClient.java +++ b/typespec-tests/src/main/java/com/parameters/spread/AliasAsyncClient.java @@ -214,8 +214,8 @@ public Mono spreadAsRequestBody(String name) { * The spreadParameterWithInnerModel operation. * * @param id The id parameter. - * @param name The name 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. @@ -226,7 +226,7 @@ public Mono spreadAsRequestBody(String name) { */ @Generated @ServiceMethod(returns = ReturnType.SINGLE) - public Mono spreadParameterWithInnerModel(String id, String name, String xMsTestHeader) { + public Mono spreadParameterWithInnerModel(String id, String xMsTestHeader, String name) { // Generated convenience method for spreadParameterWithInnerModelWithResponse RequestOptions requestOptions = new RequestOptions(); SpreadParameterWithInnerModelRequest spreadParameterWithInnerModelRequestObj @@ -325,9 +325,9 @@ public Mono spreadWithMultipleParameters(String id, String xMsTestHeader, * 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. - * @param xMsTestHeader The xMsTestHeader parameter. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws HttpResponseException thrown if the request is rejected by server. * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. @@ -338,7 +338,7 @@ public Mono spreadWithMultipleParameters(String id, String xMsTestHeader, */ @Generated @ServiceMethod(returns = ReturnType.SINGLE) - public Mono spreadParameterWithInnerAlias(String id, String name, int age, String xMsTestHeader) { + public Mono spreadParameterWithInnerAlias(String id, String xMsTestHeader, String name, int age) { // Generated convenience method for spreadParameterWithInnerAliasWithResponse RequestOptions requestOptions = new RequestOptions(); SpreadParameterWithInnerAliasRequest spreadParameterWithInnerAliasRequestObj diff --git a/typespec-tests/src/main/java/com/parameters/spread/AliasClient.java b/typespec-tests/src/main/java/com/parameters/spread/AliasClient.java index fb0e2fde55..6964882f2f 100644 --- a/typespec-tests/src/main/java/com/parameters/spread/AliasClient.java +++ b/typespec-tests/src/main/java/com/parameters/spread/AliasClient.java @@ -211,8 +211,8 @@ public void spreadAsRequestBody(String name) { * The spreadParameterWithInnerModel operation. * * @param id The id parameter. - * @param name The name 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. @@ -222,7 +222,7 @@ public void spreadAsRequestBody(String name) { */ @Generated @ServiceMethod(returns = ReturnType.SINGLE) - public void spreadParameterWithInnerModel(String id, String name, String xMsTestHeader) { + public void spreadParameterWithInnerModel(String id, String xMsTestHeader, String name) { // Generated convenience method for spreadParameterWithInnerModelWithResponse RequestOptions requestOptions = new RequestOptions(); SpreadParameterWithInnerModelRequest spreadParameterWithInnerModelRequestObj @@ -318,9 +318,9 @@ public void spreadWithMultipleParameters(String id, String xMsTestHeader, String * 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. - * @param xMsTestHeader The xMsTestHeader parameter. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws HttpResponseException thrown if the request is rejected by server. * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. @@ -330,7 +330,7 @@ public void spreadWithMultipleParameters(String id, String xMsTestHeader, String */ @Generated @ServiceMethod(returns = ReturnType.SINGLE) - public void spreadParameterWithInnerAlias(String id, String name, int age, String xMsTestHeader) { + public void spreadParameterWithInnerAlias(String id, String xMsTestHeader, String name, int age) { // Generated convenience method for spreadParameterWithInnerAliasWithResponse RequestOptions requestOptions = new RequestOptions(); SpreadParameterWithInnerAliasRequest spreadParameterWithInnerAliasRequestObj diff --git a/typespec-tests/src/main/java/com/parameters/spread/SpreadClientBuilder.java b/typespec-tests/src/main/java/com/parameters/spread/SpreadClientBuilder.java index 0c9d2e14ca..47711e460b 100644 --- a/typespec-tests/src/main/java/com/parameters/spread/SpreadClientBuilder.java +++ b/typespec-tests/src/main/java/com/parameters/spread/SpreadClientBuilder.java @@ -7,6 +7,7 @@ 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; @@ -41,8 +42,8 @@ */ @ServiceClientBuilder( serviceClients = { ModelClient.class, AliasClient.class, ModelAsyncClient.class, AliasAsyncClient.class }) -public final class SpreadClientBuilder - implements HttpTrait, ConfigurationTrait { +public final class SpreadClientBuilder implements HttpTrait, + ConfigurationTrait, EndpointTrait { @Generated private static final String SDK_NAME = "name"; @@ -173,6 +174,22 @@ public SpreadClientBuilder configuration(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. */ @@ -200,7 +217,9 @@ public SpreadClientBuilder retryPolicy(RetryPolicy retryPolicy) { private SpreadClientImpl buildInnerClient() { this.validateClient(); HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); - SpreadClientImpl client = new SpreadClientImpl(localPipeline, JacksonAdapter.createDefaultSerializerAdapter()); + String localEndpoint = (endpoint != null) ? endpoint : "http://localhost:3000"; + SpreadClientImpl client + = new SpreadClientImpl(localPipeline, JacksonAdapter.createDefaultSerializerAdapter(), localEndpoint); return client; } diff --git a/typespec-tests/src/main/java/com/parameters/spread/implementation/AliasImpl.java b/typespec-tests/src/main/java/com/parameters/spread/implementation/AliasImpl.java index 448e70f90e..b99cea4e3e 100644 --- a/typespec-tests/src/main/java/com/parameters/spread/implementation/AliasImpl.java +++ b/typespec-tests/src/main/java/com/parameters/spread/implementation/AliasImpl.java @@ -8,6 +8,7 @@ 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; @@ -55,7 +56,7 @@ public final class AliasImpl { * The interface defining all the services for SpreadClientAlias to be used by the proxy service to perform REST * calls. */ - @Host("http://localhost:3000") + @Host("{endpoint}") @ServiceInterface(name = "SpreadClientAlias") public interface AliasService { @Put("/parameters/spread/alias/request-body") @@ -64,7 +65,8 @@ public interface AliasService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> spreadAsRequestBody(@HeaderParam("accept") String accept, + Mono> spreadAsRequestBody(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData spreadAsRequestBodyRequest, RequestOptions requestOptions, Context context); @@ -74,7 +76,8 @@ Mono> spreadAsRequestBody(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response spreadAsRequestBodySync(@HeaderParam("accept") String accept, + Response spreadAsRequestBodySync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData spreadAsRequestBodyRequest, RequestOptions requestOptions, Context context); @@ -84,8 +87,9 @@ Response spreadAsRequestBodySync(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> spreadParameterWithInnerModel(@PathParam("id") String id, - @HeaderParam("x-ms-test-header") String xMsTestHeader, @HeaderParam("accept") String accept, + 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); @@ -95,8 +99,9 @@ Mono> spreadParameterWithInnerModel(@PathParam("id") String id, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response spreadParameterWithInnerModelSync(@PathParam("id") String id, - @HeaderParam("x-ms-test-header") String xMsTestHeader, @HeaderParam("accept") String accept, + 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); @@ -106,8 +111,9 @@ Response spreadParameterWithInnerModelSync(@PathParam("id") String id, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> spreadAsRequestParameter(@PathParam("id") String id, - @HeaderParam("x-ms-test-header") String xMsTestHeader, @HeaderParam("accept") String accept, + 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); @@ -117,8 +123,8 @@ Mono> spreadAsRequestParameter(@PathParam("id") String id, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response spreadAsRequestParameterSync(@PathParam("id") String id, - @HeaderParam("x-ms-test-header") String xMsTestHeader, @HeaderParam("accept") String accept, + 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); @@ -128,8 +134,9 @@ Response spreadAsRequestParameterSync(@PathParam("id") String id, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> spreadWithMultipleParameters(@PathParam("id") String id, - @HeaderParam("x-ms-test-header") String xMsTestHeader, @HeaderParam("accept") String accept, + 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); @@ -139,8 +146,9 @@ Mono> spreadWithMultipleParameters(@PathParam("id") String id, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response spreadWithMultipleParametersSync(@PathParam("id") String id, - @HeaderParam("x-ms-test-header") String xMsTestHeader, @HeaderParam("accept") String accept, + 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); @@ -150,8 +158,9 @@ Response spreadWithMultipleParametersSync(@PathParam("id") String id, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> spreadParameterWithInnerAlias(@PathParam("id") String id, - @HeaderParam("x-ms-test-header") String xMsTestHeader, @HeaderParam("accept") String accept, + 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); @@ -161,8 +170,9 @@ Mono> spreadParameterWithInnerAlias(@PathParam("id") String id, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response spreadParameterWithInnerAliasSync(@PathParam("id") String id, - @HeaderParam("x-ms-test-header") String xMsTestHeader, @HeaderParam("accept") String accept, + 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); } @@ -188,9 +198,9 @@ Response spreadParameterWithInnerAliasSync(@PathParam("id") String id, @ServiceMethod(returns = ReturnType.SINGLE) public Mono> spreadAsRequestBodyWithResponseAsync(BinaryData spreadAsRequestBodyRequest, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext( - context -> service.spreadAsRequestBody(accept, spreadAsRequestBodyRequest, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil.withContext(context -> service.spreadAsRequestBody(this.client.getEndpoint(), contentType, + spreadAsRequestBodyRequest, requestOptions, context)); } /** @@ -214,8 +224,9 @@ public Mono> spreadAsRequestBodyWithResponseAsync(BinaryData spre @ServiceMethod(returns = ReturnType.SINGLE) public Response spreadAsRequestBodyWithResponse(BinaryData spreadAsRequestBodyRequest, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.spreadAsRequestBodySync(accept, spreadAsRequestBodyRequest, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.spreadAsRequestBodySync(this.client.getEndpoint(), contentType, spreadAsRequestBodyRequest, + requestOptions, Context.NONE); } /** @@ -241,9 +252,9 @@ public Response spreadAsRequestBodyWithResponse(BinaryData spreadAsRequest @ServiceMethod(returns = ReturnType.SINGLE) public Mono> spreadParameterWithInnerModelWithResponseAsync(String id, String xMsTestHeader, BinaryData spreadParameterWithInnerModelRequest, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.spreadParameterWithInnerModel(id, xMsTestHeader, accept, - spreadParameterWithInnerModelRequest, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil.withContext(context -> service.spreadParameterWithInnerModel(this.client.getEndpoint(), id, + xMsTestHeader, contentType, spreadParameterWithInnerModelRequest, requestOptions, context)); } /** @@ -269,8 +280,8 @@ public Mono> spreadParameterWithInnerModelWithResponseAsync(Strin @ServiceMethod(returns = ReturnType.SINGLE) public Response spreadParameterWithInnerModelWithResponse(String id, String xMsTestHeader, BinaryData spreadParameterWithInnerModelRequest, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.spreadParameterWithInnerModelSync(id, xMsTestHeader, accept, + final String contentType = "application/json"; + return service.spreadParameterWithInnerModelSync(this.client.getEndpoint(), id, xMsTestHeader, contentType, spreadParameterWithInnerModelRequest, requestOptions, Context.NONE); } @@ -297,9 +308,9 @@ public Response spreadParameterWithInnerModelWithResponse(String id, Strin @ServiceMethod(returns = ReturnType.SINGLE) public Mono> spreadAsRequestParameterWithResponseAsync(String id, String xMsTestHeader, BinaryData spreadAsRequestParameterRequest, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.spreadAsRequestParameter(id, xMsTestHeader, accept, - spreadAsRequestParameterRequest, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil.withContext(context -> service.spreadAsRequestParameter(this.client.getEndpoint(), id, + xMsTestHeader, contentType, spreadAsRequestParameterRequest, requestOptions, context)); } /** @@ -325,9 +336,9 @@ public Mono> spreadAsRequestParameterWithResponseAsync(String id, @ServiceMethod(returns = ReturnType.SINGLE) public Response spreadAsRequestParameterWithResponse(String id, String xMsTestHeader, BinaryData spreadAsRequestParameterRequest, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.spreadAsRequestParameterSync(id, xMsTestHeader, accept, spreadAsRequestParameterRequest, - requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.spreadAsRequestParameterSync(this.client.getEndpoint(), id, xMsTestHeader, contentType, + spreadAsRequestParameterRequest, requestOptions, Context.NONE); } /** @@ -360,9 +371,9 @@ public Response spreadAsRequestParameterWithResponse(String id, String xMs @ServiceMethod(returns = ReturnType.SINGLE) public Mono> spreadWithMultipleParametersWithResponseAsync(String id, String xMsTestHeader, BinaryData spreadWithMultipleParametersRequest, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.spreadWithMultipleParameters(id, xMsTestHeader, accept, - spreadWithMultipleParametersRequest, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil.withContext(context -> service.spreadWithMultipleParameters(this.client.getEndpoint(), id, + xMsTestHeader, contentType, spreadWithMultipleParametersRequest, requestOptions, context)); } /** @@ -395,9 +406,9 @@ public Mono> spreadWithMultipleParametersWithResponseAsync(String @ServiceMethod(returns = ReturnType.SINGLE) public Response spreadWithMultipleParametersWithResponse(String id, String xMsTestHeader, BinaryData spreadWithMultipleParametersRequest, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.spreadWithMultipleParametersSync(id, xMsTestHeader, accept, spreadWithMultipleParametersRequest, - requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.spreadWithMultipleParametersSync(this.client.getEndpoint(), id, xMsTestHeader, contentType, + spreadWithMultipleParametersRequest, requestOptions, Context.NONE); } /** @@ -424,9 +435,9 @@ public Response spreadWithMultipleParametersWithResponse(String id, String @ServiceMethod(returns = ReturnType.SINGLE) public Mono> spreadParameterWithInnerAliasWithResponseAsync(String id, String xMsTestHeader, BinaryData spreadParameterWithInnerAliasRequest, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.spreadParameterWithInnerAlias(id, xMsTestHeader, accept, - spreadParameterWithInnerAliasRequest, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil.withContext(context -> service.spreadParameterWithInnerAlias(this.client.getEndpoint(), id, + xMsTestHeader, contentType, spreadParameterWithInnerAliasRequest, requestOptions, context)); } /** @@ -453,8 +464,8 @@ public Mono> spreadParameterWithInnerAliasWithResponseAsync(Strin @ServiceMethod(returns = ReturnType.SINGLE) public Response spreadParameterWithInnerAliasWithResponse(String id, String xMsTestHeader, BinaryData spreadParameterWithInnerAliasRequest, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.spreadParameterWithInnerAliasSync(id, xMsTestHeader, accept, + final String contentType = "application/json"; + return service.spreadParameterWithInnerAliasSync(this.client.getEndpoint(), id, xMsTestHeader, contentType, spreadParameterWithInnerAliasRequest, requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/parameters/spread/implementation/ModelsImpl.java b/typespec-tests/src/main/java/com/parameters/spread/implementation/ModelsImpl.java index c56205230a..bd8d00820e 100644 --- a/typespec-tests/src/main/java/com/parameters/spread/implementation/ModelsImpl.java +++ b/typespec-tests/src/main/java/com/parameters/spread/implementation/ModelsImpl.java @@ -8,6 +8,7 @@ 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; @@ -54,7 +55,7 @@ public final class ModelsImpl { * The interface defining all the services for SpreadClientModels to be used by the proxy service to perform REST * calls. */ - @Host("http://localhost:3000") + @Host("{endpoint}") @ServiceInterface(name = "SpreadClientModels") public interface ModelsService { @Put("/parameters/spread/model/request-body") @@ -63,7 +64,8 @@ public interface ModelsService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> spreadAsRequestBody(@HeaderParam("accept") String accept, + Mono> spreadAsRequestBody(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData spreadAsRequestBodyRequest1, RequestOptions requestOptions, Context context); @@ -73,7 +75,8 @@ Mono> spreadAsRequestBody(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response spreadAsRequestBodySync(@HeaderParam("accept") String accept, + Response spreadAsRequestBodySync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData spreadAsRequestBodyRequest1, RequestOptions requestOptions, Context context); @@ -83,8 +86,9 @@ Response spreadAsRequestBodySync(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> spreadCompositeRequestOnlyWithBody(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + 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 }) @@ -92,8 +96,9 @@ Mono> spreadCompositeRequestOnlyWithBody(@HeaderParam("accept") S @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response spreadCompositeRequestOnlyWithBodySync(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + 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 }) @@ -101,8 +106,8 @@ Response spreadCompositeRequestOnlyWithBodySync(@HeaderParam("accept") Str @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> spreadCompositeRequestWithoutBody(@PathParam("name") String name, - @HeaderParam("test-header") String testHeader, @HeaderParam("accept") String accept, + 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}") @@ -111,8 +116,8 @@ Mono> spreadCompositeRequestWithoutBody(@PathParam("name") String @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response spreadCompositeRequestWithoutBodySync(@PathParam("name") String name, - @HeaderParam("test-header") String testHeader, @HeaderParam("accept") String accept, + 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}") @@ -121,9 +126,10 @@ Response spreadCompositeRequestWithoutBodySync(@PathParam("name") String n @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> spreadCompositeRequest(@PathParam("name") String name, - @HeaderParam("test-header") String testHeader, @HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + 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 }) @@ -131,9 +137,10 @@ Mono> spreadCompositeRequest(@PathParam("name") String name, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response spreadCompositeRequestSync(@PathParam("name") String name, - @HeaderParam("test-header") String testHeader, @HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + 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 }) @@ -141,8 +148,9 @@ Response spreadCompositeRequestSync(@PathParam("name") String name, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> spreadCompositeRequestMix(@PathParam("name") String name, - @HeaderParam("test-header") String testHeader, @HeaderParam("accept") String accept, + 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); @@ -152,8 +160,9 @@ Mono> spreadCompositeRequestMix(@PathParam("name") String name, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response spreadCompositeRequestMixSync(@PathParam("name") String name, - @HeaderParam("test-header") String testHeader, @HeaderParam("accept") String accept, + 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); } @@ -179,9 +188,9 @@ Response spreadCompositeRequestMixSync(@PathParam("name") String name, @ServiceMethod(returns = ReturnType.SINGLE) public Mono> spreadAsRequestBodyWithResponseAsync(BinaryData spreadAsRequestBodyRequest1, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext( - context -> service.spreadAsRequestBody(accept, spreadAsRequestBodyRequest1, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil.withContext(context -> service.spreadAsRequestBody(this.client.getEndpoint(), contentType, + spreadAsRequestBodyRequest1, requestOptions, context)); } /** @@ -205,8 +214,9 @@ public Mono> spreadAsRequestBodyWithResponseAsync(BinaryData spre @ServiceMethod(returns = ReturnType.SINGLE) public Response spreadAsRequestBodyWithResponse(BinaryData spreadAsRequestBodyRequest1, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.spreadAsRequestBodySync(accept, spreadAsRequestBodyRequest1, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.spreadAsRequestBodySync(this.client.getEndpoint(), contentType, spreadAsRequestBodyRequest1, + requestOptions, Context.NONE); } /** @@ -230,9 +240,9 @@ public Response spreadAsRequestBodyWithResponse(BinaryData spreadAsRequest @ServiceMethod(returns = ReturnType.SINGLE) public Mono> spreadCompositeRequestOnlyWithBodyWithResponseAsync(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil - .withContext(context -> service.spreadCompositeRequestOnlyWithBody(accept, body, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil.withContext(context -> service.spreadCompositeRequestOnlyWithBody(this.client.getEndpoint(), + contentType, body, requestOptions, context)); } /** @@ -256,8 +266,9 @@ public Mono> spreadCompositeRequestOnlyWithBodyWithResponseAsync( @ServiceMethod(returns = ReturnType.SINGLE) public Response spreadCompositeRequestOnlyWithBodyWithResponse(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.spreadCompositeRequestOnlyWithBodySync(accept, body, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.spreadCompositeRequestOnlyWithBodySync(this.client.getEndpoint(), contentType, body, + requestOptions, Context.NONE); } /** @@ -275,9 +286,8 @@ public Response spreadCompositeRequestOnlyWithBodyWithResponse(BinaryData @ServiceMethod(returns = ReturnType.SINGLE) public Mono> spreadCompositeRequestWithoutBodyWithResponseAsync(String name, String testHeader, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext( - context -> service.spreadCompositeRequestWithoutBody(name, testHeader, accept, requestOptions, context)); + return FluxUtil.withContext(context -> service.spreadCompositeRequestWithoutBody(this.client.getEndpoint(), + name, testHeader, requestOptions, context)); } /** @@ -295,8 +305,8 @@ public Mono> spreadCompositeRequestWithoutBodyWithResponseAsync(S @ServiceMethod(returns = ReturnType.SINGLE) public Response spreadCompositeRequestWithoutBodyWithResponse(String name, String testHeader, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.spreadCompositeRequestWithoutBodySync(name, testHeader, accept, requestOptions, Context.NONE); + return service.spreadCompositeRequestWithoutBodySync(this.client.getEndpoint(), name, testHeader, + requestOptions, Context.NONE); } /** @@ -322,9 +332,9 @@ public Response spreadCompositeRequestWithoutBodyWithResponse(String name, @ServiceMethod(returns = ReturnType.SINGLE) public Mono> spreadCompositeRequestWithResponseAsync(String name, String testHeader, BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext( - context -> service.spreadCompositeRequest(name, testHeader, accept, body, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil.withContext(context -> service.spreadCompositeRequest(this.client.getEndpoint(), name, + testHeader, contentType, body, requestOptions, context)); } /** @@ -350,8 +360,9 @@ public Mono> spreadCompositeRequestWithResponseAsync(String name, @ServiceMethod(returns = ReturnType.SINGLE) public Response spreadCompositeRequestWithResponse(String name, String testHeader, BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.spreadCompositeRequestSync(name, testHeader, accept, body, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.spreadCompositeRequestSync(this.client.getEndpoint(), name, testHeader, contentType, body, + requestOptions, Context.NONE); } /** @@ -377,9 +388,9 @@ public Response spreadCompositeRequestWithResponse(String name, String tes @ServiceMethod(returns = ReturnType.SINGLE) public Mono> spreadCompositeRequestMixWithResponseAsync(String name, String testHeader, BinaryData spreadCompositeRequestMixRequest, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.spreadCompositeRequestMix(name, testHeader, accept, - spreadCompositeRequestMixRequest, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil.withContext(context -> service.spreadCompositeRequestMix(this.client.getEndpoint(), name, + testHeader, contentType, spreadCompositeRequestMixRequest, requestOptions, context)); } /** @@ -405,8 +416,8 @@ public Mono> spreadCompositeRequestMixWithResponseAsync(String na @ServiceMethod(returns = ReturnType.SINGLE) public Response spreadCompositeRequestMixWithResponse(String name, String testHeader, BinaryData spreadCompositeRequestMixRequest, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.spreadCompositeRequestMixSync(name, testHeader, accept, spreadCompositeRequestMixRequest, - requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.spreadCompositeRequestMixSync(this.client.getEndpoint(), name, testHeader, contentType, + spreadCompositeRequestMixRequest, requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/parameters/spread/implementation/SpreadClientImpl.java b/typespec-tests/src/main/java/com/parameters/spread/implementation/SpreadClientImpl.java index cfb42fd5bf..f9f10e5a40 100644 --- a/typespec-tests/src/main/java/com/parameters/spread/implementation/SpreadClientImpl.java +++ b/typespec-tests/src/main/java/com/parameters/spread/implementation/SpreadClientImpl.java @@ -15,6 +15,20 @@ * 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. */ @@ -73,19 +87,22 @@ public AliasImpl getAlias() { /** * Initializes an instance of SpreadClient client. + * + * @param endpoint Service host. */ - public SpreadClientImpl() { + public SpreadClientImpl(String endpoint) { this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), - JacksonAdapter.createDefaultSerializerAdapter()); + 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) { - this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter()); + public SpreadClientImpl(HttpPipeline httpPipeline, String endpoint) { + this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint); } /** @@ -93,10 +110,12 @@ public SpreadClientImpl(HttpPipeline httpPipeline) { * * @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) { + 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/typespec-tests/src/main/java/com/payload/contentnegotiation/ContentNegotiationClientBuilder.java b/typespec-tests/src/main/java/com/payload/contentnegotiation/ContentNegotiationClientBuilder.java index ffa3a20d1d..10d4aa52e6 100644 --- a/typespec-tests/src/main/java/com/payload/contentnegotiation/ContentNegotiationClientBuilder.java +++ b/typespec-tests/src/main/java/com/payload/contentnegotiation/ContentNegotiationClientBuilder.java @@ -7,6 +7,7 @@ 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; @@ -45,8 +46,8 @@ DifferentBodyClient.class, SameBodyAsyncClient.class, DifferentBodyAsyncClient.class }) -public final class ContentNegotiationClientBuilder - implements HttpTrait, ConfigurationTrait { +public final class ContentNegotiationClientBuilder implements HttpTrait, + ConfigurationTrait, EndpointTrait { @Generated private static final String SDK_NAME = "name"; @@ -178,6 +179,22 @@ public ContentNegotiationClientBuilder configuration(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. */ @@ -205,8 +222,9 @@ public ContentNegotiationClientBuilder retryPolicy(RetryPolicy retryPolicy) { private ContentNegotiationClientImpl buildInnerClient() { this.validateClient(); HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); - ContentNegotiationClientImpl client - = new ContentNegotiationClientImpl(localPipeline, JacksonAdapter.createDefaultSerializerAdapter()); + String localEndpoint = (endpoint != null) ? endpoint : "http://localhost:3000"; + ContentNegotiationClientImpl client = new ContentNegotiationClientImpl(localPipeline, + JacksonAdapter.createDefaultSerializerAdapter(), localEndpoint); return client; } diff --git a/typespec-tests/src/main/java/com/payload/contentnegotiation/implementation/ContentNegotiationClientImpl.java b/typespec-tests/src/main/java/com/payload/contentnegotiation/implementation/ContentNegotiationClientImpl.java index ea207cfe45..2b4d2ab945 100644 --- a/typespec-tests/src/main/java/com/payload/contentnegotiation/implementation/ContentNegotiationClientImpl.java +++ b/typespec-tests/src/main/java/com/payload/contentnegotiation/implementation/ContentNegotiationClientImpl.java @@ -15,6 +15,20 @@ * 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. */ @@ -73,19 +87,22 @@ public DifferentBodiesImpl getDifferentBodies() { /** * Initializes an instance of ContentNegotiationClient client. + * + * @param endpoint Service host. */ - public ContentNegotiationClientImpl() { + public ContentNegotiationClientImpl(String endpoint) { this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), - JacksonAdapter.createDefaultSerializerAdapter()); + 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) { - this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter()); + public ContentNegotiationClientImpl(HttpPipeline httpPipeline, String endpoint) { + this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint); } /** @@ -93,10 +110,13 @@ public ContentNegotiationClientImpl(HttpPipeline httpPipeline) { * * @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) { + 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/typespec-tests/src/main/java/com/payload/contentnegotiation/implementation/DifferentBodiesImpl.java b/typespec-tests/src/main/java/com/payload/contentnegotiation/implementation/DifferentBodiesImpl.java index ccd0a42ddb..feeb0ea89a 100644 --- a/typespec-tests/src/main/java/com/payload/contentnegotiation/implementation/DifferentBodiesImpl.java +++ b/typespec-tests/src/main/java/com/payload/contentnegotiation/implementation/DifferentBodiesImpl.java @@ -8,6 +8,7 @@ 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; @@ -53,7 +54,7 @@ public final class DifferentBodiesImpl { * The interface defining all the services for ContentNegotiationClientDifferentBodies to be used by the proxy * service to perform REST calls. */ - @Host("http://localhost:3000") + @Host("{endpoint}") @ServiceInterface(name = "ContentNegotiationCl") public interface DifferentBodiesService { @Get("/content-negotiation/different-body") @@ -62,8 +63,8 @@ public interface DifferentBodiesService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> getAvatarAsPng(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Mono> getAvatarAsPng(@HostParam("endpoint") String endpoint, + @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); @Get("/content-negotiation/different-body") @ExpectedResponses({ 200 }) @@ -71,8 +72,8 @@ Mono> getAvatarAsPng(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response getAvatarAsPngSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Response getAvatarAsPngSync(@HostParam("endpoint") String endpoint, + @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); @Get("/content-negotiation/different-body") @ExpectedResponses({ 200 }) @@ -80,8 +81,8 @@ Response getAvatarAsPngSync(@HeaderParam("accept") String accept, Re @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> getAvatarAsJson(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Mono> getAvatarAsJson(@HostParam("endpoint") String endpoint, + @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); @Get("/content-negotiation/different-body") @ExpectedResponses({ 200 }) @@ -89,8 +90,8 @@ Mono> getAvatarAsJson(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response getAvatarAsJsonSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Response getAvatarAsJsonSync(@HostParam("endpoint") String endpoint, + @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); } /** @@ -111,7 +112,8 @@ Response getAvatarAsJsonSync(@HeaderParam("accept") String accept, R @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getAvatarAsPngWithResponseAsync(RequestOptions requestOptions) { final String accept = "image/png"; - return FluxUtil.withContext(context -> service.getAvatarAsPng(accept, requestOptions, context)); + return FluxUtil + .withContext(context -> service.getAvatarAsPng(this.client.getEndpoint(), accept, requestOptions, context)); } /** @@ -132,7 +134,7 @@ public Mono> getAvatarAsPngWithResponseAsync(RequestOptions @ServiceMethod(returns = ReturnType.SINGLE) public Response getAvatarAsPngWithResponse(RequestOptions requestOptions) { final String accept = "image/png"; - return service.getAvatarAsPngSync(accept, requestOptions, Context.NONE); + return service.getAvatarAsPngSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); } /** @@ -155,7 +157,8 @@ public Response getAvatarAsPngWithResponse(RequestOptions requestOpt @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getAvatarAsJsonWithResponseAsync(RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.getAvatarAsJson(accept, requestOptions, context)); + return FluxUtil.withContext( + context -> service.getAvatarAsJson(this.client.getEndpoint(), accept, requestOptions, context)); } /** @@ -178,6 +181,6 @@ public Mono> getAvatarAsJsonWithResponseAsync(RequestOption @ServiceMethod(returns = ReturnType.SINGLE) public Response getAvatarAsJsonWithResponse(RequestOptions requestOptions) { final String accept = "application/json"; - return service.getAvatarAsJsonSync(accept, requestOptions, Context.NONE); + return service.getAvatarAsJsonSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/payload/contentnegotiation/implementation/SameBodiesImpl.java b/typespec-tests/src/main/java/com/payload/contentnegotiation/implementation/SameBodiesImpl.java index 0f3d68fb15..ed0f152210 100644 --- a/typespec-tests/src/main/java/com/payload/contentnegotiation/implementation/SameBodiesImpl.java +++ b/typespec-tests/src/main/java/com/payload/contentnegotiation/implementation/SameBodiesImpl.java @@ -8,6 +8,7 @@ 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; @@ -53,7 +54,7 @@ public final class SameBodiesImpl { * The interface defining all the services for ContentNegotiationClientSameBodies to be used by the proxy service to * perform REST calls. */ - @Host("http://localhost:3000") + @Host("{endpoint}") @ServiceInterface(name = "ContentNegotiationCl") public interface SameBodiesService { @Get("/content-negotiation/same-body") @@ -62,8 +63,8 @@ public interface SameBodiesService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> getAvatarAsPng(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Mono> getAvatarAsPng(@HostParam("endpoint") String endpoint, + @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); @Get("/content-negotiation/same-body") @ExpectedResponses({ 200 }) @@ -71,8 +72,8 @@ Mono> getAvatarAsPng(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response getAvatarAsPngSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Response getAvatarAsPngSync(@HostParam("endpoint") String endpoint, + @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); @Get("/content-negotiation/same-body") @ExpectedResponses({ 200 }) @@ -80,8 +81,8 @@ Response getAvatarAsPngSync(@HeaderParam("accept") String accept, Re @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> getAvatarAsJpeg(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Mono> getAvatarAsJpeg(@HostParam("endpoint") String endpoint, + @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); @Get("/content-negotiation/same-body") @ExpectedResponses({ 200 }) @@ -89,8 +90,8 @@ Mono> getAvatarAsJpeg(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response getAvatarAsJpegSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Response getAvatarAsJpegSync(@HostParam("endpoint") String endpoint, + @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); } /** @@ -111,7 +112,8 @@ Response getAvatarAsJpegSync(@HeaderParam("accept") String accept, R @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getAvatarAsPngWithResponseAsync(RequestOptions requestOptions) { final String accept = "image/png"; - return FluxUtil.withContext(context -> service.getAvatarAsPng(accept, requestOptions, context)); + return FluxUtil + .withContext(context -> service.getAvatarAsPng(this.client.getEndpoint(), accept, requestOptions, context)); } /** @@ -132,7 +134,7 @@ public Mono> getAvatarAsPngWithResponseAsync(RequestOptions @ServiceMethod(returns = ReturnType.SINGLE) public Response getAvatarAsPngWithResponse(RequestOptions requestOptions) { final String accept = "image/png"; - return service.getAvatarAsPngSync(accept, requestOptions, Context.NONE); + return service.getAvatarAsPngSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); } /** @@ -153,7 +155,8 @@ public Response getAvatarAsPngWithResponse(RequestOptions requestOpt @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getAvatarAsJpegWithResponseAsync(RequestOptions requestOptions) { final String accept = "image/jpeg"; - return FluxUtil.withContext(context -> service.getAvatarAsJpeg(accept, requestOptions, context)); + return FluxUtil.withContext( + context -> service.getAvatarAsJpeg(this.client.getEndpoint(), accept, requestOptions, context)); } /** @@ -174,6 +177,6 @@ public Mono> getAvatarAsJpegWithResponseAsync(RequestOption @ServiceMethod(returns = ReturnType.SINGLE) public Response getAvatarAsJpegWithResponse(RequestOptions requestOptions) { final String accept = "image/jpeg"; - return service.getAvatarAsJpegSync(accept, requestOptions, Context.NONE); + return service.getAvatarAsJpegSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/payload/jsonmergepatch/JsonMergePatchAsyncClient.java b/typespec-tests/src/main/java/com/payload/jsonmergepatch/JsonMergePatchAsyncClient.java index 3fa9f091ed..ba33191a59 100644 --- a/typespec-tests/src/main/java/com/payload/jsonmergepatch/JsonMergePatchAsyncClient.java +++ b/typespec-tests/src/main/java/com/payload/jsonmergepatch/JsonMergePatchAsyncClient.java @@ -169,6 +169,14 @@ public Mono> updateResourceWithResponse(BinaryData body, Re /** * 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
diff --git a/typespec-tests/src/main/java/com/payload/jsonmergepatch/JsonMergePatchClient.java b/typespec-tests/src/main/java/com/payload/jsonmergepatch/JsonMergePatchClient.java
index 632d20242b..08acc09d0a 100644
--- a/typespec-tests/src/main/java/com/payload/jsonmergepatch/JsonMergePatchClient.java
+++ b/typespec-tests/src/main/java/com/payload/jsonmergepatch/JsonMergePatchClient.java
@@ -167,6 +167,14 @@ public Response updateResourceWithResponse(BinaryData body, RequestO
 
     /**
      * 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
diff --git a/typespec-tests/src/main/java/com/payload/jsonmergepatch/JsonMergePatchClientBuilder.java b/typespec-tests/src/main/java/com/payload/jsonmergepatch/JsonMergePatchClientBuilder.java
index 4c2e2e7484..c669c66315 100644
--- a/typespec-tests/src/main/java/com/payload/jsonmergepatch/JsonMergePatchClientBuilder.java
+++ b/typespec-tests/src/main/java/com/payload/jsonmergepatch/JsonMergePatchClientBuilder.java
@@ -7,6 +7,7 @@
 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;
@@ -40,8 +41,8 @@
  * A builder for creating a new instance of the JsonMergePatchClient type.
  */
 @ServiceClientBuilder(serviceClients = { JsonMergePatchClient.class, JsonMergePatchAsyncClient.class })
-public final class JsonMergePatchClientBuilder
-    implements HttpTrait, ConfigurationTrait {
+public final class JsonMergePatchClientBuilder implements HttpTrait,
+    ConfigurationTrait, EndpointTrait {
     @Generated
     private static final String SDK_NAME = "name";
 
@@ -172,6 +173,22 @@ public JsonMergePatchClientBuilder configuration(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.
      */
@@ -199,8 +216,9 @@ public JsonMergePatchClientBuilder retryPolicy(RetryPolicy retryPolicy) {
     private JsonMergePatchClientImpl buildInnerClient() {
         this.validateClient();
         HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline();
-        JsonMergePatchClientImpl client
-            = new JsonMergePatchClientImpl(localPipeline, JacksonAdapter.createDefaultSerializerAdapter());
+        String localEndpoint = (endpoint != null) ? endpoint : "http://localhost:3000";
+        JsonMergePatchClientImpl client = new JsonMergePatchClientImpl(localPipeline,
+            JacksonAdapter.createDefaultSerializerAdapter(), localEndpoint);
         return client;
     }
 
diff --git a/typespec-tests/src/main/java/com/payload/jsonmergepatch/implementation/JsonMergePatchClientImpl.java b/typespec-tests/src/main/java/com/payload/jsonmergepatch/implementation/JsonMergePatchClientImpl.java
index a96d48530e..c83fd683c7 100644
--- a/typespec-tests/src/main/java/com/payload/jsonmergepatch/implementation/JsonMergePatchClientImpl.java
+++ b/typespec-tests/src/main/java/com/payload/jsonmergepatch/implementation/JsonMergePatchClientImpl.java
@@ -8,6 +8,7 @@
 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;
@@ -42,6 +43,20 @@ public final class JsonMergePatchClientImpl {
      */
     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.
      */
@@ -72,19 +87,22 @@ public SerializerAdapter getSerializerAdapter() {
 
     /**
      * Initializes an instance of JsonMergePatchClient client.
+     * 
+     * @param endpoint Service host.
      */
-    public JsonMergePatchClientImpl() {
+    public JsonMergePatchClientImpl(String endpoint) {
         this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(),
-            JacksonAdapter.createDefaultSerializerAdapter());
+            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) {
-        this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter());
+    public JsonMergePatchClientImpl(HttpPipeline httpPipeline, String endpoint) {
+        this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint);
     }
 
     /**
@@ -92,10 +110,12 @@ public JsonMergePatchClientImpl(HttpPipeline httpPipeline) {
      * 
      * @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) {
+    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());
     }
@@ -104,7 +124,7 @@ public JsonMergePatchClientImpl(HttpPipeline httpPipeline, SerializerAdapter ser
      * The interface defining all the services for JsonMergePatchClient to be used by the proxy service to perform REST
      * calls.
      */
-    @Host("http://localhost:3000")
+    @Host("{endpoint}")
     @ServiceInterface(name = "JsonMergePatchClient")
     public interface JsonMergePatchClientService {
         @Put("/json-merge-patch/create/resource")
@@ -113,7 +133,8 @@ public interface JsonMergePatchClientService {
         @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 })
         @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 })
         @UnexpectedResponseExceptionType(HttpResponseException.class)
-        Mono> createResource(@HeaderParam("accept") String accept,
+        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")
@@ -122,7 +143,8 @@ Mono> createResource(@HeaderParam("accept") String accept,
         @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 })
         @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 })
         @UnexpectedResponseExceptionType(HttpResponseException.class)
-        Response createResourceSync(@HeaderParam("accept") String accept,
+        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")
@@ -131,9 +153,9 @@ Response createResourceSync(@HeaderParam("accept") String accept,
         @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 })
         @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 })
         @UnexpectedResponseExceptionType(HttpResponseException.class)
-        Mono> updateResource(@HeaderParam("content-type") String contentType,
-            @HeaderParam("accept") String accept, @BodyParam("application/merge-patch+json") BinaryData body,
-            RequestOptions requestOptions, Context context);
+        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 })
@@ -141,9 +163,9 @@ Mono> updateResource(@HeaderParam("content-type") String co
         @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 })
         @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 })
         @UnexpectedResponseExceptionType(HttpResponseException.class)
-        Response updateResourceSync(@HeaderParam("content-type") String contentType,
-            @HeaderParam("accept") String accept, @BodyParam("application/merge-patch+json") BinaryData body,
-            RequestOptions requestOptions, Context context);
+        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 })
@@ -151,8 +173,8 @@ Response updateResourceSync(@HeaderParam("content-type") String cont
         @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 })
         @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 })
         @UnexpectedResponseExceptionType(HttpResponseException.class)
-        Mono> updateOptionalResource(@HeaderParam("content-type") String contentType,
-            @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context);
+        Mono> updateOptionalResource(@HostParam("endpoint") String endpoint,
+            @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context);
 
         @Patch("/json-merge-patch/update/resource/optional")
         @ExpectedResponses({ 200 })
@@ -160,8 +182,8 @@ Mono> updateOptionalResource(@HeaderParam("content-type") S
         @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 })
         @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 })
         @UnexpectedResponseExceptionType(HttpResponseException.class)
-        Response updateOptionalResourceSync(@HeaderParam("content-type") String contentType,
-            @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context);
+        Response updateOptionalResourceSync(@HostParam("endpoint") String endpoint,
+            @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context);
     }
 
     /**
@@ -224,8 +246,10 @@ Response updateOptionalResourceSync(@HeaderParam("content-type") Str
      */
     @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(accept, body, requestOptions, context));
+        return FluxUtil.withContext(
+            context -> service.createResource(this.getEndpoint(), contentType, accept, body, requestOptions, context));
     }
 
     /**
@@ -288,8 +312,9 @@ public Mono> createResourceWithResponseAsync(BinaryData bod
      */
     @ServiceMethod(returns = ReturnType.SINGLE)
     public Response createResourceWithResponse(BinaryData body, RequestOptions requestOptions) {
+        final String contentType = "application/json";
         final String accept = "application/json";
-        return service.createResourceSync(accept, body, requestOptions, Context.NONE);
+        return service.createResourceSync(this.getEndpoint(), contentType, accept, body, requestOptions, Context.NONE);
     }
 
     /**
@@ -353,8 +378,8 @@ public Response createResourceWithResponse(BinaryData body, RequestO
     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(contentType, accept, body, requestOptions, context));
+        return FluxUtil.withContext(
+            context -> service.updateResource(this.getEndpoint(), contentType, accept, body, requestOptions, context));
     }
 
     /**
@@ -418,11 +443,19 @@ public Mono> updateResourceWithResponseAsync(BinaryData bod
     public Response updateResourceWithResponse(BinaryData body, RequestOptions requestOptions) {
         final String contentType = "application/merge-patch+json";
         final String accept = "application/json";
-        return service.updateResourceSync(contentType, accept, body, requestOptions, Context.NONE);
+        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
@@ -479,7 +512,6 @@ public Response updateResourceWithResponse(BinaryData body, RequestO
      */
     @ServiceMethod(returns = ReturnType.SINGLE)
     public Mono> updateOptionalResourceWithResponseAsync(RequestOptions requestOptions) {
-        final String contentType = "application/merge-patch+json";
         final String accept = "application/json";
         RequestOptions requestOptionsLocal = requestOptions == null ? new RequestOptions() : requestOptions;
         requestOptionsLocal.addRequestCallback(requestLocal -> {
@@ -487,12 +519,20 @@ public Mono> updateOptionalResourceWithResponseAsync(Reques
                 requestLocal.getHeaders().set(HttpHeaderName.CONTENT_TYPE, "application/merge-patch+json");
             }
         });
-        return FluxUtil
-            .withContext(context -> service.updateOptionalResource(contentType, accept, requestOptionsLocal, context));
+        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
@@ -549,7 +589,6 @@ public Mono> updateOptionalResourceWithResponseAsync(Reques
      */
     @ServiceMethod(returns = ReturnType.SINGLE)
     public Response updateOptionalResourceWithResponse(RequestOptions requestOptions) {
-        final String contentType = "application/merge-patch+json";
         final String accept = "application/json";
         RequestOptions requestOptionsLocal = requestOptions == null ? new RequestOptions() : requestOptions;
         requestOptionsLocal.addRequestCallback(requestLocal -> {
@@ -557,6 +596,6 @@ public Response updateOptionalResourceWithResponse(RequestOptions re
                 requestLocal.getHeaders().set(HttpHeaderName.CONTENT_TYPE, "application/merge-patch+json");
             }
         });
-        return service.updateOptionalResourceSync(contentType, accept, requestOptionsLocal, Context.NONE);
+        return service.updateOptionalResourceSync(this.getEndpoint(), accept, requestOptionsLocal, Context.NONE);
     }
 }
diff --git a/typespec-tests/src/main/java/com/payload/mediatype/MediaTypeClientBuilder.java b/typespec-tests/src/main/java/com/payload/mediatype/MediaTypeClientBuilder.java
index dfd4c2c51b..c2efd2827a 100644
--- a/typespec-tests/src/main/java/com/payload/mediatype/MediaTypeClientBuilder.java
+++ b/typespec-tests/src/main/java/com/payload/mediatype/MediaTypeClientBuilder.java
@@ -7,6 +7,7 @@
 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;
@@ -40,8 +41,8 @@
  * A builder for creating a new instance of the MediaTypeClient type.
  */
 @ServiceClientBuilder(serviceClients = { MediaTypeClient.class, MediaTypeAsyncClient.class })
-public final class MediaTypeClientBuilder
-    implements HttpTrait, ConfigurationTrait {
+public final class MediaTypeClientBuilder implements HttpTrait,
+    ConfigurationTrait, EndpointTrait {
     @Generated
     private static final String SDK_NAME = "name";
 
@@ -172,6 +173,22 @@ public MediaTypeClientBuilder configuration(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.
      */
@@ -199,8 +216,9 @@ public MediaTypeClientBuilder retryPolicy(RetryPolicy retryPolicy) {
     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());
+            = new MediaTypeClientImpl(localPipeline, JacksonAdapter.createDefaultSerializerAdapter(), localEndpoint);
         return client;
     }
 
diff --git a/typespec-tests/src/main/java/com/payload/mediatype/implementation/MediaTypeClientImpl.java b/typespec-tests/src/main/java/com/payload/mediatype/implementation/MediaTypeClientImpl.java
index 1c622892b9..98398c2533 100644
--- a/typespec-tests/src/main/java/com/payload/mediatype/implementation/MediaTypeClientImpl.java
+++ b/typespec-tests/src/main/java/com/payload/mediatype/implementation/MediaTypeClientImpl.java
@@ -15,6 +15,20 @@
  * 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.
      */
@@ -59,19 +73,22 @@ public StringBodiesImpl getStringBodies() {
 
     /**
      * Initializes an instance of MediaTypeClient client.
+     * 
+     * @param endpoint Service host.
      */
-    public MediaTypeClientImpl() {
+    public MediaTypeClientImpl(String endpoint) {
         this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(),
-            JacksonAdapter.createDefaultSerializerAdapter());
+            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) {
-        this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter());
+    public MediaTypeClientImpl(HttpPipeline httpPipeline, String endpoint) {
+        this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint);
     }
 
     /**
@@ -79,10 +96,12 @@ public MediaTypeClientImpl(HttpPipeline httpPipeline) {
      * 
      * @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) {
+    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/typespec-tests/src/main/java/com/payload/mediatype/implementation/StringBodiesImpl.java b/typespec-tests/src/main/java/com/payload/mediatype/implementation/StringBodiesImpl.java
index 6514b25f96..4acde5ace5 100644
--- a/typespec-tests/src/main/java/com/payload/mediatype/implementation/StringBodiesImpl.java
+++ b/typespec-tests/src/main/java/com/payload/mediatype/implementation/StringBodiesImpl.java
@@ -9,6 +9,7 @@
 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;
@@ -55,7 +56,7 @@ public final class StringBodiesImpl {
      * The interface defining all the services for MediaTypeClientStringBodies to be used by the proxy service to
      * perform REST calls.
      */
-    @Host("http://localhost:3000")
+    @Host("{endpoint}")
     @ServiceInterface(name = "MediaTypeClientStrin")
     public interface StringBodiesService {
         @Post("/payload/media-type/string-body/sendAsText")
@@ -64,8 +65,8 @@ public interface StringBodiesService {
         @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 })
         @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 })
         @UnexpectedResponseExceptionType(HttpResponseException.class)
-        Mono> sendAsText(@HeaderParam("content-type") String contentType,
-            @HeaderParam("accept") String accept, @BodyParam("text/plain") BinaryData text,
+        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")
@@ -74,8 +75,8 @@ Mono> sendAsText(@HeaderParam("content-type") String contentType,
         @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 })
         @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 })
         @UnexpectedResponseExceptionType(HttpResponseException.class)
-        Response sendAsTextSync(@HeaderParam("content-type") String contentType,
-            @HeaderParam("accept") String accept, @BodyParam("text/plain") BinaryData text,
+        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")
@@ -84,8 +85,8 @@ Response sendAsTextSync(@HeaderParam("content-type") String contentType,
         @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 })
         @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 })
         @UnexpectedResponseExceptionType(HttpResponseException.class)
-        Mono> getAsText(@HeaderParam("accept") String accept, RequestOptions requestOptions,
-            Context context);
+        Mono> getAsText(@HostParam("endpoint") String endpoint,
+            @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context);
 
         @Get("/payload/media-type/string-body/getAsText")
         @ExpectedResponses({ 200 })
@@ -93,8 +94,8 @@ Mono> getAsText(@HeaderParam("accept") String accept, Reque
         @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 })
         @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 })
         @UnexpectedResponseExceptionType(HttpResponseException.class)
-        Response getAsTextSync(@HeaderParam("accept") String accept, RequestOptions requestOptions,
-            Context context);
+        Response getAsTextSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept,
+            RequestOptions requestOptions, Context context);
 
         @Post("/payload/media-type/string-body/sendAsJson")
         @ExpectedResponses({ 200 })
@@ -102,8 +103,8 @@ Response getAsTextSync(@HeaderParam("accept") String accept, Request
         @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 })
         @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 })
         @UnexpectedResponseExceptionType(HttpResponseException.class)
-        Mono> sendAsJson(@HeaderParam("content-type") String contentType,
-            @HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData text,
+        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")
@@ -112,8 +113,8 @@ Mono> sendAsJson(@HeaderParam("content-type") String contentType,
         @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 })
         @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 })
         @UnexpectedResponseExceptionType(HttpResponseException.class)
-        Response sendAsJsonSync(@HeaderParam("content-type") String contentType,
-            @HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData text,
+        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")
@@ -122,8 +123,8 @@ Response sendAsJsonSync(@HeaderParam("content-type") String contentType,
         @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 })
         @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 })
         @UnexpectedResponseExceptionType(HttpResponseException.class)
-        Mono> getAsJson(@HeaderParam("accept") String accept, RequestOptions requestOptions,
-            Context context);
+        Mono> getAsJson(@HostParam("endpoint") String endpoint,
+            @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context);
 
         @Get("/payload/media-type/string-body/getAsJson")
         @ExpectedResponses({ 200 })
@@ -131,8 +132,8 @@ Mono> getAsJson(@HeaderParam("accept") String accept, Reque
         @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 })
         @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 })
         @UnexpectedResponseExceptionType(HttpResponseException.class)
-        Response getAsJsonSync(@HeaderParam("accept") String accept, RequestOptions requestOptions,
-            Context context);
+        Response getAsJsonSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept,
+            RequestOptions requestOptions, Context context);
     }
 
     /**
@@ -154,8 +155,8 @@ Response getAsJsonSync(@HeaderParam("accept") String accept, Request
     @ServiceMethod(returns = ReturnType.SINGLE)
     public Mono> sendAsTextWithResponseAsync(BinaryData text, RequestOptions requestOptions) {
         final String contentType = "text/plain";
-        final String accept = "application/json";
-        return FluxUtil.withContext(context -> service.sendAsText(contentType, accept, text, requestOptions, context));
+        return FluxUtil.withContext(
+            context -> service.sendAsText(this.client.getEndpoint(), contentType, text, requestOptions, context));
     }
 
     /**
@@ -177,8 +178,7 @@ public Mono> sendAsTextWithResponseAsync(BinaryData text, Request
     @ServiceMethod(returns = ReturnType.SINGLE)
     public Response sendAsTextWithResponse(BinaryData text, RequestOptions requestOptions) {
         final String contentType = "text/plain";
-        final String accept = "application/json";
-        return service.sendAsTextSync(contentType, accept, text, requestOptions, Context.NONE);
+        return service.sendAsTextSync(this.client.getEndpoint(), contentType, text, requestOptions, Context.NONE);
     }
 
     /**
@@ -199,7 +199,8 @@ public Response sendAsTextWithResponse(BinaryData text, RequestOptions req
     @ServiceMethod(returns = ReturnType.SINGLE)
     public Mono> getAsTextWithResponseAsync(RequestOptions requestOptions) {
         final String accept = "text/plain";
-        return FluxUtil.withContext(context -> service.getAsText(accept, requestOptions, context));
+        return FluxUtil
+            .withContext(context -> service.getAsText(this.client.getEndpoint(), accept, requestOptions, context));
     }
 
     /**
@@ -220,7 +221,7 @@ public Mono> getAsTextWithResponseAsync(RequestOptions requ
     @ServiceMethod(returns = ReturnType.SINGLE)
     public Response getAsTextWithResponse(RequestOptions requestOptions) {
         final String accept = "text/plain";
-        return service.getAsTextSync(accept, requestOptions, Context.NONE);
+        return service.getAsTextSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE);
     }
 
     /**
@@ -242,8 +243,8 @@ public Response getAsTextWithResponse(RequestOptions requestOptions)
     @ServiceMethod(returns = ReturnType.SINGLE)
     public Mono> sendAsJsonWithResponseAsync(BinaryData text, RequestOptions requestOptions) {
         final String contentType = "application/json";
-        final String accept = "application/json";
-        return FluxUtil.withContext(context -> service.sendAsJson(contentType, accept, text, requestOptions, context));
+        return FluxUtil.withContext(
+            context -> service.sendAsJson(this.client.getEndpoint(), contentType, text, requestOptions, context));
     }
 
     /**
@@ -265,8 +266,7 @@ public Mono> sendAsJsonWithResponseAsync(BinaryData text, Request
     @ServiceMethod(returns = ReturnType.SINGLE)
     public Response sendAsJsonWithResponse(BinaryData text, RequestOptions requestOptions) {
         final String contentType = "application/json";
-        final String accept = "application/json";
-        return service.sendAsJsonSync(contentType, accept, text, requestOptions, Context.NONE);
+        return service.sendAsJsonSync(this.client.getEndpoint(), contentType, text, requestOptions, Context.NONE);
     }
 
     /**
@@ -287,7 +287,8 @@ public Response sendAsJsonWithResponse(BinaryData text, RequestOptions req
     @ServiceMethod(returns = ReturnType.SINGLE)
     public Mono> getAsJsonWithResponseAsync(RequestOptions requestOptions) {
         final String accept = "application/json";
-        return FluxUtil.withContext(context -> service.getAsJson(accept, requestOptions, context));
+        return FluxUtil
+            .withContext(context -> service.getAsJson(this.client.getEndpoint(), accept, requestOptions, context));
     }
 
     /**
@@ -308,6 +309,6 @@ public Mono> getAsJsonWithResponseAsync(RequestOptions requ
     @ServiceMethod(returns = ReturnType.SINGLE)
     public Response getAsJsonWithResponse(RequestOptions requestOptions) {
         final String accept = "application/json";
-        return service.getAsJsonSync(accept, requestOptions, Context.NONE);
+        return service.getAsJsonSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE);
     }
 }
diff --git a/typespec-tests/src/main/java/com/payload/multipart/MultiPartClientBuilder.java b/typespec-tests/src/main/java/com/payload/multipart/MultiPartClientBuilder.java
index 40dbcf9148..b1734e648f 100644
--- a/typespec-tests/src/main/java/com/payload/multipart/MultiPartClientBuilder.java
+++ b/typespec-tests/src/main/java/com/payload/multipart/MultiPartClientBuilder.java
@@ -7,6 +7,7 @@
 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;
@@ -40,8 +41,8 @@
  * A builder for creating a new instance of the MultiPartClient type.
  */
 @ServiceClientBuilder(serviceClients = { MultiPartClient.class, MultiPartAsyncClient.class })
-public final class MultiPartClientBuilder
-    implements HttpTrait, ConfigurationTrait {
+public final class MultiPartClientBuilder implements HttpTrait,
+    ConfigurationTrait, EndpointTrait {
     @Generated
     private static final String SDK_NAME = "name";
 
@@ -172,6 +173,22 @@ public MultiPartClientBuilder configuration(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.
      */
@@ -199,8 +216,9 @@ public MultiPartClientBuilder retryPolicy(RetryPolicy retryPolicy) {
     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());
+            = new MultiPartClientImpl(localPipeline, JacksonAdapter.createDefaultSerializerAdapter(), localEndpoint);
         return client;
     }
 
diff --git a/typespec-tests/src/main/java/com/payload/multipart/implementation/FormDatasImpl.java b/typespec-tests/src/main/java/com/payload/multipart/implementation/FormDatasImpl.java
index 23e72d60a6..9136290d42 100644
--- a/typespec-tests/src/main/java/com/payload/multipart/implementation/FormDatasImpl.java
+++ b/typespec-tests/src/main/java/com/payload/multipart/implementation/FormDatasImpl.java
@@ -8,6 +8,7 @@
 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;
@@ -54,7 +55,7 @@ public final class FormDatasImpl {
      * The interface defining all the services for MultiPartClientFormDatas to be used by the proxy service to perform
      * REST calls.
      */
-    @Host("http://localhost:3000")
+    @Host("{endpoint}")
     @ServiceInterface(name = "MultiPartClientFormD")
     public interface FormDatasService {
         // @Multipart not supported by RestProxy
@@ -64,8 +65,8 @@ public interface FormDatasService {
         @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 })
         @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 })
         @UnexpectedResponseExceptionType(HttpResponseException.class)
-        Mono> basic(@HeaderParam("content-type") String contentType,
-            @HeaderParam("accept") String accept, @BodyParam("multipart/form-data") BinaryData body,
+        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
@@ -75,8 +76,9 @@ Mono> basic(@HeaderParam("content-type") String contentType,
         @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 })
         @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 })
         @UnexpectedResponseExceptionType(HttpResponseException.class)
-        Response basicSync(@HeaderParam("content-type") String contentType, @HeaderParam("accept") String accept,
-            @BodyParam("multipart/form-data") BinaryData body, RequestOptions requestOptions, Context context);
+        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")
@@ -85,8 +87,8 @@ Response basicSync(@HeaderParam("content-type") String contentType, @Heade
         @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 })
         @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 })
         @UnexpectedResponseExceptionType(HttpResponseException.class)
-        Mono> complex(@HeaderParam("content-type") String contentType,
-            @HeaderParam("accept") String accept, @BodyParam("multipart/form-data") BinaryData body,
+        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
@@ -96,8 +98,8 @@ Mono> complex(@HeaderParam("content-type") String contentType,
         @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 })
         @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 })
         @UnexpectedResponseExceptionType(HttpResponseException.class)
-        Response complexSync(@HeaderParam("content-type") String contentType,
-            @HeaderParam("accept") String accept, @BodyParam("multipart/form-data") BinaryData body,
+        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
@@ -107,8 +109,8 @@ Response complexSync(@HeaderParam("content-type") String contentType,
         @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 })
         @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 })
         @UnexpectedResponseExceptionType(HttpResponseException.class)
-        Mono> jsonPart(@HeaderParam("content-type") String contentType,
-            @HeaderParam("accept") String accept, @BodyParam("multipart/form-data") BinaryData body,
+        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
@@ -118,8 +120,8 @@ Mono> jsonPart(@HeaderParam("content-type") String contentType,
         @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 })
         @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 })
         @UnexpectedResponseExceptionType(HttpResponseException.class)
-        Response jsonPartSync(@HeaderParam("content-type") String contentType,
-            @HeaderParam("accept") String accept, @BodyParam("multipart/form-data") BinaryData body,
+        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
@@ -129,8 +131,8 @@ Response jsonPartSync(@HeaderParam("content-type") String contentType,
         @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 })
         @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 })
         @UnexpectedResponseExceptionType(HttpResponseException.class)
-        Mono> binaryArrayParts(@HeaderParam("content-type") String contentType,
-            @HeaderParam("accept") String accept, @BodyParam("multipart/form-data") BinaryData body,
+        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
@@ -140,8 +142,8 @@ Mono> binaryArrayParts(@HeaderParam("content-type") String conten
         @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 })
         @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 })
         @UnexpectedResponseExceptionType(HttpResponseException.class)
-        Response binaryArrayPartsSync(@HeaderParam("content-type") String contentType,
-            @HeaderParam("accept") String accept, @BodyParam("multipart/form-data") BinaryData body,
+        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
@@ -151,8 +153,8 @@ Response binaryArrayPartsSync(@HeaderParam("content-type") String contentT
         @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 })
         @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 })
         @UnexpectedResponseExceptionType(HttpResponseException.class)
-        Mono> multiBinaryParts(@HeaderParam("content-type") String contentType,
-            @HeaderParam("accept") String accept, @BodyParam("multipart/form-data") BinaryData body,
+        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
@@ -162,8 +164,8 @@ Mono> multiBinaryParts(@HeaderParam("content-type") String conten
         @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 })
         @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 })
         @UnexpectedResponseExceptionType(HttpResponseException.class)
-        Response multiBinaryPartsSync(@HeaderParam("content-type") String contentType,
-            @HeaderParam("accept") String accept, @BodyParam("multipart/form-data") BinaryData body,
+        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
@@ -173,8 +175,8 @@ Response multiBinaryPartsSync(@HeaderParam("content-type") String contentT
         @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 })
         @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 })
         @UnexpectedResponseExceptionType(HttpResponseException.class)
-        Mono> checkFileNameAndContentType(@HeaderParam("content-type") String contentType,
-            @HeaderParam("accept") String accept, @BodyParam("multipart/form-data") BinaryData body,
+        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
@@ -184,8 +186,8 @@ Mono> checkFileNameAndContentType(@HeaderParam("content-type") St
         @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 })
         @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 })
         @UnexpectedResponseExceptionType(HttpResponseException.class)
-        Response checkFileNameAndContentTypeSync(@HeaderParam("content-type") String contentType,
-            @HeaderParam("accept") String accept, @BodyParam("multipart/form-data") BinaryData body,
+        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
@@ -195,9 +197,10 @@ Response checkFileNameAndContentTypeSync(@HeaderParam("content-type") Stri
         @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 })
         @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 })
         @UnexpectedResponseExceptionType(HttpResponseException.class)
-        Mono> anonymousModel(@HeaderParam("content-type") String contentType,
-            @HeaderParam("accept") String accept, @BodyParam("multipart/form-data") BinaryData anonymousModelRequest,
-            RequestOptions requestOptions, Context context);
+        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")
@@ -206,9 +209,10 @@ Mono> anonymousModel(@HeaderParam("content-type") String contentT
         @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 })
         @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 })
         @UnexpectedResponseExceptionType(HttpResponseException.class)
-        Response anonymousModelSync(@HeaderParam("content-type") String contentType,
-            @HeaderParam("accept") String accept, @BodyParam("multipart/form-data") BinaryData anonymousModelRequest,
-            RequestOptions requestOptions, Context context);
+        Response anonymousModelSync(@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/check-filename-and-specific-content-type-with-httppart")
@@ -217,8 +221,8 @@ Response anonymousModelSync(@HeaderParam("content-type") String contentTyp
         @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 })
         @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 })
         @UnexpectedResponseExceptionType(HttpResponseException.class)
-        Mono> fileWithHttpPartSpecificContentType(@HeaderParam("content-type") String contentType,
-            @HeaderParam("accept") String accept, @BodyParam("multipart/form-data") BinaryData body,
+        Mono> fileWithHttpPartSpecificContentType(@HostParam("endpoint") String endpoint,
+            @HeaderParam("content-type") String contentType, @BodyParam("multipart/form-data") BinaryData body,
             RequestOptions requestOptions, Context context);
 
         // @Multipart not supported by RestProxy
@@ -228,8 +232,8 @@ Mono> fileWithHttpPartSpecificContentType(@HeaderParam("content-t
         @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 })
         @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 })
         @UnexpectedResponseExceptionType(HttpResponseException.class)
-        Response fileWithHttpPartSpecificContentTypeSync(@HeaderParam("content-type") String contentType,
-            @HeaderParam("accept") String accept, @BodyParam("multipart/form-data") BinaryData body,
+        Response fileWithHttpPartSpecificContentTypeSync(@HostParam("endpoint") String endpoint,
+            @HeaderParam("content-type") String contentType, @BodyParam("multipart/form-data") BinaryData body,
             RequestOptions requestOptions, Context context);
 
         // @Multipart not supported by RestProxy
@@ -239,8 +243,8 @@ Response fileWithHttpPartSpecificContentTypeSync(@HeaderParam("content-typ
         @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 })
         @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 })
         @UnexpectedResponseExceptionType(HttpResponseException.class)
-        Mono> fileWithHttpPartRequiredContentType(@HeaderParam("content-type") String contentType,
-            @HeaderParam("accept") String accept, @BodyParam("multipart/form-data") BinaryData body,
+        Mono> fileWithHttpPartRequiredContentType(@HostParam("endpoint") String endpoint,
+            @HeaderParam("content-type") String contentType, @BodyParam("multipart/form-data") BinaryData body,
             RequestOptions requestOptions, Context context);
 
         // @Multipart not supported by RestProxy
@@ -250,8 +254,8 @@ Mono> fileWithHttpPartRequiredContentType(@HeaderParam("content-t
         @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 })
         @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 })
         @UnexpectedResponseExceptionType(HttpResponseException.class)
-        Response fileWithHttpPartRequiredContentTypeSync(@HeaderParam("content-type") String contentType,
-            @HeaderParam("accept") String accept, @BodyParam("multipart/form-data") BinaryData body,
+        Response fileWithHttpPartRequiredContentTypeSync(@HostParam("endpoint") String endpoint,
+            @HeaderParam("content-type") String contentType, @BodyParam("multipart/form-data") BinaryData body,
             RequestOptions requestOptions, Context context);
 
         // @Multipart not supported by RestProxy
@@ -261,8 +265,8 @@ Response fileWithHttpPartRequiredContentTypeSync(@HeaderParam("content-typ
         @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 })
         @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 })
         @UnexpectedResponseExceptionType(HttpResponseException.class)
-        Mono> fileWithHttpPartOptionalContentType(@HeaderParam("content-type") String contentType,
-            @HeaderParam("accept") String accept, @BodyParam("multipart/form-data") BinaryData body,
+        Mono> fileWithHttpPartOptionalContentType(@HostParam("endpoint") String endpoint,
+            @HeaderParam("content-type") String contentType, @BodyParam("multipart/form-data") BinaryData body,
             RequestOptions requestOptions, Context context);
 
         // @Multipart not supported by RestProxy
@@ -272,8 +276,8 @@ Mono> fileWithHttpPartOptionalContentType(@HeaderParam("content-t
         @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 })
         @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 })
         @UnexpectedResponseExceptionType(HttpResponseException.class)
-        Response fileWithHttpPartOptionalContentTypeSync(@HeaderParam("content-type") String contentType,
-            @HeaderParam("accept") String accept, @BodyParam("multipart/form-data") BinaryData body,
+        Response fileWithHttpPartOptionalContentTypeSync(@HostParam("endpoint") String endpoint,
+            @HeaderParam("content-type") String contentType, @BodyParam("multipart/form-data") BinaryData body,
             RequestOptions requestOptions, Context context);
 
         // @Multipart not supported by RestProxy
@@ -283,8 +287,8 @@ Response fileWithHttpPartOptionalContentTypeSync(@HeaderParam("content-typ
         @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 })
         @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 })
         @UnexpectedResponseExceptionType(HttpResponseException.class)
-        Mono> complexWithHttpPart(@HeaderParam("content-type") String contentType,
-            @HeaderParam("accept") String accept, @BodyParam("multipart/form-data") BinaryData body,
+        Mono> complexWithHttpPart(@HostParam("endpoint") String endpoint,
+            @HeaderParam("content-type") String contentType, @BodyParam("multipart/form-data") BinaryData body,
             RequestOptions requestOptions, Context context);
 
         // @Multipart not supported by RestProxy
@@ -294,8 +298,8 @@ Mono> complexWithHttpPart(@HeaderParam("content-type") String con
         @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 })
         @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 })
         @UnexpectedResponseExceptionType(HttpResponseException.class)
-        Response complexWithHttpPartSync(@HeaderParam("content-type") String contentType,
-            @HeaderParam("accept") String accept, @BodyParam("multipart/form-data") BinaryData body,
+        Response complexWithHttpPartSync(@HostParam("endpoint") String endpoint,
+            @HeaderParam("content-type") String contentType, @BodyParam("multipart/form-data") BinaryData body,
             RequestOptions requestOptions, Context context);
     }
 
@@ -313,8 +317,8 @@ Response complexWithHttpPartSync(@HeaderParam("content-type") String conte
     @ServiceMethod(returns = ReturnType.SINGLE)
     public Mono> basicWithResponseAsync(BinaryData body, RequestOptions requestOptions) {
         final String contentType = "multipart/form-data";
-        final String accept = "application/json";
-        return FluxUtil.withContext(context -> service.basic(contentType, accept, body, requestOptions, context));
+        return FluxUtil.withContext(
+            context -> service.basic(this.client.getEndpoint(), contentType, body, requestOptions, context));
     }
 
     /**
@@ -331,8 +335,7 @@ public Mono> basicWithResponseAsync(BinaryData body, RequestOptio
     @ServiceMethod(returns = ReturnType.SINGLE)
     public Response basicWithResponse(BinaryData body, RequestOptions requestOptions) {
         final String contentType = "multipart/form-data";
-        final String accept = "application/json";
-        return service.basicSync(contentType, accept, body, requestOptions, Context.NONE);
+        return service.basicSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE);
     }
 
     /**
@@ -349,8 +352,8 @@ public Response basicWithResponse(BinaryData body, RequestOptions requestO
     @ServiceMethod(returns = ReturnType.SINGLE)
     public Mono> complexWithResponseAsync(BinaryData body, RequestOptions requestOptions) {
         final String contentType = "multipart/form-data";
-        final String accept = "application/json";
-        return FluxUtil.withContext(context -> service.complex(contentType, accept, body, requestOptions, context));
+        return FluxUtil.withContext(
+            context -> service.complex(this.client.getEndpoint(), contentType, body, requestOptions, context));
     }
 
     /**
@@ -367,8 +370,7 @@ public Mono> complexWithResponseAsync(BinaryData body, RequestOpt
     @ServiceMethod(returns = ReturnType.SINGLE)
     public Response complexWithResponse(BinaryData body, RequestOptions requestOptions) {
         final String contentType = "multipart/form-data";
-        final String accept = "application/json";
-        return service.complexSync(contentType, accept, body, requestOptions, Context.NONE);
+        return service.complexSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE);
     }
 
     /**
@@ -385,8 +387,8 @@ public Response complexWithResponse(BinaryData body, RequestOptions reques
     @ServiceMethod(returns = ReturnType.SINGLE)
     public Mono> jsonPartWithResponseAsync(BinaryData body, RequestOptions requestOptions) {
         final String contentType = "multipart/form-data";
-        final String accept = "application/json";
-        return FluxUtil.withContext(context -> service.jsonPart(contentType, accept, body, requestOptions, context));
+        return FluxUtil.withContext(
+            context -> service.jsonPart(this.client.getEndpoint(), contentType, body, requestOptions, context));
     }
 
     /**
@@ -403,8 +405,7 @@ public Mono> jsonPartWithResponseAsync(BinaryData body, RequestOp
     @ServiceMethod(returns = ReturnType.SINGLE)
     public Response jsonPartWithResponse(BinaryData body, RequestOptions requestOptions) {
         final String contentType = "multipart/form-data";
-        final String accept = "application/json";
-        return service.jsonPartSync(contentType, accept, body, requestOptions, Context.NONE);
+        return service.jsonPartSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE);
     }
 
     /**
@@ -421,9 +422,8 @@ public Response jsonPartWithResponse(BinaryData body, RequestOptions reque
     @ServiceMethod(returns = ReturnType.SINGLE)
     public Mono> binaryArrayPartsWithResponseAsync(BinaryData body, RequestOptions requestOptions) {
         final String contentType = "multipart/form-data";
-        final String accept = "application/json";
-        return FluxUtil
-            .withContext(context -> service.binaryArrayParts(contentType, accept, body, requestOptions, context));
+        return FluxUtil.withContext(
+            context -> service.binaryArrayParts(this.client.getEndpoint(), contentType, body, requestOptions, context));
     }
 
     /**
@@ -440,8 +440,7 @@ public Mono> binaryArrayPartsWithResponseAsync(BinaryData body, R
     @ServiceMethod(returns = ReturnType.SINGLE)
     public Response binaryArrayPartsWithResponse(BinaryData body, RequestOptions requestOptions) {
         final String contentType = "multipart/form-data";
-        final String accept = "application/json";
-        return service.binaryArrayPartsSync(contentType, accept, body, requestOptions, Context.NONE);
+        return service.binaryArrayPartsSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE);
     }
 
     /**
@@ -458,9 +457,8 @@ public Response binaryArrayPartsWithResponse(BinaryData body, RequestOptio
     @ServiceMethod(returns = ReturnType.SINGLE)
     public Mono> multiBinaryPartsWithResponseAsync(BinaryData body, RequestOptions requestOptions) {
         final String contentType = "multipart/form-data";
-        final String accept = "application/json";
-        return FluxUtil
-            .withContext(context -> service.multiBinaryParts(contentType, accept, body, requestOptions, context));
+        return FluxUtil.withContext(
+            context -> service.multiBinaryParts(this.client.getEndpoint(), contentType, body, requestOptions, context));
     }
 
     /**
@@ -477,8 +475,7 @@ public Mono> multiBinaryPartsWithResponseAsync(BinaryData body, R
     @ServiceMethod(returns = ReturnType.SINGLE)
     public Response multiBinaryPartsWithResponse(BinaryData body, RequestOptions requestOptions) {
         final String contentType = "multipart/form-data";
-        final String accept = "application/json";
-        return service.multiBinaryPartsSync(contentType, accept, body, requestOptions, Context.NONE);
+        return service.multiBinaryPartsSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE);
     }
 
     /**
@@ -496,9 +493,8 @@ public Response multiBinaryPartsWithResponse(BinaryData body, RequestOptio
     public Mono> checkFileNameAndContentTypeWithResponseAsync(BinaryData body,
         RequestOptions requestOptions) {
         final String contentType = "multipart/form-data";
-        final String accept = "application/json";
-        return FluxUtil.withContext(
-            context -> service.checkFileNameAndContentType(contentType, accept, body, requestOptions, context));
+        return FluxUtil.withContext(context -> service.checkFileNameAndContentType(this.client.getEndpoint(),
+            contentType, body, requestOptions, context));
     }
 
     /**
@@ -515,8 +511,8 @@ public Mono> checkFileNameAndContentTypeWithResponseAsync(BinaryD
     @ServiceMethod(returns = ReturnType.SINGLE)
     public Response checkFileNameAndContentTypeWithResponse(BinaryData body, RequestOptions requestOptions) {
         final String contentType = "multipart/form-data";
-        final String accept = "application/json";
-        return service.checkFileNameAndContentTypeSync(contentType, accept, body, requestOptions, Context.NONE);
+        return service.checkFileNameAndContentTypeSync(this.client.getEndpoint(), contentType, body, requestOptions,
+            Context.NONE);
     }
 
     /**
@@ -534,9 +530,8 @@ public Response checkFileNameAndContentTypeWithResponse(BinaryData body, R
     public Mono> anonymousModelWithResponseAsync(BinaryData anonymousModelRequest,
         RequestOptions requestOptions) {
         final String contentType = "multipart/form-data";
-        final String accept = "application/json";
-        return FluxUtil.withContext(
-            context -> service.anonymousModel(contentType, accept, anonymousModelRequest, requestOptions, context));
+        return FluxUtil.withContext(context -> service.anonymousModel(this.client.getEndpoint(), contentType,
+            anonymousModelRequest, requestOptions, context));
     }
 
     /**
@@ -553,8 +548,8 @@ public Mono> anonymousModelWithResponseAsync(BinaryData anonymous
     @ServiceMethod(returns = ReturnType.SINGLE)
     public Response anonymousModelWithResponse(BinaryData anonymousModelRequest, RequestOptions requestOptions) {
         final String contentType = "multipart/form-data";
-        final String accept = "application/json";
-        return service.anonymousModelSync(contentType, accept, anonymousModelRequest, requestOptions, Context.NONE);
+        return service.anonymousModelSync(this.client.getEndpoint(), contentType, anonymousModelRequest, requestOptions,
+            Context.NONE);
     }
 
     /**
@@ -572,9 +567,8 @@ public Response anonymousModelWithResponse(BinaryData anonymousModelReques
     public Mono> fileWithHttpPartSpecificContentTypeWithResponseAsync(BinaryData body,
         RequestOptions requestOptions) {
         final String contentType = "multipart/form-data";
-        final String accept = "application/json";
-        return FluxUtil.withContext(
-            context -> service.fileWithHttpPartSpecificContentType(contentType, accept, body, requestOptions, context));
+        return FluxUtil.withContext(context -> service.fileWithHttpPartSpecificContentType(this.client.getEndpoint(),
+            contentType, body, requestOptions, context));
     }
 
     /**
@@ -592,8 +586,8 @@ public Mono> fileWithHttpPartSpecificContentTypeWithResponseAsync
     public Response fileWithHttpPartSpecificContentTypeWithResponse(BinaryData body,
         RequestOptions requestOptions) {
         final String contentType = "multipart/form-data";
-        final String accept = "application/json";
-        return service.fileWithHttpPartSpecificContentTypeSync(contentType, accept, body, requestOptions, Context.NONE);
+        return service.fileWithHttpPartSpecificContentTypeSync(this.client.getEndpoint(), contentType, body,
+            requestOptions, Context.NONE);
     }
 
     /**
@@ -611,9 +605,8 @@ public Response fileWithHttpPartSpecificContentTypeWithResponse(BinaryData
     public Mono> fileWithHttpPartRequiredContentTypeWithResponseAsync(BinaryData body,
         RequestOptions requestOptions) {
         final String contentType = "multipart/form-data";
-        final String accept = "application/json";
-        return FluxUtil.withContext(
-            context -> service.fileWithHttpPartRequiredContentType(contentType, accept, body, requestOptions, context));
+        return FluxUtil.withContext(context -> service.fileWithHttpPartRequiredContentType(this.client.getEndpoint(),
+            contentType, body, requestOptions, context));
     }
 
     /**
@@ -631,8 +624,8 @@ public Mono> fileWithHttpPartRequiredContentTypeWithResponseAsync
     public Response fileWithHttpPartRequiredContentTypeWithResponse(BinaryData body,
         RequestOptions requestOptions) {
         final String contentType = "multipart/form-data";
-        final String accept = "application/json";
-        return service.fileWithHttpPartRequiredContentTypeSync(contentType, accept, body, requestOptions, Context.NONE);
+        return service.fileWithHttpPartRequiredContentTypeSync(this.client.getEndpoint(), contentType, body,
+            requestOptions, Context.NONE);
     }
 
     /**
@@ -650,9 +643,8 @@ public Response fileWithHttpPartRequiredContentTypeWithResponse(BinaryData
     public Mono> fileWithHttpPartOptionalContentTypeWithResponseAsync(BinaryData body,
         RequestOptions requestOptions) {
         final String contentType = "multipart/form-data";
-        final String accept = "application/json";
-        return FluxUtil.withContext(
-            context -> service.fileWithHttpPartOptionalContentType(contentType, accept, body, requestOptions, context));
+        return FluxUtil.withContext(context -> service.fileWithHttpPartOptionalContentType(this.client.getEndpoint(),
+            contentType, body, requestOptions, context));
     }
 
     /**
@@ -670,8 +662,8 @@ public Mono> fileWithHttpPartOptionalContentTypeWithResponseAsync
     public Response fileWithHttpPartOptionalContentTypeWithResponse(BinaryData body,
         RequestOptions requestOptions) {
         final String contentType = "multipart/form-data";
-        final String accept = "application/json";
-        return service.fileWithHttpPartOptionalContentTypeSync(contentType, accept, body, requestOptions, Context.NONE);
+        return service.fileWithHttpPartOptionalContentTypeSync(this.client.getEndpoint(), contentType, body,
+            requestOptions, Context.NONE);
     }
 
     /**
@@ -688,9 +680,8 @@ public Response fileWithHttpPartOptionalContentTypeWithResponse(BinaryData
     @ServiceMethod(returns = ReturnType.SINGLE)
     public Mono> complexWithHttpPartWithResponseAsync(BinaryData body, RequestOptions requestOptions) {
         final String contentType = "multipart/form-data";
-        final String accept = "application/json";
-        return FluxUtil
-            .withContext(context -> service.complexWithHttpPart(contentType, accept, body, requestOptions, context));
+        return FluxUtil.withContext(context -> service.complexWithHttpPart(this.client.getEndpoint(), contentType, body,
+            requestOptions, context));
     }
 
     /**
@@ -707,7 +698,7 @@ public Mono> complexWithHttpPartWithResponseAsync(BinaryData body
     @ServiceMethod(returns = ReturnType.SINGLE)
     public Response complexWithHttpPartWithResponse(BinaryData body, RequestOptions requestOptions) {
         final String contentType = "multipart/form-data";
-        final String accept = "application/json";
-        return service.complexWithHttpPartSync(contentType, accept, body, requestOptions, Context.NONE);
+        return service.complexWithHttpPartSync(this.client.getEndpoint(), contentType, body, requestOptions,
+            Context.NONE);
     }
 }
diff --git a/typespec-tests/src/main/java/com/payload/multipart/implementation/MultiPartClientImpl.java b/typespec-tests/src/main/java/com/payload/multipart/implementation/MultiPartClientImpl.java
index 31c1179031..b09a3bf8dc 100644
--- a/typespec-tests/src/main/java/com/payload/multipart/implementation/MultiPartClientImpl.java
+++ b/typespec-tests/src/main/java/com/payload/multipart/implementation/MultiPartClientImpl.java
@@ -15,6 +15,20 @@
  * 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.
      */
@@ -59,19 +73,22 @@ public FormDatasImpl getFormDatas() {
 
     /**
      * Initializes an instance of MultiPartClient client.
+     * 
+     * @param endpoint Service host.
      */
-    public MultiPartClientImpl() {
+    public MultiPartClientImpl(String endpoint) {
         this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(),
-            JacksonAdapter.createDefaultSerializerAdapter());
+            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) {
-        this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter());
+    public MultiPartClientImpl(HttpPipeline httpPipeline, String endpoint) {
+        this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint);
     }
 
     /**
@@ -79,10 +96,12 @@ public MultiPartClientImpl(HttpPipeline httpPipeline) {
      * 
      * @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) {
+    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/typespec-tests/src/main/java/com/payload/pageable/PageableClientBuilder.java b/typespec-tests/src/main/java/com/payload/pageable/PageableClientBuilder.java
index 37725fcab3..5e4da1687b 100644
--- a/typespec-tests/src/main/java/com/payload/pageable/PageableClientBuilder.java
+++ b/typespec-tests/src/main/java/com/payload/pageable/PageableClientBuilder.java
@@ -7,6 +7,7 @@
 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;
@@ -40,8 +41,8 @@
  * A builder for creating a new instance of the PageableClient type.
  */
 @ServiceClientBuilder(serviceClients = { PageableClient.class, PageableAsyncClient.class })
-public final class PageableClientBuilder
-    implements HttpTrait, ConfigurationTrait {
+public final class PageableClientBuilder implements HttpTrait,
+    ConfigurationTrait, EndpointTrait {
     @Generated
     private static final String SDK_NAME = "name";
 
@@ -172,6 +173,22 @@ public PageableClientBuilder configuration(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.
      */
@@ -199,8 +216,9 @@ public PageableClientBuilder retryPolicy(RetryPolicy retryPolicy) {
     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());
+            = new PageableClientImpl(localPipeline, JacksonAdapter.createDefaultSerializerAdapter(), localEndpoint);
         return client;
     }
 
diff --git a/typespec-tests/src/main/java/com/payload/pageable/implementation/PageableClientImpl.java b/typespec-tests/src/main/java/com/payload/pageable/implementation/PageableClientImpl.java
index 6e4347e371..bc5106cec3 100644
--- a/typespec-tests/src/main/java/com/payload/pageable/implementation/PageableClientImpl.java
+++ b/typespec-tests/src/main/java/com/payload/pageable/implementation/PageableClientImpl.java
@@ -8,6 +8,7 @@
 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;
@@ -48,6 +49,20 @@ public final class PageableClientImpl {
      */
     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.
      */
@@ -78,19 +93,22 @@ public SerializerAdapter getSerializerAdapter() {
 
     /**
      * Initializes an instance of PageableClient client.
+     * 
+     * @param endpoint Service host.
      */
-    public PageableClientImpl() {
+    public PageableClientImpl(String endpoint) {
         this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(),
-            JacksonAdapter.createDefaultSerializerAdapter());
+            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) {
-        this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter());
+    public PageableClientImpl(HttpPipeline httpPipeline, String endpoint) {
+        this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint);
     }
 
     /**
@@ -98,17 +116,19 @@ public PageableClientImpl(HttpPipeline httpPipeline) {
      * 
      * @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) {
+    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("http://localhost:3000")
+    @Host("{endpoint}")
     @ServiceInterface(name = "PageableClient")
     public interface PageableClientService {
         @Get("/payload/pageable")
@@ -117,8 +137,8 @@ public interface PageableClientService {
         @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 })
         @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 })
         @UnexpectedResponseExceptionType(HttpResponseException.class)
-        Mono> list(@HeaderParam("accept") String accept, RequestOptions requestOptions,
-            Context context);
+        Mono> list(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept,
+            RequestOptions requestOptions, Context context);
 
         @Get("/payload/pageable")
         @ExpectedResponses({ 200 })
@@ -126,8 +146,8 @@ Mono> list(@HeaderParam("accept") String accept, RequestOpt
         @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 })
         @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 })
         @UnexpectedResponseExceptionType(HttpResponseException.class)
-        Response listSync(@HeaderParam("accept") String accept, RequestOptions requestOptions,
-            Context context);
+        Response listSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept,
+            RequestOptions requestOptions, Context context);
 
         @Get("{nextLink}")
         @ExpectedResponses({ 200 })
@@ -136,7 +156,8 @@ Response listSync(@HeaderParam("accept") String accept, RequestOptio
         @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 })
         @UnexpectedResponseExceptionType(HttpResponseException.class)
         Mono> listNext(@PathParam(value = "nextLink", encoded = true) String nextLink,
-            @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context);
+            @HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, RequestOptions requestOptions,
+            Context context);
 
         @Get("{nextLink}")
         @ExpectedResponses({ 200 })
@@ -145,7 +166,8 @@ Mono> listNext(@PathParam(value = "nextLink", encoded = tru
         @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 })
         @UnexpectedResponseExceptionType(HttpResponseException.class)
         Response listNextSync(@PathParam(value = "nextLink", encoded = true) String nextLink,
-            @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context);
+            @HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, RequestOptions requestOptions,
+            Context context);
     }
 
     /**
@@ -175,7 +197,7 @@ Response listNextSync(@PathParam(value = "nextLink", encoded = true)
     @ServiceMethod(returns = ReturnType.SINGLE)
     private Mono> listSinglePageAsync(RequestOptions requestOptions) {
         final String accept = "application/json";
-        return FluxUtil.withContext(context -> service.list(accept, requestOptions, context))
+        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));
     }
@@ -260,7 +282,7 @@ public PagedFlux listAsync(RequestOptions requestOptions) {
     @ServiceMethod(returns = ReturnType.SINGLE)
     private PagedResponse listSinglePage(RequestOptions requestOptions) {
         final String accept = "application/json";
-        Response res = service.listSync(accept, requestOptions, Context.NONE);
+        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);
     }
@@ -319,6 +341,8 @@ public PagedIterable list(RequestOptions requestOptions) {
     }
 
     /**
+     * List users
+     * 
      * Get the next page of items.
      * 

Response Body Schema

* @@ -339,12 +363,15 @@ public PagedIterable list(RequestOptions requestOptions) { @ServiceMethod(returns = ReturnType.SINGLE) private Mono> listNextSinglePageAsync(String nextLink, RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.listNext(nextLink, accept, requestOptions, context)) + 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

* @@ -365,7 +392,8 @@ private Mono> listNextSinglePageAsync(String nextLink, @ServiceMethod(returns = ReturnType.SINGLE) private PagedResponse listNextSinglePage(String nextLink, RequestOptions requestOptions) { final String accept = "application/json"; - Response res = service.listNextSync(nextLink, accept, requestOptions, Context.NONE); + 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); } diff --git a/typespec-tests/src/main/java/com/resiliency/servicedriven/implementation/ResiliencyServiceDrivenClientImpl.java b/typespec-tests/src/main/java/com/resiliency/servicedriven/implementation/ResiliencyServiceDrivenClientImpl.java index 0ab9638406..a5f1b3eb21 100644 --- a/typespec-tests/src/main/java/com/resiliency/servicedriven/implementation/ResiliencyServiceDrivenClientImpl.java +++ b/typespec-tests/src/main/java/com/resiliency/servicedriven/implementation/ResiliencyServiceDrivenClientImpl.java @@ -8,7 +8,6 @@ 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.QueryParam; @@ -185,8 +184,7 @@ public interface ResiliencyServiceDrivenClientService { @UnexpectedResponseExceptionType(HttpResponseException.class) Mono> addOperation(@HostParam("endpoint") String endpoint, @HostParam("serviceDeploymentVersion") String serviceDeploymentVersion, - @HostParam("apiVersion") String apiVersion, @HeaderParam("accept") String accept, - RequestOptions requestOptions, Context context); + @HostParam("apiVersion") String apiVersion, RequestOptions requestOptions, Context context); @Delete("/add-operation") @ExpectedResponses({ 204 }) @@ -196,8 +194,7 @@ Mono> addOperation(@HostParam("endpoint") String endpoint, @UnexpectedResponseExceptionType(HttpResponseException.class) Response addOperationSync(@HostParam("endpoint") String endpoint, @HostParam("serviceDeploymentVersion") String serviceDeploymentVersion, - @HostParam("apiVersion") String apiVersion, @HeaderParam("accept") String accept, - RequestOptions requestOptions, Context context); + @HostParam("apiVersion") String apiVersion, RequestOptions requestOptions, Context context); @Head("/add-optional-param/from-none") @ExpectedResponses({ 204 }) @@ -207,8 +204,7 @@ Response addOperationSync(@HostParam("endpoint") String endpoint, @UnexpectedResponseExceptionType(HttpResponseException.class) Mono> fromNone(@HostParam("endpoint") String endpoint, @HostParam("serviceDeploymentVersion") String serviceDeploymentVersion, - @HostParam("apiVersion") String apiVersion, @HeaderParam("accept") String accept, - RequestOptions requestOptions, Context context); + @HostParam("apiVersion") String apiVersion, RequestOptions requestOptions, Context context); @Head("/add-optional-param/from-none") @ExpectedResponses({ 204 }) @@ -218,8 +214,7 @@ Mono> fromNone(@HostParam("endpoint") String endpoint, @UnexpectedResponseExceptionType(HttpResponseException.class) Response fromNoneSync(@HostParam("endpoint") String endpoint, @HostParam("serviceDeploymentVersion") String serviceDeploymentVersion, - @HostParam("apiVersion") String apiVersion, @HeaderParam("accept") String accept, - RequestOptions requestOptions, Context context); + @HostParam("apiVersion") String apiVersion, RequestOptions requestOptions, Context context); @Get("/add-optional-param/from-one-required") @ExpectedResponses({ 204 }) @@ -230,7 +225,7 @@ Response fromNoneSync(@HostParam("endpoint") String endpoint, Mono> fromOneRequired(@HostParam("endpoint") String endpoint, @HostParam("serviceDeploymentVersion") String serviceDeploymentVersion, @HostParam("apiVersion") String apiVersion, @QueryParam("parameter") String parameter, - @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + RequestOptions requestOptions, Context context); @Get("/add-optional-param/from-one-required") @ExpectedResponses({ 204 }) @@ -241,7 +236,7 @@ Mono> fromOneRequired(@HostParam("endpoint") String endpoint, Response fromOneRequiredSync(@HostParam("endpoint") String endpoint, @HostParam("serviceDeploymentVersion") String serviceDeploymentVersion, @HostParam("apiVersion") String apiVersion, @QueryParam("parameter") String parameter, - @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + RequestOptions requestOptions, Context context); @Get("/add-optional-param/from-one-optional") @ExpectedResponses({ 204 }) @@ -251,8 +246,7 @@ Response fromOneRequiredSync(@HostParam("endpoint") String endpoint, @UnexpectedResponseExceptionType(HttpResponseException.class) Mono> fromOneOptional(@HostParam("endpoint") String endpoint, @HostParam("serviceDeploymentVersion") String serviceDeploymentVersion, - @HostParam("apiVersion") String apiVersion, @HeaderParam("accept") String accept, - RequestOptions requestOptions, Context context); + @HostParam("apiVersion") String apiVersion, RequestOptions requestOptions, Context context); @Get("/add-optional-param/from-one-optional") @ExpectedResponses({ 204 }) @@ -262,8 +256,7 @@ Mono> fromOneOptional(@HostParam("endpoint") String endpoint, @UnexpectedResponseExceptionType(HttpResponseException.class) Response fromOneOptionalSync(@HostParam("endpoint") String endpoint, @HostParam("serviceDeploymentVersion") String serviceDeploymentVersion, - @HostParam("apiVersion") String apiVersion, @HeaderParam("accept") String accept, - RequestOptions requestOptions, Context context); + @HostParam("apiVersion") String apiVersion, RequestOptions requestOptions, Context context); } /** @@ -278,10 +271,8 @@ Response fromOneOptionalSync(@HostParam("endpoint") String endpoint, */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> addOperationWithResponseAsync(RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil - .withContext(context -> service.addOperation(this.getEndpoint(), this.getServiceDeploymentVersion(), - this.getServiceVersion().getVersion(), accept, requestOptions, context)); + return FluxUtil.withContext(context -> service.addOperation(this.getEndpoint(), + this.getServiceDeploymentVersion(), this.getServiceVersion().getVersion(), requestOptions, context)); } /** @@ -296,9 +287,8 @@ public Mono> addOperationWithResponseAsync(RequestOptions request */ @ServiceMethod(returns = ReturnType.SINGLE) public Response addOperationWithResponse(RequestOptions requestOptions) { - final String accept = "application/json"; return service.addOperationSync(this.getEndpoint(), this.getServiceDeploymentVersion(), - this.getServiceVersion().getVersion(), accept, requestOptions, Context.NONE); + this.getServiceVersion().getVersion(), requestOptions, Context.NONE); } /** @@ -320,9 +310,8 @@ public Response addOperationWithResponse(RequestOptions requestOptions) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> fromNoneWithResponseAsync(RequestOptions requestOptions) { - final String accept = "application/json"; return FluxUtil.withContext(context -> service.fromNone(this.getEndpoint(), this.getServiceDeploymentVersion(), - this.getServiceVersion().getVersion(), accept, requestOptions, context)); + this.getServiceVersion().getVersion(), requestOptions, context)); } /** @@ -344,9 +333,8 @@ public Mono> fromNoneWithResponseAsync(RequestOptions requestOpti */ @ServiceMethod(returns = ReturnType.SINGLE) public Response fromNoneWithResponse(RequestOptions requestOptions) { - final String accept = "application/json"; return service.fromNoneSync(this.getEndpoint(), this.getServiceDeploymentVersion(), - this.getServiceVersion().getVersion(), accept, requestOptions, Context.NONE); + this.getServiceVersion().getVersion(), requestOptions, Context.NONE); } /** @@ -370,10 +358,9 @@ public Response fromNoneWithResponse(RequestOptions requestOptions) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> fromOneRequiredWithResponseAsync(String parameter, RequestOptions requestOptions) { - final String accept = "application/json"; return FluxUtil .withContext(context -> service.fromOneRequired(this.getEndpoint(), this.getServiceDeploymentVersion(), - this.getServiceVersion().getVersion(), parameter, accept, requestOptions, context)); + this.getServiceVersion().getVersion(), parameter, requestOptions, context)); } /** @@ -397,9 +384,8 @@ public Mono> fromOneRequiredWithResponseAsync(String parameter, R */ @ServiceMethod(returns = ReturnType.SINGLE) public Response fromOneRequiredWithResponse(String parameter, RequestOptions requestOptions) { - final String accept = "application/json"; return service.fromOneRequiredSync(this.getEndpoint(), this.getServiceDeploymentVersion(), - this.getServiceVersion().getVersion(), parameter, accept, requestOptions, Context.NONE); + this.getServiceVersion().getVersion(), parameter, requestOptions, Context.NONE); } /** @@ -423,10 +409,8 @@ public Response fromOneRequiredWithResponse(String parameter, RequestOptio */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> fromOneOptionalWithResponseAsync(RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil - .withContext(context -> service.fromOneOptional(this.getEndpoint(), this.getServiceDeploymentVersion(), - this.getServiceVersion().getVersion(), accept, requestOptions, context)); + return FluxUtil.withContext(context -> service.fromOneOptional(this.getEndpoint(), + this.getServiceDeploymentVersion(), this.getServiceVersion().getVersion(), requestOptions, context)); } /** @@ -450,8 +434,7 @@ public Mono> fromOneOptionalWithResponseAsync(RequestOptions requ */ @ServiceMethod(returns = ReturnType.SINGLE) public Response fromOneOptionalWithResponse(RequestOptions requestOptions) { - final String accept = "application/json"; return service.fromOneOptionalSync(this.getEndpoint(), this.getServiceDeploymentVersion(), - this.getServiceVersion().getVersion(), accept, requestOptions, Context.NONE); + this.getServiceVersion().getVersion(), requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/resiliency/servicedriven/v1/implementation/ResiliencyServiceDrivenClientImpl.java b/typespec-tests/src/main/java/com/resiliency/servicedriven/v1/implementation/ResiliencyServiceDrivenClientImpl.java index e52308a2ad..e72894c316 100644 --- a/typespec-tests/src/main/java/com/resiliency/servicedriven/v1/implementation/ResiliencyServiceDrivenClientImpl.java +++ b/typespec-tests/src/main/java/com/resiliency/servicedriven/v1/implementation/ResiliencyServiceDrivenClientImpl.java @@ -7,7 +7,6 @@ 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.QueryParam; @@ -184,8 +183,7 @@ public interface ResiliencyServiceDrivenClientService { @UnexpectedResponseExceptionType(HttpResponseException.class) Mono> fromNone(@HostParam("endpoint") String endpoint, @HostParam("serviceDeploymentVersion") String serviceDeploymentVersion, - @HostParam("apiVersion") String apiVersion, @HeaderParam("accept") String accept, - RequestOptions requestOptions, Context context); + @HostParam("apiVersion") String apiVersion, RequestOptions requestOptions, Context context); @Head("/add-optional-param/from-none") @ExpectedResponses({ 204 }) @@ -195,8 +193,7 @@ Mono> fromNone(@HostParam("endpoint") String endpoint, @UnexpectedResponseExceptionType(HttpResponseException.class) Response fromNoneSync(@HostParam("endpoint") String endpoint, @HostParam("serviceDeploymentVersion") String serviceDeploymentVersion, - @HostParam("apiVersion") String apiVersion, @HeaderParam("accept") String accept, - RequestOptions requestOptions, Context context); + @HostParam("apiVersion") String apiVersion, RequestOptions requestOptions, Context context); @Get("/add-optional-param/from-one-required") @ExpectedResponses({ 204 }) @@ -207,7 +204,7 @@ Response fromNoneSync(@HostParam("endpoint") String endpoint, Mono> fromOneRequired(@HostParam("endpoint") String endpoint, @HostParam("serviceDeploymentVersion") String serviceDeploymentVersion, @HostParam("apiVersion") String apiVersion, @QueryParam("parameter") String parameter, - @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + RequestOptions requestOptions, Context context); @Get("/add-optional-param/from-one-required") @ExpectedResponses({ 204 }) @@ -218,7 +215,7 @@ Mono> fromOneRequired(@HostParam("endpoint") String endpoint, Response fromOneRequiredSync(@HostParam("endpoint") String endpoint, @HostParam("serviceDeploymentVersion") String serviceDeploymentVersion, @HostParam("apiVersion") String apiVersion, @QueryParam("parameter") String parameter, - @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + RequestOptions requestOptions, Context context); @Get("/add-optional-param/from-one-optional") @ExpectedResponses({ 204 }) @@ -228,8 +225,7 @@ Response fromOneRequiredSync(@HostParam("endpoint") String endpoint, @UnexpectedResponseExceptionType(HttpResponseException.class) Mono> fromOneOptional(@HostParam("endpoint") String endpoint, @HostParam("serviceDeploymentVersion") String serviceDeploymentVersion, - @HostParam("apiVersion") String apiVersion, @HeaderParam("accept") String accept, - RequestOptions requestOptions, Context context); + @HostParam("apiVersion") String apiVersion, RequestOptions requestOptions, Context context); @Get("/add-optional-param/from-one-optional") @ExpectedResponses({ 204 }) @@ -239,8 +235,7 @@ Mono> fromOneOptional(@HostParam("endpoint") String endpoint, @UnexpectedResponseExceptionType(HttpResponseException.class) Response fromOneOptionalSync(@HostParam("endpoint") String endpoint, @HostParam("serviceDeploymentVersion") String serviceDeploymentVersion, - @HostParam("apiVersion") String apiVersion, @HeaderParam("accept") String accept, - RequestOptions requestOptions, Context context); + @HostParam("apiVersion") String apiVersion, RequestOptions requestOptions, Context context); } /** @@ -256,9 +251,8 @@ Response fromOneOptionalSync(@HostParam("endpoint") String endpoint, */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> fromNoneWithResponseAsync(RequestOptions requestOptions) { - final String accept = "application/json"; return FluxUtil.withContext(context -> service.fromNone(this.getEndpoint(), this.getServiceDeploymentVersion(), - this.getServiceVersion().getVersion(), accept, requestOptions, context)); + this.getServiceVersion().getVersion(), requestOptions, context)); } /** @@ -274,9 +268,8 @@ public Mono> fromNoneWithResponseAsync(RequestOptions requestOpti */ @ServiceMethod(returns = ReturnType.SINGLE) public Response fromNoneWithResponse(RequestOptions requestOptions) { - final String accept = "application/json"; return service.fromNoneSync(this.getEndpoint(), this.getServiceDeploymentVersion(), - this.getServiceVersion().getVersion(), accept, requestOptions, Context.NONE); + this.getServiceVersion().getVersion(), requestOptions, Context.NONE); } /** @@ -293,10 +286,9 @@ public Response fromNoneWithResponse(RequestOptions requestOptions) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> fromOneRequiredWithResponseAsync(String parameter, RequestOptions requestOptions) { - final String accept = "application/json"; return FluxUtil .withContext(context -> service.fromOneRequired(this.getEndpoint(), this.getServiceDeploymentVersion(), - this.getServiceVersion().getVersion(), parameter, accept, requestOptions, context)); + this.getServiceVersion().getVersion(), parameter, requestOptions, context)); } /** @@ -313,9 +305,8 @@ public Mono> fromOneRequiredWithResponseAsync(String parameter, R */ @ServiceMethod(returns = ReturnType.SINGLE) public Response fromOneRequiredWithResponse(String parameter, RequestOptions requestOptions) { - final String accept = "application/json"; return service.fromOneRequiredSync(this.getEndpoint(), this.getServiceDeploymentVersion(), - this.getServiceVersion().getVersion(), parameter, accept, requestOptions, Context.NONE); + this.getServiceVersion().getVersion(), parameter, requestOptions, Context.NONE); } /** @@ -338,10 +329,8 @@ public Response fromOneRequiredWithResponse(String parameter, RequestOptio */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> fromOneOptionalWithResponseAsync(RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil - .withContext(context -> service.fromOneOptional(this.getEndpoint(), this.getServiceDeploymentVersion(), - this.getServiceVersion().getVersion(), accept, requestOptions, context)); + return FluxUtil.withContext(context -> service.fromOneOptional(this.getEndpoint(), + this.getServiceDeploymentVersion(), this.getServiceVersion().getVersion(), requestOptions, context)); } /** @@ -364,8 +353,7 @@ public Mono> fromOneOptionalWithResponseAsync(RequestOptions requ */ @ServiceMethod(returns = ReturnType.SINGLE) public Response fromOneOptionalWithResponse(RequestOptions requestOptions) { - final String accept = "application/json"; return service.fromOneOptionalSync(this.getEndpoint(), this.getServiceDeploymentVersion(), - this.getServiceVersion().getVersion(), accept, requestOptions, Context.NONE); + this.getServiceVersion().getVersion(), requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/serialization/encodedname/json/JsonClientBuilder.java b/typespec-tests/src/main/java/com/serialization/encodedname/json/JsonClientBuilder.java index b4a2d6600b..6ff9943293 100644 --- a/typespec-tests/src/main/java/com/serialization/encodedname/json/JsonClientBuilder.java +++ b/typespec-tests/src/main/java/com/serialization/encodedname/json/JsonClientBuilder.java @@ -7,6 +7,7 @@ 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; @@ -40,7 +41,8 @@ * A builder for creating a new instance of the JsonClient type. */ @ServiceClientBuilder(serviceClients = { JsonClient.class, JsonAsyncClient.class }) -public final class JsonClientBuilder implements HttpTrait, ConfigurationTrait { +public final class JsonClientBuilder + implements HttpTrait, ConfigurationTrait, EndpointTrait { @Generated private static final String SDK_NAME = "name"; @@ -172,6 +174,22 @@ public JsonClientBuilder configuration(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. */ @@ -199,7 +217,9 @@ public JsonClientBuilder retryPolicy(RetryPolicy retryPolicy) { private JsonClientImpl buildInnerClient() { this.validateClient(); HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); - JsonClientImpl client = new JsonClientImpl(localPipeline, JacksonAdapter.createDefaultSerializerAdapter()); + String localEndpoint = (endpoint != null) ? endpoint : "http://localhost:3000"; + JsonClientImpl client + = new JsonClientImpl(localPipeline, JacksonAdapter.createDefaultSerializerAdapter(), localEndpoint); return client; } diff --git a/typespec-tests/src/main/java/com/serialization/encodedname/json/implementation/JsonClientImpl.java b/typespec-tests/src/main/java/com/serialization/encodedname/json/implementation/JsonClientImpl.java index 04feefca94..9d3972323c 100644 --- a/typespec-tests/src/main/java/com/serialization/encodedname/json/implementation/JsonClientImpl.java +++ b/typespec-tests/src/main/java/com/serialization/encodedname/json/implementation/JsonClientImpl.java @@ -15,6 +15,20 @@ * 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. */ @@ -59,19 +73,22 @@ public PropertiesImpl getProperties() { /** * Initializes an instance of JsonClient client. + * + * @param endpoint Service host. */ - public JsonClientImpl() { + public JsonClientImpl(String endpoint) { this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), - JacksonAdapter.createDefaultSerializerAdapter()); + 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) { - this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter()); + public JsonClientImpl(HttpPipeline httpPipeline, String endpoint) { + this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint); } /** @@ -79,10 +96,12 @@ public JsonClientImpl(HttpPipeline httpPipeline) { * * @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) { + 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/typespec-tests/src/main/java/com/serialization/encodedname/json/implementation/PropertiesImpl.java b/typespec-tests/src/main/java/com/serialization/encodedname/json/implementation/PropertiesImpl.java index 342282e241..a72b2daa01 100644 --- a/typespec-tests/src/main/java/com/serialization/encodedname/json/implementation/PropertiesImpl.java +++ b/typespec-tests/src/main/java/com/serialization/encodedname/json/implementation/PropertiesImpl.java @@ -9,6 +9,7 @@ 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; @@ -55,7 +56,7 @@ public final class PropertiesImpl { * The interface defining all the services for JsonClientProperties to be used by the proxy service to perform REST * calls. */ - @Host("http://localhost:3000") + @Host("{endpoint}") @ServiceInterface(name = "JsonClientProperties") public interface PropertiesService { @Post("/serialization/encoded-name/json/property") @@ -64,7 +65,8 @@ public interface PropertiesService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> send(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, + 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") @@ -73,8 +75,8 @@ Mono> send(@HeaderParam("accept") String accept, @BodyParam("appl @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response sendSync(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, - RequestOptions requestOptions, Context context); + 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 }) @@ -82,8 +84,8 @@ Response sendSync(@HeaderParam("accept") String accept, @BodyParam("applic @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> get(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Get("/serialization/encoded-name/json/property") @ExpectedResponses({ 200 }) @@ -91,8 +93,8 @@ Mono> get(@HeaderParam("accept") String accept, RequestOpti @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response getSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); } /** @@ -115,8 +117,9 @@ Response getSync(@HeaderParam("accept") String accept, RequestOption */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> sendWithResponseAsync(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.send(accept, body, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.send(this.client.getEndpoint(), contentType, body, requestOptions, context)); } /** @@ -139,8 +142,8 @@ public Mono> sendWithResponseAsync(BinaryData body, RequestOption */ @ServiceMethod(returns = ReturnType.SINGLE) public Response sendWithResponse(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.sendSync(accept, body, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.sendSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); } /** @@ -163,7 +166,7 @@ public Response sendWithResponse(BinaryData body, RequestOptions requestOp @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getWithResponseAsync(RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.get(accept, requestOptions, context)); + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); } /** @@ -186,6 +189,6 @@ public Mono> getWithResponseAsync(RequestOptions requestOpt @ServiceMethod(returns = ReturnType.SINGLE) public Response getWithResponse(RequestOptions requestOptions) { final String accept = "application/json"; - return service.getSync(accept, requestOptions, Context.NONE); + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/server/endpoint/notdefined/implementation/NotDefinedClientImpl.java b/typespec-tests/src/main/java/com/server/endpoint/notdefined/implementation/NotDefinedClientImpl.java index 8d282a971e..7cce6d2572 100644 --- a/typespec-tests/src/main/java/com/server/endpoint/notdefined/implementation/NotDefinedClientImpl.java +++ b/typespec-tests/src/main/java/com/server/endpoint/notdefined/implementation/NotDefinedClientImpl.java @@ -6,7 +6,6 @@ import com.azure.core.annotation.ExpectedResponses; 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.ReturnType; @@ -40,12 +39,12 @@ public final class NotDefinedClientImpl { private final NotDefinedClientService service; /** - * Server parameter. + * Service host. */ private final String endpoint; /** - * Gets Server parameter. + * Gets Service host. * * @return the endpoint value. */ @@ -84,7 +83,7 @@ public SerializerAdapter getSerializerAdapter() { /** * Initializes an instance of NotDefinedClient client. * - * @param endpoint Server parameter. + * @param endpoint Service host. */ public NotDefinedClientImpl(String endpoint) { this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), @@ -95,7 +94,7 @@ public NotDefinedClientImpl(String endpoint) { * Initializes an instance of NotDefinedClient client. * * @param httpPipeline The HTTP pipeline to send requests through. - * @param endpoint Server parameter. + * @param endpoint Service host. */ public NotDefinedClientImpl(HttpPipeline httpPipeline, String endpoint) { this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint); @@ -106,7 +105,7 @@ public NotDefinedClientImpl(HttpPipeline httpPipeline, String endpoint) { * * @param httpPipeline The HTTP pipeline to send requests through. * @param serializerAdapter The serializer to serialize an object into a string. - * @param endpoint Server parameter. + * @param endpoint Service host. */ public NotDefinedClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, String endpoint) { this.httpPipeline = httpPipeline; @@ -128,8 +127,8 @@ public interface NotDefinedClientService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> valid(@HostParam("endpoint") String endpoint, @HeaderParam("accept") String accept, - RequestOptions requestOptions, Context context); + Mono> valid(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, + Context context); @Head("/server/endpoint/not-defined/valid") @ExpectedResponses({ 200 }) @@ -137,8 +136,8 @@ Mono> valid(@HostParam("endpoint") String endpoint, @HeaderParam( @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response validSync(@HostParam("endpoint") String endpoint, @HeaderParam("accept") String accept, - RequestOptions requestOptions, Context context); + Response validSync(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, + Context context); } /** @@ -153,8 +152,7 @@ Response validSync(@HostParam("endpoint") String endpoint, @HeaderParam("a */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> validWithResponseAsync(RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.valid(this.getEndpoint(), accept, requestOptions, context)); + return FluxUtil.withContext(context -> service.valid(this.getEndpoint(), requestOptions, context)); } /** @@ -169,7 +167,6 @@ public Mono> validWithResponseAsync(RequestOptions requestOptions */ @ServiceMethod(returns = ReturnType.SINGLE) public Response validWithResponse(RequestOptions requestOptions) { - final String accept = "application/json"; - return service.validSync(this.getEndpoint(), accept, requestOptions, Context.NONE); + return service.validSync(this.getEndpoint(), requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/server/path/multiple/implementation/MultipleClientImpl.java b/typespec-tests/src/main/java/com/server/path/multiple/implementation/MultipleClientImpl.java index 93144cb321..629ed9a325 100644 --- a/typespec-tests/src/main/java/com/server/path/multiple/implementation/MultipleClientImpl.java +++ b/typespec-tests/src/main/java/com/server/path/multiple/implementation/MultipleClientImpl.java @@ -6,7 +6,6 @@ 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; @@ -149,8 +148,7 @@ public interface MultipleClientService { @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Mono> noOperationParams(@HostParam("endpoint") String endpoint, - @HostParam("apiVersion") String apiVersion, @HeaderParam("accept") String accept, - RequestOptions requestOptions, Context context); + @HostParam("apiVersion") String apiVersion, RequestOptions requestOptions, Context context); @Get("/") @ExpectedResponses({ 204 }) @@ -159,8 +157,7 @@ Mono> noOperationParams(@HostParam("endpoint") String endpoint, @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Response noOperationParamsSync(@HostParam("endpoint") String endpoint, - @HostParam("apiVersion") String apiVersion, @HeaderParam("accept") String accept, - RequestOptions requestOptions, Context context); + @HostParam("apiVersion") String apiVersion, RequestOptions requestOptions, Context context); @Get("/{keyword}") @ExpectedResponses({ 204 }) @@ -170,7 +167,7 @@ Response noOperationParamsSync(@HostParam("endpoint") String endpoint, @UnexpectedResponseExceptionType(HttpResponseException.class) Mono> withOperationPathParam(@HostParam("endpoint") String endpoint, @HostParam("apiVersion") String apiVersion, @PathParam("keyword") String keyword, - @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + RequestOptions requestOptions, Context context); @Get("/{keyword}") @ExpectedResponses({ 204 }) @@ -180,7 +177,7 @@ Mono> withOperationPathParam(@HostParam("endpoint") String endpoi @UnexpectedResponseExceptionType(HttpResponseException.class) Response withOperationPathParamSync(@HostParam("endpoint") String endpoint, @HostParam("apiVersion") String apiVersion, @PathParam("keyword") String keyword, - @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + RequestOptions requestOptions, Context context); } /** @@ -195,9 +192,8 @@ Response withOperationPathParamSync(@HostParam("endpoint") String endpoint */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> noOperationParamsWithResponseAsync(RequestOptions requestOptions) { - final String accept = "application/json"; return FluxUtil.withContext(context -> service.noOperationParams(this.getEndpoint(), - this.getServiceVersion().getVersion(), accept, requestOptions, context)); + this.getServiceVersion().getVersion(), requestOptions, context)); } /** @@ -212,9 +208,8 @@ public Mono> noOperationParamsWithResponseAsync(RequestOptions re */ @ServiceMethod(returns = ReturnType.SINGLE) public Response noOperationParamsWithResponse(RequestOptions requestOptions) { - final String accept = "application/json"; - return service.noOperationParamsSync(this.getEndpoint(), this.getServiceVersion().getVersion(), accept, - requestOptions, Context.NONE); + return service.noOperationParamsSync(this.getEndpoint(), this.getServiceVersion().getVersion(), requestOptions, + Context.NONE); } /** @@ -230,9 +225,8 @@ public Response noOperationParamsWithResponse(RequestOptions requestOption */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> withOperationPathParamWithResponseAsync(String keyword, RequestOptions requestOptions) { - final String accept = "application/json"; return FluxUtil.withContext(context -> service.withOperationPathParam(this.getEndpoint(), - this.getServiceVersion().getVersion(), keyword, accept, requestOptions, context)); + this.getServiceVersion().getVersion(), keyword, requestOptions, context)); } /** @@ -248,8 +242,7 @@ public Mono> withOperationPathParamWithResponseAsync(String keywo */ @ServiceMethod(returns = ReturnType.SINGLE) public Response withOperationPathParamWithResponse(String keyword, RequestOptions requestOptions) { - final String accept = "application/json"; return service.withOperationPathParamSync(this.getEndpoint(), this.getServiceVersion().getVersion(), keyword, - accept, requestOptions, Context.NONE); + requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/server/path/single/implementation/SingleClientImpl.java b/typespec-tests/src/main/java/com/server/path/single/implementation/SingleClientImpl.java index bfd0a77abe..59c6962adc 100644 --- a/typespec-tests/src/main/java/com/server/path/single/implementation/SingleClientImpl.java +++ b/typespec-tests/src/main/java/com/server/path/single/implementation/SingleClientImpl.java @@ -6,7 +6,6 @@ import com.azure.core.annotation.ExpectedResponses; 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.ReturnType; @@ -127,8 +126,8 @@ public interface SingleClientService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> myOp(@HostParam("endpoint") String endpoint, @HeaderParam("accept") String accept, - RequestOptions requestOptions, Context context); + Mono> myOp(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, + Context context); @Head("/server/path/single/myOp") @ExpectedResponses({ 200 }) @@ -136,8 +135,7 @@ Mono> myOp(@HostParam("endpoint") String endpoint, @HeaderParam(" @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response myOpSync(@HostParam("endpoint") String endpoint, @HeaderParam("accept") String accept, - RequestOptions requestOptions, Context context); + Response myOpSync(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, Context context); } /** @@ -152,8 +150,7 @@ Response myOpSync(@HostParam("endpoint") String endpoint, @HeaderParam("ac */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> myOpWithResponseAsync(RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.myOp(this.getEndpoint(), accept, requestOptions, context)); + return FluxUtil.withContext(context -> service.myOp(this.getEndpoint(), requestOptions, context)); } /** @@ -168,7 +165,6 @@ public Mono> myOpWithResponseAsync(RequestOptions requestOptions) */ @ServiceMethod(returns = ReturnType.SINGLE) public Response myOpWithResponse(RequestOptions requestOptions) { - final String accept = "application/json"; - return service.myOpSync(this.getEndpoint(), accept, requestOptions, Context.NONE); + return service.myOpSync(this.getEndpoint(), requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/server/versions/notversioned/implementation/NotVersionedClientImpl.java b/typespec-tests/src/main/java/com/server/versions/notversioned/implementation/NotVersionedClientImpl.java index 25d41d2449..eff9b16d95 100644 --- a/typespec-tests/src/main/java/com/server/versions/notversioned/implementation/NotVersionedClientImpl.java +++ b/typespec-tests/src/main/java/com/server/versions/notversioned/implementation/NotVersionedClientImpl.java @@ -6,7 +6,6 @@ import com.azure.core.annotation.ExpectedResponses; 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; @@ -131,8 +130,8 @@ public interface NotVersionedClientService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> withoutApiVersion(@HostParam("endpoint") String endpoint, - @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + Mono> withoutApiVersion(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, + Context context); @Head("/server/versions/not-versioned/without-api-version") @ExpectedResponses({ 200 }) @@ -140,8 +139,8 @@ Mono> withoutApiVersion(@HostParam("endpoint") String endpoint, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response withoutApiVersionSync(@HostParam("endpoint") String endpoint, - @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + Response withoutApiVersionSync(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, + Context context); @Head("/server/versions/not-versioned/with-query-api-version") @ExpectedResponses({ 200 }) @@ -150,8 +149,7 @@ Response withoutApiVersionSync(@HostParam("endpoint") String endpoint, @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Mono> withQueryApiVersion(@HostParam("endpoint") String endpoint, - @QueryParam("api-version") String apiVersion, @HeaderParam("accept") String accept, - RequestOptions requestOptions, Context context); + @QueryParam("api-version") String apiVersion, RequestOptions requestOptions, Context context); @Head("/server/versions/not-versioned/with-query-api-version") @ExpectedResponses({ 200 }) @@ -160,8 +158,7 @@ Mono> withQueryApiVersion(@HostParam("endpoint") String endpoint, @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Response withQueryApiVersionSync(@HostParam("endpoint") String endpoint, - @QueryParam("api-version") String apiVersion, @HeaderParam("accept") String accept, - RequestOptions requestOptions, Context context); + @QueryParam("api-version") String apiVersion, RequestOptions requestOptions, Context context); @Head("/server/versions/not-versioned/with-path-api-version/{apiVersion}") @ExpectedResponses({ 200 }) @@ -170,8 +167,7 @@ Response withQueryApiVersionSync(@HostParam("endpoint") String endpoint, @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Mono> withPathApiVersion(@HostParam("endpoint") String endpoint, - @PathParam("apiVersion") String apiVersion, @HeaderParam("accept") String accept, - RequestOptions requestOptions, Context context); + @PathParam("apiVersion") String apiVersion, RequestOptions requestOptions, Context context); @Head("/server/versions/not-versioned/with-path-api-version/{apiVersion}") @ExpectedResponses({ 200 }) @@ -180,8 +176,7 @@ Mono> withPathApiVersion(@HostParam("endpoint") String endpoint, @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Response withPathApiVersionSync(@HostParam("endpoint") String endpoint, - @PathParam("apiVersion") String apiVersion, @HeaderParam("accept") String accept, - RequestOptions requestOptions, Context context); + @PathParam("apiVersion") String apiVersion, RequestOptions requestOptions, Context context); } /** @@ -196,9 +191,7 @@ Response withPathApiVersionSync(@HostParam("endpoint") String endpoint, */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> withoutApiVersionWithResponseAsync(RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil - .withContext(context -> service.withoutApiVersion(this.getEndpoint(), accept, requestOptions, context)); + return FluxUtil.withContext(context -> service.withoutApiVersion(this.getEndpoint(), requestOptions, context)); } /** @@ -213,8 +206,7 @@ public Mono> withoutApiVersionWithResponseAsync(RequestOptions re */ @ServiceMethod(returns = ReturnType.SINGLE) public Response withoutApiVersionWithResponse(RequestOptions requestOptions) { - final String accept = "application/json"; - return service.withoutApiVersionSync(this.getEndpoint(), accept, requestOptions, Context.NONE); + return service.withoutApiVersionSync(this.getEndpoint(), requestOptions, Context.NONE); } /** @@ -230,9 +222,8 @@ public Response withoutApiVersionWithResponse(RequestOptions requestOption */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> withQueryApiVersionWithResponseAsync(String apiVersion, RequestOptions requestOptions) { - final String accept = "application/json"; return FluxUtil.withContext( - context -> service.withQueryApiVersion(this.getEndpoint(), apiVersion, accept, requestOptions, context)); + context -> service.withQueryApiVersion(this.getEndpoint(), apiVersion, requestOptions, context)); } /** @@ -248,8 +239,7 @@ public Mono> withQueryApiVersionWithResponseAsync(String apiVersi */ @ServiceMethod(returns = ReturnType.SINGLE) public Response withQueryApiVersionWithResponse(String apiVersion, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.withQueryApiVersionSync(this.getEndpoint(), apiVersion, accept, requestOptions, Context.NONE); + return service.withQueryApiVersionSync(this.getEndpoint(), apiVersion, requestOptions, Context.NONE); } /** @@ -265,9 +255,8 @@ public Response withQueryApiVersionWithResponse(String apiVersion, Request */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> withPathApiVersionWithResponseAsync(String apiVersion, RequestOptions requestOptions) { - final String accept = "application/json"; return FluxUtil.withContext( - context -> service.withPathApiVersion(this.getEndpoint(), apiVersion, accept, requestOptions, context)); + context -> service.withPathApiVersion(this.getEndpoint(), apiVersion, requestOptions, context)); } /** @@ -283,7 +272,6 @@ public Mono> withPathApiVersionWithResponseAsync(String apiVersio */ @ServiceMethod(returns = ReturnType.SINGLE) public Response withPathApiVersionWithResponse(String apiVersion, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.withPathApiVersionSync(this.getEndpoint(), apiVersion, accept, requestOptions, Context.NONE); + return service.withPathApiVersionSync(this.getEndpoint(), apiVersion, requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/server/versions/versioned/implementation/VersionedClientImpl.java b/typespec-tests/src/main/java/com/server/versions/versioned/implementation/VersionedClientImpl.java index fae0a0f208..70b6ff082e 100644 --- a/typespec-tests/src/main/java/com/server/versions/versioned/implementation/VersionedClientImpl.java +++ b/typespec-tests/src/main/java/com/server/versions/versioned/implementation/VersionedClientImpl.java @@ -6,7 +6,6 @@ import com.azure.core.annotation.ExpectedResponses; 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; @@ -150,8 +149,8 @@ public interface VersionedClientService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> withoutApiVersion(@HostParam("endpoint") String endpoint, - @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + Mono> withoutApiVersion(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, + Context context); @Head("/server/versions/versioned/without-api-version") @ExpectedResponses({ 200 }) @@ -159,8 +158,8 @@ Mono> withoutApiVersion(@HostParam("endpoint") String endpoint, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response withoutApiVersionSync(@HostParam("endpoint") String endpoint, - @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + Response withoutApiVersionSync(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, + Context context); @Head("/server/versions/versioned/with-query-api-version") @ExpectedResponses({ 200 }) @@ -169,8 +168,7 @@ Response withoutApiVersionSync(@HostParam("endpoint") String endpoint, @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Mono> withQueryApiVersion(@HostParam("endpoint") String endpoint, - @QueryParam("api-version") String apiVersion, @HeaderParam("accept") String accept, - RequestOptions requestOptions, Context context); + @QueryParam("api-version") String apiVersion, RequestOptions requestOptions, Context context); @Head("/server/versions/versioned/with-query-api-version") @ExpectedResponses({ 200 }) @@ -179,8 +177,7 @@ Mono> withQueryApiVersion(@HostParam("endpoint") String endpoint, @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Response withQueryApiVersionSync(@HostParam("endpoint") String endpoint, - @QueryParam("api-version") String apiVersion, @HeaderParam("accept") String accept, - RequestOptions requestOptions, Context context); + @QueryParam("api-version") String apiVersion, RequestOptions requestOptions, Context context); @Head("/server/versions/versioned/with-path-api-version/{apiVersion}") @ExpectedResponses({ 200 }) @@ -189,8 +186,7 @@ Response withQueryApiVersionSync(@HostParam("endpoint") String endpoint, @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Mono> withPathApiVersion(@HostParam("endpoint") String endpoint, - @PathParam("apiVersion") String apiVersion, @HeaderParam("accept") String accept, - RequestOptions requestOptions, Context context); + @PathParam("apiVersion") String apiVersion, RequestOptions requestOptions, Context context); @Head("/server/versions/versioned/with-path-api-version/{apiVersion}") @ExpectedResponses({ 200 }) @@ -199,8 +195,7 @@ Mono> withPathApiVersion(@HostParam("endpoint") String endpoint, @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Response withPathApiVersionSync(@HostParam("endpoint") String endpoint, - @PathParam("apiVersion") String apiVersion, @HeaderParam("accept") String accept, - RequestOptions requestOptions, Context context); + @PathParam("apiVersion") String apiVersion, RequestOptions requestOptions, Context context); @Head("/server/versions/versioned/with-query-old-api-version") @ExpectedResponses({ 200 }) @@ -209,8 +204,7 @@ Response withPathApiVersionSync(@HostParam("endpoint") String endpoint, @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Mono> withQueryOldApiVersion(@HostParam("endpoint") String endpoint, - @QueryParam("api-version") String apiVersion, @HeaderParam("accept") String accept, - RequestOptions requestOptions, Context context); + @QueryParam("api-version") String apiVersion, RequestOptions requestOptions, Context context); @Head("/server/versions/versioned/with-query-old-api-version") @ExpectedResponses({ 200 }) @@ -219,8 +213,7 @@ Mono> withQueryOldApiVersion(@HostParam("endpoint") String endpoi @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Response withQueryOldApiVersionSync(@HostParam("endpoint") String endpoint, - @QueryParam("api-version") String apiVersion, @HeaderParam("accept") String accept, - RequestOptions requestOptions, Context context); + @QueryParam("api-version") String apiVersion, RequestOptions requestOptions, Context context); } /** @@ -235,9 +228,7 @@ Response withQueryOldApiVersionSync(@HostParam("endpoint") String endpoint */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> withoutApiVersionWithResponseAsync(RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil - .withContext(context -> service.withoutApiVersion(this.getEndpoint(), accept, requestOptions, context)); + return FluxUtil.withContext(context -> service.withoutApiVersion(this.getEndpoint(), requestOptions, context)); } /** @@ -252,8 +243,7 @@ public Mono> withoutApiVersionWithResponseAsync(RequestOptions re */ @ServiceMethod(returns = ReturnType.SINGLE) public Response withoutApiVersionWithResponse(RequestOptions requestOptions) { - final String accept = "application/json"; - return service.withoutApiVersionSync(this.getEndpoint(), accept, requestOptions, Context.NONE); + return service.withoutApiVersionSync(this.getEndpoint(), requestOptions, Context.NONE); } /** @@ -268,9 +258,8 @@ public Response withoutApiVersionWithResponse(RequestOptions requestOption */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> withQueryApiVersionWithResponseAsync(RequestOptions requestOptions) { - final String accept = "application/json"; return FluxUtil.withContext(context -> service.withQueryApiVersion(this.getEndpoint(), - this.getServiceVersion().getVersion(), accept, requestOptions, context)); + this.getServiceVersion().getVersion(), requestOptions, context)); } /** @@ -285,8 +274,7 @@ public Mono> withQueryApiVersionWithResponseAsync(RequestOptions */ @ServiceMethod(returns = ReturnType.SINGLE) public Response withQueryApiVersionWithResponse(RequestOptions requestOptions) { - final String accept = "application/json"; - return service.withQueryApiVersionSync(this.getEndpoint(), this.getServiceVersion().getVersion(), accept, + return service.withQueryApiVersionSync(this.getEndpoint(), this.getServiceVersion().getVersion(), requestOptions, Context.NONE); } @@ -302,9 +290,8 @@ public Response withQueryApiVersionWithResponse(RequestOptions requestOpti */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> withPathApiVersionWithResponseAsync(RequestOptions requestOptions) { - final String accept = "application/json"; return FluxUtil.withContext(context -> service.withPathApiVersion(this.getEndpoint(), - this.getServiceVersion().getVersion(), accept, requestOptions, context)); + this.getServiceVersion().getVersion(), requestOptions, context)); } /** @@ -319,9 +306,8 @@ public Mono> withPathApiVersionWithResponseAsync(RequestOptions r */ @ServiceMethod(returns = ReturnType.SINGLE) public Response withPathApiVersionWithResponse(RequestOptions requestOptions) { - final String accept = "application/json"; - return service.withPathApiVersionSync(this.getEndpoint(), this.getServiceVersion().getVersion(), accept, - requestOptions, Context.NONE); + return service.withPathApiVersionSync(this.getEndpoint(), this.getServiceVersion().getVersion(), requestOptions, + Context.NONE); } /** @@ -336,9 +322,8 @@ public Response withPathApiVersionWithResponse(RequestOptions requestOptio */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> withQueryOldApiVersionWithResponseAsync(RequestOptions requestOptions) { - final String accept = "application/json"; return FluxUtil.withContext(context -> service.withQueryOldApiVersion(this.getEndpoint(), - this.getServiceVersion().getVersion(), accept, requestOptions, context)); + this.getServiceVersion().getVersion(), requestOptions, context)); } /** @@ -353,8 +338,7 @@ public Mono> withQueryOldApiVersionWithResponseAsync(RequestOptio */ @ServiceMethod(returns = ReturnType.SINGLE) public Response withQueryOldApiVersionWithResponse(RequestOptions requestOptions) { - final String accept = "application/json"; - return service.withQueryOldApiVersionSync(this.getEndpoint(), this.getServiceVersion().getVersion(), accept, + return service.withQueryOldApiVersionSync(this.getEndpoint(), this.getServiceVersion().getVersion(), requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/specialheaders/conditionalrequest/ConditionalRequestClientBuilder.java b/typespec-tests/src/main/java/com/specialheaders/conditionalrequest/ConditionalRequestClientBuilder.java index 42b0b31550..422aefcef4 100644 --- a/typespec-tests/src/main/java/com/specialheaders/conditionalrequest/ConditionalRequestClientBuilder.java +++ b/typespec-tests/src/main/java/com/specialheaders/conditionalrequest/ConditionalRequestClientBuilder.java @@ -7,6 +7,7 @@ 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; @@ -40,8 +41,8 @@ * A builder for creating a new instance of the ConditionalRequestClient type. */ @ServiceClientBuilder(serviceClients = { ConditionalRequestClient.class, ConditionalRequestAsyncClient.class }) -public final class ConditionalRequestClientBuilder - implements HttpTrait, ConfigurationTrait { +public final class ConditionalRequestClientBuilder implements HttpTrait, + ConfigurationTrait, EndpointTrait { @Generated private static final String SDK_NAME = "name"; @@ -173,6 +174,22 @@ public ConditionalRequestClientBuilder configuration(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. */ @@ -200,8 +217,9 @@ public ConditionalRequestClientBuilder retryPolicy(RetryPolicy retryPolicy) { private ConditionalRequestClientImpl buildInnerClient() { this.validateClient(); HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); - ConditionalRequestClientImpl client - = new ConditionalRequestClientImpl(localPipeline, JacksonAdapter.createDefaultSerializerAdapter()); + String localEndpoint = (endpoint != null) ? endpoint : "http://localhost:3000"; + ConditionalRequestClientImpl client = new ConditionalRequestClientImpl(localPipeline, + JacksonAdapter.createDefaultSerializerAdapter(), localEndpoint); return client; } diff --git a/typespec-tests/src/main/java/com/specialheaders/conditionalrequest/implementation/ConditionalRequestClientImpl.java b/typespec-tests/src/main/java/com/specialheaders/conditionalrequest/implementation/ConditionalRequestClientImpl.java index b5b4d489a0..a5d41b886c 100644 --- a/typespec-tests/src/main/java/com/specialheaders/conditionalrequest/implementation/ConditionalRequestClientImpl.java +++ b/typespec-tests/src/main/java/com/specialheaders/conditionalrequest/implementation/ConditionalRequestClientImpl.java @@ -5,8 +5,8 @@ package com.specialheaders.conditionalrequest.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.Post; import com.azure.core.annotation.ReturnType; import com.azure.core.annotation.ServiceInterface; @@ -38,6 +38,20 @@ public final class ConditionalRequestClientImpl { */ 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. */ @@ -68,19 +82,22 @@ public SerializerAdapter getSerializerAdapter() { /** * Initializes an instance of ConditionalRequestClient client. + * + * @param endpoint Service host. */ - public ConditionalRequestClientImpl() { + public ConditionalRequestClientImpl(String endpoint) { this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), - JacksonAdapter.createDefaultSerializerAdapter()); + 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) { - this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter()); + public ConditionalRequestClientImpl(HttpPipeline httpPipeline, String endpoint) { + this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint); } /** @@ -88,10 +105,13 @@ public ConditionalRequestClientImpl(HttpPipeline httpPipeline) { * * @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) { + 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()); } @@ -100,7 +120,7 @@ public ConditionalRequestClientImpl(HttpPipeline httpPipeline, SerializerAdapter * The interface defining all the services for ConditionalRequestClient to be used by the proxy service to perform * REST calls. */ - @Host("http://localhost:3000") + @Host("{endpoint}") @ServiceInterface(name = "ConditionalRequestCl") public interface ConditionalRequestClientService { @Post("/special-headers/conditional-request/if-match") @@ -109,7 +129,7 @@ public interface ConditionalRequestClientService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> postIfMatch(@HeaderParam("accept") String accept, RequestOptions requestOptions, + Mono> postIfMatch(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, Context context); @Post("/special-headers/conditional-request/if-match") @@ -118,7 +138,7 @@ Mono> postIfMatch(@HeaderParam("accept") String accept, RequestOp @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response postIfMatchSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, + Response postIfMatchSync(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, Context context); @Post("/special-headers/conditional-request/if-none-match") @@ -127,7 +147,7 @@ Response postIfMatchSync(@HeaderParam("accept") String accept, RequestOpti @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> postIfNoneMatch(@HeaderParam("accept") String accept, RequestOptions requestOptions, + Mono> postIfNoneMatch(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, Context context); @Post("/special-headers/conditional-request/if-none-match") @@ -136,7 +156,7 @@ Mono> postIfNoneMatch(@HeaderParam("accept") String accept, Reque @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response postIfNoneMatchSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, + Response postIfNoneMatchSync(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, Context context); } @@ -160,8 +180,7 @@ Response postIfNoneMatchSync(@HeaderParam("accept") String accept, Request */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> postIfMatchWithResponseAsync(RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.postIfMatch(accept, requestOptions, context)); + return FluxUtil.withContext(context -> service.postIfMatch(this.getEndpoint(), requestOptions, context)); } /** @@ -184,8 +203,7 @@ public Mono> postIfMatchWithResponseAsync(RequestOptions requestO */ @ServiceMethod(returns = ReturnType.SINGLE) public Response postIfMatchWithResponse(RequestOptions requestOptions) { - final String accept = "application/json"; - return service.postIfMatchSync(accept, requestOptions, Context.NONE); + return service.postIfMatchSync(this.getEndpoint(), requestOptions, Context.NONE); } /** @@ -208,8 +226,7 @@ public Response postIfMatchWithResponse(RequestOptions requestOptions) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> postIfNoneMatchWithResponseAsync(RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.postIfNoneMatch(accept, requestOptions, context)); + return FluxUtil.withContext(context -> service.postIfNoneMatch(this.getEndpoint(), requestOptions, context)); } /** @@ -232,7 +249,6 @@ public Mono> postIfNoneMatchWithResponseAsync(RequestOptions requ */ @ServiceMethod(returns = ReturnType.SINGLE) public Response postIfNoneMatchWithResponse(RequestOptions requestOptions) { - final String accept = "application/json"; - return service.postIfNoneMatchSync(accept, requestOptions, Context.NONE); + return service.postIfNoneMatchSync(this.getEndpoint(), requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/specialheaders/repeatability/RepeatabilityClientBuilder.java b/typespec-tests/src/main/java/com/specialheaders/repeatability/RepeatabilityClientBuilder.java index 627ad0c303..8502679f2f 100644 --- a/typespec-tests/src/main/java/com/specialheaders/repeatability/RepeatabilityClientBuilder.java +++ b/typespec-tests/src/main/java/com/specialheaders/repeatability/RepeatabilityClientBuilder.java @@ -7,6 +7,7 @@ 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; @@ -40,8 +41,8 @@ * A builder for creating a new instance of the RepeatabilityClient type. */ @ServiceClientBuilder(serviceClients = { RepeatabilityClient.class, RepeatabilityAsyncClient.class }) -public final class RepeatabilityClientBuilder - implements HttpTrait, ConfigurationTrait { +public final class RepeatabilityClientBuilder implements HttpTrait, + ConfigurationTrait, EndpointTrait { @Generated private static final String SDK_NAME = "name"; @@ -173,6 +174,22 @@ public RepeatabilityClientBuilder configuration(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. */ @@ -200,8 +217,9 @@ public RepeatabilityClientBuilder retryPolicy(RetryPolicy retryPolicy) { private RepeatabilityClientImpl buildInnerClient() { this.validateClient(); HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); - RepeatabilityClientImpl client - = new RepeatabilityClientImpl(localPipeline, JacksonAdapter.createDefaultSerializerAdapter()); + String localEndpoint = (endpoint != null) ? endpoint : "http://localhost:3000"; + RepeatabilityClientImpl client = new RepeatabilityClientImpl(localPipeline, + JacksonAdapter.createDefaultSerializerAdapter(), localEndpoint); return client; } diff --git a/typespec-tests/src/main/java/com/specialheaders/repeatability/implementation/RepeatabilityClientImpl.java b/typespec-tests/src/main/java/com/specialheaders/repeatability/implementation/RepeatabilityClientImpl.java index 2fac45b8ce..d9263b183b 100644 --- a/typespec-tests/src/main/java/com/specialheaders/repeatability/implementation/RepeatabilityClientImpl.java +++ b/typespec-tests/src/main/java/com/specialheaders/repeatability/implementation/RepeatabilityClientImpl.java @@ -5,8 +5,8 @@ package com.specialheaders.repeatability.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.Post; import com.azure.core.annotation.ReturnType; import com.azure.core.annotation.ServiceInterface; @@ -42,6 +42,20 @@ public final class RepeatabilityClientImpl { */ 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. */ @@ -72,19 +86,22 @@ public SerializerAdapter getSerializerAdapter() { /** * Initializes an instance of RepeatabilityClient client. + * + * @param endpoint Service host. */ - public RepeatabilityClientImpl() { + public RepeatabilityClientImpl(String endpoint) { this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), - JacksonAdapter.createDefaultSerializerAdapter()); + 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) { - this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter()); + public RepeatabilityClientImpl(HttpPipeline httpPipeline, String endpoint) { + this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint); } /** @@ -92,10 +109,12 @@ public RepeatabilityClientImpl(HttpPipeline httpPipeline) { * * @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) { + 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()); } @@ -104,7 +123,7 @@ public RepeatabilityClientImpl(HttpPipeline httpPipeline, SerializerAdapter seri * The interface defining all the services for RepeatabilityClient to be used by the proxy service to perform REST * calls. */ - @Host("http://localhost:3000") + @Host("{endpoint}") @ServiceInterface(name = "RepeatabilityClient") public interface RepeatabilityClientService { @Post("/special-headers/repeatability/immediateSuccess") @@ -113,7 +132,7 @@ public interface RepeatabilityClientService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> immediateSuccess(@HeaderParam("accept") String accept, RequestOptions requestOptions, + Mono> immediateSuccess(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, Context context); @Post("/special-headers/repeatability/immediateSuccess") @@ -122,7 +141,7 @@ Mono> immediateSuccess(@HeaderParam("accept") String accept, Requ @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response immediateSuccessSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, + Response immediateSuccessSync(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, Context context); } @@ -147,7 +166,6 @@ Response immediateSuccessSync(@HeaderParam("accept") String accept, Reques */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> immediateSuccessWithResponseAsync(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) { @@ -162,7 +180,8 @@ public Mono> immediateSuccessWithResponseAsync(RequestOptions req DateTimeRfc1123.toRfc1123String(OffsetDateTime.now())); } }); - return FluxUtil.withContext(context -> service.immediateSuccess(accept, requestOptionsLocal, context)); + return FluxUtil + .withContext(context -> service.immediateSuccess(this.getEndpoint(), requestOptionsLocal, context)); } /** @@ -186,7 +205,6 @@ public Mono> immediateSuccessWithResponseAsync(RequestOptions req */ @ServiceMethod(returns = ReturnType.SINGLE) public Response immediateSuccessWithResponse(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) { @@ -201,6 +219,6 @@ public Response immediateSuccessWithResponse(RequestOptions requestOptions DateTimeRfc1123.toRfc1123String(OffsetDateTime.now())); } }); - return service.immediateSuccessSync(accept, requestOptionsLocal, Context.NONE); + return service.immediateSuccessSync(this.getEndpoint(), requestOptionsLocal, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/specialwords/SpecialWordsClientBuilder.java b/typespec-tests/src/main/java/com/specialwords/SpecialWordsClientBuilder.java index 3b2ddaf7df..5dce7abed9 100644 --- a/typespec-tests/src/main/java/com/specialwords/SpecialWordsClientBuilder.java +++ b/typespec-tests/src/main/java/com/specialwords/SpecialWordsClientBuilder.java @@ -7,6 +7,7 @@ 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; @@ -49,8 +50,8 @@ ModelPropertiesAsyncClient.class, OperationsAsyncClient.class, ParametersAsyncClient.class }) -public final class SpecialWordsClientBuilder - implements HttpTrait, ConfigurationTrait { +public final class SpecialWordsClientBuilder implements HttpTrait, + ConfigurationTrait, EndpointTrait { @Generated private static final String SDK_NAME = "name"; @@ -181,6 +182,22 @@ public SpecialWordsClientBuilder configuration(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. */ @@ -208,8 +225,9 @@ public SpecialWordsClientBuilder retryPolicy(RetryPolicy retryPolicy) { 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()); + = new SpecialWordsClientImpl(localPipeline, JacksonAdapter.createDefaultSerializerAdapter(), localEndpoint); return client; } diff --git a/typespec-tests/src/main/java/com/specialwords/implementation/ModelPropertiesImpl.java b/typespec-tests/src/main/java/com/specialwords/implementation/ModelPropertiesImpl.java index db9360cc23..bdf0af0544 100644 --- a/typespec-tests/src/main/java/com/specialwords/implementation/ModelPropertiesImpl.java +++ b/typespec-tests/src/main/java/com/specialwords/implementation/ModelPropertiesImpl.java @@ -8,6 +8,7 @@ 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; @@ -54,7 +55,7 @@ public final class ModelPropertiesImpl { * The interface defining all the services for SpecialWordsClientModelProperties to be used by the proxy service to * perform REST calls. */ - @Host("http://localhost:3000") + @Host("{endpoint}") @ServiceInterface(name = "SpecialWordsClientMo") public interface ModelPropertiesService { @Post("/special-words/model-properties/same-as-model") @@ -63,8 +64,9 @@ public interface ModelPropertiesService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> sameAsModel(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + 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 }) @@ -72,8 +74,9 @@ Mono> sameAsModel(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response sameAsModelSync(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + Response sameAsModelSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); } /** @@ -96,8 +99,9 @@ Response sameAsModelSync(@HeaderParam("accept") String accept, */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> sameAsModelWithResponseAsync(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.sameAsModel(accept, body, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.sameAsModel(this.client.getEndpoint(), contentType, body, requestOptions, context)); } /** @@ -120,7 +124,7 @@ public Mono> sameAsModelWithResponseAsync(BinaryData body, Reques */ @ServiceMethod(returns = ReturnType.SINGLE) public Response sameAsModelWithResponse(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.sameAsModelSync(accept, body, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.sameAsModelSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/specialwords/implementation/ModelsImpl.java b/typespec-tests/src/main/java/com/specialwords/implementation/ModelsImpl.java index d4b6404abf..4b9e9e561d 100644 --- a/typespec-tests/src/main/java/com/specialwords/implementation/ModelsImpl.java +++ b/typespec-tests/src/main/java/com/specialwords/implementation/ModelsImpl.java @@ -8,6 +8,7 @@ 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; @@ -53,7 +54,7 @@ public final class ModelsImpl { * The interface defining all the services for SpecialWordsClientModels to be used by the proxy service to perform * REST calls. */ - @Host("http://localhost:3000") + @Host("{endpoint}") @ServiceInterface(name = "SpecialWordsClientMo") public interface ModelsService { @Post("/special-words/models/and") @@ -62,8 +63,9 @@ public interface ModelsService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> withAnd(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + 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 }) @@ -71,7 +73,8 @@ Mono> withAnd(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response withAndSync(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, + 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") @@ -80,8 +83,9 @@ Response withAndSync(@HeaderParam("accept") String accept, @BodyParam("app @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> withAs(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + 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 }) @@ -89,7 +93,8 @@ Mono> withAs(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response withAsSync(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, + 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") @@ -98,8 +103,9 @@ Response withAsSync(@HeaderParam("accept") String accept, @BodyParam("appl @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> withAssert(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + 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 }) @@ -107,8 +113,9 @@ Mono> withAssert(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response withAssertSync(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + 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 }) @@ -116,8 +123,9 @@ Response withAssertSync(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> withAsync(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + 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 }) @@ -125,8 +133,9 @@ Mono> withAsync(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response withAsyncSync(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + 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 }) @@ -134,8 +143,9 @@ Response withAsyncSync(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> withAwait(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + 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 }) @@ -143,8 +153,9 @@ Mono> withAwait(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response withAwaitSync(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + 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 }) @@ -152,8 +163,9 @@ Response withAwaitSync(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> withBreak(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + 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 }) @@ -161,8 +173,9 @@ Mono> withBreak(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response withBreakSync(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + 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 }) @@ -170,8 +183,9 @@ Response withBreakSync(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> withClass(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + 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 }) @@ -179,8 +193,9 @@ Mono> withClass(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response withClassSync(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + 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 }) @@ -188,8 +203,9 @@ Response withClassSync(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> withConstructor(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + 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 }) @@ -197,8 +213,9 @@ Mono> withConstructor(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response withConstructorSync(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + 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 }) @@ -206,8 +223,9 @@ Response withConstructorSync(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> withContinue(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + 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 }) @@ -215,8 +233,9 @@ Mono> withContinue(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response withContinueSync(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + 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 }) @@ -224,8 +243,9 @@ Response withContinueSync(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> withDef(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + 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 }) @@ -233,7 +253,8 @@ Mono> withDef(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response withDefSync(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, + 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") @@ -242,8 +263,9 @@ Response withDefSync(@HeaderParam("accept") String accept, @BodyParam("app @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> withDel(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + 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 }) @@ -251,7 +273,8 @@ Mono> withDel(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response withDelSync(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, + 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") @@ -260,8 +283,9 @@ Response withDelSync(@HeaderParam("accept") String accept, @BodyParam("app @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> withElif(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + 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 }) @@ -269,8 +293,9 @@ Mono> withElif(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response withElifSync(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + 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 }) @@ -278,8 +303,9 @@ Response withElifSync(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> withElse(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + 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 }) @@ -287,8 +313,9 @@ Mono> withElse(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response withElseSync(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + 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 }) @@ -296,8 +323,9 @@ Response withElseSync(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> withExcept(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + 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 }) @@ -305,8 +333,9 @@ Mono> withExcept(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response withExceptSync(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + 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 }) @@ -314,8 +343,9 @@ Response withExceptSync(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> withExec(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + 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 }) @@ -323,8 +353,9 @@ Mono> withExec(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response withExecSync(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + 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 }) @@ -332,8 +363,9 @@ Response withExecSync(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> withFinally(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + 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 }) @@ -341,8 +373,9 @@ Mono> withFinally(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response withFinallySync(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + 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 }) @@ -350,8 +383,9 @@ Response withFinallySync(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> withFor(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + 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 }) @@ -359,7 +393,8 @@ Mono> withFor(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response withForSync(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, + 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") @@ -368,8 +403,9 @@ Response withForSync(@HeaderParam("accept") String accept, @BodyParam("app @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> withFrom(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + 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 }) @@ -377,8 +413,9 @@ Mono> withFrom(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response withFromSync(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + 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 }) @@ -386,8 +423,9 @@ Response withFromSync(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> withGlobal(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + 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 }) @@ -395,8 +433,9 @@ Mono> withGlobal(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response withGlobalSync(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + 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 }) @@ -404,8 +443,9 @@ Response withGlobalSync(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> withIf(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + 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 }) @@ -413,7 +453,8 @@ Mono> withIf(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response withIfSync(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, + 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") @@ -422,8 +463,9 @@ Response withIfSync(@HeaderParam("accept") String accept, @BodyParam("appl @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> withImport(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + 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 }) @@ -431,8 +473,9 @@ Mono> withImport(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response withImportSync(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + 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 }) @@ -440,8 +483,9 @@ Response withImportSync(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> withIn(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + 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 }) @@ -449,7 +493,8 @@ Mono> withIn(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response withInSync(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, + 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") @@ -458,8 +503,9 @@ Response withInSync(@HeaderParam("accept") String accept, @BodyParam("appl @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> withIs(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + 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 }) @@ -467,7 +513,8 @@ Mono> withIs(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response withIsSync(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, + 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") @@ -476,8 +523,9 @@ Response withIsSync(@HeaderParam("accept") String accept, @BodyParam("appl @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> withLambda(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + 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 }) @@ -485,8 +533,9 @@ Mono> withLambda(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response withLambdaSync(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + 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 }) @@ -494,8 +543,9 @@ Response withLambdaSync(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> withNot(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + 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 }) @@ -503,7 +553,8 @@ Mono> withNot(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response withNotSync(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, + 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") @@ -512,8 +563,9 @@ Response withNotSync(@HeaderParam("accept") String accept, @BodyParam("app @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> withOr(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + 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 }) @@ -521,7 +573,8 @@ Mono> withOr(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response withOrSync(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, + 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") @@ -530,8 +583,9 @@ Response withOrSync(@HeaderParam("accept") String accept, @BodyParam("appl @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> withPass(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + 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 }) @@ -539,8 +593,9 @@ Mono> withPass(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response withPassSync(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + 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 }) @@ -548,8 +603,9 @@ Response withPassSync(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> withRaise(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + 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 }) @@ -557,8 +613,9 @@ Mono> withRaise(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response withRaiseSync(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + 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 }) @@ -566,8 +623,9 @@ Response withRaiseSync(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> withReturn(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + 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 }) @@ -575,8 +633,9 @@ Mono> withReturn(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response withReturnSync(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + 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 }) @@ -584,8 +643,9 @@ Response withReturnSync(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> withTry(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + 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 }) @@ -593,7 +653,8 @@ Mono> withTry(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response withTrySync(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, + 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") @@ -602,8 +663,9 @@ Response withTrySync(@HeaderParam("accept") String accept, @BodyParam("app @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> withWhile(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + 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 }) @@ -611,8 +673,9 @@ Mono> withWhile(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response withWhileSync(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + 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 }) @@ -620,8 +683,9 @@ Response withWhileSync(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> withWith(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + 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 }) @@ -629,8 +693,9 @@ Mono> withWith(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response withWithSync(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + 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 }) @@ -638,8 +703,9 @@ Response withWithSync(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> withYield(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + 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 }) @@ -647,8 +713,9 @@ Mono> withYield(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response withYieldSync(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + Response withYieldSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); } /** @@ -671,8 +738,9 @@ Response withYieldSync(@HeaderParam("accept") String accept, */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> withAndWithResponseAsync(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.withAnd(accept, body, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.withAnd(this.client.getEndpoint(), contentType, body, requestOptions, context)); } /** @@ -695,8 +763,8 @@ public Mono> withAndWithResponseAsync(BinaryData body, RequestOpt */ @ServiceMethod(returns = ReturnType.SINGLE) public Response withAndWithResponse(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.withAndSync(accept, body, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.withAndSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); } /** @@ -719,8 +787,9 @@ public Response withAndWithResponse(BinaryData body, RequestOptions reques */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> withAsWithResponseAsync(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.withAs(accept, body, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.withAs(this.client.getEndpoint(), contentType, body, requestOptions, context)); } /** @@ -743,8 +812,8 @@ public Mono> withAsWithResponseAsync(BinaryData body, RequestOpti */ @ServiceMethod(returns = ReturnType.SINGLE) public Response withAsWithResponse(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.withAsSync(accept, body, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.withAsSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); } /** @@ -767,8 +836,9 @@ public Response withAsWithResponse(BinaryData body, RequestOptions request */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> withAssertWithResponseAsync(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.withAssert(accept, body, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.withAssert(this.client.getEndpoint(), contentType, body, requestOptions, context)); } /** @@ -791,8 +861,8 @@ public Mono> withAssertWithResponseAsync(BinaryData body, Request */ @ServiceMethod(returns = ReturnType.SINGLE) public Response withAssertWithResponse(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.withAssertSync(accept, body, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.withAssertSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); } /** @@ -815,8 +885,9 @@ public Response withAssertWithResponse(BinaryData body, RequestOptions req */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> withAsyncWithResponseAsync(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.withAsync(accept, body, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.withAsync(this.client.getEndpoint(), contentType, body, requestOptions, context)); } /** @@ -839,8 +910,8 @@ public Mono> withAsyncWithResponseAsync(BinaryData body, RequestO */ @ServiceMethod(returns = ReturnType.SINGLE) public Response withAsyncWithResponse(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.withAsyncSync(accept, body, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.withAsyncSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); } /** @@ -863,8 +934,9 @@ public Response withAsyncWithResponse(BinaryData body, RequestOptions requ */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> withAwaitWithResponseAsync(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.withAwait(accept, body, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.withAwait(this.client.getEndpoint(), contentType, body, requestOptions, context)); } /** @@ -887,8 +959,8 @@ public Mono> withAwaitWithResponseAsync(BinaryData body, RequestO */ @ServiceMethod(returns = ReturnType.SINGLE) public Response withAwaitWithResponse(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.withAwaitSync(accept, body, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.withAwaitSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); } /** @@ -911,8 +983,9 @@ public Response withAwaitWithResponse(BinaryData body, RequestOptions requ */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> withBreakWithResponseAsync(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.withBreak(accept, body, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.withBreak(this.client.getEndpoint(), contentType, body, requestOptions, context)); } /** @@ -935,8 +1008,8 @@ public Mono> withBreakWithResponseAsync(BinaryData body, RequestO */ @ServiceMethod(returns = ReturnType.SINGLE) public Response withBreakWithResponse(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.withBreakSync(accept, body, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.withBreakSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); } /** @@ -959,8 +1032,9 @@ public Response withBreakWithResponse(BinaryData body, RequestOptions requ */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> withClassWithResponseAsync(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.withClass(accept, body, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.withClass(this.client.getEndpoint(), contentType, body, requestOptions, context)); } /** @@ -983,8 +1057,8 @@ public Mono> withClassWithResponseAsync(BinaryData body, RequestO */ @ServiceMethod(returns = ReturnType.SINGLE) public Response withClassWithResponse(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.withClassSync(accept, body, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.withClassSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); } /** @@ -1007,8 +1081,9 @@ public Response withClassWithResponse(BinaryData body, RequestOptions requ */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> withConstructorWithResponseAsync(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.withConstructor(accept, body, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.withConstructor(this.client.getEndpoint(), contentType, body, requestOptions, context)); } /** @@ -1031,8 +1106,8 @@ public Mono> withConstructorWithResponseAsync(BinaryData body, Re */ @ServiceMethod(returns = ReturnType.SINGLE) public Response withConstructorWithResponse(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.withConstructorSync(accept, body, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.withConstructorSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); } /** @@ -1055,8 +1130,9 @@ public Response withConstructorWithResponse(BinaryData body, RequestOption */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> withContinueWithResponseAsync(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.withContinue(accept, body, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.withContinue(this.client.getEndpoint(), contentType, body, requestOptions, context)); } /** @@ -1079,8 +1155,8 @@ public Mono> withContinueWithResponseAsync(BinaryData body, Reque */ @ServiceMethod(returns = ReturnType.SINGLE) public Response withContinueWithResponse(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.withContinueSync(accept, body, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.withContinueSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); } /** @@ -1103,8 +1179,9 @@ public Response withContinueWithResponse(BinaryData body, RequestOptions r */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> withDefWithResponseAsync(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.withDef(accept, body, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.withDef(this.client.getEndpoint(), contentType, body, requestOptions, context)); } /** @@ -1127,8 +1204,8 @@ public Mono> withDefWithResponseAsync(BinaryData body, RequestOpt */ @ServiceMethod(returns = ReturnType.SINGLE) public Response withDefWithResponse(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.withDefSync(accept, body, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.withDefSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); } /** @@ -1151,8 +1228,9 @@ public Response withDefWithResponse(BinaryData body, RequestOptions reques */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> withDelWithResponseAsync(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.withDel(accept, body, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.withDel(this.client.getEndpoint(), contentType, body, requestOptions, context)); } /** @@ -1175,8 +1253,8 @@ public Mono> withDelWithResponseAsync(BinaryData body, RequestOpt */ @ServiceMethod(returns = ReturnType.SINGLE) public Response withDelWithResponse(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.withDelSync(accept, body, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.withDelSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); } /** @@ -1199,8 +1277,9 @@ public Response withDelWithResponse(BinaryData body, RequestOptions reques */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> withElifWithResponseAsync(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.withElif(accept, body, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.withElif(this.client.getEndpoint(), contentType, body, requestOptions, context)); } /** @@ -1223,8 +1302,8 @@ public Mono> withElifWithResponseAsync(BinaryData body, RequestOp */ @ServiceMethod(returns = ReturnType.SINGLE) public Response withElifWithResponse(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.withElifSync(accept, body, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.withElifSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); } /** @@ -1247,8 +1326,9 @@ public Response withElifWithResponse(BinaryData body, RequestOptions reque */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> withElseWithResponseAsync(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.withElse(accept, body, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.withElse(this.client.getEndpoint(), contentType, body, requestOptions, context)); } /** @@ -1271,8 +1351,8 @@ public Mono> withElseWithResponseAsync(BinaryData body, RequestOp */ @ServiceMethod(returns = ReturnType.SINGLE) public Response withElseWithResponse(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.withElseSync(accept, body, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.withElseSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); } /** @@ -1295,8 +1375,9 @@ public Response withElseWithResponse(BinaryData body, RequestOptions reque */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> withExceptWithResponseAsync(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.withExcept(accept, body, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.withExcept(this.client.getEndpoint(), contentType, body, requestOptions, context)); } /** @@ -1319,8 +1400,8 @@ public Mono> withExceptWithResponseAsync(BinaryData body, Request */ @ServiceMethod(returns = ReturnType.SINGLE) public Response withExceptWithResponse(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.withExceptSync(accept, body, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.withExceptSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); } /** @@ -1343,8 +1424,9 @@ public Response withExceptWithResponse(BinaryData body, RequestOptions req */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> withExecWithResponseAsync(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.withExec(accept, body, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.withExec(this.client.getEndpoint(), contentType, body, requestOptions, context)); } /** @@ -1367,8 +1449,8 @@ public Mono> withExecWithResponseAsync(BinaryData body, RequestOp */ @ServiceMethod(returns = ReturnType.SINGLE) public Response withExecWithResponse(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.withExecSync(accept, body, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.withExecSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); } /** @@ -1391,8 +1473,9 @@ public Response withExecWithResponse(BinaryData body, RequestOptions reque */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> withFinallyWithResponseAsync(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.withFinally(accept, body, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.withFinally(this.client.getEndpoint(), contentType, body, requestOptions, context)); } /** @@ -1415,8 +1498,8 @@ public Mono> withFinallyWithResponseAsync(BinaryData body, Reques */ @ServiceMethod(returns = ReturnType.SINGLE) public Response withFinallyWithResponse(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.withFinallySync(accept, body, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.withFinallySync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); } /** @@ -1439,8 +1522,9 @@ public Response withFinallyWithResponse(BinaryData body, RequestOptions re */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> withForWithResponseAsync(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.withFor(accept, body, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.withFor(this.client.getEndpoint(), contentType, body, requestOptions, context)); } /** @@ -1463,8 +1547,8 @@ public Mono> withForWithResponseAsync(BinaryData body, RequestOpt */ @ServiceMethod(returns = ReturnType.SINGLE) public Response withForWithResponse(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.withForSync(accept, body, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.withForSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); } /** @@ -1487,8 +1571,9 @@ public Response withForWithResponse(BinaryData body, RequestOptions reques */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> withFromWithResponseAsync(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.withFrom(accept, body, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.withFrom(this.client.getEndpoint(), contentType, body, requestOptions, context)); } /** @@ -1511,8 +1596,8 @@ public Mono> withFromWithResponseAsync(BinaryData body, RequestOp */ @ServiceMethod(returns = ReturnType.SINGLE) public Response withFromWithResponse(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.withFromSync(accept, body, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.withFromSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); } /** @@ -1535,8 +1620,9 @@ public Response withFromWithResponse(BinaryData body, RequestOptions reque */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> withGlobalWithResponseAsync(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.withGlobal(accept, body, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.withGlobal(this.client.getEndpoint(), contentType, body, requestOptions, context)); } /** @@ -1559,8 +1645,8 @@ public Mono> withGlobalWithResponseAsync(BinaryData body, Request */ @ServiceMethod(returns = ReturnType.SINGLE) public Response withGlobalWithResponse(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.withGlobalSync(accept, body, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.withGlobalSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); } /** @@ -1583,8 +1669,9 @@ public Response withGlobalWithResponse(BinaryData body, RequestOptions req */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> withIfWithResponseAsync(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.withIf(accept, body, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.withIf(this.client.getEndpoint(), contentType, body, requestOptions, context)); } /** @@ -1607,8 +1694,8 @@ public Mono> withIfWithResponseAsync(BinaryData body, RequestOpti */ @ServiceMethod(returns = ReturnType.SINGLE) public Response withIfWithResponse(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.withIfSync(accept, body, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.withIfSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); } /** @@ -1631,8 +1718,9 @@ public Response withIfWithResponse(BinaryData body, RequestOptions request */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> withImportWithResponseAsync(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.withImport(accept, body, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.withImport(this.client.getEndpoint(), contentType, body, requestOptions, context)); } /** @@ -1655,8 +1743,8 @@ public Mono> withImportWithResponseAsync(BinaryData body, Request */ @ServiceMethod(returns = ReturnType.SINGLE) public Response withImportWithResponse(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.withImportSync(accept, body, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.withImportSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); } /** @@ -1679,8 +1767,9 @@ public Response withImportWithResponse(BinaryData body, RequestOptions req */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> withInWithResponseAsync(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.withIn(accept, body, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.withIn(this.client.getEndpoint(), contentType, body, requestOptions, context)); } /** @@ -1703,8 +1792,8 @@ public Mono> withInWithResponseAsync(BinaryData body, RequestOpti */ @ServiceMethod(returns = ReturnType.SINGLE) public Response withInWithResponse(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.withInSync(accept, body, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.withInSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); } /** @@ -1727,8 +1816,9 @@ public Response withInWithResponse(BinaryData body, RequestOptions request */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> withIsWithResponseAsync(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.withIs(accept, body, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.withIs(this.client.getEndpoint(), contentType, body, requestOptions, context)); } /** @@ -1751,8 +1841,8 @@ public Mono> withIsWithResponseAsync(BinaryData body, RequestOpti */ @ServiceMethod(returns = ReturnType.SINGLE) public Response withIsWithResponse(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.withIsSync(accept, body, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.withIsSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); } /** @@ -1775,8 +1865,9 @@ public Response withIsWithResponse(BinaryData body, RequestOptions request */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> withLambdaWithResponseAsync(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.withLambda(accept, body, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.withLambda(this.client.getEndpoint(), contentType, body, requestOptions, context)); } /** @@ -1799,8 +1890,8 @@ public Mono> withLambdaWithResponseAsync(BinaryData body, Request */ @ServiceMethod(returns = ReturnType.SINGLE) public Response withLambdaWithResponse(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.withLambdaSync(accept, body, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.withLambdaSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); } /** @@ -1823,8 +1914,9 @@ public Response withLambdaWithResponse(BinaryData body, RequestOptions req */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> withNotWithResponseAsync(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.withNot(accept, body, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.withNot(this.client.getEndpoint(), contentType, body, requestOptions, context)); } /** @@ -1847,8 +1939,8 @@ public Mono> withNotWithResponseAsync(BinaryData body, RequestOpt */ @ServiceMethod(returns = ReturnType.SINGLE) public Response withNotWithResponse(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.withNotSync(accept, body, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.withNotSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); } /** @@ -1871,8 +1963,9 @@ public Response withNotWithResponse(BinaryData body, RequestOptions reques */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> withOrWithResponseAsync(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.withOr(accept, body, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.withOr(this.client.getEndpoint(), contentType, body, requestOptions, context)); } /** @@ -1895,8 +1988,8 @@ public Mono> withOrWithResponseAsync(BinaryData body, RequestOpti */ @ServiceMethod(returns = ReturnType.SINGLE) public Response withOrWithResponse(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.withOrSync(accept, body, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.withOrSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); } /** @@ -1919,8 +2012,9 @@ public Response withOrWithResponse(BinaryData body, RequestOptions request */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> withPassWithResponseAsync(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.withPass(accept, body, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.withPass(this.client.getEndpoint(), contentType, body, requestOptions, context)); } /** @@ -1943,8 +2037,8 @@ public Mono> withPassWithResponseAsync(BinaryData body, RequestOp */ @ServiceMethod(returns = ReturnType.SINGLE) public Response withPassWithResponse(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.withPassSync(accept, body, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.withPassSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); } /** @@ -1967,8 +2061,9 @@ public Response withPassWithResponse(BinaryData body, RequestOptions reque */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> withRaiseWithResponseAsync(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.withRaise(accept, body, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.withRaise(this.client.getEndpoint(), contentType, body, requestOptions, context)); } /** @@ -1991,8 +2086,8 @@ public Mono> withRaiseWithResponseAsync(BinaryData body, RequestO */ @ServiceMethod(returns = ReturnType.SINGLE) public Response withRaiseWithResponse(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.withRaiseSync(accept, body, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.withRaiseSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); } /** @@ -2015,8 +2110,9 @@ public Response withRaiseWithResponse(BinaryData body, RequestOptions requ */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> withReturnWithResponseAsync(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.withReturn(accept, body, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.withReturn(this.client.getEndpoint(), contentType, body, requestOptions, context)); } /** @@ -2039,8 +2135,8 @@ public Mono> withReturnWithResponseAsync(BinaryData body, Request */ @ServiceMethod(returns = ReturnType.SINGLE) public Response withReturnWithResponse(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.withReturnSync(accept, body, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.withReturnSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); } /** @@ -2063,8 +2159,9 @@ public Response withReturnWithResponse(BinaryData body, RequestOptions req */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> withTryWithResponseAsync(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.withTry(accept, body, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.withTry(this.client.getEndpoint(), contentType, body, requestOptions, context)); } /** @@ -2087,8 +2184,8 @@ public Mono> withTryWithResponseAsync(BinaryData body, RequestOpt */ @ServiceMethod(returns = ReturnType.SINGLE) public Response withTryWithResponse(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.withTrySync(accept, body, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.withTrySync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); } /** @@ -2111,8 +2208,9 @@ public Response withTryWithResponse(BinaryData body, RequestOptions reques */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> withWhileWithResponseAsync(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.withWhile(accept, body, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.withWhile(this.client.getEndpoint(), contentType, body, requestOptions, context)); } /** @@ -2135,8 +2233,8 @@ public Mono> withWhileWithResponseAsync(BinaryData body, RequestO */ @ServiceMethod(returns = ReturnType.SINGLE) public Response withWhileWithResponse(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.withWhileSync(accept, body, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.withWhileSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); } /** @@ -2159,8 +2257,9 @@ public Response withWhileWithResponse(BinaryData body, RequestOptions requ */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> withWithWithResponseAsync(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.withWith(accept, body, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.withWith(this.client.getEndpoint(), contentType, body, requestOptions, context)); } /** @@ -2183,8 +2282,8 @@ public Mono> withWithWithResponseAsync(BinaryData body, RequestOp */ @ServiceMethod(returns = ReturnType.SINGLE) public Response withWithWithResponse(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.withWithSync(accept, body, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.withWithSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); } /** @@ -2207,8 +2306,9 @@ public Response withWithWithResponse(BinaryData body, RequestOptions reque */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> withYieldWithResponseAsync(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.withYield(accept, body, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.withYield(this.client.getEndpoint(), contentType, body, requestOptions, context)); } /** @@ -2231,7 +2331,7 @@ public Mono> withYieldWithResponseAsync(BinaryData body, RequestO */ @ServiceMethod(returns = ReturnType.SINGLE) public Response withYieldWithResponse(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.withYieldSync(accept, body, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.withYieldSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/specialwords/implementation/OperationsImpl.java b/typespec-tests/src/main/java/com/specialwords/implementation/OperationsImpl.java index cbd4595300..6ab0be29cc 100644 --- a/typespec-tests/src/main/java/com/specialwords/implementation/OperationsImpl.java +++ b/typespec-tests/src/main/java/com/specialwords/implementation/OperationsImpl.java @@ -6,8 +6,8 @@ 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; @@ -52,7 +52,7 @@ public final class OperationsImpl { * The interface defining all the services for SpecialWordsClientOperations to be used by the proxy service to * perform REST calls. */ - @Host("http://localhost:3000") + @Host("{endpoint}") @ServiceInterface(name = "SpecialWordsClientOp") public interface OperationsService { @Get("/special-words/operations/and") @@ -61,7 +61,8 @@ public interface OperationsService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> and(@HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + Mono> and(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, + Context context); @Get("/special-words/operations/and") @ExpectedResponses({ 204 }) @@ -69,7 +70,7 @@ public interface OperationsService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response andSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + Response andSync(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, Context context); @Get("/special-words/operations/as") @ExpectedResponses({ 204 }) @@ -77,7 +78,7 @@ public interface OperationsService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> as(@HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + Mono> as(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, Context context); @Get("/special-words/operations/as") @ExpectedResponses({ 204 }) @@ -85,7 +86,7 @@ public interface OperationsService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response asSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + Response asSync(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, Context context); @Get("/special-words/operations/assert") @ExpectedResponses({ 204 }) @@ -93,7 +94,7 @@ public interface OperationsService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> assertMethod(@HeaderParam("accept") String accept, RequestOptions requestOptions, + Mono> assertMethod(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, Context context); @Get("/special-words/operations/assert") @@ -102,7 +103,7 @@ Mono> assertMethod(@HeaderParam("accept") String accept, RequestO @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response assertMethodSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, + Response assertMethodSync(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, Context context); @Get("/special-words/operations/async") @@ -111,7 +112,7 @@ Response assertMethodSync(@HeaderParam("accept") String accept, RequestOpt @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> async(@HeaderParam("accept") String accept, RequestOptions requestOptions, + Mono> async(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, Context context); @Get("/special-words/operations/async") @@ -120,7 +121,8 @@ Mono> async(@HeaderParam("accept") String accept, RequestOptions @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response asyncSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + Response asyncSync(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, + Context context); @Get("/special-words/operations/await") @ExpectedResponses({ 204 }) @@ -128,7 +130,7 @@ Mono> async(@HeaderParam("accept") String accept, RequestOptions @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> await(@HeaderParam("accept") String accept, RequestOptions requestOptions, + Mono> await(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, Context context); @Get("/special-words/operations/await") @@ -137,7 +139,8 @@ Mono> await(@HeaderParam("accept") String accept, RequestOptions @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response awaitSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + Response awaitSync(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, + Context context); @Get("/special-words/operations/break") @ExpectedResponses({ 204 }) @@ -145,7 +148,7 @@ Mono> await(@HeaderParam("accept") String accept, RequestOptions @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> breakMethod(@HeaderParam("accept") String accept, RequestOptions requestOptions, + Mono> breakMethod(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, Context context); @Get("/special-words/operations/break") @@ -154,7 +157,7 @@ Mono> breakMethod(@HeaderParam("accept") String accept, RequestOp @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response breakMethodSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, + Response breakMethodSync(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, Context context); @Get("/special-words/operations/class") @@ -163,7 +166,7 @@ Response breakMethodSync(@HeaderParam("accept") String accept, RequestOpti @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> classMethod(@HeaderParam("accept") String accept, RequestOptions requestOptions, + Mono> classMethod(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, Context context); @Get("/special-words/operations/class") @@ -172,7 +175,7 @@ Mono> classMethod(@HeaderParam("accept") String accept, RequestOp @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response classMethodSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, + Response classMethodSync(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, Context context); @Get("/special-words/operations/constructor") @@ -181,7 +184,7 @@ Response classMethodSync(@HeaderParam("accept") String accept, RequestOpti @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> constructor(@HeaderParam("accept") String accept, RequestOptions requestOptions, + Mono> constructor(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, Context context); @Get("/special-words/operations/constructor") @@ -190,7 +193,7 @@ Mono> constructor(@HeaderParam("accept") String accept, RequestOp @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response constructorSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, + Response constructorSync(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, Context context); @Get("/special-words/operations/continue") @@ -199,7 +202,7 @@ Response constructorSync(@HeaderParam("accept") String accept, RequestOpti @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> continueMethod(@HeaderParam("accept") String accept, RequestOptions requestOptions, + Mono> continueMethod(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, Context context); @Get("/special-words/operations/continue") @@ -208,7 +211,7 @@ Mono> continueMethod(@HeaderParam("accept") String accept, Reques @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response continueMethodSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, + Response continueMethodSync(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, Context context); @Get("/special-words/operations/def") @@ -217,7 +220,8 @@ Response continueMethodSync(@HeaderParam("accept") String accept, RequestO @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> def(@HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + Mono> def(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, + Context context); @Get("/special-words/operations/def") @ExpectedResponses({ 204 }) @@ -225,7 +229,7 @@ Response continueMethodSync(@HeaderParam("accept") String accept, RequestO @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response defSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + Response defSync(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, Context context); @Get("/special-words/operations/del") @ExpectedResponses({ 204 }) @@ -233,7 +237,8 @@ Response continueMethodSync(@HeaderParam("accept") String accept, RequestO @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> del(@HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + Mono> del(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, + Context context); @Get("/special-words/operations/del") @ExpectedResponses({ 204 }) @@ -241,7 +246,7 @@ Response continueMethodSync(@HeaderParam("accept") String accept, RequestO @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response delSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + Response delSync(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, Context context); @Get("/special-words/operations/elif") @ExpectedResponses({ 204 }) @@ -249,7 +254,8 @@ Response continueMethodSync(@HeaderParam("accept") String accept, RequestO @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> elif(@HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + Mono> elif(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, + Context context); @Get("/special-words/operations/elif") @ExpectedResponses({ 204 }) @@ -257,7 +263,7 @@ Response continueMethodSync(@HeaderParam("accept") String accept, RequestO @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response elifSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + Response elifSync(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, Context context); @Get("/special-words/operations/else") @ExpectedResponses({ 204 }) @@ -265,7 +271,7 @@ Response continueMethodSync(@HeaderParam("accept") String accept, RequestO @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> elseMethod(@HeaderParam("accept") String accept, RequestOptions requestOptions, + Mono> elseMethod(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, Context context); @Get("/special-words/operations/else") @@ -274,7 +280,7 @@ Mono> elseMethod(@HeaderParam("accept") String accept, RequestOpt @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response elseMethodSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, + Response elseMethodSync(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, Context context); @Get("/special-words/operations/except") @@ -283,7 +289,7 @@ Response elseMethodSync(@HeaderParam("accept") String accept, RequestOptio @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> except(@HeaderParam("accept") String accept, RequestOptions requestOptions, + Mono> except(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, Context context); @Get("/special-words/operations/except") @@ -292,7 +298,8 @@ Mono> except(@HeaderParam("accept") String accept, RequestOptions @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response exceptSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + Response exceptSync(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, + Context context); @Get("/special-words/operations/exec") @ExpectedResponses({ 204 }) @@ -300,7 +307,8 @@ Mono> except(@HeaderParam("accept") String accept, RequestOptions @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> exec(@HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + Mono> exec(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, + Context context); @Get("/special-words/operations/exec") @ExpectedResponses({ 204 }) @@ -308,7 +316,7 @@ Mono> except(@HeaderParam("accept") String accept, RequestOptions @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response execSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + Response execSync(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, Context context); @Get("/special-words/operations/finally") @ExpectedResponses({ 204 }) @@ -316,7 +324,7 @@ Mono> except(@HeaderParam("accept") String accept, RequestOptions @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> finallyMethod(@HeaderParam("accept") String accept, RequestOptions requestOptions, + Mono> finallyMethod(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, Context context); @Get("/special-words/operations/finally") @@ -325,7 +333,7 @@ Mono> finallyMethod(@HeaderParam("accept") String accept, Request @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response finallyMethodSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, + Response finallyMethodSync(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, Context context); @Get("/special-words/operations/for") @@ -334,7 +342,7 @@ Response finallyMethodSync(@HeaderParam("accept") String accept, RequestOp @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> forMethod(@HeaderParam("accept") String accept, RequestOptions requestOptions, + Mono> forMethod(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, Context context); @Get("/special-words/operations/for") @@ -343,7 +351,7 @@ Mono> forMethod(@HeaderParam("accept") String accept, RequestOpti @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response forMethodSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, + Response forMethodSync(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, Context context); @Get("/special-words/operations/from") @@ -352,7 +360,8 @@ Response forMethodSync(@HeaderParam("accept") String accept, RequestOption @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> from(@HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + Mono> from(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, + Context context); @Get("/special-words/operations/from") @ExpectedResponses({ 204 }) @@ -360,7 +369,7 @@ Response forMethodSync(@HeaderParam("accept") String accept, RequestOption @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response fromSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + Response fromSync(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, Context context); @Get("/special-words/operations/global") @ExpectedResponses({ 204 }) @@ -368,7 +377,7 @@ Response forMethodSync(@HeaderParam("accept") String accept, RequestOption @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> global(@HeaderParam("accept") String accept, RequestOptions requestOptions, + Mono> global(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, Context context); @Get("/special-words/operations/global") @@ -377,7 +386,8 @@ Mono> global(@HeaderParam("accept") String accept, RequestOptions @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response globalSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + Response globalSync(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, + Context context); @Get("/special-words/operations/if") @ExpectedResponses({ 204 }) @@ -385,7 +395,7 @@ Mono> global(@HeaderParam("accept") String accept, RequestOptions @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> ifMethod(@HeaderParam("accept") String accept, RequestOptions requestOptions, + Mono> ifMethod(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, Context context); @Get("/special-words/operations/if") @@ -394,7 +404,7 @@ Mono> ifMethod(@HeaderParam("accept") String accept, RequestOptio @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response ifMethodSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, + Response ifMethodSync(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, Context context); @Get("/special-words/operations/import") @@ -403,7 +413,7 @@ Response ifMethodSync(@HeaderParam("accept") String accept, RequestOptions @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> importMethod(@HeaderParam("accept") String accept, RequestOptions requestOptions, + Mono> importMethod(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, Context context); @Get("/special-words/operations/import") @@ -412,7 +422,7 @@ Mono> importMethod(@HeaderParam("accept") String accept, RequestO @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response importMethodSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, + Response importMethodSync(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, Context context); @Get("/special-words/operations/in") @@ -421,7 +431,7 @@ Response importMethodSync(@HeaderParam("accept") String accept, RequestOpt @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> in(@HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + Mono> in(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, Context context); @Get("/special-words/operations/in") @ExpectedResponses({ 204 }) @@ -429,7 +439,7 @@ Response importMethodSync(@HeaderParam("accept") String accept, RequestOpt @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response inSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + Response inSync(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, Context context); @Get("/special-words/operations/is") @ExpectedResponses({ 204 }) @@ -437,7 +447,7 @@ Response importMethodSync(@HeaderParam("accept") String accept, RequestOpt @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> is(@HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + Mono> is(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, Context context); @Get("/special-words/operations/is") @ExpectedResponses({ 204 }) @@ -445,7 +455,7 @@ Response importMethodSync(@HeaderParam("accept") String accept, RequestOpt @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response isSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + Response isSync(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, Context context); @Get("/special-words/operations/lambda") @ExpectedResponses({ 204 }) @@ -453,7 +463,7 @@ Response importMethodSync(@HeaderParam("accept") String accept, RequestOpt @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> lambda(@HeaderParam("accept") String accept, RequestOptions requestOptions, + Mono> lambda(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, Context context); @Get("/special-words/operations/lambda") @@ -462,7 +472,8 @@ Mono> lambda(@HeaderParam("accept") String accept, RequestOptions @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response lambdaSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + Response lambdaSync(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, + Context context); @Get("/special-words/operations/not") @ExpectedResponses({ 204 }) @@ -470,7 +481,8 @@ Mono> lambda(@HeaderParam("accept") String accept, RequestOptions @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> not(@HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + Mono> not(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, + Context context); @Get("/special-words/operations/not") @ExpectedResponses({ 204 }) @@ -478,7 +490,7 @@ Mono> lambda(@HeaderParam("accept") String accept, RequestOptions @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response notSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + Response notSync(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, Context context); @Get("/special-words/operations/or") @ExpectedResponses({ 204 }) @@ -486,7 +498,7 @@ Mono> lambda(@HeaderParam("accept") String accept, RequestOptions @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> or(@HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + Mono> or(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, Context context); @Get("/special-words/operations/or") @ExpectedResponses({ 204 }) @@ -494,7 +506,7 @@ Mono> lambda(@HeaderParam("accept") String accept, RequestOptions @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response orSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + Response orSync(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, Context context); @Get("/special-words/operations/pass") @ExpectedResponses({ 204 }) @@ -502,7 +514,8 @@ Mono> lambda(@HeaderParam("accept") String accept, RequestOptions @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> pass(@HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + Mono> pass(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, + Context context); @Get("/special-words/operations/pass") @ExpectedResponses({ 204 }) @@ -510,7 +523,7 @@ Mono> lambda(@HeaderParam("accept") String accept, RequestOptions @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response passSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + Response passSync(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, Context context); @Get("/special-words/operations/raise") @ExpectedResponses({ 204 }) @@ -518,7 +531,7 @@ Mono> lambda(@HeaderParam("accept") String accept, RequestOptions @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> raise(@HeaderParam("accept") String accept, RequestOptions requestOptions, + Mono> raise(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, Context context); @Get("/special-words/operations/raise") @@ -527,7 +540,8 @@ Mono> raise(@HeaderParam("accept") String accept, RequestOptions @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response raiseSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + Response raiseSync(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, + Context context); @Get("/special-words/operations/return") @ExpectedResponses({ 204 }) @@ -535,7 +549,7 @@ Mono> raise(@HeaderParam("accept") String accept, RequestOptions @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> returnMethod(@HeaderParam("accept") String accept, RequestOptions requestOptions, + Mono> returnMethod(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, Context context); @Get("/special-words/operations/return") @@ -544,7 +558,7 @@ Mono> returnMethod(@HeaderParam("accept") String accept, RequestO @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response returnMethodSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, + Response returnMethodSync(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, Context context); @Get("/special-words/operations/try") @@ -553,7 +567,7 @@ Response returnMethodSync(@HeaderParam("accept") String accept, RequestOpt @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> tryMethod(@HeaderParam("accept") String accept, RequestOptions requestOptions, + Mono> tryMethod(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, Context context); @Get("/special-words/operations/try") @@ -562,7 +576,7 @@ Mono> tryMethod(@HeaderParam("accept") String accept, RequestOpti @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response tryMethodSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, + Response tryMethodSync(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, Context context); @Get("/special-words/operations/while") @@ -571,7 +585,7 @@ Response tryMethodSync(@HeaderParam("accept") String accept, RequestOption @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> whileMethod(@HeaderParam("accept") String accept, RequestOptions requestOptions, + Mono> whileMethod(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, Context context); @Get("/special-words/operations/while") @@ -580,7 +594,7 @@ Mono> whileMethod(@HeaderParam("accept") String accept, RequestOp @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response whileMethodSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, + Response whileMethodSync(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, Context context); @Get("/special-words/operations/with") @@ -589,7 +603,8 @@ Response whileMethodSync(@HeaderParam("accept") String accept, RequestOpti @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> with(@HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + Mono> with(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, + Context context); @Get("/special-words/operations/with") @ExpectedResponses({ 204 }) @@ -597,7 +612,7 @@ Response whileMethodSync(@HeaderParam("accept") String accept, RequestOpti @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response withSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + Response withSync(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, Context context); @Get("/special-words/operations/yield") @ExpectedResponses({ 204 }) @@ -605,7 +620,7 @@ Response whileMethodSync(@HeaderParam("accept") String accept, RequestOpti @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> yield(@HeaderParam("accept") String accept, RequestOptions requestOptions, + Mono> yield(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, Context context); @Get("/special-words/operations/yield") @@ -614,7 +629,8 @@ Mono> yield(@HeaderParam("accept") String accept, RequestOptions @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response yieldSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + Response yieldSync(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, + Context context); } /** @@ -629,8 +645,7 @@ Mono> yield(@HeaderParam("accept") String accept, RequestOptions */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> andWithResponseAsync(RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.and(accept, requestOptions, context)); + return FluxUtil.withContext(context -> service.and(this.client.getEndpoint(), requestOptions, context)); } /** @@ -645,8 +660,7 @@ public Mono> andWithResponseAsync(RequestOptions requestOptions) */ @ServiceMethod(returns = ReturnType.SINGLE) public Response andWithResponse(RequestOptions requestOptions) { - final String accept = "application/json"; - return service.andSync(accept, requestOptions, Context.NONE); + return service.andSync(this.client.getEndpoint(), requestOptions, Context.NONE); } /** @@ -661,8 +675,7 @@ public Response andWithResponse(RequestOptions requestOptions) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> asWithResponseAsync(RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.as(accept, requestOptions, context)); + return FluxUtil.withContext(context -> service.as(this.client.getEndpoint(), requestOptions, context)); } /** @@ -677,8 +690,7 @@ public Mono> asWithResponseAsync(RequestOptions requestOptions) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Response asWithResponse(RequestOptions requestOptions) { - final String accept = "application/json"; - return service.asSync(accept, requestOptions, Context.NONE); + return service.asSync(this.client.getEndpoint(), requestOptions, Context.NONE); } /** @@ -693,8 +705,8 @@ public Response asWithResponse(RequestOptions requestOptions) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> assertMethodWithResponseAsync(RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.assertMethod(accept, requestOptions, context)); + return FluxUtil + .withContext(context -> service.assertMethod(this.client.getEndpoint(), requestOptions, context)); } /** @@ -709,8 +721,7 @@ public Mono> assertMethodWithResponseAsync(RequestOptions request */ @ServiceMethod(returns = ReturnType.SINGLE) public Response assertMethodWithResponse(RequestOptions requestOptions) { - final String accept = "application/json"; - return service.assertMethodSync(accept, requestOptions, Context.NONE); + return service.assertMethodSync(this.client.getEndpoint(), requestOptions, Context.NONE); } /** @@ -725,8 +736,7 @@ public Response assertMethodWithResponse(RequestOptions requestOptions) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> asyncWithResponseAsync(RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.async(accept, requestOptions, context)); + return FluxUtil.withContext(context -> service.async(this.client.getEndpoint(), requestOptions, context)); } /** @@ -741,8 +751,7 @@ public Mono> asyncWithResponseAsync(RequestOptions requestOptions */ @ServiceMethod(returns = ReturnType.SINGLE) public Response asyncWithResponse(RequestOptions requestOptions) { - final String accept = "application/json"; - return service.asyncSync(accept, requestOptions, Context.NONE); + return service.asyncSync(this.client.getEndpoint(), requestOptions, Context.NONE); } /** @@ -757,8 +766,7 @@ public Response asyncWithResponse(RequestOptions requestOptions) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> awaitWithResponseAsync(RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.await(accept, requestOptions, context)); + return FluxUtil.withContext(context -> service.await(this.client.getEndpoint(), requestOptions, context)); } /** @@ -773,8 +781,7 @@ public Mono> awaitWithResponseAsync(RequestOptions requestOptions */ @ServiceMethod(returns = ReturnType.SINGLE) public Response awaitWithResponse(RequestOptions requestOptions) { - final String accept = "application/json"; - return service.awaitSync(accept, requestOptions, Context.NONE); + return service.awaitSync(this.client.getEndpoint(), requestOptions, Context.NONE); } /** @@ -789,8 +796,7 @@ public Response awaitWithResponse(RequestOptions requestOptions) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> breakMethodWithResponseAsync(RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.breakMethod(accept, requestOptions, context)); + return FluxUtil.withContext(context -> service.breakMethod(this.client.getEndpoint(), requestOptions, context)); } /** @@ -805,8 +811,7 @@ public Mono> breakMethodWithResponseAsync(RequestOptions requestO */ @ServiceMethod(returns = ReturnType.SINGLE) public Response breakMethodWithResponse(RequestOptions requestOptions) { - final String accept = "application/json"; - return service.breakMethodSync(accept, requestOptions, Context.NONE); + return service.breakMethodSync(this.client.getEndpoint(), requestOptions, Context.NONE); } /** @@ -821,8 +826,7 @@ public Response breakMethodWithResponse(RequestOptions requestOptions) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> classMethodWithResponseAsync(RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.classMethod(accept, requestOptions, context)); + return FluxUtil.withContext(context -> service.classMethod(this.client.getEndpoint(), requestOptions, context)); } /** @@ -837,8 +841,7 @@ public Mono> classMethodWithResponseAsync(RequestOptions requestO */ @ServiceMethod(returns = ReturnType.SINGLE) public Response classMethodWithResponse(RequestOptions requestOptions) { - final String accept = "application/json"; - return service.classMethodSync(accept, requestOptions, Context.NONE); + return service.classMethodSync(this.client.getEndpoint(), requestOptions, Context.NONE); } /** @@ -853,8 +856,7 @@ public Response classMethodWithResponse(RequestOptions requestOptions) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> constructorWithResponseAsync(RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.constructor(accept, requestOptions, context)); + return FluxUtil.withContext(context -> service.constructor(this.client.getEndpoint(), requestOptions, context)); } /** @@ -869,8 +871,7 @@ public Mono> constructorWithResponseAsync(RequestOptions requestO */ @ServiceMethod(returns = ReturnType.SINGLE) public Response constructorWithResponse(RequestOptions requestOptions) { - final String accept = "application/json"; - return service.constructorSync(accept, requestOptions, Context.NONE); + return service.constructorSync(this.client.getEndpoint(), requestOptions, Context.NONE); } /** @@ -885,8 +886,8 @@ public Response constructorWithResponse(RequestOptions requestOptions) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> continueMethodWithResponseAsync(RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.continueMethod(accept, requestOptions, context)); + return FluxUtil + .withContext(context -> service.continueMethod(this.client.getEndpoint(), requestOptions, context)); } /** @@ -901,8 +902,7 @@ public Mono> continueMethodWithResponseAsync(RequestOptions reque */ @ServiceMethod(returns = ReturnType.SINGLE) public Response continueMethodWithResponse(RequestOptions requestOptions) { - final String accept = "application/json"; - return service.continueMethodSync(accept, requestOptions, Context.NONE); + return service.continueMethodSync(this.client.getEndpoint(), requestOptions, Context.NONE); } /** @@ -917,8 +917,7 @@ public Response continueMethodWithResponse(RequestOptions requestOptions) */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> defWithResponseAsync(RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.def(accept, requestOptions, context)); + return FluxUtil.withContext(context -> service.def(this.client.getEndpoint(), requestOptions, context)); } /** @@ -933,8 +932,7 @@ public Mono> defWithResponseAsync(RequestOptions requestOptions) */ @ServiceMethod(returns = ReturnType.SINGLE) public Response defWithResponse(RequestOptions requestOptions) { - final String accept = "application/json"; - return service.defSync(accept, requestOptions, Context.NONE); + return service.defSync(this.client.getEndpoint(), requestOptions, Context.NONE); } /** @@ -949,8 +947,7 @@ public Response defWithResponse(RequestOptions requestOptions) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> delWithResponseAsync(RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.del(accept, requestOptions, context)); + return FluxUtil.withContext(context -> service.del(this.client.getEndpoint(), requestOptions, context)); } /** @@ -965,8 +962,7 @@ public Mono> delWithResponseAsync(RequestOptions requestOptions) */ @ServiceMethod(returns = ReturnType.SINGLE) public Response delWithResponse(RequestOptions requestOptions) { - final String accept = "application/json"; - return service.delSync(accept, requestOptions, Context.NONE); + return service.delSync(this.client.getEndpoint(), requestOptions, Context.NONE); } /** @@ -981,8 +977,7 @@ public Response delWithResponse(RequestOptions requestOptions) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> elifWithResponseAsync(RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.elif(accept, requestOptions, context)); + return FluxUtil.withContext(context -> service.elif(this.client.getEndpoint(), requestOptions, context)); } /** @@ -997,8 +992,7 @@ public Mono> elifWithResponseAsync(RequestOptions requestOptions) */ @ServiceMethod(returns = ReturnType.SINGLE) public Response elifWithResponse(RequestOptions requestOptions) { - final String accept = "application/json"; - return service.elifSync(accept, requestOptions, Context.NONE); + return service.elifSync(this.client.getEndpoint(), requestOptions, Context.NONE); } /** @@ -1013,8 +1007,7 @@ public Response elifWithResponse(RequestOptions requestOptions) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> elseMethodWithResponseAsync(RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.elseMethod(accept, requestOptions, context)); + return FluxUtil.withContext(context -> service.elseMethod(this.client.getEndpoint(), requestOptions, context)); } /** @@ -1029,8 +1022,7 @@ public Mono> elseMethodWithResponseAsync(RequestOptions requestOp */ @ServiceMethod(returns = ReturnType.SINGLE) public Response elseMethodWithResponse(RequestOptions requestOptions) { - final String accept = "application/json"; - return service.elseMethodSync(accept, requestOptions, Context.NONE); + return service.elseMethodSync(this.client.getEndpoint(), requestOptions, Context.NONE); } /** @@ -1045,8 +1037,7 @@ public Response elseMethodWithResponse(RequestOptions requestOptions) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> exceptWithResponseAsync(RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.except(accept, requestOptions, context)); + return FluxUtil.withContext(context -> service.except(this.client.getEndpoint(), requestOptions, context)); } /** @@ -1061,8 +1052,7 @@ public Mono> exceptWithResponseAsync(RequestOptions requestOption */ @ServiceMethod(returns = ReturnType.SINGLE) public Response exceptWithResponse(RequestOptions requestOptions) { - final String accept = "application/json"; - return service.exceptSync(accept, requestOptions, Context.NONE); + return service.exceptSync(this.client.getEndpoint(), requestOptions, Context.NONE); } /** @@ -1077,8 +1067,7 @@ public Response exceptWithResponse(RequestOptions requestOptions) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> execWithResponseAsync(RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.exec(accept, requestOptions, context)); + return FluxUtil.withContext(context -> service.exec(this.client.getEndpoint(), requestOptions, context)); } /** @@ -1093,8 +1082,7 @@ public Mono> execWithResponseAsync(RequestOptions requestOptions) */ @ServiceMethod(returns = ReturnType.SINGLE) public Response execWithResponse(RequestOptions requestOptions) { - final String accept = "application/json"; - return service.execSync(accept, requestOptions, Context.NONE); + return service.execSync(this.client.getEndpoint(), requestOptions, Context.NONE); } /** @@ -1109,8 +1097,8 @@ public Response execWithResponse(RequestOptions requestOptions) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> finallyMethodWithResponseAsync(RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.finallyMethod(accept, requestOptions, context)); + return FluxUtil + .withContext(context -> service.finallyMethod(this.client.getEndpoint(), requestOptions, context)); } /** @@ -1125,8 +1113,7 @@ public Mono> finallyMethodWithResponseAsync(RequestOptions reques */ @ServiceMethod(returns = ReturnType.SINGLE) public Response finallyMethodWithResponse(RequestOptions requestOptions) { - final String accept = "application/json"; - return service.finallyMethodSync(accept, requestOptions, Context.NONE); + return service.finallyMethodSync(this.client.getEndpoint(), requestOptions, Context.NONE); } /** @@ -1141,8 +1128,7 @@ public Response finallyMethodWithResponse(RequestOptions requestOptions) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> forMethodWithResponseAsync(RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.forMethod(accept, requestOptions, context)); + return FluxUtil.withContext(context -> service.forMethod(this.client.getEndpoint(), requestOptions, context)); } /** @@ -1157,8 +1143,7 @@ public Mono> forMethodWithResponseAsync(RequestOptions requestOpt */ @ServiceMethod(returns = ReturnType.SINGLE) public Response forMethodWithResponse(RequestOptions requestOptions) { - final String accept = "application/json"; - return service.forMethodSync(accept, requestOptions, Context.NONE); + return service.forMethodSync(this.client.getEndpoint(), requestOptions, Context.NONE); } /** @@ -1173,8 +1158,7 @@ public Response forMethodWithResponse(RequestOptions requestOptions) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> fromWithResponseAsync(RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.from(accept, requestOptions, context)); + return FluxUtil.withContext(context -> service.from(this.client.getEndpoint(), requestOptions, context)); } /** @@ -1189,8 +1173,7 @@ public Mono> fromWithResponseAsync(RequestOptions requestOptions) */ @ServiceMethod(returns = ReturnType.SINGLE) public Response fromWithResponse(RequestOptions requestOptions) { - final String accept = "application/json"; - return service.fromSync(accept, requestOptions, Context.NONE); + return service.fromSync(this.client.getEndpoint(), requestOptions, Context.NONE); } /** @@ -1205,8 +1188,7 @@ public Response fromWithResponse(RequestOptions requestOptions) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> globalWithResponseAsync(RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.global(accept, requestOptions, context)); + return FluxUtil.withContext(context -> service.global(this.client.getEndpoint(), requestOptions, context)); } /** @@ -1221,8 +1203,7 @@ public Mono> globalWithResponseAsync(RequestOptions requestOption */ @ServiceMethod(returns = ReturnType.SINGLE) public Response globalWithResponse(RequestOptions requestOptions) { - final String accept = "application/json"; - return service.globalSync(accept, requestOptions, Context.NONE); + return service.globalSync(this.client.getEndpoint(), requestOptions, Context.NONE); } /** @@ -1237,8 +1218,7 @@ public Response globalWithResponse(RequestOptions requestOptions) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> ifMethodWithResponseAsync(RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.ifMethod(accept, requestOptions, context)); + return FluxUtil.withContext(context -> service.ifMethod(this.client.getEndpoint(), requestOptions, context)); } /** @@ -1253,8 +1233,7 @@ public Mono> ifMethodWithResponseAsync(RequestOptions requestOpti */ @ServiceMethod(returns = ReturnType.SINGLE) public Response ifMethodWithResponse(RequestOptions requestOptions) { - final String accept = "application/json"; - return service.ifMethodSync(accept, requestOptions, Context.NONE); + return service.ifMethodSync(this.client.getEndpoint(), requestOptions, Context.NONE); } /** @@ -1269,8 +1248,8 @@ public Response ifMethodWithResponse(RequestOptions requestOptions) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> importMethodWithResponseAsync(RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.importMethod(accept, requestOptions, context)); + return FluxUtil + .withContext(context -> service.importMethod(this.client.getEndpoint(), requestOptions, context)); } /** @@ -1285,8 +1264,7 @@ public Mono> importMethodWithResponseAsync(RequestOptions request */ @ServiceMethod(returns = ReturnType.SINGLE) public Response importMethodWithResponse(RequestOptions requestOptions) { - final String accept = "application/json"; - return service.importMethodSync(accept, requestOptions, Context.NONE); + return service.importMethodSync(this.client.getEndpoint(), requestOptions, Context.NONE); } /** @@ -1301,8 +1279,7 @@ public Response importMethodWithResponse(RequestOptions requestOptions) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> inWithResponseAsync(RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.in(accept, requestOptions, context)); + return FluxUtil.withContext(context -> service.in(this.client.getEndpoint(), requestOptions, context)); } /** @@ -1317,8 +1294,7 @@ public Mono> inWithResponseAsync(RequestOptions requestOptions) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Response inWithResponse(RequestOptions requestOptions) { - final String accept = "application/json"; - return service.inSync(accept, requestOptions, Context.NONE); + return service.inSync(this.client.getEndpoint(), requestOptions, Context.NONE); } /** @@ -1333,8 +1309,7 @@ public Response inWithResponse(RequestOptions requestOptions) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> isWithResponseAsync(RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.is(accept, requestOptions, context)); + return FluxUtil.withContext(context -> service.is(this.client.getEndpoint(), requestOptions, context)); } /** @@ -1349,8 +1324,7 @@ public Mono> isWithResponseAsync(RequestOptions requestOptions) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Response isWithResponse(RequestOptions requestOptions) { - final String accept = "application/json"; - return service.isSync(accept, requestOptions, Context.NONE); + return service.isSync(this.client.getEndpoint(), requestOptions, Context.NONE); } /** @@ -1365,8 +1339,7 @@ public Response isWithResponse(RequestOptions requestOptions) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> lambdaWithResponseAsync(RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.lambda(accept, requestOptions, context)); + return FluxUtil.withContext(context -> service.lambda(this.client.getEndpoint(), requestOptions, context)); } /** @@ -1381,8 +1354,7 @@ public Mono> lambdaWithResponseAsync(RequestOptions requestOption */ @ServiceMethod(returns = ReturnType.SINGLE) public Response lambdaWithResponse(RequestOptions requestOptions) { - final String accept = "application/json"; - return service.lambdaSync(accept, requestOptions, Context.NONE); + return service.lambdaSync(this.client.getEndpoint(), requestOptions, Context.NONE); } /** @@ -1397,8 +1369,7 @@ public Response lambdaWithResponse(RequestOptions requestOptions) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> notWithResponseAsync(RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.not(accept, requestOptions, context)); + return FluxUtil.withContext(context -> service.not(this.client.getEndpoint(), requestOptions, context)); } /** @@ -1413,8 +1384,7 @@ public Mono> notWithResponseAsync(RequestOptions requestOptions) */ @ServiceMethod(returns = ReturnType.SINGLE) public Response notWithResponse(RequestOptions requestOptions) { - final String accept = "application/json"; - return service.notSync(accept, requestOptions, Context.NONE); + return service.notSync(this.client.getEndpoint(), requestOptions, Context.NONE); } /** @@ -1429,8 +1399,7 @@ public Response notWithResponse(RequestOptions requestOptions) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> orWithResponseAsync(RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.or(accept, requestOptions, context)); + return FluxUtil.withContext(context -> service.or(this.client.getEndpoint(), requestOptions, context)); } /** @@ -1445,8 +1414,7 @@ public Mono> orWithResponseAsync(RequestOptions requestOptions) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Response orWithResponse(RequestOptions requestOptions) { - final String accept = "application/json"; - return service.orSync(accept, requestOptions, Context.NONE); + return service.orSync(this.client.getEndpoint(), requestOptions, Context.NONE); } /** @@ -1461,8 +1429,7 @@ public Response orWithResponse(RequestOptions requestOptions) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> passWithResponseAsync(RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.pass(accept, requestOptions, context)); + return FluxUtil.withContext(context -> service.pass(this.client.getEndpoint(), requestOptions, context)); } /** @@ -1477,8 +1444,7 @@ public Mono> passWithResponseAsync(RequestOptions requestOptions) */ @ServiceMethod(returns = ReturnType.SINGLE) public Response passWithResponse(RequestOptions requestOptions) { - final String accept = "application/json"; - return service.passSync(accept, requestOptions, Context.NONE); + return service.passSync(this.client.getEndpoint(), requestOptions, Context.NONE); } /** @@ -1493,8 +1459,7 @@ public Response passWithResponse(RequestOptions requestOptions) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> raiseWithResponseAsync(RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.raise(accept, requestOptions, context)); + return FluxUtil.withContext(context -> service.raise(this.client.getEndpoint(), requestOptions, context)); } /** @@ -1509,8 +1474,7 @@ public Mono> raiseWithResponseAsync(RequestOptions requestOptions */ @ServiceMethod(returns = ReturnType.SINGLE) public Response raiseWithResponse(RequestOptions requestOptions) { - final String accept = "application/json"; - return service.raiseSync(accept, requestOptions, Context.NONE); + return service.raiseSync(this.client.getEndpoint(), requestOptions, Context.NONE); } /** @@ -1525,8 +1489,8 @@ public Response raiseWithResponse(RequestOptions requestOptions) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> returnMethodWithResponseAsync(RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.returnMethod(accept, requestOptions, context)); + return FluxUtil + .withContext(context -> service.returnMethod(this.client.getEndpoint(), requestOptions, context)); } /** @@ -1541,8 +1505,7 @@ public Mono> returnMethodWithResponseAsync(RequestOptions request */ @ServiceMethod(returns = ReturnType.SINGLE) public Response returnMethodWithResponse(RequestOptions requestOptions) { - final String accept = "application/json"; - return service.returnMethodSync(accept, requestOptions, Context.NONE); + return service.returnMethodSync(this.client.getEndpoint(), requestOptions, Context.NONE); } /** @@ -1557,8 +1520,7 @@ public Response returnMethodWithResponse(RequestOptions requestOptions) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> tryMethodWithResponseAsync(RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.tryMethod(accept, requestOptions, context)); + return FluxUtil.withContext(context -> service.tryMethod(this.client.getEndpoint(), requestOptions, context)); } /** @@ -1573,8 +1535,7 @@ public Mono> tryMethodWithResponseAsync(RequestOptions requestOpt */ @ServiceMethod(returns = ReturnType.SINGLE) public Response tryMethodWithResponse(RequestOptions requestOptions) { - final String accept = "application/json"; - return service.tryMethodSync(accept, requestOptions, Context.NONE); + return service.tryMethodSync(this.client.getEndpoint(), requestOptions, Context.NONE); } /** @@ -1589,8 +1550,7 @@ public Response tryMethodWithResponse(RequestOptions requestOptions) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> whileMethodWithResponseAsync(RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.whileMethod(accept, requestOptions, context)); + return FluxUtil.withContext(context -> service.whileMethod(this.client.getEndpoint(), requestOptions, context)); } /** @@ -1605,8 +1565,7 @@ public Mono> whileMethodWithResponseAsync(RequestOptions requestO */ @ServiceMethod(returns = ReturnType.SINGLE) public Response whileMethodWithResponse(RequestOptions requestOptions) { - final String accept = "application/json"; - return service.whileMethodSync(accept, requestOptions, Context.NONE); + return service.whileMethodSync(this.client.getEndpoint(), requestOptions, Context.NONE); } /** @@ -1621,8 +1580,7 @@ public Response whileMethodWithResponse(RequestOptions requestOptions) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> withWithResponseAsync(RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.with(accept, requestOptions, context)); + return FluxUtil.withContext(context -> service.with(this.client.getEndpoint(), requestOptions, context)); } /** @@ -1637,8 +1595,7 @@ public Mono> withWithResponseAsync(RequestOptions requestOptions) */ @ServiceMethod(returns = ReturnType.SINGLE) public Response withWithResponse(RequestOptions requestOptions) { - final String accept = "application/json"; - return service.withSync(accept, requestOptions, Context.NONE); + return service.withSync(this.client.getEndpoint(), requestOptions, Context.NONE); } /** @@ -1653,8 +1610,7 @@ public Response withWithResponse(RequestOptions requestOptions) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> yieldWithResponseAsync(RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.yield(accept, requestOptions, context)); + return FluxUtil.withContext(context -> service.yield(this.client.getEndpoint(), requestOptions, context)); } /** @@ -1669,7 +1625,6 @@ public Mono> yieldWithResponseAsync(RequestOptions requestOptions */ @ServiceMethod(returns = ReturnType.SINGLE) public Response yieldWithResponse(RequestOptions requestOptions) { - final String accept = "application/json"; - return service.yieldSync(accept, requestOptions, Context.NONE); + return service.yieldSync(this.client.getEndpoint(), requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/specialwords/implementation/ParametersImpl.java b/typespec-tests/src/main/java/com/specialwords/implementation/ParametersImpl.java index 40e40e0a6a..a848bcd270 100644 --- a/typespec-tests/src/main/java/com/specialwords/implementation/ParametersImpl.java +++ b/typespec-tests/src/main/java/com/specialwords/implementation/ParametersImpl.java @@ -6,8 +6,8 @@ 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; @@ -53,7 +53,7 @@ public final class ParametersImpl { * The interface defining all the services for SpecialWordsClientParameters to be used by the proxy service to * perform REST calls. */ - @Host("http://localhost:3000") + @Host("{endpoint}") @ServiceInterface(name = "SpecialWordsClientPa") public interface ParametersService { @Get("/special-words/parameters/and") @@ -62,7 +62,7 @@ public interface ParametersService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> withAnd(@QueryParam("and") String and, @HeaderParam("accept") String accept, + Mono> withAnd(@HostParam("endpoint") String endpoint, @QueryParam("and") String and, RequestOptions requestOptions, Context context); @Get("/special-words/parameters/and") @@ -71,7 +71,7 @@ Mono> withAnd(@QueryParam("and") String and, @HeaderParam("accept @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response withAndSync(@QueryParam("and") String and, @HeaderParam("accept") String accept, + Response withAndSync(@HostParam("endpoint") String endpoint, @QueryParam("and") String and, RequestOptions requestOptions, Context context); @Get("/special-words/parameters/as") @@ -80,7 +80,7 @@ Response withAndSync(@QueryParam("and") String and, @HeaderParam("accept") @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> withAs(@QueryParam("as") String as, @HeaderParam("accept") String accept, + Mono> withAs(@HostParam("endpoint") String endpoint, @QueryParam("as") String as, RequestOptions requestOptions, Context context); @Get("/special-words/parameters/as") @@ -89,7 +89,7 @@ Mono> withAs(@QueryParam("as") String as, @HeaderParam("accept") @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response withAsSync(@QueryParam("as") String as, @HeaderParam("accept") String accept, + Response withAsSync(@HostParam("endpoint") String endpoint, @QueryParam("as") String as, RequestOptions requestOptions, Context context); @Get("/special-words/parameters/assert") @@ -98,8 +98,8 @@ Response withAsSync(@QueryParam("as") String as, @HeaderParam("accept") St @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> withAssert(@QueryParam("assert") String assertParameter, - @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + Mono> withAssert(@HostParam("endpoint") String endpoint, + @QueryParam("assert") String assertParameter, RequestOptions requestOptions, Context context); @Get("/special-words/parameters/assert") @ExpectedResponses({ 204 }) @@ -107,8 +107,8 @@ Mono> withAssert(@QueryParam("assert") String assertParameter, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response withAssertSync(@QueryParam("assert") String assertParameter, - @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + Response withAssertSync(@HostParam("endpoint") String endpoint, + @QueryParam("assert") String assertParameter, RequestOptions requestOptions, Context context); @Get("/special-words/parameters/async") @ExpectedResponses({ 204 }) @@ -116,7 +116,7 @@ Response withAssertSync(@QueryParam("assert") String assertParameter, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> withAsync(@QueryParam("async") String async, @HeaderParam("accept") String accept, + Mono> withAsync(@HostParam("endpoint") String endpoint, @QueryParam("async") String async, RequestOptions requestOptions, Context context); @Get("/special-words/parameters/async") @@ -125,7 +125,7 @@ Mono> withAsync(@QueryParam("async") String async, @HeaderParam(" @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response withAsyncSync(@QueryParam("async") String async, @HeaderParam("accept") String accept, + Response withAsyncSync(@HostParam("endpoint") String endpoint, @QueryParam("async") String async, RequestOptions requestOptions, Context context); @Get("/special-words/parameters/await") @@ -134,7 +134,7 @@ Response withAsyncSync(@QueryParam("async") String async, @HeaderParam("ac @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> withAwait(@QueryParam("await") String await, @HeaderParam("accept") String accept, + Mono> withAwait(@HostParam("endpoint") String endpoint, @QueryParam("await") String await, RequestOptions requestOptions, Context context); @Get("/special-words/parameters/await") @@ -143,7 +143,7 @@ Mono> withAwait(@QueryParam("await") String await, @HeaderParam(" @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response withAwaitSync(@QueryParam("await") String await, @HeaderParam("accept") String accept, + Response withAwaitSync(@HostParam("endpoint") String endpoint, @QueryParam("await") String await, RequestOptions requestOptions, Context context); @Get("/special-words/parameters/break") @@ -152,8 +152,8 @@ Response withAwaitSync(@QueryParam("await") String await, @HeaderParam("ac @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> withBreak(@QueryParam("break") String breakParameter, @HeaderParam("accept") String accept, - RequestOptions requestOptions, Context context); + Mono> withBreak(@HostParam("endpoint") String endpoint, + @QueryParam("break") String breakParameter, RequestOptions requestOptions, Context context); @Get("/special-words/parameters/break") @ExpectedResponses({ 204 }) @@ -161,7 +161,7 @@ Mono> withBreak(@QueryParam("break") String breakParameter, @Head @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response withBreakSync(@QueryParam("break") String breakParameter, @HeaderParam("accept") String accept, + Response withBreakSync(@HostParam("endpoint") String endpoint, @QueryParam("break") String breakParameter, RequestOptions requestOptions, Context context); @Get("/special-words/parameters/class") @@ -170,8 +170,8 @@ Response withBreakSync(@QueryParam("break") String breakParameter, @Header @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> withClass(@QueryParam("class") String classParameter, @HeaderParam("accept") String accept, - RequestOptions requestOptions, Context context); + Mono> withClass(@HostParam("endpoint") String endpoint, + @QueryParam("class") String classParameter, RequestOptions requestOptions, Context context); @Get("/special-words/parameters/class") @ExpectedResponses({ 204 }) @@ -179,7 +179,7 @@ Mono> withClass(@QueryParam("class") String classParameter, @Head @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response withClassSync(@QueryParam("class") String classParameter, @HeaderParam("accept") String accept, + Response withClassSync(@HostParam("endpoint") String endpoint, @QueryParam("class") String classParameter, RequestOptions requestOptions, Context context); @Get("/special-words/parameters/constructor") @@ -188,8 +188,8 @@ Response withClassSync(@QueryParam("class") String classParameter, @Header @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> withConstructor(@QueryParam("constructor") String constructor, - @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + Mono> withConstructor(@HostParam("endpoint") String endpoint, + @QueryParam("constructor") String constructor, RequestOptions requestOptions, Context context); @Get("/special-words/parameters/constructor") @ExpectedResponses({ 204 }) @@ -197,8 +197,8 @@ Mono> withConstructor(@QueryParam("constructor") String construct @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response withConstructorSync(@QueryParam("constructor") String constructor, - @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + Response withConstructorSync(@HostParam("endpoint") String endpoint, + @QueryParam("constructor") String constructor, RequestOptions requestOptions, Context context); @Get("/special-words/parameters/continue") @ExpectedResponses({ 204 }) @@ -206,8 +206,8 @@ Response withConstructorSync(@QueryParam("constructor") String constructor @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> withContinue(@QueryParam("continue") String continueParameter, - @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + Mono> withContinue(@HostParam("endpoint") String endpoint, + @QueryParam("continue") String continueParameter, RequestOptions requestOptions, Context context); @Get("/special-words/parameters/continue") @ExpectedResponses({ 204 }) @@ -215,8 +215,8 @@ Mono> withContinue(@QueryParam("continue") String continueParamet @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response withContinueSync(@QueryParam("continue") String continueParameter, - @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + Response withContinueSync(@HostParam("endpoint") String endpoint, + @QueryParam("continue") String continueParameter, RequestOptions requestOptions, Context context); @Get("/special-words/parameters/def") @ExpectedResponses({ 204 }) @@ -224,7 +224,7 @@ Response withContinueSync(@QueryParam("continue") String continueParameter @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> withDef(@QueryParam("def") String def, @HeaderParam("accept") String accept, + Mono> withDef(@HostParam("endpoint") String endpoint, @QueryParam("def") String def, RequestOptions requestOptions, Context context); @Get("/special-words/parameters/def") @@ -233,7 +233,7 @@ Mono> withDef(@QueryParam("def") String def, @HeaderParam("accept @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response withDefSync(@QueryParam("def") String def, @HeaderParam("accept") String accept, + Response withDefSync(@HostParam("endpoint") String endpoint, @QueryParam("def") String def, RequestOptions requestOptions, Context context); @Get("/special-words/parameters/del") @@ -242,7 +242,7 @@ Response withDefSync(@QueryParam("def") String def, @HeaderParam("accept") @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> withDel(@QueryParam("del") String del, @HeaderParam("accept") String accept, + Mono> withDel(@HostParam("endpoint") String endpoint, @QueryParam("del") String del, RequestOptions requestOptions, Context context); @Get("/special-words/parameters/del") @@ -251,7 +251,7 @@ Mono> withDel(@QueryParam("del") String del, @HeaderParam("accept @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response withDelSync(@QueryParam("del") String del, @HeaderParam("accept") String accept, + Response withDelSync(@HostParam("endpoint") String endpoint, @QueryParam("del") String del, RequestOptions requestOptions, Context context); @Get("/special-words/parameters/elif") @@ -260,7 +260,7 @@ Response withDelSync(@QueryParam("del") String del, @HeaderParam("accept") @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> withElif(@QueryParam("elif") String elif, @HeaderParam("accept") String accept, + Mono> withElif(@HostParam("endpoint") String endpoint, @QueryParam("elif") String elif, RequestOptions requestOptions, Context context); @Get("/special-words/parameters/elif") @@ -269,7 +269,7 @@ Mono> withElif(@QueryParam("elif") String elif, @HeaderParam("acc @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response withElifSync(@QueryParam("elif") String elif, @HeaderParam("accept") String accept, + Response withElifSync(@HostParam("endpoint") String endpoint, @QueryParam("elif") String elif, RequestOptions requestOptions, Context context); @Get("/special-words/parameters/else") @@ -278,7 +278,7 @@ Response withElifSync(@QueryParam("elif") String elif, @HeaderParam("accep @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> withElse(@QueryParam("else") String elseParameter, @HeaderParam("accept") String accept, + Mono> withElse(@HostParam("endpoint") String endpoint, @QueryParam("else") String elseParameter, RequestOptions requestOptions, Context context); @Get("/special-words/parameters/else") @@ -287,7 +287,7 @@ Mono> withElse(@QueryParam("else") String elseParameter, @HeaderP @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response withElseSync(@QueryParam("else") String elseParameter, @HeaderParam("accept") String accept, + Response withElseSync(@HostParam("endpoint") String endpoint, @QueryParam("else") String elseParameter, RequestOptions requestOptions, Context context); @Get("/special-words/parameters/except") @@ -296,7 +296,7 @@ Response withElseSync(@QueryParam("else") String elseParameter, @HeaderPar @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> withExcept(@QueryParam("except") String except, @HeaderParam("accept") String accept, + Mono> withExcept(@HostParam("endpoint") String endpoint, @QueryParam("except") String except, RequestOptions requestOptions, Context context); @Get("/special-words/parameters/except") @@ -305,7 +305,7 @@ Mono> withExcept(@QueryParam("except") String except, @HeaderPara @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response withExceptSync(@QueryParam("except") String except, @HeaderParam("accept") String accept, + Response withExceptSync(@HostParam("endpoint") String endpoint, @QueryParam("except") String except, RequestOptions requestOptions, Context context); @Get("/special-words/parameters/exec") @@ -314,7 +314,7 @@ Response withExceptSync(@QueryParam("except") String except, @HeaderParam( @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> withExec(@QueryParam("exec") String exec, @HeaderParam("accept") String accept, + Mono> withExec(@HostParam("endpoint") String endpoint, @QueryParam("exec") String exec, RequestOptions requestOptions, Context context); @Get("/special-words/parameters/exec") @@ -323,7 +323,7 @@ Mono> withExec(@QueryParam("exec") String exec, @HeaderParam("acc @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response withExecSync(@QueryParam("exec") String exec, @HeaderParam("accept") String accept, + Response withExecSync(@HostParam("endpoint") String endpoint, @QueryParam("exec") String exec, RequestOptions requestOptions, Context context); @Get("/special-words/parameters/finally") @@ -332,8 +332,8 @@ Response withExecSync(@QueryParam("exec") String exec, @HeaderParam("accep @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> withFinally(@QueryParam("finally") String finallyParameter, - @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + Mono> withFinally(@HostParam("endpoint") String endpoint, + @QueryParam("finally") String finallyParameter, RequestOptions requestOptions, Context context); @Get("/special-words/parameters/finally") @ExpectedResponses({ 204 }) @@ -341,8 +341,8 @@ Mono> withFinally(@QueryParam("finally") String finallyParameter, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response withFinallySync(@QueryParam("finally") String finallyParameter, - @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + Response withFinallySync(@HostParam("endpoint") String endpoint, + @QueryParam("finally") String finallyParameter, RequestOptions requestOptions, Context context); @Get("/special-words/parameters/for") @ExpectedResponses({ 204 }) @@ -350,7 +350,7 @@ Response withFinallySync(@QueryParam("finally") String finallyParameter, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> withFor(@QueryParam("for") String forParameter, @HeaderParam("accept") String accept, + Mono> withFor(@HostParam("endpoint") String endpoint, @QueryParam("for") String forParameter, RequestOptions requestOptions, Context context); @Get("/special-words/parameters/for") @@ -359,7 +359,7 @@ Mono> withFor(@QueryParam("for") String forParameter, @HeaderPara @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response withForSync(@QueryParam("for") String forParameter, @HeaderParam("accept") String accept, + Response withForSync(@HostParam("endpoint") String endpoint, @QueryParam("for") String forParameter, RequestOptions requestOptions, Context context); @Get("/special-words/parameters/from") @@ -368,7 +368,7 @@ Response withForSync(@QueryParam("for") String forParameter, @HeaderParam( @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> withFrom(@QueryParam("from") String from, @HeaderParam("accept") String accept, + Mono> withFrom(@HostParam("endpoint") String endpoint, @QueryParam("from") String from, RequestOptions requestOptions, Context context); @Get("/special-words/parameters/from") @@ -377,7 +377,7 @@ Mono> withFrom(@QueryParam("from") String from, @HeaderParam("acc @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response withFromSync(@QueryParam("from") String from, @HeaderParam("accept") String accept, + Response withFromSync(@HostParam("endpoint") String endpoint, @QueryParam("from") String from, RequestOptions requestOptions, Context context); @Get("/special-words/parameters/global") @@ -386,7 +386,7 @@ Response withFromSync(@QueryParam("from") String from, @HeaderParam("accep @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> withGlobal(@QueryParam("global") String global, @HeaderParam("accept") String accept, + Mono> withGlobal(@HostParam("endpoint") String endpoint, @QueryParam("global") String global, RequestOptions requestOptions, Context context); @Get("/special-words/parameters/global") @@ -395,7 +395,7 @@ Mono> withGlobal(@QueryParam("global") String global, @HeaderPara @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response withGlobalSync(@QueryParam("global") String global, @HeaderParam("accept") String accept, + Response withGlobalSync(@HostParam("endpoint") String endpoint, @QueryParam("global") String global, RequestOptions requestOptions, Context context); @Get("/special-words/parameters/if") @@ -404,7 +404,7 @@ Response withGlobalSync(@QueryParam("global") String global, @HeaderParam( @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> withIf(@QueryParam("if") String ifParameter, @HeaderParam("accept") String accept, + Mono> withIf(@HostParam("endpoint") String endpoint, @QueryParam("if") String ifParameter, RequestOptions requestOptions, Context context); @Get("/special-words/parameters/if") @@ -413,7 +413,7 @@ Mono> withIf(@QueryParam("if") String ifParameter, @HeaderParam(" @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response withIfSync(@QueryParam("if") String ifParameter, @HeaderParam("accept") String accept, + Response withIfSync(@HostParam("endpoint") String endpoint, @QueryParam("if") String ifParameter, RequestOptions requestOptions, Context context); @Get("/special-words/parameters/import") @@ -422,8 +422,8 @@ Response withIfSync(@QueryParam("if") String ifParameter, @HeaderParam("ac @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> withImport(@QueryParam("import") String importParameter, - @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + Mono> withImport(@HostParam("endpoint") String endpoint, + @QueryParam("import") String importParameter, RequestOptions requestOptions, Context context); @Get("/special-words/parameters/import") @ExpectedResponses({ 204 }) @@ -431,8 +431,8 @@ Mono> withImport(@QueryParam("import") String importParameter, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response withImportSync(@QueryParam("import") String importParameter, - @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + Response withImportSync(@HostParam("endpoint") String endpoint, + @QueryParam("import") String importParameter, RequestOptions requestOptions, Context context); @Get("/special-words/parameters/in") @ExpectedResponses({ 204 }) @@ -440,7 +440,7 @@ Response withImportSync(@QueryParam("import") String importParameter, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> withIn(@QueryParam("in") String in, @HeaderParam("accept") String accept, + Mono> withIn(@HostParam("endpoint") String endpoint, @QueryParam("in") String in, RequestOptions requestOptions, Context context); @Get("/special-words/parameters/in") @@ -449,7 +449,7 @@ Mono> withIn(@QueryParam("in") String in, @HeaderParam("accept") @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response withInSync(@QueryParam("in") String in, @HeaderParam("accept") String accept, + Response withInSync(@HostParam("endpoint") String endpoint, @QueryParam("in") String in, RequestOptions requestOptions, Context context); @Get("/special-words/parameters/is") @@ -458,7 +458,7 @@ Response withInSync(@QueryParam("in") String in, @HeaderParam("accept") St @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> withIs(@QueryParam("is") String is, @HeaderParam("accept") String accept, + Mono> withIs(@HostParam("endpoint") String endpoint, @QueryParam("is") String is, RequestOptions requestOptions, Context context); @Get("/special-words/parameters/is") @@ -467,7 +467,7 @@ Mono> withIs(@QueryParam("is") String is, @HeaderParam("accept") @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response withIsSync(@QueryParam("is") String is, @HeaderParam("accept") String accept, + Response withIsSync(@HostParam("endpoint") String endpoint, @QueryParam("is") String is, RequestOptions requestOptions, Context context); @Get("/special-words/parameters/lambda") @@ -476,7 +476,7 @@ Response withIsSync(@QueryParam("is") String is, @HeaderParam("accept") St @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> withLambda(@QueryParam("lambda") String lambda, @HeaderParam("accept") String accept, + Mono> withLambda(@HostParam("endpoint") String endpoint, @QueryParam("lambda") String lambda, RequestOptions requestOptions, Context context); @Get("/special-words/parameters/lambda") @@ -485,7 +485,7 @@ Mono> withLambda(@QueryParam("lambda") String lambda, @HeaderPara @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response withLambdaSync(@QueryParam("lambda") String lambda, @HeaderParam("accept") String accept, + Response withLambdaSync(@HostParam("endpoint") String endpoint, @QueryParam("lambda") String lambda, RequestOptions requestOptions, Context context); @Get("/special-words/parameters/not") @@ -494,7 +494,7 @@ Response withLambdaSync(@QueryParam("lambda") String lambda, @HeaderParam( @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> withNot(@QueryParam("not") String not, @HeaderParam("accept") String accept, + Mono> withNot(@HostParam("endpoint") String endpoint, @QueryParam("not") String not, RequestOptions requestOptions, Context context); @Get("/special-words/parameters/not") @@ -503,7 +503,7 @@ Mono> withNot(@QueryParam("not") String not, @HeaderParam("accept @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response withNotSync(@QueryParam("not") String not, @HeaderParam("accept") String accept, + Response withNotSync(@HostParam("endpoint") String endpoint, @QueryParam("not") String not, RequestOptions requestOptions, Context context); @Get("/special-words/parameters/or") @@ -512,7 +512,7 @@ Response withNotSync(@QueryParam("not") String not, @HeaderParam("accept") @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> withOr(@QueryParam("or") String or, @HeaderParam("accept") String accept, + Mono> withOr(@HostParam("endpoint") String endpoint, @QueryParam("or") String or, RequestOptions requestOptions, Context context); @Get("/special-words/parameters/or") @@ -521,7 +521,7 @@ Mono> withOr(@QueryParam("or") String or, @HeaderParam("accept") @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response withOrSync(@QueryParam("or") String or, @HeaderParam("accept") String accept, + Response withOrSync(@HostParam("endpoint") String endpoint, @QueryParam("or") String or, RequestOptions requestOptions, Context context); @Get("/special-words/parameters/pass") @@ -530,7 +530,7 @@ Response withOrSync(@QueryParam("or") String or, @HeaderParam("accept") St @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> withPass(@QueryParam("pass") String pass, @HeaderParam("accept") String accept, + Mono> withPass(@HostParam("endpoint") String endpoint, @QueryParam("pass") String pass, RequestOptions requestOptions, Context context); @Get("/special-words/parameters/pass") @@ -539,7 +539,7 @@ Mono> withPass(@QueryParam("pass") String pass, @HeaderParam("acc @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response withPassSync(@QueryParam("pass") String pass, @HeaderParam("accept") String accept, + Response withPassSync(@HostParam("endpoint") String endpoint, @QueryParam("pass") String pass, RequestOptions requestOptions, Context context); @Get("/special-words/parameters/raise") @@ -548,7 +548,7 @@ Response withPassSync(@QueryParam("pass") String pass, @HeaderParam("accep @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> withRaise(@QueryParam("raise") String raise, @HeaderParam("accept") String accept, + Mono> withRaise(@HostParam("endpoint") String endpoint, @QueryParam("raise") String raise, RequestOptions requestOptions, Context context); @Get("/special-words/parameters/raise") @@ -557,7 +557,7 @@ Mono> withRaise(@QueryParam("raise") String raise, @HeaderParam(" @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response withRaiseSync(@QueryParam("raise") String raise, @HeaderParam("accept") String accept, + Response withRaiseSync(@HostParam("endpoint") String endpoint, @QueryParam("raise") String raise, RequestOptions requestOptions, Context context); @Get("/special-words/parameters/return") @@ -566,8 +566,8 @@ Response withRaiseSync(@QueryParam("raise") String raise, @HeaderParam("ac @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> withReturn(@QueryParam("return") String returnParameter, - @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + Mono> withReturn(@HostParam("endpoint") String endpoint, + @QueryParam("return") String returnParameter, RequestOptions requestOptions, Context context); @Get("/special-words/parameters/return") @ExpectedResponses({ 204 }) @@ -575,8 +575,8 @@ Mono> withReturn(@QueryParam("return") String returnParameter, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response withReturnSync(@QueryParam("return") String returnParameter, - @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + Response withReturnSync(@HostParam("endpoint") String endpoint, + @QueryParam("return") String returnParameter, RequestOptions requestOptions, Context context); @Get("/special-words/parameters/try") @ExpectedResponses({ 204 }) @@ -584,7 +584,7 @@ Response withReturnSync(@QueryParam("return") String returnParameter, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> withTry(@QueryParam("try") String tryParameter, @HeaderParam("accept") String accept, + Mono> withTry(@HostParam("endpoint") String endpoint, @QueryParam("try") String tryParameter, RequestOptions requestOptions, Context context); @Get("/special-words/parameters/try") @@ -593,7 +593,7 @@ Mono> withTry(@QueryParam("try") String tryParameter, @HeaderPara @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response withTrySync(@QueryParam("try") String tryParameter, @HeaderParam("accept") String accept, + Response withTrySync(@HostParam("endpoint") String endpoint, @QueryParam("try") String tryParameter, RequestOptions requestOptions, Context context); @Get("/special-words/parameters/while") @@ -602,8 +602,8 @@ Response withTrySync(@QueryParam("try") String tryParameter, @HeaderParam( @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> withWhile(@QueryParam("while") String whileParameter, @HeaderParam("accept") String accept, - RequestOptions requestOptions, Context context); + Mono> withWhile(@HostParam("endpoint") String endpoint, + @QueryParam("while") String whileParameter, RequestOptions requestOptions, Context context); @Get("/special-words/parameters/while") @ExpectedResponses({ 204 }) @@ -611,7 +611,7 @@ Mono> withWhile(@QueryParam("while") String whileParameter, @Head @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response withWhileSync(@QueryParam("while") String whileParameter, @HeaderParam("accept") String accept, + Response withWhileSync(@HostParam("endpoint") String endpoint, @QueryParam("while") String whileParameter, RequestOptions requestOptions, Context context); @Get("/special-words/parameters/with") @@ -620,7 +620,7 @@ Response withWhileSync(@QueryParam("while") String whileParameter, @Header @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> withWith(@QueryParam("with") String with, @HeaderParam("accept") String accept, + Mono> withWith(@HostParam("endpoint") String endpoint, @QueryParam("with") String with, RequestOptions requestOptions, Context context); @Get("/special-words/parameters/with") @@ -629,7 +629,7 @@ Mono> withWith(@QueryParam("with") String with, @HeaderParam("acc @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response withWithSync(@QueryParam("with") String with, @HeaderParam("accept") String accept, + Response withWithSync(@HostParam("endpoint") String endpoint, @QueryParam("with") String with, RequestOptions requestOptions, Context context); @Get("/special-words/parameters/yield") @@ -638,7 +638,7 @@ Response withWithSync(@QueryParam("with") String with, @HeaderParam("accep @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> withYield(@QueryParam("yield") String yield, @HeaderParam("accept") String accept, + Mono> withYield(@HostParam("endpoint") String endpoint, @QueryParam("yield") String yield, RequestOptions requestOptions, Context context); @Get("/special-words/parameters/yield") @@ -647,7 +647,7 @@ Mono> withYield(@QueryParam("yield") String yield, @HeaderParam(" @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response withYieldSync(@QueryParam("yield") String yield, @HeaderParam("accept") String accept, + Response withYieldSync(@HostParam("endpoint") String endpoint, @QueryParam("yield") String yield, RequestOptions requestOptions, Context context); @Get("/special-words/parameters/cancellationToken") @@ -656,8 +656,8 @@ Response withYieldSync(@QueryParam("yield") String yield, @HeaderParam("ac @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> withCancellationToken(@QueryParam("cancellationToken") String cancellationToken, - @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + Mono> withCancellationToken(@HostParam("endpoint") String endpoint, + @QueryParam("cancellationToken") String cancellationToken, RequestOptions requestOptions, Context context); @Get("/special-words/parameters/cancellationToken") @ExpectedResponses({ 204 }) @@ -665,8 +665,8 @@ Mono> withCancellationToken(@QueryParam("cancellationToken") Stri @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response withCancellationTokenSync(@QueryParam("cancellationToken") String cancellationToken, - @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + Response withCancellationTokenSync(@HostParam("endpoint") String endpoint, + @QueryParam("cancellationToken") String cancellationToken, RequestOptions requestOptions, Context context); } /** @@ -682,8 +682,8 @@ Response withCancellationTokenSync(@QueryParam("cancellationToken") String */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> withAndWithResponseAsync(String and, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.withAnd(and, accept, requestOptions, context)); + return FluxUtil + .withContext(context -> service.withAnd(this.client.getEndpoint(), and, requestOptions, context)); } /** @@ -699,8 +699,7 @@ public Mono> withAndWithResponseAsync(String and, RequestOptions */ @ServiceMethod(returns = ReturnType.SINGLE) public Response withAndWithResponse(String and, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.withAndSync(and, accept, requestOptions, Context.NONE); + return service.withAndSync(this.client.getEndpoint(), and, requestOptions, Context.NONE); } /** @@ -716,8 +715,7 @@ public Response withAndWithResponse(String and, RequestOptions requestOpti */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> withAsWithResponseAsync(String as, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.withAs(as, accept, requestOptions, context)); + return FluxUtil.withContext(context -> service.withAs(this.client.getEndpoint(), as, requestOptions, context)); } /** @@ -733,8 +731,7 @@ public Mono> withAsWithResponseAsync(String as, RequestOptions re */ @ServiceMethod(returns = ReturnType.SINGLE) public Response withAsWithResponse(String as, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.withAsSync(as, accept, requestOptions, Context.NONE); + return service.withAsSync(this.client.getEndpoint(), as, requestOptions, Context.NONE); } /** @@ -750,8 +747,8 @@ public Response withAsWithResponse(String as, RequestOptions requestOption */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> withAssertWithResponseAsync(String assertParameter, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.withAssert(assertParameter, accept, requestOptions, context)); + return FluxUtil.withContext( + context -> service.withAssert(this.client.getEndpoint(), assertParameter, requestOptions, context)); } /** @@ -767,8 +764,7 @@ public Mono> withAssertWithResponseAsync(String assertParameter, */ @ServiceMethod(returns = ReturnType.SINGLE) public Response withAssertWithResponse(String assertParameter, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.withAssertSync(assertParameter, accept, requestOptions, Context.NONE); + return service.withAssertSync(this.client.getEndpoint(), assertParameter, requestOptions, Context.NONE); } /** @@ -784,8 +780,8 @@ public Response withAssertWithResponse(String assertParameter, RequestOpti */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> withAsyncWithResponseAsync(String async, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.withAsync(async, accept, requestOptions, context)); + return FluxUtil + .withContext(context -> service.withAsync(this.client.getEndpoint(), async, requestOptions, context)); } /** @@ -801,8 +797,7 @@ public Mono> withAsyncWithResponseAsync(String async, RequestOpti */ @ServiceMethod(returns = ReturnType.SINGLE) public Response withAsyncWithResponse(String async, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.withAsyncSync(async, accept, requestOptions, Context.NONE); + return service.withAsyncSync(this.client.getEndpoint(), async, requestOptions, Context.NONE); } /** @@ -818,8 +813,8 @@ public Response withAsyncWithResponse(String async, RequestOptions request */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> withAwaitWithResponseAsync(String await, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.withAwait(await, accept, requestOptions, context)); + return FluxUtil + .withContext(context -> service.withAwait(this.client.getEndpoint(), await, requestOptions, context)); } /** @@ -835,8 +830,7 @@ public Mono> withAwaitWithResponseAsync(String await, RequestOpti */ @ServiceMethod(returns = ReturnType.SINGLE) public Response withAwaitWithResponse(String await, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.withAwaitSync(await, accept, requestOptions, Context.NONE); + return service.withAwaitSync(this.client.getEndpoint(), await, requestOptions, Context.NONE); } /** @@ -852,8 +846,8 @@ public Response withAwaitWithResponse(String await, RequestOptions request */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> withBreakWithResponseAsync(String breakParameter, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.withBreak(breakParameter, accept, requestOptions, context)); + return FluxUtil.withContext( + context -> service.withBreak(this.client.getEndpoint(), breakParameter, requestOptions, context)); } /** @@ -869,8 +863,7 @@ public Mono> withBreakWithResponseAsync(String breakParameter, Re */ @ServiceMethod(returns = ReturnType.SINGLE) public Response withBreakWithResponse(String breakParameter, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.withBreakSync(breakParameter, accept, requestOptions, Context.NONE); + return service.withBreakSync(this.client.getEndpoint(), breakParameter, requestOptions, Context.NONE); } /** @@ -886,8 +879,8 @@ public Response withBreakWithResponse(String breakParameter, RequestOption */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> withClassWithResponseAsync(String classParameter, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.withClass(classParameter, accept, requestOptions, context)); + return FluxUtil.withContext( + context -> service.withClass(this.client.getEndpoint(), classParameter, requestOptions, context)); } /** @@ -903,8 +896,7 @@ public Mono> withClassWithResponseAsync(String classParameter, Re */ @ServiceMethod(returns = ReturnType.SINGLE) public Response withClassWithResponse(String classParameter, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.withClassSync(classParameter, accept, requestOptions, Context.NONE); + return service.withClassSync(this.client.getEndpoint(), classParameter, requestOptions, Context.NONE); } /** @@ -920,8 +912,8 @@ public Response withClassWithResponse(String classParameter, RequestOption */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> withConstructorWithResponseAsync(String constructor, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.withConstructor(constructor, accept, requestOptions, context)); + return FluxUtil.withContext( + context -> service.withConstructor(this.client.getEndpoint(), constructor, requestOptions, context)); } /** @@ -937,8 +929,7 @@ public Mono> withConstructorWithResponseAsync(String constructor, */ @ServiceMethod(returns = ReturnType.SINGLE) public Response withConstructorWithResponse(String constructor, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.withConstructorSync(constructor, accept, requestOptions, Context.NONE); + return service.withConstructorSync(this.client.getEndpoint(), constructor, requestOptions, Context.NONE); } /** @@ -954,9 +945,8 @@ public Response withConstructorWithResponse(String constructor, RequestOpt */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> withContinueWithResponseAsync(String continueParameter, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil - .withContext(context -> service.withContinue(continueParameter, accept, requestOptions, context)); + return FluxUtil.withContext( + context -> service.withContinue(this.client.getEndpoint(), continueParameter, requestOptions, context)); } /** @@ -972,8 +962,7 @@ public Mono> withContinueWithResponseAsync(String continueParamet */ @ServiceMethod(returns = ReturnType.SINGLE) public Response withContinueWithResponse(String continueParameter, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.withContinueSync(continueParameter, accept, requestOptions, Context.NONE); + return service.withContinueSync(this.client.getEndpoint(), continueParameter, requestOptions, Context.NONE); } /** @@ -989,8 +978,8 @@ public Response withContinueWithResponse(String continueParameter, Request */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> withDefWithResponseAsync(String def, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.withDef(def, accept, requestOptions, context)); + return FluxUtil + .withContext(context -> service.withDef(this.client.getEndpoint(), def, requestOptions, context)); } /** @@ -1006,8 +995,7 @@ public Mono> withDefWithResponseAsync(String def, RequestOptions */ @ServiceMethod(returns = ReturnType.SINGLE) public Response withDefWithResponse(String def, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.withDefSync(def, accept, requestOptions, Context.NONE); + return service.withDefSync(this.client.getEndpoint(), def, requestOptions, Context.NONE); } /** @@ -1023,8 +1011,8 @@ public Response withDefWithResponse(String def, RequestOptions requestOpti */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> withDelWithResponseAsync(String del, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.withDel(del, accept, requestOptions, context)); + return FluxUtil + .withContext(context -> service.withDel(this.client.getEndpoint(), del, requestOptions, context)); } /** @@ -1040,8 +1028,7 @@ public Mono> withDelWithResponseAsync(String del, RequestOptions */ @ServiceMethod(returns = ReturnType.SINGLE) public Response withDelWithResponse(String del, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.withDelSync(del, accept, requestOptions, Context.NONE); + return service.withDelSync(this.client.getEndpoint(), del, requestOptions, Context.NONE); } /** @@ -1057,8 +1044,8 @@ public Response withDelWithResponse(String del, RequestOptions requestOpti */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> withElifWithResponseAsync(String elif, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.withElif(elif, accept, requestOptions, context)); + return FluxUtil + .withContext(context -> service.withElif(this.client.getEndpoint(), elif, requestOptions, context)); } /** @@ -1074,8 +1061,7 @@ public Mono> withElifWithResponseAsync(String elif, RequestOption */ @ServiceMethod(returns = ReturnType.SINGLE) public Response withElifWithResponse(String elif, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.withElifSync(elif, accept, requestOptions, Context.NONE); + return service.withElifSync(this.client.getEndpoint(), elif, requestOptions, Context.NONE); } /** @@ -1091,8 +1077,8 @@ public Response withElifWithResponse(String elif, RequestOptions requestOp */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> withElseWithResponseAsync(String elseParameter, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.withElse(elseParameter, accept, requestOptions, context)); + return FluxUtil.withContext( + context -> service.withElse(this.client.getEndpoint(), elseParameter, requestOptions, context)); } /** @@ -1108,8 +1094,7 @@ public Mono> withElseWithResponseAsync(String elseParameter, Requ */ @ServiceMethod(returns = ReturnType.SINGLE) public Response withElseWithResponse(String elseParameter, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.withElseSync(elseParameter, accept, requestOptions, Context.NONE); + return service.withElseSync(this.client.getEndpoint(), elseParameter, requestOptions, Context.NONE); } /** @@ -1125,8 +1110,8 @@ public Response withElseWithResponse(String elseParameter, RequestOptions */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> withExceptWithResponseAsync(String except, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.withExcept(except, accept, requestOptions, context)); + return FluxUtil + .withContext(context -> service.withExcept(this.client.getEndpoint(), except, requestOptions, context)); } /** @@ -1142,8 +1127,7 @@ public Mono> withExceptWithResponseAsync(String except, RequestOp */ @ServiceMethod(returns = ReturnType.SINGLE) public Response withExceptWithResponse(String except, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.withExceptSync(except, accept, requestOptions, Context.NONE); + return service.withExceptSync(this.client.getEndpoint(), except, requestOptions, Context.NONE); } /** @@ -1159,8 +1143,8 @@ public Response withExceptWithResponse(String except, RequestOptions reque */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> withExecWithResponseAsync(String exec, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.withExec(exec, accept, requestOptions, context)); + return FluxUtil + .withContext(context -> service.withExec(this.client.getEndpoint(), exec, requestOptions, context)); } /** @@ -1176,8 +1160,7 @@ public Mono> withExecWithResponseAsync(String exec, RequestOption */ @ServiceMethod(returns = ReturnType.SINGLE) public Response withExecWithResponse(String exec, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.withExecSync(exec, accept, requestOptions, Context.NONE); + return service.withExecSync(this.client.getEndpoint(), exec, requestOptions, Context.NONE); } /** @@ -1193,8 +1176,8 @@ public Response withExecWithResponse(String exec, RequestOptions requestOp */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> withFinallyWithResponseAsync(String finallyParameter, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.withFinally(finallyParameter, accept, requestOptions, context)); + return FluxUtil.withContext( + context -> service.withFinally(this.client.getEndpoint(), finallyParameter, requestOptions, context)); } /** @@ -1210,8 +1193,7 @@ public Mono> withFinallyWithResponseAsync(String finallyParameter */ @ServiceMethod(returns = ReturnType.SINGLE) public Response withFinallyWithResponse(String finallyParameter, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.withFinallySync(finallyParameter, accept, requestOptions, Context.NONE); + return service.withFinallySync(this.client.getEndpoint(), finallyParameter, requestOptions, Context.NONE); } /** @@ -1227,8 +1209,8 @@ public Response withFinallyWithResponse(String finallyParameter, RequestOp */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> withForWithResponseAsync(String forParameter, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.withFor(forParameter, accept, requestOptions, context)); + return FluxUtil + .withContext(context -> service.withFor(this.client.getEndpoint(), forParameter, requestOptions, context)); } /** @@ -1244,8 +1226,7 @@ public Mono> withForWithResponseAsync(String forParameter, Reques */ @ServiceMethod(returns = ReturnType.SINGLE) public Response withForWithResponse(String forParameter, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.withForSync(forParameter, accept, requestOptions, Context.NONE); + return service.withForSync(this.client.getEndpoint(), forParameter, requestOptions, Context.NONE); } /** @@ -1261,8 +1242,8 @@ public Response withForWithResponse(String forParameter, RequestOptions re */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> withFromWithResponseAsync(String from, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.withFrom(from, accept, requestOptions, context)); + return FluxUtil + .withContext(context -> service.withFrom(this.client.getEndpoint(), from, requestOptions, context)); } /** @@ -1278,8 +1259,7 @@ public Mono> withFromWithResponseAsync(String from, RequestOption */ @ServiceMethod(returns = ReturnType.SINGLE) public Response withFromWithResponse(String from, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.withFromSync(from, accept, requestOptions, Context.NONE); + return service.withFromSync(this.client.getEndpoint(), from, requestOptions, Context.NONE); } /** @@ -1295,8 +1275,8 @@ public Response withFromWithResponse(String from, RequestOptions requestOp */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> withGlobalWithResponseAsync(String global, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.withGlobal(global, accept, requestOptions, context)); + return FluxUtil + .withContext(context -> service.withGlobal(this.client.getEndpoint(), global, requestOptions, context)); } /** @@ -1312,8 +1292,7 @@ public Mono> withGlobalWithResponseAsync(String global, RequestOp */ @ServiceMethod(returns = ReturnType.SINGLE) public Response withGlobalWithResponse(String global, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.withGlobalSync(global, accept, requestOptions, Context.NONE); + return service.withGlobalSync(this.client.getEndpoint(), global, requestOptions, Context.NONE); } /** @@ -1329,8 +1308,8 @@ public Response withGlobalWithResponse(String global, RequestOptions reque */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> withIfWithResponseAsync(String ifParameter, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.withIf(ifParameter, accept, requestOptions, context)); + return FluxUtil + .withContext(context -> service.withIf(this.client.getEndpoint(), ifParameter, requestOptions, context)); } /** @@ -1346,8 +1325,7 @@ public Mono> withIfWithResponseAsync(String ifParameter, RequestO */ @ServiceMethod(returns = ReturnType.SINGLE) public Response withIfWithResponse(String ifParameter, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.withIfSync(ifParameter, accept, requestOptions, Context.NONE); + return service.withIfSync(this.client.getEndpoint(), ifParameter, requestOptions, Context.NONE); } /** @@ -1363,8 +1341,8 @@ public Response withIfWithResponse(String ifParameter, RequestOptions requ */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> withImportWithResponseAsync(String importParameter, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.withImport(importParameter, accept, requestOptions, context)); + return FluxUtil.withContext( + context -> service.withImport(this.client.getEndpoint(), importParameter, requestOptions, context)); } /** @@ -1380,8 +1358,7 @@ public Mono> withImportWithResponseAsync(String importParameter, */ @ServiceMethod(returns = ReturnType.SINGLE) public Response withImportWithResponse(String importParameter, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.withImportSync(importParameter, accept, requestOptions, Context.NONE); + return service.withImportSync(this.client.getEndpoint(), importParameter, requestOptions, Context.NONE); } /** @@ -1397,8 +1374,7 @@ public Response withImportWithResponse(String importParameter, RequestOpti */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> withInWithResponseAsync(String in, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.withIn(in, accept, requestOptions, context)); + return FluxUtil.withContext(context -> service.withIn(this.client.getEndpoint(), in, requestOptions, context)); } /** @@ -1414,8 +1390,7 @@ public Mono> withInWithResponseAsync(String in, RequestOptions re */ @ServiceMethod(returns = ReturnType.SINGLE) public Response withInWithResponse(String in, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.withInSync(in, accept, requestOptions, Context.NONE); + return service.withInSync(this.client.getEndpoint(), in, requestOptions, Context.NONE); } /** @@ -1431,8 +1406,7 @@ public Response withInWithResponse(String in, RequestOptions requestOption */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> withIsWithResponseAsync(String is, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.withIs(is, accept, requestOptions, context)); + return FluxUtil.withContext(context -> service.withIs(this.client.getEndpoint(), is, requestOptions, context)); } /** @@ -1448,8 +1422,7 @@ public Mono> withIsWithResponseAsync(String is, RequestOptions re */ @ServiceMethod(returns = ReturnType.SINGLE) public Response withIsWithResponse(String is, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.withIsSync(is, accept, requestOptions, Context.NONE); + return service.withIsSync(this.client.getEndpoint(), is, requestOptions, Context.NONE); } /** @@ -1465,8 +1438,8 @@ public Response withIsWithResponse(String is, RequestOptions requestOption */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> withLambdaWithResponseAsync(String lambda, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.withLambda(lambda, accept, requestOptions, context)); + return FluxUtil + .withContext(context -> service.withLambda(this.client.getEndpoint(), lambda, requestOptions, context)); } /** @@ -1482,8 +1455,7 @@ public Mono> withLambdaWithResponseAsync(String lambda, RequestOp */ @ServiceMethod(returns = ReturnType.SINGLE) public Response withLambdaWithResponse(String lambda, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.withLambdaSync(lambda, accept, requestOptions, Context.NONE); + return service.withLambdaSync(this.client.getEndpoint(), lambda, requestOptions, Context.NONE); } /** @@ -1499,8 +1471,8 @@ public Response withLambdaWithResponse(String lambda, RequestOptions reque */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> withNotWithResponseAsync(String not, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.withNot(not, accept, requestOptions, context)); + return FluxUtil + .withContext(context -> service.withNot(this.client.getEndpoint(), not, requestOptions, context)); } /** @@ -1516,8 +1488,7 @@ public Mono> withNotWithResponseAsync(String not, RequestOptions */ @ServiceMethod(returns = ReturnType.SINGLE) public Response withNotWithResponse(String not, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.withNotSync(not, accept, requestOptions, Context.NONE); + return service.withNotSync(this.client.getEndpoint(), not, requestOptions, Context.NONE); } /** @@ -1533,8 +1504,7 @@ public Response withNotWithResponse(String not, RequestOptions requestOpti */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> withOrWithResponseAsync(String or, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.withOr(or, accept, requestOptions, context)); + return FluxUtil.withContext(context -> service.withOr(this.client.getEndpoint(), or, requestOptions, context)); } /** @@ -1550,8 +1520,7 @@ public Mono> withOrWithResponseAsync(String or, RequestOptions re */ @ServiceMethod(returns = ReturnType.SINGLE) public Response withOrWithResponse(String or, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.withOrSync(or, accept, requestOptions, Context.NONE); + return service.withOrSync(this.client.getEndpoint(), or, requestOptions, Context.NONE); } /** @@ -1567,8 +1536,8 @@ public Response withOrWithResponse(String or, RequestOptions requestOption */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> withPassWithResponseAsync(String pass, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.withPass(pass, accept, requestOptions, context)); + return FluxUtil + .withContext(context -> service.withPass(this.client.getEndpoint(), pass, requestOptions, context)); } /** @@ -1584,8 +1553,7 @@ public Mono> withPassWithResponseAsync(String pass, RequestOption */ @ServiceMethod(returns = ReturnType.SINGLE) public Response withPassWithResponse(String pass, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.withPassSync(pass, accept, requestOptions, Context.NONE); + return service.withPassSync(this.client.getEndpoint(), pass, requestOptions, Context.NONE); } /** @@ -1601,8 +1569,8 @@ public Response withPassWithResponse(String pass, RequestOptions requestOp */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> withRaiseWithResponseAsync(String raise, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.withRaise(raise, accept, requestOptions, context)); + return FluxUtil + .withContext(context -> service.withRaise(this.client.getEndpoint(), raise, requestOptions, context)); } /** @@ -1618,8 +1586,7 @@ public Mono> withRaiseWithResponseAsync(String raise, RequestOpti */ @ServiceMethod(returns = ReturnType.SINGLE) public Response withRaiseWithResponse(String raise, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.withRaiseSync(raise, accept, requestOptions, Context.NONE); + return service.withRaiseSync(this.client.getEndpoint(), raise, requestOptions, Context.NONE); } /** @@ -1635,8 +1602,8 @@ public Response withRaiseWithResponse(String raise, RequestOptions request */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> withReturnWithResponseAsync(String returnParameter, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.withReturn(returnParameter, accept, requestOptions, context)); + return FluxUtil.withContext( + context -> service.withReturn(this.client.getEndpoint(), returnParameter, requestOptions, context)); } /** @@ -1652,8 +1619,7 @@ public Mono> withReturnWithResponseAsync(String returnParameter, */ @ServiceMethod(returns = ReturnType.SINGLE) public Response withReturnWithResponse(String returnParameter, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.withReturnSync(returnParameter, accept, requestOptions, Context.NONE); + return service.withReturnSync(this.client.getEndpoint(), returnParameter, requestOptions, Context.NONE); } /** @@ -1669,8 +1635,8 @@ public Response withReturnWithResponse(String returnParameter, RequestOpti */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> withTryWithResponseAsync(String tryParameter, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.withTry(tryParameter, accept, requestOptions, context)); + return FluxUtil + .withContext(context -> service.withTry(this.client.getEndpoint(), tryParameter, requestOptions, context)); } /** @@ -1686,8 +1652,7 @@ public Mono> withTryWithResponseAsync(String tryParameter, Reques */ @ServiceMethod(returns = ReturnType.SINGLE) public Response withTryWithResponse(String tryParameter, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.withTrySync(tryParameter, accept, requestOptions, Context.NONE); + return service.withTrySync(this.client.getEndpoint(), tryParameter, requestOptions, Context.NONE); } /** @@ -1703,8 +1668,8 @@ public Response withTryWithResponse(String tryParameter, RequestOptions re */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> withWhileWithResponseAsync(String whileParameter, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.withWhile(whileParameter, accept, requestOptions, context)); + return FluxUtil.withContext( + context -> service.withWhile(this.client.getEndpoint(), whileParameter, requestOptions, context)); } /** @@ -1720,8 +1685,7 @@ public Mono> withWhileWithResponseAsync(String whileParameter, Re */ @ServiceMethod(returns = ReturnType.SINGLE) public Response withWhileWithResponse(String whileParameter, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.withWhileSync(whileParameter, accept, requestOptions, Context.NONE); + return service.withWhileSync(this.client.getEndpoint(), whileParameter, requestOptions, Context.NONE); } /** @@ -1737,8 +1701,8 @@ public Response withWhileWithResponse(String whileParameter, RequestOption */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> withWithWithResponseAsync(String with, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.withWith(with, accept, requestOptions, context)); + return FluxUtil + .withContext(context -> service.withWith(this.client.getEndpoint(), with, requestOptions, context)); } /** @@ -1754,8 +1718,7 @@ public Mono> withWithWithResponseAsync(String with, RequestOption */ @ServiceMethod(returns = ReturnType.SINGLE) public Response withWithWithResponse(String with, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.withWithSync(with, accept, requestOptions, Context.NONE); + return service.withWithSync(this.client.getEndpoint(), with, requestOptions, Context.NONE); } /** @@ -1771,8 +1734,8 @@ public Response withWithWithResponse(String with, RequestOptions requestOp */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> withYieldWithResponseAsync(String yield, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.withYield(yield, accept, requestOptions, context)); + return FluxUtil + .withContext(context -> service.withYield(this.client.getEndpoint(), yield, requestOptions, context)); } /** @@ -1788,8 +1751,7 @@ public Mono> withYieldWithResponseAsync(String yield, RequestOpti */ @ServiceMethod(returns = ReturnType.SINGLE) public Response withYieldWithResponse(String yield, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.withYieldSync(yield, accept, requestOptions, Context.NONE); + return service.withYieldSync(this.client.getEndpoint(), yield, requestOptions, Context.NONE); } /** @@ -1806,9 +1768,8 @@ public Response withYieldWithResponse(String yield, RequestOptions request @ServiceMethod(returns = ReturnType.SINGLE) public Mono> withCancellationTokenWithResponseAsync(String cancellationToken, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil - .withContext(context -> service.withCancellationToken(cancellationToken, accept, requestOptions, context)); + return FluxUtil.withContext(context -> service.withCancellationToken(this.client.getEndpoint(), + cancellationToken, requestOptions, context)); } /** @@ -1824,7 +1785,7 @@ public Mono> withCancellationTokenWithResponseAsync(String cancel */ @ServiceMethod(returns = ReturnType.SINGLE) public Response withCancellationTokenWithResponse(String cancellationToken, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.withCancellationTokenSync(cancellationToken, accept, requestOptions, Context.NONE); + return service.withCancellationTokenSync(this.client.getEndpoint(), cancellationToken, requestOptions, + Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/specialwords/implementation/SpecialWordsClientImpl.java b/typespec-tests/src/main/java/com/specialwords/implementation/SpecialWordsClientImpl.java index ad1725213a..8ffa098671 100644 --- a/typespec-tests/src/main/java/com/specialwords/implementation/SpecialWordsClientImpl.java +++ b/typespec-tests/src/main/java/com/specialwords/implementation/SpecialWordsClientImpl.java @@ -15,6 +15,20 @@ * 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. */ @@ -101,19 +115,22 @@ public ParametersImpl getParameters() { /** * Initializes an instance of SpecialWordsClient client. + * + * @param endpoint Service host. */ - public SpecialWordsClientImpl() { + public SpecialWordsClientImpl(String endpoint) { this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), - JacksonAdapter.createDefaultSerializerAdapter()); + 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) { - this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter()); + public SpecialWordsClientImpl(HttpPipeline httpPipeline, String endpoint) { + this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint); } /** @@ -121,10 +138,12 @@ public SpecialWordsClientImpl(HttpPipeline httpPipeline) { * * @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) { + 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); diff --git a/typespec-tests/src/main/java/com/type/array/ArrayClientBuilder.java b/typespec-tests/src/main/java/com/type/array/ArrayClientBuilder.java index 5ac537539d..ff37bf08e4 100644 --- a/typespec-tests/src/main/java/com/type/array/ArrayClientBuilder.java +++ b/typespec-tests/src/main/java/com/type/array/ArrayClientBuilder.java @@ -7,6 +7,7 @@ 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; @@ -69,7 +70,8 @@ NullableBooleanValueAsyncClient.class, NullableStringValueAsyncClient.class, NullableModelValueAsyncClient.class }) -public final class ArrayClientBuilder implements HttpTrait, ConfigurationTrait { +public final class ArrayClientBuilder implements HttpTrait, ConfigurationTrait, + EndpointTrait { @Generated private static final String SDK_NAME = "name"; @@ -200,6 +202,22 @@ public ArrayClientBuilder configuration(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. */ @@ -227,7 +245,9 @@ public ArrayClientBuilder retryPolicy(RetryPolicy retryPolicy) { private ArrayClientImpl buildInnerClient() { this.validateClient(); HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); - ArrayClientImpl client = new ArrayClientImpl(localPipeline, JacksonAdapter.createDefaultSerializerAdapter()); + String localEndpoint = (endpoint != null) ? endpoint : "http://localhost:3000"; + ArrayClientImpl client + = new ArrayClientImpl(localPipeline, JacksonAdapter.createDefaultSerializerAdapter(), localEndpoint); return client; } diff --git a/typespec-tests/src/main/java/com/type/array/implementation/ArrayClientImpl.java b/typespec-tests/src/main/java/com/type/array/implementation/ArrayClientImpl.java index cc873e7457..f2cac991f5 100644 --- a/typespec-tests/src/main/java/com/type/array/implementation/ArrayClientImpl.java +++ b/typespec-tests/src/main/java/com/type/array/implementation/ArrayClientImpl.java @@ -15,6 +15,20 @@ * 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. */ @@ -241,19 +255,22 @@ public NullableModelValuesImpl getNullableModelValues() { /** * Initializes an instance of ArrayClient client. + * + * @param endpoint Service host. */ - public ArrayClientImpl() { + public ArrayClientImpl(String endpoint) { this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), - JacksonAdapter.createDefaultSerializerAdapter()); + 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) { - this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter()); + public ArrayClientImpl(HttpPipeline httpPipeline, String endpoint) { + this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint); } /** @@ -261,10 +278,12 @@ public ArrayClientImpl(HttpPipeline httpPipeline) { * * @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) { + 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); diff --git a/typespec-tests/src/main/java/com/type/array/implementation/BooleanValuesImpl.java b/typespec-tests/src/main/java/com/type/array/implementation/BooleanValuesImpl.java index 1fe41e98f7..3f0d5b06a3 100644 --- a/typespec-tests/src/main/java/com/type/array/implementation/BooleanValuesImpl.java +++ b/typespec-tests/src/main/java/com/type/array/implementation/BooleanValuesImpl.java @@ -9,6 +9,7 @@ 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; @@ -55,7 +56,7 @@ public final class BooleanValuesImpl { * The interface defining all the services for ArrayClientBooleanValues to be used by the proxy service to perform * REST calls. */ - @Host("http://localhost:3000") + @Host("{endpoint}") @ServiceInterface(name = "ArrayClientBooleanVa") public interface BooleanValuesService { @Get("/type/array/boolean") @@ -64,8 +65,8 @@ public interface BooleanValuesService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> get(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Get("/type/array/boolean") @ExpectedResponses({ 200 }) @@ -73,8 +74,8 @@ Mono> get(@HeaderParam("accept") String accept, RequestOpti @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response getSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Put("/type/array/boolean") @ExpectedResponses({ 204 }) @@ -82,7 +83,8 @@ Response getSync(@HeaderParam("accept") String accept, RequestOption @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> put(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, + Mono> put(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); @Put("/type/array/boolean") @@ -91,8 +93,8 @@ Mono> put(@HeaderParam("accept") String accept, @BodyParam("appli @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response putSync(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, - RequestOptions requestOptions, Context context); + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); } /** @@ -115,7 +117,7 @@ Response putSync(@HeaderParam("accept") String accept, @BodyParam("applica @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getWithResponseAsync(RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.get(accept, requestOptions, context)); + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); } /** @@ -138,7 +140,7 @@ public Mono> getWithResponseAsync(RequestOptions requestOpt @ServiceMethod(returns = ReturnType.SINGLE) public Response getWithResponse(RequestOptions requestOptions) { final String accept = "application/json"; - return service.getSync(accept, requestOptions, Context.NONE); + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); } /** @@ -161,8 +163,9 @@ public Response getWithResponse(RequestOptions requestOptions) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> putWithResponseAsync(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.put(accept, body, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.put(this.client.getEndpoint(), contentType, body, requestOptions, context)); } /** @@ -185,7 +188,7 @@ public Mono> putWithResponseAsync(BinaryData body, RequestOptions */ @ServiceMethod(returns = ReturnType.SINGLE) public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.putSync(accept, body, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/type/array/implementation/DatetimeValuesImpl.java b/typespec-tests/src/main/java/com/type/array/implementation/DatetimeValuesImpl.java index bf57043843..7878448bf2 100644 --- a/typespec-tests/src/main/java/com/type/array/implementation/DatetimeValuesImpl.java +++ b/typespec-tests/src/main/java/com/type/array/implementation/DatetimeValuesImpl.java @@ -9,6 +9,7 @@ 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; @@ -55,7 +56,7 @@ public final class DatetimeValuesImpl { * The interface defining all the services for ArrayClientDatetimeValues to be used by the proxy service to perform * REST calls. */ - @Host("http://localhost:3000") + @Host("{endpoint}") @ServiceInterface(name = "ArrayClientDatetimeV") public interface DatetimeValuesService { @Get("/type/array/datetime") @@ -64,8 +65,8 @@ public interface DatetimeValuesService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> get(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Get("/type/array/datetime") @ExpectedResponses({ 200 }) @@ -73,8 +74,8 @@ Mono> get(@HeaderParam("accept") String accept, RequestOpti @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response getSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Put("/type/array/datetime") @ExpectedResponses({ 204 }) @@ -82,7 +83,8 @@ Response getSync(@HeaderParam("accept") String accept, RequestOption @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> put(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, + Mono> put(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); @Put("/type/array/datetime") @@ -91,8 +93,8 @@ Mono> put(@HeaderParam("accept") String accept, @BodyParam("appli @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response putSync(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, - RequestOptions requestOptions, Context context); + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); } /** @@ -115,7 +117,7 @@ Response putSync(@HeaderParam("accept") String accept, @BodyParam("applica @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getWithResponseAsync(RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.get(accept, requestOptions, context)); + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); } /** @@ -138,7 +140,7 @@ public Mono> getWithResponseAsync(RequestOptions requestOpt @ServiceMethod(returns = ReturnType.SINGLE) public Response getWithResponse(RequestOptions requestOptions) { final String accept = "application/json"; - return service.getSync(accept, requestOptions, Context.NONE); + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); } /** @@ -161,8 +163,9 @@ public Response getWithResponse(RequestOptions requestOptions) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> putWithResponseAsync(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.put(accept, body, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.put(this.client.getEndpoint(), contentType, body, requestOptions, context)); } /** @@ -185,7 +188,7 @@ public Mono> putWithResponseAsync(BinaryData body, RequestOptions */ @ServiceMethod(returns = ReturnType.SINGLE) public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.putSync(accept, body, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/type/array/implementation/DurationValuesImpl.java b/typespec-tests/src/main/java/com/type/array/implementation/DurationValuesImpl.java index 2ad8d29b75..bdb0253104 100644 --- a/typespec-tests/src/main/java/com/type/array/implementation/DurationValuesImpl.java +++ b/typespec-tests/src/main/java/com/type/array/implementation/DurationValuesImpl.java @@ -9,6 +9,7 @@ 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; @@ -55,7 +56,7 @@ public final class DurationValuesImpl { * The interface defining all the services for ArrayClientDurationValues to be used by the proxy service to perform * REST calls. */ - @Host("http://localhost:3000") + @Host("{endpoint}") @ServiceInterface(name = "ArrayClientDurationV") public interface DurationValuesService { @Get("/type/array/duration") @@ -64,8 +65,8 @@ public interface DurationValuesService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> get(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Get("/type/array/duration") @ExpectedResponses({ 200 }) @@ -73,8 +74,8 @@ Mono> get(@HeaderParam("accept") String accept, RequestOpti @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response getSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Put("/type/array/duration") @ExpectedResponses({ 204 }) @@ -82,7 +83,8 @@ Response getSync(@HeaderParam("accept") String accept, RequestOption @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> put(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, + Mono> put(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); @Put("/type/array/duration") @@ -91,8 +93,8 @@ Mono> put(@HeaderParam("accept") String accept, @BodyParam("appli @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response putSync(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, - RequestOptions requestOptions, Context context); + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); } /** @@ -115,7 +117,7 @@ Response putSync(@HeaderParam("accept") String accept, @BodyParam("applica @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getWithResponseAsync(RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.get(accept, requestOptions, context)); + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); } /** @@ -138,7 +140,7 @@ public Mono> getWithResponseAsync(RequestOptions requestOpt @ServiceMethod(returns = ReturnType.SINGLE) public Response getWithResponse(RequestOptions requestOptions) { final String accept = "application/json"; - return service.getSync(accept, requestOptions, Context.NONE); + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); } /** @@ -161,8 +163,9 @@ public Response getWithResponse(RequestOptions requestOptions) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> putWithResponseAsync(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.put(accept, body, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.put(this.client.getEndpoint(), contentType, body, requestOptions, context)); } /** @@ -185,7 +188,7 @@ public Mono> putWithResponseAsync(BinaryData body, RequestOptions */ @ServiceMethod(returns = ReturnType.SINGLE) public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.putSync(accept, body, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/type/array/implementation/Float32ValuesImpl.java b/typespec-tests/src/main/java/com/type/array/implementation/Float32ValuesImpl.java index 9ff1844849..3090e9b8cc 100644 --- a/typespec-tests/src/main/java/com/type/array/implementation/Float32ValuesImpl.java +++ b/typespec-tests/src/main/java/com/type/array/implementation/Float32ValuesImpl.java @@ -9,6 +9,7 @@ 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; @@ -55,7 +56,7 @@ public final class Float32ValuesImpl { * The interface defining all the services for ArrayClientFloat32Values to be used by the proxy service to perform * REST calls. */ - @Host("http://localhost:3000") + @Host("{endpoint}") @ServiceInterface(name = "ArrayClientFloat32Va") public interface Float32ValuesService { @Get("/type/array/float32") @@ -64,8 +65,8 @@ public interface Float32ValuesService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> get(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Get("/type/array/float32") @ExpectedResponses({ 200 }) @@ -73,8 +74,8 @@ Mono> get(@HeaderParam("accept") String accept, RequestOpti @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response getSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Put("/type/array/float32") @ExpectedResponses({ 204 }) @@ -82,7 +83,8 @@ Response getSync(@HeaderParam("accept") String accept, RequestOption @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> put(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, + Mono> put(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); @Put("/type/array/float32") @@ -91,8 +93,8 @@ Mono> put(@HeaderParam("accept") String accept, @BodyParam("appli @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response putSync(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, - RequestOptions requestOptions, Context context); + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); } /** @@ -115,7 +117,7 @@ Response putSync(@HeaderParam("accept") String accept, @BodyParam("applica @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getWithResponseAsync(RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.get(accept, requestOptions, context)); + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); } /** @@ -138,7 +140,7 @@ public Mono> getWithResponseAsync(RequestOptions requestOpt @ServiceMethod(returns = ReturnType.SINGLE) public Response getWithResponse(RequestOptions requestOptions) { final String accept = "application/json"; - return service.getSync(accept, requestOptions, Context.NONE); + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); } /** @@ -161,8 +163,9 @@ public Response getWithResponse(RequestOptions requestOptions) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> putWithResponseAsync(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.put(accept, body, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.put(this.client.getEndpoint(), contentType, body, requestOptions, context)); } /** @@ -185,7 +188,7 @@ public Mono> putWithResponseAsync(BinaryData body, RequestOptions */ @ServiceMethod(returns = ReturnType.SINGLE) public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.putSync(accept, body, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/type/array/implementation/Int32ValuesImpl.java b/typespec-tests/src/main/java/com/type/array/implementation/Int32ValuesImpl.java index 93c087d948..7a32bda1c4 100644 --- a/typespec-tests/src/main/java/com/type/array/implementation/Int32ValuesImpl.java +++ b/typespec-tests/src/main/java/com/type/array/implementation/Int32ValuesImpl.java @@ -9,6 +9,7 @@ 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; @@ -55,7 +56,7 @@ public final class Int32ValuesImpl { * The interface defining all the services for ArrayClientInt32Values to be used by the proxy service to perform * REST calls. */ - @Host("http://localhost:3000") + @Host("{endpoint}") @ServiceInterface(name = "ArrayClientInt32Valu") public interface Int32ValuesService { @Get("/type/array/int32") @@ -64,8 +65,8 @@ public interface Int32ValuesService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> get(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Get("/type/array/int32") @ExpectedResponses({ 200 }) @@ -73,8 +74,8 @@ Mono> get(@HeaderParam("accept") String accept, RequestOpti @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response getSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Put("/type/array/int32") @ExpectedResponses({ 204 }) @@ -82,7 +83,8 @@ Response getSync(@HeaderParam("accept") String accept, RequestOption @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> put(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, + Mono> put(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); @Put("/type/array/int32") @@ -91,8 +93,8 @@ Mono> put(@HeaderParam("accept") String accept, @BodyParam("appli @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response putSync(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, - RequestOptions requestOptions, Context context); + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); } /** @@ -115,7 +117,7 @@ Response putSync(@HeaderParam("accept") String accept, @BodyParam("applica @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getWithResponseAsync(RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.get(accept, requestOptions, context)); + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); } /** @@ -138,7 +140,7 @@ public Mono> getWithResponseAsync(RequestOptions requestOpt @ServiceMethod(returns = ReturnType.SINGLE) public Response getWithResponse(RequestOptions requestOptions) { final String accept = "application/json"; - return service.getSync(accept, requestOptions, Context.NONE); + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); } /** @@ -161,8 +163,9 @@ public Response getWithResponse(RequestOptions requestOptions) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> putWithResponseAsync(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.put(accept, body, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.put(this.client.getEndpoint(), contentType, body, requestOptions, context)); } /** @@ -185,7 +188,7 @@ public Mono> putWithResponseAsync(BinaryData body, RequestOptions */ @ServiceMethod(returns = ReturnType.SINGLE) public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.putSync(accept, body, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/type/array/implementation/Int64ValuesImpl.java b/typespec-tests/src/main/java/com/type/array/implementation/Int64ValuesImpl.java index 5001f0f289..0ee68b4174 100644 --- a/typespec-tests/src/main/java/com/type/array/implementation/Int64ValuesImpl.java +++ b/typespec-tests/src/main/java/com/type/array/implementation/Int64ValuesImpl.java @@ -9,6 +9,7 @@ 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; @@ -55,7 +56,7 @@ public final class Int64ValuesImpl { * The interface defining all the services for ArrayClientInt64Values to be used by the proxy service to perform * REST calls. */ - @Host("http://localhost:3000") + @Host("{endpoint}") @ServiceInterface(name = "ArrayClientInt64Valu") public interface Int64ValuesService { @Get("/type/array/int64") @@ -64,8 +65,8 @@ public interface Int64ValuesService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> get(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Get("/type/array/int64") @ExpectedResponses({ 200 }) @@ -73,8 +74,8 @@ Mono> get(@HeaderParam("accept") String accept, RequestOpti @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response getSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Put("/type/array/int64") @ExpectedResponses({ 204 }) @@ -82,7 +83,8 @@ Response getSync(@HeaderParam("accept") String accept, RequestOption @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> put(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, + Mono> put(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); @Put("/type/array/int64") @@ -91,8 +93,8 @@ Mono> put(@HeaderParam("accept") String accept, @BodyParam("appli @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response putSync(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, - RequestOptions requestOptions, Context context); + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); } /** @@ -115,7 +117,7 @@ Response putSync(@HeaderParam("accept") String accept, @BodyParam("applica @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getWithResponseAsync(RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.get(accept, requestOptions, context)); + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); } /** @@ -138,7 +140,7 @@ public Mono> getWithResponseAsync(RequestOptions requestOpt @ServiceMethod(returns = ReturnType.SINGLE) public Response getWithResponse(RequestOptions requestOptions) { final String accept = "application/json"; - return service.getSync(accept, requestOptions, Context.NONE); + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); } /** @@ -161,8 +163,9 @@ public Response getWithResponse(RequestOptions requestOptions) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> putWithResponseAsync(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.put(accept, body, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.put(this.client.getEndpoint(), contentType, body, requestOptions, context)); } /** @@ -185,7 +188,7 @@ public Mono> putWithResponseAsync(BinaryData body, RequestOptions */ @ServiceMethod(returns = ReturnType.SINGLE) public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.putSync(accept, body, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/type/array/implementation/ModelValuesImpl.java b/typespec-tests/src/main/java/com/type/array/implementation/ModelValuesImpl.java index b1e3161b47..a9b4bbdf18 100644 --- a/typespec-tests/src/main/java/com/type/array/implementation/ModelValuesImpl.java +++ b/typespec-tests/src/main/java/com/type/array/implementation/ModelValuesImpl.java @@ -9,6 +9,7 @@ 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; @@ -55,7 +56,7 @@ public final class ModelValuesImpl { * The interface defining all the services for ArrayClientModelValues to be used by the proxy service to perform * REST calls. */ - @Host("http://localhost:3000") + @Host("{endpoint}") @ServiceInterface(name = "ArrayClientModelValu") public interface ModelValuesService { @Get("/type/array/model") @@ -64,8 +65,8 @@ public interface ModelValuesService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> get(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Get("/type/array/model") @ExpectedResponses({ 200 }) @@ -73,8 +74,8 @@ Mono> get(@HeaderParam("accept") String accept, RequestOpti @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response getSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Put("/type/array/model") @ExpectedResponses({ 204 }) @@ -82,7 +83,8 @@ Response getSync(@HeaderParam("accept") String accept, RequestOption @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> put(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, + Mono> put(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); @Put("/type/array/model") @@ -91,8 +93,8 @@ Mono> put(@HeaderParam("accept") String accept, @BodyParam("appli @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response putSync(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, - RequestOptions requestOptions, Context context); + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); } /** @@ -120,7 +122,7 @@ Response putSync(@HeaderParam("accept") String accept, @BodyParam("applica @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getWithResponseAsync(RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.get(accept, requestOptions, context)); + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); } /** @@ -148,7 +150,7 @@ public Mono> getWithResponseAsync(RequestOptions requestOpt @ServiceMethod(returns = ReturnType.SINGLE) public Response getWithResponse(RequestOptions requestOptions) { final String accept = "application/json"; - return service.getSync(accept, requestOptions, Context.NONE); + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); } /** @@ -176,8 +178,9 @@ public Response getWithResponse(RequestOptions requestOptions) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> putWithResponseAsync(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.put(accept, body, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.put(this.client.getEndpoint(), contentType, body, requestOptions, context)); } /** @@ -205,7 +208,7 @@ public Mono> putWithResponseAsync(BinaryData body, RequestOptions */ @ServiceMethod(returns = ReturnType.SINGLE) public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.putSync(accept, body, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/type/array/implementation/NullableBooleanValuesImpl.java b/typespec-tests/src/main/java/com/type/array/implementation/NullableBooleanValuesImpl.java index 568cdaf7d4..4fdf0dd3ed 100644 --- a/typespec-tests/src/main/java/com/type/array/implementation/NullableBooleanValuesImpl.java +++ b/typespec-tests/src/main/java/com/type/array/implementation/NullableBooleanValuesImpl.java @@ -9,6 +9,7 @@ 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; @@ -55,7 +56,7 @@ public final class NullableBooleanValuesImpl { * The interface defining all the services for ArrayClientNullableBooleanValues to be used by the proxy service to * perform REST calls. */ - @Host("http://localhost:3000") + @Host("{endpoint}") @ServiceInterface(name = "ArrayClientNullableB") public interface NullableBooleanValuesService { @Get("/type/array/nullable-boolean") @@ -64,8 +65,8 @@ public interface NullableBooleanValuesService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> get(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Get("/type/array/nullable-boolean") @ExpectedResponses({ 200 }) @@ -73,8 +74,8 @@ Mono> get(@HeaderParam("accept") String accept, RequestOpti @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response getSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Put("/type/array/nullable-boolean") @ExpectedResponses({ 204 }) @@ -82,7 +83,8 @@ Response getSync(@HeaderParam("accept") String accept, RequestOption @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> put(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, + 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") @@ -91,8 +93,8 @@ Mono> put(@HeaderParam("accept") String accept, @BodyParam("appli @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response putSync(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, - RequestOptions requestOptions, Context context); + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); } /** @@ -115,7 +117,7 @@ Response putSync(@HeaderParam("accept") String accept, @BodyParam("applica @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getWithResponseAsync(RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.get(accept, requestOptions, context)); + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); } /** @@ -138,7 +140,7 @@ public Mono> getWithResponseAsync(RequestOptions requestOpt @ServiceMethod(returns = ReturnType.SINGLE) public Response getWithResponse(RequestOptions requestOptions) { final String accept = "application/json"; - return service.getSync(accept, requestOptions, Context.NONE); + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); } /** @@ -161,8 +163,9 @@ public Response getWithResponse(RequestOptions requestOptions) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> putWithResponseAsync(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.put(accept, body, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.put(this.client.getEndpoint(), contentType, body, requestOptions, context)); } /** @@ -185,7 +188,7 @@ public Mono> putWithResponseAsync(BinaryData body, RequestOptions */ @ServiceMethod(returns = ReturnType.SINGLE) public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.putSync(accept, body, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/type/array/implementation/NullableFloatValuesImpl.java b/typespec-tests/src/main/java/com/type/array/implementation/NullableFloatValuesImpl.java index 7ec91a5d72..7c5932bec5 100644 --- a/typespec-tests/src/main/java/com/type/array/implementation/NullableFloatValuesImpl.java +++ b/typespec-tests/src/main/java/com/type/array/implementation/NullableFloatValuesImpl.java @@ -9,6 +9,7 @@ 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; @@ -55,7 +56,7 @@ public final class NullableFloatValuesImpl { * The interface defining all the services for ArrayClientNullableFloatValues to be used by the proxy service to * perform REST calls. */ - @Host("http://localhost:3000") + @Host("{endpoint}") @ServiceInterface(name = "ArrayClientNullableF") public interface NullableFloatValuesService { @Get("/type/array/nullable-float") @@ -64,8 +65,8 @@ public interface NullableFloatValuesService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> get(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Get("/type/array/nullable-float") @ExpectedResponses({ 200 }) @@ -73,8 +74,8 @@ Mono> get(@HeaderParam("accept") String accept, RequestOpti @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response getSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Put("/type/array/nullable-float") @ExpectedResponses({ 204 }) @@ -82,7 +83,8 @@ Response getSync(@HeaderParam("accept") String accept, RequestOption @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> put(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, + 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") @@ -91,8 +93,8 @@ Mono> put(@HeaderParam("accept") String accept, @BodyParam("appli @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response putSync(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, - RequestOptions requestOptions, Context context); + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); } /** @@ -115,7 +117,7 @@ Response putSync(@HeaderParam("accept") String accept, @BodyParam("applica @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getWithResponseAsync(RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.get(accept, requestOptions, context)); + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); } /** @@ -138,7 +140,7 @@ public Mono> getWithResponseAsync(RequestOptions requestOpt @ServiceMethod(returns = ReturnType.SINGLE) public Response getWithResponse(RequestOptions requestOptions) { final String accept = "application/json"; - return service.getSync(accept, requestOptions, Context.NONE); + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); } /** @@ -161,8 +163,9 @@ public Response getWithResponse(RequestOptions requestOptions) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> putWithResponseAsync(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.put(accept, body, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.put(this.client.getEndpoint(), contentType, body, requestOptions, context)); } /** @@ -185,7 +188,7 @@ public Mono> putWithResponseAsync(BinaryData body, RequestOptions */ @ServiceMethod(returns = ReturnType.SINGLE) public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.putSync(accept, body, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/type/array/implementation/NullableInt32ValuesImpl.java b/typespec-tests/src/main/java/com/type/array/implementation/NullableInt32ValuesImpl.java index 2ea543029e..b4c447bfab 100644 --- a/typespec-tests/src/main/java/com/type/array/implementation/NullableInt32ValuesImpl.java +++ b/typespec-tests/src/main/java/com/type/array/implementation/NullableInt32ValuesImpl.java @@ -9,6 +9,7 @@ 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; @@ -55,7 +56,7 @@ public final class NullableInt32ValuesImpl { * The interface defining all the services for ArrayClientNullableInt32Values to be used by the proxy service to * perform REST calls. */ - @Host("http://localhost:3000") + @Host("{endpoint}") @ServiceInterface(name = "ArrayClientNullableI") public interface NullableInt32ValuesService { @Get("/type/array/nullable-int32") @@ -64,8 +65,8 @@ public interface NullableInt32ValuesService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> get(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Get("/type/array/nullable-int32") @ExpectedResponses({ 200 }) @@ -73,8 +74,8 @@ Mono> get(@HeaderParam("accept") String accept, RequestOpti @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response getSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Put("/type/array/nullable-int32") @ExpectedResponses({ 204 }) @@ -82,7 +83,8 @@ Response getSync(@HeaderParam("accept") String accept, RequestOption @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> put(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, + 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") @@ -91,8 +93,8 @@ Mono> put(@HeaderParam("accept") String accept, @BodyParam("appli @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response putSync(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, - RequestOptions requestOptions, Context context); + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); } /** @@ -115,7 +117,7 @@ Response putSync(@HeaderParam("accept") String accept, @BodyParam("applica @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getWithResponseAsync(RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.get(accept, requestOptions, context)); + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); } /** @@ -138,7 +140,7 @@ public Mono> getWithResponseAsync(RequestOptions requestOpt @ServiceMethod(returns = ReturnType.SINGLE) public Response getWithResponse(RequestOptions requestOptions) { final String accept = "application/json"; - return service.getSync(accept, requestOptions, Context.NONE); + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); } /** @@ -161,8 +163,9 @@ public Response getWithResponse(RequestOptions requestOptions) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> putWithResponseAsync(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.put(accept, body, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.put(this.client.getEndpoint(), contentType, body, requestOptions, context)); } /** @@ -185,7 +188,7 @@ public Mono> putWithResponseAsync(BinaryData body, RequestOptions */ @ServiceMethod(returns = ReturnType.SINGLE) public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.putSync(accept, body, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/type/array/implementation/NullableModelValuesImpl.java b/typespec-tests/src/main/java/com/type/array/implementation/NullableModelValuesImpl.java index 1a7aa50cb1..643063bfb7 100644 --- a/typespec-tests/src/main/java/com/type/array/implementation/NullableModelValuesImpl.java +++ b/typespec-tests/src/main/java/com/type/array/implementation/NullableModelValuesImpl.java @@ -9,6 +9,7 @@ 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; @@ -55,7 +56,7 @@ public final class NullableModelValuesImpl { * The interface defining all the services for ArrayClientNullableModelValues to be used by the proxy service to * perform REST calls. */ - @Host("http://localhost:3000") + @Host("{endpoint}") @ServiceInterface(name = "ArrayClientNullableM") public interface NullableModelValuesService { @Get("/type/array/nullable-model") @@ -64,8 +65,8 @@ public interface NullableModelValuesService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> get(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Get("/type/array/nullable-model") @ExpectedResponses({ 200 }) @@ -73,8 +74,8 @@ Mono> get(@HeaderParam("accept") String accept, RequestOpti @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response getSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Put("/type/array/nullable-model") @ExpectedResponses({ 204 }) @@ -82,7 +83,8 @@ Response getSync(@HeaderParam("accept") String accept, RequestOption @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> put(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, + 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") @@ -91,8 +93,8 @@ Mono> put(@HeaderParam("accept") String accept, @BodyParam("appli @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response putSync(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, - RequestOptions requestOptions, Context context); + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); } /** @@ -120,7 +122,7 @@ Response putSync(@HeaderParam("accept") String accept, @BodyParam("applica @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getWithResponseAsync(RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.get(accept, requestOptions, context)); + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); } /** @@ -148,7 +150,7 @@ public Mono> getWithResponseAsync(RequestOptions requestOpt @ServiceMethod(returns = ReturnType.SINGLE) public Response getWithResponse(RequestOptions requestOptions) { final String accept = "application/json"; - return service.getSync(accept, requestOptions, Context.NONE); + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); } /** @@ -176,8 +178,9 @@ public Response getWithResponse(RequestOptions requestOptions) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> putWithResponseAsync(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.put(accept, body, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.put(this.client.getEndpoint(), contentType, body, requestOptions, context)); } /** @@ -205,7 +208,7 @@ public Mono> putWithResponseAsync(BinaryData body, RequestOptions */ @ServiceMethod(returns = ReturnType.SINGLE) public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.putSync(accept, body, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/type/array/implementation/NullableStringValuesImpl.java b/typespec-tests/src/main/java/com/type/array/implementation/NullableStringValuesImpl.java index 14d3526cf2..bbf0ce8b3b 100644 --- a/typespec-tests/src/main/java/com/type/array/implementation/NullableStringValuesImpl.java +++ b/typespec-tests/src/main/java/com/type/array/implementation/NullableStringValuesImpl.java @@ -9,6 +9,7 @@ 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; @@ -55,7 +56,7 @@ public final class NullableStringValuesImpl { * The interface defining all the services for ArrayClientNullableStringValues to be used by the proxy service to * perform REST calls. */ - @Host("http://localhost:3000") + @Host("{endpoint}") @ServiceInterface(name = "ArrayClientNullableS") public interface NullableStringValuesService { @Get("/type/array/nullable-string") @@ -64,8 +65,8 @@ public interface NullableStringValuesService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> get(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Get("/type/array/nullable-string") @ExpectedResponses({ 200 }) @@ -73,8 +74,8 @@ Mono> get(@HeaderParam("accept") String accept, RequestOpti @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response getSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Put("/type/array/nullable-string") @ExpectedResponses({ 204 }) @@ -82,7 +83,8 @@ Response getSync(@HeaderParam("accept") String accept, RequestOption @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> put(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, + 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") @@ -91,8 +93,8 @@ Mono> put(@HeaderParam("accept") String accept, @BodyParam("appli @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response putSync(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, - RequestOptions requestOptions, Context context); + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); } /** @@ -115,7 +117,7 @@ Response putSync(@HeaderParam("accept") String accept, @BodyParam("applica @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getWithResponseAsync(RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.get(accept, requestOptions, context)); + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); } /** @@ -138,7 +140,7 @@ public Mono> getWithResponseAsync(RequestOptions requestOpt @ServiceMethod(returns = ReturnType.SINGLE) public Response getWithResponse(RequestOptions requestOptions) { final String accept = "application/json"; - return service.getSync(accept, requestOptions, Context.NONE); + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); } /** @@ -161,8 +163,9 @@ public Response getWithResponse(RequestOptions requestOptions) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> putWithResponseAsync(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.put(accept, body, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.put(this.client.getEndpoint(), contentType, body, requestOptions, context)); } /** @@ -185,7 +188,7 @@ public Mono> putWithResponseAsync(BinaryData body, RequestOptions */ @ServiceMethod(returns = ReturnType.SINGLE) public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.putSync(accept, body, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/type/array/implementation/StringValuesImpl.java b/typespec-tests/src/main/java/com/type/array/implementation/StringValuesImpl.java index ef7552c5d1..a4f654a3d5 100644 --- a/typespec-tests/src/main/java/com/type/array/implementation/StringValuesImpl.java +++ b/typespec-tests/src/main/java/com/type/array/implementation/StringValuesImpl.java @@ -9,6 +9,7 @@ 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; @@ -55,7 +56,7 @@ public final class StringValuesImpl { * The interface defining all the services for ArrayClientStringValues to be used by the proxy service to perform * REST calls. */ - @Host("http://localhost:3000") + @Host("{endpoint}") @ServiceInterface(name = "ArrayClientStringVal") public interface StringValuesService { @Get("/type/array/string") @@ -64,8 +65,8 @@ public interface StringValuesService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> get(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Get("/type/array/string") @ExpectedResponses({ 200 }) @@ -73,8 +74,8 @@ Mono> get(@HeaderParam("accept") String accept, RequestOpti @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response getSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Put("/type/array/string") @ExpectedResponses({ 204 }) @@ -82,7 +83,8 @@ Response getSync(@HeaderParam("accept") String accept, RequestOption @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> put(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, + Mono> put(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); @Put("/type/array/string") @@ -91,8 +93,8 @@ Mono> put(@HeaderParam("accept") String accept, @BodyParam("appli @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response putSync(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, - RequestOptions requestOptions, Context context); + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); } /** @@ -115,7 +117,7 @@ Response putSync(@HeaderParam("accept") String accept, @BodyParam("applica @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getWithResponseAsync(RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.get(accept, requestOptions, context)); + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); } /** @@ -138,7 +140,7 @@ public Mono> getWithResponseAsync(RequestOptions requestOpt @ServiceMethod(returns = ReturnType.SINGLE) public Response getWithResponse(RequestOptions requestOptions) { final String accept = "application/json"; - return service.getSync(accept, requestOptions, Context.NONE); + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); } /** @@ -161,8 +163,9 @@ public Response getWithResponse(RequestOptions requestOptions) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> putWithResponseAsync(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.put(accept, body, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.put(this.client.getEndpoint(), contentType, body, requestOptions, context)); } /** @@ -185,7 +188,7 @@ public Mono> putWithResponseAsync(BinaryData body, RequestOptions */ @ServiceMethod(returns = ReturnType.SINGLE) public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.putSync(accept, body, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/type/array/implementation/UnknownValuesImpl.java b/typespec-tests/src/main/java/com/type/array/implementation/UnknownValuesImpl.java index b79b8875f7..278340bf3c 100644 --- a/typespec-tests/src/main/java/com/type/array/implementation/UnknownValuesImpl.java +++ b/typespec-tests/src/main/java/com/type/array/implementation/UnknownValuesImpl.java @@ -9,6 +9,7 @@ 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; @@ -55,7 +56,7 @@ public final class UnknownValuesImpl { * The interface defining all the services for ArrayClientUnknownValues to be used by the proxy service to perform * REST calls. */ - @Host("http://localhost:3000") + @Host("{endpoint}") @ServiceInterface(name = "ArrayClientUnknownVa") public interface UnknownValuesService { @Get("/type/array/unknown") @@ -64,8 +65,8 @@ public interface UnknownValuesService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> get(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Get("/type/array/unknown") @ExpectedResponses({ 200 }) @@ -73,8 +74,8 @@ Mono> get(@HeaderParam("accept") String accept, RequestOpti @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response getSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Put("/type/array/unknown") @ExpectedResponses({ 204 }) @@ -82,7 +83,8 @@ Response getSync(@HeaderParam("accept") String accept, RequestOption @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> put(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, + Mono> put(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); @Put("/type/array/unknown") @@ -91,8 +93,8 @@ Mono> put(@HeaderParam("accept") String accept, @BodyParam("appli @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response putSync(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, - RequestOptions requestOptions, Context context); + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); } /** @@ -115,7 +117,7 @@ Response putSync(@HeaderParam("accept") String accept, @BodyParam("applica @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getWithResponseAsync(RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.get(accept, requestOptions, context)); + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); } /** @@ -138,7 +140,7 @@ public Mono> getWithResponseAsync(RequestOptions requestOpt @ServiceMethod(returns = ReturnType.SINGLE) public Response getWithResponse(RequestOptions requestOptions) { final String accept = "application/json"; - return service.getSync(accept, requestOptions, Context.NONE); + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); } /** @@ -161,8 +163,9 @@ public Response getWithResponse(RequestOptions requestOptions) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> putWithResponseAsync(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.put(accept, body, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.put(this.client.getEndpoint(), contentType, body, requestOptions, context)); } /** @@ -185,7 +188,7 @@ public Mono> putWithResponseAsync(BinaryData body, RequestOptions */ @ServiceMethod(returns = ReturnType.SINGLE) public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.putSync(accept, body, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/type/dictionary/DictionaryClientBuilder.java b/typespec-tests/src/main/java/com/type/dictionary/DictionaryClientBuilder.java index 5207e105a7..d9c58a5c61 100644 --- a/typespec-tests/src/main/java/com/type/dictionary/DictionaryClientBuilder.java +++ b/typespec-tests/src/main/java/com/type/dictionary/DictionaryClientBuilder.java @@ -7,6 +7,7 @@ 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; @@ -63,8 +64,8 @@ ModelValueAsyncClient.class, RecursiveModelValueAsyncClient.class, NullableFloatValueAsyncClient.class }) -public final class DictionaryClientBuilder - implements HttpTrait, ConfigurationTrait { +public final class DictionaryClientBuilder implements HttpTrait, + ConfigurationTrait, EndpointTrait { @Generated private static final String SDK_NAME = "name"; @@ -195,6 +196,22 @@ public DictionaryClientBuilder configuration(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. */ @@ -222,8 +239,9 @@ public DictionaryClientBuilder retryPolicy(RetryPolicy retryPolicy) { 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()); + = new DictionaryClientImpl(localPipeline, JacksonAdapter.createDefaultSerializerAdapter(), localEndpoint); return client; } diff --git a/typespec-tests/src/main/java/com/type/dictionary/implementation/BooleanValuesImpl.java b/typespec-tests/src/main/java/com/type/dictionary/implementation/BooleanValuesImpl.java index fef9ecf811..4252c4d7f2 100644 --- a/typespec-tests/src/main/java/com/type/dictionary/implementation/BooleanValuesImpl.java +++ b/typespec-tests/src/main/java/com/type/dictionary/implementation/BooleanValuesImpl.java @@ -9,6 +9,7 @@ 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; @@ -55,7 +56,7 @@ public final class BooleanValuesImpl { * The interface defining all the services for DictionaryClientBooleanValues to be used by the proxy service to * perform REST calls. */ - @Host("http://localhost:3000") + @Host("{endpoint}") @ServiceInterface(name = "DictionaryClientBool") public interface BooleanValuesService { @Get("/type/dictionary/boolean") @@ -64,8 +65,8 @@ public interface BooleanValuesService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> get(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Get("/type/dictionary/boolean") @ExpectedResponses({ 200 }) @@ -73,8 +74,8 @@ Mono> get(@HeaderParam("accept") String accept, RequestOpti @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response getSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Put("/type/dictionary/boolean") @ExpectedResponses({ 204 }) @@ -82,7 +83,8 @@ Response getSync(@HeaderParam("accept") String accept, RequestOption @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> put(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, + Mono> put(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); @Put("/type/dictionary/boolean") @@ -91,8 +93,8 @@ Mono> put(@HeaderParam("accept") String accept, @BodyParam("appli @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response putSync(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, - RequestOptions requestOptions, Context context); + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); } /** @@ -115,7 +117,7 @@ Response putSync(@HeaderParam("accept") String accept, @BodyParam("applica @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getWithResponseAsync(RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.get(accept, requestOptions, context)); + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); } /** @@ -138,7 +140,7 @@ public Mono> getWithResponseAsync(RequestOptions requestOpt @ServiceMethod(returns = ReturnType.SINGLE) public Response getWithResponse(RequestOptions requestOptions) { final String accept = "application/json"; - return service.getSync(accept, requestOptions, Context.NONE); + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); } /** @@ -161,8 +163,9 @@ public Response getWithResponse(RequestOptions requestOptions) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> putWithResponseAsync(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.put(accept, body, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.put(this.client.getEndpoint(), contentType, body, requestOptions, context)); } /** @@ -185,7 +188,7 @@ public Mono> putWithResponseAsync(BinaryData body, RequestOptions */ @ServiceMethod(returns = ReturnType.SINGLE) public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.putSync(accept, body, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/type/dictionary/implementation/DatetimeValuesImpl.java b/typespec-tests/src/main/java/com/type/dictionary/implementation/DatetimeValuesImpl.java index 2e7fddb5c3..c69e91000f 100644 --- a/typespec-tests/src/main/java/com/type/dictionary/implementation/DatetimeValuesImpl.java +++ b/typespec-tests/src/main/java/com/type/dictionary/implementation/DatetimeValuesImpl.java @@ -9,6 +9,7 @@ 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; @@ -55,7 +56,7 @@ public final class DatetimeValuesImpl { * The interface defining all the services for DictionaryClientDatetimeValues to be used by the proxy service to * perform REST calls. */ - @Host("http://localhost:3000") + @Host("{endpoint}") @ServiceInterface(name = "DictionaryClientDate") public interface DatetimeValuesService { @Get("/type/dictionary/datetime") @@ -64,8 +65,8 @@ public interface DatetimeValuesService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> get(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Get("/type/dictionary/datetime") @ExpectedResponses({ 200 }) @@ -73,8 +74,8 @@ Mono> get(@HeaderParam("accept") String accept, RequestOpti @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response getSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Put("/type/dictionary/datetime") @ExpectedResponses({ 204 }) @@ -82,7 +83,8 @@ Response getSync(@HeaderParam("accept") String accept, RequestOption @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> put(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, + Mono> put(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); @Put("/type/dictionary/datetime") @@ -91,8 +93,8 @@ Mono> put(@HeaderParam("accept") String accept, @BodyParam("appli @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response putSync(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, - RequestOptions requestOptions, Context context); + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); } /** @@ -115,7 +117,7 @@ Response putSync(@HeaderParam("accept") String accept, @BodyParam("applica @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getWithResponseAsync(RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.get(accept, requestOptions, context)); + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); } /** @@ -138,7 +140,7 @@ public Mono> getWithResponseAsync(RequestOptions requestOpt @ServiceMethod(returns = ReturnType.SINGLE) public Response getWithResponse(RequestOptions requestOptions) { final String accept = "application/json"; - return service.getSync(accept, requestOptions, Context.NONE); + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); } /** @@ -161,8 +163,9 @@ public Response getWithResponse(RequestOptions requestOptions) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> putWithResponseAsync(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.put(accept, body, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.put(this.client.getEndpoint(), contentType, body, requestOptions, context)); } /** @@ -185,7 +188,7 @@ public Mono> putWithResponseAsync(BinaryData body, RequestOptions */ @ServiceMethod(returns = ReturnType.SINGLE) public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.putSync(accept, body, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/type/dictionary/implementation/DictionaryClientImpl.java b/typespec-tests/src/main/java/com/type/dictionary/implementation/DictionaryClientImpl.java index c913de3bf4..e102ac6198 100644 --- a/typespec-tests/src/main/java/com/type/dictionary/implementation/DictionaryClientImpl.java +++ b/typespec-tests/src/main/java/com/type/dictionary/implementation/DictionaryClientImpl.java @@ -15,6 +15,20 @@ * 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. */ @@ -199,19 +213,22 @@ public NullableFloatValuesImpl getNullableFloatValues() { /** * Initializes an instance of DictionaryClient client. + * + * @param endpoint Service host. */ - public DictionaryClientImpl() { + public DictionaryClientImpl(String endpoint) { this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), - JacksonAdapter.createDefaultSerializerAdapter()); + 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) { - this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter()); + public DictionaryClientImpl(HttpPipeline httpPipeline, String endpoint) { + this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint); } /** @@ -219,10 +236,12 @@ public DictionaryClientImpl(HttpPipeline httpPipeline) { * * @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) { + 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); diff --git a/typespec-tests/src/main/java/com/type/dictionary/implementation/DurationValuesImpl.java b/typespec-tests/src/main/java/com/type/dictionary/implementation/DurationValuesImpl.java index 112a1695e8..fd34b374c1 100644 --- a/typespec-tests/src/main/java/com/type/dictionary/implementation/DurationValuesImpl.java +++ b/typespec-tests/src/main/java/com/type/dictionary/implementation/DurationValuesImpl.java @@ -9,6 +9,7 @@ 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; @@ -55,7 +56,7 @@ public final class DurationValuesImpl { * The interface defining all the services for DictionaryClientDurationValues to be used by the proxy service to * perform REST calls. */ - @Host("http://localhost:3000") + @Host("{endpoint}") @ServiceInterface(name = "DictionaryClientDura") public interface DurationValuesService { @Get("/type/dictionary/duration") @@ -64,8 +65,8 @@ public interface DurationValuesService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> get(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Get("/type/dictionary/duration") @ExpectedResponses({ 200 }) @@ -73,8 +74,8 @@ Mono> get(@HeaderParam("accept") String accept, RequestOpti @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response getSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Put("/type/dictionary/duration") @ExpectedResponses({ 204 }) @@ -82,7 +83,8 @@ Response getSync(@HeaderParam("accept") String accept, RequestOption @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> put(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, + Mono> put(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); @Put("/type/dictionary/duration") @@ -91,8 +93,8 @@ Mono> put(@HeaderParam("accept") String accept, @BodyParam("appli @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response putSync(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, - RequestOptions requestOptions, Context context); + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); } /** @@ -115,7 +117,7 @@ Response putSync(@HeaderParam("accept") String accept, @BodyParam("applica @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getWithResponseAsync(RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.get(accept, requestOptions, context)); + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); } /** @@ -138,7 +140,7 @@ public Mono> getWithResponseAsync(RequestOptions requestOpt @ServiceMethod(returns = ReturnType.SINGLE) public Response getWithResponse(RequestOptions requestOptions) { final String accept = "application/json"; - return service.getSync(accept, requestOptions, Context.NONE); + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); } /** @@ -161,8 +163,9 @@ public Response getWithResponse(RequestOptions requestOptions) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> putWithResponseAsync(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.put(accept, body, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.put(this.client.getEndpoint(), contentType, body, requestOptions, context)); } /** @@ -185,7 +188,7 @@ public Mono> putWithResponseAsync(BinaryData body, RequestOptions */ @ServiceMethod(returns = ReturnType.SINGLE) public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.putSync(accept, body, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/type/dictionary/implementation/Float32ValuesImpl.java b/typespec-tests/src/main/java/com/type/dictionary/implementation/Float32ValuesImpl.java index aa131f6908..31c0c48d5b 100644 --- a/typespec-tests/src/main/java/com/type/dictionary/implementation/Float32ValuesImpl.java +++ b/typespec-tests/src/main/java/com/type/dictionary/implementation/Float32ValuesImpl.java @@ -9,6 +9,7 @@ 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; @@ -55,7 +56,7 @@ public final class Float32ValuesImpl { * The interface defining all the services for DictionaryClientFloat32Values to be used by the proxy service to * perform REST calls. */ - @Host("http://localhost:3000") + @Host("{endpoint}") @ServiceInterface(name = "DictionaryClientFloa") public interface Float32ValuesService { @Get("/type/dictionary/float32") @@ -64,8 +65,8 @@ public interface Float32ValuesService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> get(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Get("/type/dictionary/float32") @ExpectedResponses({ 200 }) @@ -73,8 +74,8 @@ Mono> get(@HeaderParam("accept") String accept, RequestOpti @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response getSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Put("/type/dictionary/float32") @ExpectedResponses({ 204 }) @@ -82,7 +83,8 @@ Response getSync(@HeaderParam("accept") String accept, RequestOption @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> put(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, + Mono> put(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); @Put("/type/dictionary/float32") @@ -91,8 +93,8 @@ Mono> put(@HeaderParam("accept") String accept, @BodyParam("appli @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response putSync(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, - RequestOptions requestOptions, Context context); + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); } /** @@ -115,7 +117,7 @@ Response putSync(@HeaderParam("accept") String accept, @BodyParam("applica @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getWithResponseAsync(RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.get(accept, requestOptions, context)); + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); } /** @@ -138,7 +140,7 @@ public Mono> getWithResponseAsync(RequestOptions requestOpt @ServiceMethod(returns = ReturnType.SINGLE) public Response getWithResponse(RequestOptions requestOptions) { final String accept = "application/json"; - return service.getSync(accept, requestOptions, Context.NONE); + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); } /** @@ -161,8 +163,9 @@ public Response getWithResponse(RequestOptions requestOptions) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> putWithResponseAsync(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.put(accept, body, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.put(this.client.getEndpoint(), contentType, body, requestOptions, context)); } /** @@ -185,7 +188,7 @@ public Mono> putWithResponseAsync(BinaryData body, RequestOptions */ @ServiceMethod(returns = ReturnType.SINGLE) public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.putSync(accept, body, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/type/dictionary/implementation/Int32ValuesImpl.java b/typespec-tests/src/main/java/com/type/dictionary/implementation/Int32ValuesImpl.java index 9abf4cc57e..218a66342b 100644 --- a/typespec-tests/src/main/java/com/type/dictionary/implementation/Int32ValuesImpl.java +++ b/typespec-tests/src/main/java/com/type/dictionary/implementation/Int32ValuesImpl.java @@ -9,6 +9,7 @@ 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; @@ -55,7 +56,7 @@ public final class Int32ValuesImpl { * The interface defining all the services for DictionaryClientInt32Values to be used by the proxy service to * perform REST calls. */ - @Host("http://localhost:3000") + @Host("{endpoint}") @ServiceInterface(name = "DictionaryClientInt3") public interface Int32ValuesService { @Get("/type/dictionary/int32") @@ -64,8 +65,8 @@ public interface Int32ValuesService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> get(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Get("/type/dictionary/int32") @ExpectedResponses({ 200 }) @@ -73,8 +74,8 @@ Mono> get(@HeaderParam("accept") String accept, RequestOpti @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response getSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Put("/type/dictionary/int32") @ExpectedResponses({ 204 }) @@ -82,7 +83,8 @@ Response getSync(@HeaderParam("accept") String accept, RequestOption @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> put(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, + Mono> put(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); @Put("/type/dictionary/int32") @@ -91,8 +93,8 @@ Mono> put(@HeaderParam("accept") String accept, @BodyParam("appli @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response putSync(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, - RequestOptions requestOptions, Context context); + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); } /** @@ -115,7 +117,7 @@ Response putSync(@HeaderParam("accept") String accept, @BodyParam("applica @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getWithResponseAsync(RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.get(accept, requestOptions, context)); + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); } /** @@ -138,7 +140,7 @@ public Mono> getWithResponseAsync(RequestOptions requestOpt @ServiceMethod(returns = ReturnType.SINGLE) public Response getWithResponse(RequestOptions requestOptions) { final String accept = "application/json"; - return service.getSync(accept, requestOptions, Context.NONE); + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); } /** @@ -161,8 +163,9 @@ public Response getWithResponse(RequestOptions requestOptions) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> putWithResponseAsync(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.put(accept, body, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.put(this.client.getEndpoint(), contentType, body, requestOptions, context)); } /** @@ -185,7 +188,7 @@ public Mono> putWithResponseAsync(BinaryData body, RequestOptions */ @ServiceMethod(returns = ReturnType.SINGLE) public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.putSync(accept, body, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/type/dictionary/implementation/Int64ValuesImpl.java b/typespec-tests/src/main/java/com/type/dictionary/implementation/Int64ValuesImpl.java index 383b89c568..0a4f18ef6a 100644 --- a/typespec-tests/src/main/java/com/type/dictionary/implementation/Int64ValuesImpl.java +++ b/typespec-tests/src/main/java/com/type/dictionary/implementation/Int64ValuesImpl.java @@ -9,6 +9,7 @@ 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; @@ -55,7 +56,7 @@ public final class Int64ValuesImpl { * The interface defining all the services for DictionaryClientInt64Values to be used by the proxy service to * perform REST calls. */ - @Host("http://localhost:3000") + @Host("{endpoint}") @ServiceInterface(name = "DictionaryClientInt6") public interface Int64ValuesService { @Get("/type/dictionary/int64") @@ -64,8 +65,8 @@ public interface Int64ValuesService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> get(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Get("/type/dictionary/int64") @ExpectedResponses({ 200 }) @@ -73,8 +74,8 @@ Mono> get(@HeaderParam("accept") String accept, RequestOpti @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response getSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Put("/type/dictionary/int64") @ExpectedResponses({ 204 }) @@ -82,7 +83,8 @@ Response getSync(@HeaderParam("accept") String accept, RequestOption @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> put(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, + Mono> put(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); @Put("/type/dictionary/int64") @@ -91,8 +93,8 @@ Mono> put(@HeaderParam("accept") String accept, @BodyParam("appli @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response putSync(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, - RequestOptions requestOptions, Context context); + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); } /** @@ -115,7 +117,7 @@ Response putSync(@HeaderParam("accept") String accept, @BodyParam("applica @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getWithResponseAsync(RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.get(accept, requestOptions, context)); + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); } /** @@ -138,7 +140,7 @@ public Mono> getWithResponseAsync(RequestOptions requestOpt @ServiceMethod(returns = ReturnType.SINGLE) public Response getWithResponse(RequestOptions requestOptions) { final String accept = "application/json"; - return service.getSync(accept, requestOptions, Context.NONE); + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); } /** @@ -161,8 +163,9 @@ public Response getWithResponse(RequestOptions requestOptions) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> putWithResponseAsync(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.put(accept, body, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.put(this.client.getEndpoint(), contentType, body, requestOptions, context)); } /** @@ -185,7 +188,7 @@ public Mono> putWithResponseAsync(BinaryData body, RequestOptions */ @ServiceMethod(returns = ReturnType.SINGLE) public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.putSync(accept, body, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/type/dictionary/implementation/ModelValuesImpl.java b/typespec-tests/src/main/java/com/type/dictionary/implementation/ModelValuesImpl.java index 0a2c47ac81..67b28966e9 100644 --- a/typespec-tests/src/main/java/com/type/dictionary/implementation/ModelValuesImpl.java +++ b/typespec-tests/src/main/java/com/type/dictionary/implementation/ModelValuesImpl.java @@ -9,6 +9,7 @@ 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; @@ -55,7 +56,7 @@ public final class ModelValuesImpl { * The interface defining all the services for DictionaryClientModelValues to be used by the proxy service to * perform REST calls. */ - @Host("http://localhost:3000") + @Host("{endpoint}") @ServiceInterface(name = "DictionaryClientMode") public interface ModelValuesService { @Get("/type/dictionary/model") @@ -64,8 +65,8 @@ public interface ModelValuesService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> get(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Get("/type/dictionary/model") @ExpectedResponses({ 200 }) @@ -73,8 +74,8 @@ Mono> get(@HeaderParam("accept") String accept, RequestOpti @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response getSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Put("/type/dictionary/model") @ExpectedResponses({ 204 }) @@ -82,7 +83,8 @@ Response getSync(@HeaderParam("accept") String accept, RequestOption @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> put(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, + Mono> put(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); @Put("/type/dictionary/model") @@ -91,8 +93,8 @@ Mono> put(@HeaderParam("accept") String accept, @BodyParam("appli @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response putSync(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, - RequestOptions requestOptions, Context context); + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); } /** @@ -120,7 +122,7 @@ Response putSync(@HeaderParam("accept") String accept, @BodyParam("applica @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getWithResponseAsync(RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.get(accept, requestOptions, context)); + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); } /** @@ -148,7 +150,7 @@ public Mono> getWithResponseAsync(RequestOptions requestOpt @ServiceMethod(returns = ReturnType.SINGLE) public Response getWithResponse(RequestOptions requestOptions) { final String accept = "application/json"; - return service.getSync(accept, requestOptions, Context.NONE); + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); } /** @@ -176,8 +178,9 @@ public Response getWithResponse(RequestOptions requestOptions) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> putWithResponseAsync(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.put(accept, body, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.put(this.client.getEndpoint(), contentType, body, requestOptions, context)); } /** @@ -205,7 +208,7 @@ public Mono> putWithResponseAsync(BinaryData body, RequestOptions */ @ServiceMethod(returns = ReturnType.SINGLE) public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.putSync(accept, body, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/type/dictionary/implementation/NullableFloatValuesImpl.java b/typespec-tests/src/main/java/com/type/dictionary/implementation/NullableFloatValuesImpl.java index c280de87dc..4bbec7bc7f 100644 --- a/typespec-tests/src/main/java/com/type/dictionary/implementation/NullableFloatValuesImpl.java +++ b/typespec-tests/src/main/java/com/type/dictionary/implementation/NullableFloatValuesImpl.java @@ -9,6 +9,7 @@ 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; @@ -55,7 +56,7 @@ public final class NullableFloatValuesImpl { * The interface defining all the services for DictionaryClientNullableFloatValues to be used by the proxy service * to perform REST calls. */ - @Host("http://localhost:3000") + @Host("{endpoint}") @ServiceInterface(name = "DictionaryClientNull") public interface NullableFloatValuesService { @Get("/type/dictionary/nullable-float") @@ -64,8 +65,8 @@ public interface NullableFloatValuesService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> get(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Get("/type/dictionary/nullable-float") @ExpectedResponses({ 200 }) @@ -73,8 +74,8 @@ Mono> get(@HeaderParam("accept") String accept, RequestOpti @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response getSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Put("/type/dictionary/nullable-float") @ExpectedResponses({ 204 }) @@ -82,7 +83,8 @@ Response getSync(@HeaderParam("accept") String accept, RequestOption @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> put(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, + 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") @@ -91,8 +93,8 @@ Mono> put(@HeaderParam("accept") String accept, @BodyParam("appli @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response putSync(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, - RequestOptions requestOptions, Context context); + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); } /** @@ -115,7 +117,7 @@ Response putSync(@HeaderParam("accept") String accept, @BodyParam("applica @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getWithResponseAsync(RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.get(accept, requestOptions, context)); + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); } /** @@ -138,7 +140,7 @@ public Mono> getWithResponseAsync(RequestOptions requestOpt @ServiceMethod(returns = ReturnType.SINGLE) public Response getWithResponse(RequestOptions requestOptions) { final String accept = "application/json"; - return service.getSync(accept, requestOptions, Context.NONE); + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); } /** @@ -161,8 +163,9 @@ public Response getWithResponse(RequestOptions requestOptions) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> putWithResponseAsync(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.put(accept, body, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.put(this.client.getEndpoint(), contentType, body, requestOptions, context)); } /** @@ -185,7 +188,7 @@ public Mono> putWithResponseAsync(BinaryData body, RequestOptions */ @ServiceMethod(returns = ReturnType.SINGLE) public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.putSync(accept, body, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/type/dictionary/implementation/RecursiveModelValuesImpl.java b/typespec-tests/src/main/java/com/type/dictionary/implementation/RecursiveModelValuesImpl.java index e2cb88c8a2..ee8fad64fe 100644 --- a/typespec-tests/src/main/java/com/type/dictionary/implementation/RecursiveModelValuesImpl.java +++ b/typespec-tests/src/main/java/com/type/dictionary/implementation/RecursiveModelValuesImpl.java @@ -9,6 +9,7 @@ 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; @@ -55,7 +56,7 @@ public final class RecursiveModelValuesImpl { * The interface defining all the services for DictionaryClientRecursiveModelValues to be used by the proxy service * to perform REST calls. */ - @Host("http://localhost:3000") + @Host("{endpoint}") @ServiceInterface(name = "DictionaryClientRecu") public interface RecursiveModelValuesService { @Get("/type/dictionary/model/recursive") @@ -64,8 +65,8 @@ public interface RecursiveModelValuesService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> get(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Get("/type/dictionary/model/recursive") @ExpectedResponses({ 200 }) @@ -73,8 +74,8 @@ Mono> get(@HeaderParam("accept") String accept, RequestOpti @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response getSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Put("/type/dictionary/model/recursive") @ExpectedResponses({ 204 }) @@ -82,7 +83,8 @@ Response getSync(@HeaderParam("accept") String accept, RequestOption @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> put(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, + 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") @@ -91,8 +93,8 @@ Mono> put(@HeaderParam("accept") String accept, @BodyParam("appli @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response putSync(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, - RequestOptions requestOptions, Context context); + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); } /** @@ -120,7 +122,7 @@ Response putSync(@HeaderParam("accept") String accept, @BodyParam("applica @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getWithResponseAsync(RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.get(accept, requestOptions, context)); + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); } /** @@ -148,7 +150,7 @@ public Mono> getWithResponseAsync(RequestOptions requestOpt @ServiceMethod(returns = ReturnType.SINGLE) public Response getWithResponse(RequestOptions requestOptions) { final String accept = "application/json"; - return service.getSync(accept, requestOptions, Context.NONE); + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); } /** @@ -176,8 +178,9 @@ public Response getWithResponse(RequestOptions requestOptions) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> putWithResponseAsync(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.put(accept, body, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.put(this.client.getEndpoint(), contentType, body, requestOptions, context)); } /** @@ -205,7 +208,7 @@ public Mono> putWithResponseAsync(BinaryData body, RequestOptions */ @ServiceMethod(returns = ReturnType.SINGLE) public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.putSync(accept, body, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/type/dictionary/implementation/StringValuesImpl.java b/typespec-tests/src/main/java/com/type/dictionary/implementation/StringValuesImpl.java index f175afc089..185d11e415 100644 --- a/typespec-tests/src/main/java/com/type/dictionary/implementation/StringValuesImpl.java +++ b/typespec-tests/src/main/java/com/type/dictionary/implementation/StringValuesImpl.java @@ -9,6 +9,7 @@ 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; @@ -55,7 +56,7 @@ public final class StringValuesImpl { * The interface defining all the services for DictionaryClientStringValues to be used by the proxy service to * perform REST calls. */ - @Host("http://localhost:3000") + @Host("{endpoint}") @ServiceInterface(name = "DictionaryClientStri") public interface StringValuesService { @Get("/type/dictionary/string") @@ -64,8 +65,8 @@ public interface StringValuesService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> get(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Get("/type/dictionary/string") @ExpectedResponses({ 200 }) @@ -73,8 +74,8 @@ Mono> get(@HeaderParam("accept") String accept, RequestOpti @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response getSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Put("/type/dictionary/string") @ExpectedResponses({ 204 }) @@ -82,7 +83,8 @@ Response getSync(@HeaderParam("accept") String accept, RequestOption @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> put(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, + Mono> put(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); @Put("/type/dictionary/string") @@ -91,8 +93,8 @@ Mono> put(@HeaderParam("accept") String accept, @BodyParam("appli @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response putSync(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, - RequestOptions requestOptions, Context context); + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); } /** @@ -115,7 +117,7 @@ Response putSync(@HeaderParam("accept") String accept, @BodyParam("applica @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getWithResponseAsync(RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.get(accept, requestOptions, context)); + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); } /** @@ -138,7 +140,7 @@ public Mono> getWithResponseAsync(RequestOptions requestOpt @ServiceMethod(returns = ReturnType.SINGLE) public Response getWithResponse(RequestOptions requestOptions) { final String accept = "application/json"; - return service.getSync(accept, requestOptions, Context.NONE); + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); } /** @@ -161,8 +163,9 @@ public Response getWithResponse(RequestOptions requestOptions) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> putWithResponseAsync(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.put(accept, body, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.put(this.client.getEndpoint(), contentType, body, requestOptions, context)); } /** @@ -185,7 +188,7 @@ public Mono> putWithResponseAsync(BinaryData body, RequestOptions */ @ServiceMethod(returns = ReturnType.SINGLE) public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.putSync(accept, body, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/type/dictionary/implementation/UnknownValuesImpl.java b/typespec-tests/src/main/java/com/type/dictionary/implementation/UnknownValuesImpl.java index db4156cabc..c8669d7a4c 100644 --- a/typespec-tests/src/main/java/com/type/dictionary/implementation/UnknownValuesImpl.java +++ b/typespec-tests/src/main/java/com/type/dictionary/implementation/UnknownValuesImpl.java @@ -9,6 +9,7 @@ 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; @@ -55,7 +56,7 @@ public final class UnknownValuesImpl { * The interface defining all the services for DictionaryClientUnknownValues to be used by the proxy service to * perform REST calls. */ - @Host("http://localhost:3000") + @Host("{endpoint}") @ServiceInterface(name = "DictionaryClientUnkn") public interface UnknownValuesService { @Get("/type/dictionary/unknown") @@ -64,8 +65,8 @@ public interface UnknownValuesService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> get(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Get("/type/dictionary/unknown") @ExpectedResponses({ 200 }) @@ -73,8 +74,8 @@ Mono> get(@HeaderParam("accept") String accept, RequestOpti @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response getSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Put("/type/dictionary/unknown") @ExpectedResponses({ 204 }) @@ -82,7 +83,8 @@ Response getSync(@HeaderParam("accept") String accept, RequestOption @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> put(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, + Mono> put(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); @Put("/type/dictionary/unknown") @@ -91,8 +93,8 @@ Mono> put(@HeaderParam("accept") String accept, @BodyParam("appli @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response putSync(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, - RequestOptions requestOptions, Context context); + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); } /** @@ -115,7 +117,7 @@ Response putSync(@HeaderParam("accept") String accept, @BodyParam("applica @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getWithResponseAsync(RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.get(accept, requestOptions, context)); + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); } /** @@ -138,7 +140,7 @@ public Mono> getWithResponseAsync(RequestOptions requestOpt @ServiceMethod(returns = ReturnType.SINGLE) public Response getWithResponse(RequestOptions requestOptions) { final String accept = "application/json"; - return service.getSync(accept, requestOptions, Context.NONE); + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); } /** @@ -161,8 +163,9 @@ public Response getWithResponse(RequestOptions requestOptions) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> putWithResponseAsync(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.put(accept, body, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.put(this.client.getEndpoint(), contentType, body, requestOptions, context)); } /** @@ -185,7 +188,7 @@ public Mono> putWithResponseAsync(BinaryData body, RequestOptions */ @ServiceMethod(returns = ReturnType.SINGLE) public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.putSync(accept, body, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/type/enums/extensible/ExtensibleClientBuilder.java b/typespec-tests/src/main/java/com/type/enums/extensible/ExtensibleClientBuilder.java index 6a3540b59f..a97dfecb8d 100644 --- a/typespec-tests/src/main/java/com/type/enums/extensible/ExtensibleClientBuilder.java +++ b/typespec-tests/src/main/java/com/type/enums/extensible/ExtensibleClientBuilder.java @@ -7,6 +7,7 @@ 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; @@ -40,8 +41,8 @@ * A builder for creating a new instance of the ExtensibleClient type. */ @ServiceClientBuilder(serviceClients = { ExtensibleClient.class, ExtensibleAsyncClient.class }) -public final class ExtensibleClientBuilder - implements HttpTrait, ConfigurationTrait { +public final class ExtensibleClientBuilder implements HttpTrait, + ConfigurationTrait, EndpointTrait { @Generated private static final String SDK_NAME = "name"; @@ -172,6 +173,22 @@ public ExtensibleClientBuilder configuration(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. */ @@ -199,8 +216,9 @@ public ExtensibleClientBuilder retryPolicy(RetryPolicy retryPolicy) { 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()); + = new ExtensibleClientImpl(localPipeline, JacksonAdapter.createDefaultSerializerAdapter(), localEndpoint); return client; } diff --git a/typespec-tests/src/main/java/com/type/enums/extensible/implementation/ExtensibleClientImpl.java b/typespec-tests/src/main/java/com/type/enums/extensible/implementation/ExtensibleClientImpl.java index ea61e06301..6f5732026d 100644 --- a/typespec-tests/src/main/java/com/type/enums/extensible/implementation/ExtensibleClientImpl.java +++ b/typespec-tests/src/main/java/com/type/enums/extensible/implementation/ExtensibleClientImpl.java @@ -15,6 +15,20 @@ * 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. */ @@ -59,19 +73,22 @@ public StringOperationsImpl getStringOperations() { /** * Initializes an instance of ExtensibleClient client. + * + * @param endpoint Service host. */ - public ExtensibleClientImpl() { + public ExtensibleClientImpl(String endpoint) { this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), - JacksonAdapter.createDefaultSerializerAdapter()); + 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) { - this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter()); + public ExtensibleClientImpl(HttpPipeline httpPipeline, String endpoint) { + this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint); } /** @@ -79,10 +96,12 @@ public ExtensibleClientImpl(HttpPipeline httpPipeline) { * * @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) { + 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/typespec-tests/src/main/java/com/type/enums/extensible/implementation/StringOperationsImpl.java b/typespec-tests/src/main/java/com/type/enums/extensible/implementation/StringOperationsImpl.java index cd5194e3e2..fa6ded7cef 100644 --- a/typespec-tests/src/main/java/com/type/enums/extensible/implementation/StringOperationsImpl.java +++ b/typespec-tests/src/main/java/com/type/enums/extensible/implementation/StringOperationsImpl.java @@ -9,6 +9,7 @@ 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; @@ -55,7 +56,7 @@ public final class StringOperationsImpl { * The interface defining all the services for ExtensibleClientStringOperations to be used by the proxy service to * perform REST calls. */ - @Host("http://localhost:3000") + @Host("{endpoint}") @ServiceInterface(name = "ExtensibleClientStri") public interface StringOperationsService { @Get("/type/enum/extensible/string/known-value") @@ -64,8 +65,8 @@ public interface StringOperationsService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> getKnownValue(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Mono> getKnownValue(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Get("/type/enum/extensible/string/known-value") @ExpectedResponses({ 200 }) @@ -73,8 +74,8 @@ Mono> getKnownValue(@HeaderParam("accept") String accept, R @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response getKnownValueSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Response getKnownValueSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Get("/type/enum/extensible/string/unknown-value") @ExpectedResponses({ 200 }) @@ -82,8 +83,8 @@ Response getKnownValueSync(@HeaderParam("accept") String accept, Req @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> getUnknownValue(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Mono> getUnknownValue(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Get("/type/enum/extensible/string/unknown-value") @ExpectedResponses({ 200 }) @@ -91,8 +92,8 @@ Mono> getUnknownValue(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response getUnknownValueSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Response getUnknownValueSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Put("/type/enum/extensible/string/known-value") @ExpectedResponses({ 204 }) @@ -100,8 +101,9 @@ Response getUnknownValueSync(@HeaderParam("accept") String accept, R @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> putKnownValue(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + 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 }) @@ -109,8 +111,9 @@ Mono> putKnownValue(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response putKnownValueSync(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + 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 }) @@ -118,8 +121,9 @@ Response putKnownValueSync(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> putUnknownValue(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + 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 }) @@ -127,8 +131,9 @@ Mono> putUnknownValue(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response putUnknownValueSync(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + Response putUnknownValueSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); } /** @@ -149,7 +154,8 @@ Response putUnknownValueSync(@HeaderParam("accept") String accept, @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getKnownValueWithResponseAsync(RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.getKnownValue(accept, requestOptions, context)); + return FluxUtil + .withContext(context -> service.getKnownValue(this.client.getEndpoint(), accept, requestOptions, context)); } /** @@ -170,7 +176,7 @@ public Mono> getKnownValueWithResponseAsync(RequestOptions @ServiceMethod(returns = ReturnType.SINGLE) public Response getKnownValueWithResponse(RequestOptions requestOptions) { final String accept = "application/json"; - return service.getKnownValueSync(accept, requestOptions, Context.NONE); + return service.getKnownValueSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); } /** @@ -191,7 +197,8 @@ public Response getKnownValueWithResponse(RequestOptions requestOpti @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getUnknownValueWithResponseAsync(RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.getUnknownValue(accept, requestOptions, context)); + return FluxUtil.withContext( + context -> service.getUnknownValue(this.client.getEndpoint(), accept, requestOptions, context)); } /** @@ -212,7 +219,7 @@ public Mono> getUnknownValueWithResponseAsync(RequestOption @ServiceMethod(returns = ReturnType.SINGLE) public Response getUnknownValueWithResponse(RequestOptions requestOptions) { final String accept = "application/json"; - return service.getUnknownValueSync(accept, requestOptions, Context.NONE); + return service.getUnknownValueSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); } /** @@ -233,8 +240,9 @@ public Response getUnknownValueWithResponse(RequestOptions requestOp */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> putKnownValueWithResponseAsync(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.putKnownValue(accept, body, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.putKnownValue(this.client.getEndpoint(), contentType, body, requestOptions, context)); } /** @@ -255,8 +263,8 @@ public Mono> putKnownValueWithResponseAsync(BinaryData body, Requ */ @ServiceMethod(returns = ReturnType.SINGLE) public Response putKnownValueWithResponse(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.putKnownValueSync(accept, body, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.putKnownValueSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); } /** @@ -277,8 +285,9 @@ public Response putKnownValueWithResponse(BinaryData body, RequestOptions */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> putUnknownValueWithResponseAsync(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.putUnknownValue(accept, body, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.putUnknownValue(this.client.getEndpoint(), contentType, body, requestOptions, context)); } /** @@ -299,7 +308,7 @@ public Mono> putUnknownValueWithResponseAsync(BinaryData body, Re */ @ServiceMethod(returns = ReturnType.SINGLE) public Response putUnknownValueWithResponse(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.putUnknownValueSync(accept, body, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.putUnknownValueSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/type/enums/fixed/FixedClientBuilder.java b/typespec-tests/src/main/java/com/type/enums/fixed/FixedClientBuilder.java index ff2435b80a..f6976efa4b 100644 --- a/typespec-tests/src/main/java/com/type/enums/fixed/FixedClientBuilder.java +++ b/typespec-tests/src/main/java/com/type/enums/fixed/FixedClientBuilder.java @@ -7,6 +7,7 @@ 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; @@ -40,7 +41,8 @@ * A builder for creating a new instance of the FixedClient type. */ @ServiceClientBuilder(serviceClients = { FixedClient.class, FixedAsyncClient.class }) -public final class FixedClientBuilder implements HttpTrait, ConfigurationTrait { +public final class FixedClientBuilder implements HttpTrait, ConfigurationTrait, + EndpointTrait { @Generated private static final String SDK_NAME = "name"; @@ -171,6 +173,22 @@ public FixedClientBuilder configuration(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. */ @@ -198,7 +216,9 @@ public FixedClientBuilder retryPolicy(RetryPolicy retryPolicy) { private FixedClientImpl buildInnerClient() { this.validateClient(); HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); - FixedClientImpl client = new FixedClientImpl(localPipeline, JacksonAdapter.createDefaultSerializerAdapter()); + String localEndpoint = (endpoint != null) ? endpoint : "http://localhost:3000"; + FixedClientImpl client + = new FixedClientImpl(localPipeline, JacksonAdapter.createDefaultSerializerAdapter(), localEndpoint); return client; } diff --git a/typespec-tests/src/main/java/com/type/enums/fixed/implementation/FixedClientImpl.java b/typespec-tests/src/main/java/com/type/enums/fixed/implementation/FixedClientImpl.java index 7cdbd69213..361d8fa839 100644 --- a/typespec-tests/src/main/java/com/type/enums/fixed/implementation/FixedClientImpl.java +++ b/typespec-tests/src/main/java/com/type/enums/fixed/implementation/FixedClientImpl.java @@ -15,6 +15,20 @@ * 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. */ @@ -59,19 +73,22 @@ public StringOperationsImpl getStringOperations() { /** * Initializes an instance of FixedClient client. + * + * @param endpoint Service host. */ - public FixedClientImpl() { + public FixedClientImpl(String endpoint) { this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), - JacksonAdapter.createDefaultSerializerAdapter()); + 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) { - this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter()); + public FixedClientImpl(HttpPipeline httpPipeline, String endpoint) { + this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint); } /** @@ -79,10 +96,12 @@ public FixedClientImpl(HttpPipeline httpPipeline) { * * @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) { + 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/typespec-tests/src/main/java/com/type/enums/fixed/implementation/StringOperationsImpl.java b/typespec-tests/src/main/java/com/type/enums/fixed/implementation/StringOperationsImpl.java index 62604da0a7..0bf97bfa46 100644 --- a/typespec-tests/src/main/java/com/type/enums/fixed/implementation/StringOperationsImpl.java +++ b/typespec-tests/src/main/java/com/type/enums/fixed/implementation/StringOperationsImpl.java @@ -9,6 +9,7 @@ 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; @@ -55,7 +56,7 @@ public final class StringOperationsImpl { * The interface defining all the services for FixedClientStringOperations to be used by the proxy service to * perform REST calls. */ - @Host("http://localhost:3000") + @Host("{endpoint}") @ServiceInterface(name = "FixedClientStringOpe") public interface StringOperationsService { @Get("/type/enum/fixed/string/known-value") @@ -64,8 +65,8 @@ public interface StringOperationsService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> getKnownValue(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Mono> getKnownValue(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Get("/type/enum/fixed/string/known-value") @ExpectedResponses({ 200 }) @@ -73,8 +74,8 @@ Mono> getKnownValue(@HeaderParam("accept") String accept, R @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response getKnownValueSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Response getKnownValueSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Put("/type/enum/fixed/string/known-value") @ExpectedResponses({ 204 }) @@ -82,8 +83,9 @@ Response getKnownValueSync(@HeaderParam("accept") String accept, Req @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> putKnownValue(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + 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 }) @@ -91,8 +93,9 @@ Mono> putKnownValue(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response putKnownValueSync(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + 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 }) @@ -100,8 +103,9 @@ Response putKnownValueSync(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> putUnknownValue(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + 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 }) @@ -109,8 +113,9 @@ Mono> putUnknownValue(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response putUnknownValueSync(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + Response putUnknownValueSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); } /** @@ -131,7 +136,8 @@ Response putUnknownValueSync(@HeaderParam("accept") String accept, @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getKnownValueWithResponseAsync(RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.getKnownValue(accept, requestOptions, context)); + return FluxUtil + .withContext(context -> service.getKnownValue(this.client.getEndpoint(), accept, requestOptions, context)); } /** @@ -152,7 +158,7 @@ public Mono> getKnownValueWithResponseAsync(RequestOptions @ServiceMethod(returns = ReturnType.SINGLE) public Response getKnownValueWithResponse(RequestOptions requestOptions) { final String accept = "application/json"; - return service.getKnownValueSync(accept, requestOptions, Context.NONE); + return service.getKnownValueSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); } /** @@ -173,8 +179,9 @@ public Response getKnownValueWithResponse(RequestOptions requestOpti */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> putKnownValueWithResponseAsync(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.putKnownValue(accept, body, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.putKnownValue(this.client.getEndpoint(), contentType, body, requestOptions, context)); } /** @@ -195,8 +202,8 @@ public Mono> putKnownValueWithResponseAsync(BinaryData body, Requ */ @ServiceMethod(returns = ReturnType.SINGLE) public Response putKnownValueWithResponse(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.putKnownValueSync(accept, body, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.putKnownValueSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); } /** @@ -217,8 +224,9 @@ public Response putKnownValueWithResponse(BinaryData body, RequestOptions */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> putUnknownValueWithResponseAsync(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.putUnknownValue(accept, body, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.putUnknownValue(this.client.getEndpoint(), contentType, body, requestOptions, context)); } /** @@ -239,7 +247,7 @@ public Mono> putUnknownValueWithResponseAsync(BinaryData body, Re */ @ServiceMethod(returns = ReturnType.SINGLE) public Response putUnknownValueWithResponse(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.putUnknownValueSync(accept, body, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.putUnknownValueSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/type/model/empty/EmptyClientBuilder.java b/typespec-tests/src/main/java/com/type/model/empty/EmptyClientBuilder.java index e51aee1be0..169491e894 100644 --- a/typespec-tests/src/main/java/com/type/model/empty/EmptyClientBuilder.java +++ b/typespec-tests/src/main/java/com/type/model/empty/EmptyClientBuilder.java @@ -7,6 +7,7 @@ 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; @@ -40,7 +41,8 @@ * A builder for creating a new instance of the EmptyClient type. */ @ServiceClientBuilder(serviceClients = { EmptyClient.class, EmptyAsyncClient.class }) -public final class EmptyClientBuilder implements HttpTrait, ConfigurationTrait { +public final class EmptyClientBuilder implements HttpTrait, ConfigurationTrait, + EndpointTrait { @Generated private static final String SDK_NAME = "name"; @@ -171,6 +173,22 @@ public EmptyClientBuilder configuration(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. */ @@ -198,7 +216,9 @@ public EmptyClientBuilder retryPolicy(RetryPolicy retryPolicy) { private EmptyClientImpl buildInnerClient() { this.validateClient(); HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); - EmptyClientImpl client = new EmptyClientImpl(localPipeline, JacksonAdapter.createDefaultSerializerAdapter()); + String localEndpoint = (endpoint != null) ? endpoint : "http://localhost:3000"; + EmptyClientImpl client + = new EmptyClientImpl(localPipeline, JacksonAdapter.createDefaultSerializerAdapter(), localEndpoint); return client; } diff --git a/typespec-tests/src/main/java/com/type/model/empty/implementation/EmptyClientImpl.java b/typespec-tests/src/main/java/com/type/model/empty/implementation/EmptyClientImpl.java index d71e6ad6dc..1efee1de49 100644 --- a/typespec-tests/src/main/java/com/type/model/empty/implementation/EmptyClientImpl.java +++ b/typespec-tests/src/main/java/com/type/model/empty/implementation/EmptyClientImpl.java @@ -9,6 +9,7 @@ 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; @@ -42,6 +43,20 @@ public final class EmptyClientImpl { */ 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. */ @@ -72,19 +87,22 @@ public SerializerAdapter getSerializerAdapter() { /** * Initializes an instance of EmptyClient client. + * + * @param endpoint Service host. */ - public EmptyClientImpl() { + public EmptyClientImpl(String endpoint) { this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), - JacksonAdapter.createDefaultSerializerAdapter()); + 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) { - this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter()); + public EmptyClientImpl(HttpPipeline httpPipeline, String endpoint) { + this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint); } /** @@ -92,17 +110,19 @@ public EmptyClientImpl(HttpPipeline httpPipeline) { * * @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) { + 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("http://localhost:3000") + @Host("{endpoint}") @ServiceInterface(name = "EmptyClient") public interface EmptyClientService { @Put("/type/model/empty/alone") @@ -111,8 +131,9 @@ public interface EmptyClientService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> putEmpty(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData input, RequestOptions requestOptions, Context context); + 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 }) @@ -120,8 +141,9 @@ Mono> putEmpty(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response putEmptySync(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData input, RequestOptions requestOptions, Context context); + 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 }) @@ -129,8 +151,8 @@ Response putEmptySync(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> getEmpty(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Mono> getEmpty(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Get("/type/model/empty/alone") @ExpectedResponses({ 200 }) @@ -138,8 +160,8 @@ Mono> getEmpty(@HeaderParam("accept") String accept, Reques @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response getEmptySync(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Response getEmptySync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Post("/type/model/empty/round-trip") @ExpectedResponses({ 200 }) @@ -147,7 +169,8 @@ Response getEmptySync(@HeaderParam("accept") String accept, RequestO @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> postRoundTripEmpty(@HeaderParam("accept") String accept, + 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") @@ -156,7 +179,8 @@ Mono> postRoundTripEmpty(@HeaderParam("accept") String acce @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response postRoundTripEmptySync(@HeaderParam("accept") String accept, + Response postRoundTripEmptySync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); } @@ -178,8 +202,9 @@ Response postRoundTripEmptySync(@HeaderParam("accept") String accept */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> putEmptyWithResponseAsync(BinaryData input, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.putEmpty(accept, input, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.putEmpty(this.getEndpoint(), contentType, input, requestOptions, context)); } /** @@ -200,8 +225,8 @@ public Mono> putEmptyWithResponseAsync(BinaryData input, RequestO */ @ServiceMethod(returns = ReturnType.SINGLE) public Response putEmptyWithResponse(BinaryData input, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.putEmptySync(accept, input, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.putEmptySync(this.getEndpoint(), contentType, input, requestOptions, Context.NONE); } /** @@ -223,7 +248,7 @@ public Response putEmptyWithResponse(BinaryData input, RequestOptions requ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getEmptyWithResponseAsync(RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.getEmpty(accept, requestOptions, context)); + return FluxUtil.withContext(context -> service.getEmpty(this.getEndpoint(), accept, requestOptions, context)); } /** @@ -244,7 +269,7 @@ public Mono> getEmptyWithResponseAsync(RequestOptions reque @ServiceMethod(returns = ReturnType.SINGLE) public Response getEmptyWithResponse(RequestOptions requestOptions) { final String accept = "application/json"; - return service.getEmptySync(accept, requestOptions, Context.NONE); + return service.getEmptySync(this.getEndpoint(), accept, requestOptions, Context.NONE); } /** @@ -273,8 +298,10 @@ public Response getEmptyWithResponse(RequestOptions requestOptions) @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(accept, body, requestOptions, context)); + return FluxUtil.withContext(context -> service.postRoundTripEmpty(this.getEndpoint(), contentType, accept, body, + requestOptions, context)); } /** @@ -301,7 +328,9 @@ public Mono> postRoundTripEmptyWithResponseAsync(BinaryData */ @ServiceMethod(returns = ReturnType.SINGLE) public Response postRoundTripEmptyWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; final String accept = "application/json"; - return service.postRoundTripEmptySync(accept, body, requestOptions, Context.NONE); + return service.postRoundTripEmptySync(this.getEndpoint(), contentType, accept, body, requestOptions, + Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/type/model/inheritance/enumdiscriminator/EnumDiscriminatorClientBuilder.java b/typespec-tests/src/main/java/com/type/model/inheritance/enumdiscriminator/EnumDiscriminatorClientBuilder.java index 8f52e6ae7c..2b53d06981 100644 --- a/typespec-tests/src/main/java/com/type/model/inheritance/enumdiscriminator/EnumDiscriminatorClientBuilder.java +++ b/typespec-tests/src/main/java/com/type/model/inheritance/enumdiscriminator/EnumDiscriminatorClientBuilder.java @@ -7,6 +7,7 @@ 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; @@ -40,8 +41,8 @@ * A builder for creating a new instance of the EnumDiscriminatorClient type. */ @ServiceClientBuilder(serviceClients = { EnumDiscriminatorClient.class, EnumDiscriminatorAsyncClient.class }) -public final class EnumDiscriminatorClientBuilder - implements HttpTrait, ConfigurationTrait { +public final class EnumDiscriminatorClientBuilder implements HttpTrait, + ConfigurationTrait, EndpointTrait { @Generated private static final String SDK_NAME = "name"; @@ -173,6 +174,22 @@ public EnumDiscriminatorClientBuilder configuration(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. */ @@ -200,8 +217,9 @@ public EnumDiscriminatorClientBuilder retryPolicy(RetryPolicy retryPolicy) { private EnumDiscriminatorClientImpl buildInnerClient() { this.validateClient(); HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); - EnumDiscriminatorClientImpl client - = new EnumDiscriminatorClientImpl(localPipeline, JacksonAdapter.createDefaultSerializerAdapter()); + String localEndpoint = (endpoint != null) ? endpoint : "http://localhost:3000"; + EnumDiscriminatorClientImpl client = new EnumDiscriminatorClientImpl(localPipeline, + JacksonAdapter.createDefaultSerializerAdapter(), localEndpoint); return client; } diff --git a/typespec-tests/src/main/java/com/type/model/inheritance/enumdiscriminator/implementation/EnumDiscriminatorClientImpl.java b/typespec-tests/src/main/java/com/type/model/inheritance/enumdiscriminator/implementation/EnumDiscriminatorClientImpl.java index fd4879ceef..7fd484ee8c 100644 --- a/typespec-tests/src/main/java/com/type/model/inheritance/enumdiscriminator/implementation/EnumDiscriminatorClientImpl.java +++ b/typespec-tests/src/main/java/com/type/model/inheritance/enumdiscriminator/implementation/EnumDiscriminatorClientImpl.java @@ -9,6 +9,7 @@ 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; @@ -41,6 +42,20 @@ public final class EnumDiscriminatorClientImpl { */ 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. */ @@ -71,19 +86,22 @@ public SerializerAdapter getSerializerAdapter() { /** * Initializes an instance of EnumDiscriminatorClient client. + * + * @param endpoint Service host. */ - public EnumDiscriminatorClientImpl() { + public EnumDiscriminatorClientImpl(String endpoint) { this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), - JacksonAdapter.createDefaultSerializerAdapter()); + 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) { - this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter()); + public EnumDiscriminatorClientImpl(HttpPipeline httpPipeline, String endpoint) { + this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint); } /** @@ -91,10 +109,13 @@ public EnumDiscriminatorClientImpl(HttpPipeline httpPipeline) { * * @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) { + 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()); } @@ -103,7 +124,7 @@ public EnumDiscriminatorClientImpl(HttpPipeline httpPipeline, SerializerAdapter * The interface defining all the services for EnumDiscriminatorClient to be used by the proxy service to perform * REST calls. */ - @Host("http://localhost:3000") + @Host("{endpoint}") @ServiceInterface(name = "EnumDiscriminatorCli") public interface EnumDiscriminatorClientService { @Get("/type/model/inheritance/enum-discriminator/extensible-enum") @@ -112,8 +133,8 @@ public interface EnumDiscriminatorClientService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> getExtensibleModel(@HeaderParam("accept") String accept, - RequestOptions requestOptions, Context context); + Mono> getExtensibleModel(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Get("/type/model/inheritance/enum-discriminator/extensible-enum") @ExpectedResponses({ 200 }) @@ -121,8 +142,8 @@ Mono> getExtensibleModel(@HeaderParam("accept") String acce @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response getExtensibleModelSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Response getExtensibleModelSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Put("/type/model/inheritance/enum-discriminator/extensible-enum") @ExpectedResponses({ 204 }) @@ -130,8 +151,9 @@ Response getExtensibleModelSync(@HeaderParam("accept") String accept @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> putExtensibleModel(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData input, RequestOptions requestOptions, Context context); + 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 }) @@ -139,8 +161,9 @@ Mono> putExtensibleModel(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response putExtensibleModelSync(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData input, RequestOptions requestOptions, Context context); + 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 }) @@ -148,8 +171,8 @@ Response putExtensibleModelSync(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> getExtensibleModelMissingDiscriminator(@HeaderParam("accept") String accept, - RequestOptions requestOptions, Context context); + 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 }) @@ -157,8 +180,8 @@ Mono> getExtensibleModelMissingDiscriminator(@HeaderParam(" @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response getExtensibleModelMissingDiscriminatorSync(@HeaderParam("accept") String accept, - RequestOptions requestOptions, Context context); + 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 }) @@ -166,8 +189,8 @@ Response getExtensibleModelMissingDiscriminatorSync(@HeaderParam("ac @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> getExtensibleModelWrongDiscriminator(@HeaderParam("accept") String accept, - RequestOptions requestOptions, Context context); + 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 }) @@ -175,8 +198,8 @@ Mono> getExtensibleModelWrongDiscriminator(@HeaderParam("ac @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response getExtensibleModelWrongDiscriminatorSync(@HeaderParam("accept") String accept, - RequestOptions requestOptions, Context context); + Response getExtensibleModelWrongDiscriminatorSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Get("/type/model/inheritance/enum-discriminator/fixed-enum") @ExpectedResponses({ 200 }) @@ -184,8 +207,8 @@ Response getExtensibleModelWrongDiscriminatorSync(@HeaderParam("acce @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> getFixedModel(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Mono> getFixedModel(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Get("/type/model/inheritance/enum-discriminator/fixed-enum") @ExpectedResponses({ 200 }) @@ -193,8 +216,8 @@ Mono> getFixedModel(@HeaderParam("accept") String accept, R @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response getFixedModelSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Response getFixedModelSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Put("/type/model/inheritance/enum-discriminator/fixed-enum") @ExpectedResponses({ 204 }) @@ -202,8 +225,9 @@ Response getFixedModelSync(@HeaderParam("accept") String accept, Req @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> putFixedModel(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData input, RequestOptions requestOptions, Context context); + 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 }) @@ -211,8 +235,9 @@ Mono> putFixedModel(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response putFixedModelSync(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData input, RequestOptions requestOptions, Context context); + 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 }) @@ -220,8 +245,8 @@ Response putFixedModelSync(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> getFixedModelMissingDiscriminator(@HeaderParam("accept") String accept, - RequestOptions requestOptions, Context context); + 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 }) @@ -229,8 +254,8 @@ Mono> getFixedModelMissingDiscriminator(@HeaderParam("accep @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response getFixedModelMissingDiscriminatorSync(@HeaderParam("accept") String accept, - RequestOptions requestOptions, Context context); + 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 }) @@ -238,8 +263,8 @@ Response getFixedModelMissingDiscriminatorSync(@HeaderParam("accept" @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> getFixedModelWrongDiscriminator(@HeaderParam("accept") String accept, - RequestOptions requestOptions, Context context); + 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 }) @@ -247,8 +272,8 @@ Mono> getFixedModelWrongDiscriminator(@HeaderParam("accept" @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response getFixedModelWrongDiscriminatorSync(@HeaderParam("accept") String accept, - RequestOptions requestOptions, Context context); + Response getFixedModelWrongDiscriminatorSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); } /** @@ -273,7 +298,8 @@ Response getFixedModelWrongDiscriminatorSync(@HeaderParam("accept") @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getExtensibleModelWithResponseAsync(RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.getExtensibleModel(accept, requestOptions, context)); + return FluxUtil + .withContext(context -> service.getExtensibleModel(this.getEndpoint(), accept, requestOptions, context)); } /** @@ -297,7 +323,7 @@ public Mono> getExtensibleModelWithResponseAsync(RequestOpt @ServiceMethod(returns = ReturnType.SINGLE) public Response getExtensibleModelWithResponse(RequestOptions requestOptions) { final String accept = "application/json"; - return service.getExtensibleModelSync(accept, requestOptions, Context.NONE); + return service.getExtensibleModelSync(this.getEndpoint(), accept, requestOptions, Context.NONE); } /** @@ -321,8 +347,9 @@ public Response getExtensibleModelWithResponse(RequestOptions reques */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> putExtensibleModelWithResponseAsync(BinaryData input, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.putExtensibleModel(accept, input, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.putExtensibleModel(this.getEndpoint(), contentType, input, requestOptions, context)); } /** @@ -346,8 +373,8 @@ public Mono> putExtensibleModelWithResponseAsync(BinaryData input */ @ServiceMethod(returns = ReturnType.SINGLE) public Response putExtensibleModelWithResponse(BinaryData input, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.putExtensibleModelSync(accept, input, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.putExtensibleModelSync(this.getEndpoint(), contentType, input, requestOptions, Context.NONE); } /** @@ -372,8 +399,8 @@ public Response putExtensibleModelWithResponse(BinaryData input, RequestOp public Mono> getExtensibleModelMissingDiscriminatorWithResponseAsync(RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil - .withContext(context -> service.getExtensibleModelMissingDiscriminator(accept, requestOptions, context)); + return FluxUtil.withContext(context -> service.getExtensibleModelMissingDiscriminator(this.getEndpoint(), + accept, requestOptions, context)); } /** @@ -397,7 +424,8 @@ public Response putExtensibleModelWithResponse(BinaryData input, RequestOp @ServiceMethod(returns = ReturnType.SINGLE) public Response getExtensibleModelMissingDiscriminatorWithResponse(RequestOptions requestOptions) { final String accept = "application/json"; - return service.getExtensibleModelMissingDiscriminatorSync(accept, requestOptions, Context.NONE); + return service.getExtensibleModelMissingDiscriminatorSync(this.getEndpoint(), accept, requestOptions, + Context.NONE); } /** @@ -423,8 +451,8 @@ public Response getExtensibleModelMissingDiscriminatorWithResponse(R public Mono> getExtensibleModelWrongDiscriminatorWithResponseAsync(RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil - .withContext(context -> service.getExtensibleModelWrongDiscriminator(accept, requestOptions, context)); + return FluxUtil.withContext(context -> service.getExtensibleModelWrongDiscriminator(this.getEndpoint(), accept, + requestOptions, context)); } /** @@ -448,7 +476,8 @@ public Response getExtensibleModelMissingDiscriminatorWithResponse(R @ServiceMethod(returns = ReturnType.SINGLE) public Response getExtensibleModelWrongDiscriminatorWithResponse(RequestOptions requestOptions) { final String accept = "application/json"; - return service.getExtensibleModelWrongDiscriminatorSync(accept, requestOptions, Context.NONE); + return service.getExtensibleModelWrongDiscriminatorSync(this.getEndpoint(), accept, requestOptions, + Context.NONE); } /** @@ -473,7 +502,8 @@ public Response getExtensibleModelWrongDiscriminatorWithResponse(Req @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getFixedModelWithResponseAsync(RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.getFixedModel(accept, requestOptions, context)); + return FluxUtil + .withContext(context -> service.getFixedModel(this.getEndpoint(), accept, requestOptions, context)); } /** @@ -497,7 +527,7 @@ public Mono> getFixedModelWithResponseAsync(RequestOptions @ServiceMethod(returns = ReturnType.SINGLE) public Response getFixedModelWithResponse(RequestOptions requestOptions) { final String accept = "application/json"; - return service.getFixedModelSync(accept, requestOptions, Context.NONE); + return service.getFixedModelSync(this.getEndpoint(), accept, requestOptions, Context.NONE); } /** @@ -521,8 +551,9 @@ public Response getFixedModelWithResponse(RequestOptions requestOpti */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> putFixedModelWithResponseAsync(BinaryData input, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.putFixedModel(accept, input, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.putFixedModel(this.getEndpoint(), contentType, input, requestOptions, context)); } /** @@ -546,8 +577,8 @@ public Mono> putFixedModelWithResponseAsync(BinaryData input, Req */ @ServiceMethod(returns = ReturnType.SINGLE) public Response putFixedModelWithResponse(BinaryData input, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.putFixedModelSync(accept, input, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.putFixedModelSync(this.getEndpoint(), contentType, input, requestOptions, Context.NONE); } /** @@ -572,8 +603,8 @@ public Response putFixedModelWithResponse(BinaryData input, RequestOptions public Mono> getFixedModelMissingDiscriminatorWithResponseAsync(RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil - .withContext(context -> service.getFixedModelMissingDiscriminator(accept, requestOptions, context)); + return FluxUtil.withContext( + context -> service.getFixedModelMissingDiscriminator(this.getEndpoint(), accept, requestOptions, context)); } /** @@ -597,7 +628,7 @@ public Response putFixedModelWithResponse(BinaryData input, RequestOptions @ServiceMethod(returns = ReturnType.SINGLE) public Response getFixedModelMissingDiscriminatorWithResponse(RequestOptions requestOptions) { final String accept = "application/json"; - return service.getFixedModelMissingDiscriminatorSync(accept, requestOptions, Context.NONE); + return service.getFixedModelMissingDiscriminatorSync(this.getEndpoint(), accept, requestOptions, Context.NONE); } /** @@ -622,8 +653,8 @@ public Response getFixedModelMissingDiscriminatorWithResponse(Reques @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getFixedModelWrongDiscriminatorWithResponseAsync(RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil - .withContext(context -> service.getFixedModelWrongDiscriminator(accept, requestOptions, context)); + return FluxUtil.withContext( + context -> service.getFixedModelWrongDiscriminator(this.getEndpoint(), accept, requestOptions, context)); } /** @@ -647,6 +678,6 @@ public Mono> getFixedModelWrongDiscriminatorWithResponseAsy @ServiceMethod(returns = ReturnType.SINGLE) public Response getFixedModelWrongDiscriminatorWithResponse(RequestOptions requestOptions) { final String accept = "application/json"; - return service.getFixedModelWrongDiscriminatorSync(accept, requestOptions, Context.NONE); + return service.getFixedModelWrongDiscriminatorSync(this.getEndpoint(), accept, requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/type/model/inheritance/enumnesteddiscriminator/EnumNestedDiscriminatorClientBuilder.java b/typespec-tests/src/main/java/com/type/model/inheritance/enumnesteddiscriminator/EnumNestedDiscriminatorClientBuilder.java index ca6f9c6315..277df88727 100644 --- a/typespec-tests/src/main/java/com/type/model/inheritance/enumnesteddiscriminator/EnumNestedDiscriminatorClientBuilder.java +++ b/typespec-tests/src/main/java/com/type/model/inheritance/enumnesteddiscriminator/EnumNestedDiscriminatorClientBuilder.java @@ -7,6 +7,7 @@ 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; @@ -42,7 +43,7 @@ @ServiceClientBuilder( serviceClients = { EnumNestedDiscriminatorClient.class, EnumNestedDiscriminatorAsyncClient.class }) public final class EnumNestedDiscriminatorClientBuilder implements HttpTrait, - ConfigurationTrait { + ConfigurationTrait, EndpointTrait { @Generated private static final String SDK_NAME = "name"; @@ -174,6 +175,22 @@ public EnumNestedDiscriminatorClientBuilder configuration(Configuration configur 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. */ @@ -201,8 +218,9 @@ public EnumNestedDiscriminatorClientBuilder retryPolicy(RetryPolicy retryPolicy) private EnumNestedDiscriminatorClientImpl buildInnerClient() { this.validateClient(); HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); - EnumNestedDiscriminatorClientImpl client - = new EnumNestedDiscriminatorClientImpl(localPipeline, JacksonAdapter.createDefaultSerializerAdapter()); + String localEndpoint = (endpoint != null) ? endpoint : "http://localhost:3000"; + EnumNestedDiscriminatorClientImpl client = new EnumNestedDiscriminatorClientImpl(localPipeline, + JacksonAdapter.createDefaultSerializerAdapter(), localEndpoint); return client; } diff --git a/typespec-tests/src/main/java/com/type/model/inheritance/enumnesteddiscriminator/implementation/EnumNestedDiscriminatorClientImpl.java b/typespec-tests/src/main/java/com/type/model/inheritance/enumnesteddiscriminator/implementation/EnumNestedDiscriminatorClientImpl.java index 92fe6ffd6d..b98c4ecb03 100644 --- a/typespec-tests/src/main/java/com/type/model/inheritance/enumnesteddiscriminator/implementation/EnumNestedDiscriminatorClientImpl.java +++ b/typespec-tests/src/main/java/com/type/model/inheritance/enumnesteddiscriminator/implementation/EnumNestedDiscriminatorClientImpl.java @@ -9,6 +9,7 @@ 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; @@ -41,6 +42,20 @@ public final class EnumNestedDiscriminatorClientImpl { */ 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. */ @@ -71,19 +86,22 @@ public SerializerAdapter getSerializerAdapter() { /** * Initializes an instance of EnumNestedDiscriminatorClient client. + * + * @param endpoint Service host. */ - public EnumNestedDiscriminatorClientImpl() { + public EnumNestedDiscriminatorClientImpl(String endpoint) { this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), - JacksonAdapter.createDefaultSerializerAdapter()); + 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) { - this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter()); + public EnumNestedDiscriminatorClientImpl(HttpPipeline httpPipeline, String endpoint) { + this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint); } /** @@ -91,10 +109,13 @@ public EnumNestedDiscriminatorClientImpl(HttpPipeline httpPipeline) { * * @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) { + 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()); } @@ -103,7 +124,7 @@ public EnumNestedDiscriminatorClientImpl(HttpPipeline httpPipeline, SerializerAd * The interface defining all the services for EnumNestedDiscriminatorClient to be used by the proxy service to * perform REST calls. */ - @Host("http://localhost:3000") + @Host("{endpoint}") @ServiceInterface(name = "EnumNestedDiscrimina") public interface EnumNestedDiscriminatorClientService { @Get("/type/model/inheritance/enum-nested-discriminator/model") @@ -112,8 +133,8 @@ public interface EnumNestedDiscriminatorClientService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> getModel(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Mono> getModel(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Get("/type/model/inheritance/enum-nested-discriminator/model") @ExpectedResponses({ 200 }) @@ -121,8 +142,8 @@ Mono> getModel(@HeaderParam("accept") String accept, Reques @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response getModelSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Response getModelSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Put("/type/model/inheritance/enum-nested-discriminator/model") @ExpectedResponses({ 204 }) @@ -130,8 +151,9 @@ Response getModelSync(@HeaderParam("accept") String accept, RequestO @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> putModel(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData input, RequestOptions requestOptions, Context context); + 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 }) @@ -139,8 +161,9 @@ Mono> putModel(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response putModelSync(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData input, RequestOptions requestOptions, Context context); + 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 }) @@ -148,8 +171,8 @@ Response putModelSync(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> getRecursiveModel(@HeaderParam("accept") String accept, - RequestOptions requestOptions, Context context); + Mono> getRecursiveModel(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Get("/type/model/inheritance/enum-nested-discriminator/recursivemodel") @ExpectedResponses({ 200 }) @@ -157,8 +180,8 @@ Mono> getRecursiveModel(@HeaderParam("accept") String accep @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response getRecursiveModelSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Response getRecursiveModelSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Put("/type/model/inheritance/enum-nested-discriminator/recursivemodel") @ExpectedResponses({ 204 }) @@ -166,8 +189,9 @@ Response getRecursiveModelSync(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> putRecursiveModel(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData input, RequestOptions requestOptions, Context context); + 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 }) @@ -175,8 +199,9 @@ Mono> putRecursiveModel(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response putRecursiveModelSync(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData input, RequestOptions requestOptions, Context context); + 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 }) @@ -184,8 +209,8 @@ Response putRecursiveModelSync(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> getMissingDiscriminator(@HeaderParam("accept") String accept, - RequestOptions requestOptions, Context context); + Mono> getMissingDiscriminator(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Get("/type/model/inheritance/enum-nested-discriminator/missingdiscriminator") @ExpectedResponses({ 200 }) @@ -193,8 +218,8 @@ Mono> getMissingDiscriminator(@HeaderParam("accept") String @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response getMissingDiscriminatorSync(@HeaderParam("accept") String accept, - RequestOptions requestOptions, Context context); + Response getMissingDiscriminatorSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Get("/type/model/inheritance/enum-nested-discriminator/wrongdiscriminator") @ExpectedResponses({ 200 }) @@ -202,8 +227,8 @@ Response getMissingDiscriminatorSync(@HeaderParam("accept") String a @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> getWrongDiscriminator(@HeaderParam("accept") String accept, - RequestOptions requestOptions, Context context); + Mono> getWrongDiscriminator(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Get("/type/model/inheritance/enum-nested-discriminator/wrongdiscriminator") @ExpectedResponses({ 200 }) @@ -211,8 +236,8 @@ Mono> getWrongDiscriminator(@HeaderParam("accept") String a @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response getWrongDiscriminatorSync(@HeaderParam("accept") String accept, - RequestOptions requestOptions, Context context); + Response getWrongDiscriminatorSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); } /** @@ -237,7 +262,7 @@ Response getWrongDiscriminatorSync(@HeaderParam("accept") String acc @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getModelWithResponseAsync(RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.getModel(accept, requestOptions, context)); + return FluxUtil.withContext(context -> service.getModel(this.getEndpoint(), accept, requestOptions, context)); } /** @@ -262,7 +287,7 @@ public Mono> getModelWithResponseAsync(RequestOptions reque @ServiceMethod(returns = ReturnType.SINGLE) public Response getModelWithResponse(RequestOptions requestOptions) { final String accept = "application/json"; - return service.getModelSync(accept, requestOptions, Context.NONE); + return service.getModelSync(this.getEndpoint(), accept, requestOptions, Context.NONE); } /** @@ -286,8 +311,9 @@ public Response getModelWithResponse(RequestOptions requestOptions) */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> putModelWithResponseAsync(BinaryData input, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.putModel(accept, input, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.putModel(this.getEndpoint(), contentType, input, requestOptions, context)); } /** @@ -311,8 +337,8 @@ public Mono> putModelWithResponseAsync(BinaryData input, RequestO */ @ServiceMethod(returns = ReturnType.SINGLE) public Response putModelWithResponse(BinaryData input, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.putModelSync(accept, input, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.putModelSync(this.getEndpoint(), contentType, input, requestOptions, Context.NONE); } /** @@ -337,7 +363,8 @@ public Response putModelWithResponse(BinaryData input, RequestOptions requ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getRecursiveModelWithResponseAsync(RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.getRecursiveModel(accept, requestOptions, context)); + return FluxUtil + .withContext(context -> service.getRecursiveModel(this.getEndpoint(), accept, requestOptions, context)); } /** @@ -362,7 +389,7 @@ public Mono> getRecursiveModelWithResponseAsync(RequestOpti @ServiceMethod(returns = ReturnType.SINGLE) public Response getRecursiveModelWithResponse(RequestOptions requestOptions) { final String accept = "application/json"; - return service.getRecursiveModelSync(accept, requestOptions, Context.NONE); + return service.getRecursiveModelSync(this.getEndpoint(), accept, requestOptions, Context.NONE); } /** @@ -386,8 +413,9 @@ public Response getRecursiveModelWithResponse(RequestOptions request */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> putRecursiveModelWithResponseAsync(BinaryData input, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.putRecursiveModel(accept, input, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.putRecursiveModel(this.getEndpoint(), contentType, input, requestOptions, context)); } /** @@ -411,8 +439,8 @@ public Mono> putRecursiveModelWithResponseAsync(BinaryData input, */ @ServiceMethod(returns = ReturnType.SINGLE) public Response putRecursiveModelWithResponse(BinaryData input, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.putRecursiveModelSync(accept, input, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.putRecursiveModelSync(this.getEndpoint(), contentType, input, requestOptions, Context.NONE); } /** @@ -437,7 +465,8 @@ public Response putRecursiveModelWithResponse(BinaryData input, RequestOpt @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getMissingDiscriminatorWithResponseAsync(RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.getMissingDiscriminator(accept, requestOptions, context)); + return FluxUtil.withContext( + context -> service.getMissingDiscriminator(this.getEndpoint(), accept, requestOptions, context)); } /** @@ -462,7 +491,7 @@ public Mono> getMissingDiscriminatorWithResponseAsync(Reque @ServiceMethod(returns = ReturnType.SINGLE) public Response getMissingDiscriminatorWithResponse(RequestOptions requestOptions) { final String accept = "application/json"; - return service.getMissingDiscriminatorSync(accept, requestOptions, Context.NONE); + return service.getMissingDiscriminatorSync(this.getEndpoint(), accept, requestOptions, Context.NONE); } /** @@ -487,7 +516,8 @@ public Response getMissingDiscriminatorWithResponse(RequestOptions r @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getWrongDiscriminatorWithResponseAsync(RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.getWrongDiscriminator(accept, requestOptions, context)); + return FluxUtil + .withContext(context -> service.getWrongDiscriminator(this.getEndpoint(), accept, requestOptions, context)); } /** @@ -512,6 +542,6 @@ public Mono> getWrongDiscriminatorWithResponseAsync(Request @ServiceMethod(returns = ReturnType.SINGLE) public Response getWrongDiscriminatorWithResponse(RequestOptions requestOptions) { final String accept = "application/json"; - return service.getWrongDiscriminatorSync(accept, requestOptions, Context.NONE); + return service.getWrongDiscriminatorSync(this.getEndpoint(), accept, requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/type/model/inheritance/nesteddiscriminator/NestedDiscriminatorClientBuilder.java b/typespec-tests/src/main/java/com/type/model/inheritance/nesteddiscriminator/NestedDiscriminatorClientBuilder.java index e99a536486..90d61f9bf0 100644 --- a/typespec-tests/src/main/java/com/type/model/inheritance/nesteddiscriminator/NestedDiscriminatorClientBuilder.java +++ b/typespec-tests/src/main/java/com/type/model/inheritance/nesteddiscriminator/NestedDiscriminatorClientBuilder.java @@ -7,6 +7,7 @@ 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; @@ -40,8 +41,8 @@ * A builder for creating a new instance of the NestedDiscriminatorClient type. */ @ServiceClientBuilder(serviceClients = { NestedDiscriminatorClient.class, NestedDiscriminatorAsyncClient.class }) -public final class NestedDiscriminatorClientBuilder - implements HttpTrait, ConfigurationTrait { +public final class NestedDiscriminatorClientBuilder implements HttpTrait, + ConfigurationTrait, EndpointTrait { @Generated private static final String SDK_NAME = "name"; @@ -173,6 +174,22 @@ public NestedDiscriminatorClientBuilder configuration(Configuration configuratio 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. */ @@ -200,8 +217,9 @@ public NestedDiscriminatorClientBuilder retryPolicy(RetryPolicy retryPolicy) { private NestedDiscriminatorClientImpl buildInnerClient() { this.validateClient(); HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); - NestedDiscriminatorClientImpl client - = new NestedDiscriminatorClientImpl(localPipeline, JacksonAdapter.createDefaultSerializerAdapter()); + String localEndpoint = (endpoint != null) ? endpoint : "http://localhost:3000"; + NestedDiscriminatorClientImpl client = new NestedDiscriminatorClientImpl(localPipeline, + JacksonAdapter.createDefaultSerializerAdapter(), localEndpoint); return client; } diff --git a/typespec-tests/src/main/java/com/type/model/inheritance/nesteddiscriminator/implementation/NestedDiscriminatorClientImpl.java b/typespec-tests/src/main/java/com/type/model/inheritance/nesteddiscriminator/implementation/NestedDiscriminatorClientImpl.java index 0872049d53..7b9917ffe7 100644 --- a/typespec-tests/src/main/java/com/type/model/inheritance/nesteddiscriminator/implementation/NestedDiscriminatorClientImpl.java +++ b/typespec-tests/src/main/java/com/type/model/inheritance/nesteddiscriminator/implementation/NestedDiscriminatorClientImpl.java @@ -9,6 +9,7 @@ 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; @@ -41,6 +42,20 @@ public final class NestedDiscriminatorClientImpl { */ 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. */ @@ -71,19 +86,22 @@ public SerializerAdapter getSerializerAdapter() { /** * Initializes an instance of NestedDiscriminatorClient client. + * + * @param endpoint Service host. */ - public NestedDiscriminatorClientImpl() { + public NestedDiscriminatorClientImpl(String endpoint) { this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), - JacksonAdapter.createDefaultSerializerAdapter()); + 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) { - this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter()); + public NestedDiscriminatorClientImpl(HttpPipeline httpPipeline, String endpoint) { + this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint); } /** @@ -91,10 +109,13 @@ public NestedDiscriminatorClientImpl(HttpPipeline httpPipeline) { * * @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) { + 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()); } @@ -103,7 +124,7 @@ public NestedDiscriminatorClientImpl(HttpPipeline httpPipeline, SerializerAdapte * The interface defining all the services for NestedDiscriminatorClient to be used by the proxy service to perform * REST calls. */ - @Host("http://localhost:3000") + @Host("{endpoint}") @ServiceInterface(name = "NestedDiscriminatorC") public interface NestedDiscriminatorClientService { @Get("/type/model/inheritance/nested-discriminator/model") @@ -112,8 +133,8 @@ public interface NestedDiscriminatorClientService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> getModel(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Mono> getModel(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Get("/type/model/inheritance/nested-discriminator/model") @ExpectedResponses({ 200 }) @@ -121,8 +142,8 @@ Mono> getModel(@HeaderParam("accept") String accept, Reques @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response getModelSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Response getModelSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Put("/type/model/inheritance/nested-discriminator/model") @ExpectedResponses({ 204 }) @@ -130,8 +151,9 @@ Response getModelSync(@HeaderParam("accept") String accept, RequestO @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> putModel(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData input, RequestOptions requestOptions, Context context); + 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 }) @@ -139,8 +161,9 @@ Mono> putModel(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response putModelSync(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData input, RequestOptions requestOptions, Context context); + 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 }) @@ -148,8 +171,8 @@ Response putModelSync(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> getRecursiveModel(@HeaderParam("accept") String accept, - RequestOptions requestOptions, Context context); + Mono> getRecursiveModel(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Get("/type/model/inheritance/nested-discriminator/recursivemodel") @ExpectedResponses({ 200 }) @@ -157,8 +180,8 @@ Mono> getRecursiveModel(@HeaderParam("accept") String accep @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response getRecursiveModelSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Response getRecursiveModelSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Put("/type/model/inheritance/nested-discriminator/recursivemodel") @ExpectedResponses({ 204 }) @@ -166,8 +189,9 @@ Response getRecursiveModelSync(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> putRecursiveModel(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData input, RequestOptions requestOptions, Context context); + 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 }) @@ -175,8 +199,9 @@ Mono> putRecursiveModel(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response putRecursiveModelSync(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData input, RequestOptions requestOptions, Context context); + 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 }) @@ -184,8 +209,8 @@ Response putRecursiveModelSync(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> getMissingDiscriminator(@HeaderParam("accept") String accept, - RequestOptions requestOptions, Context context); + Mono> getMissingDiscriminator(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Get("/type/model/inheritance/nested-discriminator/missingdiscriminator") @ExpectedResponses({ 200 }) @@ -193,8 +218,8 @@ Mono> getMissingDiscriminator(@HeaderParam("accept") String @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response getMissingDiscriminatorSync(@HeaderParam("accept") String accept, - RequestOptions requestOptions, Context context); + Response getMissingDiscriminatorSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Get("/type/model/inheritance/nested-discriminator/wrongdiscriminator") @ExpectedResponses({ 200 }) @@ -202,8 +227,8 @@ Response getMissingDiscriminatorSync(@HeaderParam("accept") String a @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> getWrongDiscriminator(@HeaderParam("accept") String accept, - RequestOptions requestOptions, Context context); + Mono> getWrongDiscriminator(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Get("/type/model/inheritance/nested-discriminator/wrongdiscriminator") @ExpectedResponses({ 200 }) @@ -211,8 +236,8 @@ Mono> getWrongDiscriminator(@HeaderParam("accept") String a @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response getWrongDiscriminatorSync(@HeaderParam("accept") String accept, - RequestOptions requestOptions, Context context); + Response getWrongDiscriminatorSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); } /** @@ -237,7 +262,7 @@ Response getWrongDiscriminatorSync(@HeaderParam("accept") String acc @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getModelWithResponseAsync(RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.getModel(accept, requestOptions, context)); + return FluxUtil.withContext(context -> service.getModel(this.getEndpoint(), accept, requestOptions, context)); } /** @@ -262,7 +287,7 @@ public Mono> getModelWithResponseAsync(RequestOptions reque @ServiceMethod(returns = ReturnType.SINGLE) public Response getModelWithResponse(RequestOptions requestOptions) { final String accept = "application/json"; - return service.getModelSync(accept, requestOptions, Context.NONE); + return service.getModelSync(this.getEndpoint(), accept, requestOptions, Context.NONE); } /** @@ -286,8 +311,9 @@ public Response getModelWithResponse(RequestOptions requestOptions) */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> putModelWithResponseAsync(BinaryData input, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.putModel(accept, input, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.putModel(this.getEndpoint(), contentType, input, requestOptions, context)); } /** @@ -311,8 +337,8 @@ public Mono> putModelWithResponseAsync(BinaryData input, RequestO */ @ServiceMethod(returns = ReturnType.SINGLE) public Response putModelWithResponse(BinaryData input, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.putModelSync(accept, input, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.putModelSync(this.getEndpoint(), contentType, input, requestOptions, Context.NONE); } /** @@ -337,7 +363,8 @@ public Response putModelWithResponse(BinaryData input, RequestOptions requ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getRecursiveModelWithResponseAsync(RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.getRecursiveModel(accept, requestOptions, context)); + return FluxUtil + .withContext(context -> service.getRecursiveModel(this.getEndpoint(), accept, requestOptions, context)); } /** @@ -362,7 +389,7 @@ public Mono> getRecursiveModelWithResponseAsync(RequestOpti @ServiceMethod(returns = ReturnType.SINGLE) public Response getRecursiveModelWithResponse(RequestOptions requestOptions) { final String accept = "application/json"; - return service.getRecursiveModelSync(accept, requestOptions, Context.NONE); + return service.getRecursiveModelSync(this.getEndpoint(), accept, requestOptions, Context.NONE); } /** @@ -386,8 +413,9 @@ public Response getRecursiveModelWithResponse(RequestOptions request */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> putRecursiveModelWithResponseAsync(BinaryData input, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.putRecursiveModel(accept, input, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.putRecursiveModel(this.getEndpoint(), contentType, input, requestOptions, context)); } /** @@ -411,8 +439,8 @@ public Mono> putRecursiveModelWithResponseAsync(BinaryData input, */ @ServiceMethod(returns = ReturnType.SINGLE) public Response putRecursiveModelWithResponse(BinaryData input, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.putRecursiveModelSync(accept, input, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.putRecursiveModelSync(this.getEndpoint(), contentType, input, requestOptions, Context.NONE); } /** @@ -437,7 +465,8 @@ public Response putRecursiveModelWithResponse(BinaryData input, RequestOpt @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getMissingDiscriminatorWithResponseAsync(RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.getMissingDiscriminator(accept, requestOptions, context)); + return FluxUtil.withContext( + context -> service.getMissingDiscriminator(this.getEndpoint(), accept, requestOptions, context)); } /** @@ -462,7 +491,7 @@ public Mono> getMissingDiscriminatorWithResponseAsync(Reque @ServiceMethod(returns = ReturnType.SINGLE) public Response getMissingDiscriminatorWithResponse(RequestOptions requestOptions) { final String accept = "application/json"; - return service.getMissingDiscriminatorSync(accept, requestOptions, Context.NONE); + return service.getMissingDiscriminatorSync(this.getEndpoint(), accept, requestOptions, Context.NONE); } /** @@ -487,7 +516,8 @@ public Response getMissingDiscriminatorWithResponse(RequestOptions r @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getWrongDiscriminatorWithResponseAsync(RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.getWrongDiscriminator(accept, requestOptions, context)); + return FluxUtil + .withContext(context -> service.getWrongDiscriminator(this.getEndpoint(), accept, requestOptions, context)); } /** @@ -512,6 +542,6 @@ public Mono> getWrongDiscriminatorWithResponseAsync(Request @ServiceMethod(returns = ReturnType.SINGLE) public Response getWrongDiscriminatorWithResponse(RequestOptions requestOptions) { final String accept = "application/json"; - return service.getWrongDiscriminatorSync(accept, requestOptions, Context.NONE); + return service.getWrongDiscriminatorSync(this.getEndpoint(), accept, requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/type/model/inheritance/notdiscriminated/NotDiscriminatedClientBuilder.java b/typespec-tests/src/main/java/com/type/model/inheritance/notdiscriminated/NotDiscriminatedClientBuilder.java index d9143fe96e..65589f6b8f 100644 --- a/typespec-tests/src/main/java/com/type/model/inheritance/notdiscriminated/NotDiscriminatedClientBuilder.java +++ b/typespec-tests/src/main/java/com/type/model/inheritance/notdiscriminated/NotDiscriminatedClientBuilder.java @@ -7,6 +7,7 @@ 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; @@ -40,8 +41,8 @@ * A builder for creating a new instance of the NotDiscriminatedClient type. */ @ServiceClientBuilder(serviceClients = { NotDiscriminatedClient.class, NotDiscriminatedAsyncClient.class }) -public final class NotDiscriminatedClientBuilder - implements HttpTrait, ConfigurationTrait { +public final class NotDiscriminatedClientBuilder implements HttpTrait, + ConfigurationTrait, EndpointTrait { @Generated private static final String SDK_NAME = "name"; @@ -173,6 +174,22 @@ public NotDiscriminatedClientBuilder configuration(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. */ @@ -200,8 +217,9 @@ public NotDiscriminatedClientBuilder retryPolicy(RetryPolicy retryPolicy) { private NotDiscriminatedClientImpl buildInnerClient() { this.validateClient(); HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); - NotDiscriminatedClientImpl client - = new NotDiscriminatedClientImpl(localPipeline, JacksonAdapter.createDefaultSerializerAdapter()); + String localEndpoint = (endpoint != null) ? endpoint : "http://localhost:3000"; + NotDiscriminatedClientImpl client = new NotDiscriminatedClientImpl(localPipeline, + JacksonAdapter.createDefaultSerializerAdapter(), localEndpoint); return client; } diff --git a/typespec-tests/src/main/java/com/type/model/inheritance/notdiscriminated/implementation/NotDiscriminatedClientImpl.java b/typespec-tests/src/main/java/com/type/model/inheritance/notdiscriminated/implementation/NotDiscriminatedClientImpl.java index 95a7d97592..8bbbad56a7 100644 --- a/typespec-tests/src/main/java/com/type/model/inheritance/notdiscriminated/implementation/NotDiscriminatedClientImpl.java +++ b/typespec-tests/src/main/java/com/type/model/inheritance/notdiscriminated/implementation/NotDiscriminatedClientImpl.java @@ -9,6 +9,7 @@ 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; @@ -42,6 +43,20 @@ public final class NotDiscriminatedClientImpl { */ 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. */ @@ -72,19 +87,22 @@ public SerializerAdapter getSerializerAdapter() { /** * Initializes an instance of NotDiscriminatedClient client. + * + * @param endpoint Service host. */ - public NotDiscriminatedClientImpl() { + public NotDiscriminatedClientImpl(String endpoint) { this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), - JacksonAdapter.createDefaultSerializerAdapter()); + 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) { - this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter()); + public NotDiscriminatedClientImpl(HttpPipeline httpPipeline, String endpoint) { + this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint); } /** @@ -92,10 +110,12 @@ public NotDiscriminatedClientImpl(HttpPipeline httpPipeline) { * * @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) { + 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()); } @@ -104,7 +124,7 @@ public NotDiscriminatedClientImpl(HttpPipeline httpPipeline, SerializerAdapter s * The interface defining all the services for NotDiscriminatedClient to be used by the proxy service to perform * REST calls. */ - @Host("http://localhost:3000") + @Host("{endpoint}") @ServiceInterface(name = "NotDiscriminatedClie") public interface NotDiscriminatedClientService { @Post("/type/model/inheritance/not-discriminated/valid") @@ -113,8 +133,9 @@ public interface NotDiscriminatedClientService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> postValid(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData input, RequestOptions requestOptions, Context context); + 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 }) @@ -122,8 +143,9 @@ Mono> postValid(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response postValidSync(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData input, RequestOptions requestOptions, Context context); + 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 }) @@ -131,8 +153,8 @@ Response postValidSync(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> getValid(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Mono> getValid(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Get("/type/model/inheritance/not-discriminated/valid") @ExpectedResponses({ 200 }) @@ -140,8 +162,8 @@ Mono> getValid(@HeaderParam("accept") String accept, Reques @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response getValidSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Response getValidSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Put("/type/model/inheritance/not-discriminated/valid") @ExpectedResponses({ 200 }) @@ -149,7 +171,8 @@ Response getValidSync(@HeaderParam("accept") String accept, RequestO @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> putValid(@HeaderParam("accept") String accept, + 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") @@ -158,7 +181,8 @@ Mono> putValid(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response putValidSync(@HeaderParam("accept") String accept, + Response putValidSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, @BodyParam("application/json") BinaryData input, RequestOptions requestOptions, Context context); } @@ -184,8 +208,9 @@ Response putValidSync(@HeaderParam("accept") String accept, */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> postValidWithResponseAsync(BinaryData input, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.postValid(accept, input, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.postValid(this.getEndpoint(), contentType, input, requestOptions, context)); } /** @@ -210,8 +235,8 @@ public Mono> postValidWithResponseAsync(BinaryData input, Request */ @ServiceMethod(returns = ReturnType.SINGLE) public Response postValidWithResponse(BinaryData input, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.postValidSync(accept, input, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.postValidSync(this.getEndpoint(), contentType, input, requestOptions, Context.NONE); } /** @@ -237,7 +262,7 @@ public Response postValidWithResponse(BinaryData input, RequestOptions req @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getValidWithResponseAsync(RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.getValid(accept, requestOptions, context)); + return FluxUtil.withContext(context -> service.getValid(this.getEndpoint(), accept, requestOptions, context)); } /** @@ -262,7 +287,7 @@ public Mono> getValidWithResponseAsync(RequestOptions reque @ServiceMethod(returns = ReturnType.SINGLE) public Response getValidWithResponse(RequestOptions requestOptions) { final String accept = "application/json"; - return service.getValidSync(accept, requestOptions, Context.NONE); + return service.getValidSync(this.getEndpoint(), accept, requestOptions, Context.NONE); } /** @@ -298,8 +323,10 @@ public Response getValidWithResponse(RequestOptions requestOptions) */ @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(accept, input, requestOptions, context)); + return FluxUtil.withContext( + context -> service.putValid(this.getEndpoint(), contentType, accept, input, requestOptions, context)); } /** @@ -334,7 +361,8 @@ public Mono> putValidWithResponseAsync(BinaryData input, Re */ @ServiceMethod(returns = ReturnType.SINGLE) public Response putValidWithResponse(BinaryData input, RequestOptions requestOptions) { + final String contentType = "application/json"; final String accept = "application/json"; - return service.putValidSync(accept, input, requestOptions, Context.NONE); + return service.putValidSync(this.getEndpoint(), contentType, accept, input, requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/type/model/inheritance/recursive/RecursiveClientBuilder.java b/typespec-tests/src/main/java/com/type/model/inheritance/recursive/RecursiveClientBuilder.java index b5a98ea2e0..757f02ca3d 100644 --- a/typespec-tests/src/main/java/com/type/model/inheritance/recursive/RecursiveClientBuilder.java +++ b/typespec-tests/src/main/java/com/type/model/inheritance/recursive/RecursiveClientBuilder.java @@ -7,6 +7,7 @@ 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; @@ -40,8 +41,8 @@ * A builder for creating a new instance of the RecursiveClient type. */ @ServiceClientBuilder(serviceClients = { RecursiveClient.class, RecursiveAsyncClient.class }) -public final class RecursiveClientBuilder - implements HttpTrait, ConfigurationTrait { +public final class RecursiveClientBuilder implements HttpTrait, + ConfigurationTrait, EndpointTrait { @Generated private static final String SDK_NAME = "name"; @@ -173,6 +174,22 @@ public RecursiveClientBuilder configuration(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. */ @@ -200,8 +217,9 @@ public RecursiveClientBuilder retryPolicy(RetryPolicy retryPolicy) { 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()); + = new RecursiveClientImpl(localPipeline, JacksonAdapter.createDefaultSerializerAdapter(), localEndpoint); return client; } diff --git a/typespec-tests/src/main/java/com/type/model/inheritance/recursive/implementation/RecursiveClientImpl.java b/typespec-tests/src/main/java/com/type/model/inheritance/recursive/implementation/RecursiveClientImpl.java index 977d2a16db..97f4a67141 100644 --- a/typespec-tests/src/main/java/com/type/model/inheritance/recursive/implementation/RecursiveClientImpl.java +++ b/typespec-tests/src/main/java/com/type/model/inheritance/recursive/implementation/RecursiveClientImpl.java @@ -9,6 +9,7 @@ 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; @@ -41,6 +42,20 @@ public final class RecursiveClientImpl { */ 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. */ @@ -71,19 +86,22 @@ public SerializerAdapter getSerializerAdapter() { /** * Initializes an instance of RecursiveClient client. + * + * @param endpoint Service host. */ - public RecursiveClientImpl() { + public RecursiveClientImpl(String endpoint) { this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), - JacksonAdapter.createDefaultSerializerAdapter()); + 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) { - this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter()); + public RecursiveClientImpl(HttpPipeline httpPipeline, String endpoint) { + this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint); } /** @@ -91,10 +109,12 @@ public RecursiveClientImpl(HttpPipeline httpPipeline) { * * @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) { + 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()); } @@ -102,7 +122,7 @@ public RecursiveClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializ * The interface defining all the services for RecursiveClient to be used by the proxy service to perform REST * calls. */ - @Host("http://localhost:3000") + @Host("{endpoint}") @ServiceInterface(name = "RecursiveClient") public interface RecursiveClientService { @Put("/type/model/inheritance/recursive") @@ -111,7 +131,8 @@ public interface RecursiveClientService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> put(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData input, + 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") @@ -120,8 +141,8 @@ Mono> put(@HeaderParam("accept") String accept, @BodyParam("appli @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response putSync(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData input, - RequestOptions requestOptions, Context context); + 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 }) @@ -129,8 +150,8 @@ Response putSync(@HeaderParam("accept") String accept, @BodyParam("applica @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> get(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Get("/type/model/inheritance/recursive") @ExpectedResponses({ 200 }) @@ -138,8 +159,8 @@ Mono> get(@HeaderParam("accept") String accept, RequestOpti @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response getSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); } /** @@ -165,8 +186,9 @@ Response getSync(@HeaderParam("accept") String accept, RequestOption */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> putWithResponseAsync(BinaryData input, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.put(accept, input, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.put(this.getEndpoint(), contentType, input, requestOptions, context)); } /** @@ -192,8 +214,8 @@ public Mono> putWithResponseAsync(BinaryData input, RequestOption */ @ServiceMethod(returns = ReturnType.SINGLE) public Response putWithResponse(BinaryData input, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.putSync(accept, input, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.putSync(this.getEndpoint(), contentType, input, requestOptions, Context.NONE); } /** @@ -219,7 +241,7 @@ public Response putWithResponse(BinaryData input, RequestOptions requestOp @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getWithResponseAsync(RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.get(accept, requestOptions, context)); + return FluxUtil.withContext(context -> service.get(this.getEndpoint(), accept, requestOptions, context)); } /** @@ -245,6 +267,6 @@ public Mono> getWithResponseAsync(RequestOptions requestOpt @ServiceMethod(returns = ReturnType.SINGLE) public Response getWithResponse(RequestOptions requestOptions) { final String accept = "application/json"; - return service.getSync(accept, requestOptions, Context.NONE); + return service.getSync(this.getEndpoint(), accept, requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/type/model/inheritance/singlediscriminator/SingleDiscriminatorClientBuilder.java b/typespec-tests/src/main/java/com/type/model/inheritance/singlediscriminator/SingleDiscriminatorClientBuilder.java index aee0efa4bb..ccebf1a8b8 100644 --- a/typespec-tests/src/main/java/com/type/model/inheritance/singlediscriminator/SingleDiscriminatorClientBuilder.java +++ b/typespec-tests/src/main/java/com/type/model/inheritance/singlediscriminator/SingleDiscriminatorClientBuilder.java @@ -7,6 +7,7 @@ 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; @@ -40,8 +41,8 @@ * A builder for creating a new instance of the SingleDiscriminatorClient type. */ @ServiceClientBuilder(serviceClients = { SingleDiscriminatorClient.class, SingleDiscriminatorAsyncClient.class }) -public final class SingleDiscriminatorClientBuilder - implements HttpTrait, ConfigurationTrait { +public final class SingleDiscriminatorClientBuilder implements HttpTrait, + ConfigurationTrait, EndpointTrait { @Generated private static final String SDK_NAME = "name"; @@ -173,6 +174,22 @@ public SingleDiscriminatorClientBuilder configuration(Configuration configuratio 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. */ @@ -200,8 +217,9 @@ public SingleDiscriminatorClientBuilder retryPolicy(RetryPolicy retryPolicy) { private SingleDiscriminatorClientImpl buildInnerClient() { this.validateClient(); HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); - SingleDiscriminatorClientImpl client - = new SingleDiscriminatorClientImpl(localPipeline, JacksonAdapter.createDefaultSerializerAdapter()); + String localEndpoint = (endpoint != null) ? endpoint : "http://localhost:3000"; + SingleDiscriminatorClientImpl client = new SingleDiscriminatorClientImpl(localPipeline, + JacksonAdapter.createDefaultSerializerAdapter(), localEndpoint); return client; } diff --git a/typespec-tests/src/main/java/com/type/model/inheritance/singlediscriminator/implementation/SingleDiscriminatorClientImpl.java b/typespec-tests/src/main/java/com/type/model/inheritance/singlediscriminator/implementation/SingleDiscriminatorClientImpl.java index d3b10c2328..5552826260 100644 --- a/typespec-tests/src/main/java/com/type/model/inheritance/singlediscriminator/implementation/SingleDiscriminatorClientImpl.java +++ b/typespec-tests/src/main/java/com/type/model/inheritance/singlediscriminator/implementation/SingleDiscriminatorClientImpl.java @@ -9,6 +9,7 @@ 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; @@ -41,6 +42,20 @@ public final class SingleDiscriminatorClientImpl { */ 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. */ @@ -71,19 +86,22 @@ public SerializerAdapter getSerializerAdapter() { /** * Initializes an instance of SingleDiscriminatorClient client. + * + * @param endpoint Service host. */ - public SingleDiscriminatorClientImpl() { + public SingleDiscriminatorClientImpl(String endpoint) { this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), - JacksonAdapter.createDefaultSerializerAdapter()); + 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) { - this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter()); + public SingleDiscriminatorClientImpl(HttpPipeline httpPipeline, String endpoint) { + this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint); } /** @@ -91,10 +109,13 @@ public SingleDiscriminatorClientImpl(HttpPipeline httpPipeline) { * * @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) { + 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()); } @@ -103,7 +124,7 @@ public SingleDiscriminatorClientImpl(HttpPipeline httpPipeline, SerializerAdapte * The interface defining all the services for SingleDiscriminatorClient to be used by the proxy service to perform * REST calls. */ - @Host("http://localhost:3000") + @Host("{endpoint}") @ServiceInterface(name = "SingleDiscriminatorC") public interface SingleDiscriminatorClientService { @Get("/type/model/inheritance/single-discriminator/model") @@ -112,8 +133,8 @@ public interface SingleDiscriminatorClientService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> getModel(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Mono> getModel(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Get("/type/model/inheritance/single-discriminator/model") @ExpectedResponses({ 200 }) @@ -121,8 +142,8 @@ Mono> getModel(@HeaderParam("accept") String accept, Reques @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response getModelSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Response getModelSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Put("/type/model/inheritance/single-discriminator/model") @ExpectedResponses({ 204 }) @@ -130,8 +151,9 @@ Response getModelSync(@HeaderParam("accept") String accept, RequestO @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> putModel(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData input, RequestOptions requestOptions, Context context); + 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 }) @@ -139,8 +161,9 @@ Mono> putModel(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response putModelSync(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData input, RequestOptions requestOptions, Context context); + 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 }) @@ -148,8 +171,8 @@ Response putModelSync(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> getRecursiveModel(@HeaderParam("accept") String accept, - RequestOptions requestOptions, Context context); + Mono> getRecursiveModel(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Get("/type/model/inheritance/single-discriminator/recursivemodel") @ExpectedResponses({ 200 }) @@ -157,8 +180,8 @@ Mono> getRecursiveModel(@HeaderParam("accept") String accep @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response getRecursiveModelSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Response getRecursiveModelSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Put("/type/model/inheritance/single-discriminator/recursivemodel") @ExpectedResponses({ 204 }) @@ -166,8 +189,9 @@ Response getRecursiveModelSync(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> putRecursiveModel(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData input, RequestOptions requestOptions, Context context); + 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 }) @@ -175,8 +199,9 @@ Mono> putRecursiveModel(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response putRecursiveModelSync(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData input, RequestOptions requestOptions, Context context); + 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 }) @@ -184,8 +209,8 @@ Response putRecursiveModelSync(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> getMissingDiscriminator(@HeaderParam("accept") String accept, - RequestOptions requestOptions, Context context); + Mono> getMissingDiscriminator(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Get("/type/model/inheritance/single-discriminator/missingdiscriminator") @ExpectedResponses({ 200 }) @@ -193,8 +218,8 @@ Mono> getMissingDiscriminator(@HeaderParam("accept") String @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response getMissingDiscriminatorSync(@HeaderParam("accept") String accept, - RequestOptions requestOptions, Context context); + Response getMissingDiscriminatorSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Get("/type/model/inheritance/single-discriminator/wrongdiscriminator") @ExpectedResponses({ 200 }) @@ -202,8 +227,8 @@ Response getMissingDiscriminatorSync(@HeaderParam("accept") String a @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> getWrongDiscriminator(@HeaderParam("accept") String accept, - RequestOptions requestOptions, Context context); + Mono> getWrongDiscriminator(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Get("/type/model/inheritance/single-discriminator/wrongdiscriminator") @ExpectedResponses({ 200 }) @@ -211,8 +236,8 @@ Mono> getWrongDiscriminator(@HeaderParam("accept") String a @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response getWrongDiscriminatorSync(@HeaderParam("accept") String accept, - RequestOptions requestOptions, Context context); + Response getWrongDiscriminatorSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Get("/type/model/inheritance/single-discriminator/legacy-model") @ExpectedResponses({ 200 }) @@ -220,8 +245,8 @@ Response getWrongDiscriminatorSync(@HeaderParam("accept") String acc @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> getLegacyModel(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Mono> getLegacyModel(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Get("/type/model/inheritance/single-discriminator/legacy-model") @ExpectedResponses({ 200 }) @@ -229,8 +254,8 @@ Mono> getLegacyModel(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response getLegacyModelSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Response getLegacyModelSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); } /** @@ -255,7 +280,7 @@ Response getLegacyModelSync(@HeaderParam("accept") String accept, Re @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getModelWithResponseAsync(RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.getModel(accept, requestOptions, context)); + return FluxUtil.withContext(context -> service.getModel(this.getEndpoint(), accept, requestOptions, context)); } /** @@ -280,7 +305,7 @@ public Mono> getModelWithResponseAsync(RequestOptions reque @ServiceMethod(returns = ReturnType.SINGLE) public Response getModelWithResponse(RequestOptions requestOptions) { final String accept = "application/json"; - return service.getModelSync(accept, requestOptions, Context.NONE); + return service.getModelSync(this.getEndpoint(), accept, requestOptions, Context.NONE); } /** @@ -304,8 +329,9 @@ public Response getModelWithResponse(RequestOptions requestOptions) */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> putModelWithResponseAsync(BinaryData input, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.putModel(accept, input, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.putModel(this.getEndpoint(), contentType, input, requestOptions, context)); } /** @@ -329,8 +355,8 @@ public Mono> putModelWithResponseAsync(BinaryData input, RequestO */ @ServiceMethod(returns = ReturnType.SINGLE) public Response putModelWithResponse(BinaryData input, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.putModelSync(accept, input, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.putModelSync(this.getEndpoint(), contentType, input, requestOptions, Context.NONE); } /** @@ -355,7 +381,8 @@ public Response putModelWithResponse(BinaryData input, RequestOptions requ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getRecursiveModelWithResponseAsync(RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.getRecursiveModel(accept, requestOptions, context)); + return FluxUtil + .withContext(context -> service.getRecursiveModel(this.getEndpoint(), accept, requestOptions, context)); } /** @@ -380,7 +407,7 @@ public Mono> getRecursiveModelWithResponseAsync(RequestOpti @ServiceMethod(returns = ReturnType.SINGLE) public Response getRecursiveModelWithResponse(RequestOptions requestOptions) { final String accept = "application/json"; - return service.getRecursiveModelSync(accept, requestOptions, Context.NONE); + return service.getRecursiveModelSync(this.getEndpoint(), accept, requestOptions, Context.NONE); } /** @@ -404,8 +431,9 @@ public Response getRecursiveModelWithResponse(RequestOptions request */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> putRecursiveModelWithResponseAsync(BinaryData input, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.putRecursiveModel(accept, input, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.putRecursiveModel(this.getEndpoint(), contentType, input, requestOptions, context)); } /** @@ -429,8 +457,8 @@ public Mono> putRecursiveModelWithResponseAsync(BinaryData input, */ @ServiceMethod(returns = ReturnType.SINGLE) public Response putRecursiveModelWithResponse(BinaryData input, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.putRecursiveModelSync(accept, input, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.putRecursiveModelSync(this.getEndpoint(), contentType, input, requestOptions, Context.NONE); } /** @@ -455,7 +483,8 @@ public Response putRecursiveModelWithResponse(BinaryData input, RequestOpt @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getMissingDiscriminatorWithResponseAsync(RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.getMissingDiscriminator(accept, requestOptions, context)); + return FluxUtil.withContext( + context -> service.getMissingDiscriminator(this.getEndpoint(), accept, requestOptions, context)); } /** @@ -480,7 +509,7 @@ public Mono> getMissingDiscriminatorWithResponseAsync(Reque @ServiceMethod(returns = ReturnType.SINGLE) public Response getMissingDiscriminatorWithResponse(RequestOptions requestOptions) { final String accept = "application/json"; - return service.getMissingDiscriminatorSync(accept, requestOptions, Context.NONE); + return service.getMissingDiscriminatorSync(this.getEndpoint(), accept, requestOptions, Context.NONE); } /** @@ -505,7 +534,8 @@ public Response getMissingDiscriminatorWithResponse(RequestOptions r @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getWrongDiscriminatorWithResponseAsync(RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.getWrongDiscriminator(accept, requestOptions, context)); + return FluxUtil + .withContext(context -> service.getWrongDiscriminator(this.getEndpoint(), accept, requestOptions, context)); } /** @@ -530,7 +560,7 @@ public Mono> getWrongDiscriminatorWithResponseAsync(Request @ServiceMethod(returns = ReturnType.SINGLE) public Response getWrongDiscriminatorWithResponse(RequestOptions requestOptions) { final String accept = "application/json"; - return service.getWrongDiscriminatorSync(accept, requestOptions, Context.NONE); + return service.getWrongDiscriminatorSync(this.getEndpoint(), accept, requestOptions, Context.NONE); } /** @@ -555,7 +585,8 @@ public Response getWrongDiscriminatorWithResponse(RequestOptions req @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getLegacyModelWithResponseAsync(RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.getLegacyModel(accept, requestOptions, context)); + return FluxUtil + .withContext(context -> service.getLegacyModel(this.getEndpoint(), accept, requestOptions, context)); } /** @@ -579,6 +610,6 @@ public Mono> getLegacyModelWithResponseAsync(RequestOptions @ServiceMethod(returns = ReturnType.SINGLE) public Response getLegacyModelWithResponse(RequestOptions requestOptions) { final String accept = "application/json"; - return service.getLegacyModelSync(accept, requestOptions, Context.NONE); + return service.getLegacyModelSync(this.getEndpoint(), accept, requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/type/model/usage/UsageClientBuilder.java b/typespec-tests/src/main/java/com/type/model/usage/UsageClientBuilder.java index 1ee385947e..82dfb76e79 100644 --- a/typespec-tests/src/main/java/com/type/model/usage/UsageClientBuilder.java +++ b/typespec-tests/src/main/java/com/type/model/usage/UsageClientBuilder.java @@ -7,6 +7,7 @@ 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; @@ -40,7 +41,8 @@ * A builder for creating a new instance of the UsageClient type. */ @ServiceClientBuilder(serviceClients = { UsageClient.class, UsageAsyncClient.class }) -public final class UsageClientBuilder implements HttpTrait, ConfigurationTrait { +public final class UsageClientBuilder implements HttpTrait, ConfigurationTrait, + EndpointTrait { @Generated private static final String SDK_NAME = "name"; @@ -171,6 +173,22 @@ public UsageClientBuilder configuration(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. */ @@ -198,7 +216,9 @@ public UsageClientBuilder retryPolicy(RetryPolicy retryPolicy) { private UsageClientImpl buildInnerClient() { this.validateClient(); HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); - UsageClientImpl client = new UsageClientImpl(localPipeline, JacksonAdapter.createDefaultSerializerAdapter()); + String localEndpoint = (endpoint != null) ? endpoint : "http://localhost:3000"; + UsageClientImpl client + = new UsageClientImpl(localPipeline, JacksonAdapter.createDefaultSerializerAdapter(), localEndpoint); return client; } diff --git a/typespec-tests/src/main/java/com/type/model/usage/implementation/UsageClientImpl.java b/typespec-tests/src/main/java/com/type/model/usage/implementation/UsageClientImpl.java index 033a927fc0..c39f723ea6 100644 --- a/typespec-tests/src/main/java/com/type/model/usage/implementation/UsageClientImpl.java +++ b/typespec-tests/src/main/java/com/type/model/usage/implementation/UsageClientImpl.java @@ -9,6 +9,7 @@ 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; @@ -41,6 +42,20 @@ public final class UsageClientImpl { */ 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. */ @@ -71,19 +86,22 @@ public SerializerAdapter getSerializerAdapter() { /** * Initializes an instance of UsageClient client. + * + * @param endpoint Service host. */ - public UsageClientImpl() { + public UsageClientImpl(String endpoint) { this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), - JacksonAdapter.createDefaultSerializerAdapter()); + 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) { - this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter()); + public UsageClientImpl(HttpPipeline httpPipeline, String endpoint) { + this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint); } /** @@ -91,17 +109,19 @@ public UsageClientImpl(HttpPipeline httpPipeline) { * * @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) { + 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("http://localhost:3000") + @Host("{endpoint}") @ServiceInterface(name = "UsageClient") public interface UsageClientService { @Post("/type/model/usage/input") @@ -110,8 +130,9 @@ public interface UsageClientService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> input(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData input, RequestOptions requestOptions, Context context); + 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 }) @@ -119,7 +140,8 @@ Mono> input(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response inputSync(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData input, + 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") @@ -128,8 +150,8 @@ Response inputSync(@HeaderParam("accept") String accept, @BodyParam("appli @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> output(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Mono> output(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Get("/type/model/usage/output") @ExpectedResponses({ 200 }) @@ -137,8 +159,8 @@ Mono> output(@HeaderParam("accept") String accept, RequestO @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response outputSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Response outputSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Post("/type/model/usage/input-output") @ExpectedResponses({ 200 }) @@ -146,7 +168,8 @@ Response outputSync(@HeaderParam("accept") String accept, RequestOpt @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> inputAndOutput(@HeaderParam("accept") String accept, + 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") @@ -155,7 +178,8 @@ Mono> inputAndOutput(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response inputAndOutputSync(@HeaderParam("accept") String accept, + Response inputAndOutputSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); } @@ -179,8 +203,9 @@ Response inputAndOutputSync(@HeaderParam("accept") String accept, */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> inputWithResponseAsync(BinaryData input, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.input(accept, input, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.input(this.getEndpoint(), contentType, input, requestOptions, context)); } /** @@ -203,8 +228,8 @@ public Mono> inputWithResponseAsync(BinaryData input, RequestOpti */ @ServiceMethod(returns = ReturnType.SINGLE) public Response inputWithResponse(BinaryData input, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.inputSync(accept, input, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.inputSync(this.getEndpoint(), contentType, input, requestOptions, Context.NONE); } /** @@ -228,7 +253,7 @@ public Response inputWithResponse(BinaryData input, RequestOptions request @ServiceMethod(returns = ReturnType.SINGLE) public Mono> outputWithResponseAsync(RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.output(accept, requestOptions, context)); + return FluxUtil.withContext(context -> service.output(this.getEndpoint(), accept, requestOptions, context)); } /** @@ -251,7 +276,7 @@ public Mono> outputWithResponseAsync(RequestOptions request @ServiceMethod(returns = ReturnType.SINGLE) public Response outputWithResponse(RequestOptions requestOptions) { final String accept = "application/json"; - return service.outputSync(accept, requestOptions, Context.NONE); + return service.outputSync(this.getEndpoint(), accept, requestOptions, Context.NONE); } /** @@ -283,8 +308,10 @@ public Response outputWithResponse(RequestOptions requestOptions) { */ @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(accept, body, requestOptions, context)); + return FluxUtil.withContext( + context -> service.inputAndOutput(this.getEndpoint(), contentType, accept, body, requestOptions, context)); } /** @@ -315,7 +342,8 @@ public Mono> inputAndOutputWithResponseAsync(BinaryData bod */ @ServiceMethod(returns = ReturnType.SINGLE) public Response inputAndOutputWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; final String accept = "application/json"; - return service.inputAndOutputSync(accept, body, requestOptions, Context.NONE); + return service.inputAndOutputSync(this.getEndpoint(), contentType, accept, body, requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/type/model/visibility/VisibilityClientBuilder.java b/typespec-tests/src/main/java/com/type/model/visibility/VisibilityClientBuilder.java index 0ff1694036..70668f3bb1 100644 --- a/typespec-tests/src/main/java/com/type/model/visibility/VisibilityClientBuilder.java +++ b/typespec-tests/src/main/java/com/type/model/visibility/VisibilityClientBuilder.java @@ -7,6 +7,7 @@ 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; @@ -40,8 +41,8 @@ * A builder for creating a new instance of the VisibilityClient type. */ @ServiceClientBuilder(serviceClients = { VisibilityClient.class, VisibilityAsyncClient.class }) -public final class VisibilityClientBuilder - implements HttpTrait, ConfigurationTrait { +public final class VisibilityClientBuilder implements HttpTrait, + ConfigurationTrait, EndpointTrait { @Generated private static final String SDK_NAME = "name"; @@ -172,6 +173,22 @@ public VisibilityClientBuilder configuration(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. */ @@ -199,8 +216,9 @@ public VisibilityClientBuilder retryPolicy(RetryPolicy retryPolicy) { 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()); + = new VisibilityClientImpl(localPipeline, JacksonAdapter.createDefaultSerializerAdapter(), localEndpoint); return client; } diff --git a/typespec-tests/src/main/java/com/type/model/visibility/implementation/VisibilityClientImpl.java b/typespec-tests/src/main/java/com/type/model/visibility/implementation/VisibilityClientImpl.java index e988f79a00..323e87eedb 100644 --- a/typespec-tests/src/main/java/com/type/model/visibility/implementation/VisibilityClientImpl.java +++ b/typespec-tests/src/main/java/com/type/model/visibility/implementation/VisibilityClientImpl.java @@ -11,6 +11,7 @@ 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; @@ -45,6 +46,20 @@ public final class VisibilityClientImpl { */ 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. */ @@ -75,19 +90,22 @@ public SerializerAdapter getSerializerAdapter() { /** * Initializes an instance of VisibilityClient client. + * + * @param endpoint Service host. */ - public VisibilityClientImpl() { + public VisibilityClientImpl(String endpoint) { this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), - JacksonAdapter.createDefaultSerializerAdapter()); + 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) { - this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter()); + public VisibilityClientImpl(HttpPipeline httpPipeline, String endpoint) { + this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint); } /** @@ -95,10 +113,12 @@ public VisibilityClientImpl(HttpPipeline httpPipeline) { * * @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) { + 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()); } @@ -106,7 +126,7 @@ public VisibilityClientImpl(HttpPipeline httpPipeline, SerializerAdapter seriali * The interface defining all the services for VisibilityClient to be used by the proxy service to perform REST * calls. */ - @Host("http://localhost:3000") + @Host("{endpoint}") @ServiceInterface(name = "VisibilityClient") public interface VisibilityClientService { @Get("/type/model/visibility") @@ -115,7 +135,8 @@ public interface VisibilityClientService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> getModel(@HeaderParam("accept") String accept, + 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") @@ -124,7 +145,8 @@ Mono> getModel(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response getModelSync(@HeaderParam("accept") String accept, + 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") @@ -133,8 +155,9 @@ Response getModelSync(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> headModel(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData input, RequestOptions requestOptions, Context context); + 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 }) @@ -142,8 +165,9 @@ Mono> headModel(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response headModelSync(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData input, RequestOptions requestOptions, Context context); + 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 }) @@ -151,8 +175,9 @@ Response headModelSync(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> putModel(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData input, RequestOptions requestOptions, Context context); + 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 }) @@ -160,8 +185,9 @@ Mono> putModel(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response putModelSync(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData input, RequestOptions requestOptions, Context context); + 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 }) @@ -169,8 +195,9 @@ Response putModelSync(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> patchModel(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData input, RequestOptions requestOptions, Context context); + 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 }) @@ -178,8 +205,9 @@ Mono> patchModel(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response patchModelSync(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData input, RequestOptions requestOptions, Context context); + 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 }) @@ -187,8 +215,9 @@ Response patchModelSync(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> postModel(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData input, RequestOptions requestOptions, Context context); + 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 }) @@ -196,8 +225,9 @@ Mono> postModel(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response postModelSync(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData input, RequestOptions requestOptions, Context context); + 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 }) @@ -205,8 +235,9 @@ Response postModelSync(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> deleteModel(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData input, RequestOptions requestOptions, Context context); + 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 }) @@ -214,8 +245,9 @@ Mono> deleteModel(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response deleteModelSync(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData input, RequestOptions requestOptions, Context context); + 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 }) @@ -223,7 +255,8 @@ Response deleteModelSync(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> putReadOnlyModel(@HeaderParam("accept") String accept, + 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") @@ -232,7 +265,8 @@ Mono> putReadOnlyModel(@HeaderParam("accept") String accept @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response putReadOnlyModelSync(@HeaderParam("accept") String accept, + Response putReadOnlyModelSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, @BodyParam("application/json") BinaryData input, RequestOptions requestOptions, Context context); } @@ -281,8 +315,10 @@ Response putReadOnlyModelSync(@HeaderParam("accept") String accept, */ @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(accept, input, requestOptions, context)); + return FluxUtil.withContext( + context -> service.getModel(this.getEndpoint(), contentType, accept, input, requestOptions, context)); } /** @@ -329,8 +365,9 @@ public Mono> getModelWithResponseAsync(BinaryData input, Re */ @ServiceMethod(returns = ReturnType.SINGLE) public Response getModelWithResponse(BinaryData input, RequestOptions requestOptions) { + final String contentType = "application/json"; final String accept = "application/json"; - return service.getModelSync(accept, input, requestOptions, Context.NONE); + return service.getModelSync(this.getEndpoint(), contentType, accept, input, requestOptions, Context.NONE); } /** @@ -361,8 +398,9 @@ public Response getModelWithResponse(BinaryData input, RequestOption */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> headModelWithResponseAsync(BinaryData input, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.headModel(accept, input, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.headModel(this.getEndpoint(), contentType, input, requestOptions, context)); } /** @@ -393,8 +431,8 @@ public Mono> headModelWithResponseAsync(BinaryData input, Request */ @ServiceMethod(returns = ReturnType.SINGLE) public Response headModelWithResponse(BinaryData input, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.headModelSync(accept, input, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.headModelSync(this.getEndpoint(), contentType, input, requestOptions, Context.NONE); } /** @@ -425,8 +463,9 @@ public Response headModelWithResponse(BinaryData input, RequestOptions req */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> putModelWithResponseAsync(BinaryData input, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.putModel(accept, input, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.putModel(this.getEndpoint(), contentType, input, requestOptions, context)); } /** @@ -457,8 +496,8 @@ public Mono> putModelWithResponseAsync(BinaryData input, RequestO */ @ServiceMethod(returns = ReturnType.SINGLE) public Response putModelWithResponse(BinaryData input, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.putModelSync(accept, input, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.putModelSync(this.getEndpoint(), contentType, input, requestOptions, Context.NONE); } /** @@ -489,8 +528,9 @@ public Response putModelWithResponse(BinaryData input, RequestOptions requ */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> patchModelWithResponseAsync(BinaryData input, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.patchModel(accept, input, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.patchModel(this.getEndpoint(), contentType, input, requestOptions, context)); } /** @@ -521,8 +561,8 @@ public Mono> patchModelWithResponseAsync(BinaryData input, Reques */ @ServiceMethod(returns = ReturnType.SINGLE) public Response patchModelWithResponse(BinaryData input, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.patchModelSync(accept, input, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.patchModelSync(this.getEndpoint(), contentType, input, requestOptions, Context.NONE); } /** @@ -553,8 +593,9 @@ public Response patchModelWithResponse(BinaryData input, RequestOptions re */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> postModelWithResponseAsync(BinaryData input, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.postModel(accept, input, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.postModel(this.getEndpoint(), contentType, input, requestOptions, context)); } /** @@ -585,8 +626,8 @@ public Mono> postModelWithResponseAsync(BinaryData input, Request */ @ServiceMethod(returns = ReturnType.SINGLE) public Response postModelWithResponse(BinaryData input, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.postModelSync(accept, input, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.postModelSync(this.getEndpoint(), contentType, input, requestOptions, Context.NONE); } /** @@ -617,8 +658,9 @@ public Response postModelWithResponse(BinaryData input, RequestOptions req */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> deleteModelWithResponseAsync(BinaryData input, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.deleteModel(accept, input, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.deleteModel(this.getEndpoint(), contentType, input, requestOptions, context)); } /** @@ -649,8 +691,8 @@ public Mono> deleteModelWithResponseAsync(BinaryData input, Reque */ @ServiceMethod(returns = ReturnType.SINGLE) public Response deleteModelWithResponse(BinaryData input, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.deleteModelSync(accept, input, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.deleteModelSync(this.getEndpoint(), contentType, input, requestOptions, Context.NONE); } /** @@ -693,8 +735,10 @@ public Response deleteModelWithResponse(BinaryData input, RequestOptions r @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(accept, input, requestOptions, context)); + return FluxUtil.withContext(context -> service.putReadOnlyModel(this.getEndpoint(), contentType, accept, input, + requestOptions, context)); } /** @@ -735,7 +779,9 @@ public Mono> putReadOnlyModelWithResponseAsync(BinaryData i */ @ServiceMethod(returns = ReturnType.SINGLE) public Response putReadOnlyModelWithResponse(BinaryData input, RequestOptions requestOptions) { + final String contentType = "application/json"; final String accept = "application/json"; - return service.putReadOnlyModelSync(accept, input, requestOptions, Context.NONE); + return service.putReadOnlyModelSync(this.getEndpoint(), contentType, accept, input, requestOptions, + Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/type/property/additionalproperties/AdditionalPropertiesClientBuilder.java b/typespec-tests/src/main/java/com/type/property/additionalproperties/AdditionalPropertiesClientBuilder.java index c315f37901..6e1941fd41 100644 --- a/typespec-tests/src/main/java/com/type/property/additionalproperties/AdditionalPropertiesClientBuilder.java +++ b/typespec-tests/src/main/java/com/type/property/additionalproperties/AdditionalPropertiesClientBuilder.java @@ -7,6 +7,7 @@ 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; @@ -105,8 +106,8 @@ SpreadRecordNonDiscriminatedUnionAsyncClient.class, SpreadRecordNonDiscriminatedUnion2AsyncClient.class, SpreadRecordNonDiscriminatedUnion3AsyncClient.class }) -public final class AdditionalPropertiesClientBuilder - implements HttpTrait, ConfigurationTrait { +public final class AdditionalPropertiesClientBuilder implements HttpTrait, + ConfigurationTrait, EndpointTrait { @Generated private static final String SDK_NAME = "name"; @@ -238,6 +239,22 @@ public AdditionalPropertiesClientBuilder configuration(Configuration configurati 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. */ @@ -265,8 +282,9 @@ public AdditionalPropertiesClientBuilder retryPolicy(RetryPolicy retryPolicy) { private AdditionalPropertiesClientImpl buildInnerClient() { this.validateClient(); HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); - AdditionalPropertiesClientImpl client - = new AdditionalPropertiesClientImpl(localPipeline, JacksonAdapter.createDefaultSerializerAdapter()); + String localEndpoint = (endpoint != null) ? endpoint : "http://localhost:3000"; + AdditionalPropertiesClientImpl client = new AdditionalPropertiesClientImpl(localPipeline, + JacksonAdapter.createDefaultSerializerAdapter(), localEndpoint); return client; } diff --git a/typespec-tests/src/main/java/com/type/property/additionalproperties/implementation/AdditionalPropertiesClientImpl.java b/typespec-tests/src/main/java/com/type/property/additionalproperties/implementation/AdditionalPropertiesClientImpl.java index ba963130d8..bc91cfeee7 100644 --- a/typespec-tests/src/main/java/com/type/property/additionalproperties/implementation/AdditionalPropertiesClientImpl.java +++ b/typespec-tests/src/main/java/com/type/property/additionalproperties/implementation/AdditionalPropertiesClientImpl.java @@ -15,6 +15,20 @@ * 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. */ @@ -493,19 +507,22 @@ public SpreadRecordNonDiscriminatedUnion3sImpl getSpreadRecordNonDiscriminatedUn /** * Initializes an instance of AdditionalPropertiesClient client. + * + * @param endpoint Service host. */ - public AdditionalPropertiesClientImpl() { + public AdditionalPropertiesClientImpl(String endpoint) { this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), - JacksonAdapter.createDefaultSerializerAdapter()); + 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) { - this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter()); + public AdditionalPropertiesClientImpl(HttpPipeline httpPipeline, String endpoint) { + this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint); } /** @@ -513,10 +530,13 @@ public AdditionalPropertiesClientImpl(HttpPipeline httpPipeline) { * * @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) { + 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); diff --git a/typespec-tests/src/main/java/com/type/property/additionalproperties/implementation/ExtendsDifferentSpreadFloatsImpl.java b/typespec-tests/src/main/java/com/type/property/additionalproperties/implementation/ExtendsDifferentSpreadFloatsImpl.java index 6fa9cb37c8..d62be52179 100644 --- a/typespec-tests/src/main/java/com/type/property/additionalproperties/implementation/ExtendsDifferentSpreadFloatsImpl.java +++ b/typespec-tests/src/main/java/com/type/property/additionalproperties/implementation/ExtendsDifferentSpreadFloatsImpl.java @@ -9,6 +9,7 @@ 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; @@ -55,7 +56,7 @@ public final class ExtendsDifferentSpreadFloatsImpl { * The interface defining all the services for AdditionalPropertiesClientExtendsDifferentSpreadFloats to be used by * the proxy service to perform REST calls. */ - @Host("http://localhost:3000") + @Host("{endpoint}") @ServiceInterface(name = "AdditionalProperties") public interface ExtendsDifferentSpreadFloatsService { @Get("/type/property/additionalProperties/extendsDifferentSpreadFloat") @@ -64,8 +65,8 @@ public interface ExtendsDifferentSpreadFloatsService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> get(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Get("/type/property/additionalProperties/extendsDifferentSpreadFloat") @ExpectedResponses({ 200 }) @@ -73,8 +74,8 @@ Mono> get(@HeaderParam("accept") String accept, RequestOpti @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response getSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Put("/type/property/additionalProperties/extendsDifferentSpreadFloat") @ExpectedResponses({ 204 }) @@ -82,7 +83,8 @@ Response getSync(@HeaderParam("accept") String accept, RequestOption @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> put(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, + 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") @@ -91,8 +93,8 @@ Mono> put(@HeaderParam("accept") String accept, @BodyParam("appli @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response putSync(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, - RequestOptions requestOptions, Context context); + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); } /** @@ -119,7 +121,7 @@ Response putSync(@HeaderParam("accept") String accept, @BodyParam("applica @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getWithResponseAsync(RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.get(accept, requestOptions, context)); + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); } /** @@ -146,7 +148,7 @@ public Mono> getWithResponseAsync(RequestOptions requestOpt @ServiceMethod(returns = ReturnType.SINGLE) public Response getWithResponse(RequestOptions requestOptions) { final String accept = "application/json"; - return service.getSync(accept, requestOptions, Context.NONE); + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); } /** @@ -173,8 +175,9 @@ public Response getWithResponse(RequestOptions requestOptions) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> putWithResponseAsync(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.put(accept, body, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.put(this.client.getEndpoint(), contentType, body, requestOptions, context)); } /** @@ -201,7 +204,7 @@ public Mono> putWithResponseAsync(BinaryData body, RequestOptions */ @ServiceMethod(returns = ReturnType.SINGLE) public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.putSync(accept, body, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/type/property/additionalproperties/implementation/ExtendsDifferentSpreadModelArraysImpl.java b/typespec-tests/src/main/java/com/type/property/additionalproperties/implementation/ExtendsDifferentSpreadModelArraysImpl.java index e8609caff6..8c75fb14cd 100644 --- a/typespec-tests/src/main/java/com/type/property/additionalproperties/implementation/ExtendsDifferentSpreadModelArraysImpl.java +++ b/typespec-tests/src/main/java/com/type/property/additionalproperties/implementation/ExtendsDifferentSpreadModelArraysImpl.java @@ -9,6 +9,7 @@ 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; @@ -55,7 +56,7 @@ public final class ExtendsDifferentSpreadModelArraysImpl { * The interface defining all the services for AdditionalPropertiesClientExtendsDifferentSpreadModelArrays to be * used by the proxy service to perform REST calls. */ - @Host("http://localhost:3000") + @Host("{endpoint}") @ServiceInterface(name = "AdditionalProperties") public interface ExtendsDifferentSpreadModelArraysService { @Get("/type/property/additionalProperties/extendsDifferentSpreadModelArray") @@ -64,8 +65,8 @@ public interface ExtendsDifferentSpreadModelArraysService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> get(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Get("/type/property/additionalProperties/extendsDifferentSpreadModelArray") @ExpectedResponses({ 200 }) @@ -73,8 +74,8 @@ Mono> get(@HeaderParam("accept") String accept, RequestOpti @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response getSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Put("/type/property/additionalProperties/extendsDifferentSpreadModelArray") @ExpectedResponses({ 204 }) @@ -82,7 +83,8 @@ Response getSync(@HeaderParam("accept") String accept, RequestOption @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> put(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, + 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") @@ -91,8 +93,8 @@ Mono> put(@HeaderParam("accept") String accept, @BodyParam("appli @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response putSync(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, - RequestOptions requestOptions, Context context); + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); } /** @@ -125,7 +127,7 @@ Response putSync(@HeaderParam("accept") String accept, @BodyParam("applica @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getWithResponseAsync(RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.get(accept, requestOptions, context)); + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); } /** @@ -158,7 +160,7 @@ public Mono> getWithResponseAsync(RequestOptions requestOpt @ServiceMethod(returns = ReturnType.SINGLE) public Response getWithResponse(RequestOptions requestOptions) { final String accept = "application/json"; - return service.getSync(accept, requestOptions, Context.NONE); + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); } /** @@ -191,8 +193,9 @@ public Response getWithResponse(RequestOptions requestOptions) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> putWithResponseAsync(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.put(accept, body, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.put(this.client.getEndpoint(), contentType, body, requestOptions, context)); } /** @@ -225,7 +228,7 @@ public Mono> putWithResponseAsync(BinaryData body, RequestOptions */ @ServiceMethod(returns = ReturnType.SINGLE) public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.putSync(accept, body, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/type/property/additionalproperties/implementation/ExtendsDifferentSpreadModelsImpl.java b/typespec-tests/src/main/java/com/type/property/additionalproperties/implementation/ExtendsDifferentSpreadModelsImpl.java index 303776b348..8e55e04e63 100644 --- a/typespec-tests/src/main/java/com/type/property/additionalproperties/implementation/ExtendsDifferentSpreadModelsImpl.java +++ b/typespec-tests/src/main/java/com/type/property/additionalproperties/implementation/ExtendsDifferentSpreadModelsImpl.java @@ -9,6 +9,7 @@ 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; @@ -55,7 +56,7 @@ public final class ExtendsDifferentSpreadModelsImpl { * The interface defining all the services for AdditionalPropertiesClientExtendsDifferentSpreadModels to be used by * the proxy service to perform REST calls. */ - @Host("http://localhost:3000") + @Host("{endpoint}") @ServiceInterface(name = "AdditionalProperties") public interface ExtendsDifferentSpreadModelsService { @Get("/type/property/additionalProperties/extendsDifferentSpreadModel") @@ -64,8 +65,8 @@ public interface ExtendsDifferentSpreadModelsService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> get(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Get("/type/property/additionalProperties/extendsDifferentSpreadModel") @ExpectedResponses({ 200 }) @@ -73,8 +74,8 @@ Mono> get(@HeaderParam("accept") String accept, RequestOpti @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response getSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Put("/type/property/additionalProperties/extendsDifferentSpreadModel") @ExpectedResponses({ 204 }) @@ -82,7 +83,8 @@ Response getSync(@HeaderParam("accept") String accept, RequestOption @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> put(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, + 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") @@ -91,8 +93,8 @@ Mono> put(@HeaderParam("accept") String accept, @BodyParam("appli @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response putSync(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, - RequestOptions requestOptions, Context context); + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); } /** @@ -121,7 +123,7 @@ Response putSync(@HeaderParam("accept") String accept, @BodyParam("applica @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getWithResponseAsync(RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.get(accept, requestOptions, context)); + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); } /** @@ -150,7 +152,7 @@ public Mono> getWithResponseAsync(RequestOptions requestOpt @ServiceMethod(returns = ReturnType.SINGLE) public Response getWithResponse(RequestOptions requestOptions) { final String accept = "application/json"; - return service.getSync(accept, requestOptions, Context.NONE); + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); } /** @@ -179,8 +181,9 @@ public Response getWithResponse(RequestOptions requestOptions) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> putWithResponseAsync(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.put(accept, body, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.put(this.client.getEndpoint(), contentType, body, requestOptions, context)); } /** @@ -209,7 +212,7 @@ public Mono> putWithResponseAsync(BinaryData body, RequestOptions */ @ServiceMethod(returns = ReturnType.SINGLE) public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.putSync(accept, body, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/type/property/additionalproperties/implementation/ExtendsDifferentSpreadStringsImpl.java b/typespec-tests/src/main/java/com/type/property/additionalproperties/implementation/ExtendsDifferentSpreadStringsImpl.java index 29f8e4e6af..bfd2dd11f1 100644 --- a/typespec-tests/src/main/java/com/type/property/additionalproperties/implementation/ExtendsDifferentSpreadStringsImpl.java +++ b/typespec-tests/src/main/java/com/type/property/additionalproperties/implementation/ExtendsDifferentSpreadStringsImpl.java @@ -9,6 +9,7 @@ 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; @@ -55,7 +56,7 @@ public final class ExtendsDifferentSpreadStringsImpl { * The interface defining all the services for AdditionalPropertiesClientExtendsDifferentSpreadStrings to be used by * the proxy service to perform REST calls. */ - @Host("http://localhost:3000") + @Host("{endpoint}") @ServiceInterface(name = "AdditionalProperties") public interface ExtendsDifferentSpreadStringsService { @Get("/type/property/additionalProperties/extendsDifferentSpreadString") @@ -64,8 +65,8 @@ public interface ExtendsDifferentSpreadStringsService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> get(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Get("/type/property/additionalProperties/extendsDifferentSpreadString") @ExpectedResponses({ 200 }) @@ -73,8 +74,8 @@ Mono> get(@HeaderParam("accept") String accept, RequestOpti @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response getSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Put("/type/property/additionalProperties/extendsDifferentSpreadString") @ExpectedResponses({ 204 }) @@ -82,7 +83,8 @@ Response getSync(@HeaderParam("accept") String accept, RequestOption @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> put(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, + 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") @@ -91,8 +93,8 @@ Mono> put(@HeaderParam("accept") String accept, @BodyParam("appli @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response putSync(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, - RequestOptions requestOptions, Context context); + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); } /** @@ -119,7 +121,7 @@ Response putSync(@HeaderParam("accept") String accept, @BodyParam("applica @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getWithResponseAsync(RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.get(accept, requestOptions, context)); + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); } /** @@ -146,7 +148,7 @@ public Mono> getWithResponseAsync(RequestOptions requestOpt @ServiceMethod(returns = ReturnType.SINGLE) public Response getWithResponse(RequestOptions requestOptions) { final String accept = "application/json"; - return service.getSync(accept, requestOptions, Context.NONE); + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); } /** @@ -173,8 +175,9 @@ public Response getWithResponse(RequestOptions requestOptions) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> putWithResponseAsync(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.put(accept, body, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.put(this.client.getEndpoint(), contentType, body, requestOptions, context)); } /** @@ -201,7 +204,7 @@ public Mono> putWithResponseAsync(BinaryData body, RequestOptions */ @ServiceMethod(returns = ReturnType.SINGLE) public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.putSync(accept, body, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/type/property/additionalproperties/implementation/ExtendsFloatsImpl.java b/typespec-tests/src/main/java/com/type/property/additionalproperties/implementation/ExtendsFloatsImpl.java index 61cc2601f4..11ac9cc0b3 100644 --- a/typespec-tests/src/main/java/com/type/property/additionalproperties/implementation/ExtendsFloatsImpl.java +++ b/typespec-tests/src/main/java/com/type/property/additionalproperties/implementation/ExtendsFloatsImpl.java @@ -9,6 +9,7 @@ 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; @@ -55,7 +56,7 @@ public final class ExtendsFloatsImpl { * The interface defining all the services for AdditionalPropertiesClientExtendsFloats to be used by the proxy * service to perform REST calls. */ - @Host("http://localhost:3000") + @Host("{endpoint}") @ServiceInterface(name = "AdditionalProperties") public interface ExtendsFloatsService { @Get("/type/property/additionalProperties/extendsRecordFloat") @@ -64,8 +65,8 @@ public interface ExtendsFloatsService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> get(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Get("/type/property/additionalProperties/extendsRecordFloat") @ExpectedResponses({ 200 }) @@ -73,8 +74,8 @@ Mono> get(@HeaderParam("accept") String accept, RequestOpti @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response getSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Put("/type/property/additionalProperties/extendsRecordFloat") @ExpectedResponses({ 204 }) @@ -82,7 +83,8 @@ Response getSync(@HeaderParam("accept") String accept, RequestOption @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> put(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, + 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") @@ -91,8 +93,8 @@ Mono> put(@HeaderParam("accept") String accept, @BodyParam("appli @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response putSync(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, - RequestOptions requestOptions, Context context); + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); } /** @@ -118,7 +120,7 @@ Response putSync(@HeaderParam("accept") String accept, @BodyParam("applica @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getWithResponseAsync(RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.get(accept, requestOptions, context)); + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); } /** @@ -144,7 +146,7 @@ public Mono> getWithResponseAsync(RequestOptions requestOpt @ServiceMethod(returns = ReturnType.SINGLE) public Response getWithResponse(RequestOptions requestOptions) { final String accept = "application/json"; - return service.getSync(accept, requestOptions, Context.NONE); + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); } /** @@ -170,8 +172,9 @@ public Response getWithResponse(RequestOptions requestOptions) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> putWithResponseAsync(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.put(accept, body, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.put(this.client.getEndpoint(), contentType, body, requestOptions, context)); } /** @@ -197,7 +200,7 @@ public Mono> putWithResponseAsync(BinaryData body, RequestOptions */ @ServiceMethod(returns = ReturnType.SINGLE) public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.putSync(accept, body, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/type/property/additionalproperties/implementation/ExtendsModelArraysImpl.java b/typespec-tests/src/main/java/com/type/property/additionalproperties/implementation/ExtendsModelArraysImpl.java index d4037271c3..e48e96e72c 100644 --- a/typespec-tests/src/main/java/com/type/property/additionalproperties/implementation/ExtendsModelArraysImpl.java +++ b/typespec-tests/src/main/java/com/type/property/additionalproperties/implementation/ExtendsModelArraysImpl.java @@ -9,6 +9,7 @@ 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; @@ -55,7 +56,7 @@ public final class ExtendsModelArraysImpl { * The interface defining all the services for AdditionalPropertiesClientExtendsModelArrays to be used by the proxy * service to perform REST calls. */ - @Host("http://localhost:3000") + @Host("{endpoint}") @ServiceInterface(name = "AdditionalProperties") public interface ExtendsModelArraysService { @Get("/type/property/additionalProperties/extendsRecordModelArray") @@ -64,8 +65,8 @@ public interface ExtendsModelArraysService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> get(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Get("/type/property/additionalProperties/extendsRecordModelArray") @ExpectedResponses({ 200 }) @@ -73,8 +74,8 @@ Mono> get(@HeaderParam("accept") String accept, RequestOpti @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response getSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Put("/type/property/additionalProperties/extendsRecordModelArray") @ExpectedResponses({ 204 }) @@ -82,7 +83,8 @@ Response getSync(@HeaderParam("accept") String accept, RequestOption @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> put(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, + 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") @@ -91,8 +93,8 @@ Mono> put(@HeaderParam("accept") String accept, @BodyParam("appli @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response putSync(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, - RequestOptions requestOptions, Context context); + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); } /** @@ -124,7 +126,7 @@ Response putSync(@HeaderParam("accept") String accept, @BodyParam("applica @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getWithResponseAsync(RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.get(accept, requestOptions, context)); + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); } /** @@ -156,7 +158,7 @@ public Mono> getWithResponseAsync(RequestOptions requestOpt @ServiceMethod(returns = ReturnType.SINGLE) public Response getWithResponse(RequestOptions requestOptions) { final String accept = "application/json"; - return service.getSync(accept, requestOptions, Context.NONE); + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); } /** @@ -188,8 +190,9 @@ public Response getWithResponse(RequestOptions requestOptions) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> putWithResponseAsync(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.put(accept, body, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.put(this.client.getEndpoint(), contentType, body, requestOptions, context)); } /** @@ -221,7 +224,7 @@ public Mono> putWithResponseAsync(BinaryData body, RequestOptions */ @ServiceMethod(returns = ReturnType.SINGLE) public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.putSync(accept, body, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/type/property/additionalproperties/implementation/ExtendsModelsImpl.java b/typespec-tests/src/main/java/com/type/property/additionalproperties/implementation/ExtendsModelsImpl.java index 954e26e129..37d6a056c3 100644 --- a/typespec-tests/src/main/java/com/type/property/additionalproperties/implementation/ExtendsModelsImpl.java +++ b/typespec-tests/src/main/java/com/type/property/additionalproperties/implementation/ExtendsModelsImpl.java @@ -9,6 +9,7 @@ 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; @@ -55,7 +56,7 @@ public final class ExtendsModelsImpl { * The interface defining all the services for AdditionalPropertiesClientExtendsModels to be used by the proxy * service to perform REST calls. */ - @Host("http://localhost:3000") + @Host("{endpoint}") @ServiceInterface(name = "AdditionalProperties") public interface ExtendsModelsService { @Get("/type/property/additionalProperties/extendsRecordModel") @@ -64,8 +65,8 @@ public interface ExtendsModelsService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> get(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Get("/type/property/additionalProperties/extendsRecordModel") @ExpectedResponses({ 200 }) @@ -73,8 +74,8 @@ Mono> get(@HeaderParam("accept") String accept, RequestOpti @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response getSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Put("/type/property/additionalProperties/extendsRecordModel") @ExpectedResponses({ 204 }) @@ -82,7 +83,8 @@ Response getSync(@HeaderParam("accept") String accept, RequestOption @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> put(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, + 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") @@ -91,8 +93,8 @@ Mono> put(@HeaderParam("accept") String accept, @BodyParam("appli @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response putSync(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, - RequestOptions requestOptions, Context context); + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); } /** @@ -120,7 +122,7 @@ Response putSync(@HeaderParam("accept") String accept, @BodyParam("applica @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getWithResponseAsync(RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.get(accept, requestOptions, context)); + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); } /** @@ -148,7 +150,7 @@ public Mono> getWithResponseAsync(RequestOptions requestOpt @ServiceMethod(returns = ReturnType.SINGLE) public Response getWithResponse(RequestOptions requestOptions) { final String accept = "application/json"; - return service.getSync(accept, requestOptions, Context.NONE); + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); } /** @@ -176,8 +178,9 @@ public Response getWithResponse(RequestOptions requestOptions) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> putWithResponseAsync(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.put(accept, body, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.put(this.client.getEndpoint(), contentType, body, requestOptions, context)); } /** @@ -205,7 +208,7 @@ public Mono> putWithResponseAsync(BinaryData body, RequestOptions */ @ServiceMethod(returns = ReturnType.SINGLE) public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.putSync(accept, body, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/type/property/additionalproperties/implementation/ExtendsStringsImpl.java b/typespec-tests/src/main/java/com/type/property/additionalproperties/implementation/ExtendsStringsImpl.java index 3d3cbbade3..2ee4476668 100644 --- a/typespec-tests/src/main/java/com/type/property/additionalproperties/implementation/ExtendsStringsImpl.java +++ b/typespec-tests/src/main/java/com/type/property/additionalproperties/implementation/ExtendsStringsImpl.java @@ -9,6 +9,7 @@ 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; @@ -55,7 +56,7 @@ public final class ExtendsStringsImpl { * The interface defining all the services for AdditionalPropertiesClientExtendsStrings to be used by the proxy * service to perform REST calls. */ - @Host("http://localhost:3000") + @Host("{endpoint}") @ServiceInterface(name = "AdditionalProperties") public interface ExtendsStringsService { @Get("/type/property/additionalProperties/extendsRecordString") @@ -64,8 +65,8 @@ public interface ExtendsStringsService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> get(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Get("/type/property/additionalProperties/extendsRecordString") @ExpectedResponses({ 200 }) @@ -73,8 +74,8 @@ Mono> get(@HeaderParam("accept") String accept, RequestOpti @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response getSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Put("/type/property/additionalProperties/extendsRecordString") @ExpectedResponses({ 204 }) @@ -82,7 +83,8 @@ Response getSync(@HeaderParam("accept") String accept, RequestOption @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> put(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, + 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") @@ -91,8 +93,8 @@ Mono> put(@HeaderParam("accept") String accept, @BodyParam("appli @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response putSync(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, - RequestOptions requestOptions, Context context); + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); } /** @@ -118,7 +120,7 @@ Response putSync(@HeaderParam("accept") String accept, @BodyParam("applica @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getWithResponseAsync(RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.get(accept, requestOptions, context)); + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); } /** @@ -144,7 +146,7 @@ public Mono> getWithResponseAsync(RequestOptions requestOpt @ServiceMethod(returns = ReturnType.SINGLE) public Response getWithResponse(RequestOptions requestOptions) { final String accept = "application/json"; - return service.getSync(accept, requestOptions, Context.NONE); + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); } /** @@ -170,8 +172,9 @@ public Response getWithResponse(RequestOptions requestOptions) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> putWithResponseAsync(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.put(accept, body, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.put(this.client.getEndpoint(), contentType, body, requestOptions, context)); } /** @@ -197,7 +200,7 @@ public Mono> putWithResponseAsync(BinaryData body, RequestOptions */ @ServiceMethod(returns = ReturnType.SINGLE) public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.putSync(accept, body, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/type/property/additionalproperties/implementation/ExtendsUnknownDerivedsImpl.java b/typespec-tests/src/main/java/com/type/property/additionalproperties/implementation/ExtendsUnknownDerivedsImpl.java index d4a55cf5ad..2aaf5b14d6 100644 --- a/typespec-tests/src/main/java/com/type/property/additionalproperties/implementation/ExtendsUnknownDerivedsImpl.java +++ b/typespec-tests/src/main/java/com/type/property/additionalproperties/implementation/ExtendsUnknownDerivedsImpl.java @@ -9,6 +9,7 @@ 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; @@ -55,7 +56,7 @@ public final class ExtendsUnknownDerivedsImpl { * The interface defining all the services for AdditionalPropertiesClientExtendsUnknownDeriveds to be used by the * proxy service to perform REST calls. */ - @Host("http://localhost:3000") + @Host("{endpoint}") @ServiceInterface(name = "AdditionalProperties") public interface ExtendsUnknownDerivedsService { @Get("/type/property/additionalProperties/extendsRecordUnknownDerived") @@ -64,8 +65,8 @@ public interface ExtendsUnknownDerivedsService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> get(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Get("/type/property/additionalProperties/extendsRecordUnknownDerived") @ExpectedResponses({ 200 }) @@ -73,8 +74,8 @@ Mono> get(@HeaderParam("accept") String accept, RequestOpti @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response getSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Put("/type/property/additionalProperties/extendsRecordUnknownDerived") @ExpectedResponses({ 204 }) @@ -82,7 +83,8 @@ Response getSync(@HeaderParam("accept") String accept, RequestOption @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> put(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, + 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") @@ -91,8 +93,8 @@ Mono> put(@HeaderParam("accept") String accept, @BodyParam("appli @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response putSync(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, - RequestOptions requestOptions, Context context); + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); } /** @@ -120,7 +122,7 @@ Response putSync(@HeaderParam("accept") String accept, @BodyParam("applica @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getWithResponseAsync(RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.get(accept, requestOptions, context)); + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); } /** @@ -148,7 +150,7 @@ public Mono> getWithResponseAsync(RequestOptions requestOpt @ServiceMethod(returns = ReturnType.SINGLE) public Response getWithResponse(RequestOptions requestOptions) { final String accept = "application/json"; - return service.getSync(accept, requestOptions, Context.NONE); + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); } /** @@ -176,8 +178,9 @@ public Response getWithResponse(RequestOptions requestOptions) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> putWithResponseAsync(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.put(accept, body, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.put(this.client.getEndpoint(), contentType, body, requestOptions, context)); } /** @@ -205,7 +208,7 @@ public Mono> putWithResponseAsync(BinaryData body, RequestOptions */ @ServiceMethod(returns = ReturnType.SINGLE) public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.putSync(accept, body, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/type/property/additionalproperties/implementation/ExtendsUnknownDiscriminatedsImpl.java b/typespec-tests/src/main/java/com/type/property/additionalproperties/implementation/ExtendsUnknownDiscriminatedsImpl.java index 96798c5a1a..5e67fb8e72 100644 --- a/typespec-tests/src/main/java/com/type/property/additionalproperties/implementation/ExtendsUnknownDiscriminatedsImpl.java +++ b/typespec-tests/src/main/java/com/type/property/additionalproperties/implementation/ExtendsUnknownDiscriminatedsImpl.java @@ -9,6 +9,7 @@ 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; @@ -55,7 +56,7 @@ public final class ExtendsUnknownDiscriminatedsImpl { * The interface defining all the services for AdditionalPropertiesClientExtendsUnknownDiscriminateds to be used by * the proxy service to perform REST calls. */ - @Host("http://localhost:3000") + @Host("{endpoint}") @ServiceInterface(name = "AdditionalProperties") public interface ExtendsUnknownDiscriminatedsService { @Get("/type/property/additionalProperties/extendsUnknownDiscriminated") @@ -64,8 +65,8 @@ public interface ExtendsUnknownDiscriminatedsService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> get(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Get("/type/property/additionalProperties/extendsUnknownDiscriminated") @ExpectedResponses({ 200 }) @@ -73,8 +74,8 @@ Mono> get(@HeaderParam("accept") String accept, RequestOpti @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response getSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Put("/type/property/additionalProperties/extendsUnknownDiscriminated") @ExpectedResponses({ 204 }) @@ -82,7 +83,8 @@ Response getSync(@HeaderParam("accept") String accept, RequestOption @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> put(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, + 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") @@ -91,8 +93,8 @@ Mono> put(@HeaderParam("accept") String accept, @BodyParam("appli @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response putSync(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, - RequestOptions requestOptions, Context context); + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); } /** @@ -119,7 +121,7 @@ Response putSync(@HeaderParam("accept") String accept, @BodyParam("applica @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getWithResponseAsync(RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.get(accept, requestOptions, context)); + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); } /** @@ -146,7 +148,7 @@ public Mono> getWithResponseAsync(RequestOptions requestOpt @ServiceMethod(returns = ReturnType.SINGLE) public Response getWithResponse(RequestOptions requestOptions) { final String accept = "application/json"; - return service.getSync(accept, requestOptions, Context.NONE); + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); } /** @@ -173,8 +175,9 @@ public Response getWithResponse(RequestOptions requestOptions) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> putWithResponseAsync(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.put(accept, body, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.put(this.client.getEndpoint(), contentType, body, requestOptions, context)); } /** @@ -201,7 +204,7 @@ public Mono> putWithResponseAsync(BinaryData body, RequestOptions */ @ServiceMethod(returns = ReturnType.SINGLE) public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.putSync(accept, body, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/type/property/additionalproperties/implementation/ExtendsUnknownsImpl.java b/typespec-tests/src/main/java/com/type/property/additionalproperties/implementation/ExtendsUnknownsImpl.java index c58713b6fc..28f682fb1d 100644 --- a/typespec-tests/src/main/java/com/type/property/additionalproperties/implementation/ExtendsUnknownsImpl.java +++ b/typespec-tests/src/main/java/com/type/property/additionalproperties/implementation/ExtendsUnknownsImpl.java @@ -9,6 +9,7 @@ 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; @@ -55,7 +56,7 @@ public final class ExtendsUnknownsImpl { * The interface defining all the services for AdditionalPropertiesClientExtendsUnknowns to be used by the proxy * service to perform REST calls. */ - @Host("http://localhost:3000") + @Host("{endpoint}") @ServiceInterface(name = "AdditionalProperties") public interface ExtendsUnknownsService { @Get("/type/property/additionalProperties/extendsRecordUnknown") @@ -64,8 +65,8 @@ public interface ExtendsUnknownsService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> get(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Get("/type/property/additionalProperties/extendsRecordUnknown") @ExpectedResponses({ 200 }) @@ -73,8 +74,8 @@ Mono> get(@HeaderParam("accept") String accept, RequestOpti @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response getSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Put("/type/property/additionalProperties/extendsRecordUnknown") @ExpectedResponses({ 204 }) @@ -82,7 +83,8 @@ Response getSync(@HeaderParam("accept") String accept, RequestOption @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> put(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, + 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") @@ -91,8 +93,8 @@ Mono> put(@HeaderParam("accept") String accept, @BodyParam("appli @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response putSync(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, - RequestOptions requestOptions, Context context); + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); } /** @@ -118,7 +120,7 @@ Response putSync(@HeaderParam("accept") String accept, @BodyParam("applica @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getWithResponseAsync(RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.get(accept, requestOptions, context)); + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); } /** @@ -144,7 +146,7 @@ public Mono> getWithResponseAsync(RequestOptions requestOpt @ServiceMethod(returns = ReturnType.SINGLE) public Response getWithResponse(RequestOptions requestOptions) { final String accept = "application/json"; - return service.getSync(accept, requestOptions, Context.NONE); + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); } /** @@ -170,8 +172,9 @@ public Response getWithResponse(RequestOptions requestOptions) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> putWithResponseAsync(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.put(accept, body, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.put(this.client.getEndpoint(), contentType, body, requestOptions, context)); } /** @@ -197,7 +200,7 @@ public Mono> putWithResponseAsync(BinaryData body, RequestOptions */ @ServiceMethod(returns = ReturnType.SINGLE) public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.putSync(accept, body, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/type/property/additionalproperties/implementation/IsFloatsImpl.java b/typespec-tests/src/main/java/com/type/property/additionalproperties/implementation/IsFloatsImpl.java index e276967a22..c652616256 100644 --- a/typespec-tests/src/main/java/com/type/property/additionalproperties/implementation/IsFloatsImpl.java +++ b/typespec-tests/src/main/java/com/type/property/additionalproperties/implementation/IsFloatsImpl.java @@ -9,6 +9,7 @@ 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; @@ -54,7 +55,7 @@ public final class IsFloatsImpl { * The interface defining all the services for AdditionalPropertiesClientIsFloats to be used by the proxy service to * perform REST calls. */ - @Host("http://localhost:3000") + @Host("{endpoint}") @ServiceInterface(name = "AdditionalProperties") public interface IsFloatsService { @Get("/type/property/additionalProperties/isRecordFloat") @@ -63,8 +64,8 @@ public interface IsFloatsService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> get(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Get("/type/property/additionalProperties/isRecordFloat") @ExpectedResponses({ 200 }) @@ -72,8 +73,8 @@ Mono> get(@HeaderParam("accept") String accept, RequestOpti @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response getSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Put("/type/property/additionalProperties/isRecordFloat") @ExpectedResponses({ 204 }) @@ -81,7 +82,8 @@ Response getSync(@HeaderParam("accept") String accept, RequestOption @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> put(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, + 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") @@ -90,8 +92,8 @@ Mono> put(@HeaderParam("accept") String accept, @BodyParam("appli @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response putSync(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, - RequestOptions requestOptions, Context context); + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); } /** @@ -117,7 +119,7 @@ Response putSync(@HeaderParam("accept") String accept, @BodyParam("applica @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getWithResponseAsync(RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.get(accept, requestOptions, context)); + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); } /** @@ -143,7 +145,7 @@ public Mono> getWithResponseAsync(RequestOptions requestOpt @ServiceMethod(returns = ReturnType.SINGLE) public Response getWithResponse(RequestOptions requestOptions) { final String accept = "application/json"; - return service.getSync(accept, requestOptions, Context.NONE); + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); } /** @@ -169,8 +171,9 @@ public Response getWithResponse(RequestOptions requestOptions) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> putWithResponseAsync(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.put(accept, body, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.put(this.client.getEndpoint(), contentType, body, requestOptions, context)); } /** @@ -196,7 +199,7 @@ public Mono> putWithResponseAsync(BinaryData body, RequestOptions */ @ServiceMethod(returns = ReturnType.SINGLE) public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.putSync(accept, body, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/type/property/additionalproperties/implementation/IsModelArraysImpl.java b/typespec-tests/src/main/java/com/type/property/additionalproperties/implementation/IsModelArraysImpl.java index 7125390719..8d95467fb6 100644 --- a/typespec-tests/src/main/java/com/type/property/additionalproperties/implementation/IsModelArraysImpl.java +++ b/typespec-tests/src/main/java/com/type/property/additionalproperties/implementation/IsModelArraysImpl.java @@ -9,6 +9,7 @@ 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; @@ -55,7 +56,7 @@ public final class IsModelArraysImpl { * The interface defining all the services for AdditionalPropertiesClientIsModelArrays to be used by the proxy * service to perform REST calls. */ - @Host("http://localhost:3000") + @Host("{endpoint}") @ServiceInterface(name = "AdditionalProperties") public interface IsModelArraysService { @Get("/type/property/additionalProperties/isRecordModelArray") @@ -64,8 +65,8 @@ public interface IsModelArraysService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> get(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Get("/type/property/additionalProperties/isRecordModelArray") @ExpectedResponses({ 200 }) @@ -73,8 +74,8 @@ Mono> get(@HeaderParam("accept") String accept, RequestOpti @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response getSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Put("/type/property/additionalProperties/isRecordModelArray") @ExpectedResponses({ 204 }) @@ -82,7 +83,8 @@ Response getSync(@HeaderParam("accept") String accept, RequestOption @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> put(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, + 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") @@ -91,8 +93,8 @@ Mono> put(@HeaderParam("accept") String accept, @BodyParam("appli @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response putSync(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, - RequestOptions requestOptions, Context context); + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); } /** @@ -124,7 +126,7 @@ Response putSync(@HeaderParam("accept") String accept, @BodyParam("applica @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getWithResponseAsync(RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.get(accept, requestOptions, context)); + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); } /** @@ -156,7 +158,7 @@ public Mono> getWithResponseAsync(RequestOptions requestOpt @ServiceMethod(returns = ReturnType.SINGLE) public Response getWithResponse(RequestOptions requestOptions) { final String accept = "application/json"; - return service.getSync(accept, requestOptions, Context.NONE); + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); } /** @@ -188,8 +190,9 @@ public Response getWithResponse(RequestOptions requestOptions) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> putWithResponseAsync(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.put(accept, body, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.put(this.client.getEndpoint(), contentType, body, requestOptions, context)); } /** @@ -221,7 +224,7 @@ public Mono> putWithResponseAsync(BinaryData body, RequestOptions */ @ServiceMethod(returns = ReturnType.SINGLE) public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.putSync(accept, body, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/type/property/additionalproperties/implementation/IsModelsImpl.java b/typespec-tests/src/main/java/com/type/property/additionalproperties/implementation/IsModelsImpl.java index 774c6d7a12..44b0c52fb1 100644 --- a/typespec-tests/src/main/java/com/type/property/additionalproperties/implementation/IsModelsImpl.java +++ b/typespec-tests/src/main/java/com/type/property/additionalproperties/implementation/IsModelsImpl.java @@ -9,6 +9,7 @@ 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; @@ -54,7 +55,7 @@ public final class IsModelsImpl { * The interface defining all the services for AdditionalPropertiesClientIsModels to be used by the proxy service to * perform REST calls. */ - @Host("http://localhost:3000") + @Host("{endpoint}") @ServiceInterface(name = "AdditionalProperties") public interface IsModelsService { @Get("/type/property/additionalProperties/isRecordModel") @@ -63,8 +64,8 @@ public interface IsModelsService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> get(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Get("/type/property/additionalProperties/isRecordModel") @ExpectedResponses({ 200 }) @@ -72,8 +73,8 @@ Mono> get(@HeaderParam("accept") String accept, RequestOpti @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response getSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Put("/type/property/additionalProperties/isRecordModel") @ExpectedResponses({ 204 }) @@ -81,7 +82,8 @@ Response getSync(@HeaderParam("accept") String accept, RequestOption @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> put(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, + 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") @@ -90,8 +92,8 @@ Mono> put(@HeaderParam("accept") String accept, @BodyParam("appli @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response putSync(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, - RequestOptions requestOptions, Context context); + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); } /** @@ -119,7 +121,7 @@ Response putSync(@HeaderParam("accept") String accept, @BodyParam("applica @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getWithResponseAsync(RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.get(accept, requestOptions, context)); + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); } /** @@ -147,7 +149,7 @@ public Mono> getWithResponseAsync(RequestOptions requestOpt @ServiceMethod(returns = ReturnType.SINGLE) public Response getWithResponse(RequestOptions requestOptions) { final String accept = "application/json"; - return service.getSync(accept, requestOptions, Context.NONE); + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); } /** @@ -175,8 +177,9 @@ public Response getWithResponse(RequestOptions requestOptions) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> putWithResponseAsync(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.put(accept, body, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.put(this.client.getEndpoint(), contentType, body, requestOptions, context)); } /** @@ -204,7 +207,7 @@ public Mono> putWithResponseAsync(BinaryData body, RequestOptions */ @ServiceMethod(returns = ReturnType.SINGLE) public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.putSync(accept, body, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/type/property/additionalproperties/implementation/IsStringsImpl.java b/typespec-tests/src/main/java/com/type/property/additionalproperties/implementation/IsStringsImpl.java index fb3f27c469..35198e065c 100644 --- a/typespec-tests/src/main/java/com/type/property/additionalproperties/implementation/IsStringsImpl.java +++ b/typespec-tests/src/main/java/com/type/property/additionalproperties/implementation/IsStringsImpl.java @@ -9,6 +9,7 @@ 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; @@ -55,7 +56,7 @@ public final class IsStringsImpl { * The interface defining all the services for AdditionalPropertiesClientIsStrings to be used by the proxy service * to perform REST calls. */ - @Host("http://localhost:3000") + @Host("{endpoint}") @ServiceInterface(name = "AdditionalProperties") public interface IsStringsService { @Get("/type/property/additionalProperties/isRecordstring") @@ -64,8 +65,8 @@ public interface IsStringsService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> get(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Get("/type/property/additionalProperties/isRecordstring") @ExpectedResponses({ 200 }) @@ -73,8 +74,8 @@ Mono> get(@HeaderParam("accept") String accept, RequestOpti @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response getSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Put("/type/property/additionalProperties/isRecordstring") @ExpectedResponses({ 204 }) @@ -82,7 +83,8 @@ Response getSync(@HeaderParam("accept") String accept, RequestOption @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> put(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, + 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") @@ -91,8 +93,8 @@ Mono> put(@HeaderParam("accept") String accept, @BodyParam("appli @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response putSync(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, - RequestOptions requestOptions, Context context); + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); } /** @@ -118,7 +120,7 @@ Response putSync(@HeaderParam("accept") String accept, @BodyParam("applica @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getWithResponseAsync(RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.get(accept, requestOptions, context)); + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); } /** @@ -144,7 +146,7 @@ public Mono> getWithResponseAsync(RequestOptions requestOpt @ServiceMethod(returns = ReturnType.SINGLE) public Response getWithResponse(RequestOptions requestOptions) { final String accept = "application/json"; - return service.getSync(accept, requestOptions, Context.NONE); + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); } /** @@ -170,8 +172,9 @@ public Response getWithResponse(RequestOptions requestOptions) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> putWithResponseAsync(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.put(accept, body, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.put(this.client.getEndpoint(), contentType, body, requestOptions, context)); } /** @@ -197,7 +200,7 @@ public Mono> putWithResponseAsync(BinaryData body, RequestOptions */ @ServiceMethod(returns = ReturnType.SINGLE) public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.putSync(accept, body, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/type/property/additionalproperties/implementation/IsUnknownDerivedsImpl.java b/typespec-tests/src/main/java/com/type/property/additionalproperties/implementation/IsUnknownDerivedsImpl.java index bc84462e01..05a68b6bb3 100644 --- a/typespec-tests/src/main/java/com/type/property/additionalproperties/implementation/IsUnknownDerivedsImpl.java +++ b/typespec-tests/src/main/java/com/type/property/additionalproperties/implementation/IsUnknownDerivedsImpl.java @@ -9,6 +9,7 @@ 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; @@ -55,7 +56,7 @@ public final class IsUnknownDerivedsImpl { * The interface defining all the services for AdditionalPropertiesClientIsUnknownDeriveds to be used by the proxy * service to perform REST calls. */ - @Host("http://localhost:3000") + @Host("{endpoint}") @ServiceInterface(name = "AdditionalProperties") public interface IsUnknownDerivedsService { @Get("/type/property/additionalProperties/isRecordUnknownDerived") @@ -64,8 +65,8 @@ public interface IsUnknownDerivedsService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> get(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Get("/type/property/additionalProperties/isRecordUnknownDerived") @ExpectedResponses({ 200 }) @@ -73,8 +74,8 @@ Mono> get(@HeaderParam("accept") String accept, RequestOpti @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response getSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Put("/type/property/additionalProperties/isRecordUnknownDerived") @ExpectedResponses({ 204 }) @@ -82,7 +83,8 @@ Response getSync(@HeaderParam("accept") String accept, RequestOption @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> put(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, + 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") @@ -91,8 +93,8 @@ Mono> put(@HeaderParam("accept") String accept, @BodyParam("appli @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response putSync(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, - RequestOptions requestOptions, Context context); + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); } /** @@ -120,7 +122,7 @@ Response putSync(@HeaderParam("accept") String accept, @BodyParam("applica @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getWithResponseAsync(RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.get(accept, requestOptions, context)); + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); } /** @@ -148,7 +150,7 @@ public Mono> getWithResponseAsync(RequestOptions requestOpt @ServiceMethod(returns = ReturnType.SINGLE) public Response getWithResponse(RequestOptions requestOptions) { final String accept = "application/json"; - return service.getSync(accept, requestOptions, Context.NONE); + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); } /** @@ -176,8 +178,9 @@ public Response getWithResponse(RequestOptions requestOptions) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> putWithResponseAsync(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.put(accept, body, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.put(this.client.getEndpoint(), contentType, body, requestOptions, context)); } /** @@ -205,7 +208,7 @@ public Mono> putWithResponseAsync(BinaryData body, RequestOptions */ @ServiceMethod(returns = ReturnType.SINGLE) public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.putSync(accept, body, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/type/property/additionalproperties/implementation/IsUnknownDiscriminatedsImpl.java b/typespec-tests/src/main/java/com/type/property/additionalproperties/implementation/IsUnknownDiscriminatedsImpl.java index 22e4b82f69..11d80df74d 100644 --- a/typespec-tests/src/main/java/com/type/property/additionalproperties/implementation/IsUnknownDiscriminatedsImpl.java +++ b/typespec-tests/src/main/java/com/type/property/additionalproperties/implementation/IsUnknownDiscriminatedsImpl.java @@ -9,6 +9,7 @@ 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; @@ -55,7 +56,7 @@ public final class IsUnknownDiscriminatedsImpl { * The interface defining all the services for AdditionalPropertiesClientIsUnknownDiscriminateds to be used by the * proxy service to perform REST calls. */ - @Host("http://localhost:3000") + @Host("{endpoint}") @ServiceInterface(name = "AdditionalProperties") public interface IsUnknownDiscriminatedsService { @Get("/type/property/additionalProperties/isUnknownDiscriminated") @@ -64,8 +65,8 @@ public interface IsUnknownDiscriminatedsService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> get(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Get("/type/property/additionalProperties/isUnknownDiscriminated") @ExpectedResponses({ 200 }) @@ -73,8 +74,8 @@ Mono> get(@HeaderParam("accept") String accept, RequestOpti @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response getSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Put("/type/property/additionalProperties/isUnknownDiscriminated") @ExpectedResponses({ 204 }) @@ -82,7 +83,8 @@ Response getSync(@HeaderParam("accept") String accept, RequestOption @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> put(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, + 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") @@ -91,8 +93,8 @@ Mono> put(@HeaderParam("accept") String accept, @BodyParam("appli @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response putSync(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, - RequestOptions requestOptions, Context context); + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); } /** @@ -119,7 +121,7 @@ Response putSync(@HeaderParam("accept") String accept, @BodyParam("applica @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getWithResponseAsync(RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.get(accept, requestOptions, context)); + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); } /** @@ -146,7 +148,7 @@ public Mono> getWithResponseAsync(RequestOptions requestOpt @ServiceMethod(returns = ReturnType.SINGLE) public Response getWithResponse(RequestOptions requestOptions) { final String accept = "application/json"; - return service.getSync(accept, requestOptions, Context.NONE); + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); } /** @@ -173,8 +175,9 @@ public Response getWithResponse(RequestOptions requestOptions) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> putWithResponseAsync(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.put(accept, body, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.put(this.client.getEndpoint(), contentType, body, requestOptions, context)); } /** @@ -201,7 +204,7 @@ public Mono> putWithResponseAsync(BinaryData body, RequestOptions */ @ServiceMethod(returns = ReturnType.SINGLE) public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.putSync(accept, body, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/type/property/additionalproperties/implementation/IsUnknownsImpl.java b/typespec-tests/src/main/java/com/type/property/additionalproperties/implementation/IsUnknownsImpl.java index 785aa71b46..14af79a153 100644 --- a/typespec-tests/src/main/java/com/type/property/additionalproperties/implementation/IsUnknownsImpl.java +++ b/typespec-tests/src/main/java/com/type/property/additionalproperties/implementation/IsUnknownsImpl.java @@ -9,6 +9,7 @@ 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; @@ -55,7 +56,7 @@ public final class IsUnknownsImpl { * The interface defining all the services for AdditionalPropertiesClientIsUnknowns to be used by the proxy service * to perform REST calls. */ - @Host("http://localhost:3000") + @Host("{endpoint}") @ServiceInterface(name = "AdditionalProperties") public interface IsUnknownsService { @Get("/type/property/additionalProperties/isRecordUnknown") @@ -64,8 +65,8 @@ public interface IsUnknownsService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> get(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Get("/type/property/additionalProperties/isRecordUnknown") @ExpectedResponses({ 200 }) @@ -73,8 +74,8 @@ Mono> get(@HeaderParam("accept") String accept, RequestOpti @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response getSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Put("/type/property/additionalProperties/isRecordUnknown") @ExpectedResponses({ 204 }) @@ -82,7 +83,8 @@ Response getSync(@HeaderParam("accept") String accept, RequestOption @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> put(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, + 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") @@ -91,8 +93,8 @@ Mono> put(@HeaderParam("accept") String accept, @BodyParam("appli @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response putSync(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, - RequestOptions requestOptions, Context context); + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); } /** @@ -118,7 +120,7 @@ Response putSync(@HeaderParam("accept") String accept, @BodyParam("applica @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getWithResponseAsync(RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.get(accept, requestOptions, context)); + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); } /** @@ -144,7 +146,7 @@ public Mono> getWithResponseAsync(RequestOptions requestOpt @ServiceMethod(returns = ReturnType.SINGLE) public Response getWithResponse(RequestOptions requestOptions) { final String accept = "application/json"; - return service.getSync(accept, requestOptions, Context.NONE); + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); } /** @@ -170,8 +172,9 @@ public Response getWithResponse(RequestOptions requestOptions) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> putWithResponseAsync(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.put(accept, body, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.put(this.client.getEndpoint(), contentType, body, requestOptions, context)); } /** @@ -197,7 +200,7 @@ public Mono> putWithResponseAsync(BinaryData body, RequestOptions */ @ServiceMethod(returns = ReturnType.SINGLE) public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.putSync(accept, body, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/type/property/additionalproperties/implementation/MultipleSpreadsImpl.java b/typespec-tests/src/main/java/com/type/property/additionalproperties/implementation/MultipleSpreadsImpl.java index dbbfe181bc..77c14978b2 100644 --- a/typespec-tests/src/main/java/com/type/property/additionalproperties/implementation/MultipleSpreadsImpl.java +++ b/typespec-tests/src/main/java/com/type/property/additionalproperties/implementation/MultipleSpreadsImpl.java @@ -9,6 +9,7 @@ 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; @@ -55,7 +56,7 @@ public final class MultipleSpreadsImpl { * The interface defining all the services for AdditionalPropertiesClientMultipleSpreads to be used by the proxy * service to perform REST calls. */ - @Host("http://localhost:3000") + @Host("{endpoint}") @ServiceInterface(name = "AdditionalProperties") public interface MultipleSpreadsService { @Get("/type/property/additionalProperties/multipleSpreadRecord") @@ -64,8 +65,8 @@ public interface MultipleSpreadsService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> get(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Get("/type/property/additionalProperties/multipleSpreadRecord") @ExpectedResponses({ 200 }) @@ -73,8 +74,8 @@ Mono> get(@HeaderParam("accept") String accept, RequestOpti @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response getSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Put("/type/property/additionalProperties/multipleSpreadRecord") @ExpectedResponses({ 204 }) @@ -82,7 +83,8 @@ Response getSync(@HeaderParam("accept") String accept, RequestOption @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> put(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, + 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") @@ -91,8 +93,8 @@ Mono> put(@HeaderParam("accept") String accept, @BodyParam("appli @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response putSync(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, - RequestOptions requestOptions, Context context); + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); } /** @@ -118,7 +120,7 @@ Response putSync(@HeaderParam("accept") String accept, @BodyParam("applica @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getWithResponseAsync(RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.get(accept, requestOptions, context)); + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); } /** @@ -144,7 +146,7 @@ public Mono> getWithResponseAsync(RequestOptions requestOpt @ServiceMethod(returns = ReturnType.SINGLE) public Response getWithResponse(RequestOptions requestOptions) { final String accept = "application/json"; - return service.getSync(accept, requestOptions, Context.NONE); + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); } /** @@ -170,8 +172,9 @@ public Response getWithResponse(RequestOptions requestOptions) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> putWithResponseAsync(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.put(accept, body, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.put(this.client.getEndpoint(), contentType, body, requestOptions, context)); } /** @@ -197,7 +200,7 @@ public Mono> putWithResponseAsync(BinaryData body, RequestOptions */ @ServiceMethod(returns = ReturnType.SINGLE) public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.putSync(accept, body, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/type/property/additionalproperties/implementation/SpreadDifferentFloatsImpl.java b/typespec-tests/src/main/java/com/type/property/additionalproperties/implementation/SpreadDifferentFloatsImpl.java index 656068de0d..0141e36ac4 100644 --- a/typespec-tests/src/main/java/com/type/property/additionalproperties/implementation/SpreadDifferentFloatsImpl.java +++ b/typespec-tests/src/main/java/com/type/property/additionalproperties/implementation/SpreadDifferentFloatsImpl.java @@ -9,6 +9,7 @@ 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; @@ -55,7 +56,7 @@ public final class SpreadDifferentFloatsImpl { * The interface defining all the services for AdditionalPropertiesClientSpreadDifferentFloats to be used by the * proxy service to perform REST calls. */ - @Host("http://localhost:3000") + @Host("{endpoint}") @ServiceInterface(name = "AdditionalProperties") public interface SpreadDifferentFloatsService { @Get("/type/property/additionalProperties/spreadDifferentRecordFloat") @@ -64,8 +65,8 @@ public interface SpreadDifferentFloatsService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> get(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Get("/type/property/additionalProperties/spreadDifferentRecordFloat") @ExpectedResponses({ 200 }) @@ -73,8 +74,8 @@ Mono> get(@HeaderParam("accept") String accept, RequestOpti @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response getSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Put("/type/property/additionalProperties/spreadDifferentRecordFloat") @ExpectedResponses({ 204 }) @@ -82,7 +83,8 @@ Response getSync(@HeaderParam("accept") String accept, RequestOption @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> put(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, + 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") @@ -91,8 +93,8 @@ Mono> put(@HeaderParam("accept") String accept, @BodyParam("appli @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response putSync(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, - RequestOptions requestOptions, Context context); + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); } /** @@ -118,7 +120,7 @@ Response putSync(@HeaderParam("accept") String accept, @BodyParam("applica @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getWithResponseAsync(RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.get(accept, requestOptions, context)); + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); } /** @@ -144,7 +146,7 @@ public Mono> getWithResponseAsync(RequestOptions requestOpt @ServiceMethod(returns = ReturnType.SINGLE) public Response getWithResponse(RequestOptions requestOptions) { final String accept = "application/json"; - return service.getSync(accept, requestOptions, Context.NONE); + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); } /** @@ -170,8 +172,9 @@ public Response getWithResponse(RequestOptions requestOptions) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> putWithResponseAsync(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.put(accept, body, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.put(this.client.getEndpoint(), contentType, body, requestOptions, context)); } /** @@ -197,7 +200,7 @@ public Mono> putWithResponseAsync(BinaryData body, RequestOptions */ @ServiceMethod(returns = ReturnType.SINGLE) public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.putSync(accept, body, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/type/property/additionalproperties/implementation/SpreadDifferentModelArraysImpl.java b/typespec-tests/src/main/java/com/type/property/additionalproperties/implementation/SpreadDifferentModelArraysImpl.java index 49fc1bc88b..c1e3aa384f 100644 --- a/typespec-tests/src/main/java/com/type/property/additionalproperties/implementation/SpreadDifferentModelArraysImpl.java +++ b/typespec-tests/src/main/java/com/type/property/additionalproperties/implementation/SpreadDifferentModelArraysImpl.java @@ -9,6 +9,7 @@ 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; @@ -55,7 +56,7 @@ public final class SpreadDifferentModelArraysImpl { * The interface defining all the services for AdditionalPropertiesClientSpreadDifferentModelArrays to be used by * the proxy service to perform REST calls. */ - @Host("http://localhost:3000") + @Host("{endpoint}") @ServiceInterface(name = "AdditionalProperties") public interface SpreadDifferentModelArraysService { @Get("/type/property/additionalProperties/spreadDifferentRecordModelArray") @@ -64,8 +65,8 @@ public interface SpreadDifferentModelArraysService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> get(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Get("/type/property/additionalProperties/spreadDifferentRecordModelArray") @ExpectedResponses({ 200 }) @@ -73,8 +74,8 @@ Mono> get(@HeaderParam("accept") String accept, RequestOpti @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response getSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Put("/type/property/additionalProperties/spreadDifferentRecordModelArray") @ExpectedResponses({ 204 }) @@ -82,7 +83,8 @@ Response getSync(@HeaderParam("accept") String accept, RequestOption @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> put(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, + 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") @@ -91,8 +93,8 @@ Mono> put(@HeaderParam("accept") String accept, @BodyParam("appli @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response putSync(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, - RequestOptions requestOptions, Context context); + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); } /** @@ -122,7 +124,7 @@ Response putSync(@HeaderParam("accept") String accept, @BodyParam("applica @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getWithResponseAsync(RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.get(accept, requestOptions, context)); + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); } /** @@ -152,7 +154,7 @@ public Mono> getWithResponseAsync(RequestOptions requestOpt @ServiceMethod(returns = ReturnType.SINGLE) public Response getWithResponse(RequestOptions requestOptions) { final String accept = "application/json"; - return service.getSync(accept, requestOptions, Context.NONE); + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); } /** @@ -182,8 +184,9 @@ public Response getWithResponse(RequestOptions requestOptions) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> putWithResponseAsync(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.put(accept, body, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.put(this.client.getEndpoint(), contentType, body, requestOptions, context)); } /** @@ -213,7 +216,7 @@ public Mono> putWithResponseAsync(BinaryData body, RequestOptions */ @ServiceMethod(returns = ReturnType.SINGLE) public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.putSync(accept, body, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/type/property/additionalproperties/implementation/SpreadDifferentModelsImpl.java b/typespec-tests/src/main/java/com/type/property/additionalproperties/implementation/SpreadDifferentModelsImpl.java index 26370c64d6..fed8bd79de 100644 --- a/typespec-tests/src/main/java/com/type/property/additionalproperties/implementation/SpreadDifferentModelsImpl.java +++ b/typespec-tests/src/main/java/com/type/property/additionalproperties/implementation/SpreadDifferentModelsImpl.java @@ -9,6 +9,7 @@ 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; @@ -55,7 +56,7 @@ public final class SpreadDifferentModelsImpl { * The interface defining all the services for AdditionalPropertiesClientSpreadDifferentModels to be used by the * proxy service to perform REST calls. */ - @Host("http://localhost:3000") + @Host("{endpoint}") @ServiceInterface(name = "AdditionalProperties") public interface SpreadDifferentModelsService { @Get("/type/property/additionalProperties/spreadDifferentRecordModel") @@ -64,8 +65,8 @@ public interface SpreadDifferentModelsService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> get(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Get("/type/property/additionalProperties/spreadDifferentRecordModel") @ExpectedResponses({ 200 }) @@ -73,8 +74,8 @@ Mono> get(@HeaderParam("accept") String accept, RequestOpti @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response getSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Put("/type/property/additionalProperties/spreadDifferentRecordModel") @ExpectedResponses({ 204 }) @@ -82,7 +83,8 @@ Response getSync(@HeaderParam("accept") String accept, RequestOption @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> put(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, + 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") @@ -91,8 +93,8 @@ Mono> put(@HeaderParam("accept") String accept, @BodyParam("appli @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response putSync(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, - RequestOptions requestOptions, Context context); + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); } /** @@ -120,7 +122,7 @@ Response putSync(@HeaderParam("accept") String accept, @BodyParam("applica @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getWithResponseAsync(RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.get(accept, requestOptions, context)); + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); } /** @@ -148,7 +150,7 @@ public Mono> getWithResponseAsync(RequestOptions requestOpt @ServiceMethod(returns = ReturnType.SINGLE) public Response getWithResponse(RequestOptions requestOptions) { final String accept = "application/json"; - return service.getSync(accept, requestOptions, Context.NONE); + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); } /** @@ -176,8 +178,9 @@ public Response getWithResponse(RequestOptions requestOptions) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> putWithResponseAsync(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.put(accept, body, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.put(this.client.getEndpoint(), contentType, body, requestOptions, context)); } /** @@ -205,7 +208,7 @@ public Mono> putWithResponseAsync(BinaryData body, RequestOptions */ @ServiceMethod(returns = ReturnType.SINGLE) public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.putSync(accept, body, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/type/property/additionalproperties/implementation/SpreadDifferentStringsImpl.java b/typespec-tests/src/main/java/com/type/property/additionalproperties/implementation/SpreadDifferentStringsImpl.java index 99142402ab..a8056c035e 100644 --- a/typespec-tests/src/main/java/com/type/property/additionalproperties/implementation/SpreadDifferentStringsImpl.java +++ b/typespec-tests/src/main/java/com/type/property/additionalproperties/implementation/SpreadDifferentStringsImpl.java @@ -9,6 +9,7 @@ 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; @@ -55,7 +56,7 @@ public final class SpreadDifferentStringsImpl { * The interface defining all the services for AdditionalPropertiesClientSpreadDifferentStrings to be used by the * proxy service to perform REST calls. */ - @Host("http://localhost:3000") + @Host("{endpoint}") @ServiceInterface(name = "AdditionalProperties") public interface SpreadDifferentStringsService { @Get("/type/property/additionalProperties/spreadDifferentRecordString") @@ -64,8 +65,8 @@ public interface SpreadDifferentStringsService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> get(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Get("/type/property/additionalProperties/spreadDifferentRecordString") @ExpectedResponses({ 200 }) @@ -73,8 +74,8 @@ Mono> get(@HeaderParam("accept") String accept, RequestOpti @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response getSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Put("/type/property/additionalProperties/spreadDifferentRecordString") @ExpectedResponses({ 204 }) @@ -82,7 +83,8 @@ Response getSync(@HeaderParam("accept") String accept, RequestOption @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> put(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, + 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") @@ -91,8 +93,8 @@ Mono> put(@HeaderParam("accept") String accept, @BodyParam("appli @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response putSync(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, - RequestOptions requestOptions, Context context); + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); } /** @@ -118,7 +120,7 @@ Response putSync(@HeaderParam("accept") String accept, @BodyParam("applica @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getWithResponseAsync(RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.get(accept, requestOptions, context)); + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); } /** @@ -144,7 +146,7 @@ public Mono> getWithResponseAsync(RequestOptions requestOpt @ServiceMethod(returns = ReturnType.SINGLE) public Response getWithResponse(RequestOptions requestOptions) { final String accept = "application/json"; - return service.getSync(accept, requestOptions, Context.NONE); + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); } /** @@ -170,8 +172,9 @@ public Response getWithResponse(RequestOptions requestOptions) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> putWithResponseAsync(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.put(accept, body, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.put(this.client.getEndpoint(), contentType, body, requestOptions, context)); } /** @@ -197,7 +200,7 @@ public Mono> putWithResponseAsync(BinaryData body, RequestOptions */ @ServiceMethod(returns = ReturnType.SINGLE) public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.putSync(accept, body, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/type/property/additionalproperties/implementation/SpreadFloatsImpl.java b/typespec-tests/src/main/java/com/type/property/additionalproperties/implementation/SpreadFloatsImpl.java index 6aabfef3d0..a6e5600d38 100644 --- a/typespec-tests/src/main/java/com/type/property/additionalproperties/implementation/SpreadFloatsImpl.java +++ b/typespec-tests/src/main/java/com/type/property/additionalproperties/implementation/SpreadFloatsImpl.java @@ -9,6 +9,7 @@ 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; @@ -55,7 +56,7 @@ public final class SpreadFloatsImpl { * The interface defining all the services for AdditionalPropertiesClientSpreadFloats to be used by the proxy * service to perform REST calls. */ - @Host("http://localhost:3000") + @Host("{endpoint}") @ServiceInterface(name = "AdditionalProperties") public interface SpreadFloatsService { @Get("/type/property/additionalProperties/spreadRecordFloat") @@ -64,8 +65,8 @@ public interface SpreadFloatsService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> get(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Get("/type/property/additionalProperties/spreadRecordFloat") @ExpectedResponses({ 200 }) @@ -73,8 +74,8 @@ Mono> get(@HeaderParam("accept") String accept, RequestOpti @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response getSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Put("/type/property/additionalProperties/spreadRecordFloat") @ExpectedResponses({ 204 }) @@ -82,7 +83,8 @@ Response getSync(@HeaderParam("accept") String accept, RequestOption @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> put(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, + 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") @@ -91,8 +93,8 @@ Mono> put(@HeaderParam("accept") String accept, @BodyParam("appli @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response putSync(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, - RequestOptions requestOptions, Context context); + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); } /** @@ -118,7 +120,7 @@ Response putSync(@HeaderParam("accept") String accept, @BodyParam("applica @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getWithResponseAsync(RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.get(accept, requestOptions, context)); + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); } /** @@ -144,7 +146,7 @@ public Mono> getWithResponseAsync(RequestOptions requestOpt @ServiceMethod(returns = ReturnType.SINGLE) public Response getWithResponse(RequestOptions requestOptions) { final String accept = "application/json"; - return service.getSync(accept, requestOptions, Context.NONE); + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); } /** @@ -170,8 +172,9 @@ public Response getWithResponse(RequestOptions requestOptions) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> putWithResponseAsync(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.put(accept, body, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.put(this.client.getEndpoint(), contentType, body, requestOptions, context)); } /** @@ -197,7 +200,7 @@ public Mono> putWithResponseAsync(BinaryData body, RequestOptions */ @ServiceMethod(returns = ReturnType.SINGLE) public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.putSync(accept, body, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/type/property/additionalproperties/implementation/SpreadModelArraysImpl.java b/typespec-tests/src/main/java/com/type/property/additionalproperties/implementation/SpreadModelArraysImpl.java index 90f5c8d51f..25eb98c761 100644 --- a/typespec-tests/src/main/java/com/type/property/additionalproperties/implementation/SpreadModelArraysImpl.java +++ b/typespec-tests/src/main/java/com/type/property/additionalproperties/implementation/SpreadModelArraysImpl.java @@ -9,6 +9,7 @@ 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; @@ -55,7 +56,7 @@ public final class SpreadModelArraysImpl { * The interface defining all the services for AdditionalPropertiesClientSpreadModelArrays to be used by the proxy * service to perform REST calls. */ - @Host("http://localhost:3000") + @Host("{endpoint}") @ServiceInterface(name = "AdditionalProperties") public interface SpreadModelArraysService { @Get("/type/property/additionalProperties/spreadRecordModelArray") @@ -64,8 +65,8 @@ public interface SpreadModelArraysService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> get(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Get("/type/property/additionalProperties/spreadRecordModelArray") @ExpectedResponses({ 200 }) @@ -73,8 +74,8 @@ Mono> get(@HeaderParam("accept") String accept, RequestOpti @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response getSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Put("/type/property/additionalProperties/spreadRecordModelArray") @ExpectedResponses({ 204 }) @@ -82,7 +83,8 @@ Response getSync(@HeaderParam("accept") String accept, RequestOption @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> put(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, + 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") @@ -91,8 +93,8 @@ Mono> put(@HeaderParam("accept") String accept, @BodyParam("appli @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response putSync(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, - RequestOptions requestOptions, Context context); + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); } /** @@ -124,7 +126,7 @@ Response putSync(@HeaderParam("accept") String accept, @BodyParam("applica @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getWithResponseAsync(RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.get(accept, requestOptions, context)); + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); } /** @@ -156,7 +158,7 @@ public Mono> getWithResponseAsync(RequestOptions requestOpt @ServiceMethod(returns = ReturnType.SINGLE) public Response getWithResponse(RequestOptions requestOptions) { final String accept = "application/json"; - return service.getSync(accept, requestOptions, Context.NONE); + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); } /** @@ -188,8 +190,9 @@ public Response getWithResponse(RequestOptions requestOptions) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> putWithResponseAsync(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.put(accept, body, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.put(this.client.getEndpoint(), contentType, body, requestOptions, context)); } /** @@ -221,7 +224,7 @@ public Mono> putWithResponseAsync(BinaryData body, RequestOptions */ @ServiceMethod(returns = ReturnType.SINGLE) public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.putSync(accept, body, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/type/property/additionalproperties/implementation/SpreadModelsImpl.java b/typespec-tests/src/main/java/com/type/property/additionalproperties/implementation/SpreadModelsImpl.java index 6697295534..fdd2a2fd9a 100644 --- a/typespec-tests/src/main/java/com/type/property/additionalproperties/implementation/SpreadModelsImpl.java +++ b/typespec-tests/src/main/java/com/type/property/additionalproperties/implementation/SpreadModelsImpl.java @@ -9,6 +9,7 @@ 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; @@ -55,7 +56,7 @@ public final class SpreadModelsImpl { * The interface defining all the services for AdditionalPropertiesClientSpreadModels to be used by the proxy * service to perform REST calls. */ - @Host("http://localhost:3000") + @Host("{endpoint}") @ServiceInterface(name = "AdditionalProperties") public interface SpreadModelsService { @Get("/type/property/additionalProperties/spreadRecordModel") @@ -64,8 +65,8 @@ public interface SpreadModelsService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> get(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Get("/type/property/additionalProperties/spreadRecordModel") @ExpectedResponses({ 200 }) @@ -73,8 +74,8 @@ Mono> get(@HeaderParam("accept") String accept, RequestOpti @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response getSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Put("/type/property/additionalProperties/spreadRecordModel") @ExpectedResponses({ 204 }) @@ -82,7 +83,8 @@ Response getSync(@HeaderParam("accept") String accept, RequestOption @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> put(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, + 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") @@ -91,8 +93,8 @@ Mono> put(@HeaderParam("accept") String accept, @BodyParam("appli @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response putSync(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, - RequestOptions requestOptions, Context context); + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); } /** @@ -120,7 +122,7 @@ Response putSync(@HeaderParam("accept") String accept, @BodyParam("applica @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getWithResponseAsync(RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.get(accept, requestOptions, context)); + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); } /** @@ -148,7 +150,7 @@ public Mono> getWithResponseAsync(RequestOptions requestOpt @ServiceMethod(returns = ReturnType.SINGLE) public Response getWithResponse(RequestOptions requestOptions) { final String accept = "application/json"; - return service.getSync(accept, requestOptions, Context.NONE); + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); } /** @@ -176,8 +178,9 @@ public Response getWithResponse(RequestOptions requestOptions) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> putWithResponseAsync(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.put(accept, body, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.put(this.client.getEndpoint(), contentType, body, requestOptions, context)); } /** @@ -205,7 +208,7 @@ public Mono> putWithResponseAsync(BinaryData body, RequestOptions */ @ServiceMethod(returns = ReturnType.SINGLE) public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.putSync(accept, body, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/type/property/additionalproperties/implementation/SpreadRecordDiscriminatedUnionsImpl.java b/typespec-tests/src/main/java/com/type/property/additionalproperties/implementation/SpreadRecordDiscriminatedUnionsImpl.java index eb6455fc95..08605622c4 100644 --- a/typespec-tests/src/main/java/com/type/property/additionalproperties/implementation/SpreadRecordDiscriminatedUnionsImpl.java +++ b/typespec-tests/src/main/java/com/type/property/additionalproperties/implementation/SpreadRecordDiscriminatedUnionsImpl.java @@ -9,6 +9,7 @@ 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; @@ -55,7 +56,7 @@ public final class SpreadRecordDiscriminatedUnionsImpl { * The interface defining all the services for AdditionalPropertiesClientSpreadRecordDiscriminatedUnions to be used * by the proxy service to perform REST calls. */ - @Host("http://localhost:3000") + @Host("{endpoint}") @ServiceInterface(name = "AdditionalProperties") public interface SpreadRecordDiscriminatedUnionsService { @Get("/type/property/additionalProperties/spreadRecordDiscriminatedUnion") @@ -64,8 +65,8 @@ public interface SpreadRecordDiscriminatedUnionsService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> get(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Get("/type/property/additionalProperties/spreadRecordDiscriminatedUnion") @ExpectedResponses({ 200 }) @@ -73,8 +74,8 @@ Mono> get(@HeaderParam("accept") String accept, RequestOpti @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response getSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Put("/type/property/additionalProperties/spreadRecordDiscriminatedUnion") @ExpectedResponses({ 204 }) @@ -82,7 +83,8 @@ Response getSync(@HeaderParam("accept") String accept, RequestOption @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> put(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, + 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") @@ -91,8 +93,8 @@ Mono> put(@HeaderParam("accept") String accept, @BodyParam("appli @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response putSync(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, - RequestOptions requestOptions, Context context); + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); } /** @@ -118,7 +120,7 @@ Response putSync(@HeaderParam("accept") String accept, @BodyParam("applica @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getWithResponseAsync(RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.get(accept, requestOptions, context)); + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); } /** @@ -144,7 +146,7 @@ public Mono> getWithResponseAsync(RequestOptions requestOpt @ServiceMethod(returns = ReturnType.SINGLE) public Response getWithResponse(RequestOptions requestOptions) { final String accept = "application/json"; - return service.getSync(accept, requestOptions, Context.NONE); + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); } /** @@ -170,8 +172,9 @@ public Response getWithResponse(RequestOptions requestOptions) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> putWithResponseAsync(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.put(accept, body, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.put(this.client.getEndpoint(), contentType, body, requestOptions, context)); } /** @@ -197,7 +200,7 @@ public Mono> putWithResponseAsync(BinaryData body, RequestOptions */ @ServiceMethod(returns = ReturnType.SINGLE) public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.putSync(accept, body, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/type/property/additionalproperties/implementation/SpreadRecordNonDiscriminatedUnion2sImpl.java b/typespec-tests/src/main/java/com/type/property/additionalproperties/implementation/SpreadRecordNonDiscriminatedUnion2sImpl.java index f4b04508f0..774b0db139 100644 --- a/typespec-tests/src/main/java/com/type/property/additionalproperties/implementation/SpreadRecordNonDiscriminatedUnion2sImpl.java +++ b/typespec-tests/src/main/java/com/type/property/additionalproperties/implementation/SpreadRecordNonDiscriminatedUnion2sImpl.java @@ -9,6 +9,7 @@ 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; @@ -55,7 +56,7 @@ public final class SpreadRecordNonDiscriminatedUnion2sImpl { * The interface defining all the services for AdditionalPropertiesClientSpreadRecordNonDiscriminatedUnion2s to be * used by the proxy service to perform REST calls. */ - @Host("http://localhost:3000") + @Host("{endpoint}") @ServiceInterface(name = "AdditionalProperties") public interface SpreadRecordNonDiscriminatedUnion2sService { @Get("/type/property/additionalProperties/spreadRecordNonDiscriminatedUnion2") @@ -64,8 +65,8 @@ public interface SpreadRecordNonDiscriminatedUnion2sService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> get(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Get("/type/property/additionalProperties/spreadRecordNonDiscriminatedUnion2") @ExpectedResponses({ 200 }) @@ -73,8 +74,8 @@ Mono> get(@HeaderParam("accept") String accept, RequestOpti @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response getSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Put("/type/property/additionalProperties/spreadRecordNonDiscriminatedUnion2") @ExpectedResponses({ 204 }) @@ -82,7 +83,8 @@ Response getSync(@HeaderParam("accept") String accept, RequestOption @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> put(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, + 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") @@ -91,8 +93,8 @@ Mono> put(@HeaderParam("accept") String accept, @BodyParam("appli @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response putSync(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, - RequestOptions requestOptions, Context context); + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); } /** @@ -118,7 +120,7 @@ Response putSync(@HeaderParam("accept") String accept, @BodyParam("applica @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getWithResponseAsync(RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.get(accept, requestOptions, context)); + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); } /** @@ -144,7 +146,7 @@ public Mono> getWithResponseAsync(RequestOptions requestOpt @ServiceMethod(returns = ReturnType.SINGLE) public Response getWithResponse(RequestOptions requestOptions) { final String accept = "application/json"; - return service.getSync(accept, requestOptions, Context.NONE); + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); } /** @@ -170,8 +172,9 @@ public Response getWithResponse(RequestOptions requestOptions) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> putWithResponseAsync(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.put(accept, body, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.put(this.client.getEndpoint(), contentType, body, requestOptions, context)); } /** @@ -197,7 +200,7 @@ public Mono> putWithResponseAsync(BinaryData body, RequestOptions */ @ServiceMethod(returns = ReturnType.SINGLE) public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.putSync(accept, body, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/type/property/additionalproperties/implementation/SpreadRecordNonDiscriminatedUnion3sImpl.java b/typespec-tests/src/main/java/com/type/property/additionalproperties/implementation/SpreadRecordNonDiscriminatedUnion3sImpl.java index 84d395ac98..29f7579eb5 100644 --- a/typespec-tests/src/main/java/com/type/property/additionalproperties/implementation/SpreadRecordNonDiscriminatedUnion3sImpl.java +++ b/typespec-tests/src/main/java/com/type/property/additionalproperties/implementation/SpreadRecordNonDiscriminatedUnion3sImpl.java @@ -9,6 +9,7 @@ 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; @@ -55,7 +56,7 @@ public final class SpreadRecordNonDiscriminatedUnion3sImpl { * The interface defining all the services for AdditionalPropertiesClientSpreadRecordNonDiscriminatedUnion3s to be * used by the proxy service to perform REST calls. */ - @Host("http://localhost:3000") + @Host("{endpoint}") @ServiceInterface(name = "AdditionalProperties") public interface SpreadRecordNonDiscriminatedUnion3sService { @Get("/type/property/additionalProperties/spreadRecordNonDiscriminatedUnion3") @@ -64,8 +65,8 @@ public interface SpreadRecordNonDiscriminatedUnion3sService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> get(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Get("/type/property/additionalProperties/spreadRecordNonDiscriminatedUnion3") @ExpectedResponses({ 200 }) @@ -73,8 +74,8 @@ Mono> get(@HeaderParam("accept") String accept, RequestOpti @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response getSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Put("/type/property/additionalProperties/spreadRecordNonDiscriminatedUnion3") @ExpectedResponses({ 204 }) @@ -82,7 +83,8 @@ Response getSync(@HeaderParam("accept") String accept, RequestOption @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> put(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, + 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") @@ -91,8 +93,8 @@ Mono> put(@HeaderParam("accept") String accept, @BodyParam("appli @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response putSync(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, - RequestOptions requestOptions, Context context); + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); } /** @@ -118,7 +120,7 @@ Response putSync(@HeaderParam("accept") String accept, @BodyParam("applica @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getWithResponseAsync(RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.get(accept, requestOptions, context)); + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); } /** @@ -144,7 +146,7 @@ public Mono> getWithResponseAsync(RequestOptions requestOpt @ServiceMethod(returns = ReturnType.SINGLE) public Response getWithResponse(RequestOptions requestOptions) { final String accept = "application/json"; - return service.getSync(accept, requestOptions, Context.NONE); + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); } /** @@ -170,8 +172,9 @@ public Response getWithResponse(RequestOptions requestOptions) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> putWithResponseAsync(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.put(accept, body, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.put(this.client.getEndpoint(), contentType, body, requestOptions, context)); } /** @@ -197,7 +200,7 @@ public Mono> putWithResponseAsync(BinaryData body, RequestOptions */ @ServiceMethod(returns = ReturnType.SINGLE) public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.putSync(accept, body, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/type/property/additionalproperties/implementation/SpreadRecordNonDiscriminatedUnionsImpl.java b/typespec-tests/src/main/java/com/type/property/additionalproperties/implementation/SpreadRecordNonDiscriminatedUnionsImpl.java index c01713dd82..f438e1fa77 100644 --- a/typespec-tests/src/main/java/com/type/property/additionalproperties/implementation/SpreadRecordNonDiscriminatedUnionsImpl.java +++ b/typespec-tests/src/main/java/com/type/property/additionalproperties/implementation/SpreadRecordNonDiscriminatedUnionsImpl.java @@ -9,6 +9,7 @@ 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; @@ -55,7 +56,7 @@ public final class SpreadRecordNonDiscriminatedUnionsImpl { * The interface defining all the services for AdditionalPropertiesClientSpreadRecordNonDiscriminatedUnions to be * used by the proxy service to perform REST calls. */ - @Host("http://localhost:3000") + @Host("{endpoint}") @ServiceInterface(name = "AdditionalProperties") public interface SpreadRecordNonDiscriminatedUnionsService { @Get("/type/property/additionalProperties/spreadRecordNonDiscriminatedUnion") @@ -64,8 +65,8 @@ public interface SpreadRecordNonDiscriminatedUnionsService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> get(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Get("/type/property/additionalProperties/spreadRecordNonDiscriminatedUnion") @ExpectedResponses({ 200 }) @@ -73,8 +74,8 @@ Mono> get(@HeaderParam("accept") String accept, RequestOpti @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response getSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Put("/type/property/additionalProperties/spreadRecordNonDiscriminatedUnion") @ExpectedResponses({ 204 }) @@ -82,7 +83,8 @@ Response getSync(@HeaderParam("accept") String accept, RequestOption @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> put(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, + 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") @@ -91,8 +93,8 @@ Mono> put(@HeaderParam("accept") String accept, @BodyParam("appli @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response putSync(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, - RequestOptions requestOptions, Context context); + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); } /** @@ -118,7 +120,7 @@ Response putSync(@HeaderParam("accept") String accept, @BodyParam("applica @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getWithResponseAsync(RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.get(accept, requestOptions, context)); + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); } /** @@ -144,7 +146,7 @@ public Mono> getWithResponseAsync(RequestOptions requestOpt @ServiceMethod(returns = ReturnType.SINGLE) public Response getWithResponse(RequestOptions requestOptions) { final String accept = "application/json"; - return service.getSync(accept, requestOptions, Context.NONE); + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); } /** @@ -170,8 +172,9 @@ public Response getWithResponse(RequestOptions requestOptions) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> putWithResponseAsync(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.put(accept, body, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.put(this.client.getEndpoint(), contentType, body, requestOptions, context)); } /** @@ -197,7 +200,7 @@ public Mono> putWithResponseAsync(BinaryData body, RequestOptions */ @ServiceMethod(returns = ReturnType.SINGLE) public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.putSync(accept, body, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/type/property/additionalproperties/implementation/SpreadRecordUnionsImpl.java b/typespec-tests/src/main/java/com/type/property/additionalproperties/implementation/SpreadRecordUnionsImpl.java index 0ec58862d2..381cf3286d 100644 --- a/typespec-tests/src/main/java/com/type/property/additionalproperties/implementation/SpreadRecordUnionsImpl.java +++ b/typespec-tests/src/main/java/com/type/property/additionalproperties/implementation/SpreadRecordUnionsImpl.java @@ -9,6 +9,7 @@ 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; @@ -55,7 +56,7 @@ public final class SpreadRecordUnionsImpl { * The interface defining all the services for AdditionalPropertiesClientSpreadRecordUnions to be used by the proxy * service to perform REST calls. */ - @Host("http://localhost:3000") + @Host("{endpoint}") @ServiceInterface(name = "AdditionalProperties") public interface SpreadRecordUnionsService { @Get("/type/property/additionalProperties/spreadRecordUnion") @@ -64,8 +65,8 @@ public interface SpreadRecordUnionsService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> get(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Get("/type/property/additionalProperties/spreadRecordUnion") @ExpectedResponses({ 200 }) @@ -73,8 +74,8 @@ Mono> get(@HeaderParam("accept") String accept, RequestOpti @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response getSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Put("/type/property/additionalProperties/spreadRecordUnion") @ExpectedResponses({ 204 }) @@ -82,7 +83,8 @@ Response getSync(@HeaderParam("accept") String accept, RequestOption @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> put(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, + 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") @@ -91,8 +93,8 @@ Mono> put(@HeaderParam("accept") String accept, @BodyParam("appli @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response putSync(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, - RequestOptions requestOptions, Context context); + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); } /** @@ -118,7 +120,7 @@ Response putSync(@HeaderParam("accept") String accept, @BodyParam("applica @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getWithResponseAsync(RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.get(accept, requestOptions, context)); + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); } /** @@ -144,7 +146,7 @@ public Mono> getWithResponseAsync(RequestOptions requestOpt @ServiceMethod(returns = ReturnType.SINGLE) public Response getWithResponse(RequestOptions requestOptions) { final String accept = "application/json"; - return service.getSync(accept, requestOptions, Context.NONE); + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); } /** @@ -170,8 +172,9 @@ public Response getWithResponse(RequestOptions requestOptions) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> putWithResponseAsync(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.put(accept, body, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.put(this.client.getEndpoint(), contentType, body, requestOptions, context)); } /** @@ -197,7 +200,7 @@ public Mono> putWithResponseAsync(BinaryData body, RequestOptions */ @ServiceMethod(returns = ReturnType.SINGLE) public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.putSync(accept, body, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/type/property/additionalproperties/implementation/SpreadStringsImpl.java b/typespec-tests/src/main/java/com/type/property/additionalproperties/implementation/SpreadStringsImpl.java index 71c0892436..8c744222c5 100644 --- a/typespec-tests/src/main/java/com/type/property/additionalproperties/implementation/SpreadStringsImpl.java +++ b/typespec-tests/src/main/java/com/type/property/additionalproperties/implementation/SpreadStringsImpl.java @@ -9,6 +9,7 @@ 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; @@ -55,7 +56,7 @@ public final class SpreadStringsImpl { * The interface defining all the services for AdditionalPropertiesClientSpreadStrings to be used by the proxy * service to perform REST calls. */ - @Host("http://localhost:3000") + @Host("{endpoint}") @ServiceInterface(name = "AdditionalProperties") public interface SpreadStringsService { @Get("/type/property/additionalProperties/spreadRecordString") @@ -64,8 +65,8 @@ public interface SpreadStringsService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> get(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Get("/type/property/additionalProperties/spreadRecordString") @ExpectedResponses({ 200 }) @@ -73,8 +74,8 @@ Mono> get(@HeaderParam("accept") String accept, RequestOpti @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response getSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Put("/type/property/additionalProperties/spreadRecordString") @ExpectedResponses({ 204 }) @@ -82,7 +83,8 @@ Response getSync(@HeaderParam("accept") String accept, RequestOption @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> put(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, + 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") @@ -91,8 +93,8 @@ Mono> put(@HeaderParam("accept") String accept, @BodyParam("appli @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response putSync(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, - RequestOptions requestOptions, Context context); + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); } /** @@ -118,7 +120,7 @@ Response putSync(@HeaderParam("accept") String accept, @BodyParam("applica @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getWithResponseAsync(RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.get(accept, requestOptions, context)); + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); } /** @@ -144,7 +146,7 @@ public Mono> getWithResponseAsync(RequestOptions requestOpt @ServiceMethod(returns = ReturnType.SINGLE) public Response getWithResponse(RequestOptions requestOptions) { final String accept = "application/json"; - return service.getSync(accept, requestOptions, Context.NONE); + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); } /** @@ -170,8 +172,9 @@ public Response getWithResponse(RequestOptions requestOptions) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> putWithResponseAsync(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.put(accept, body, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.put(this.client.getEndpoint(), contentType, body, requestOptions, context)); } /** @@ -197,7 +200,7 @@ public Mono> putWithResponseAsync(BinaryData body, RequestOptions */ @ServiceMethod(returns = ReturnType.SINGLE) public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.putSync(accept, body, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/type/property/nullable/NullableClientBuilder.java b/typespec-tests/src/main/java/com/type/property/nullable/NullableClientBuilder.java index 173f2426a6..2fd8684062 100644 --- a/typespec-tests/src/main/java/com/type/property/nullable/NullableClientBuilder.java +++ b/typespec-tests/src/main/java/com/type/property/nullable/NullableClientBuilder.java @@ -7,6 +7,7 @@ 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; @@ -55,8 +56,8 @@ CollectionsByteAsyncClient.class, CollectionsModelAsyncClient.class, CollectionsStringAsyncClient.class }) -public final class NullableClientBuilder - implements HttpTrait, ConfigurationTrait { +public final class NullableClientBuilder implements HttpTrait, + ConfigurationTrait, EndpointTrait { @Generated private static final String SDK_NAME = "name"; @@ -187,6 +188,22 @@ public NullableClientBuilder configuration(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. */ @@ -214,8 +231,9 @@ public NullableClientBuilder retryPolicy(RetryPolicy retryPolicy) { 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()); + = new NullableClientImpl(localPipeline, JacksonAdapter.createDefaultSerializerAdapter(), localEndpoint); return client; } diff --git a/typespec-tests/src/main/java/com/type/property/nullable/implementation/BytesImpl.java b/typespec-tests/src/main/java/com/type/property/nullable/implementation/BytesImpl.java index 3f437a5bda..a84d26ea0f 100644 --- a/typespec-tests/src/main/java/com/type/property/nullable/implementation/BytesImpl.java +++ b/typespec-tests/src/main/java/com/type/property/nullable/implementation/BytesImpl.java @@ -9,6 +9,7 @@ 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; @@ -54,7 +55,7 @@ public final class BytesImpl { * The interface defining all the services for NullableClientBytes to be used by the proxy service to perform REST * calls. */ - @Host("http://localhost:3000") + @Host("{endpoint}") @ServiceInterface(name = "NullableClientBytes") public interface BytesService { @Get("/type/property/nullable/bytes/non-null") @@ -63,8 +64,8 @@ public interface BytesService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> getNonNull(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Mono> getNonNull(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Get("/type/property/nullable/bytes/non-null") @ExpectedResponses({ 200 }) @@ -72,8 +73,8 @@ Mono> getNonNull(@HeaderParam("accept") String accept, Requ @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response getNonNullSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Response getNonNullSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Get("/type/property/nullable/bytes/null") @ExpectedResponses({ 200 }) @@ -81,8 +82,8 @@ Response getNonNullSync(@HeaderParam("accept") String accept, Reques @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> getNull(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Mono> getNull(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Get("/type/property/nullable/bytes/null") @ExpectedResponses({ 200 }) @@ -90,8 +91,8 @@ Mono> getNull(@HeaderParam("accept") String accept, Request @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response getNullSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Response getNullSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Patch("/type/property/nullable/bytes/non-null") @ExpectedResponses({ 204 }) @@ -99,8 +100,8 @@ Response getNullSync(@HeaderParam("accept") String accept, RequestOp @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> patchNonNull(@HeaderParam("Content-Type") String contentType, - @HeaderParam("accept") String accept, @BodyParam("application/merge-patch+json") BinaryData body, + 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") @@ -109,8 +110,8 @@ Mono> patchNonNull(@HeaderParam("Content-Type") String contentTyp @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response patchNonNullSync(@HeaderParam("Content-Type") String contentType, - @HeaderParam("accept") String accept, @BodyParam("application/merge-patch+json") BinaryData body, + 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") @@ -119,8 +120,8 @@ Response patchNonNullSync(@HeaderParam("Content-Type") String contentType, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> patchNull(@HeaderParam("Content-Type") String contentType, - @HeaderParam("accept") String accept, @BodyParam("application/merge-patch+json") BinaryData body, + 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") @@ -129,8 +130,8 @@ Mono> patchNull(@HeaderParam("Content-Type") String contentType, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response patchNullSync(@HeaderParam("Content-Type") String contentType, - @HeaderParam("accept") String accept, @BodyParam("application/merge-patch+json") BinaryData body, + Response patchNullSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/merge-patch+json") BinaryData body, RequestOptions requestOptions, Context context); } @@ -156,7 +157,8 @@ Response patchNullSync(@HeaderParam("Content-Type") String contentType, @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getNonNullWithResponseAsync(RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.getNonNull(accept, requestOptions, context)); + return FluxUtil + .withContext(context -> service.getNonNull(this.client.getEndpoint(), accept, requestOptions, context)); } /** @@ -180,7 +182,7 @@ public Mono> getNonNullWithResponseAsync(RequestOptions req @ServiceMethod(returns = ReturnType.SINGLE) public Response getNonNullWithResponse(RequestOptions requestOptions) { final String accept = "application/json"; - return service.getNonNullSync(accept, requestOptions, Context.NONE); + return service.getNonNullSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); } /** @@ -205,7 +207,8 @@ public Response getNonNullWithResponse(RequestOptions requestOptions @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getNullWithResponseAsync(RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.getNull(accept, requestOptions, context)); + return FluxUtil + .withContext(context -> service.getNull(this.client.getEndpoint(), accept, requestOptions, context)); } /** @@ -229,7 +232,7 @@ public Mono> getNullWithResponseAsync(RequestOptions reques @ServiceMethod(returns = ReturnType.SINGLE) public Response getNullWithResponse(RequestOptions requestOptions) { final String accept = "application/json"; - return service.getNullSync(accept, requestOptions, Context.NONE); + return service.getNullSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); } /** @@ -254,9 +257,8 @@ public Response getNullWithResponse(RequestOptions requestOptions) { @ServiceMethod(returns = ReturnType.SINGLE) public Mono> patchNonNullWithResponseAsync(BinaryData body, RequestOptions requestOptions) { final String contentType = "application/merge-patch+json"; - final String accept = "application/json"; - return FluxUtil - .withContext(context -> service.patchNonNull(contentType, accept, body, requestOptions, context)); + return FluxUtil.withContext( + context -> service.patchNonNull(this.client.getEndpoint(), contentType, body, requestOptions, context)); } /** @@ -281,8 +283,7 @@ public Mono> patchNonNullWithResponseAsync(BinaryData body, Reque @ServiceMethod(returns = ReturnType.SINGLE) public Response patchNonNullWithResponse(BinaryData body, RequestOptions requestOptions) { final String contentType = "application/merge-patch+json"; - final String accept = "application/json"; - return service.patchNonNullSync(contentType, accept, body, requestOptions, Context.NONE); + return service.patchNonNullSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); } /** @@ -307,8 +308,8 @@ public Response patchNonNullWithResponse(BinaryData body, RequestOptions r @ServiceMethod(returns = ReturnType.SINGLE) public Mono> patchNullWithResponseAsync(BinaryData body, RequestOptions requestOptions) { final String contentType = "application/merge-patch+json"; - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.patchNull(contentType, accept, body, requestOptions, context)); + return FluxUtil.withContext( + context -> service.patchNull(this.client.getEndpoint(), contentType, body, requestOptions, context)); } /** @@ -333,7 +334,6 @@ public Mono> patchNullWithResponseAsync(BinaryData body, RequestO @ServiceMethod(returns = ReturnType.SINGLE) public Response patchNullWithResponse(BinaryData body, RequestOptions requestOptions) { final String contentType = "application/merge-patch+json"; - final String accept = "application/json"; - return service.patchNullSync(contentType, accept, body, requestOptions, Context.NONE); + return service.patchNullSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/type/property/nullable/implementation/CollectionsBytesImpl.java b/typespec-tests/src/main/java/com/type/property/nullable/implementation/CollectionsBytesImpl.java index 22e07f33ff..6d1cccfcbd 100644 --- a/typespec-tests/src/main/java/com/type/property/nullable/implementation/CollectionsBytesImpl.java +++ b/typespec-tests/src/main/java/com/type/property/nullable/implementation/CollectionsBytesImpl.java @@ -9,6 +9,7 @@ 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; @@ -55,7 +56,7 @@ public final class CollectionsBytesImpl { * The interface defining all the services for NullableClientCollectionsBytes to be used by the proxy service to * perform REST calls. */ - @Host("http://localhost:3000") + @Host("{endpoint}") @ServiceInterface(name = "NullableClientCollec") public interface CollectionsBytesService { @Get("/type/property/nullable/collections/bytes/non-null") @@ -64,8 +65,8 @@ public interface CollectionsBytesService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> getNonNull(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Mono> getNonNull(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Get("/type/property/nullable/collections/bytes/non-null") @ExpectedResponses({ 200 }) @@ -73,8 +74,8 @@ Mono> getNonNull(@HeaderParam("accept") String accept, Requ @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response getNonNullSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Response getNonNullSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Get("/type/property/nullable/collections/bytes/null") @ExpectedResponses({ 200 }) @@ -82,8 +83,8 @@ Response getNonNullSync(@HeaderParam("accept") String accept, Reques @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> getNull(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Mono> getNull(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Get("/type/property/nullable/collections/bytes/null") @ExpectedResponses({ 200 }) @@ -91,8 +92,8 @@ Mono> getNull(@HeaderParam("accept") String accept, Request @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response getNullSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Response getNullSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Patch("/type/property/nullable/collections/bytes/non-null") @ExpectedResponses({ 204 }) @@ -100,8 +101,8 @@ Response getNullSync(@HeaderParam("accept") String accept, RequestOp @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> patchNonNull(@HeaderParam("Content-Type") String contentType, - @HeaderParam("accept") String accept, @BodyParam("application/merge-patch+json") BinaryData body, + 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") @@ -110,8 +111,8 @@ Mono> patchNonNull(@HeaderParam("Content-Type") String contentTyp @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response patchNonNullSync(@HeaderParam("Content-Type") String contentType, - @HeaderParam("accept") String accept, @BodyParam("application/merge-patch+json") BinaryData body, + 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") @@ -120,8 +121,8 @@ Response patchNonNullSync(@HeaderParam("Content-Type") String contentType, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> patchNull(@HeaderParam("Content-Type") String contentType, - @HeaderParam("accept") String accept, @BodyParam("application/merge-patch+json") BinaryData body, + 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") @@ -130,8 +131,8 @@ Mono> patchNull(@HeaderParam("Content-Type") String contentType, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response patchNullSync(@HeaderParam("Content-Type") String contentType, - @HeaderParam("accept") String accept, @BodyParam("application/merge-patch+json") BinaryData body, + Response patchNullSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/merge-patch+json") BinaryData body, RequestOptions requestOptions, Context context); } @@ -159,7 +160,8 @@ Response patchNullSync(@HeaderParam("Content-Type") String contentType, @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getNonNullWithResponseAsync(RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.getNonNull(accept, requestOptions, context)); + return FluxUtil + .withContext(context -> service.getNonNull(this.client.getEndpoint(), accept, requestOptions, context)); } /** @@ -185,7 +187,7 @@ public Mono> getNonNullWithResponseAsync(RequestOptions req @ServiceMethod(returns = ReturnType.SINGLE) public Response getNonNullWithResponse(RequestOptions requestOptions) { final String accept = "application/json"; - return service.getNonNullSync(accept, requestOptions, Context.NONE); + return service.getNonNullSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); } /** @@ -212,7 +214,8 @@ public Response getNonNullWithResponse(RequestOptions requestOptions @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getNullWithResponseAsync(RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.getNull(accept, requestOptions, context)); + return FluxUtil + .withContext(context -> service.getNull(this.client.getEndpoint(), accept, requestOptions, context)); } /** @@ -238,7 +241,7 @@ public Mono> getNullWithResponseAsync(RequestOptions reques @ServiceMethod(returns = ReturnType.SINGLE) public Response getNullWithResponse(RequestOptions requestOptions) { final String accept = "application/json"; - return service.getNullSync(accept, requestOptions, Context.NONE); + return service.getNullSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); } /** @@ -265,9 +268,8 @@ public Response getNullWithResponse(RequestOptions requestOptions) { @ServiceMethod(returns = ReturnType.SINGLE) public Mono> patchNonNullWithResponseAsync(BinaryData body, RequestOptions requestOptions) { final String contentType = "application/merge-patch+json"; - final String accept = "application/json"; - return FluxUtil - .withContext(context -> service.patchNonNull(contentType, accept, body, requestOptions, context)); + return FluxUtil.withContext( + context -> service.patchNonNull(this.client.getEndpoint(), contentType, body, requestOptions, context)); } /** @@ -294,8 +296,7 @@ public Mono> patchNonNullWithResponseAsync(BinaryData body, Reque @ServiceMethod(returns = ReturnType.SINGLE) public Response patchNonNullWithResponse(BinaryData body, RequestOptions requestOptions) { final String contentType = "application/merge-patch+json"; - final String accept = "application/json"; - return service.patchNonNullSync(contentType, accept, body, requestOptions, Context.NONE); + return service.patchNonNullSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); } /** @@ -322,8 +323,8 @@ public Response patchNonNullWithResponse(BinaryData body, RequestOptions r @ServiceMethod(returns = ReturnType.SINGLE) public Mono> patchNullWithResponseAsync(BinaryData body, RequestOptions requestOptions) { final String contentType = "application/merge-patch+json"; - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.patchNull(contentType, accept, body, requestOptions, context)); + return FluxUtil.withContext( + context -> service.patchNull(this.client.getEndpoint(), contentType, body, requestOptions, context)); } /** @@ -350,7 +351,6 @@ public Mono> patchNullWithResponseAsync(BinaryData body, RequestO @ServiceMethod(returns = ReturnType.SINGLE) public Response patchNullWithResponse(BinaryData body, RequestOptions requestOptions) { final String contentType = "application/merge-patch+json"; - final String accept = "application/json"; - return service.patchNullSync(contentType, accept, body, requestOptions, Context.NONE); + return service.patchNullSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/type/property/nullable/implementation/CollectionsModelsImpl.java b/typespec-tests/src/main/java/com/type/property/nullable/implementation/CollectionsModelsImpl.java index 1e72392d36..c1d453e103 100644 --- a/typespec-tests/src/main/java/com/type/property/nullable/implementation/CollectionsModelsImpl.java +++ b/typespec-tests/src/main/java/com/type/property/nullable/implementation/CollectionsModelsImpl.java @@ -9,6 +9,7 @@ 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; @@ -55,7 +56,7 @@ public final class CollectionsModelsImpl { * The interface defining all the services for NullableClientCollectionsModels to be used by the proxy service to * perform REST calls. */ - @Host("http://localhost:3000") + @Host("{endpoint}") @ServiceInterface(name = "NullableClientCollec") public interface CollectionsModelsService { @Get("/type/property/nullable/collections/model/non-null") @@ -64,8 +65,8 @@ public interface CollectionsModelsService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> getNonNull(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Mono> getNonNull(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Get("/type/property/nullable/collections/model/non-null") @ExpectedResponses({ 200 }) @@ -73,8 +74,8 @@ Mono> getNonNull(@HeaderParam("accept") String accept, Requ @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response getNonNullSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Response getNonNullSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Get("/type/property/nullable/collections/model/null") @ExpectedResponses({ 200 }) @@ -82,8 +83,8 @@ Response getNonNullSync(@HeaderParam("accept") String accept, Reques @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> getNull(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Mono> getNull(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Get("/type/property/nullable/collections/model/null") @ExpectedResponses({ 200 }) @@ -91,8 +92,8 @@ Mono> getNull(@HeaderParam("accept") String accept, Request @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response getNullSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Response getNullSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Patch("/type/property/nullable/collections/model/non-null") @ExpectedResponses({ 204 }) @@ -100,8 +101,8 @@ Response getNullSync(@HeaderParam("accept") String accept, RequestOp @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> patchNonNull(@HeaderParam("Content-Type") String contentType, - @HeaderParam("accept") String accept, @BodyParam("application/merge-patch+json") BinaryData body, + 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") @@ -110,8 +111,8 @@ Mono> patchNonNull(@HeaderParam("Content-Type") String contentTyp @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response patchNonNullSync(@HeaderParam("Content-Type") String contentType, - @HeaderParam("accept") String accept, @BodyParam("application/merge-patch+json") BinaryData body, + 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") @@ -120,8 +121,8 @@ Response patchNonNullSync(@HeaderParam("Content-Type") String contentType, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> patchNull(@HeaderParam("Content-Type") String contentType, - @HeaderParam("accept") String accept, @BodyParam("application/merge-patch+json") BinaryData body, + 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") @@ -130,8 +131,8 @@ Mono> patchNull(@HeaderParam("Content-Type") String contentType, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response patchNullSync(@HeaderParam("Content-Type") String contentType, - @HeaderParam("accept") String accept, @BodyParam("application/merge-patch+json") BinaryData body, + Response patchNullSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/merge-patch+json") BinaryData body, RequestOptions requestOptions, Context context); } @@ -161,7 +162,8 @@ Response patchNullSync(@HeaderParam("Content-Type") String contentType, @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getNonNullWithResponseAsync(RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.getNonNull(accept, requestOptions, context)); + return FluxUtil + .withContext(context -> service.getNonNull(this.client.getEndpoint(), accept, requestOptions, context)); } /** @@ -189,7 +191,7 @@ public Mono> getNonNullWithResponseAsync(RequestOptions req @ServiceMethod(returns = ReturnType.SINGLE) public Response getNonNullWithResponse(RequestOptions requestOptions) { final String accept = "application/json"; - return service.getNonNullSync(accept, requestOptions, Context.NONE); + return service.getNonNullSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); } /** @@ -218,7 +220,8 @@ public Response getNonNullWithResponse(RequestOptions requestOptions @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getNullWithResponseAsync(RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.getNull(accept, requestOptions, context)); + return FluxUtil + .withContext(context -> service.getNull(this.client.getEndpoint(), accept, requestOptions, context)); } /** @@ -246,7 +249,7 @@ public Mono> getNullWithResponseAsync(RequestOptions reques @ServiceMethod(returns = ReturnType.SINGLE) public Response getNullWithResponse(RequestOptions requestOptions) { final String accept = "application/json"; - return service.getNullSync(accept, requestOptions, Context.NONE); + return service.getNullSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); } /** @@ -275,9 +278,8 @@ public Response getNullWithResponse(RequestOptions requestOptions) { @ServiceMethod(returns = ReturnType.SINGLE) public Mono> patchNonNullWithResponseAsync(BinaryData body, RequestOptions requestOptions) { final String contentType = "application/merge-patch+json"; - final String accept = "application/json"; - return FluxUtil - .withContext(context -> service.patchNonNull(contentType, accept, body, requestOptions, context)); + return FluxUtil.withContext( + context -> service.patchNonNull(this.client.getEndpoint(), contentType, body, requestOptions, context)); } /** @@ -306,8 +308,7 @@ public Mono> patchNonNullWithResponseAsync(BinaryData body, Reque @ServiceMethod(returns = ReturnType.SINGLE) public Response patchNonNullWithResponse(BinaryData body, RequestOptions requestOptions) { final String contentType = "application/merge-patch+json"; - final String accept = "application/json"; - return service.patchNonNullSync(contentType, accept, body, requestOptions, Context.NONE); + return service.patchNonNullSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); } /** @@ -336,8 +337,8 @@ public Response patchNonNullWithResponse(BinaryData body, RequestOptions r @ServiceMethod(returns = ReturnType.SINGLE) public Mono> patchNullWithResponseAsync(BinaryData body, RequestOptions requestOptions) { final String contentType = "application/merge-patch+json"; - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.patchNull(contentType, accept, body, requestOptions, context)); + return FluxUtil.withContext( + context -> service.patchNull(this.client.getEndpoint(), contentType, body, requestOptions, context)); } /** @@ -366,7 +367,6 @@ public Mono> patchNullWithResponseAsync(BinaryData body, RequestO @ServiceMethod(returns = ReturnType.SINGLE) public Response patchNullWithResponse(BinaryData body, RequestOptions requestOptions) { final String contentType = "application/merge-patch+json"; - final String accept = "application/json"; - return service.patchNullSync(contentType, accept, body, requestOptions, Context.NONE); + return service.patchNullSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/type/property/nullable/implementation/CollectionsStringsImpl.java b/typespec-tests/src/main/java/com/type/property/nullable/implementation/CollectionsStringsImpl.java index ed96a21925..d6cd65ef09 100644 --- a/typespec-tests/src/main/java/com/type/property/nullable/implementation/CollectionsStringsImpl.java +++ b/typespec-tests/src/main/java/com/type/property/nullable/implementation/CollectionsStringsImpl.java @@ -9,6 +9,7 @@ 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; @@ -55,7 +56,7 @@ public final class CollectionsStringsImpl { * The interface defining all the services for NullableClientCollectionsStrings to be used by the proxy service to * perform REST calls. */ - @Host("http://localhost:3000") + @Host("{endpoint}") @ServiceInterface(name = "NullableClientCollec") public interface CollectionsStringsService { @Get("/type/property/nullable/collections/string/non-null") @@ -64,8 +65,8 @@ public interface CollectionsStringsService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> getNonNull(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Mono> getNonNull(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Get("/type/property/nullable/collections/string/non-null") @ExpectedResponses({ 200 }) @@ -73,8 +74,8 @@ Mono> getNonNull(@HeaderParam("accept") String accept, Requ @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response getNonNullSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Response getNonNullSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Get("/type/property/nullable/collections/string/null") @ExpectedResponses({ 200 }) @@ -82,8 +83,8 @@ Response getNonNullSync(@HeaderParam("accept") String accept, Reques @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> getNull(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Mono> getNull(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Get("/type/property/nullable/collections/string/null") @ExpectedResponses({ 200 }) @@ -91,8 +92,8 @@ Mono> getNull(@HeaderParam("accept") String accept, Request @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response getNullSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Response getNullSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Patch("/type/property/nullable/collections/string/non-null") @ExpectedResponses({ 204 }) @@ -100,8 +101,8 @@ Response getNullSync(@HeaderParam("accept") String accept, RequestOp @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> patchNonNull(@HeaderParam("Content-Type") String contentType, - @HeaderParam("accept") String accept, @BodyParam("application/merge-patch+json") BinaryData body, + 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") @@ -110,8 +111,8 @@ Mono> patchNonNull(@HeaderParam("Content-Type") String contentTyp @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response patchNonNullSync(@HeaderParam("Content-Type") String contentType, - @HeaderParam("accept") String accept, @BodyParam("application/merge-patch+json") BinaryData body, + 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") @@ -120,8 +121,8 @@ Response patchNonNullSync(@HeaderParam("Content-Type") String contentType, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> patchNull(@HeaderParam("Content-Type") String contentType, - @HeaderParam("accept") String accept, @BodyParam("application/merge-patch+json") BinaryData body, + 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") @@ -130,8 +131,8 @@ Mono> patchNull(@HeaderParam("Content-Type") String contentType, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response patchNullSync(@HeaderParam("Content-Type") String contentType, - @HeaderParam("accept") String accept, @BodyParam("application/merge-patch+json") BinaryData body, + Response patchNullSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/merge-patch+json") BinaryData body, RequestOptions requestOptions, Context context); } @@ -159,7 +160,8 @@ Response patchNullSync(@HeaderParam("Content-Type") String contentType, @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getNonNullWithResponseAsync(RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.getNonNull(accept, requestOptions, context)); + return FluxUtil + .withContext(context -> service.getNonNull(this.client.getEndpoint(), accept, requestOptions, context)); } /** @@ -185,7 +187,7 @@ public Mono> getNonNullWithResponseAsync(RequestOptions req @ServiceMethod(returns = ReturnType.SINGLE) public Response getNonNullWithResponse(RequestOptions requestOptions) { final String accept = "application/json"; - return service.getNonNullSync(accept, requestOptions, Context.NONE); + return service.getNonNullSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); } /** @@ -212,7 +214,8 @@ public Response getNonNullWithResponse(RequestOptions requestOptions @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getNullWithResponseAsync(RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.getNull(accept, requestOptions, context)); + return FluxUtil + .withContext(context -> service.getNull(this.client.getEndpoint(), accept, requestOptions, context)); } /** @@ -238,7 +241,7 @@ public Mono> getNullWithResponseAsync(RequestOptions reques @ServiceMethod(returns = ReturnType.SINGLE) public Response getNullWithResponse(RequestOptions requestOptions) { final String accept = "application/json"; - return service.getNullSync(accept, requestOptions, Context.NONE); + return service.getNullSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); } /** @@ -265,9 +268,8 @@ public Response getNullWithResponse(RequestOptions requestOptions) { @ServiceMethod(returns = ReturnType.SINGLE) public Mono> patchNonNullWithResponseAsync(BinaryData body, RequestOptions requestOptions) { final String contentType = "application/merge-patch+json"; - final String accept = "application/json"; - return FluxUtil - .withContext(context -> service.patchNonNull(contentType, accept, body, requestOptions, context)); + return FluxUtil.withContext( + context -> service.patchNonNull(this.client.getEndpoint(), contentType, body, requestOptions, context)); } /** @@ -294,8 +296,7 @@ public Mono> patchNonNullWithResponseAsync(BinaryData body, Reque @ServiceMethod(returns = ReturnType.SINGLE) public Response patchNonNullWithResponse(BinaryData body, RequestOptions requestOptions) { final String contentType = "application/merge-patch+json"; - final String accept = "application/json"; - return service.patchNonNullSync(contentType, accept, body, requestOptions, Context.NONE); + return service.patchNonNullSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); } /** @@ -322,8 +323,8 @@ public Response patchNonNullWithResponse(BinaryData body, RequestOptions r @ServiceMethod(returns = ReturnType.SINGLE) public Mono> patchNullWithResponseAsync(BinaryData body, RequestOptions requestOptions) { final String contentType = "application/merge-patch+json"; - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.patchNull(contentType, accept, body, requestOptions, context)); + return FluxUtil.withContext( + context -> service.patchNull(this.client.getEndpoint(), contentType, body, requestOptions, context)); } /** @@ -350,7 +351,6 @@ public Mono> patchNullWithResponseAsync(BinaryData body, RequestO @ServiceMethod(returns = ReturnType.SINGLE) public Response patchNullWithResponse(BinaryData body, RequestOptions requestOptions) { final String contentType = "application/merge-patch+json"; - final String accept = "application/json"; - return service.patchNullSync(contentType, accept, body, requestOptions, Context.NONE); + return service.patchNullSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/type/property/nullable/implementation/DatetimeOperationsImpl.java b/typespec-tests/src/main/java/com/type/property/nullable/implementation/DatetimeOperationsImpl.java index 0b112670da..d4356df4d4 100644 --- a/typespec-tests/src/main/java/com/type/property/nullable/implementation/DatetimeOperationsImpl.java +++ b/typespec-tests/src/main/java/com/type/property/nullable/implementation/DatetimeOperationsImpl.java @@ -9,6 +9,7 @@ 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; @@ -55,7 +56,7 @@ public final class DatetimeOperationsImpl { * The interface defining all the services for NullableClientDatetimeOperations to be used by the proxy service to * perform REST calls. */ - @Host("http://localhost:3000") + @Host("{endpoint}") @ServiceInterface(name = "NullableClientDateti") public interface DatetimeOperationsService { @Get("/type/property/nullable/datetime/non-null") @@ -64,8 +65,8 @@ public interface DatetimeOperationsService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> getNonNull(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Mono> getNonNull(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Get("/type/property/nullable/datetime/non-null") @ExpectedResponses({ 200 }) @@ -73,8 +74,8 @@ Mono> getNonNull(@HeaderParam("accept") String accept, Requ @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response getNonNullSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Response getNonNullSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Get("/type/property/nullable/datetime/null") @ExpectedResponses({ 200 }) @@ -82,8 +83,8 @@ Response getNonNullSync(@HeaderParam("accept") String accept, Reques @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> getNull(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Mono> getNull(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Get("/type/property/nullable/datetime/null") @ExpectedResponses({ 200 }) @@ -91,8 +92,8 @@ Mono> getNull(@HeaderParam("accept") String accept, Request @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response getNullSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Response getNullSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Patch("/type/property/nullable/datetime/non-null") @ExpectedResponses({ 204 }) @@ -100,8 +101,8 @@ Response getNullSync(@HeaderParam("accept") String accept, RequestOp @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> patchNonNull(@HeaderParam("Content-Type") String contentType, - @HeaderParam("accept") String accept, @BodyParam("application/merge-patch+json") BinaryData body, + 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") @@ -110,8 +111,8 @@ Mono> patchNonNull(@HeaderParam("Content-Type") String contentTyp @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response patchNonNullSync(@HeaderParam("Content-Type") String contentType, - @HeaderParam("accept") String accept, @BodyParam("application/merge-patch+json") BinaryData body, + 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") @@ -120,8 +121,8 @@ Response patchNonNullSync(@HeaderParam("Content-Type") String contentType, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> patchNull(@HeaderParam("Content-Type") String contentType, - @HeaderParam("accept") String accept, @BodyParam("application/merge-patch+json") BinaryData body, + 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") @@ -130,8 +131,8 @@ Mono> patchNull(@HeaderParam("Content-Type") String contentType, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response patchNullSync(@HeaderParam("Content-Type") String contentType, - @HeaderParam("accept") String accept, @BodyParam("application/merge-patch+json") BinaryData body, + Response patchNullSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/merge-patch+json") BinaryData body, RequestOptions requestOptions, Context context); } @@ -157,7 +158,8 @@ Response patchNullSync(@HeaderParam("Content-Type") String contentType, @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getNonNullWithResponseAsync(RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.getNonNull(accept, requestOptions, context)); + return FluxUtil + .withContext(context -> service.getNonNull(this.client.getEndpoint(), accept, requestOptions, context)); } /** @@ -181,7 +183,7 @@ public Mono> getNonNullWithResponseAsync(RequestOptions req @ServiceMethod(returns = ReturnType.SINGLE) public Response getNonNullWithResponse(RequestOptions requestOptions) { final String accept = "application/json"; - return service.getNonNullSync(accept, requestOptions, Context.NONE); + return service.getNonNullSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); } /** @@ -206,7 +208,8 @@ public Response getNonNullWithResponse(RequestOptions requestOptions @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getNullWithResponseAsync(RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.getNull(accept, requestOptions, context)); + return FluxUtil + .withContext(context -> service.getNull(this.client.getEndpoint(), accept, requestOptions, context)); } /** @@ -230,7 +233,7 @@ public Mono> getNullWithResponseAsync(RequestOptions reques @ServiceMethod(returns = ReturnType.SINGLE) public Response getNullWithResponse(RequestOptions requestOptions) { final String accept = "application/json"; - return service.getNullSync(accept, requestOptions, Context.NONE); + return service.getNullSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); } /** @@ -255,9 +258,8 @@ public Response getNullWithResponse(RequestOptions requestOptions) { @ServiceMethod(returns = ReturnType.SINGLE) public Mono> patchNonNullWithResponseAsync(BinaryData body, RequestOptions requestOptions) { final String contentType = "application/merge-patch+json"; - final String accept = "application/json"; - return FluxUtil - .withContext(context -> service.patchNonNull(contentType, accept, body, requestOptions, context)); + return FluxUtil.withContext( + context -> service.patchNonNull(this.client.getEndpoint(), contentType, body, requestOptions, context)); } /** @@ -282,8 +284,7 @@ public Mono> patchNonNullWithResponseAsync(BinaryData body, Reque @ServiceMethod(returns = ReturnType.SINGLE) public Response patchNonNullWithResponse(BinaryData body, RequestOptions requestOptions) { final String contentType = "application/merge-patch+json"; - final String accept = "application/json"; - return service.patchNonNullSync(contentType, accept, body, requestOptions, Context.NONE); + return service.patchNonNullSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); } /** @@ -308,8 +309,8 @@ public Response patchNonNullWithResponse(BinaryData body, RequestOptions r @ServiceMethod(returns = ReturnType.SINGLE) public Mono> patchNullWithResponseAsync(BinaryData body, RequestOptions requestOptions) { final String contentType = "application/merge-patch+json"; - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.patchNull(contentType, accept, body, requestOptions, context)); + return FluxUtil.withContext( + context -> service.patchNull(this.client.getEndpoint(), contentType, body, requestOptions, context)); } /** @@ -334,7 +335,6 @@ public Mono> patchNullWithResponseAsync(BinaryData body, RequestO @ServiceMethod(returns = ReturnType.SINGLE) public Response patchNullWithResponse(BinaryData body, RequestOptions requestOptions) { final String contentType = "application/merge-patch+json"; - final String accept = "application/json"; - return service.patchNullSync(contentType, accept, body, requestOptions, Context.NONE); + return service.patchNullSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/type/property/nullable/implementation/DurationOperationsImpl.java b/typespec-tests/src/main/java/com/type/property/nullable/implementation/DurationOperationsImpl.java index 7c427c03ea..c4f14ababb 100644 --- a/typespec-tests/src/main/java/com/type/property/nullable/implementation/DurationOperationsImpl.java +++ b/typespec-tests/src/main/java/com/type/property/nullable/implementation/DurationOperationsImpl.java @@ -9,6 +9,7 @@ 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; @@ -55,7 +56,7 @@ public final class DurationOperationsImpl { * The interface defining all the services for NullableClientDurationOperations to be used by the proxy service to * perform REST calls. */ - @Host("http://localhost:3000") + @Host("{endpoint}") @ServiceInterface(name = "NullableClientDurati") public interface DurationOperationsService { @Get("/type/property/nullable/duration/non-null") @@ -64,8 +65,8 @@ public interface DurationOperationsService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> getNonNull(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Mono> getNonNull(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Get("/type/property/nullable/duration/non-null") @ExpectedResponses({ 200 }) @@ -73,8 +74,8 @@ Mono> getNonNull(@HeaderParam("accept") String accept, Requ @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response getNonNullSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Response getNonNullSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Get("/type/property/nullable/duration/null") @ExpectedResponses({ 200 }) @@ -82,8 +83,8 @@ Response getNonNullSync(@HeaderParam("accept") String accept, Reques @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> getNull(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Mono> getNull(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Get("/type/property/nullable/duration/null") @ExpectedResponses({ 200 }) @@ -91,8 +92,8 @@ Mono> getNull(@HeaderParam("accept") String accept, Request @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response getNullSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Response getNullSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Patch("/type/property/nullable/duration/non-null") @ExpectedResponses({ 204 }) @@ -100,8 +101,8 @@ Response getNullSync(@HeaderParam("accept") String accept, RequestOp @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> patchNonNull(@HeaderParam("Content-Type") String contentType, - @HeaderParam("accept") String accept, @BodyParam("application/merge-patch+json") BinaryData body, + 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") @@ -110,8 +111,8 @@ Mono> patchNonNull(@HeaderParam("Content-Type") String contentTyp @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response patchNonNullSync(@HeaderParam("Content-Type") String contentType, - @HeaderParam("accept") String accept, @BodyParam("application/merge-patch+json") BinaryData body, + 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") @@ -120,8 +121,8 @@ Response patchNonNullSync(@HeaderParam("Content-Type") String contentType, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> patchNull(@HeaderParam("Content-Type") String contentType, - @HeaderParam("accept") String accept, @BodyParam("application/merge-patch+json") BinaryData body, + 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") @@ -130,8 +131,8 @@ Mono> patchNull(@HeaderParam("Content-Type") String contentType, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response patchNullSync(@HeaderParam("Content-Type") String contentType, - @HeaderParam("accept") String accept, @BodyParam("application/merge-patch+json") BinaryData body, + Response patchNullSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/merge-patch+json") BinaryData body, RequestOptions requestOptions, Context context); } @@ -157,7 +158,8 @@ Response patchNullSync(@HeaderParam("Content-Type") String contentType, @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getNonNullWithResponseAsync(RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.getNonNull(accept, requestOptions, context)); + return FluxUtil + .withContext(context -> service.getNonNull(this.client.getEndpoint(), accept, requestOptions, context)); } /** @@ -181,7 +183,7 @@ public Mono> getNonNullWithResponseAsync(RequestOptions req @ServiceMethod(returns = ReturnType.SINGLE) public Response getNonNullWithResponse(RequestOptions requestOptions) { final String accept = "application/json"; - return service.getNonNullSync(accept, requestOptions, Context.NONE); + return service.getNonNullSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); } /** @@ -206,7 +208,8 @@ public Response getNonNullWithResponse(RequestOptions requestOptions @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getNullWithResponseAsync(RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.getNull(accept, requestOptions, context)); + return FluxUtil + .withContext(context -> service.getNull(this.client.getEndpoint(), accept, requestOptions, context)); } /** @@ -230,7 +233,7 @@ public Mono> getNullWithResponseAsync(RequestOptions reques @ServiceMethod(returns = ReturnType.SINGLE) public Response getNullWithResponse(RequestOptions requestOptions) { final String accept = "application/json"; - return service.getNullSync(accept, requestOptions, Context.NONE); + return service.getNullSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); } /** @@ -255,9 +258,8 @@ public Response getNullWithResponse(RequestOptions requestOptions) { @ServiceMethod(returns = ReturnType.SINGLE) public Mono> patchNonNullWithResponseAsync(BinaryData body, RequestOptions requestOptions) { final String contentType = "application/merge-patch+json"; - final String accept = "application/json"; - return FluxUtil - .withContext(context -> service.patchNonNull(contentType, accept, body, requestOptions, context)); + return FluxUtil.withContext( + context -> service.patchNonNull(this.client.getEndpoint(), contentType, body, requestOptions, context)); } /** @@ -282,8 +284,7 @@ public Mono> patchNonNullWithResponseAsync(BinaryData body, Reque @ServiceMethod(returns = ReturnType.SINGLE) public Response patchNonNullWithResponse(BinaryData body, RequestOptions requestOptions) { final String contentType = "application/merge-patch+json"; - final String accept = "application/json"; - return service.patchNonNullSync(contentType, accept, body, requestOptions, Context.NONE); + return service.patchNonNullSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); } /** @@ -308,8 +309,8 @@ public Response patchNonNullWithResponse(BinaryData body, RequestOptions r @ServiceMethod(returns = ReturnType.SINGLE) public Mono> patchNullWithResponseAsync(BinaryData body, RequestOptions requestOptions) { final String contentType = "application/merge-patch+json"; - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.patchNull(contentType, accept, body, requestOptions, context)); + return FluxUtil.withContext( + context -> service.patchNull(this.client.getEndpoint(), contentType, body, requestOptions, context)); } /** @@ -334,7 +335,6 @@ public Mono> patchNullWithResponseAsync(BinaryData body, RequestO @ServiceMethod(returns = ReturnType.SINGLE) public Response patchNullWithResponse(BinaryData body, RequestOptions requestOptions) { final String contentType = "application/merge-patch+json"; - final String accept = "application/json"; - return service.patchNullSync(contentType, accept, body, requestOptions, Context.NONE); + return service.patchNullSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/type/property/nullable/implementation/NullableClientImpl.java b/typespec-tests/src/main/java/com/type/property/nullable/implementation/NullableClientImpl.java index 004abade6a..25e685719d 100644 --- a/typespec-tests/src/main/java/com/type/property/nullable/implementation/NullableClientImpl.java +++ b/typespec-tests/src/main/java/com/type/property/nullable/implementation/NullableClientImpl.java @@ -15,6 +15,20 @@ * 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. */ @@ -143,19 +157,22 @@ public CollectionsStringsImpl getCollectionsStrings() { /** * Initializes an instance of NullableClient client. + * + * @param endpoint Service host. */ - public NullableClientImpl() { + public NullableClientImpl(String endpoint) { this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), - JacksonAdapter.createDefaultSerializerAdapter()); + 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) { - this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter()); + public NullableClientImpl(HttpPipeline httpPipeline, String endpoint) { + this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint); } /** @@ -163,10 +180,12 @@ public NullableClientImpl(HttpPipeline httpPipeline) { * * @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) { + 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); diff --git a/typespec-tests/src/main/java/com/type/property/nullable/implementation/StringOperationsImpl.java b/typespec-tests/src/main/java/com/type/property/nullable/implementation/StringOperationsImpl.java index 34b813d183..c4b61dcb84 100644 --- a/typespec-tests/src/main/java/com/type/property/nullable/implementation/StringOperationsImpl.java +++ b/typespec-tests/src/main/java/com/type/property/nullable/implementation/StringOperationsImpl.java @@ -9,6 +9,7 @@ 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; @@ -55,7 +56,7 @@ public final class StringOperationsImpl { * The interface defining all the services for NullableClientStringOperations to be used by the proxy service to * perform REST calls. */ - @Host("http://localhost:3000") + @Host("{endpoint}") @ServiceInterface(name = "NullableClientString") public interface StringOperationsService { @Get("/type/property/nullable/string/non-null") @@ -64,8 +65,8 @@ public interface StringOperationsService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> getNonNull(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Mono> getNonNull(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Get("/type/property/nullable/string/non-null") @ExpectedResponses({ 200 }) @@ -73,8 +74,8 @@ Mono> getNonNull(@HeaderParam("accept") String accept, Requ @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response getNonNullSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Response getNonNullSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Get("/type/property/nullable/string/null") @ExpectedResponses({ 200 }) @@ -82,8 +83,8 @@ Response getNonNullSync(@HeaderParam("accept") String accept, Reques @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> getNull(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Mono> getNull(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Get("/type/property/nullable/string/null") @ExpectedResponses({ 200 }) @@ -91,8 +92,8 @@ Mono> getNull(@HeaderParam("accept") String accept, Request @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response getNullSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Response getNullSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Patch("/type/property/nullable/string/non-null") @ExpectedResponses({ 204 }) @@ -100,8 +101,8 @@ Response getNullSync(@HeaderParam("accept") String accept, RequestOp @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> patchNonNull(@HeaderParam("Content-Type") String contentType, - @HeaderParam("accept") String accept, @BodyParam("application/merge-patch+json") BinaryData body, + 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") @@ -110,8 +111,8 @@ Mono> patchNonNull(@HeaderParam("Content-Type") String contentTyp @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response patchNonNullSync(@HeaderParam("Content-Type") String contentType, - @HeaderParam("accept") String accept, @BodyParam("application/merge-patch+json") BinaryData body, + 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") @@ -120,8 +121,8 @@ Response patchNonNullSync(@HeaderParam("Content-Type") String contentType, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> patchNull(@HeaderParam("Content-Type") String contentType, - @HeaderParam("accept") String accept, @BodyParam("application/merge-patch+json") BinaryData body, + 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") @@ -130,8 +131,8 @@ Mono> patchNull(@HeaderParam("Content-Type") String contentType, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response patchNullSync(@HeaderParam("Content-Type") String contentType, - @HeaderParam("accept") String accept, @BodyParam("application/merge-patch+json") BinaryData body, + Response patchNullSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/merge-patch+json") BinaryData body, RequestOptions requestOptions, Context context); } @@ -157,7 +158,8 @@ Response patchNullSync(@HeaderParam("Content-Type") String contentType, @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getNonNullWithResponseAsync(RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.getNonNull(accept, requestOptions, context)); + return FluxUtil + .withContext(context -> service.getNonNull(this.client.getEndpoint(), accept, requestOptions, context)); } /** @@ -181,7 +183,7 @@ public Mono> getNonNullWithResponseAsync(RequestOptions req @ServiceMethod(returns = ReturnType.SINGLE) public Response getNonNullWithResponse(RequestOptions requestOptions) { final String accept = "application/json"; - return service.getNonNullSync(accept, requestOptions, Context.NONE); + return service.getNonNullSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); } /** @@ -206,7 +208,8 @@ public Response getNonNullWithResponse(RequestOptions requestOptions @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getNullWithResponseAsync(RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.getNull(accept, requestOptions, context)); + return FluxUtil + .withContext(context -> service.getNull(this.client.getEndpoint(), accept, requestOptions, context)); } /** @@ -230,7 +233,7 @@ public Mono> getNullWithResponseAsync(RequestOptions reques @ServiceMethod(returns = ReturnType.SINGLE) public Response getNullWithResponse(RequestOptions requestOptions) { final String accept = "application/json"; - return service.getNullSync(accept, requestOptions, Context.NONE); + return service.getNullSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); } /** @@ -255,9 +258,8 @@ public Response getNullWithResponse(RequestOptions requestOptions) { @ServiceMethod(returns = ReturnType.SINGLE) public Mono> patchNonNullWithResponseAsync(BinaryData body, RequestOptions requestOptions) { final String contentType = "application/merge-patch+json"; - final String accept = "application/json"; - return FluxUtil - .withContext(context -> service.patchNonNull(contentType, accept, body, requestOptions, context)); + return FluxUtil.withContext( + context -> service.patchNonNull(this.client.getEndpoint(), contentType, body, requestOptions, context)); } /** @@ -282,8 +284,7 @@ public Mono> patchNonNullWithResponseAsync(BinaryData body, Reque @ServiceMethod(returns = ReturnType.SINGLE) public Response patchNonNullWithResponse(BinaryData body, RequestOptions requestOptions) { final String contentType = "application/merge-patch+json"; - final String accept = "application/json"; - return service.patchNonNullSync(contentType, accept, body, requestOptions, Context.NONE); + return service.patchNonNullSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); } /** @@ -308,8 +309,8 @@ public Response patchNonNullWithResponse(BinaryData body, RequestOptions r @ServiceMethod(returns = ReturnType.SINGLE) public Mono> patchNullWithResponseAsync(BinaryData body, RequestOptions requestOptions) { final String contentType = "application/merge-patch+json"; - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.patchNull(contentType, accept, body, requestOptions, context)); + return FluxUtil.withContext( + context -> service.patchNull(this.client.getEndpoint(), contentType, body, requestOptions, context)); } /** @@ -334,7 +335,6 @@ public Mono> patchNullWithResponseAsync(BinaryData body, RequestO @ServiceMethod(returns = ReturnType.SINGLE) public Response patchNullWithResponse(BinaryData body, RequestOptions requestOptions) { final String contentType = "application/merge-patch+json"; - final String accept = "application/json"; - return service.patchNullSync(contentType, accept, body, requestOptions, Context.NONE); + return service.patchNullSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/type/property/optional/OptionalClientBuilder.java b/typespec-tests/src/main/java/com/type/property/optional/OptionalClientBuilder.java index b0ae353909..10051d33c8 100644 --- a/typespec-tests/src/main/java/com/type/property/optional/OptionalClientBuilder.java +++ b/typespec-tests/src/main/java/com/type/property/optional/OptionalClientBuilder.java @@ -7,6 +7,7 @@ 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; @@ -73,8 +74,8 @@ UnionIntLiteralAsyncClient.class, UnionFloatLiteralAsyncClient.class, RequiredAndOptionalAsyncClient.class }) -public final class OptionalClientBuilder - implements HttpTrait, ConfigurationTrait { +public final class OptionalClientBuilder implements HttpTrait, + ConfigurationTrait, EndpointTrait { @Generated private static final String SDK_NAME = "name"; @@ -205,6 +206,22 @@ public OptionalClientBuilder configuration(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. */ @@ -232,8 +249,9 @@ public OptionalClientBuilder retryPolicy(RetryPolicy retryPolicy) { 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()); + = new OptionalClientImpl(localPipeline, JacksonAdapter.createDefaultSerializerAdapter(), localEndpoint); return client; } diff --git a/typespec-tests/src/main/java/com/type/property/optional/implementation/BooleanLiteralsImpl.java b/typespec-tests/src/main/java/com/type/property/optional/implementation/BooleanLiteralsImpl.java index e72269c7a3..e417d0f075 100644 --- a/typespec-tests/src/main/java/com/type/property/optional/implementation/BooleanLiteralsImpl.java +++ b/typespec-tests/src/main/java/com/type/property/optional/implementation/BooleanLiteralsImpl.java @@ -9,6 +9,7 @@ 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; @@ -55,7 +56,7 @@ public final class BooleanLiteralsImpl { * The interface defining all the services for OptionalClientBooleanLiterals to be used by the proxy service to * perform REST calls. */ - @Host("http://localhost:3000") + @Host("{endpoint}") @ServiceInterface(name = "OptionalClientBoolea") public interface BooleanLiteralsService { @Get("/type/property/optional/boolean/literal/all") @@ -64,8 +65,8 @@ public interface BooleanLiteralsService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> getAll(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Mono> getAll(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Get("/type/property/optional/boolean/literal/all") @ExpectedResponses({ 200 }) @@ -73,8 +74,8 @@ Mono> getAll(@HeaderParam("accept") String accept, RequestO @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response getAllSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Response getAllSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Get("/type/property/optional/boolean/literal/default") @ExpectedResponses({ 200 }) @@ -82,8 +83,8 @@ Response getAllSync(@HeaderParam("accept") String accept, RequestOpt @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> getDefault(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Mono> getDefault(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Get("/type/property/optional/boolean/literal/default") @ExpectedResponses({ 200 }) @@ -91,8 +92,8 @@ Mono> getDefault(@HeaderParam("accept") String accept, Requ @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response getDefaultSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Response getDefaultSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Put("/type/property/optional/boolean/literal/all") @ExpectedResponses({ 204 }) @@ -100,8 +101,9 @@ Response getDefaultSync(@HeaderParam("accept") String accept, Reques @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> putAll(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + 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 }) @@ -109,7 +111,8 @@ Mono> putAll(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response putAllSync(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, + 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") @@ -118,8 +121,9 @@ Response putAllSync(@HeaderParam("accept") String accept, @BodyParam("appl @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> putDefault(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + 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 }) @@ -127,8 +131,9 @@ Mono> putDefault(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response putDefaultSync(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + Response putDefaultSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); } /** @@ -152,7 +157,8 @@ Response putDefaultSync(@HeaderParam("accept") String accept, @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getAllWithResponseAsync(RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.getAll(accept, requestOptions, context)); + return FluxUtil + .withContext(context -> service.getAll(this.client.getEndpoint(), accept, requestOptions, context)); } /** @@ -175,7 +181,7 @@ public Mono> getAllWithResponseAsync(RequestOptions request @ServiceMethod(returns = ReturnType.SINGLE) public Response getAllWithResponse(RequestOptions requestOptions) { final String accept = "application/json"; - return service.getAllSync(accept, requestOptions, Context.NONE); + return service.getAllSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); } /** @@ -199,7 +205,8 @@ public Response getAllWithResponse(RequestOptions requestOptions) { @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getDefaultWithResponseAsync(RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.getDefault(accept, requestOptions, context)); + return FluxUtil + .withContext(context -> service.getDefault(this.client.getEndpoint(), accept, requestOptions, context)); } /** @@ -222,7 +229,7 @@ public Mono> getDefaultWithResponseAsync(RequestOptions req @ServiceMethod(returns = ReturnType.SINGLE) public Response getDefaultWithResponse(RequestOptions requestOptions) { final String accept = "application/json"; - return service.getDefaultSync(accept, requestOptions, Context.NONE); + return service.getDefaultSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); } /** @@ -245,8 +252,9 @@ public Response getDefaultWithResponse(RequestOptions requestOptions */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> putAllWithResponseAsync(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.putAll(accept, body, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.putAll(this.client.getEndpoint(), contentType, body, requestOptions, context)); } /** @@ -269,8 +277,8 @@ public Mono> putAllWithResponseAsync(BinaryData body, RequestOpti */ @ServiceMethod(returns = ReturnType.SINGLE) public Response putAllWithResponse(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.putAllSync(accept, body, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.putAllSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); } /** @@ -293,8 +301,9 @@ public Response putAllWithResponse(BinaryData body, RequestOptions request */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> putDefaultWithResponseAsync(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.putDefault(accept, body, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.putDefault(this.client.getEndpoint(), contentType, body, requestOptions, context)); } /** @@ -317,7 +326,7 @@ public Mono> putDefaultWithResponseAsync(BinaryData body, Request */ @ServiceMethod(returns = ReturnType.SINGLE) public Response putDefaultWithResponse(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.putDefaultSync(accept, body, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.putDefaultSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/type/property/optional/implementation/BytesImpl.java b/typespec-tests/src/main/java/com/type/property/optional/implementation/BytesImpl.java index 7cfd63358e..4aa5b0e291 100644 --- a/typespec-tests/src/main/java/com/type/property/optional/implementation/BytesImpl.java +++ b/typespec-tests/src/main/java/com/type/property/optional/implementation/BytesImpl.java @@ -9,6 +9,7 @@ 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; @@ -54,7 +55,7 @@ public final class BytesImpl { * The interface defining all the services for OptionalClientBytes to be used by the proxy service to perform REST * calls. */ - @Host("http://localhost:3000") + @Host("{endpoint}") @ServiceInterface(name = "OptionalClientBytes") public interface BytesService { @Get("/type/property/optional/bytes/all") @@ -63,8 +64,8 @@ public interface BytesService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> getAll(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Mono> getAll(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Get("/type/property/optional/bytes/all") @ExpectedResponses({ 200 }) @@ -72,8 +73,8 @@ Mono> getAll(@HeaderParam("accept") String accept, RequestO @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response getAllSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Response getAllSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Get("/type/property/optional/bytes/default") @ExpectedResponses({ 200 }) @@ -81,8 +82,8 @@ Response getAllSync(@HeaderParam("accept") String accept, RequestOpt @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> getDefault(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Mono> getDefault(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Get("/type/property/optional/bytes/default") @ExpectedResponses({ 200 }) @@ -90,8 +91,8 @@ Mono> getDefault(@HeaderParam("accept") String accept, Requ @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response getDefaultSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Response getDefaultSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Put("/type/property/optional/bytes/all") @ExpectedResponses({ 204 }) @@ -99,8 +100,9 @@ Response getDefaultSync(@HeaderParam("accept") String accept, Reques @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> putAll(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + 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 }) @@ -108,7 +110,8 @@ Mono> putAll(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response putAllSync(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, + 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") @@ -117,8 +120,9 @@ Response putAllSync(@HeaderParam("accept") String accept, @BodyParam("appl @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> putDefault(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + 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 }) @@ -126,8 +130,9 @@ Mono> putDefault(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response putDefaultSync(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + Response putDefaultSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); } /** @@ -151,7 +156,8 @@ Response putDefaultSync(@HeaderParam("accept") String accept, @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getAllWithResponseAsync(RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.getAll(accept, requestOptions, context)); + return FluxUtil + .withContext(context -> service.getAll(this.client.getEndpoint(), accept, requestOptions, context)); } /** @@ -174,7 +180,7 @@ public Mono> getAllWithResponseAsync(RequestOptions request @ServiceMethod(returns = ReturnType.SINGLE) public Response getAllWithResponse(RequestOptions requestOptions) { final String accept = "application/json"; - return service.getAllSync(accept, requestOptions, Context.NONE); + return service.getAllSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); } /** @@ -198,7 +204,8 @@ public Response getAllWithResponse(RequestOptions requestOptions) { @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getDefaultWithResponseAsync(RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.getDefault(accept, requestOptions, context)); + return FluxUtil + .withContext(context -> service.getDefault(this.client.getEndpoint(), accept, requestOptions, context)); } /** @@ -221,7 +228,7 @@ public Mono> getDefaultWithResponseAsync(RequestOptions req @ServiceMethod(returns = ReturnType.SINGLE) public Response getDefaultWithResponse(RequestOptions requestOptions) { final String accept = "application/json"; - return service.getDefaultSync(accept, requestOptions, Context.NONE); + return service.getDefaultSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); } /** @@ -244,8 +251,9 @@ public Response getDefaultWithResponse(RequestOptions requestOptions */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> putAllWithResponseAsync(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.putAll(accept, body, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.putAll(this.client.getEndpoint(), contentType, body, requestOptions, context)); } /** @@ -268,8 +276,8 @@ public Mono> putAllWithResponseAsync(BinaryData body, RequestOpti */ @ServiceMethod(returns = ReturnType.SINGLE) public Response putAllWithResponse(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.putAllSync(accept, body, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.putAllSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); } /** @@ -292,8 +300,9 @@ public Response putAllWithResponse(BinaryData body, RequestOptions request */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> putDefaultWithResponseAsync(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.putDefault(accept, body, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.putDefault(this.client.getEndpoint(), contentType, body, requestOptions, context)); } /** @@ -316,7 +325,7 @@ public Mono> putDefaultWithResponseAsync(BinaryData body, Request */ @ServiceMethod(returns = ReturnType.SINGLE) public Response putDefaultWithResponse(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.putDefaultSync(accept, body, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.putDefaultSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/type/property/optional/implementation/CollectionsBytesImpl.java b/typespec-tests/src/main/java/com/type/property/optional/implementation/CollectionsBytesImpl.java index 2e9533b065..bc22af5f7d 100644 --- a/typespec-tests/src/main/java/com/type/property/optional/implementation/CollectionsBytesImpl.java +++ b/typespec-tests/src/main/java/com/type/property/optional/implementation/CollectionsBytesImpl.java @@ -9,6 +9,7 @@ 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; @@ -55,7 +56,7 @@ public final class CollectionsBytesImpl { * The interface defining all the services for OptionalClientCollectionsBytes to be used by the proxy service to * perform REST calls. */ - @Host("http://localhost:3000") + @Host("{endpoint}") @ServiceInterface(name = "OptionalClientCollec") public interface CollectionsBytesService { @Get("/type/property/optional/collections/bytes/all") @@ -64,8 +65,8 @@ public interface CollectionsBytesService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> getAll(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Mono> getAll(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Get("/type/property/optional/collections/bytes/all") @ExpectedResponses({ 200 }) @@ -73,8 +74,8 @@ Mono> getAll(@HeaderParam("accept") String accept, RequestO @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response getAllSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Response getAllSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Get("/type/property/optional/collections/bytes/default") @ExpectedResponses({ 200 }) @@ -82,8 +83,8 @@ Response getAllSync(@HeaderParam("accept") String accept, RequestOpt @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> getDefault(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Mono> getDefault(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Get("/type/property/optional/collections/bytes/default") @ExpectedResponses({ 200 }) @@ -91,8 +92,8 @@ Mono> getDefault(@HeaderParam("accept") String accept, Requ @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response getDefaultSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Response getDefaultSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Put("/type/property/optional/collections/bytes/all") @ExpectedResponses({ 204 }) @@ -100,8 +101,9 @@ Response getDefaultSync(@HeaderParam("accept") String accept, Reques @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> putAll(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + 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 }) @@ -109,7 +111,8 @@ Mono> putAll(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response putAllSync(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, + 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") @@ -118,8 +121,9 @@ Response putAllSync(@HeaderParam("accept") String accept, @BodyParam("appl @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> putDefault(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + 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 }) @@ -127,8 +131,9 @@ Mono> putDefault(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response putDefaultSync(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + Response putDefaultSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); } /** @@ -154,7 +159,8 @@ Response putDefaultSync(@HeaderParam("accept") String accept, @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getAllWithResponseAsync(RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.getAll(accept, requestOptions, context)); + return FluxUtil + .withContext(context -> service.getAll(this.client.getEndpoint(), accept, requestOptions, context)); } /** @@ -179,7 +185,7 @@ public Mono> getAllWithResponseAsync(RequestOptions request @ServiceMethod(returns = ReturnType.SINGLE) public Response getAllWithResponse(RequestOptions requestOptions) { final String accept = "application/json"; - return service.getAllSync(accept, requestOptions, Context.NONE); + return service.getAllSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); } /** @@ -205,7 +211,8 @@ public Response getAllWithResponse(RequestOptions requestOptions) { @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getDefaultWithResponseAsync(RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.getDefault(accept, requestOptions, context)); + return FluxUtil + .withContext(context -> service.getDefault(this.client.getEndpoint(), accept, requestOptions, context)); } /** @@ -230,7 +237,7 @@ public Mono> getDefaultWithResponseAsync(RequestOptions req @ServiceMethod(returns = ReturnType.SINGLE) public Response getDefaultWithResponse(RequestOptions requestOptions) { final String accept = "application/json"; - return service.getDefaultSync(accept, requestOptions, Context.NONE); + return service.getDefaultSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); } /** @@ -255,8 +262,9 @@ public Response getDefaultWithResponse(RequestOptions requestOptions */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> putAllWithResponseAsync(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.putAll(accept, body, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.putAll(this.client.getEndpoint(), contentType, body, requestOptions, context)); } /** @@ -281,8 +289,8 @@ public Mono> putAllWithResponseAsync(BinaryData body, RequestOpti */ @ServiceMethod(returns = ReturnType.SINGLE) public Response putAllWithResponse(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.putAllSync(accept, body, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.putAllSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); } /** @@ -307,8 +315,9 @@ public Response putAllWithResponse(BinaryData body, RequestOptions request */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> putDefaultWithResponseAsync(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.putDefault(accept, body, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.putDefault(this.client.getEndpoint(), contentType, body, requestOptions, context)); } /** @@ -333,7 +342,7 @@ public Mono> putDefaultWithResponseAsync(BinaryData body, Request */ @ServiceMethod(returns = ReturnType.SINGLE) public Response putDefaultWithResponse(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.putDefaultSync(accept, body, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.putDefaultSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/type/property/optional/implementation/CollectionsModelsImpl.java b/typespec-tests/src/main/java/com/type/property/optional/implementation/CollectionsModelsImpl.java index d85f5175ea..f83f9c9443 100644 --- a/typespec-tests/src/main/java/com/type/property/optional/implementation/CollectionsModelsImpl.java +++ b/typespec-tests/src/main/java/com/type/property/optional/implementation/CollectionsModelsImpl.java @@ -9,6 +9,7 @@ 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; @@ -55,7 +56,7 @@ public final class CollectionsModelsImpl { * The interface defining all the services for OptionalClientCollectionsModels to be used by the proxy service to * perform REST calls. */ - @Host("http://localhost:3000") + @Host("{endpoint}") @ServiceInterface(name = "OptionalClientCollec") public interface CollectionsModelsService { @Get("/type/property/optional/collections/model/all") @@ -64,8 +65,8 @@ public interface CollectionsModelsService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> getAll(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Mono> getAll(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Get("/type/property/optional/collections/model/all") @ExpectedResponses({ 200 }) @@ -73,8 +74,8 @@ Mono> getAll(@HeaderParam("accept") String accept, RequestO @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response getAllSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Response getAllSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Get("/type/property/optional/collections/model/default") @ExpectedResponses({ 200 }) @@ -82,8 +83,8 @@ Response getAllSync(@HeaderParam("accept") String accept, RequestOpt @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> getDefault(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Mono> getDefault(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Get("/type/property/optional/collections/model/default") @ExpectedResponses({ 200 }) @@ -91,8 +92,8 @@ Mono> getDefault(@HeaderParam("accept") String accept, Requ @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response getDefaultSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Response getDefaultSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Put("/type/property/optional/collections/model/all") @ExpectedResponses({ 204 }) @@ -100,8 +101,9 @@ Response getDefaultSync(@HeaderParam("accept") String accept, Reques @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> putAll(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + 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 }) @@ -109,7 +111,8 @@ Mono> putAll(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response putAllSync(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, + 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") @@ -118,8 +121,9 @@ Response putAllSync(@HeaderParam("accept") String accept, @BodyParam("appl @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> putDefault(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + 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 }) @@ -127,8 +131,9 @@ Mono> putDefault(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response putDefaultSync(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + Response putDefaultSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); } /** @@ -156,7 +161,8 @@ Response putDefaultSync(@HeaderParam("accept") String accept, @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getAllWithResponseAsync(RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.getAll(accept, requestOptions, context)); + return FluxUtil + .withContext(context -> service.getAll(this.client.getEndpoint(), accept, requestOptions, context)); } /** @@ -183,7 +189,7 @@ public Mono> getAllWithResponseAsync(RequestOptions request @ServiceMethod(returns = ReturnType.SINGLE) public Response getAllWithResponse(RequestOptions requestOptions) { final String accept = "application/json"; - return service.getAllSync(accept, requestOptions, Context.NONE); + return service.getAllSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); } /** @@ -211,7 +217,8 @@ public Response getAllWithResponse(RequestOptions requestOptions) { @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getDefaultWithResponseAsync(RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.getDefault(accept, requestOptions, context)); + return FluxUtil + .withContext(context -> service.getDefault(this.client.getEndpoint(), accept, requestOptions, context)); } /** @@ -238,7 +245,7 @@ public Mono> getDefaultWithResponseAsync(RequestOptions req @ServiceMethod(returns = ReturnType.SINGLE) public Response getDefaultWithResponse(RequestOptions requestOptions) { final String accept = "application/json"; - return service.getDefaultSync(accept, requestOptions, Context.NONE); + return service.getDefaultSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); } /** @@ -265,8 +272,9 @@ public Response getDefaultWithResponse(RequestOptions requestOptions */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> putAllWithResponseAsync(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.putAll(accept, body, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.putAll(this.client.getEndpoint(), contentType, body, requestOptions, context)); } /** @@ -293,8 +301,8 @@ public Mono> putAllWithResponseAsync(BinaryData body, RequestOpti */ @ServiceMethod(returns = ReturnType.SINGLE) public Response putAllWithResponse(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.putAllSync(accept, body, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.putAllSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); } /** @@ -321,8 +329,9 @@ public Response putAllWithResponse(BinaryData body, RequestOptions request */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> putDefaultWithResponseAsync(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.putDefault(accept, body, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.putDefault(this.client.getEndpoint(), contentType, body, requestOptions, context)); } /** @@ -349,7 +358,7 @@ public Mono> putDefaultWithResponseAsync(BinaryData body, Request */ @ServiceMethod(returns = ReturnType.SINGLE) public Response putDefaultWithResponse(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.putDefaultSync(accept, body, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.putDefaultSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/type/property/optional/implementation/DatetimeOperationsImpl.java b/typespec-tests/src/main/java/com/type/property/optional/implementation/DatetimeOperationsImpl.java index 320cafafdf..538f44b6fe 100644 --- a/typespec-tests/src/main/java/com/type/property/optional/implementation/DatetimeOperationsImpl.java +++ b/typespec-tests/src/main/java/com/type/property/optional/implementation/DatetimeOperationsImpl.java @@ -9,6 +9,7 @@ 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; @@ -55,7 +56,7 @@ public final class DatetimeOperationsImpl { * The interface defining all the services for OptionalClientDatetimeOperations to be used by the proxy service to * perform REST calls. */ - @Host("http://localhost:3000") + @Host("{endpoint}") @ServiceInterface(name = "OptionalClientDateti") public interface DatetimeOperationsService { @Get("/type/property/optional/datetime/all") @@ -64,8 +65,8 @@ public interface DatetimeOperationsService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> getAll(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Mono> getAll(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Get("/type/property/optional/datetime/all") @ExpectedResponses({ 200 }) @@ -73,8 +74,8 @@ Mono> getAll(@HeaderParam("accept") String accept, RequestO @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response getAllSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Response getAllSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Get("/type/property/optional/datetime/default") @ExpectedResponses({ 200 }) @@ -82,8 +83,8 @@ Response getAllSync(@HeaderParam("accept") String accept, RequestOpt @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> getDefault(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Mono> getDefault(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Get("/type/property/optional/datetime/default") @ExpectedResponses({ 200 }) @@ -91,8 +92,8 @@ Mono> getDefault(@HeaderParam("accept") String accept, Requ @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response getDefaultSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Response getDefaultSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Put("/type/property/optional/datetime/all") @ExpectedResponses({ 204 }) @@ -100,8 +101,9 @@ Response getDefaultSync(@HeaderParam("accept") String accept, Reques @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> putAll(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + 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 }) @@ -109,7 +111,8 @@ Mono> putAll(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response putAllSync(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, + 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") @@ -118,8 +121,9 @@ Response putAllSync(@HeaderParam("accept") String accept, @BodyParam("appl @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> putDefault(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + 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 }) @@ -127,8 +131,9 @@ Mono> putDefault(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response putDefaultSync(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + Response putDefaultSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); } /** @@ -152,7 +157,8 @@ Response putDefaultSync(@HeaderParam("accept") String accept, @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getAllWithResponseAsync(RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.getAll(accept, requestOptions, context)); + return FluxUtil + .withContext(context -> service.getAll(this.client.getEndpoint(), accept, requestOptions, context)); } /** @@ -175,7 +181,7 @@ public Mono> getAllWithResponseAsync(RequestOptions request @ServiceMethod(returns = ReturnType.SINGLE) public Response getAllWithResponse(RequestOptions requestOptions) { final String accept = "application/json"; - return service.getAllSync(accept, requestOptions, Context.NONE); + return service.getAllSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); } /** @@ -199,7 +205,8 @@ public Response getAllWithResponse(RequestOptions requestOptions) { @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getDefaultWithResponseAsync(RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.getDefault(accept, requestOptions, context)); + return FluxUtil + .withContext(context -> service.getDefault(this.client.getEndpoint(), accept, requestOptions, context)); } /** @@ -222,7 +229,7 @@ public Mono> getDefaultWithResponseAsync(RequestOptions req @ServiceMethod(returns = ReturnType.SINGLE) public Response getDefaultWithResponse(RequestOptions requestOptions) { final String accept = "application/json"; - return service.getDefaultSync(accept, requestOptions, Context.NONE); + return service.getDefaultSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); } /** @@ -245,8 +252,9 @@ public Response getDefaultWithResponse(RequestOptions requestOptions */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> putAllWithResponseAsync(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.putAll(accept, body, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.putAll(this.client.getEndpoint(), contentType, body, requestOptions, context)); } /** @@ -269,8 +277,8 @@ public Mono> putAllWithResponseAsync(BinaryData body, RequestOpti */ @ServiceMethod(returns = ReturnType.SINGLE) public Response putAllWithResponse(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.putAllSync(accept, body, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.putAllSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); } /** @@ -293,8 +301,9 @@ public Response putAllWithResponse(BinaryData body, RequestOptions request */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> putDefaultWithResponseAsync(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.putDefault(accept, body, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.putDefault(this.client.getEndpoint(), contentType, body, requestOptions, context)); } /** @@ -317,7 +326,7 @@ public Mono> putDefaultWithResponseAsync(BinaryData body, Request */ @ServiceMethod(returns = ReturnType.SINGLE) public Response putDefaultWithResponse(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.putDefaultSync(accept, body, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.putDefaultSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/type/property/optional/implementation/DurationOperationsImpl.java b/typespec-tests/src/main/java/com/type/property/optional/implementation/DurationOperationsImpl.java index 226ab461ae..3931d71c30 100644 --- a/typespec-tests/src/main/java/com/type/property/optional/implementation/DurationOperationsImpl.java +++ b/typespec-tests/src/main/java/com/type/property/optional/implementation/DurationOperationsImpl.java @@ -9,6 +9,7 @@ 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; @@ -55,7 +56,7 @@ public final class DurationOperationsImpl { * The interface defining all the services for OptionalClientDurationOperations to be used by the proxy service to * perform REST calls. */ - @Host("http://localhost:3000") + @Host("{endpoint}") @ServiceInterface(name = "OptionalClientDurati") public interface DurationOperationsService { @Get("/type/property/optional/duration/all") @@ -64,8 +65,8 @@ public interface DurationOperationsService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> getAll(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Mono> getAll(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Get("/type/property/optional/duration/all") @ExpectedResponses({ 200 }) @@ -73,8 +74,8 @@ Mono> getAll(@HeaderParam("accept") String accept, RequestO @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response getAllSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Response getAllSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Get("/type/property/optional/duration/default") @ExpectedResponses({ 200 }) @@ -82,8 +83,8 @@ Response getAllSync(@HeaderParam("accept") String accept, RequestOpt @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> getDefault(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Mono> getDefault(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Get("/type/property/optional/duration/default") @ExpectedResponses({ 200 }) @@ -91,8 +92,8 @@ Mono> getDefault(@HeaderParam("accept") String accept, Requ @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response getDefaultSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Response getDefaultSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Put("/type/property/optional/duration/all") @ExpectedResponses({ 204 }) @@ -100,8 +101,9 @@ Response getDefaultSync(@HeaderParam("accept") String accept, Reques @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> putAll(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + 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 }) @@ -109,7 +111,8 @@ Mono> putAll(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response putAllSync(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, + 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") @@ -118,8 +121,9 @@ Response putAllSync(@HeaderParam("accept") String accept, @BodyParam("appl @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> putDefault(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + 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 }) @@ -127,8 +131,9 @@ Mono> putDefault(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response putDefaultSync(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + Response putDefaultSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); } /** @@ -152,7 +157,8 @@ Response putDefaultSync(@HeaderParam("accept") String accept, @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getAllWithResponseAsync(RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.getAll(accept, requestOptions, context)); + return FluxUtil + .withContext(context -> service.getAll(this.client.getEndpoint(), accept, requestOptions, context)); } /** @@ -175,7 +181,7 @@ public Mono> getAllWithResponseAsync(RequestOptions request @ServiceMethod(returns = ReturnType.SINGLE) public Response getAllWithResponse(RequestOptions requestOptions) { final String accept = "application/json"; - return service.getAllSync(accept, requestOptions, Context.NONE); + return service.getAllSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); } /** @@ -199,7 +205,8 @@ public Response getAllWithResponse(RequestOptions requestOptions) { @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getDefaultWithResponseAsync(RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.getDefault(accept, requestOptions, context)); + return FluxUtil + .withContext(context -> service.getDefault(this.client.getEndpoint(), accept, requestOptions, context)); } /** @@ -222,7 +229,7 @@ public Mono> getDefaultWithResponseAsync(RequestOptions req @ServiceMethod(returns = ReturnType.SINGLE) public Response getDefaultWithResponse(RequestOptions requestOptions) { final String accept = "application/json"; - return service.getDefaultSync(accept, requestOptions, Context.NONE); + return service.getDefaultSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); } /** @@ -245,8 +252,9 @@ public Response getDefaultWithResponse(RequestOptions requestOptions */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> putAllWithResponseAsync(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.putAll(accept, body, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.putAll(this.client.getEndpoint(), contentType, body, requestOptions, context)); } /** @@ -269,8 +277,8 @@ public Mono> putAllWithResponseAsync(BinaryData body, RequestOpti */ @ServiceMethod(returns = ReturnType.SINGLE) public Response putAllWithResponse(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.putAllSync(accept, body, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.putAllSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); } /** @@ -293,8 +301,9 @@ public Response putAllWithResponse(BinaryData body, RequestOptions request */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> putDefaultWithResponseAsync(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.putDefault(accept, body, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.putDefault(this.client.getEndpoint(), contentType, body, requestOptions, context)); } /** @@ -317,7 +326,7 @@ public Mono> putDefaultWithResponseAsync(BinaryData body, Request */ @ServiceMethod(returns = ReturnType.SINGLE) public Response putDefaultWithResponse(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.putDefaultSync(accept, body, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.putDefaultSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/type/property/optional/implementation/FloatLiteralsImpl.java b/typespec-tests/src/main/java/com/type/property/optional/implementation/FloatLiteralsImpl.java index 0a8453db4e..3b6a473338 100644 --- a/typespec-tests/src/main/java/com/type/property/optional/implementation/FloatLiteralsImpl.java +++ b/typespec-tests/src/main/java/com/type/property/optional/implementation/FloatLiteralsImpl.java @@ -9,6 +9,7 @@ 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; @@ -55,7 +56,7 @@ public final class FloatLiteralsImpl { * The interface defining all the services for OptionalClientFloatLiterals to be used by the proxy service to * perform REST calls. */ - @Host("http://localhost:3000") + @Host("{endpoint}") @ServiceInterface(name = "OptionalClientFloatL") public interface FloatLiteralsService { @Get("/type/property/optional/float/literal/all") @@ -64,8 +65,8 @@ public interface FloatLiteralsService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> getAll(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Mono> getAll(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Get("/type/property/optional/float/literal/all") @ExpectedResponses({ 200 }) @@ -73,8 +74,8 @@ Mono> getAll(@HeaderParam("accept") String accept, RequestO @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response getAllSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Response getAllSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Get("/type/property/optional/float/literal/default") @ExpectedResponses({ 200 }) @@ -82,8 +83,8 @@ Response getAllSync(@HeaderParam("accept") String accept, RequestOpt @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> getDefault(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Mono> getDefault(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Get("/type/property/optional/float/literal/default") @ExpectedResponses({ 200 }) @@ -91,8 +92,8 @@ Mono> getDefault(@HeaderParam("accept") String accept, Requ @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response getDefaultSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Response getDefaultSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Put("/type/property/optional/float/literal/all") @ExpectedResponses({ 204 }) @@ -100,8 +101,9 @@ Response getDefaultSync(@HeaderParam("accept") String accept, Reques @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> putAll(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + 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 }) @@ -109,7 +111,8 @@ Mono> putAll(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response putAllSync(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, + 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") @@ -118,8 +121,9 @@ Response putAllSync(@HeaderParam("accept") String accept, @BodyParam("appl @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> putDefault(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + 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 }) @@ -127,8 +131,9 @@ Mono> putDefault(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response putDefaultSync(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + Response putDefaultSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); } /** @@ -152,7 +157,8 @@ Response putDefaultSync(@HeaderParam("accept") String accept, @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getAllWithResponseAsync(RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.getAll(accept, requestOptions, context)); + return FluxUtil + .withContext(context -> service.getAll(this.client.getEndpoint(), accept, requestOptions, context)); } /** @@ -175,7 +181,7 @@ public Mono> getAllWithResponseAsync(RequestOptions request @ServiceMethod(returns = ReturnType.SINGLE) public Response getAllWithResponse(RequestOptions requestOptions) { final String accept = "application/json"; - return service.getAllSync(accept, requestOptions, Context.NONE); + return service.getAllSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); } /** @@ -199,7 +205,8 @@ public Response getAllWithResponse(RequestOptions requestOptions) { @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getDefaultWithResponseAsync(RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.getDefault(accept, requestOptions, context)); + return FluxUtil + .withContext(context -> service.getDefault(this.client.getEndpoint(), accept, requestOptions, context)); } /** @@ -222,7 +229,7 @@ public Mono> getDefaultWithResponseAsync(RequestOptions req @ServiceMethod(returns = ReturnType.SINGLE) public Response getDefaultWithResponse(RequestOptions requestOptions) { final String accept = "application/json"; - return service.getDefaultSync(accept, requestOptions, Context.NONE); + return service.getDefaultSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); } /** @@ -245,8 +252,9 @@ public Response getDefaultWithResponse(RequestOptions requestOptions */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> putAllWithResponseAsync(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.putAll(accept, body, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.putAll(this.client.getEndpoint(), contentType, body, requestOptions, context)); } /** @@ -269,8 +277,8 @@ public Mono> putAllWithResponseAsync(BinaryData body, RequestOpti */ @ServiceMethod(returns = ReturnType.SINGLE) public Response putAllWithResponse(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.putAllSync(accept, body, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.putAllSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); } /** @@ -293,8 +301,9 @@ public Response putAllWithResponse(BinaryData body, RequestOptions request */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> putDefaultWithResponseAsync(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.putDefault(accept, body, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.putDefault(this.client.getEndpoint(), contentType, body, requestOptions, context)); } /** @@ -317,7 +326,7 @@ public Mono> putDefaultWithResponseAsync(BinaryData body, Request */ @ServiceMethod(returns = ReturnType.SINGLE) public Response putDefaultWithResponse(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.putDefaultSync(accept, body, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.putDefaultSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/type/property/optional/implementation/IntLiteralsImpl.java b/typespec-tests/src/main/java/com/type/property/optional/implementation/IntLiteralsImpl.java index 8597087a7e..672e4db8c6 100644 --- a/typespec-tests/src/main/java/com/type/property/optional/implementation/IntLiteralsImpl.java +++ b/typespec-tests/src/main/java/com/type/property/optional/implementation/IntLiteralsImpl.java @@ -9,6 +9,7 @@ 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; @@ -55,7 +56,7 @@ public final class IntLiteralsImpl { * The interface defining all the services for OptionalClientIntLiterals to be used by the proxy service to perform * REST calls. */ - @Host("http://localhost:3000") + @Host("{endpoint}") @ServiceInterface(name = "OptionalClientIntLit") public interface IntLiteralsService { @Get("/type/property/optional/int/literal/all") @@ -64,8 +65,8 @@ public interface IntLiteralsService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> getAll(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Mono> getAll(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Get("/type/property/optional/int/literal/all") @ExpectedResponses({ 200 }) @@ -73,8 +74,8 @@ Mono> getAll(@HeaderParam("accept") String accept, RequestO @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response getAllSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Response getAllSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Get("/type/property/optional/int/literal/default") @ExpectedResponses({ 200 }) @@ -82,8 +83,8 @@ Response getAllSync(@HeaderParam("accept") String accept, RequestOpt @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> getDefault(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Mono> getDefault(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Get("/type/property/optional/int/literal/default") @ExpectedResponses({ 200 }) @@ -91,8 +92,8 @@ Mono> getDefault(@HeaderParam("accept") String accept, Requ @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response getDefaultSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Response getDefaultSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Put("/type/property/optional/int/literal/all") @ExpectedResponses({ 204 }) @@ -100,8 +101,9 @@ Response getDefaultSync(@HeaderParam("accept") String accept, Reques @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> putAll(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + 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 }) @@ -109,7 +111,8 @@ Mono> putAll(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response putAllSync(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, + 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") @@ -118,8 +121,9 @@ Response putAllSync(@HeaderParam("accept") String accept, @BodyParam("appl @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> putDefault(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + 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 }) @@ -127,8 +131,9 @@ Mono> putDefault(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response putDefaultSync(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + Response putDefaultSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); } /** @@ -152,7 +157,8 @@ Response putDefaultSync(@HeaderParam("accept") String accept, @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getAllWithResponseAsync(RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.getAll(accept, requestOptions, context)); + return FluxUtil + .withContext(context -> service.getAll(this.client.getEndpoint(), accept, requestOptions, context)); } /** @@ -175,7 +181,7 @@ public Mono> getAllWithResponseAsync(RequestOptions request @ServiceMethod(returns = ReturnType.SINGLE) public Response getAllWithResponse(RequestOptions requestOptions) { final String accept = "application/json"; - return service.getAllSync(accept, requestOptions, Context.NONE); + return service.getAllSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); } /** @@ -199,7 +205,8 @@ public Response getAllWithResponse(RequestOptions requestOptions) { @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getDefaultWithResponseAsync(RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.getDefault(accept, requestOptions, context)); + return FluxUtil + .withContext(context -> service.getDefault(this.client.getEndpoint(), accept, requestOptions, context)); } /** @@ -222,7 +229,7 @@ public Mono> getDefaultWithResponseAsync(RequestOptions req @ServiceMethod(returns = ReturnType.SINGLE) public Response getDefaultWithResponse(RequestOptions requestOptions) { final String accept = "application/json"; - return service.getDefaultSync(accept, requestOptions, Context.NONE); + return service.getDefaultSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); } /** @@ -245,8 +252,9 @@ public Response getDefaultWithResponse(RequestOptions requestOptions */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> putAllWithResponseAsync(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.putAll(accept, body, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.putAll(this.client.getEndpoint(), contentType, body, requestOptions, context)); } /** @@ -269,8 +277,8 @@ public Mono> putAllWithResponseAsync(BinaryData body, RequestOpti */ @ServiceMethod(returns = ReturnType.SINGLE) public Response putAllWithResponse(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.putAllSync(accept, body, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.putAllSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); } /** @@ -293,8 +301,9 @@ public Response putAllWithResponse(BinaryData body, RequestOptions request */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> putDefaultWithResponseAsync(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.putDefault(accept, body, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.putDefault(this.client.getEndpoint(), contentType, body, requestOptions, context)); } /** @@ -317,7 +326,7 @@ public Mono> putDefaultWithResponseAsync(BinaryData body, Request */ @ServiceMethod(returns = ReturnType.SINGLE) public Response putDefaultWithResponse(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.putDefaultSync(accept, body, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.putDefaultSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/type/property/optional/implementation/OptionalClientImpl.java b/typespec-tests/src/main/java/com/type/property/optional/implementation/OptionalClientImpl.java index bbada9f151..3340a31281 100644 --- a/typespec-tests/src/main/java/com/type/property/optional/implementation/OptionalClientImpl.java +++ b/typespec-tests/src/main/java/com/type/property/optional/implementation/OptionalClientImpl.java @@ -15,6 +15,20 @@ * 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. */ @@ -269,19 +283,22 @@ public RequiredAndOptionalsImpl getRequiredAndOptionals() { /** * Initializes an instance of OptionalClient client. + * + * @param endpoint Service host. */ - public OptionalClientImpl() { + public OptionalClientImpl(String endpoint) { this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), - JacksonAdapter.createDefaultSerializerAdapter()); + 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) { - this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter()); + public OptionalClientImpl(HttpPipeline httpPipeline, String endpoint) { + this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint); } /** @@ -289,10 +306,12 @@ public OptionalClientImpl(HttpPipeline httpPipeline) { * * @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) { + 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); diff --git a/typespec-tests/src/main/java/com/type/property/optional/implementation/PlainDatesImpl.java b/typespec-tests/src/main/java/com/type/property/optional/implementation/PlainDatesImpl.java index 05efad88d1..c971409575 100644 --- a/typespec-tests/src/main/java/com/type/property/optional/implementation/PlainDatesImpl.java +++ b/typespec-tests/src/main/java/com/type/property/optional/implementation/PlainDatesImpl.java @@ -9,6 +9,7 @@ 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; @@ -55,7 +56,7 @@ public final class PlainDatesImpl { * The interface defining all the services for OptionalClientPlainDates to be used by the proxy service to perform * REST calls. */ - @Host("http://localhost:3000") + @Host("{endpoint}") @ServiceInterface(name = "OptionalClientPlainD") public interface PlainDatesService { @Get("/type/property/optional/plainDate/all") @@ -64,8 +65,8 @@ public interface PlainDatesService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> getAll(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Mono> getAll(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Get("/type/property/optional/plainDate/all") @ExpectedResponses({ 200 }) @@ -73,8 +74,8 @@ Mono> getAll(@HeaderParam("accept") String accept, RequestO @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response getAllSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Response getAllSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Get("/type/property/optional/plainDate/default") @ExpectedResponses({ 200 }) @@ -82,8 +83,8 @@ Response getAllSync(@HeaderParam("accept") String accept, RequestOpt @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> getDefault(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Mono> getDefault(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Get("/type/property/optional/plainDate/default") @ExpectedResponses({ 200 }) @@ -91,8 +92,8 @@ Mono> getDefault(@HeaderParam("accept") String accept, Requ @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response getDefaultSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Response getDefaultSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Put("/type/property/optional/plainDate/all") @ExpectedResponses({ 204 }) @@ -100,8 +101,9 @@ Response getDefaultSync(@HeaderParam("accept") String accept, Reques @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> putAll(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + 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 }) @@ -109,7 +111,8 @@ Mono> putAll(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response putAllSync(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, + 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") @@ -118,8 +121,9 @@ Response putAllSync(@HeaderParam("accept") String accept, @BodyParam("appl @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> putDefault(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + 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 }) @@ -127,8 +131,9 @@ Mono> putDefault(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response putDefaultSync(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + Response putDefaultSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); } /** @@ -152,7 +157,8 @@ Response putDefaultSync(@HeaderParam("accept") String accept, @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getAllWithResponseAsync(RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.getAll(accept, requestOptions, context)); + return FluxUtil + .withContext(context -> service.getAll(this.client.getEndpoint(), accept, requestOptions, context)); } /** @@ -175,7 +181,7 @@ public Mono> getAllWithResponseAsync(RequestOptions request @ServiceMethod(returns = ReturnType.SINGLE) public Response getAllWithResponse(RequestOptions requestOptions) { final String accept = "application/json"; - return service.getAllSync(accept, requestOptions, Context.NONE); + return service.getAllSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); } /** @@ -199,7 +205,8 @@ public Response getAllWithResponse(RequestOptions requestOptions) { @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getDefaultWithResponseAsync(RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.getDefault(accept, requestOptions, context)); + return FluxUtil + .withContext(context -> service.getDefault(this.client.getEndpoint(), accept, requestOptions, context)); } /** @@ -222,7 +229,7 @@ public Mono> getDefaultWithResponseAsync(RequestOptions req @ServiceMethod(returns = ReturnType.SINGLE) public Response getDefaultWithResponse(RequestOptions requestOptions) { final String accept = "application/json"; - return service.getDefaultSync(accept, requestOptions, Context.NONE); + return service.getDefaultSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); } /** @@ -245,8 +252,9 @@ public Response getDefaultWithResponse(RequestOptions requestOptions */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> putAllWithResponseAsync(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.putAll(accept, body, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.putAll(this.client.getEndpoint(), contentType, body, requestOptions, context)); } /** @@ -269,8 +277,8 @@ public Mono> putAllWithResponseAsync(BinaryData body, RequestOpti */ @ServiceMethod(returns = ReturnType.SINGLE) public Response putAllWithResponse(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.putAllSync(accept, body, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.putAllSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); } /** @@ -293,8 +301,9 @@ public Response putAllWithResponse(BinaryData body, RequestOptions request */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> putDefaultWithResponseAsync(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.putDefault(accept, body, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.putDefault(this.client.getEndpoint(), contentType, body, requestOptions, context)); } /** @@ -317,7 +326,7 @@ public Mono> putDefaultWithResponseAsync(BinaryData body, Request */ @ServiceMethod(returns = ReturnType.SINGLE) public Response putDefaultWithResponse(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.putDefaultSync(accept, body, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.putDefaultSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/type/property/optional/implementation/PlainTimesImpl.java b/typespec-tests/src/main/java/com/type/property/optional/implementation/PlainTimesImpl.java index dfd18fb5f3..12a0ebd724 100644 --- a/typespec-tests/src/main/java/com/type/property/optional/implementation/PlainTimesImpl.java +++ b/typespec-tests/src/main/java/com/type/property/optional/implementation/PlainTimesImpl.java @@ -9,6 +9,7 @@ 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; @@ -55,7 +56,7 @@ public final class PlainTimesImpl { * The interface defining all the services for OptionalClientPlainTimes to be used by the proxy service to perform * REST calls. */ - @Host("http://localhost:3000") + @Host("{endpoint}") @ServiceInterface(name = "OptionalClientPlainT") public interface PlainTimesService { @Get("/type/property/optional/plainTime/all") @@ -64,8 +65,8 @@ public interface PlainTimesService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> getAll(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Mono> getAll(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Get("/type/property/optional/plainTime/all") @ExpectedResponses({ 200 }) @@ -73,8 +74,8 @@ Mono> getAll(@HeaderParam("accept") String accept, RequestO @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response getAllSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Response getAllSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Get("/type/property/optional/plainTime/default") @ExpectedResponses({ 200 }) @@ -82,8 +83,8 @@ Response getAllSync(@HeaderParam("accept") String accept, RequestOpt @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> getDefault(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Mono> getDefault(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Get("/type/property/optional/plainTime/default") @ExpectedResponses({ 200 }) @@ -91,8 +92,8 @@ Mono> getDefault(@HeaderParam("accept") String accept, Requ @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response getDefaultSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Response getDefaultSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Put("/type/property/optional/plainTime/all") @ExpectedResponses({ 204 }) @@ -100,8 +101,9 @@ Response getDefaultSync(@HeaderParam("accept") String accept, Reques @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> putAll(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + 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 }) @@ -109,7 +111,8 @@ Mono> putAll(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response putAllSync(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, + 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") @@ -118,8 +121,9 @@ Response putAllSync(@HeaderParam("accept") String accept, @BodyParam("appl @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> putDefault(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + 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 }) @@ -127,8 +131,9 @@ Mono> putDefault(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response putDefaultSync(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + Response putDefaultSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); } /** @@ -152,7 +157,8 @@ Response putDefaultSync(@HeaderParam("accept") String accept, @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getAllWithResponseAsync(RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.getAll(accept, requestOptions, context)); + return FluxUtil + .withContext(context -> service.getAll(this.client.getEndpoint(), accept, requestOptions, context)); } /** @@ -175,7 +181,7 @@ public Mono> getAllWithResponseAsync(RequestOptions request @ServiceMethod(returns = ReturnType.SINGLE) public Response getAllWithResponse(RequestOptions requestOptions) { final String accept = "application/json"; - return service.getAllSync(accept, requestOptions, Context.NONE); + return service.getAllSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); } /** @@ -199,7 +205,8 @@ public Response getAllWithResponse(RequestOptions requestOptions) { @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getDefaultWithResponseAsync(RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.getDefault(accept, requestOptions, context)); + return FluxUtil + .withContext(context -> service.getDefault(this.client.getEndpoint(), accept, requestOptions, context)); } /** @@ -222,7 +229,7 @@ public Mono> getDefaultWithResponseAsync(RequestOptions req @ServiceMethod(returns = ReturnType.SINGLE) public Response getDefaultWithResponse(RequestOptions requestOptions) { final String accept = "application/json"; - return service.getDefaultSync(accept, requestOptions, Context.NONE); + return service.getDefaultSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); } /** @@ -245,8 +252,9 @@ public Response getDefaultWithResponse(RequestOptions requestOptions */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> putAllWithResponseAsync(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.putAll(accept, body, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.putAll(this.client.getEndpoint(), contentType, body, requestOptions, context)); } /** @@ -269,8 +277,8 @@ public Mono> putAllWithResponseAsync(BinaryData body, RequestOpti */ @ServiceMethod(returns = ReturnType.SINGLE) public Response putAllWithResponse(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.putAllSync(accept, body, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.putAllSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); } /** @@ -293,8 +301,9 @@ public Response putAllWithResponse(BinaryData body, RequestOptions request */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> putDefaultWithResponseAsync(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.putDefault(accept, body, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.putDefault(this.client.getEndpoint(), contentType, body, requestOptions, context)); } /** @@ -317,7 +326,7 @@ public Mono> putDefaultWithResponseAsync(BinaryData body, Request */ @ServiceMethod(returns = ReturnType.SINGLE) public Response putDefaultWithResponse(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.putDefaultSync(accept, body, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.putDefaultSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/type/property/optional/implementation/RequiredAndOptionalsImpl.java b/typespec-tests/src/main/java/com/type/property/optional/implementation/RequiredAndOptionalsImpl.java index 4e41231942..4e6d033bea 100644 --- a/typespec-tests/src/main/java/com/type/property/optional/implementation/RequiredAndOptionalsImpl.java +++ b/typespec-tests/src/main/java/com/type/property/optional/implementation/RequiredAndOptionalsImpl.java @@ -9,6 +9,7 @@ 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; @@ -55,7 +56,7 @@ public final class RequiredAndOptionalsImpl { * The interface defining all the services for OptionalClientRequiredAndOptionals to be used by the proxy service to * perform REST calls. */ - @Host("http://localhost:3000") + @Host("{endpoint}") @ServiceInterface(name = "OptionalClientRequir") public interface RequiredAndOptionalsService { @Get("/type/property/optional/requiredAndOptional/all") @@ -64,8 +65,8 @@ public interface RequiredAndOptionalsService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> getAll(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Mono> getAll(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Get("/type/property/optional/requiredAndOptional/all") @ExpectedResponses({ 200 }) @@ -73,8 +74,8 @@ Mono> getAll(@HeaderParam("accept") String accept, RequestO @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response getAllSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Response getAllSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Get("/type/property/optional/requiredAndOptional/requiredOnly") @ExpectedResponses({ 200 }) @@ -82,8 +83,8 @@ Response getAllSync(@HeaderParam("accept") String accept, RequestOpt @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> getRequiredOnly(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Mono> getRequiredOnly(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Get("/type/property/optional/requiredAndOptional/requiredOnly") @ExpectedResponses({ 200 }) @@ -91,8 +92,8 @@ Mono> getRequiredOnly(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response getRequiredOnlySync(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Response getRequiredOnlySync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Put("/type/property/optional/requiredAndOptional/all") @ExpectedResponses({ 204 }) @@ -100,8 +101,9 @@ Response getRequiredOnlySync(@HeaderParam("accept") String accept, R @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> putAll(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + 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 }) @@ -109,7 +111,8 @@ Mono> putAll(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response putAllSync(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, + 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") @@ -118,8 +121,9 @@ Response putAllSync(@HeaderParam("accept") String accept, @BodyParam("appl @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> putRequiredOnly(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + 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 }) @@ -127,8 +131,9 @@ Mono> putRequiredOnly(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response putRequiredOnlySync(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + Response putRequiredOnlySync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); } /** @@ -153,7 +158,8 @@ Response putRequiredOnlySync(@HeaderParam("accept") String accept, @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getAllWithResponseAsync(RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.getAll(accept, requestOptions, context)); + return FluxUtil + .withContext(context -> service.getAll(this.client.getEndpoint(), accept, requestOptions, context)); } /** @@ -177,7 +183,7 @@ public Mono> getAllWithResponseAsync(RequestOptions request @ServiceMethod(returns = ReturnType.SINGLE) public Response getAllWithResponse(RequestOptions requestOptions) { final String accept = "application/json"; - return service.getAllSync(accept, requestOptions, Context.NONE); + return service.getAllSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); } /** @@ -202,7 +208,8 @@ public Response getAllWithResponse(RequestOptions requestOptions) { @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getRequiredOnlyWithResponseAsync(RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.getRequiredOnly(accept, requestOptions, context)); + return FluxUtil.withContext( + context -> service.getRequiredOnly(this.client.getEndpoint(), accept, requestOptions, context)); } /** @@ -226,7 +233,7 @@ public Mono> getRequiredOnlyWithResponseAsync(RequestOption @ServiceMethod(returns = ReturnType.SINGLE) public Response getRequiredOnlyWithResponse(RequestOptions requestOptions) { final String accept = "application/json"; - return service.getRequiredOnlySync(accept, requestOptions, Context.NONE); + return service.getRequiredOnlySync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); } /** @@ -250,8 +257,9 @@ public Response getRequiredOnlyWithResponse(RequestOptions requestOp */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> putAllWithResponseAsync(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.putAll(accept, body, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.putAll(this.client.getEndpoint(), contentType, body, requestOptions, context)); } /** @@ -275,8 +283,8 @@ public Mono> putAllWithResponseAsync(BinaryData body, RequestOpti */ @ServiceMethod(returns = ReturnType.SINGLE) public Response putAllWithResponse(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.putAllSync(accept, body, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.putAllSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); } /** @@ -300,8 +308,9 @@ public Response putAllWithResponse(BinaryData body, RequestOptions request */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> putRequiredOnlyWithResponseAsync(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.putRequiredOnly(accept, body, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.putRequiredOnly(this.client.getEndpoint(), contentType, body, requestOptions, context)); } /** @@ -325,7 +334,7 @@ public Mono> putRequiredOnlyWithResponseAsync(BinaryData body, Re */ @ServiceMethod(returns = ReturnType.SINGLE) public Response putRequiredOnlyWithResponse(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.putRequiredOnlySync(accept, body, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.putRequiredOnlySync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/type/property/optional/implementation/StringLiteralsImpl.java b/typespec-tests/src/main/java/com/type/property/optional/implementation/StringLiteralsImpl.java index 7dbf99b700..7eb0af857e 100644 --- a/typespec-tests/src/main/java/com/type/property/optional/implementation/StringLiteralsImpl.java +++ b/typespec-tests/src/main/java/com/type/property/optional/implementation/StringLiteralsImpl.java @@ -9,6 +9,7 @@ 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; @@ -55,7 +56,7 @@ public final class StringLiteralsImpl { * The interface defining all the services for OptionalClientStringLiterals to be used by the proxy service to * perform REST calls. */ - @Host("http://localhost:3000") + @Host("{endpoint}") @ServiceInterface(name = "OptionalClientString") public interface StringLiteralsService { @Get("/type/property/optional/string/literal/all") @@ -64,8 +65,8 @@ public interface StringLiteralsService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> getAll(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Mono> getAll(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Get("/type/property/optional/string/literal/all") @ExpectedResponses({ 200 }) @@ -73,8 +74,8 @@ Mono> getAll(@HeaderParam("accept") String accept, RequestO @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response getAllSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Response getAllSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Get("/type/property/optional/string/literal/default") @ExpectedResponses({ 200 }) @@ -82,8 +83,8 @@ Response getAllSync(@HeaderParam("accept") String accept, RequestOpt @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> getDefault(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Mono> getDefault(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Get("/type/property/optional/string/literal/default") @ExpectedResponses({ 200 }) @@ -91,8 +92,8 @@ Mono> getDefault(@HeaderParam("accept") String accept, Requ @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response getDefaultSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Response getDefaultSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Put("/type/property/optional/string/literal/all") @ExpectedResponses({ 204 }) @@ -100,8 +101,9 @@ Response getDefaultSync(@HeaderParam("accept") String accept, Reques @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> putAll(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + 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 }) @@ -109,7 +111,8 @@ Mono> putAll(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response putAllSync(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, + 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") @@ -118,8 +121,9 @@ Response putAllSync(@HeaderParam("accept") String accept, @BodyParam("appl @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> putDefault(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + 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 }) @@ -127,8 +131,9 @@ Mono> putDefault(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response putDefaultSync(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + Response putDefaultSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); } /** @@ -152,7 +157,8 @@ Response putDefaultSync(@HeaderParam("accept") String accept, @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getAllWithResponseAsync(RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.getAll(accept, requestOptions, context)); + return FluxUtil + .withContext(context -> service.getAll(this.client.getEndpoint(), accept, requestOptions, context)); } /** @@ -175,7 +181,7 @@ public Mono> getAllWithResponseAsync(RequestOptions request @ServiceMethod(returns = ReturnType.SINGLE) public Response getAllWithResponse(RequestOptions requestOptions) { final String accept = "application/json"; - return service.getAllSync(accept, requestOptions, Context.NONE); + return service.getAllSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); } /** @@ -199,7 +205,8 @@ public Response getAllWithResponse(RequestOptions requestOptions) { @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getDefaultWithResponseAsync(RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.getDefault(accept, requestOptions, context)); + return FluxUtil + .withContext(context -> service.getDefault(this.client.getEndpoint(), accept, requestOptions, context)); } /** @@ -222,7 +229,7 @@ public Mono> getDefaultWithResponseAsync(RequestOptions req @ServiceMethod(returns = ReturnType.SINGLE) public Response getDefaultWithResponse(RequestOptions requestOptions) { final String accept = "application/json"; - return service.getDefaultSync(accept, requestOptions, Context.NONE); + return service.getDefaultSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); } /** @@ -245,8 +252,9 @@ public Response getDefaultWithResponse(RequestOptions requestOptions */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> putAllWithResponseAsync(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.putAll(accept, body, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.putAll(this.client.getEndpoint(), contentType, body, requestOptions, context)); } /** @@ -269,8 +277,8 @@ public Mono> putAllWithResponseAsync(BinaryData body, RequestOpti */ @ServiceMethod(returns = ReturnType.SINGLE) public Response putAllWithResponse(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.putAllSync(accept, body, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.putAllSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); } /** @@ -293,8 +301,9 @@ public Response putAllWithResponse(BinaryData body, RequestOptions request */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> putDefaultWithResponseAsync(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.putDefault(accept, body, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.putDefault(this.client.getEndpoint(), contentType, body, requestOptions, context)); } /** @@ -317,7 +326,7 @@ public Mono> putDefaultWithResponseAsync(BinaryData body, Request */ @ServiceMethod(returns = ReturnType.SINGLE) public Response putDefaultWithResponse(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.putDefaultSync(accept, body, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.putDefaultSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/type/property/optional/implementation/StringOperationsImpl.java b/typespec-tests/src/main/java/com/type/property/optional/implementation/StringOperationsImpl.java index 77f6591e40..e75323f134 100644 --- a/typespec-tests/src/main/java/com/type/property/optional/implementation/StringOperationsImpl.java +++ b/typespec-tests/src/main/java/com/type/property/optional/implementation/StringOperationsImpl.java @@ -9,6 +9,7 @@ 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; @@ -55,7 +56,7 @@ public final class StringOperationsImpl { * The interface defining all the services for OptionalClientStringOperations to be used by the proxy service to * perform REST calls. */ - @Host("http://localhost:3000") + @Host("{endpoint}") @ServiceInterface(name = "OptionalClientString") public interface StringOperationsService { @Get("/type/property/optional/string/all") @@ -64,8 +65,8 @@ public interface StringOperationsService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> getAll(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Mono> getAll(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Get("/type/property/optional/string/all") @ExpectedResponses({ 200 }) @@ -73,8 +74,8 @@ Mono> getAll(@HeaderParam("accept") String accept, RequestO @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response getAllSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Response getAllSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Get("/type/property/optional/string/default") @ExpectedResponses({ 200 }) @@ -82,8 +83,8 @@ Response getAllSync(@HeaderParam("accept") String accept, RequestOpt @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> getDefault(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Mono> getDefault(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Get("/type/property/optional/string/default") @ExpectedResponses({ 200 }) @@ -91,8 +92,8 @@ Mono> getDefault(@HeaderParam("accept") String accept, Requ @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response getDefaultSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Response getDefaultSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Put("/type/property/optional/string/all") @ExpectedResponses({ 204 }) @@ -100,8 +101,9 @@ Response getDefaultSync(@HeaderParam("accept") String accept, Reques @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> putAll(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + 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 }) @@ -109,7 +111,8 @@ Mono> putAll(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response putAllSync(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, + 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") @@ -118,8 +121,9 @@ Response putAllSync(@HeaderParam("accept") String accept, @BodyParam("appl @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> putDefault(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + 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 }) @@ -127,8 +131,9 @@ Mono> putDefault(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response putDefaultSync(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + Response putDefaultSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); } /** @@ -152,7 +157,8 @@ Response putDefaultSync(@HeaderParam("accept") String accept, @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getAllWithResponseAsync(RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.getAll(accept, requestOptions, context)); + return FluxUtil + .withContext(context -> service.getAll(this.client.getEndpoint(), accept, requestOptions, context)); } /** @@ -175,7 +181,7 @@ public Mono> getAllWithResponseAsync(RequestOptions request @ServiceMethod(returns = ReturnType.SINGLE) public Response getAllWithResponse(RequestOptions requestOptions) { final String accept = "application/json"; - return service.getAllSync(accept, requestOptions, Context.NONE); + return service.getAllSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); } /** @@ -199,7 +205,8 @@ public Response getAllWithResponse(RequestOptions requestOptions) { @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getDefaultWithResponseAsync(RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.getDefault(accept, requestOptions, context)); + return FluxUtil + .withContext(context -> service.getDefault(this.client.getEndpoint(), accept, requestOptions, context)); } /** @@ -222,7 +229,7 @@ public Mono> getDefaultWithResponseAsync(RequestOptions req @ServiceMethod(returns = ReturnType.SINGLE) public Response getDefaultWithResponse(RequestOptions requestOptions) { final String accept = "application/json"; - return service.getDefaultSync(accept, requestOptions, Context.NONE); + return service.getDefaultSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); } /** @@ -245,8 +252,9 @@ public Response getDefaultWithResponse(RequestOptions requestOptions */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> putAllWithResponseAsync(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.putAll(accept, body, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.putAll(this.client.getEndpoint(), contentType, body, requestOptions, context)); } /** @@ -269,8 +277,8 @@ public Mono> putAllWithResponseAsync(BinaryData body, RequestOpti */ @ServiceMethod(returns = ReturnType.SINGLE) public Response putAllWithResponse(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.putAllSync(accept, body, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.putAllSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); } /** @@ -293,8 +301,9 @@ public Response putAllWithResponse(BinaryData body, RequestOptions request */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> putDefaultWithResponseAsync(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.putDefault(accept, body, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.putDefault(this.client.getEndpoint(), contentType, body, requestOptions, context)); } /** @@ -317,7 +326,7 @@ public Mono> putDefaultWithResponseAsync(BinaryData body, Request */ @ServiceMethod(returns = ReturnType.SINGLE) public Response putDefaultWithResponse(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.putDefaultSync(accept, body, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.putDefaultSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/type/property/optional/implementation/UnionFloatLiteralsImpl.java b/typespec-tests/src/main/java/com/type/property/optional/implementation/UnionFloatLiteralsImpl.java index 4decf810ac..2d6f4c8971 100644 --- a/typespec-tests/src/main/java/com/type/property/optional/implementation/UnionFloatLiteralsImpl.java +++ b/typespec-tests/src/main/java/com/type/property/optional/implementation/UnionFloatLiteralsImpl.java @@ -9,6 +9,7 @@ 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; @@ -55,7 +56,7 @@ public final class UnionFloatLiteralsImpl { * The interface defining all the services for OptionalClientUnionFloatLiterals to be used by the proxy service to * perform REST calls. */ - @Host("http://localhost:3000") + @Host("{endpoint}") @ServiceInterface(name = "OptionalClientUnionF") public interface UnionFloatLiteralsService { @Get("/type/property/optional/union/float/literal/all") @@ -64,8 +65,8 @@ public interface UnionFloatLiteralsService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> getAll(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Mono> getAll(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Get("/type/property/optional/union/float/literal/all") @ExpectedResponses({ 200 }) @@ -73,8 +74,8 @@ Mono> getAll(@HeaderParam("accept") String accept, RequestO @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response getAllSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Response getAllSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Get("/type/property/optional/union/float/literal/default") @ExpectedResponses({ 200 }) @@ -82,8 +83,8 @@ Response getAllSync(@HeaderParam("accept") String accept, RequestOpt @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> getDefault(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Mono> getDefault(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Get("/type/property/optional/union/float/literal/default") @ExpectedResponses({ 200 }) @@ -91,8 +92,8 @@ Mono> getDefault(@HeaderParam("accept") String accept, Requ @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response getDefaultSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Response getDefaultSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Put("/type/property/optional/union/float/literal/all") @ExpectedResponses({ 204 }) @@ -100,8 +101,9 @@ Response getDefaultSync(@HeaderParam("accept") String accept, Reques @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> putAll(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + 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 }) @@ -109,7 +111,8 @@ Mono> putAll(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response putAllSync(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, + 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") @@ -118,8 +121,9 @@ Response putAllSync(@HeaderParam("accept") String accept, @BodyParam("appl @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> putDefault(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + 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 }) @@ -127,8 +131,9 @@ Mono> putDefault(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response putDefaultSync(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + Response putDefaultSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); } /** @@ -152,7 +157,8 @@ Response putDefaultSync(@HeaderParam("accept") String accept, @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getAllWithResponseAsync(RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.getAll(accept, requestOptions, context)); + return FluxUtil + .withContext(context -> service.getAll(this.client.getEndpoint(), accept, requestOptions, context)); } /** @@ -175,7 +181,7 @@ public Mono> getAllWithResponseAsync(RequestOptions request @ServiceMethod(returns = ReturnType.SINGLE) public Response getAllWithResponse(RequestOptions requestOptions) { final String accept = "application/json"; - return service.getAllSync(accept, requestOptions, Context.NONE); + return service.getAllSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); } /** @@ -199,7 +205,8 @@ public Response getAllWithResponse(RequestOptions requestOptions) { @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getDefaultWithResponseAsync(RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.getDefault(accept, requestOptions, context)); + return FluxUtil + .withContext(context -> service.getDefault(this.client.getEndpoint(), accept, requestOptions, context)); } /** @@ -222,7 +229,7 @@ public Mono> getDefaultWithResponseAsync(RequestOptions req @ServiceMethod(returns = ReturnType.SINGLE) public Response getDefaultWithResponse(RequestOptions requestOptions) { final String accept = "application/json"; - return service.getDefaultSync(accept, requestOptions, Context.NONE); + return service.getDefaultSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); } /** @@ -245,8 +252,9 @@ public Response getDefaultWithResponse(RequestOptions requestOptions */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> putAllWithResponseAsync(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.putAll(accept, body, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.putAll(this.client.getEndpoint(), contentType, body, requestOptions, context)); } /** @@ -269,8 +277,8 @@ public Mono> putAllWithResponseAsync(BinaryData body, RequestOpti */ @ServiceMethod(returns = ReturnType.SINGLE) public Response putAllWithResponse(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.putAllSync(accept, body, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.putAllSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); } /** @@ -293,8 +301,9 @@ public Response putAllWithResponse(BinaryData body, RequestOptions request */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> putDefaultWithResponseAsync(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.putDefault(accept, body, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.putDefault(this.client.getEndpoint(), contentType, body, requestOptions, context)); } /** @@ -317,7 +326,7 @@ public Mono> putDefaultWithResponseAsync(BinaryData body, Request */ @ServiceMethod(returns = ReturnType.SINGLE) public Response putDefaultWithResponse(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.putDefaultSync(accept, body, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.putDefaultSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/type/property/optional/implementation/UnionIntLiteralsImpl.java b/typespec-tests/src/main/java/com/type/property/optional/implementation/UnionIntLiteralsImpl.java index 791550d174..1f032a817c 100644 --- a/typespec-tests/src/main/java/com/type/property/optional/implementation/UnionIntLiteralsImpl.java +++ b/typespec-tests/src/main/java/com/type/property/optional/implementation/UnionIntLiteralsImpl.java @@ -9,6 +9,7 @@ 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; @@ -55,7 +56,7 @@ public final class UnionIntLiteralsImpl { * The interface defining all the services for OptionalClientUnionIntLiterals to be used by the proxy service to * perform REST calls. */ - @Host("http://localhost:3000") + @Host("{endpoint}") @ServiceInterface(name = "OptionalClientUnionI") public interface UnionIntLiteralsService { @Get("/type/property/optional/union/int/literal/all") @@ -64,8 +65,8 @@ public interface UnionIntLiteralsService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> getAll(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Mono> getAll(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Get("/type/property/optional/union/int/literal/all") @ExpectedResponses({ 200 }) @@ -73,8 +74,8 @@ Mono> getAll(@HeaderParam("accept") String accept, RequestO @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response getAllSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Response getAllSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Get("/type/property/optional/union/int/literal/default") @ExpectedResponses({ 200 }) @@ -82,8 +83,8 @@ Response getAllSync(@HeaderParam("accept") String accept, RequestOpt @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> getDefault(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Mono> getDefault(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Get("/type/property/optional/union/int/literal/default") @ExpectedResponses({ 200 }) @@ -91,8 +92,8 @@ Mono> getDefault(@HeaderParam("accept") String accept, Requ @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response getDefaultSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Response getDefaultSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Put("/type/property/optional/union/int/literal/all") @ExpectedResponses({ 204 }) @@ -100,8 +101,9 @@ Response getDefaultSync(@HeaderParam("accept") String accept, Reques @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> putAll(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + 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 }) @@ -109,7 +111,8 @@ Mono> putAll(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response putAllSync(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, + 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") @@ -118,8 +121,9 @@ Response putAllSync(@HeaderParam("accept") String accept, @BodyParam("appl @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> putDefault(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + 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 }) @@ -127,8 +131,9 @@ Mono> putDefault(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response putDefaultSync(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + Response putDefaultSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); } /** @@ -152,7 +157,8 @@ Response putDefaultSync(@HeaderParam("accept") String accept, @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getAllWithResponseAsync(RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.getAll(accept, requestOptions, context)); + return FluxUtil + .withContext(context -> service.getAll(this.client.getEndpoint(), accept, requestOptions, context)); } /** @@ -175,7 +181,7 @@ public Mono> getAllWithResponseAsync(RequestOptions request @ServiceMethod(returns = ReturnType.SINGLE) public Response getAllWithResponse(RequestOptions requestOptions) { final String accept = "application/json"; - return service.getAllSync(accept, requestOptions, Context.NONE); + return service.getAllSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); } /** @@ -199,7 +205,8 @@ public Response getAllWithResponse(RequestOptions requestOptions) { @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getDefaultWithResponseAsync(RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.getDefault(accept, requestOptions, context)); + return FluxUtil + .withContext(context -> service.getDefault(this.client.getEndpoint(), accept, requestOptions, context)); } /** @@ -222,7 +229,7 @@ public Mono> getDefaultWithResponseAsync(RequestOptions req @ServiceMethod(returns = ReturnType.SINGLE) public Response getDefaultWithResponse(RequestOptions requestOptions) { final String accept = "application/json"; - return service.getDefaultSync(accept, requestOptions, Context.NONE); + return service.getDefaultSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); } /** @@ -245,8 +252,9 @@ public Response getDefaultWithResponse(RequestOptions requestOptions */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> putAllWithResponseAsync(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.putAll(accept, body, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.putAll(this.client.getEndpoint(), contentType, body, requestOptions, context)); } /** @@ -269,8 +277,8 @@ public Mono> putAllWithResponseAsync(BinaryData body, RequestOpti */ @ServiceMethod(returns = ReturnType.SINGLE) public Response putAllWithResponse(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.putAllSync(accept, body, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.putAllSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); } /** @@ -293,8 +301,9 @@ public Response putAllWithResponse(BinaryData body, RequestOptions request */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> putDefaultWithResponseAsync(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.putDefault(accept, body, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.putDefault(this.client.getEndpoint(), contentType, body, requestOptions, context)); } /** @@ -317,7 +326,7 @@ public Mono> putDefaultWithResponseAsync(BinaryData body, Request */ @ServiceMethod(returns = ReturnType.SINGLE) public Response putDefaultWithResponse(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.putDefaultSync(accept, body, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.putDefaultSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/type/property/optional/implementation/UnionStringLiteralsImpl.java b/typespec-tests/src/main/java/com/type/property/optional/implementation/UnionStringLiteralsImpl.java index 08636166f8..f3269df466 100644 --- a/typespec-tests/src/main/java/com/type/property/optional/implementation/UnionStringLiteralsImpl.java +++ b/typespec-tests/src/main/java/com/type/property/optional/implementation/UnionStringLiteralsImpl.java @@ -9,6 +9,7 @@ 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; @@ -55,7 +56,7 @@ public final class UnionStringLiteralsImpl { * The interface defining all the services for OptionalClientUnionStringLiterals to be used by the proxy service to * perform REST calls. */ - @Host("http://localhost:3000") + @Host("{endpoint}") @ServiceInterface(name = "OptionalClientUnionS") public interface UnionStringLiteralsService { @Get("/type/property/optional/union/string/literal/all") @@ -64,8 +65,8 @@ public interface UnionStringLiteralsService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> getAll(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Mono> getAll(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Get("/type/property/optional/union/string/literal/all") @ExpectedResponses({ 200 }) @@ -73,8 +74,8 @@ Mono> getAll(@HeaderParam("accept") String accept, RequestO @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response getAllSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Response getAllSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Get("/type/property/optional/union/string/literal/default") @ExpectedResponses({ 200 }) @@ -82,8 +83,8 @@ Response getAllSync(@HeaderParam("accept") String accept, RequestOpt @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> getDefault(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Mono> getDefault(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Get("/type/property/optional/union/string/literal/default") @ExpectedResponses({ 200 }) @@ -91,8 +92,8 @@ Mono> getDefault(@HeaderParam("accept") String accept, Requ @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response getDefaultSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Response getDefaultSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Put("/type/property/optional/union/string/literal/all") @ExpectedResponses({ 204 }) @@ -100,8 +101,9 @@ Response getDefaultSync(@HeaderParam("accept") String accept, Reques @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> putAll(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + 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 }) @@ -109,7 +111,8 @@ Mono> putAll(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response putAllSync(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, + 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") @@ -118,8 +121,9 @@ Response putAllSync(@HeaderParam("accept") String accept, @BodyParam("appl @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> putDefault(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + 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 }) @@ -127,8 +131,9 @@ Mono> putDefault(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response putDefaultSync(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + Response putDefaultSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); } /** @@ -152,7 +157,8 @@ Response putDefaultSync(@HeaderParam("accept") String accept, @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getAllWithResponseAsync(RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.getAll(accept, requestOptions, context)); + return FluxUtil + .withContext(context -> service.getAll(this.client.getEndpoint(), accept, requestOptions, context)); } /** @@ -175,7 +181,7 @@ public Mono> getAllWithResponseAsync(RequestOptions request @ServiceMethod(returns = ReturnType.SINGLE) public Response getAllWithResponse(RequestOptions requestOptions) { final String accept = "application/json"; - return service.getAllSync(accept, requestOptions, Context.NONE); + return service.getAllSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); } /** @@ -199,7 +205,8 @@ public Response getAllWithResponse(RequestOptions requestOptions) { @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getDefaultWithResponseAsync(RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.getDefault(accept, requestOptions, context)); + return FluxUtil + .withContext(context -> service.getDefault(this.client.getEndpoint(), accept, requestOptions, context)); } /** @@ -222,7 +229,7 @@ public Mono> getDefaultWithResponseAsync(RequestOptions req @ServiceMethod(returns = ReturnType.SINGLE) public Response getDefaultWithResponse(RequestOptions requestOptions) { final String accept = "application/json"; - return service.getDefaultSync(accept, requestOptions, Context.NONE); + return service.getDefaultSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); } /** @@ -245,8 +252,9 @@ public Response getDefaultWithResponse(RequestOptions requestOptions */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> putAllWithResponseAsync(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.putAll(accept, body, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.putAll(this.client.getEndpoint(), contentType, body, requestOptions, context)); } /** @@ -269,8 +277,8 @@ public Mono> putAllWithResponseAsync(BinaryData body, RequestOpti */ @ServiceMethod(returns = ReturnType.SINGLE) public Response putAllWithResponse(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.putAllSync(accept, body, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.putAllSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); } /** @@ -293,8 +301,9 @@ public Response putAllWithResponse(BinaryData body, RequestOptions request */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> putDefaultWithResponseAsync(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.putDefault(accept, body, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.putDefault(this.client.getEndpoint(), contentType, body, requestOptions, context)); } /** @@ -317,7 +326,7 @@ public Mono> putDefaultWithResponseAsync(BinaryData body, Request */ @ServiceMethod(returns = ReturnType.SINGLE) public Response putDefaultWithResponse(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.putDefaultSync(accept, body, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.putDefaultSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/type/property/valuetypes/ValueTypesClientBuilder.java b/typespec-tests/src/main/java/com/type/property/valuetypes/ValueTypesClientBuilder.java index 04bf5e080a..c08bd9971f 100644 --- a/typespec-tests/src/main/java/com/type/property/valuetypes/ValueTypesClientBuilder.java +++ b/typespec-tests/src/main/java/com/type/property/valuetypes/ValueTypesClientBuilder.java @@ -7,6 +7,7 @@ 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; @@ -99,8 +100,8 @@ UnionIntLiteralAsyncClient.class, UnionFloatLiteralAsyncClient.class, UnionEnumValueAsyncClient.class }) -public final class ValueTypesClientBuilder - implements HttpTrait, ConfigurationTrait { +public final class ValueTypesClientBuilder implements HttpTrait, + ConfigurationTrait, EndpointTrait { @Generated private static final String SDK_NAME = "name"; @@ -232,6 +233,22 @@ public ValueTypesClientBuilder configuration(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. */ @@ -259,8 +276,9 @@ public ValueTypesClientBuilder retryPolicy(RetryPolicy retryPolicy) { 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()); + = new ValueTypesClientImpl(localPipeline, JacksonAdapter.createDefaultSerializerAdapter(), localEndpoint); return client; } diff --git a/typespec-tests/src/main/java/com/type/property/valuetypes/implementation/BooleanLiteralsImpl.java b/typespec-tests/src/main/java/com/type/property/valuetypes/implementation/BooleanLiteralsImpl.java index f044a6712f..5848e3691d 100644 --- a/typespec-tests/src/main/java/com/type/property/valuetypes/implementation/BooleanLiteralsImpl.java +++ b/typespec-tests/src/main/java/com/type/property/valuetypes/implementation/BooleanLiteralsImpl.java @@ -9,6 +9,7 @@ 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; @@ -55,7 +56,7 @@ public final class BooleanLiteralsImpl { * The interface defining all the services for ValueTypesClientBooleanLiterals to be used by the proxy service to * perform REST calls. */ - @Host("http://localhost:3000") + @Host("{endpoint}") @ServiceInterface(name = "ValueTypesClientBool") public interface BooleanLiteralsService { @Get("/type/property/value-types/boolean/literal") @@ -64,8 +65,8 @@ public interface BooleanLiteralsService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> get(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Get("/type/property/value-types/boolean/literal") @ExpectedResponses({ 200 }) @@ -73,8 +74,8 @@ Mono> get(@HeaderParam("accept") String accept, RequestOpti @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response getSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Put("/type/property/value-types/boolean/literal") @ExpectedResponses({ 204 }) @@ -82,7 +83,8 @@ Response getSync(@HeaderParam("accept") String accept, RequestOption @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> put(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, + 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") @@ -91,8 +93,8 @@ Mono> put(@HeaderParam("accept") String accept, @BodyParam("appli @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response putSync(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, - RequestOptions requestOptions, Context context); + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); } /** @@ -115,7 +117,7 @@ Response putSync(@HeaderParam("accept") String accept, @BodyParam("applica @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getWithResponseAsync(RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.get(accept, requestOptions, context)); + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); } /** @@ -138,7 +140,7 @@ public Mono> getWithResponseAsync(RequestOptions requestOpt @ServiceMethod(returns = ReturnType.SINGLE) public Response getWithResponse(RequestOptions requestOptions) { final String accept = "application/json"; - return service.getSync(accept, requestOptions, Context.NONE); + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); } /** @@ -161,8 +163,9 @@ public Response getWithResponse(RequestOptions requestOptions) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> putWithResponseAsync(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.put(accept, body, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.put(this.client.getEndpoint(), contentType, body, requestOptions, context)); } /** @@ -185,7 +188,7 @@ public Mono> putWithResponseAsync(BinaryData body, RequestOptions */ @ServiceMethod(returns = ReturnType.SINGLE) public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.putSync(accept, body, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/type/property/valuetypes/implementation/BooleanOperationsImpl.java b/typespec-tests/src/main/java/com/type/property/valuetypes/implementation/BooleanOperationsImpl.java index 7bc544aa60..9afe0ace2c 100644 --- a/typespec-tests/src/main/java/com/type/property/valuetypes/implementation/BooleanOperationsImpl.java +++ b/typespec-tests/src/main/java/com/type/property/valuetypes/implementation/BooleanOperationsImpl.java @@ -9,6 +9,7 @@ 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; @@ -55,7 +56,7 @@ public final class BooleanOperationsImpl { * The interface defining all the services for ValueTypesClientBooleanOperations to be used by the proxy service to * perform REST calls. */ - @Host("http://localhost:3000") + @Host("{endpoint}") @ServiceInterface(name = "ValueTypesClientBool") public interface BooleanOperationsService { @Get("/type/property/value-types/boolean") @@ -64,8 +65,8 @@ public interface BooleanOperationsService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> get(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Get("/type/property/value-types/boolean") @ExpectedResponses({ 200 }) @@ -73,8 +74,8 @@ Mono> get(@HeaderParam("accept") String accept, RequestOpti @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response getSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Put("/type/property/value-types/boolean") @ExpectedResponses({ 204 }) @@ -82,7 +83,8 @@ Response getSync(@HeaderParam("accept") String accept, RequestOption @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> put(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, + 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") @@ -91,8 +93,8 @@ Mono> put(@HeaderParam("accept") String accept, @BodyParam("appli @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response putSync(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, - RequestOptions requestOptions, Context context); + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); } /** @@ -115,7 +117,7 @@ Response putSync(@HeaderParam("accept") String accept, @BodyParam("applica @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getWithResponseAsync(RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.get(accept, requestOptions, context)); + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); } /** @@ -138,7 +140,7 @@ public Mono> getWithResponseAsync(RequestOptions requestOpt @ServiceMethod(returns = ReturnType.SINGLE) public Response getWithResponse(RequestOptions requestOptions) { final String accept = "application/json"; - return service.getSync(accept, requestOptions, Context.NONE); + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); } /** @@ -161,8 +163,9 @@ public Response getWithResponse(RequestOptions requestOptions) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> putWithResponseAsync(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.put(accept, body, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.put(this.client.getEndpoint(), contentType, body, requestOptions, context)); } /** @@ -185,7 +188,7 @@ public Mono> putWithResponseAsync(BinaryData body, RequestOptions */ @ServiceMethod(returns = ReturnType.SINGLE) public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.putSync(accept, body, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/type/property/valuetypes/implementation/BytesImpl.java b/typespec-tests/src/main/java/com/type/property/valuetypes/implementation/BytesImpl.java index 97617c9762..517428e4ca 100644 --- a/typespec-tests/src/main/java/com/type/property/valuetypes/implementation/BytesImpl.java +++ b/typespec-tests/src/main/java/com/type/property/valuetypes/implementation/BytesImpl.java @@ -9,6 +9,7 @@ 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; @@ -54,7 +55,7 @@ public final class BytesImpl { * The interface defining all the services for ValueTypesClientBytes to be used by the proxy service to perform REST * calls. */ - @Host("http://localhost:3000") + @Host("{endpoint}") @ServiceInterface(name = "ValueTypesClientByte") public interface BytesService { @Get("/type/property/value-types/bytes") @@ -63,8 +64,8 @@ public interface BytesService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> get(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Get("/type/property/value-types/bytes") @ExpectedResponses({ 200 }) @@ -72,8 +73,8 @@ Mono> get(@HeaderParam("accept") String accept, RequestOpti @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response getSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Put("/type/property/value-types/bytes") @ExpectedResponses({ 204 }) @@ -81,7 +82,8 @@ Response getSync(@HeaderParam("accept") String accept, RequestOption @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> put(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, + 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") @@ -90,8 +92,8 @@ Mono> put(@HeaderParam("accept") String accept, @BodyParam("appli @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response putSync(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, - RequestOptions requestOptions, Context context); + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); } /** @@ -114,7 +116,7 @@ Response putSync(@HeaderParam("accept") String accept, @BodyParam("applica @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getWithResponseAsync(RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.get(accept, requestOptions, context)); + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); } /** @@ -137,7 +139,7 @@ public Mono> getWithResponseAsync(RequestOptions requestOpt @ServiceMethod(returns = ReturnType.SINGLE) public Response getWithResponse(RequestOptions requestOptions) { final String accept = "application/json"; - return service.getSync(accept, requestOptions, Context.NONE); + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); } /** @@ -160,8 +162,9 @@ public Response getWithResponse(RequestOptions requestOptions) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> putWithResponseAsync(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.put(accept, body, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.put(this.client.getEndpoint(), contentType, body, requestOptions, context)); } /** @@ -184,7 +187,7 @@ public Mono> putWithResponseAsync(BinaryData body, RequestOptions */ @ServiceMethod(returns = ReturnType.SINGLE) public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.putSync(accept, body, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/type/property/valuetypes/implementation/CollectionsIntsImpl.java b/typespec-tests/src/main/java/com/type/property/valuetypes/implementation/CollectionsIntsImpl.java index 8b66c952ac..a91f37333d 100644 --- a/typespec-tests/src/main/java/com/type/property/valuetypes/implementation/CollectionsIntsImpl.java +++ b/typespec-tests/src/main/java/com/type/property/valuetypes/implementation/CollectionsIntsImpl.java @@ -9,6 +9,7 @@ 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; @@ -55,7 +56,7 @@ public final class CollectionsIntsImpl { * The interface defining all the services for ValueTypesClientCollectionsInts to be used by the proxy service to * perform REST calls. */ - @Host("http://localhost:3000") + @Host("{endpoint}") @ServiceInterface(name = "ValueTypesClientColl") public interface CollectionsIntsService { @Get("/type/property/value-types/collections/int") @@ -64,8 +65,8 @@ public interface CollectionsIntsService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> get(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Get("/type/property/value-types/collections/int") @ExpectedResponses({ 200 }) @@ -73,8 +74,8 @@ Mono> get(@HeaderParam("accept") String accept, RequestOpti @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response getSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Put("/type/property/value-types/collections/int") @ExpectedResponses({ 204 }) @@ -82,7 +83,8 @@ Response getSync(@HeaderParam("accept") String accept, RequestOption @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> put(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, + 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") @@ -91,8 +93,8 @@ Mono> put(@HeaderParam("accept") String accept, @BodyParam("appli @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response putSync(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, - RequestOptions requestOptions, Context context); + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); } /** @@ -117,7 +119,7 @@ Response putSync(@HeaderParam("accept") String accept, @BodyParam("applica @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getWithResponseAsync(RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.get(accept, requestOptions, context)); + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); } /** @@ -142,7 +144,7 @@ public Mono> getWithResponseAsync(RequestOptions requestOpt @ServiceMethod(returns = ReturnType.SINGLE) public Response getWithResponse(RequestOptions requestOptions) { final String accept = "application/json"; - return service.getSync(accept, requestOptions, Context.NONE); + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); } /** @@ -167,8 +169,9 @@ public Response getWithResponse(RequestOptions requestOptions) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> putWithResponseAsync(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.put(accept, body, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.put(this.client.getEndpoint(), contentType, body, requestOptions, context)); } /** @@ -193,7 +196,7 @@ public Mono> putWithResponseAsync(BinaryData body, RequestOptions */ @ServiceMethod(returns = ReturnType.SINGLE) public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.putSync(accept, body, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/type/property/valuetypes/implementation/CollectionsModelsImpl.java b/typespec-tests/src/main/java/com/type/property/valuetypes/implementation/CollectionsModelsImpl.java index a37cc3bed6..791cce1929 100644 --- a/typespec-tests/src/main/java/com/type/property/valuetypes/implementation/CollectionsModelsImpl.java +++ b/typespec-tests/src/main/java/com/type/property/valuetypes/implementation/CollectionsModelsImpl.java @@ -9,6 +9,7 @@ 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; @@ -55,7 +56,7 @@ public final class CollectionsModelsImpl { * The interface defining all the services for ValueTypesClientCollectionsModels to be used by the proxy service to * perform REST calls. */ - @Host("http://localhost:3000") + @Host("{endpoint}") @ServiceInterface(name = "ValueTypesClientColl") public interface CollectionsModelsService { @Get("/type/property/value-types/collections/model") @@ -64,8 +65,8 @@ public interface CollectionsModelsService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> get(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Get("/type/property/value-types/collections/model") @ExpectedResponses({ 200 }) @@ -73,8 +74,8 @@ Mono> get(@HeaderParam("accept") String accept, RequestOpti @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response getSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Put("/type/property/value-types/collections/model") @ExpectedResponses({ 204 }) @@ -82,7 +83,8 @@ Response getSync(@HeaderParam("accept") String accept, RequestOption @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> put(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, + 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") @@ -91,8 +93,8 @@ Mono> put(@HeaderParam("accept") String accept, @BodyParam("appli @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response putSync(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, - RequestOptions requestOptions, Context context); + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); } /** @@ -119,7 +121,7 @@ Response putSync(@HeaderParam("accept") String accept, @BodyParam("applica @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getWithResponseAsync(RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.get(accept, requestOptions, context)); + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); } /** @@ -146,7 +148,7 @@ public Mono> getWithResponseAsync(RequestOptions requestOpt @ServiceMethod(returns = ReturnType.SINGLE) public Response getWithResponse(RequestOptions requestOptions) { final String accept = "application/json"; - return service.getSync(accept, requestOptions, Context.NONE); + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); } /** @@ -173,8 +175,9 @@ public Response getWithResponse(RequestOptions requestOptions) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> putWithResponseAsync(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.put(accept, body, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.put(this.client.getEndpoint(), contentType, body, requestOptions, context)); } /** @@ -201,7 +204,7 @@ public Mono> putWithResponseAsync(BinaryData body, RequestOptions */ @ServiceMethod(returns = ReturnType.SINGLE) public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.putSync(accept, body, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/type/property/valuetypes/implementation/CollectionsStringsImpl.java b/typespec-tests/src/main/java/com/type/property/valuetypes/implementation/CollectionsStringsImpl.java index a762c83dd6..a67d59771e 100644 --- a/typespec-tests/src/main/java/com/type/property/valuetypes/implementation/CollectionsStringsImpl.java +++ b/typespec-tests/src/main/java/com/type/property/valuetypes/implementation/CollectionsStringsImpl.java @@ -9,6 +9,7 @@ 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; @@ -55,7 +56,7 @@ public final class CollectionsStringsImpl { * The interface defining all the services for ValueTypesClientCollectionsStrings to be used by the proxy service to * perform REST calls. */ - @Host("http://localhost:3000") + @Host("{endpoint}") @ServiceInterface(name = "ValueTypesClientColl") public interface CollectionsStringsService { @Get("/type/property/value-types/collections/string") @@ -64,8 +65,8 @@ public interface CollectionsStringsService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> get(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Get("/type/property/value-types/collections/string") @ExpectedResponses({ 200 }) @@ -73,8 +74,8 @@ Mono> get(@HeaderParam("accept") String accept, RequestOpti @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response getSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Put("/type/property/value-types/collections/string") @ExpectedResponses({ 204 }) @@ -82,7 +83,8 @@ Response getSync(@HeaderParam("accept") String accept, RequestOption @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> put(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, + 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") @@ -91,8 +93,8 @@ Mono> put(@HeaderParam("accept") String accept, @BodyParam("appli @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response putSync(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, - RequestOptions requestOptions, Context context); + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); } /** @@ -117,7 +119,7 @@ Response putSync(@HeaderParam("accept") String accept, @BodyParam("applica @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getWithResponseAsync(RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.get(accept, requestOptions, context)); + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); } /** @@ -142,7 +144,7 @@ public Mono> getWithResponseAsync(RequestOptions requestOpt @ServiceMethod(returns = ReturnType.SINGLE) public Response getWithResponse(RequestOptions requestOptions) { final String accept = "application/json"; - return service.getSync(accept, requestOptions, Context.NONE); + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); } /** @@ -167,8 +169,9 @@ public Response getWithResponse(RequestOptions requestOptions) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> putWithResponseAsync(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.put(accept, body, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.put(this.client.getEndpoint(), contentType, body, requestOptions, context)); } /** @@ -193,7 +196,7 @@ public Mono> putWithResponseAsync(BinaryData body, RequestOptions */ @ServiceMethod(returns = ReturnType.SINGLE) public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.putSync(accept, body, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/type/property/valuetypes/implementation/DatetimeOperationsImpl.java b/typespec-tests/src/main/java/com/type/property/valuetypes/implementation/DatetimeOperationsImpl.java index d8e9cd6481..592c4019b5 100644 --- a/typespec-tests/src/main/java/com/type/property/valuetypes/implementation/DatetimeOperationsImpl.java +++ b/typespec-tests/src/main/java/com/type/property/valuetypes/implementation/DatetimeOperationsImpl.java @@ -9,6 +9,7 @@ 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; @@ -55,7 +56,7 @@ public final class DatetimeOperationsImpl { * The interface defining all the services for ValueTypesClientDatetimeOperations to be used by the proxy service to * perform REST calls. */ - @Host("http://localhost:3000") + @Host("{endpoint}") @ServiceInterface(name = "ValueTypesClientDate") public interface DatetimeOperationsService { @Get("/type/property/value-types/datetime") @@ -64,8 +65,8 @@ public interface DatetimeOperationsService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> get(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Get("/type/property/value-types/datetime") @ExpectedResponses({ 200 }) @@ -73,8 +74,8 @@ Mono> get(@HeaderParam("accept") String accept, RequestOpti @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response getSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Put("/type/property/value-types/datetime") @ExpectedResponses({ 204 }) @@ -82,7 +83,8 @@ Response getSync(@HeaderParam("accept") String accept, RequestOption @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> put(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, + 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") @@ -91,8 +93,8 @@ Mono> put(@HeaderParam("accept") String accept, @BodyParam("appli @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response putSync(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, - RequestOptions requestOptions, Context context); + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); } /** @@ -115,7 +117,7 @@ Response putSync(@HeaderParam("accept") String accept, @BodyParam("applica @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getWithResponseAsync(RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.get(accept, requestOptions, context)); + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); } /** @@ -138,7 +140,7 @@ public Mono> getWithResponseAsync(RequestOptions requestOpt @ServiceMethod(returns = ReturnType.SINGLE) public Response getWithResponse(RequestOptions requestOptions) { final String accept = "application/json"; - return service.getSync(accept, requestOptions, Context.NONE); + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); } /** @@ -161,8 +163,9 @@ public Response getWithResponse(RequestOptions requestOptions) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> putWithResponseAsync(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.put(accept, body, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.put(this.client.getEndpoint(), contentType, body, requestOptions, context)); } /** @@ -185,7 +188,7 @@ public Mono> putWithResponseAsync(BinaryData body, RequestOptions */ @ServiceMethod(returns = ReturnType.SINGLE) public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.putSync(accept, body, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/type/property/valuetypes/implementation/Decimal128sImpl.java b/typespec-tests/src/main/java/com/type/property/valuetypes/implementation/Decimal128sImpl.java index 2e5bb88c9d..b7a90b185b 100644 --- a/typespec-tests/src/main/java/com/type/property/valuetypes/implementation/Decimal128sImpl.java +++ b/typespec-tests/src/main/java/com/type/property/valuetypes/implementation/Decimal128sImpl.java @@ -9,6 +9,7 @@ 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; @@ -55,7 +56,7 @@ public final class Decimal128sImpl { * The interface defining all the services for ValueTypesClientDecimal128s to be used by the proxy service to * perform REST calls. */ - @Host("http://localhost:3000") + @Host("{endpoint}") @ServiceInterface(name = "ValueTypesClientDeci") public interface Decimal128sService { @Get("/type/property/value-types/decimal128") @@ -64,8 +65,8 @@ public interface Decimal128sService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> get(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Get("/type/property/value-types/decimal128") @ExpectedResponses({ 200 }) @@ -73,8 +74,8 @@ Mono> get(@HeaderParam("accept") String accept, RequestOpti @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response getSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Put("/type/property/value-types/decimal128") @ExpectedResponses({ 204 }) @@ -82,7 +83,8 @@ Response getSync(@HeaderParam("accept") String accept, RequestOption @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> put(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, + 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") @@ -91,8 +93,8 @@ Mono> put(@HeaderParam("accept") String accept, @BodyParam("appli @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response putSync(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, - RequestOptions requestOptions, Context context); + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); } /** @@ -115,7 +117,7 @@ Response putSync(@HeaderParam("accept") String accept, @BodyParam("applica @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getWithResponseAsync(RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.get(accept, requestOptions, context)); + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); } /** @@ -138,7 +140,7 @@ public Mono> getWithResponseAsync(RequestOptions requestOpt @ServiceMethod(returns = ReturnType.SINGLE) public Response getWithResponse(RequestOptions requestOptions) { final String accept = "application/json"; - return service.getSync(accept, requestOptions, Context.NONE); + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); } /** @@ -161,8 +163,9 @@ public Response getWithResponse(RequestOptions requestOptions) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> putWithResponseAsync(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.put(accept, body, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.put(this.client.getEndpoint(), contentType, body, requestOptions, context)); } /** @@ -185,7 +188,7 @@ public Mono> putWithResponseAsync(BinaryData body, RequestOptions */ @ServiceMethod(returns = ReturnType.SINGLE) public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.putSync(accept, body, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/type/property/valuetypes/implementation/DecimalsImpl.java b/typespec-tests/src/main/java/com/type/property/valuetypes/implementation/DecimalsImpl.java index ed97eb861f..9de39e4d74 100644 --- a/typespec-tests/src/main/java/com/type/property/valuetypes/implementation/DecimalsImpl.java +++ b/typespec-tests/src/main/java/com/type/property/valuetypes/implementation/DecimalsImpl.java @@ -9,6 +9,7 @@ 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; @@ -54,7 +55,7 @@ public final class DecimalsImpl { * The interface defining all the services for ValueTypesClientDecimals to be used by the proxy service to perform * REST calls. */ - @Host("http://localhost:3000") + @Host("{endpoint}") @ServiceInterface(name = "ValueTypesClientDeci") public interface DecimalsService { @Get("/type/property/value-types/decimal") @@ -63,8 +64,8 @@ public interface DecimalsService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> get(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Get("/type/property/value-types/decimal") @ExpectedResponses({ 200 }) @@ -72,8 +73,8 @@ Mono> get(@HeaderParam("accept") String accept, RequestOpti @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response getSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Put("/type/property/value-types/decimal") @ExpectedResponses({ 204 }) @@ -81,7 +82,8 @@ Response getSync(@HeaderParam("accept") String accept, RequestOption @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> put(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, + 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") @@ -90,8 +92,8 @@ Mono> put(@HeaderParam("accept") String accept, @BodyParam("appli @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response putSync(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, - RequestOptions requestOptions, Context context); + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); } /** @@ -114,7 +116,7 @@ Response putSync(@HeaderParam("accept") String accept, @BodyParam("applica @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getWithResponseAsync(RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.get(accept, requestOptions, context)); + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); } /** @@ -137,7 +139,7 @@ public Mono> getWithResponseAsync(RequestOptions requestOpt @ServiceMethod(returns = ReturnType.SINGLE) public Response getWithResponse(RequestOptions requestOptions) { final String accept = "application/json"; - return service.getSync(accept, requestOptions, Context.NONE); + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); } /** @@ -160,8 +162,9 @@ public Response getWithResponse(RequestOptions requestOptions) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> putWithResponseAsync(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.put(accept, body, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.put(this.client.getEndpoint(), contentType, body, requestOptions, context)); } /** @@ -184,7 +187,7 @@ public Mono> putWithResponseAsync(BinaryData body, RequestOptions */ @ServiceMethod(returns = ReturnType.SINGLE) public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.putSync(accept, body, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/type/property/valuetypes/implementation/DictionaryStringsImpl.java b/typespec-tests/src/main/java/com/type/property/valuetypes/implementation/DictionaryStringsImpl.java index ba0e9667f8..e9bbea5562 100644 --- a/typespec-tests/src/main/java/com/type/property/valuetypes/implementation/DictionaryStringsImpl.java +++ b/typespec-tests/src/main/java/com/type/property/valuetypes/implementation/DictionaryStringsImpl.java @@ -9,6 +9,7 @@ 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; @@ -55,7 +56,7 @@ public final class DictionaryStringsImpl { * The interface defining all the services for ValueTypesClientDictionaryStrings to be used by the proxy service to * perform REST calls. */ - @Host("http://localhost:3000") + @Host("{endpoint}") @ServiceInterface(name = "ValueTypesClientDict") public interface DictionaryStringsService { @Get("/type/property/value-types/dictionary/string") @@ -64,8 +65,8 @@ public interface DictionaryStringsService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> get(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Get("/type/property/value-types/dictionary/string") @ExpectedResponses({ 200 }) @@ -73,8 +74,8 @@ Mono> get(@HeaderParam("accept") String accept, RequestOpti @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response getSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Put("/type/property/value-types/dictionary/string") @ExpectedResponses({ 204 }) @@ -82,7 +83,8 @@ Response getSync(@HeaderParam("accept") String accept, RequestOption @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> put(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, + 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") @@ -91,8 +93,8 @@ Mono> put(@HeaderParam("accept") String accept, @BodyParam("appli @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response putSync(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, - RequestOptions requestOptions, Context context); + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); } /** @@ -117,7 +119,7 @@ Response putSync(@HeaderParam("accept") String accept, @BodyParam("applica @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getWithResponseAsync(RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.get(accept, requestOptions, context)); + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); } /** @@ -142,7 +144,7 @@ public Mono> getWithResponseAsync(RequestOptions requestOpt @ServiceMethod(returns = ReturnType.SINGLE) public Response getWithResponse(RequestOptions requestOptions) { final String accept = "application/json"; - return service.getSync(accept, requestOptions, Context.NONE); + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); } /** @@ -167,8 +169,9 @@ public Response getWithResponse(RequestOptions requestOptions) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> putWithResponseAsync(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.put(accept, body, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.put(this.client.getEndpoint(), contentType, body, requestOptions, context)); } /** @@ -193,7 +196,7 @@ public Mono> putWithResponseAsync(BinaryData body, RequestOptions */ @ServiceMethod(returns = ReturnType.SINGLE) public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.putSync(accept, body, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/type/property/valuetypes/implementation/DurationOperationsImpl.java b/typespec-tests/src/main/java/com/type/property/valuetypes/implementation/DurationOperationsImpl.java index 1103d13826..cdf87b14a1 100644 --- a/typespec-tests/src/main/java/com/type/property/valuetypes/implementation/DurationOperationsImpl.java +++ b/typespec-tests/src/main/java/com/type/property/valuetypes/implementation/DurationOperationsImpl.java @@ -9,6 +9,7 @@ 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; @@ -55,7 +56,7 @@ public final class DurationOperationsImpl { * The interface defining all the services for ValueTypesClientDurationOperations to be used by the proxy service to * perform REST calls. */ - @Host("http://localhost:3000") + @Host("{endpoint}") @ServiceInterface(name = "ValueTypesClientDura") public interface DurationOperationsService { @Get("/type/property/value-types/duration") @@ -64,8 +65,8 @@ public interface DurationOperationsService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> get(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Get("/type/property/value-types/duration") @ExpectedResponses({ 200 }) @@ -73,8 +74,8 @@ Mono> get(@HeaderParam("accept") String accept, RequestOpti @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response getSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Put("/type/property/value-types/duration") @ExpectedResponses({ 204 }) @@ -82,7 +83,8 @@ Response getSync(@HeaderParam("accept") String accept, RequestOption @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> put(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, + 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") @@ -91,8 +93,8 @@ Mono> put(@HeaderParam("accept") String accept, @BodyParam("appli @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response putSync(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, - RequestOptions requestOptions, Context context); + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); } /** @@ -115,7 +117,7 @@ Response putSync(@HeaderParam("accept") String accept, @BodyParam("applica @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getWithResponseAsync(RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.get(accept, requestOptions, context)); + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); } /** @@ -138,7 +140,7 @@ public Mono> getWithResponseAsync(RequestOptions requestOpt @ServiceMethod(returns = ReturnType.SINGLE) public Response getWithResponse(RequestOptions requestOptions) { final String accept = "application/json"; - return service.getSync(accept, requestOptions, Context.NONE); + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); } /** @@ -161,8 +163,9 @@ public Response getWithResponse(RequestOptions requestOptions) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> putWithResponseAsync(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.put(accept, body, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.put(this.client.getEndpoint(), contentType, body, requestOptions, context)); } /** @@ -185,7 +188,7 @@ public Mono> putWithResponseAsync(BinaryData body, RequestOptions */ @ServiceMethod(returns = ReturnType.SINGLE) public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.putSync(accept, body, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/type/property/valuetypes/implementation/EnumsImpl.java b/typespec-tests/src/main/java/com/type/property/valuetypes/implementation/EnumsImpl.java index d46ce8bb8c..f62709f9d9 100644 --- a/typespec-tests/src/main/java/com/type/property/valuetypes/implementation/EnumsImpl.java +++ b/typespec-tests/src/main/java/com/type/property/valuetypes/implementation/EnumsImpl.java @@ -9,6 +9,7 @@ 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; @@ -54,7 +55,7 @@ public final class EnumsImpl { * The interface defining all the services for ValueTypesClientEnums to be used by the proxy service to perform REST * calls. */ - @Host("http://localhost:3000") + @Host("{endpoint}") @ServiceInterface(name = "ValueTypesClientEnum") public interface EnumsService { @Get("/type/property/value-types/enum") @@ -63,8 +64,8 @@ public interface EnumsService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> get(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Get("/type/property/value-types/enum") @ExpectedResponses({ 200 }) @@ -72,8 +73,8 @@ Mono> get(@HeaderParam("accept") String accept, RequestOpti @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response getSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Put("/type/property/value-types/enum") @ExpectedResponses({ 204 }) @@ -81,7 +82,8 @@ Response getSync(@HeaderParam("accept") String accept, RequestOption @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> put(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, + 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") @@ -90,8 +92,8 @@ Mono> put(@HeaderParam("accept") String accept, @BodyParam("appli @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response putSync(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, - RequestOptions requestOptions, Context context); + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); } /** @@ -114,7 +116,7 @@ Response putSync(@HeaderParam("accept") String accept, @BodyParam("applica @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getWithResponseAsync(RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.get(accept, requestOptions, context)); + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); } /** @@ -137,7 +139,7 @@ public Mono> getWithResponseAsync(RequestOptions requestOpt @ServiceMethod(returns = ReturnType.SINGLE) public Response getWithResponse(RequestOptions requestOptions) { final String accept = "application/json"; - return service.getSync(accept, requestOptions, Context.NONE); + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); } /** @@ -160,8 +162,9 @@ public Response getWithResponse(RequestOptions requestOptions) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> putWithResponseAsync(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.put(accept, body, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.put(this.client.getEndpoint(), contentType, body, requestOptions, context)); } /** @@ -184,7 +187,7 @@ public Mono> putWithResponseAsync(BinaryData body, RequestOptions */ @ServiceMethod(returns = ReturnType.SINGLE) public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.putSync(accept, body, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/type/property/valuetypes/implementation/ExtensibleEnumsImpl.java b/typespec-tests/src/main/java/com/type/property/valuetypes/implementation/ExtensibleEnumsImpl.java index 9c571604fa..6146f83517 100644 --- a/typespec-tests/src/main/java/com/type/property/valuetypes/implementation/ExtensibleEnumsImpl.java +++ b/typespec-tests/src/main/java/com/type/property/valuetypes/implementation/ExtensibleEnumsImpl.java @@ -9,6 +9,7 @@ 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; @@ -55,7 +56,7 @@ public final class ExtensibleEnumsImpl { * The interface defining all the services for ValueTypesClientExtensibleEnums to be used by the proxy service to * perform REST calls. */ - @Host("http://localhost:3000") + @Host("{endpoint}") @ServiceInterface(name = "ValueTypesClientExte") public interface ExtensibleEnumsService { @Get("/type/property/value-types/extensible-enum") @@ -64,8 +65,8 @@ public interface ExtensibleEnumsService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> get(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Get("/type/property/value-types/extensible-enum") @ExpectedResponses({ 200 }) @@ -73,8 +74,8 @@ Mono> get(@HeaderParam("accept") String accept, RequestOpti @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response getSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Put("/type/property/value-types/extensible-enum") @ExpectedResponses({ 204 }) @@ -82,7 +83,8 @@ Response getSync(@HeaderParam("accept") String accept, RequestOption @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> put(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, + 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") @@ -91,8 +93,8 @@ Mono> put(@HeaderParam("accept") String accept, @BodyParam("appli @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response putSync(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, - RequestOptions requestOptions, Context context); + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); } /** @@ -115,7 +117,7 @@ Response putSync(@HeaderParam("accept") String accept, @BodyParam("applica @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getWithResponseAsync(RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.get(accept, requestOptions, context)); + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); } /** @@ -138,7 +140,7 @@ public Mono> getWithResponseAsync(RequestOptions requestOpt @ServiceMethod(returns = ReturnType.SINGLE) public Response getWithResponse(RequestOptions requestOptions) { final String accept = "application/json"; - return service.getSync(accept, requestOptions, Context.NONE); + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); } /** @@ -161,8 +163,9 @@ public Response getWithResponse(RequestOptions requestOptions) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> putWithResponseAsync(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.put(accept, body, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.put(this.client.getEndpoint(), contentType, body, requestOptions, context)); } /** @@ -185,7 +188,7 @@ public Mono> putWithResponseAsync(BinaryData body, RequestOptions */ @ServiceMethod(returns = ReturnType.SINGLE) public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.putSync(accept, body, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/type/property/valuetypes/implementation/FloatLiteralsImpl.java b/typespec-tests/src/main/java/com/type/property/valuetypes/implementation/FloatLiteralsImpl.java index f7774bca94..bd4c5042b2 100644 --- a/typespec-tests/src/main/java/com/type/property/valuetypes/implementation/FloatLiteralsImpl.java +++ b/typespec-tests/src/main/java/com/type/property/valuetypes/implementation/FloatLiteralsImpl.java @@ -9,6 +9,7 @@ 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; @@ -55,7 +56,7 @@ public final class FloatLiteralsImpl { * The interface defining all the services for ValueTypesClientFloatLiterals to be used by the proxy service to * perform REST calls. */ - @Host("http://localhost:3000") + @Host("{endpoint}") @ServiceInterface(name = "ValueTypesClientFloa") public interface FloatLiteralsService { @Get("/type/property/value-types/float/literal") @@ -64,8 +65,8 @@ public interface FloatLiteralsService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> get(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Get("/type/property/value-types/float/literal") @ExpectedResponses({ 200 }) @@ -73,8 +74,8 @@ Mono> get(@HeaderParam("accept") String accept, RequestOpti @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response getSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Put("/type/property/value-types/float/literal") @ExpectedResponses({ 204 }) @@ -82,7 +83,8 @@ Response getSync(@HeaderParam("accept") String accept, RequestOption @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> put(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, + 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") @@ -91,8 +93,8 @@ Mono> put(@HeaderParam("accept") String accept, @BodyParam("appli @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response putSync(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, - RequestOptions requestOptions, Context context); + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); } /** @@ -115,7 +117,7 @@ Response putSync(@HeaderParam("accept") String accept, @BodyParam("applica @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getWithResponseAsync(RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.get(accept, requestOptions, context)); + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); } /** @@ -138,7 +140,7 @@ public Mono> getWithResponseAsync(RequestOptions requestOpt @ServiceMethod(returns = ReturnType.SINGLE) public Response getWithResponse(RequestOptions requestOptions) { final String accept = "application/json"; - return service.getSync(accept, requestOptions, Context.NONE); + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); } /** @@ -161,8 +163,9 @@ public Response getWithResponse(RequestOptions requestOptions) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> putWithResponseAsync(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.put(accept, body, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.put(this.client.getEndpoint(), contentType, body, requestOptions, context)); } /** @@ -185,7 +188,7 @@ public Mono> putWithResponseAsync(BinaryData body, RequestOptions */ @ServiceMethod(returns = ReturnType.SINGLE) public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.putSync(accept, body, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/type/property/valuetypes/implementation/FloatOperationsImpl.java b/typespec-tests/src/main/java/com/type/property/valuetypes/implementation/FloatOperationsImpl.java index d0706e6297..4cc17f7625 100644 --- a/typespec-tests/src/main/java/com/type/property/valuetypes/implementation/FloatOperationsImpl.java +++ b/typespec-tests/src/main/java/com/type/property/valuetypes/implementation/FloatOperationsImpl.java @@ -9,6 +9,7 @@ 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; @@ -55,7 +56,7 @@ public final class FloatOperationsImpl { * The interface defining all the services for ValueTypesClientFloatOperations to be used by the proxy service to * perform REST calls. */ - @Host("http://localhost:3000") + @Host("{endpoint}") @ServiceInterface(name = "ValueTypesClientFloa") public interface FloatOperationsService { @Get("/type/property/value-types/float") @@ -64,8 +65,8 @@ public interface FloatOperationsService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> get(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Get("/type/property/value-types/float") @ExpectedResponses({ 200 }) @@ -73,8 +74,8 @@ Mono> get(@HeaderParam("accept") String accept, RequestOpti @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response getSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Put("/type/property/value-types/float") @ExpectedResponses({ 204 }) @@ -82,7 +83,8 @@ Response getSync(@HeaderParam("accept") String accept, RequestOption @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> put(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, + 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") @@ -91,8 +93,8 @@ Mono> put(@HeaderParam("accept") String accept, @BodyParam("appli @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response putSync(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, - RequestOptions requestOptions, Context context); + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); } /** @@ -115,7 +117,7 @@ Response putSync(@HeaderParam("accept") String accept, @BodyParam("applica @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getWithResponseAsync(RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.get(accept, requestOptions, context)); + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); } /** @@ -138,7 +140,7 @@ public Mono> getWithResponseAsync(RequestOptions requestOpt @ServiceMethod(returns = ReturnType.SINGLE) public Response getWithResponse(RequestOptions requestOptions) { final String accept = "application/json"; - return service.getSync(accept, requestOptions, Context.NONE); + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); } /** @@ -161,8 +163,9 @@ public Response getWithResponse(RequestOptions requestOptions) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> putWithResponseAsync(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.put(accept, body, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.put(this.client.getEndpoint(), contentType, body, requestOptions, context)); } /** @@ -185,7 +188,7 @@ public Mono> putWithResponseAsync(BinaryData body, RequestOptions */ @ServiceMethod(returns = ReturnType.SINGLE) public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.putSync(accept, body, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/type/property/valuetypes/implementation/IntLiteralsImpl.java b/typespec-tests/src/main/java/com/type/property/valuetypes/implementation/IntLiteralsImpl.java index 0b47e87d0f..2449786fd0 100644 --- a/typespec-tests/src/main/java/com/type/property/valuetypes/implementation/IntLiteralsImpl.java +++ b/typespec-tests/src/main/java/com/type/property/valuetypes/implementation/IntLiteralsImpl.java @@ -9,6 +9,7 @@ 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; @@ -55,7 +56,7 @@ public final class IntLiteralsImpl { * The interface defining all the services for ValueTypesClientIntLiterals to be used by the proxy service to * perform REST calls. */ - @Host("http://localhost:3000") + @Host("{endpoint}") @ServiceInterface(name = "ValueTypesClientIntL") public interface IntLiteralsService { @Get("/type/property/value-types/int/literal") @@ -64,8 +65,8 @@ public interface IntLiteralsService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> get(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Get("/type/property/value-types/int/literal") @ExpectedResponses({ 200 }) @@ -73,8 +74,8 @@ Mono> get(@HeaderParam("accept") String accept, RequestOpti @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response getSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Put("/type/property/value-types/int/literal") @ExpectedResponses({ 204 }) @@ -82,7 +83,8 @@ Response getSync(@HeaderParam("accept") String accept, RequestOption @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> put(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, + 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") @@ -91,8 +93,8 @@ Mono> put(@HeaderParam("accept") String accept, @BodyParam("appli @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response putSync(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, - RequestOptions requestOptions, Context context); + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); } /** @@ -115,7 +117,7 @@ Response putSync(@HeaderParam("accept") String accept, @BodyParam("applica @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getWithResponseAsync(RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.get(accept, requestOptions, context)); + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); } /** @@ -138,7 +140,7 @@ public Mono> getWithResponseAsync(RequestOptions requestOpt @ServiceMethod(returns = ReturnType.SINGLE) public Response getWithResponse(RequestOptions requestOptions) { final String accept = "application/json"; - return service.getSync(accept, requestOptions, Context.NONE); + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); } /** @@ -161,8 +163,9 @@ public Response getWithResponse(RequestOptions requestOptions) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> putWithResponseAsync(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.put(accept, body, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.put(this.client.getEndpoint(), contentType, body, requestOptions, context)); } /** @@ -185,7 +188,7 @@ public Mono> putWithResponseAsync(BinaryData body, RequestOptions */ @ServiceMethod(returns = ReturnType.SINGLE) public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.putSync(accept, body, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/type/property/valuetypes/implementation/IntsImpl.java b/typespec-tests/src/main/java/com/type/property/valuetypes/implementation/IntsImpl.java index b74d365f10..0a68ae4beb 100644 --- a/typespec-tests/src/main/java/com/type/property/valuetypes/implementation/IntsImpl.java +++ b/typespec-tests/src/main/java/com/type/property/valuetypes/implementation/IntsImpl.java @@ -9,6 +9,7 @@ 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; @@ -54,7 +55,7 @@ public final class IntsImpl { * The interface defining all the services for ValueTypesClientInts to be used by the proxy service to perform REST * calls. */ - @Host("http://localhost:3000") + @Host("{endpoint}") @ServiceInterface(name = "ValueTypesClientInts") public interface IntsService { @Get("/type/property/value-types/int") @@ -63,8 +64,8 @@ public interface IntsService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> get(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Get("/type/property/value-types/int") @ExpectedResponses({ 200 }) @@ -72,8 +73,8 @@ Mono> get(@HeaderParam("accept") String accept, RequestOpti @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response getSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Put("/type/property/value-types/int") @ExpectedResponses({ 204 }) @@ -81,7 +82,8 @@ Response getSync(@HeaderParam("accept") String accept, RequestOption @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> put(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, + 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") @@ -90,8 +92,8 @@ Mono> put(@HeaderParam("accept") String accept, @BodyParam("appli @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response putSync(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, - RequestOptions requestOptions, Context context); + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); } /** @@ -114,7 +116,7 @@ Response putSync(@HeaderParam("accept") String accept, @BodyParam("applica @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getWithResponseAsync(RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.get(accept, requestOptions, context)); + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); } /** @@ -137,7 +139,7 @@ public Mono> getWithResponseAsync(RequestOptions requestOpt @ServiceMethod(returns = ReturnType.SINGLE) public Response getWithResponse(RequestOptions requestOptions) { final String accept = "application/json"; - return service.getSync(accept, requestOptions, Context.NONE); + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); } /** @@ -160,8 +162,9 @@ public Response getWithResponse(RequestOptions requestOptions) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> putWithResponseAsync(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.put(accept, body, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.put(this.client.getEndpoint(), contentType, body, requestOptions, context)); } /** @@ -184,7 +187,7 @@ public Mono> putWithResponseAsync(BinaryData body, RequestOptions */ @ServiceMethod(returns = ReturnType.SINGLE) public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.putSync(accept, body, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/type/property/valuetypes/implementation/ModelsImpl.java b/typespec-tests/src/main/java/com/type/property/valuetypes/implementation/ModelsImpl.java index 475388e54f..04d5f18673 100644 --- a/typespec-tests/src/main/java/com/type/property/valuetypes/implementation/ModelsImpl.java +++ b/typespec-tests/src/main/java/com/type/property/valuetypes/implementation/ModelsImpl.java @@ -9,6 +9,7 @@ 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; @@ -54,7 +55,7 @@ public final class ModelsImpl { * The interface defining all the services for ValueTypesClientModels to be used by the proxy service to perform * REST calls. */ - @Host("http://localhost:3000") + @Host("{endpoint}") @ServiceInterface(name = "ValueTypesClientMode") public interface ModelsService { @Get("/type/property/value-types/model") @@ -63,8 +64,8 @@ public interface ModelsService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> get(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Get("/type/property/value-types/model") @ExpectedResponses({ 200 }) @@ -72,8 +73,8 @@ Mono> get(@HeaderParam("accept") String accept, RequestOpti @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response getSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Put("/type/property/value-types/model") @ExpectedResponses({ 204 }) @@ -81,7 +82,8 @@ Response getSync(@HeaderParam("accept") String accept, RequestOption @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> put(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, + 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") @@ -90,8 +92,8 @@ Mono> put(@HeaderParam("accept") String accept, @BodyParam("appli @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response putSync(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, - RequestOptions requestOptions, Context context); + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); } /** @@ -116,7 +118,7 @@ Response putSync(@HeaderParam("accept") String accept, @BodyParam("applica @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getWithResponseAsync(RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.get(accept, requestOptions, context)); + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); } /** @@ -141,7 +143,7 @@ public Mono> getWithResponseAsync(RequestOptions requestOpt @ServiceMethod(returns = ReturnType.SINGLE) public Response getWithResponse(RequestOptions requestOptions) { final String accept = "application/json"; - return service.getSync(accept, requestOptions, Context.NONE); + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); } /** @@ -166,8 +168,9 @@ public Response getWithResponse(RequestOptions requestOptions) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> putWithResponseAsync(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.put(accept, body, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.put(this.client.getEndpoint(), contentType, body, requestOptions, context)); } /** @@ -192,7 +195,7 @@ public Mono> putWithResponseAsync(BinaryData body, RequestOptions */ @ServiceMethod(returns = ReturnType.SINGLE) public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.putSync(accept, body, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/type/property/valuetypes/implementation/NeversImpl.java b/typespec-tests/src/main/java/com/type/property/valuetypes/implementation/NeversImpl.java index 0ee5812b2a..ab363c68ce 100644 --- a/typespec-tests/src/main/java/com/type/property/valuetypes/implementation/NeversImpl.java +++ b/typespec-tests/src/main/java/com/type/property/valuetypes/implementation/NeversImpl.java @@ -9,6 +9,7 @@ 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; @@ -54,7 +55,7 @@ public final class NeversImpl { * The interface defining all the services for ValueTypesClientNevers to be used by the proxy service to perform * REST calls. */ - @Host("http://localhost:3000") + @Host("{endpoint}") @ServiceInterface(name = "ValueTypesClientNeve") public interface NeversService { @Get("/type/property/value-types/never") @@ -63,8 +64,8 @@ public interface NeversService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> get(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Get("/type/property/value-types/never") @ExpectedResponses({ 200 }) @@ -72,8 +73,8 @@ Mono> get(@HeaderParam("accept") String accept, RequestOpti @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response getSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Put("/type/property/value-types/never") @ExpectedResponses({ 204 }) @@ -81,7 +82,8 @@ Response getSync(@HeaderParam("accept") String accept, RequestOption @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> put(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, + 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") @@ -90,8 +92,8 @@ Mono> put(@HeaderParam("accept") String accept, @BodyParam("appli @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response putSync(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, - RequestOptions requestOptions, Context context); + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); } /** @@ -112,7 +114,7 @@ Response putSync(@HeaderParam("accept") String accept, @BodyParam("applica @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getWithResponseAsync(RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.get(accept, requestOptions, context)); + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); } /** @@ -133,7 +135,7 @@ public Mono> getWithResponseAsync(RequestOptions requestOpt @ServiceMethod(returns = ReturnType.SINGLE) public Response getWithResponse(RequestOptions requestOptions) { final String accept = "application/json"; - return service.getSync(accept, requestOptions, Context.NONE); + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); } /** @@ -154,8 +156,9 @@ public Response getWithResponse(RequestOptions requestOptions) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> putWithResponseAsync(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.put(accept, body, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.put(this.client.getEndpoint(), contentType, body, requestOptions, context)); } /** @@ -176,7 +179,7 @@ public Mono> putWithResponseAsync(BinaryData body, RequestOptions */ @ServiceMethod(returns = ReturnType.SINGLE) public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.putSync(accept, body, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/type/property/valuetypes/implementation/StringLiteralsImpl.java b/typespec-tests/src/main/java/com/type/property/valuetypes/implementation/StringLiteralsImpl.java index 925cfbc34b..f0cfae22a2 100644 --- a/typespec-tests/src/main/java/com/type/property/valuetypes/implementation/StringLiteralsImpl.java +++ b/typespec-tests/src/main/java/com/type/property/valuetypes/implementation/StringLiteralsImpl.java @@ -9,6 +9,7 @@ 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; @@ -55,7 +56,7 @@ public final class StringLiteralsImpl { * The interface defining all the services for ValueTypesClientStringLiterals to be used by the proxy service to * perform REST calls. */ - @Host("http://localhost:3000") + @Host("{endpoint}") @ServiceInterface(name = "ValueTypesClientStri") public interface StringLiteralsService { @Get("/type/property/value-types/string/literal") @@ -64,8 +65,8 @@ public interface StringLiteralsService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> get(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Get("/type/property/value-types/string/literal") @ExpectedResponses({ 200 }) @@ -73,8 +74,8 @@ Mono> get(@HeaderParam("accept") String accept, RequestOpti @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response getSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Put("/type/property/value-types/string/literal") @ExpectedResponses({ 204 }) @@ -82,7 +83,8 @@ Response getSync(@HeaderParam("accept") String accept, RequestOption @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> put(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, + 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") @@ -91,8 +93,8 @@ Mono> put(@HeaderParam("accept") String accept, @BodyParam("appli @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response putSync(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, - RequestOptions requestOptions, Context context); + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); } /** @@ -115,7 +117,7 @@ Response putSync(@HeaderParam("accept") String accept, @BodyParam("applica @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getWithResponseAsync(RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.get(accept, requestOptions, context)); + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); } /** @@ -138,7 +140,7 @@ public Mono> getWithResponseAsync(RequestOptions requestOpt @ServiceMethod(returns = ReturnType.SINGLE) public Response getWithResponse(RequestOptions requestOptions) { final String accept = "application/json"; - return service.getSync(accept, requestOptions, Context.NONE); + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); } /** @@ -161,8 +163,9 @@ public Response getWithResponse(RequestOptions requestOptions) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> putWithResponseAsync(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.put(accept, body, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.put(this.client.getEndpoint(), contentType, body, requestOptions, context)); } /** @@ -185,7 +188,7 @@ public Mono> putWithResponseAsync(BinaryData body, RequestOptions */ @ServiceMethod(returns = ReturnType.SINGLE) public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.putSync(accept, body, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/type/property/valuetypes/implementation/StringOperationsImpl.java b/typespec-tests/src/main/java/com/type/property/valuetypes/implementation/StringOperationsImpl.java index 0a14991592..437a592659 100644 --- a/typespec-tests/src/main/java/com/type/property/valuetypes/implementation/StringOperationsImpl.java +++ b/typespec-tests/src/main/java/com/type/property/valuetypes/implementation/StringOperationsImpl.java @@ -9,6 +9,7 @@ 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; @@ -55,7 +56,7 @@ public final class StringOperationsImpl { * The interface defining all the services for ValueTypesClientStringOperations to be used by the proxy service to * perform REST calls. */ - @Host("http://localhost:3000") + @Host("{endpoint}") @ServiceInterface(name = "ValueTypesClientStri") public interface StringOperationsService { @Get("/type/property/value-types/string") @@ -64,8 +65,8 @@ public interface StringOperationsService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> get(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Get("/type/property/value-types/string") @ExpectedResponses({ 200 }) @@ -73,8 +74,8 @@ Mono> get(@HeaderParam("accept") String accept, RequestOpti @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response getSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Put("/type/property/value-types/string") @ExpectedResponses({ 204 }) @@ -82,7 +83,8 @@ Response getSync(@HeaderParam("accept") String accept, RequestOption @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> put(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, + 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") @@ -91,8 +93,8 @@ Mono> put(@HeaderParam("accept") String accept, @BodyParam("appli @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response putSync(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, - RequestOptions requestOptions, Context context); + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); } /** @@ -115,7 +117,7 @@ Response putSync(@HeaderParam("accept") String accept, @BodyParam("applica @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getWithResponseAsync(RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.get(accept, requestOptions, context)); + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); } /** @@ -138,7 +140,7 @@ public Mono> getWithResponseAsync(RequestOptions requestOpt @ServiceMethod(returns = ReturnType.SINGLE) public Response getWithResponse(RequestOptions requestOptions) { final String accept = "application/json"; - return service.getSync(accept, requestOptions, Context.NONE); + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); } /** @@ -161,8 +163,9 @@ public Response getWithResponse(RequestOptions requestOptions) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> putWithResponseAsync(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.put(accept, body, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.put(this.client.getEndpoint(), contentType, body, requestOptions, context)); } /** @@ -185,7 +188,7 @@ public Mono> putWithResponseAsync(BinaryData body, RequestOptions */ @ServiceMethod(returns = ReturnType.SINGLE) public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.putSync(accept, body, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/type/property/valuetypes/implementation/UnionEnumValuesImpl.java b/typespec-tests/src/main/java/com/type/property/valuetypes/implementation/UnionEnumValuesImpl.java index d134e37823..c18f9dc2cc 100644 --- a/typespec-tests/src/main/java/com/type/property/valuetypes/implementation/UnionEnumValuesImpl.java +++ b/typespec-tests/src/main/java/com/type/property/valuetypes/implementation/UnionEnumValuesImpl.java @@ -9,6 +9,7 @@ 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; @@ -55,7 +56,7 @@ public final class UnionEnumValuesImpl { * The interface defining all the services for ValueTypesClientUnionEnumValues to be used by the proxy service to * perform REST calls. */ - @Host("http://localhost:3000") + @Host("{endpoint}") @ServiceInterface(name = "ValueTypesClientUnio") public interface UnionEnumValuesService { @Get("/type/property/value-types/union-enum-value") @@ -64,8 +65,8 @@ public interface UnionEnumValuesService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> get(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Get("/type/property/value-types/union-enum-value") @ExpectedResponses({ 200 }) @@ -73,8 +74,8 @@ Mono> get(@HeaderParam("accept") String accept, RequestOpti @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response getSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Put("/type/property/value-types/union-enum-value") @ExpectedResponses({ 204 }) @@ -82,7 +83,8 @@ Response getSync(@HeaderParam("accept") String accept, RequestOption @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> put(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, + 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") @@ -91,8 +93,8 @@ Mono> put(@HeaderParam("accept") String accept, @BodyParam("appli @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response putSync(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, - RequestOptions requestOptions, Context context); + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); } /** @@ -115,7 +117,7 @@ Response putSync(@HeaderParam("accept") String accept, @BodyParam("applica @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getWithResponseAsync(RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.get(accept, requestOptions, context)); + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); } /** @@ -138,7 +140,7 @@ public Mono> getWithResponseAsync(RequestOptions requestOpt @ServiceMethod(returns = ReturnType.SINGLE) public Response getWithResponse(RequestOptions requestOptions) { final String accept = "application/json"; - return service.getSync(accept, requestOptions, Context.NONE); + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); } /** @@ -161,8 +163,9 @@ public Response getWithResponse(RequestOptions requestOptions) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> putWithResponseAsync(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.put(accept, body, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.put(this.client.getEndpoint(), contentType, body, requestOptions, context)); } /** @@ -185,7 +188,7 @@ public Mono> putWithResponseAsync(BinaryData body, RequestOptions */ @ServiceMethod(returns = ReturnType.SINGLE) public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.putSync(accept, body, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/type/property/valuetypes/implementation/UnionFloatLiteralsImpl.java b/typespec-tests/src/main/java/com/type/property/valuetypes/implementation/UnionFloatLiteralsImpl.java index 2ef0c1534b..c587c7094b 100644 --- a/typespec-tests/src/main/java/com/type/property/valuetypes/implementation/UnionFloatLiteralsImpl.java +++ b/typespec-tests/src/main/java/com/type/property/valuetypes/implementation/UnionFloatLiteralsImpl.java @@ -9,6 +9,7 @@ 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; @@ -55,7 +56,7 @@ public final class UnionFloatLiteralsImpl { * The interface defining all the services for ValueTypesClientUnionFloatLiterals to be used by the proxy service to * perform REST calls. */ - @Host("http://localhost:3000") + @Host("{endpoint}") @ServiceInterface(name = "ValueTypesClientUnio") public interface UnionFloatLiteralsService { @Get("/type/property/value-types/union/float/literal") @@ -64,8 +65,8 @@ public interface UnionFloatLiteralsService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> get(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Get("/type/property/value-types/union/float/literal") @ExpectedResponses({ 200 }) @@ -73,8 +74,8 @@ Mono> get(@HeaderParam("accept") String accept, RequestOpti @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response getSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Put("/type/property/value-types/union/float/literal") @ExpectedResponses({ 204 }) @@ -82,7 +83,8 @@ Response getSync(@HeaderParam("accept") String accept, RequestOption @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> put(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, + 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") @@ -91,8 +93,8 @@ Mono> put(@HeaderParam("accept") String accept, @BodyParam("appli @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response putSync(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, - RequestOptions requestOptions, Context context); + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); } /** @@ -115,7 +117,7 @@ Response putSync(@HeaderParam("accept") String accept, @BodyParam("applica @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getWithResponseAsync(RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.get(accept, requestOptions, context)); + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); } /** @@ -138,7 +140,7 @@ public Mono> getWithResponseAsync(RequestOptions requestOpt @ServiceMethod(returns = ReturnType.SINGLE) public Response getWithResponse(RequestOptions requestOptions) { final String accept = "application/json"; - return service.getSync(accept, requestOptions, Context.NONE); + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); } /** @@ -161,8 +163,9 @@ public Response getWithResponse(RequestOptions requestOptions) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> putWithResponseAsync(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.put(accept, body, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.put(this.client.getEndpoint(), contentType, body, requestOptions, context)); } /** @@ -185,7 +188,7 @@ public Mono> putWithResponseAsync(BinaryData body, RequestOptions */ @ServiceMethod(returns = ReturnType.SINGLE) public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.putSync(accept, body, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/type/property/valuetypes/implementation/UnionIntLiteralsImpl.java b/typespec-tests/src/main/java/com/type/property/valuetypes/implementation/UnionIntLiteralsImpl.java index d624ac99a0..47b1c3216d 100644 --- a/typespec-tests/src/main/java/com/type/property/valuetypes/implementation/UnionIntLiteralsImpl.java +++ b/typespec-tests/src/main/java/com/type/property/valuetypes/implementation/UnionIntLiteralsImpl.java @@ -9,6 +9,7 @@ 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; @@ -55,7 +56,7 @@ public final class UnionIntLiteralsImpl { * The interface defining all the services for ValueTypesClientUnionIntLiterals to be used by the proxy service to * perform REST calls. */ - @Host("http://localhost:3000") + @Host("{endpoint}") @ServiceInterface(name = "ValueTypesClientUnio") public interface UnionIntLiteralsService { @Get("/type/property/value-types/union/int/literal") @@ -64,8 +65,8 @@ public interface UnionIntLiteralsService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> get(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Get("/type/property/value-types/union/int/literal") @ExpectedResponses({ 200 }) @@ -73,8 +74,8 @@ Mono> get(@HeaderParam("accept") String accept, RequestOpti @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response getSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Put("/type/property/value-types/union/int/literal") @ExpectedResponses({ 204 }) @@ -82,7 +83,8 @@ Response getSync(@HeaderParam("accept") String accept, RequestOption @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> put(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, + 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") @@ -91,8 +93,8 @@ Mono> put(@HeaderParam("accept") String accept, @BodyParam("appli @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response putSync(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, - RequestOptions requestOptions, Context context); + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); } /** @@ -115,7 +117,7 @@ Response putSync(@HeaderParam("accept") String accept, @BodyParam("applica @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getWithResponseAsync(RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.get(accept, requestOptions, context)); + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); } /** @@ -138,7 +140,7 @@ public Mono> getWithResponseAsync(RequestOptions requestOpt @ServiceMethod(returns = ReturnType.SINGLE) public Response getWithResponse(RequestOptions requestOptions) { final String accept = "application/json"; - return service.getSync(accept, requestOptions, Context.NONE); + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); } /** @@ -161,8 +163,9 @@ public Response getWithResponse(RequestOptions requestOptions) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> putWithResponseAsync(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.put(accept, body, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.put(this.client.getEndpoint(), contentType, body, requestOptions, context)); } /** @@ -185,7 +188,7 @@ public Mono> putWithResponseAsync(BinaryData body, RequestOptions */ @ServiceMethod(returns = ReturnType.SINGLE) public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.putSync(accept, body, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/type/property/valuetypes/implementation/UnionStringLiteralsImpl.java b/typespec-tests/src/main/java/com/type/property/valuetypes/implementation/UnionStringLiteralsImpl.java index e30da4628a..d9176261b9 100644 --- a/typespec-tests/src/main/java/com/type/property/valuetypes/implementation/UnionStringLiteralsImpl.java +++ b/typespec-tests/src/main/java/com/type/property/valuetypes/implementation/UnionStringLiteralsImpl.java @@ -9,6 +9,7 @@ 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; @@ -55,7 +56,7 @@ public final class UnionStringLiteralsImpl { * The interface defining all the services for ValueTypesClientUnionStringLiterals to be used by the proxy service * to perform REST calls. */ - @Host("http://localhost:3000") + @Host("{endpoint}") @ServiceInterface(name = "ValueTypesClientUnio") public interface UnionStringLiteralsService { @Get("/type/property/value-types/union/string/literal") @@ -64,8 +65,8 @@ public interface UnionStringLiteralsService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> get(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Get("/type/property/value-types/union/string/literal") @ExpectedResponses({ 200 }) @@ -73,8 +74,8 @@ Mono> get(@HeaderParam("accept") String accept, RequestOpti @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response getSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Put("/type/property/value-types/union/string/literal") @ExpectedResponses({ 204 }) @@ -82,7 +83,8 @@ Response getSync(@HeaderParam("accept") String accept, RequestOption @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> put(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, + 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") @@ -91,8 +93,8 @@ Mono> put(@HeaderParam("accept") String accept, @BodyParam("appli @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response putSync(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, - RequestOptions requestOptions, Context context); + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); } /** @@ -115,7 +117,7 @@ Response putSync(@HeaderParam("accept") String accept, @BodyParam("applica @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getWithResponseAsync(RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.get(accept, requestOptions, context)); + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); } /** @@ -138,7 +140,7 @@ public Mono> getWithResponseAsync(RequestOptions requestOpt @ServiceMethod(returns = ReturnType.SINGLE) public Response getWithResponse(RequestOptions requestOptions) { final String accept = "application/json"; - return service.getSync(accept, requestOptions, Context.NONE); + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); } /** @@ -161,8 +163,9 @@ public Response getWithResponse(RequestOptions requestOptions) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> putWithResponseAsync(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.put(accept, body, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.put(this.client.getEndpoint(), contentType, body, requestOptions, context)); } /** @@ -185,7 +188,7 @@ public Mono> putWithResponseAsync(BinaryData body, RequestOptions */ @ServiceMethod(returns = ReturnType.SINGLE) public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.putSync(accept, body, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/type/property/valuetypes/implementation/UnknownArraysImpl.java b/typespec-tests/src/main/java/com/type/property/valuetypes/implementation/UnknownArraysImpl.java index 62b57490e1..5e0ce54caa 100644 --- a/typespec-tests/src/main/java/com/type/property/valuetypes/implementation/UnknownArraysImpl.java +++ b/typespec-tests/src/main/java/com/type/property/valuetypes/implementation/UnknownArraysImpl.java @@ -9,6 +9,7 @@ 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; @@ -55,7 +56,7 @@ public final class UnknownArraysImpl { * The interface defining all the services for ValueTypesClientUnknownArrays to be used by the proxy service to * perform REST calls. */ - @Host("http://localhost:3000") + @Host("{endpoint}") @ServiceInterface(name = "ValueTypesClientUnkn") public interface UnknownArraysService { @Get("/type/property/value-types/unknown/array") @@ -64,8 +65,8 @@ public interface UnknownArraysService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> get(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Get("/type/property/value-types/unknown/array") @ExpectedResponses({ 200 }) @@ -73,8 +74,8 @@ Mono> get(@HeaderParam("accept") String accept, RequestOpti @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response getSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Put("/type/property/value-types/unknown/array") @ExpectedResponses({ 204 }) @@ -82,7 +83,8 @@ Response getSync(@HeaderParam("accept") String accept, RequestOption @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> put(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, + 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") @@ -91,8 +93,8 @@ Mono> put(@HeaderParam("accept") String accept, @BodyParam("appli @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response putSync(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, - RequestOptions requestOptions, Context context); + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); } /** @@ -115,7 +117,7 @@ Response putSync(@HeaderParam("accept") String accept, @BodyParam("applica @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getWithResponseAsync(RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.get(accept, requestOptions, context)); + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); } /** @@ -138,7 +140,7 @@ public Mono> getWithResponseAsync(RequestOptions requestOpt @ServiceMethod(returns = ReturnType.SINGLE) public Response getWithResponse(RequestOptions requestOptions) { final String accept = "application/json"; - return service.getSync(accept, requestOptions, Context.NONE); + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); } /** @@ -161,8 +163,9 @@ public Response getWithResponse(RequestOptions requestOptions) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> putWithResponseAsync(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.put(accept, body, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.put(this.client.getEndpoint(), contentType, body, requestOptions, context)); } /** @@ -185,7 +188,7 @@ public Mono> putWithResponseAsync(BinaryData body, RequestOptions */ @ServiceMethod(returns = ReturnType.SINGLE) public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.putSync(accept, body, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/type/property/valuetypes/implementation/UnknownDictsImpl.java b/typespec-tests/src/main/java/com/type/property/valuetypes/implementation/UnknownDictsImpl.java index c13ddac04c..ddf7456a9e 100644 --- a/typespec-tests/src/main/java/com/type/property/valuetypes/implementation/UnknownDictsImpl.java +++ b/typespec-tests/src/main/java/com/type/property/valuetypes/implementation/UnknownDictsImpl.java @@ -9,6 +9,7 @@ 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; @@ -55,7 +56,7 @@ public final class UnknownDictsImpl { * The interface defining all the services for ValueTypesClientUnknownDicts to be used by the proxy service to * perform REST calls. */ - @Host("http://localhost:3000") + @Host("{endpoint}") @ServiceInterface(name = "ValueTypesClientUnkn") public interface UnknownDictsService { @Get("/type/property/value-types/unknown/dict") @@ -64,8 +65,8 @@ public interface UnknownDictsService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> get(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Get("/type/property/value-types/unknown/dict") @ExpectedResponses({ 200 }) @@ -73,8 +74,8 @@ Mono> get(@HeaderParam("accept") String accept, RequestOpti @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response getSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Put("/type/property/value-types/unknown/dict") @ExpectedResponses({ 204 }) @@ -82,7 +83,8 @@ Response getSync(@HeaderParam("accept") String accept, RequestOption @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> put(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, + 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") @@ -91,8 +93,8 @@ Mono> put(@HeaderParam("accept") String accept, @BodyParam("appli @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response putSync(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, - RequestOptions requestOptions, Context context); + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); } /** @@ -115,7 +117,7 @@ Response putSync(@HeaderParam("accept") String accept, @BodyParam("applica @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getWithResponseAsync(RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.get(accept, requestOptions, context)); + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); } /** @@ -138,7 +140,7 @@ public Mono> getWithResponseAsync(RequestOptions requestOpt @ServiceMethod(returns = ReturnType.SINGLE) public Response getWithResponse(RequestOptions requestOptions) { final String accept = "application/json"; - return service.getSync(accept, requestOptions, Context.NONE); + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); } /** @@ -161,8 +163,9 @@ public Response getWithResponse(RequestOptions requestOptions) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> putWithResponseAsync(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.put(accept, body, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.put(this.client.getEndpoint(), contentType, body, requestOptions, context)); } /** @@ -185,7 +188,7 @@ public Mono> putWithResponseAsync(BinaryData body, RequestOptions */ @ServiceMethod(returns = ReturnType.SINGLE) public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.putSync(accept, body, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/type/property/valuetypes/implementation/UnknownIntsImpl.java b/typespec-tests/src/main/java/com/type/property/valuetypes/implementation/UnknownIntsImpl.java index 18af3c5879..c805517099 100644 --- a/typespec-tests/src/main/java/com/type/property/valuetypes/implementation/UnknownIntsImpl.java +++ b/typespec-tests/src/main/java/com/type/property/valuetypes/implementation/UnknownIntsImpl.java @@ -9,6 +9,7 @@ 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; @@ -55,7 +56,7 @@ public final class UnknownIntsImpl { * The interface defining all the services for ValueTypesClientUnknownInts to be used by the proxy service to * perform REST calls. */ - @Host("http://localhost:3000") + @Host("{endpoint}") @ServiceInterface(name = "ValueTypesClientUnkn") public interface UnknownIntsService { @Get("/type/property/value-types/unknown/int") @@ -64,8 +65,8 @@ public interface UnknownIntsService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> get(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Get("/type/property/value-types/unknown/int") @ExpectedResponses({ 200 }) @@ -73,8 +74,8 @@ Mono> get(@HeaderParam("accept") String accept, RequestOpti @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response getSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Put("/type/property/value-types/unknown/int") @ExpectedResponses({ 204 }) @@ -82,7 +83,8 @@ Response getSync(@HeaderParam("accept") String accept, RequestOption @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> put(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, + 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") @@ -91,8 +93,8 @@ Mono> put(@HeaderParam("accept") String accept, @BodyParam("appli @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response putSync(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, - RequestOptions requestOptions, Context context); + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); } /** @@ -115,7 +117,7 @@ Response putSync(@HeaderParam("accept") String accept, @BodyParam("applica @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getWithResponseAsync(RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.get(accept, requestOptions, context)); + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); } /** @@ -138,7 +140,7 @@ public Mono> getWithResponseAsync(RequestOptions requestOpt @ServiceMethod(returns = ReturnType.SINGLE) public Response getWithResponse(RequestOptions requestOptions) { final String accept = "application/json"; - return service.getSync(accept, requestOptions, Context.NONE); + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); } /** @@ -161,8 +163,9 @@ public Response getWithResponse(RequestOptions requestOptions) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> putWithResponseAsync(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.put(accept, body, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.put(this.client.getEndpoint(), contentType, body, requestOptions, context)); } /** @@ -185,7 +188,7 @@ public Mono> putWithResponseAsync(BinaryData body, RequestOptions */ @ServiceMethod(returns = ReturnType.SINGLE) public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.putSync(accept, body, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/type/property/valuetypes/implementation/UnknownStringsImpl.java b/typespec-tests/src/main/java/com/type/property/valuetypes/implementation/UnknownStringsImpl.java index cc8277e2f2..9d8d1b6204 100644 --- a/typespec-tests/src/main/java/com/type/property/valuetypes/implementation/UnknownStringsImpl.java +++ b/typespec-tests/src/main/java/com/type/property/valuetypes/implementation/UnknownStringsImpl.java @@ -9,6 +9,7 @@ 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; @@ -55,7 +56,7 @@ public final class UnknownStringsImpl { * The interface defining all the services for ValueTypesClientUnknownStrings to be used by the proxy service to * perform REST calls. */ - @Host("http://localhost:3000") + @Host("{endpoint}") @ServiceInterface(name = "ValueTypesClientUnkn") public interface UnknownStringsService { @Get("/type/property/value-types/unknown/string") @@ -64,8 +65,8 @@ public interface UnknownStringsService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> get(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Get("/type/property/value-types/unknown/string") @ExpectedResponses({ 200 }) @@ -73,8 +74,8 @@ Mono> get(@HeaderParam("accept") String accept, RequestOpti @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response getSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Put("/type/property/value-types/unknown/string") @ExpectedResponses({ 204 }) @@ -82,7 +83,8 @@ Response getSync(@HeaderParam("accept") String accept, RequestOption @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> put(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, + 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") @@ -91,8 +93,8 @@ Mono> put(@HeaderParam("accept") String accept, @BodyParam("appli @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response putSync(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, - RequestOptions requestOptions, Context context); + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); } /** @@ -115,7 +117,7 @@ Response putSync(@HeaderParam("accept") String accept, @BodyParam("applica @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getWithResponseAsync(RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.get(accept, requestOptions, context)); + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); } /** @@ -138,7 +140,7 @@ public Mono> getWithResponseAsync(RequestOptions requestOpt @ServiceMethod(returns = ReturnType.SINGLE) public Response getWithResponse(RequestOptions requestOptions) { final String accept = "application/json"; - return service.getSync(accept, requestOptions, Context.NONE); + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); } /** @@ -161,8 +163,9 @@ public Response getWithResponse(RequestOptions requestOptions) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> putWithResponseAsync(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.put(accept, body, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.put(this.client.getEndpoint(), contentType, body, requestOptions, context)); } /** @@ -185,7 +188,7 @@ public Mono> putWithResponseAsync(BinaryData body, RequestOptions */ @ServiceMethod(returns = ReturnType.SINGLE) public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.putSync(accept, body, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/type/property/valuetypes/implementation/ValueTypesClientImpl.java b/typespec-tests/src/main/java/com/type/property/valuetypes/implementation/ValueTypesClientImpl.java index 1380cabcd4..74ad9e1c0a 100644 --- a/typespec-tests/src/main/java/com/type/property/valuetypes/implementation/ValueTypesClientImpl.java +++ b/typespec-tests/src/main/java/com/type/property/valuetypes/implementation/ValueTypesClientImpl.java @@ -15,6 +15,20 @@ * 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. */ @@ -451,19 +465,22 @@ public UnionEnumValuesImpl getUnionEnumValues() { /** * Initializes an instance of ValueTypesClient client. + * + * @param endpoint Service host. */ - public ValueTypesClientImpl() { + public ValueTypesClientImpl(String endpoint) { this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), - JacksonAdapter.createDefaultSerializerAdapter()); + 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) { - this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter()); + public ValueTypesClientImpl(HttpPipeline httpPipeline, String endpoint) { + this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint); } /** @@ -471,10 +488,12 @@ public ValueTypesClientImpl(HttpPipeline httpPipeline) { * * @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) { + 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); diff --git a/typespec-tests/src/main/java/com/type/scalar/ScalarClientBuilder.java b/typespec-tests/src/main/java/com/type/scalar/ScalarClientBuilder.java index be720a82e2..8b71294c9a 100644 --- a/typespec-tests/src/main/java/com/type/scalar/ScalarClientBuilder.java +++ b/typespec-tests/src/main/java/com/type/scalar/ScalarClientBuilder.java @@ -7,6 +7,7 @@ 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; @@ -55,8 +56,8 @@ Decimal128TypeAsyncClient.class, DecimalVerifyAsyncClient.class, Decimal128VerifyAsyncClient.class }) -public final class ScalarClientBuilder - implements HttpTrait, ConfigurationTrait { +public final class ScalarClientBuilder implements HttpTrait, + ConfigurationTrait, EndpointTrait { @Generated private static final String SDK_NAME = "name"; @@ -187,6 +188,22 @@ public ScalarClientBuilder configuration(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. */ @@ -214,7 +231,9 @@ public ScalarClientBuilder retryPolicy(RetryPolicy retryPolicy) { private ScalarClientImpl buildInnerClient() { this.validateClient(); HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); - ScalarClientImpl client = new ScalarClientImpl(localPipeline, JacksonAdapter.createDefaultSerializerAdapter()); + String localEndpoint = (endpoint != null) ? endpoint : "http://localhost:3000"; + ScalarClientImpl client + = new ScalarClientImpl(localPipeline, JacksonAdapter.createDefaultSerializerAdapter(), localEndpoint); return client; } diff --git a/typespec-tests/src/main/java/com/type/scalar/implementation/BooleanOperationsImpl.java b/typespec-tests/src/main/java/com/type/scalar/implementation/BooleanOperationsImpl.java index 85a5e4540d..de2b4533c8 100644 --- a/typespec-tests/src/main/java/com/type/scalar/implementation/BooleanOperationsImpl.java +++ b/typespec-tests/src/main/java/com/type/scalar/implementation/BooleanOperationsImpl.java @@ -9,6 +9,7 @@ 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; @@ -55,7 +56,7 @@ public final class BooleanOperationsImpl { * The interface defining all the services for ScalarClientBooleanOperations to be used by the proxy service to * perform REST calls. */ - @Host("http://localhost:3000") + @Host("{endpoint}") @ServiceInterface(name = "ScalarClientBooleanO") public interface BooleanOperationsService { @Get("/type/scalar/boolean") @@ -64,8 +65,8 @@ public interface BooleanOperationsService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> get(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Get("/type/scalar/boolean") @ExpectedResponses({ 200 }) @@ -73,8 +74,8 @@ Mono> get(@HeaderParam("accept") String accept, RequestOpti @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response getSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Put("/type/scalar/boolean") @ExpectedResponses({ 204 }) @@ -82,7 +83,8 @@ Response getSync(@HeaderParam("accept") String accept, RequestOption @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> put(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, + Mono> put(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); @Put("/type/scalar/boolean") @@ -91,8 +93,8 @@ Mono> put(@HeaderParam("accept") String accept, @BodyParam("appli @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response putSync(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, - RequestOptions requestOptions, Context context); + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); } /** @@ -113,7 +115,7 @@ Response putSync(@HeaderParam("accept") String accept, @BodyParam("applica @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getWithResponseAsync(RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.get(accept, requestOptions, context)); + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); } /** @@ -134,7 +136,7 @@ public Mono> getWithResponseAsync(RequestOptions requestOpt @ServiceMethod(returns = ReturnType.SINGLE) public Response getWithResponse(RequestOptions requestOptions) { final String accept = "application/json"; - return service.getSync(accept, requestOptions, Context.NONE); + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); } /** @@ -155,8 +157,9 @@ public Response getWithResponse(RequestOptions requestOptions) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> putWithResponseAsync(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.put(accept, body, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.put(this.client.getEndpoint(), contentType, body, requestOptions, context)); } /** @@ -177,7 +180,7 @@ public Mono> putWithResponseAsync(BinaryData body, RequestOptions */ @ServiceMethod(returns = ReturnType.SINGLE) public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.putSync(accept, body, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/type/scalar/implementation/Decimal128TypesImpl.java b/typespec-tests/src/main/java/com/type/scalar/implementation/Decimal128TypesImpl.java index 7888d3acb3..485753a5ae 100644 --- a/typespec-tests/src/main/java/com/type/scalar/implementation/Decimal128TypesImpl.java +++ b/typespec-tests/src/main/java/com/type/scalar/implementation/Decimal128TypesImpl.java @@ -9,6 +9,7 @@ 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; @@ -57,7 +58,7 @@ public final class Decimal128TypesImpl { * The interface defining all the services for ScalarClientDecimal128Types to be used by the proxy service to * perform REST calls. */ - @Host("http://localhost:3000") + @Host("{endpoint}") @ServiceInterface(name = "ScalarClientDecimal1") public interface Decimal128TypesService { @Get("/type/scalar/decimal128/response_body") @@ -66,8 +67,8 @@ public interface Decimal128TypesService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> responseBody(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Mono> responseBody(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Get("/type/scalar/decimal128/response_body") @ExpectedResponses({ 200 }) @@ -75,8 +76,8 @@ Mono> responseBody(@HeaderParam("accept") String accept, Re @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response responseBodySync(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Response responseBodySync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Put("/type/scalar/decimal128/resquest_body") @ExpectedResponses({ 204 }) @@ -84,8 +85,9 @@ Response responseBodySync(@HeaderParam("accept") String accept, Requ @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> requestBody(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + 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 }) @@ -93,8 +95,9 @@ Mono> requestBody(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response requestBodySync(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + 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 }) @@ -102,8 +105,8 @@ Response requestBodySync(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> requestParameter(@QueryParam("value") BigDecimal value, - @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + Mono> requestParameter(@HostParam("endpoint") String endpoint, + @QueryParam("value") BigDecimal value, RequestOptions requestOptions, Context context); @Get("/type/scalar/decimal128/request_parameter") @ExpectedResponses({ 204 }) @@ -111,8 +114,8 @@ Mono> requestParameter(@QueryParam("value") BigDecimal value, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response requestParameterSync(@QueryParam("value") BigDecimal value, @HeaderParam("accept") String accept, - RequestOptions requestOptions, Context context); + Response requestParameterSync(@HostParam("endpoint") String endpoint, + @QueryParam("value") BigDecimal value, RequestOptions requestOptions, Context context); } /** @@ -133,7 +136,8 @@ Response requestParameterSync(@QueryParam("value") BigDecimal value, @Head @ServiceMethod(returns = ReturnType.SINGLE) public Mono> responseBodyWithResponseAsync(RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.responseBody(accept, requestOptions, context)); + return FluxUtil + .withContext(context -> service.responseBody(this.client.getEndpoint(), accept, requestOptions, context)); } /** @@ -154,7 +158,7 @@ public Mono> responseBodyWithResponseAsync(RequestOptions r @ServiceMethod(returns = ReturnType.SINGLE) public Response responseBodyWithResponse(RequestOptions requestOptions) { final String accept = "application/json"; - return service.responseBodySync(accept, requestOptions, Context.NONE); + return service.responseBodySync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); } /** @@ -175,8 +179,9 @@ public Response responseBodyWithResponse(RequestOptions requestOptio */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> requestBodyWithResponseAsync(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.requestBody(accept, body, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.requestBody(this.client.getEndpoint(), contentType, body, requestOptions, context)); } /** @@ -197,8 +202,8 @@ public Mono> requestBodyWithResponseAsync(BinaryData body, Reques */ @ServiceMethod(returns = ReturnType.SINGLE) public Response requestBodyWithResponse(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.requestBodySync(accept, body, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.requestBodySync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); } /** @@ -214,8 +219,8 @@ public Response requestBodyWithResponse(BinaryData body, RequestOptions re */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> requestParameterWithResponseAsync(BigDecimal value, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.requestParameter(value, accept, requestOptions, context)); + return FluxUtil.withContext( + context -> service.requestParameter(this.client.getEndpoint(), value, requestOptions, context)); } /** @@ -231,7 +236,6 @@ public Mono> requestParameterWithResponseAsync(BigDecimal value, */ @ServiceMethod(returns = ReturnType.SINGLE) public Response requestParameterWithResponse(BigDecimal value, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.requestParameterSync(value, accept, requestOptions, Context.NONE); + return service.requestParameterSync(this.client.getEndpoint(), value, requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/type/scalar/implementation/Decimal128VerifiesImpl.java b/typespec-tests/src/main/java/com/type/scalar/implementation/Decimal128VerifiesImpl.java index 9ab59d8665..60333b6446 100644 --- a/typespec-tests/src/main/java/com/type/scalar/implementation/Decimal128VerifiesImpl.java +++ b/typespec-tests/src/main/java/com/type/scalar/implementation/Decimal128VerifiesImpl.java @@ -9,6 +9,7 @@ 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; @@ -55,7 +56,7 @@ public final class Decimal128VerifiesImpl { * The interface defining all the services for ScalarClientDecimal128Verifies to be used by the proxy service to * perform REST calls. */ - @Host("http://localhost:3000") + @Host("{endpoint}") @ServiceInterface(name = "ScalarClientDecimal1") public interface Decimal128VerifiesService { @Get("/type/scalar/decimal128/prepare_verify") @@ -64,8 +65,8 @@ public interface Decimal128VerifiesService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> prepareVerify(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Mono> prepareVerify(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Get("/type/scalar/decimal128/prepare_verify") @ExpectedResponses({ 200 }) @@ -73,8 +74,8 @@ Mono> prepareVerify(@HeaderParam("accept") String accept, R @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response prepareVerifySync(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Response prepareVerifySync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Post("/type/scalar/decimal128/verify") @ExpectedResponses({ 204 }) @@ -82,8 +83,9 @@ Response prepareVerifySync(@HeaderParam("accept") String accept, Req @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> verify(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + 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 }) @@ -91,7 +93,8 @@ Mono> verify(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response verifySync(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, + Response verifySync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); } @@ -115,7 +118,8 @@ Response verifySync(@HeaderParam("accept") String accept, @BodyParam("appl @ServiceMethod(returns = ReturnType.SINGLE) public Mono> prepareVerifyWithResponseAsync(RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.prepareVerify(accept, requestOptions, context)); + return FluxUtil + .withContext(context -> service.prepareVerify(this.client.getEndpoint(), accept, requestOptions, context)); } /** @@ -138,7 +142,7 @@ public Mono> prepareVerifyWithResponseAsync(RequestOptions @ServiceMethod(returns = ReturnType.SINGLE) public Response prepareVerifyWithResponse(RequestOptions requestOptions) { final String accept = "application/json"; - return service.prepareVerifySync(accept, requestOptions, Context.NONE); + return service.prepareVerifySync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); } /** @@ -159,8 +163,9 @@ public Response prepareVerifyWithResponse(RequestOptions requestOpti */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> verifyWithResponseAsync(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.verify(accept, body, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.verify(this.client.getEndpoint(), contentType, body, requestOptions, context)); } /** @@ -181,7 +186,7 @@ public Mono> verifyWithResponseAsync(BinaryData body, RequestOpti */ @ServiceMethod(returns = ReturnType.SINGLE) public Response verifyWithResponse(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.verifySync(accept, body, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.verifySync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/type/scalar/implementation/DecimalTypesImpl.java b/typespec-tests/src/main/java/com/type/scalar/implementation/DecimalTypesImpl.java index e44f5908ad..f4883c57e8 100644 --- a/typespec-tests/src/main/java/com/type/scalar/implementation/DecimalTypesImpl.java +++ b/typespec-tests/src/main/java/com/type/scalar/implementation/DecimalTypesImpl.java @@ -9,6 +9,7 @@ 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; @@ -57,7 +58,7 @@ public final class DecimalTypesImpl { * The interface defining all the services for ScalarClientDecimalTypes to be used by the proxy service to perform * REST calls. */ - @Host("http://localhost:3000") + @Host("{endpoint}") @ServiceInterface(name = "ScalarClientDecimalT") public interface DecimalTypesService { @Get("/type/scalar/decimal/response_body") @@ -66,8 +67,8 @@ public interface DecimalTypesService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> responseBody(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Mono> responseBody(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Get("/type/scalar/decimal/response_body") @ExpectedResponses({ 200 }) @@ -75,8 +76,8 @@ Mono> responseBody(@HeaderParam("accept") String accept, Re @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response responseBodySync(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Response responseBodySync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Put("/type/scalar/decimal/resquest_body") @ExpectedResponses({ 204 }) @@ -84,8 +85,9 @@ Response responseBodySync(@HeaderParam("accept") String accept, Requ @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> requestBody(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + 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 }) @@ -93,8 +95,9 @@ Mono> requestBody(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response requestBodySync(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + 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 }) @@ -102,8 +105,8 @@ Response requestBodySync(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> requestParameter(@QueryParam("value") BigDecimal value, - @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + Mono> requestParameter(@HostParam("endpoint") String endpoint, + @QueryParam("value") BigDecimal value, RequestOptions requestOptions, Context context); @Get("/type/scalar/decimal/request_parameter") @ExpectedResponses({ 204 }) @@ -111,8 +114,8 @@ Mono> requestParameter(@QueryParam("value") BigDecimal value, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response requestParameterSync(@QueryParam("value") BigDecimal value, @HeaderParam("accept") String accept, - RequestOptions requestOptions, Context context); + Response requestParameterSync(@HostParam("endpoint") String endpoint, + @QueryParam("value") BigDecimal value, RequestOptions requestOptions, Context context); } /** @@ -134,7 +137,8 @@ Response requestParameterSync(@QueryParam("value") BigDecimal value, @Head @ServiceMethod(returns = ReturnType.SINGLE) public Mono> responseBodyWithResponseAsync(RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.responseBody(accept, requestOptions, context)); + return FluxUtil + .withContext(context -> service.responseBody(this.client.getEndpoint(), accept, requestOptions, context)); } /** @@ -155,7 +159,7 @@ public Mono> responseBodyWithResponseAsync(RequestOptions r @ServiceMethod(returns = ReturnType.SINGLE) public Response responseBodyWithResponse(RequestOptions requestOptions) { final String accept = "application/json"; - return service.responseBodySync(accept, requestOptions, Context.NONE); + return service.responseBodySync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); } /** @@ -176,8 +180,9 @@ public Response responseBodyWithResponse(RequestOptions requestOptio */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> requestBodyWithResponseAsync(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.requestBody(accept, body, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.requestBody(this.client.getEndpoint(), contentType, body, requestOptions, context)); } /** @@ -198,8 +203,8 @@ public Mono> requestBodyWithResponseAsync(BinaryData body, Reques */ @ServiceMethod(returns = ReturnType.SINGLE) public Response requestBodyWithResponse(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.requestBodySync(accept, body, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.requestBodySync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); } /** @@ -215,8 +220,8 @@ public Response requestBodyWithResponse(BinaryData body, RequestOptions re */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> requestParameterWithResponseAsync(BigDecimal value, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.requestParameter(value, accept, requestOptions, context)); + return FluxUtil.withContext( + context -> service.requestParameter(this.client.getEndpoint(), value, requestOptions, context)); } /** @@ -232,7 +237,6 @@ public Mono> requestParameterWithResponseAsync(BigDecimal value, */ @ServiceMethod(returns = ReturnType.SINGLE) public Response requestParameterWithResponse(BigDecimal value, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.requestParameterSync(value, accept, requestOptions, Context.NONE); + return service.requestParameterSync(this.client.getEndpoint(), value, requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/type/scalar/implementation/DecimalVerifiesImpl.java b/typespec-tests/src/main/java/com/type/scalar/implementation/DecimalVerifiesImpl.java index 4917636063..a74d656a76 100644 --- a/typespec-tests/src/main/java/com/type/scalar/implementation/DecimalVerifiesImpl.java +++ b/typespec-tests/src/main/java/com/type/scalar/implementation/DecimalVerifiesImpl.java @@ -9,6 +9,7 @@ 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; @@ -55,7 +56,7 @@ public final class DecimalVerifiesImpl { * The interface defining all the services for ScalarClientDecimalVerifies to be used by the proxy service to * perform REST calls. */ - @Host("http://localhost:3000") + @Host("{endpoint}") @ServiceInterface(name = "ScalarClientDecimalV") public interface DecimalVerifiesService { @Get("/type/scalar/decimal/prepare_verify") @@ -64,8 +65,8 @@ public interface DecimalVerifiesService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> prepareVerify(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Mono> prepareVerify(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Get("/type/scalar/decimal/prepare_verify") @ExpectedResponses({ 200 }) @@ -73,8 +74,8 @@ Mono> prepareVerify(@HeaderParam("accept") String accept, R @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response prepareVerifySync(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Response prepareVerifySync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); @Post("/type/scalar/decimal/verify") @ExpectedResponses({ 204 }) @@ -82,8 +83,9 @@ Response prepareVerifySync(@HeaderParam("accept") String accept, Req @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> verify(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + 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 }) @@ -91,7 +93,8 @@ Mono> verify(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response verifySync(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, + Response verifySync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); } @@ -115,7 +118,8 @@ Response verifySync(@HeaderParam("accept") String accept, @BodyParam("appl @ServiceMethod(returns = ReturnType.SINGLE) public Mono> prepareVerifyWithResponseAsync(RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.prepareVerify(accept, requestOptions, context)); + return FluxUtil + .withContext(context -> service.prepareVerify(this.client.getEndpoint(), accept, requestOptions, context)); } /** @@ -138,7 +142,7 @@ public Mono> prepareVerifyWithResponseAsync(RequestOptions @ServiceMethod(returns = ReturnType.SINGLE) public Response prepareVerifyWithResponse(RequestOptions requestOptions) { final String accept = "application/json"; - return service.prepareVerifySync(accept, requestOptions, Context.NONE); + return service.prepareVerifySync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); } /** @@ -159,8 +163,9 @@ public Response prepareVerifyWithResponse(RequestOptions requestOpti */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> verifyWithResponseAsync(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.verify(accept, body, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.verify(this.client.getEndpoint(), contentType, body, requestOptions, context)); } /** @@ -181,7 +186,7 @@ public Mono> verifyWithResponseAsync(BinaryData body, RequestOpti */ @ServiceMethod(returns = ReturnType.SINGLE) public Response verifyWithResponse(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.verifySync(accept, body, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.verifySync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/type/scalar/implementation/ScalarClientImpl.java b/typespec-tests/src/main/java/com/type/scalar/implementation/ScalarClientImpl.java index fe44e11fce..1da15a1e67 100644 --- a/typespec-tests/src/main/java/com/type/scalar/implementation/ScalarClientImpl.java +++ b/typespec-tests/src/main/java/com/type/scalar/implementation/ScalarClientImpl.java @@ -15,6 +15,20 @@ * 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. */ @@ -143,19 +157,22 @@ public Decimal128VerifiesImpl getDecimal128Verifies() { /** * Initializes an instance of ScalarClient client. + * + * @param endpoint Service host. */ - public ScalarClientImpl() { + public ScalarClientImpl(String endpoint) { this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), - JacksonAdapter.createDefaultSerializerAdapter()); + 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) { - this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter()); + public ScalarClientImpl(HttpPipeline httpPipeline, String endpoint) { + this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint); } /** @@ -163,10 +180,12 @@ public ScalarClientImpl(HttpPipeline httpPipeline) { * * @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) { + 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); diff --git a/typespec-tests/src/main/java/com/type/scalar/implementation/StringOperationsImpl.java b/typespec-tests/src/main/java/com/type/scalar/implementation/StringOperationsImpl.java index 577df014e4..de7b8ad0c7 100644 --- a/typespec-tests/src/main/java/com/type/scalar/implementation/StringOperationsImpl.java +++ b/typespec-tests/src/main/java/com/type/scalar/implementation/StringOperationsImpl.java @@ -9,6 +9,7 @@ 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; @@ -55,7 +56,7 @@ public final class StringOperationsImpl { * The interface defining all the services for ScalarClientStringOperations to be used by the proxy service to * perform REST calls. */ - @Host("http://localhost:3000") + @Host("{endpoint}") @ServiceInterface(name = "ScalarClientStringOp") public interface StringOperationsService { @Get("/type/scalar/string") @@ -64,8 +65,8 @@ public interface StringOperationsService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> get(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Get("/type/scalar/string") @ExpectedResponses({ 200 }) @@ -73,8 +74,8 @@ Mono> get(@HeaderParam("accept") String accept, RequestOpti @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response getSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Put("/type/scalar/string") @ExpectedResponses({ 204 }) @@ -82,7 +83,8 @@ Response getSync(@HeaderParam("accept") String accept, RequestOption @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> put(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, + Mono> put(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); @Put("/type/scalar/string") @@ -91,8 +93,8 @@ Mono> put(@HeaderParam("accept") String accept, @BodyParam("appli @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response putSync(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, - RequestOptions requestOptions, Context context); + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); } /** @@ -113,7 +115,7 @@ Response putSync(@HeaderParam("accept") String accept, @BodyParam("applica @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getWithResponseAsync(RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.get(accept, requestOptions, context)); + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); } /** @@ -134,7 +136,7 @@ public Mono> getWithResponseAsync(RequestOptions requestOpt @ServiceMethod(returns = ReturnType.SINGLE) public Response getWithResponse(RequestOptions requestOptions) { final String accept = "application/json"; - return service.getSync(accept, requestOptions, Context.NONE); + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); } /** @@ -155,8 +157,9 @@ public Response getWithResponse(RequestOptions requestOptions) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> putWithResponseAsync(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.put(accept, body, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.put(this.client.getEndpoint(), contentType, body, requestOptions, context)); } /** @@ -177,7 +180,7 @@ public Mono> putWithResponseAsync(BinaryData body, RequestOptions */ @ServiceMethod(returns = ReturnType.SINGLE) public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.putSync(accept, body, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/type/scalar/implementation/UnknownsImpl.java b/typespec-tests/src/main/java/com/type/scalar/implementation/UnknownsImpl.java index fdd5fea491..584c563198 100644 --- a/typespec-tests/src/main/java/com/type/scalar/implementation/UnknownsImpl.java +++ b/typespec-tests/src/main/java/com/type/scalar/implementation/UnknownsImpl.java @@ -9,6 +9,7 @@ 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; @@ -54,7 +55,7 @@ public final class UnknownsImpl { * The interface defining all the services for ScalarClientUnknowns to be used by the proxy service to perform REST * calls. */ - @Host("http://localhost:3000") + @Host("{endpoint}") @ServiceInterface(name = "ScalarClientUnknowns") public interface UnknownsService { @Get("/type/scalar/unknown") @@ -63,8 +64,8 @@ public interface UnknownsService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> get(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Get("/type/scalar/unknown") @ExpectedResponses({ 200 }) @@ -72,8 +73,8 @@ Mono> get(@HeaderParam("accept") String accept, RequestOpti @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response getSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Put("/type/scalar/unknown") @ExpectedResponses({ 204 }) @@ -81,7 +82,8 @@ Response getSync(@HeaderParam("accept") String accept, RequestOption @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> put(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, + Mono> put(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); @Put("/type/scalar/unknown") @@ -90,8 +92,8 @@ Mono> put(@HeaderParam("accept") String accept, @BodyParam("appli @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response putSync(@HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, - RequestOptions requestOptions, Context context); + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); } /** @@ -112,7 +114,7 @@ Response putSync(@HeaderParam("accept") String accept, @BodyParam("applica @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getWithResponseAsync(RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.get(accept, requestOptions, context)); + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); } /** @@ -133,7 +135,7 @@ public Mono> getWithResponseAsync(RequestOptions requestOpt @ServiceMethod(returns = ReturnType.SINGLE) public Response getWithResponse(RequestOptions requestOptions) { final String accept = "application/json"; - return service.getSync(accept, requestOptions, Context.NONE); + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); } /** @@ -154,8 +156,9 @@ public Response getWithResponse(RequestOptions requestOptions) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> putWithResponseAsync(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.put(accept, body, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.put(this.client.getEndpoint(), contentType, body, requestOptions, context)); } /** @@ -176,7 +179,7 @@ public Mono> putWithResponseAsync(BinaryData body, RequestOptions */ @ServiceMethod(returns = ReturnType.SINGLE) public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.putSync(accept, body, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/type/union/UnionClientBuilder.java b/typespec-tests/src/main/java/com/type/union/UnionClientBuilder.java index 68aa7f3355..25c0117494 100644 --- a/typespec-tests/src/main/java/com/type/union/UnionClientBuilder.java +++ b/typespec-tests/src/main/java/com/type/union/UnionClientBuilder.java @@ -7,6 +7,7 @@ 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; @@ -61,7 +62,8 @@ StringAndArrayAsyncClient.class, MixedLiteralsAsyncClient.class, MixedTypesAsyncClient.class }) -public final class UnionClientBuilder implements HttpTrait, ConfigurationTrait { +public final class UnionClientBuilder implements HttpTrait, ConfigurationTrait, + EndpointTrait { @Generated private static final String SDK_NAME = "name"; @@ -192,6 +194,22 @@ public UnionClientBuilder configuration(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. */ @@ -219,7 +237,9 @@ public UnionClientBuilder retryPolicy(RetryPolicy retryPolicy) { private UnionClientImpl buildInnerClient() { this.validateClient(); HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); - UnionClientImpl client = new UnionClientImpl(localPipeline, JacksonAdapter.createDefaultSerializerAdapter()); + String localEndpoint = (endpoint != null) ? endpoint : "http://localhost:3000"; + UnionClientImpl client + = new UnionClientImpl(localPipeline, JacksonAdapter.createDefaultSerializerAdapter(), localEndpoint); return client; } diff --git a/typespec-tests/src/main/java/com/type/union/implementation/EnumsOnliesImpl.java b/typespec-tests/src/main/java/com/type/union/implementation/EnumsOnliesImpl.java index 1e77334931..0c996a5669 100644 --- a/typespec-tests/src/main/java/com/type/union/implementation/EnumsOnliesImpl.java +++ b/typespec-tests/src/main/java/com/type/union/implementation/EnumsOnliesImpl.java @@ -9,6 +9,7 @@ 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; @@ -55,7 +56,7 @@ public final class EnumsOnliesImpl { * The interface defining all the services for UnionClientEnumsOnlies to be used by the proxy service to perform * REST calls. */ - @Host("http://localhost:3000") + @Host("{endpoint}") @ServiceInterface(name = "UnionClientEnumsOnli") public interface EnumsOnliesService { @Get("/type/union/enums-only") @@ -64,8 +65,8 @@ public interface EnumsOnliesService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> get(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Get("/type/union/enums-only") @ExpectedResponses({ 200 }) @@ -73,8 +74,8 @@ Mono> get(@HeaderParam("accept") String accept, RequestOpti @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response getSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Post("/type/union/enums-only") @ExpectedResponses({ 204 }) @@ -82,8 +83,9 @@ Response getSync(@HeaderParam("accept") String accept, RequestOption @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> send(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData sendRequest3, RequestOptions requestOptions, Context context); + 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 }) @@ -91,7 +93,7 @@ Mono> send(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response sendSync(@HeaderParam("accept") String accept, + Response sendSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData sendRequest3, RequestOptions requestOptions, Context context); } @@ -118,7 +120,7 @@ Response sendSync(@HeaderParam("accept") String accept, @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getWithResponseAsync(RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.get(accept, requestOptions, context)); + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); } /** @@ -144,7 +146,7 @@ public Mono> getWithResponseAsync(RequestOptions requestOpt @ServiceMethod(returns = ReturnType.SINGLE) public Response getWithResponse(RequestOptions requestOptions) { final String accept = "application/json"; - return service.getSync(accept, requestOptions, Context.NONE); + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); } /** @@ -170,8 +172,9 @@ public Response getWithResponse(RequestOptions requestOptions) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> sendWithResponseAsync(BinaryData sendRequest3, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.send(accept, sendRequest3, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.send(this.client.getEndpoint(), contentType, sendRequest3, requestOptions, context)); } /** @@ -197,7 +200,7 @@ public Mono> sendWithResponseAsync(BinaryData sendRequest3, Reque */ @ServiceMethod(returns = ReturnType.SINGLE) public Response sendWithResponse(BinaryData sendRequest3, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.sendSync(accept, sendRequest3, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.sendSync(this.client.getEndpoint(), contentType, sendRequest3, requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/type/union/implementation/FloatsOnliesImpl.java b/typespec-tests/src/main/java/com/type/union/implementation/FloatsOnliesImpl.java index 0d38239585..535a35f0b4 100644 --- a/typespec-tests/src/main/java/com/type/union/implementation/FloatsOnliesImpl.java +++ b/typespec-tests/src/main/java/com/type/union/implementation/FloatsOnliesImpl.java @@ -9,6 +9,7 @@ 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; @@ -55,7 +56,7 @@ public final class FloatsOnliesImpl { * The interface defining all the services for UnionClientFloatsOnlies to be used by the proxy service to perform * REST calls. */ - @Host("http://localhost:3000") + @Host("{endpoint}") @ServiceInterface(name = "UnionClientFloatsOnl") public interface FloatsOnliesService { @Get("/type/union/floats-only") @@ -64,8 +65,8 @@ public interface FloatsOnliesService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> get(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Get("/type/union/floats-only") @ExpectedResponses({ 200 }) @@ -73,8 +74,8 @@ Mono> get(@HeaderParam("accept") String accept, RequestOpti @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response getSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Post("/type/union/floats-only") @ExpectedResponses({ 204 }) @@ -82,8 +83,9 @@ Response getSync(@HeaderParam("accept") String accept, RequestOption @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> send(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData sendRequest5, RequestOptions requestOptions, Context context); + 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 }) @@ -91,7 +93,7 @@ Mono> send(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response sendSync(@HeaderParam("accept") String accept, + Response sendSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData sendRequest5, RequestOptions requestOptions, Context context); } @@ -115,7 +117,7 @@ Response sendSync(@HeaderParam("accept") String accept, @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getWithResponseAsync(RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.get(accept, requestOptions, context)); + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); } /** @@ -138,7 +140,7 @@ public Mono> getWithResponseAsync(RequestOptions requestOpt @ServiceMethod(returns = ReturnType.SINGLE) public Response getWithResponse(RequestOptions requestOptions) { final String accept = "application/json"; - return service.getSync(accept, requestOptions, Context.NONE); + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); } /** @@ -161,8 +163,9 @@ public Response getWithResponse(RequestOptions requestOptions) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> sendWithResponseAsync(BinaryData sendRequest5, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.send(accept, sendRequest5, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.send(this.client.getEndpoint(), contentType, sendRequest5, requestOptions, context)); } /** @@ -185,7 +188,7 @@ public Mono> sendWithResponseAsync(BinaryData sendRequest5, Reque */ @ServiceMethod(returns = ReturnType.SINGLE) public Response sendWithResponse(BinaryData sendRequest5, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.sendSync(accept, sendRequest5, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.sendSync(this.client.getEndpoint(), contentType, sendRequest5, requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/type/union/implementation/IntsOnliesImpl.java b/typespec-tests/src/main/java/com/type/union/implementation/IntsOnliesImpl.java index a83f054fc6..3fb60afe18 100644 --- a/typespec-tests/src/main/java/com/type/union/implementation/IntsOnliesImpl.java +++ b/typespec-tests/src/main/java/com/type/union/implementation/IntsOnliesImpl.java @@ -9,6 +9,7 @@ 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; @@ -55,7 +56,7 @@ public final class IntsOnliesImpl { * The interface defining all the services for UnionClientIntsOnlies to be used by the proxy service to perform REST * calls. */ - @Host("http://localhost:3000") + @Host("{endpoint}") @ServiceInterface(name = "UnionClientIntsOnlie") public interface IntsOnliesService { @Get("/type/union/ints-only") @@ -64,8 +65,8 @@ public interface IntsOnliesService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> get(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Get("/type/union/ints-only") @ExpectedResponses({ 200 }) @@ -73,8 +74,8 @@ Mono> get(@HeaderParam("accept") String accept, RequestOpti @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response getSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Post("/type/union/ints-only") @ExpectedResponses({ 204 }) @@ -82,8 +83,9 @@ Response getSync(@HeaderParam("accept") String accept, RequestOption @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> send(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData sendRequest6, RequestOptions requestOptions, Context context); + 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 }) @@ -91,7 +93,7 @@ Mono> send(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response sendSync(@HeaderParam("accept") String accept, + Response sendSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData sendRequest6, RequestOptions requestOptions, Context context); } @@ -115,7 +117,7 @@ Response sendSync(@HeaderParam("accept") String accept, @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getWithResponseAsync(RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.get(accept, requestOptions, context)); + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); } /** @@ -138,7 +140,7 @@ public Mono> getWithResponseAsync(RequestOptions requestOpt @ServiceMethod(returns = ReturnType.SINGLE) public Response getWithResponse(RequestOptions requestOptions) { final String accept = "application/json"; - return service.getSync(accept, requestOptions, Context.NONE); + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); } /** @@ -161,8 +163,9 @@ public Response getWithResponse(RequestOptions requestOptions) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> sendWithResponseAsync(BinaryData sendRequest6, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.send(accept, sendRequest6, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.send(this.client.getEndpoint(), contentType, sendRequest6, requestOptions, context)); } /** @@ -185,7 +188,7 @@ public Mono> sendWithResponseAsync(BinaryData sendRequest6, Reque */ @ServiceMethod(returns = ReturnType.SINGLE) public Response sendWithResponse(BinaryData sendRequest6, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.sendSync(accept, sendRequest6, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.sendSync(this.client.getEndpoint(), contentType, sendRequest6, requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/type/union/implementation/MixedLiteralsImpl.java b/typespec-tests/src/main/java/com/type/union/implementation/MixedLiteralsImpl.java index 0009929c23..ba55149b22 100644 --- a/typespec-tests/src/main/java/com/type/union/implementation/MixedLiteralsImpl.java +++ b/typespec-tests/src/main/java/com/type/union/implementation/MixedLiteralsImpl.java @@ -9,6 +9,7 @@ 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; @@ -55,7 +56,7 @@ public final class MixedLiteralsImpl { * The interface defining all the services for UnionClientMixedLiterals to be used by the proxy service to perform * REST calls. */ - @Host("http://localhost:3000") + @Host("{endpoint}") @ServiceInterface(name = "UnionClientMixedLite") public interface MixedLiteralsService { @Get("/type/union/mixed-literals") @@ -64,8 +65,8 @@ public interface MixedLiteralsService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> get(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Get("/type/union/mixed-literals") @ExpectedResponses({ 200 }) @@ -73,8 +74,8 @@ Mono> get(@HeaderParam("accept") String accept, RequestOpti @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response getSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Post("/type/union/mixed-literals") @ExpectedResponses({ 204 }) @@ -82,8 +83,9 @@ Response getSync(@HeaderParam("accept") String accept, RequestOption @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> send(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData sendRequest1, RequestOptions requestOptions, Context context); + 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 }) @@ -91,7 +93,7 @@ Mono> send(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response sendSync(@HeaderParam("accept") String accept, + Response sendSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData sendRequest1, RequestOptions requestOptions, Context context); } @@ -120,7 +122,7 @@ Response sendSync(@HeaderParam("accept") String accept, @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getWithResponseAsync(RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.get(accept, requestOptions, context)); + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); } /** @@ -148,7 +150,7 @@ public Mono> getWithResponseAsync(RequestOptions requestOpt @ServiceMethod(returns = ReturnType.SINGLE) public Response getWithResponse(RequestOptions requestOptions) { final String accept = "application/json"; - return service.getSync(accept, requestOptions, Context.NONE); + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); } /** @@ -176,8 +178,9 @@ public Response getWithResponse(RequestOptions requestOptions) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> sendWithResponseAsync(BinaryData sendRequest1, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.send(accept, sendRequest1, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.send(this.client.getEndpoint(), contentType, sendRequest1, requestOptions, context)); } /** @@ -205,7 +208,7 @@ public Mono> sendWithResponseAsync(BinaryData sendRequest1, Reque */ @ServiceMethod(returns = ReturnType.SINGLE) public Response sendWithResponse(BinaryData sendRequest1, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.sendSync(accept, sendRequest1, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.sendSync(this.client.getEndpoint(), contentType, sendRequest1, requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/type/union/implementation/MixedTypesImpl.java b/typespec-tests/src/main/java/com/type/union/implementation/MixedTypesImpl.java index cfa98f8b9f..addcec99e0 100644 --- a/typespec-tests/src/main/java/com/type/union/implementation/MixedTypesImpl.java +++ b/typespec-tests/src/main/java/com/type/union/implementation/MixedTypesImpl.java @@ -9,6 +9,7 @@ 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; @@ -55,7 +56,7 @@ public final class MixedTypesImpl { * The interface defining all the services for UnionClientMixedTypes to be used by the proxy service to perform REST * calls. */ - @Host("http://localhost:3000") + @Host("{endpoint}") @ServiceInterface(name = "UnionClientMixedType") public interface MixedTypesService { @Get("/type/union/mixed-types") @@ -64,8 +65,8 @@ public interface MixedTypesService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> get(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Get("/type/union/mixed-types") @ExpectedResponses({ 200 }) @@ -73,8 +74,8 @@ Mono> get(@HeaderParam("accept") String accept, RequestOpti @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response getSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Post("/type/union/mixed-types") @ExpectedResponses({ 204 }) @@ -82,8 +83,9 @@ Response getSync(@HeaderParam("accept") String accept, RequestOption @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> send(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData sendRequest, RequestOptions requestOptions, Context context); + 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 }) @@ -91,7 +93,7 @@ Mono> send(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response sendSync(@HeaderParam("accept") String accept, + Response sendSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData sendRequest, RequestOptions requestOptions, Context context); } @@ -123,7 +125,7 @@ Response sendSync(@HeaderParam("accept") String accept, @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getWithResponseAsync(RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.get(accept, requestOptions, context)); + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); } /** @@ -154,7 +156,7 @@ public Mono> getWithResponseAsync(RequestOptions requestOpt @ServiceMethod(returns = ReturnType.SINGLE) public Response getWithResponse(RequestOptions requestOptions) { final String accept = "application/json"; - return service.getSync(accept, requestOptions, Context.NONE); + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); } /** @@ -185,8 +187,9 @@ public Response getWithResponse(RequestOptions requestOptions) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> sendWithResponseAsync(BinaryData sendRequest, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.send(accept, sendRequest, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.send(this.client.getEndpoint(), contentType, sendRequest, requestOptions, context)); } /** @@ -217,7 +220,7 @@ public Mono> sendWithResponseAsync(BinaryData sendRequest, Reques */ @ServiceMethod(returns = ReturnType.SINGLE) public Response sendWithResponse(BinaryData sendRequest, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.sendSync(accept, sendRequest, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.sendSync(this.client.getEndpoint(), contentType, sendRequest, requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/type/union/implementation/ModelsOnliesImpl.java b/typespec-tests/src/main/java/com/type/union/implementation/ModelsOnliesImpl.java index b4e16f01c6..fcb3375e22 100644 --- a/typespec-tests/src/main/java/com/type/union/implementation/ModelsOnliesImpl.java +++ b/typespec-tests/src/main/java/com/type/union/implementation/ModelsOnliesImpl.java @@ -9,6 +9,7 @@ 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; @@ -55,7 +56,7 @@ public final class ModelsOnliesImpl { * The interface defining all the services for UnionClientModelsOnlies to be used by the proxy service to perform * REST calls. */ - @Host("http://localhost:3000") + @Host("{endpoint}") @ServiceInterface(name = "UnionClientModelsOnl") public interface ModelsOnliesService { @Get("/type/union/models-only") @@ -64,8 +65,8 @@ public interface ModelsOnliesService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> get(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Get("/type/union/models-only") @ExpectedResponses({ 200 }) @@ -73,8 +74,8 @@ Mono> get(@HeaderParam("accept") String accept, RequestOpti @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response getSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Post("/type/union/models-only") @ExpectedResponses({ 204 }) @@ -82,8 +83,9 @@ Response getSync(@HeaderParam("accept") String accept, RequestOption @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> send(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData sendRequest4, RequestOptions requestOptions, Context context); + 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 }) @@ -91,7 +93,7 @@ Mono> send(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response sendSync(@HeaderParam("accept") String accept, + Response sendSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData sendRequest4, RequestOptions requestOptions, Context context); } @@ -115,7 +117,7 @@ Response sendSync(@HeaderParam("accept") String accept, @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getWithResponseAsync(RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.get(accept, requestOptions, context)); + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); } /** @@ -138,7 +140,7 @@ public Mono> getWithResponseAsync(RequestOptions requestOpt @ServiceMethod(returns = ReturnType.SINGLE) public Response getWithResponse(RequestOptions requestOptions) { final String accept = "application/json"; - return service.getSync(accept, requestOptions, Context.NONE); + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); } /** @@ -161,8 +163,9 @@ public Response getWithResponse(RequestOptions requestOptions) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> sendWithResponseAsync(BinaryData sendRequest4, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.send(accept, sendRequest4, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.send(this.client.getEndpoint(), contentType, sendRequest4, requestOptions, context)); } /** @@ -185,7 +188,7 @@ public Mono> sendWithResponseAsync(BinaryData sendRequest4, Reque */ @ServiceMethod(returns = ReturnType.SINGLE) public Response sendWithResponse(BinaryData sendRequest4, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.sendSync(accept, sendRequest4, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.sendSync(this.client.getEndpoint(), contentType, sendRequest4, requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/type/union/implementation/StringAndArraysImpl.java b/typespec-tests/src/main/java/com/type/union/implementation/StringAndArraysImpl.java index 82db1f931b..671d05b444 100644 --- a/typespec-tests/src/main/java/com/type/union/implementation/StringAndArraysImpl.java +++ b/typespec-tests/src/main/java/com/type/union/implementation/StringAndArraysImpl.java @@ -9,6 +9,7 @@ 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; @@ -55,7 +56,7 @@ public final class StringAndArraysImpl { * The interface defining all the services for UnionClientStringAndArrays to be used by the proxy service to perform * REST calls. */ - @Host("http://localhost:3000") + @Host("{endpoint}") @ServiceInterface(name = "UnionClientStringAnd") public interface StringAndArraysService { @Get("/type/union/string-and-array") @@ -64,8 +65,8 @@ public interface StringAndArraysService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> get(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Get("/type/union/string-and-array") @ExpectedResponses({ 200 }) @@ -73,8 +74,8 @@ Mono> get(@HeaderParam("accept") String accept, RequestOpti @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response getSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Post("/type/union/string-and-array") @ExpectedResponses({ 204 }) @@ -82,8 +83,9 @@ Response getSync(@HeaderParam("accept") String accept, RequestOption @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> send(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData sendRequest2, RequestOptions requestOptions, Context context); + 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 }) @@ -91,7 +93,7 @@ Mono> send(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response sendSync(@HeaderParam("accept") String accept, + Response sendSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData sendRequest2, RequestOptions requestOptions, Context context); } @@ -118,7 +120,7 @@ Response sendSync(@HeaderParam("accept") String accept, @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getWithResponseAsync(RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.get(accept, requestOptions, context)); + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); } /** @@ -144,7 +146,7 @@ public Mono> getWithResponseAsync(RequestOptions requestOpt @ServiceMethod(returns = ReturnType.SINGLE) public Response getWithResponse(RequestOptions requestOptions) { final String accept = "application/json"; - return service.getSync(accept, requestOptions, Context.NONE); + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); } /** @@ -170,8 +172,9 @@ public Response getWithResponse(RequestOptions requestOptions) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> sendWithResponseAsync(BinaryData sendRequest2, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.send(accept, sendRequest2, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.send(this.client.getEndpoint(), contentType, sendRequest2, requestOptions, context)); } /** @@ -197,7 +200,7 @@ public Mono> sendWithResponseAsync(BinaryData sendRequest2, Reque */ @ServiceMethod(returns = ReturnType.SINGLE) public Response sendWithResponse(BinaryData sendRequest2, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.sendSync(accept, sendRequest2, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.sendSync(this.client.getEndpoint(), contentType, sendRequest2, requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/type/union/implementation/StringExtensibleNamedsImpl.java b/typespec-tests/src/main/java/com/type/union/implementation/StringExtensibleNamedsImpl.java index 8066f73f79..8e6c8c197a 100644 --- a/typespec-tests/src/main/java/com/type/union/implementation/StringExtensibleNamedsImpl.java +++ b/typespec-tests/src/main/java/com/type/union/implementation/StringExtensibleNamedsImpl.java @@ -9,6 +9,7 @@ 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; @@ -55,7 +56,7 @@ public final class StringExtensibleNamedsImpl { * The interface defining all the services for UnionClientStringExtensibleNameds to be used by the proxy service to * perform REST calls. */ - @Host("http://localhost:3000") + @Host("{endpoint}") @ServiceInterface(name = "UnionClientStringExt") public interface StringExtensibleNamedsService { @Get("/type/union/string-extensible-named") @@ -64,8 +65,8 @@ public interface StringExtensibleNamedsService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> get(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Get("/type/union/string-extensible-named") @ExpectedResponses({ 200 }) @@ -73,8 +74,8 @@ Mono> get(@HeaderParam("accept") String accept, RequestOpti @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response getSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Post("/type/union/string-extensible-named") @ExpectedResponses({ 204 }) @@ -82,8 +83,9 @@ Response getSync(@HeaderParam("accept") String accept, RequestOption @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> send(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData sendRequest7, RequestOptions requestOptions, Context context); + 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 }) @@ -91,7 +93,7 @@ Mono> send(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response sendSync(@HeaderParam("accept") String accept, + Response sendSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData sendRequest7, RequestOptions requestOptions, Context context); } @@ -115,7 +117,7 @@ Response sendSync(@HeaderParam("accept") String accept, @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getWithResponseAsync(RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.get(accept, requestOptions, context)); + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); } /** @@ -138,7 +140,7 @@ public Mono> getWithResponseAsync(RequestOptions requestOpt @ServiceMethod(returns = ReturnType.SINGLE) public Response getWithResponse(RequestOptions requestOptions) { final String accept = "application/json"; - return service.getSync(accept, requestOptions, Context.NONE); + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); } /** @@ -161,8 +163,9 @@ public Response getWithResponse(RequestOptions requestOptions) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> sendWithResponseAsync(BinaryData sendRequest7, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.send(accept, sendRequest7, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.send(this.client.getEndpoint(), contentType, sendRequest7, requestOptions, context)); } /** @@ -185,7 +188,7 @@ public Mono> sendWithResponseAsync(BinaryData sendRequest7, Reque */ @ServiceMethod(returns = ReturnType.SINGLE) public Response sendWithResponse(BinaryData sendRequest7, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.sendSync(accept, sendRequest7, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.sendSync(this.client.getEndpoint(), contentType, sendRequest7, requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/type/union/implementation/StringExtensiblesImpl.java b/typespec-tests/src/main/java/com/type/union/implementation/StringExtensiblesImpl.java index ed83e7409a..fd556aca11 100644 --- a/typespec-tests/src/main/java/com/type/union/implementation/StringExtensiblesImpl.java +++ b/typespec-tests/src/main/java/com/type/union/implementation/StringExtensiblesImpl.java @@ -9,6 +9,7 @@ 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; @@ -55,7 +56,7 @@ public final class StringExtensiblesImpl { * The interface defining all the services for UnionClientStringExtensibles to be used by the proxy service to * perform REST calls. */ - @Host("http://localhost:3000") + @Host("{endpoint}") @ServiceInterface(name = "UnionClientStringExt") public interface StringExtensiblesService { @Get("/type/union/string-extensible") @@ -64,8 +65,8 @@ public interface StringExtensiblesService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> get(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Get("/type/union/string-extensible") @ExpectedResponses({ 200 }) @@ -73,8 +74,8 @@ Mono> get(@HeaderParam("accept") String accept, RequestOpti @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response getSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Post("/type/union/string-extensible") @ExpectedResponses({ 204 }) @@ -82,8 +83,9 @@ Response getSync(@HeaderParam("accept") String accept, RequestOption @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> send(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData sendRequest8, RequestOptions requestOptions, Context context); + 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 }) @@ -91,7 +93,7 @@ Mono> send(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response sendSync(@HeaderParam("accept") String accept, + Response sendSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData sendRequest8, RequestOptions requestOptions, Context context); } @@ -115,7 +117,7 @@ Response sendSync(@HeaderParam("accept") String accept, @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getWithResponseAsync(RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.get(accept, requestOptions, context)); + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); } /** @@ -138,7 +140,7 @@ public Mono> getWithResponseAsync(RequestOptions requestOpt @ServiceMethod(returns = ReturnType.SINGLE) public Response getWithResponse(RequestOptions requestOptions) { final String accept = "application/json"; - return service.getSync(accept, requestOptions, Context.NONE); + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); } /** @@ -161,8 +163,9 @@ public Response getWithResponse(RequestOptions requestOptions) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> sendWithResponseAsync(BinaryData sendRequest8, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.send(accept, sendRequest8, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.send(this.client.getEndpoint(), contentType, sendRequest8, requestOptions, context)); } /** @@ -185,7 +188,7 @@ public Mono> sendWithResponseAsync(BinaryData sendRequest8, Reque */ @ServiceMethod(returns = ReturnType.SINGLE) public Response sendWithResponse(BinaryData sendRequest8, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.sendSync(accept, sendRequest8, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.sendSync(this.client.getEndpoint(), contentType, sendRequest8, requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/type/union/implementation/StringsOnliesImpl.java b/typespec-tests/src/main/java/com/type/union/implementation/StringsOnliesImpl.java index 58d503544e..902e491648 100644 --- a/typespec-tests/src/main/java/com/type/union/implementation/StringsOnliesImpl.java +++ b/typespec-tests/src/main/java/com/type/union/implementation/StringsOnliesImpl.java @@ -9,6 +9,7 @@ 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; @@ -55,7 +56,7 @@ public final class StringsOnliesImpl { * The interface defining all the services for UnionClientStringsOnlies to be used by the proxy service to perform * REST calls. */ - @Host("http://localhost:3000") + @Host("{endpoint}") @ServiceInterface(name = "UnionClientStringsOn") public interface StringsOnliesService { @Get("/type/union/strings-only") @@ -64,8 +65,8 @@ public interface StringsOnliesService { @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> get(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Get("/type/union/strings-only") @ExpectedResponses({ 200 }) @@ -73,8 +74,8 @@ Mono> get(@HeaderParam("accept") String accept, RequestOpti @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response getSync(@HeaderParam("accept") String accept, RequestOptions requestOptions, - Context context); + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); @Post("/type/union/strings-only") @ExpectedResponses({ 204 }) @@ -82,8 +83,9 @@ Response getSync(@HeaderParam("accept") String accept, RequestOption @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> send(@HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData sendRequest9, RequestOptions requestOptions, Context context); + 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 }) @@ -91,7 +93,7 @@ Mono> send(@HeaderParam("accept") String accept, @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response sendSync(@HeaderParam("accept") String accept, + Response sendSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData sendRequest9, RequestOptions requestOptions, Context context); } @@ -115,7 +117,7 @@ Response sendSync(@HeaderParam("accept") String accept, @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getWithResponseAsync(RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.get(accept, requestOptions, context)); + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); } /** @@ -138,7 +140,7 @@ public Mono> getWithResponseAsync(RequestOptions requestOpt @ServiceMethod(returns = ReturnType.SINGLE) public Response getWithResponse(RequestOptions requestOptions) { final String accept = "application/json"; - return service.getSync(accept, requestOptions, Context.NONE); + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); } /** @@ -161,8 +163,9 @@ public Response getWithResponse(RequestOptions requestOptions) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> sendWithResponseAsync(BinaryData sendRequest9, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.send(accept, sendRequest9, requestOptions, context)); + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.send(this.client.getEndpoint(), contentType, sendRequest9, requestOptions, context)); } /** @@ -185,7 +188,7 @@ public Mono> sendWithResponseAsync(BinaryData sendRequest9, Reque */ @ServiceMethod(returns = ReturnType.SINGLE) public Response sendWithResponse(BinaryData sendRequest9, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.sendSync(accept, sendRequest9, requestOptions, Context.NONE); + final String contentType = "application/json"; + return service.sendSync(this.client.getEndpoint(), contentType, sendRequest9, requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/type/union/implementation/UnionClientImpl.java b/typespec-tests/src/main/java/com/type/union/implementation/UnionClientImpl.java index 050995d3be..7a4459ca77 100644 --- a/typespec-tests/src/main/java/com/type/union/implementation/UnionClientImpl.java +++ b/typespec-tests/src/main/java/com/type/union/implementation/UnionClientImpl.java @@ -15,6 +15,20 @@ * 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. */ @@ -185,19 +199,22 @@ public MixedTypesImpl getMixedTypes() { /** * Initializes an instance of UnionClient client. + * + * @param endpoint Service host. */ - public UnionClientImpl() { + public UnionClientImpl(String endpoint) { this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), - JacksonAdapter.createDefaultSerializerAdapter()); + 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) { - this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter()); + public UnionClientImpl(HttpPipeline httpPipeline, String endpoint) { + this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint); } /** @@ -205,10 +222,12 @@ public UnionClientImpl(HttpPipeline httpPipeline) { * * @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) { + 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); diff --git a/typespec-tests/src/main/java/com/versioning/added/implementation/AddedClientImpl.java b/typespec-tests/src/main/java/com/versioning/added/implementation/AddedClientImpl.java index ea3c2305cd..76f0d27904 100644 --- a/typespec-tests/src/main/java/com/versioning/added/implementation/AddedClientImpl.java +++ b/typespec-tests/src/main/java/com/versioning/added/implementation/AddedClientImpl.java @@ -184,8 +184,9 @@ public interface AddedClientService { @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("accept") String accept, - @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + @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 }) @@ -194,8 +195,9 @@ Mono> v1(@HostParam("endpoint") String endpoint, @HostParam @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("accept") String accept, - @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + @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 }) @@ -204,8 +206,8 @@ Response v1Sync(@HostParam("endpoint") String endpoint, @HostParam(" @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Mono> v2(@HostParam("endpoint") String endpoint, @HostParam("version") String version, - @HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, - RequestOptions requestOptions, Context context); + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); @Post("/v2") @ExpectedResponses({ 200 }) @@ -214,8 +216,8 @@ Mono> v2(@HostParam("endpoint") String endpoint, @HostParam @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Response v2Sync(@HostParam("endpoint") String endpoint, @HostParam("version") String version, - @HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, - RequestOptions requestOptions, Context context); + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); } /** @@ -252,9 +254,10 @@ Response v2Sync(@HostParam("endpoint") String endpoint, @HostParam(" @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, accept, body, - requestOptions, context)); + return FluxUtil.withContext(context -> service.v1(this.getEndpoint(), this.getVersion(), headerV2, contentType, + accept, body, requestOptions, context)); } /** @@ -290,9 +293,10 @@ public Mono> v1WithResponseAsync(String headerV2, BinaryDat */ @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, accept, body, requestOptions, - Context.NONE); + return service.v1Sync(this.getEndpoint(), this.getVersion(), headerV2, contentType, accept, body, + requestOptions, Context.NONE); } /** @@ -327,9 +331,10 @@ public Response v1WithResponse(String headerV2, BinaryData body, Req */ @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(), accept, body, requestOptions, context)); + return FluxUtil.withContext(context -> service.v2(this.getEndpoint(), this.getVersion(), contentType, accept, + body, requestOptions, context)); } /** @@ -364,7 +369,9 @@ public Mono> v2WithResponseAsync(BinaryData body, RequestOp */ @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(), accept, body, requestOptions, Context.NONE); + return service.v2Sync(this.getEndpoint(), this.getVersion(), contentType, accept, body, requestOptions, + Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/versioning/added/implementation/InterfaceV2sImpl.java b/typespec-tests/src/main/java/com/versioning/added/implementation/InterfaceV2sImpl.java index 31d6ad0d3c..a032c93597 100644 --- a/typespec-tests/src/main/java/com/versioning/added/implementation/InterfaceV2sImpl.java +++ b/typespec-tests/src/main/java/com/versioning/added/implementation/InterfaceV2sImpl.java @@ -75,8 +75,9 @@ public interface InterfaceV2sService { @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Mono> v2InInterface(@HostParam("endpoint") String endpoint, - @HostParam("version") String version, @HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + @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 }) @@ -85,8 +86,9 @@ Mono> v2InInterface(@HostParam("endpoint") String endpoint, @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Response v2InInterfaceSync(@HostParam("endpoint") String endpoint, - @HostParam("version") String version, @HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + @HostParam("version") String version, @HeaderParam("Content-Type") String contentType, + @HeaderParam("Accept") String accept, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); } /** @@ -121,9 +123,10 @@ Response v2InInterfaceSync(@HostParam("endpoint") String endpoint, */ @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(), accept, body, requestOptions, context)); + this.client.getVersion(), contentType, accept, body, requestOptions, context)); } /** @@ -158,8 +161,9 @@ public Mono> v2InInterfaceWithResponseAsync(BinaryData body */ @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(), accept, body, + return service.v2InInterfaceSync(this.client.getEndpoint(), this.client.getVersion(), contentType, accept, body, requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/versioning/madeoptional/implementation/MadeOptionalClientImpl.java b/typespec-tests/src/main/java/com/versioning/madeoptional/implementation/MadeOptionalClientImpl.java index 11b87890d5..fc57f6064f 100644 --- a/typespec-tests/src/main/java/com/versioning/madeoptional/implementation/MadeOptionalClientImpl.java +++ b/typespec-tests/src/main/java/com/versioning/madeoptional/implementation/MadeOptionalClientImpl.java @@ -171,8 +171,8 @@ public interface MadeOptionalClientService { @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Mono> test(@HostParam("endpoint") String endpoint, @HostParam("version") String version, - @HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, - RequestOptions requestOptions, Context context); + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); @Post("/test") @ExpectedResponses({ 200 }) @@ -181,8 +181,8 @@ Mono> test(@HostParam("endpoint") String endpoint, @HostPar @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Response testSync(@HostParam("endpoint") String endpoint, @HostParam("version") String version, - @HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, - RequestOptions requestOptions, Context context); + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); } /** @@ -222,9 +222,10 @@ Response testSync(@HostParam("endpoint") String endpoint, @HostParam */ @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(), accept, body, requestOptions, context)); + return FluxUtil.withContext(context -> service.test(this.getEndpoint(), this.getVersion(), contentType, accept, + body, requestOptions, context)); } /** @@ -264,7 +265,9 @@ public Mono> testWithResponseAsync(BinaryData body, Request */ @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(), accept, body, requestOptions, Context.NONE); + return service.testSync(this.getEndpoint(), this.getVersion(), contentType, accept, body, requestOptions, + Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/versioning/removed/implementation/RemovedClientImpl.java b/typespec-tests/src/main/java/com/versioning/removed/implementation/RemovedClientImpl.java index 75be98281d..74936454ac 100644 --- a/typespec-tests/src/main/java/com/versioning/removed/implementation/RemovedClientImpl.java +++ b/typespec-tests/src/main/java/com/versioning/removed/implementation/RemovedClientImpl.java @@ -169,8 +169,8 @@ public interface RemovedClientService { @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Mono> v2(@HostParam("endpoint") String endpoint, @HostParam("version") String version, - @HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, - RequestOptions requestOptions, Context context); + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); @Post("/v2") @ExpectedResponses({ 200 }) @@ -179,8 +179,8 @@ Mono> v2(@HostParam("endpoint") String endpoint, @HostParam @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Response v2Sync(@HostParam("endpoint") String endpoint, @HostParam("version") String version, - @HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, - RequestOptions requestOptions, Context context); + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); } /** @@ -215,9 +215,10 @@ Response v2Sync(@HostParam("endpoint") String endpoint, @HostParam(" */ @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(), accept, body, requestOptions, context)); + return FluxUtil.withContext(context -> service.v2(this.getEndpoint(), this.getVersion(), contentType, accept, + body, requestOptions, context)); } /** @@ -252,7 +253,9 @@ public Mono> v2WithResponseAsync(BinaryData body, RequestOp */ @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(), accept, body, requestOptions, Context.NONE); + return service.v2Sync(this.getEndpoint(), this.getVersion(), contentType, accept, body, requestOptions, + Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/versioning/renamedfrom/implementation/NewInterfacesImpl.java b/typespec-tests/src/main/java/com/versioning/renamedfrom/implementation/NewInterfacesImpl.java index 3efaf2c5a5..4f6dd02c68 100644 --- a/typespec-tests/src/main/java/com/versioning/renamedfrom/implementation/NewInterfacesImpl.java +++ b/typespec-tests/src/main/java/com/versioning/renamedfrom/implementation/NewInterfacesImpl.java @@ -75,8 +75,9 @@ public interface NewInterfacesService { @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Mono> newOpInNewInterface(@HostParam("endpoint") String endpoint, - @HostParam("version") String version, @HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + @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 }) @@ -85,8 +86,9 @@ Mono> newOpInNewInterface(@HostParam("endpoint") String end @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Response newOpInNewInterfaceSync(@HostParam("endpoint") String endpoint, - @HostParam("version") String version, @HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + @HostParam("version") String version, @HeaderParam("Content-Type") String contentType, + @HeaderParam("Accept") String accept, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); } /** @@ -122,9 +124,10 @@ Response newOpInNewInterfaceSync(@HostParam("endpoint") String endpo @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(), accept, body, requestOptions, context)); + this.client.getVersion(), contentType, accept, body, requestOptions, context)); } /** @@ -159,8 +162,9 @@ public Mono> newOpInNewInterfaceWithResponseAsync(BinaryDat */ @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(), accept, body, - requestOptions, Context.NONE); + return service.newOpInNewInterfaceSync(this.client.getEndpoint(), this.client.getVersion(), contentType, accept, + body, requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/versioning/renamedfrom/implementation/RenamedFromClientImpl.java b/typespec-tests/src/main/java/com/versioning/renamedfrom/implementation/RenamedFromClientImpl.java index 8cb793c44a..4b3e777ef4 100644 --- a/typespec-tests/src/main/java/com/versioning/renamedfrom/implementation/RenamedFromClientImpl.java +++ b/typespec-tests/src/main/java/com/versioning/renamedfrom/implementation/RenamedFromClientImpl.java @@ -186,8 +186,9 @@ public interface RenamedFromClientService { @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Mono> newOp(@HostParam("endpoint") String endpoint, @HostParam("version") String version, - @QueryParam("newQuery") String newQuery, @HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + @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 }) @@ -196,8 +197,9 @@ Mono> newOp(@HostParam("endpoint") String endpoint, @HostPa @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Response newOpSync(@HostParam("endpoint") String endpoint, @HostParam("version") String version, - @QueryParam("newQuery") String newQuery, @HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + @QueryParam("newQuery") String newQuery, @HeaderParam("Content-Type") String contentType, + @HeaderParam("Accept") String accept, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); } /** @@ -234,9 +236,10 @@ Response newOpSync(@HostParam("endpoint") String endpoint, @HostPara @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, accept, - body, requestOptions, context)); + return FluxUtil.withContext(context -> service.newOp(this.getEndpoint(), this.getVersion(), newQuery, + contentType, accept, body, requestOptions, context)); } /** @@ -272,8 +275,9 @@ public Mono> newOpWithResponseAsync(String newQuery, Binary */ @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, accept, body, requestOptions, - Context.NONE); + return service.newOpSync(this.getEndpoint(), this.getVersion(), newQuery, contentType, accept, body, + requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/versioning/returntypechangedfrom/implementation/ReturnTypeChangedFromClientImpl.java b/typespec-tests/src/main/java/com/versioning/returntypechangedfrom/implementation/ReturnTypeChangedFromClientImpl.java index 58e80a8662..ac32c99f2e 100644 --- a/typespec-tests/src/main/java/com/versioning/returntypechangedfrom/implementation/ReturnTypeChangedFromClientImpl.java +++ b/typespec-tests/src/main/java/com/versioning/returntypechangedfrom/implementation/ReturnTypeChangedFromClientImpl.java @@ -172,8 +172,8 @@ public interface ReturnTypeChangedFromClientService { @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Mono> test(@HostParam("endpoint") String endpoint, @HostParam("version") String version, - @HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, - RequestOptions requestOptions, Context context); + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); @Post("/test") @ExpectedResponses({ 200 }) @@ -182,8 +182,8 @@ Mono> test(@HostParam("endpoint") String endpoint, @HostPar @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Response testSync(@HostParam("endpoint") String endpoint, @HostParam("version") String version, - @HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData body, - RequestOptions requestOptions, Context context); + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); } /** @@ -210,9 +210,10 @@ Response testSync(@HostParam("endpoint") String endpoint, @HostParam */ @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(), accept, body, requestOptions, context)); + return FluxUtil.withContext(context -> service.test(this.getEndpoint(), this.getVersion(), contentType, accept, + body, requestOptions, context)); } /** @@ -239,7 +240,9 @@ public Mono> testWithResponseAsync(BinaryData body, Request */ @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(), accept, body, requestOptions, Context.NONE); + return service.testSync(this.getEndpoint(), this.getVersion(), contentType, accept, body, requestOptions, + Context.NONE); } } diff --git a/typespec-tests/src/main/java/com/versioning/typechangedfrom/implementation/TypeChangedFromClientImpl.java b/typespec-tests/src/main/java/com/versioning/typechangedfrom/implementation/TypeChangedFromClientImpl.java index b11f99fc16..76874be3a0 100644 --- a/typespec-tests/src/main/java/com/versioning/typechangedfrom/implementation/TypeChangedFromClientImpl.java +++ b/typespec-tests/src/main/java/com/versioning/typechangedfrom/implementation/TypeChangedFromClientImpl.java @@ -172,8 +172,9 @@ public interface TypeChangedFromClientService { @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Mono> test(@HostParam("endpoint") String endpoint, @HostParam("version") String version, - @QueryParam("param") String param, @HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + @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 }) @@ -182,8 +183,9 @@ Mono> test(@HostParam("endpoint") String endpoint, @HostPar @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Response testSync(@HostParam("endpoint") String endpoint, @HostParam("version") String version, - @QueryParam("param") String param, @HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + @QueryParam("param") String param, @HeaderParam("Content-Type") String contentType, + @HeaderParam("Accept") String accept, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); } /** @@ -218,9 +220,10 @@ Response testSync(@HostParam("endpoint") String endpoint, @HostParam @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, accept, body, - requestOptions, context)); + return FluxUtil.withContext(context -> service.test(this.getEndpoint(), this.getVersion(), param, contentType, + accept, body, requestOptions, context)); } /** @@ -254,8 +257,9 @@ public Mono> testWithResponseAsync(String param, BinaryData */ @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, accept, body, requestOptions, + return service.testSync(this.getEndpoint(), this.getVersion(), param, contentType, accept, body, requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/samples/java/com/_specs_/azure/example/basic/generated/BasicAction.java b/typespec-tests/src/samples/java/com/_specs_/azure/example/basic/generated/BasicAction.java index e2bb62fdc7..5764a952fe 100644 --- a/typespec-tests/src/samples/java/com/_specs_/azure/example/basic/generated/BasicAction.java +++ b/typespec-tests/src/samples/java/com/_specs_/azure/example/basic/generated/BasicAction.java @@ -16,7 +16,8 @@ public class BasicAction { public static void main(String[] args) { - AzureExampleClient azureExampleClient = new AzureExampleClientBuilder().buildClient(); + 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") diff --git a/typespec-tests/src/test/java/com/_specs_/azure/clientgenerator/core/access/generated/AccessClientTestBase.java b/typespec-tests/src/test/java/com/_specs_/azure/clientgenerator/core/access/generated/AccessClientTestBase.java index 994183c7b3..6d967d662e 100644 --- a/typespec-tests/src/test/java/com/_specs_/azure/clientgenerator/core/access/generated/AccessClientTestBase.java +++ b/typespec-tests/src/test/java/com/_specs_/azure/clientgenerator/core/access/generated/AccessClientTestBase.java @@ -18,6 +18,7 @@ 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; @@ -30,9 +31,10 @@ class AccessClientTestBase extends TestProxyTestBase { @Override protected void beforeTest() { - AccessClientBuilder publicOperationClientbuilder - = new AccessClientBuilder().httpClient(HttpClient.createDefault()) - .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + 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) { @@ -40,9 +42,10 @@ protected void beforeTest() { } publicOperationClient = publicOperationClientbuilder.buildPublicOperationClient(); - AccessClientBuilder internalOperationClientbuilder - = new AccessClientBuilder().httpClient(HttpClient.createDefault()) - .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + 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) { @@ -50,9 +53,10 @@ protected void beforeTest() { } internalOperationClient = internalOperationClientbuilder.buildInternalOperationClient(); - AccessClientBuilder sharedModelInOperationClientbuilder - = new AccessClientBuilder().httpClient(HttpClient.createDefault()) - .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + 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) { @@ -60,9 +64,10 @@ protected void beforeTest() { } sharedModelInOperationClient = sharedModelInOperationClientbuilder.buildSharedModelInOperationClient(); - AccessClientBuilder relativeModelInOperationClientbuilder - = new AccessClientBuilder().httpClient(HttpClient.createDefault()) - .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + 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) { diff --git a/typespec-tests/src/test/java/com/_specs_/azure/clientgenerator/core/usage/generated/UsageClientTestBase.java b/typespec-tests/src/test/java/com/_specs_/azure/clientgenerator/core/usage/generated/UsageClientTestBase.java index 774278f9d7..4e2c739eb3 100644 --- a/typespec-tests/src/test/java/com/_specs_/azure/clientgenerator/core/usage/generated/UsageClientTestBase.java +++ b/typespec-tests/src/test/java/com/_specs_/azure/clientgenerator/core/usage/generated/UsageClientTestBase.java @@ -15,13 +15,16 @@ 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().httpClient(HttpClient.createDefault()) + 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()); diff --git a/typespec-tests/src/test/java/com/_specs_/azure/core/basic/generated/BasicClientTestBase.java b/typespec-tests/src/test/java/com/_specs_/azure/core/basic/generated/BasicClientTestBase.java index b170bd5050..6451d16c18 100644 --- a/typespec-tests/src/test/java/com/_specs_/azure/core/basic/generated/BasicClientTestBase.java +++ b/typespec-tests/src/test/java/com/_specs_/azure/core/basic/generated/BasicClientTestBase.java @@ -15,13 +15,16 @@ 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().httpClient(HttpClient.createDefault()) + 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()); diff --git a/typespec-tests/src/test/java/com/_specs_/azure/core/lro/rpc/generated/RpcClientTestBase.java b/typespec-tests/src/test/java/com/_specs_/azure/core/lro/rpc/generated/RpcClientTestBase.java index ddac5cb0db..7c4090b05d 100644 --- a/typespec-tests/src/test/java/com/_specs_/azure/core/lro/rpc/generated/RpcClientTestBase.java +++ b/typespec-tests/src/test/java/com/_specs_/azure/core/lro/rpc/generated/RpcClientTestBase.java @@ -15,13 +15,16 @@ 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().httpClient(HttpClient.createDefault()) + 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()); diff --git a/typespec-tests/src/test/java/com/_specs_/azure/core/lro/standard/generated/StandardClientTestBase.java b/typespec-tests/src/test/java/com/_specs_/azure/core/lro/standard/generated/StandardClientTestBase.java index e7d75b18b0..ac96f13085 100644 --- a/typespec-tests/src/test/java/com/_specs_/azure/core/lro/standard/generated/StandardClientTestBase.java +++ b/typespec-tests/src/test/java/com/_specs_/azure/core/lro/standard/generated/StandardClientTestBase.java @@ -15,13 +15,16 @@ 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().httpClient(HttpClient.createDefault()) + 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()); diff --git a/typespec-tests/src/test/java/com/_specs_/azure/core/model/generated/ModelClientTestBase.java b/typespec-tests/src/test/java/com/_specs_/azure/core/model/generated/ModelClientTestBase.java index 5c53f73869..5c65b8a132 100644 --- a/typespec-tests/src/test/java/com/_specs_/azure/core/model/generated/ModelClientTestBase.java +++ b/typespec-tests/src/test/java/com/_specs_/azure/core/model/generated/ModelClientTestBase.java @@ -15,13 +15,16 @@ 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().httpClient(HttpClient.createDefault()) + 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()); diff --git a/typespec-tests/src/test/java/com/_specs_/azure/core/page/generated/PageClientTestBase.java b/typespec-tests/src/test/java/com/_specs_/azure/core/page/generated/PageClientTestBase.java index 8ab03ed7b9..b5d61efe3d 100644 --- a/typespec-tests/src/test/java/com/_specs_/azure/core/page/generated/PageClientTestBase.java +++ b/typespec-tests/src/test/java/com/_specs_/azure/core/page/generated/PageClientTestBase.java @@ -16,6 +16,7 @@ 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; @@ -24,7 +25,9 @@ class PageClientTestBase extends TestProxyTestBase { @Override protected void beforeTest() { - PageClientBuilder pageClientbuilder = new PageClientBuilder().httpClient(HttpClient.createDefault()) + 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()); @@ -33,9 +36,10 @@ protected void beforeTest() { } pageClient = pageClientbuilder.buildClient(); - PageClientBuilder twoModelsAsPageItemClientbuilder - = new PageClientBuilder().httpClient(HttpClient.createDefault()) - .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + 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) { diff --git a/typespec-tests/src/test/java/com/_specs_/azure/core/scalar/generated/ScalarClientTestBase.java b/typespec-tests/src/test/java/com/_specs_/azure/core/scalar/generated/ScalarClientTestBase.java index 9ef79ad174..426bd1baed 100644 --- a/typespec-tests/src/test/java/com/_specs_/azure/core/scalar/generated/ScalarClientTestBase.java +++ b/typespec-tests/src/test/java/com/_specs_/azure/core/scalar/generated/ScalarClientTestBase.java @@ -15,13 +15,16 @@ 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().httpClient(HttpClient.createDefault()) + 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()); diff --git a/typespec-tests/src/test/java/com/_specs_/azure/core/traits/generated/TraitsClientTestBase.java b/typespec-tests/src/test/java/com/_specs_/azure/core/traits/generated/TraitsClientTestBase.java index 453debb61d..cc582cb39c 100644 --- a/typespec-tests/src/test/java/com/_specs_/azure/core/traits/generated/TraitsClientTestBase.java +++ b/typespec-tests/src/test/java/com/_specs_/azure/core/traits/generated/TraitsClientTestBase.java @@ -15,13 +15,16 @@ 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().httpClient(HttpClient.createDefault()) + 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()); diff --git a/typespec-tests/src/test/java/com/_specs_/azure/example/basic/generated/AzureExampleClientTestBase.java b/typespec-tests/src/test/java/com/_specs_/azure/example/basic/generated/AzureExampleClientTestBase.java index 4ef683eb85..df2da2a545 100644 --- a/typespec-tests/src/test/java/com/_specs_/azure/example/basic/generated/AzureExampleClientTestBase.java +++ b/typespec-tests/src/test/java/com/_specs_/azure/example/basic/generated/AzureExampleClientTestBase.java @@ -15,15 +15,17 @@ 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().httpClient(HttpClient.createDefault()) - .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + 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) { diff --git a/typespec-tests/src/test/java/com/authentication/apikey/generated/ApiKeyClientTestBase.java b/typespec-tests/src/test/java/com/authentication/apikey/generated/ApiKeyClientTestBase.java index 8786d55aa0..a4a047af29 100644 --- a/typespec-tests/src/test/java/com/authentication/apikey/generated/ApiKeyClientTestBase.java +++ b/typespec-tests/src/test/java/com/authentication/apikey/generated/ApiKeyClientTestBase.java @@ -15,13 +15,16 @@ 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().httpClient(HttpClient.createDefault()) + 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()); diff --git a/typespec-tests/src/test/java/com/authentication/http/custom/generated/CustomClientTestBase.java b/typespec-tests/src/test/java/com/authentication/http/custom/generated/CustomClientTestBase.java index 7a9fa6487e..898fe6fd8b 100644 --- a/typespec-tests/src/test/java/com/authentication/http/custom/generated/CustomClientTestBase.java +++ b/typespec-tests/src/test/java/com/authentication/http/custom/generated/CustomClientTestBase.java @@ -15,13 +15,16 @@ 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().httpClient(HttpClient.createDefault()) + 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()); diff --git a/typespec-tests/src/test/java/com/authentication/oauth2/generated/OAuth2ClientTestBase.java b/typespec-tests/src/test/java/com/authentication/oauth2/generated/OAuth2ClientTestBase.java index 7366e17cbe..f4beb748f1 100644 --- a/typespec-tests/src/test/java/com/authentication/oauth2/generated/OAuth2ClientTestBase.java +++ b/typespec-tests/src/test/java/com/authentication/oauth2/generated/OAuth2ClientTestBase.java @@ -16,6 +16,7 @@ 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 { @@ -23,7 +24,9 @@ class OAuth2ClientTestBase extends TestProxyTestBase { @Override protected void beforeTest() { - OAuth2ClientBuilder oAuth2Clientbuilder = new OAuth2ClientBuilder().httpClient(HttpClient.createDefault()) + 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()) diff --git a/typespec-tests/src/test/java/com/authentication/union/generated/UnionClientTestBase.java b/typespec-tests/src/test/java/com/authentication/union/generated/UnionClientTestBase.java index c137e9522c..f2282b1581 100644 --- a/typespec-tests/src/test/java/com/authentication/union/generated/UnionClientTestBase.java +++ b/typespec-tests/src/test/java/com/authentication/union/generated/UnionClientTestBase.java @@ -16,6 +16,7 @@ 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 { @@ -23,7 +24,9 @@ class UnionClientTestBase extends TestProxyTestBase { @Override protected void beforeTest() { - UnionClientBuilder unionClientbuilder = new UnionClientBuilder().httpClient(HttpClient.createDefault()) + 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()); diff --git a/typespec-tests/src/test/java/com/azure/clientgenerator/core/flattenproperty/generated/FlattenPropertyClientTestBase.java b/typespec-tests/src/test/java/com/azure/clientgenerator/core/flattenproperty/generated/FlattenPropertyClientTestBase.java index 6dd9056471..4b7d84689b 100644 --- a/typespec-tests/src/test/java/com/azure/clientgenerator/core/flattenproperty/generated/FlattenPropertyClientTestBase.java +++ b/typespec-tests/src/test/java/com/azure/clientgenerator/core/flattenproperty/generated/FlattenPropertyClientTestBase.java @@ -15,15 +15,17 @@ 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 FlattenPropertyClientTestBase extends TestProxyTestBase { protected FlattenPropertyClient flattenPropertyClient; @Override protected void beforeTest() { - FlattenPropertyClientBuilder flattenPropertyClientbuilder - = new FlattenPropertyClientBuilder().httpClient(HttpClient.createDefault()) - .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + FlattenPropertyClientBuilder flattenPropertyClientbuilder = new FlattenPropertyClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); if (getTestMode() == TestMode.PLAYBACK) { flattenPropertyClientbuilder.httpClient(interceptorManager.getPlaybackClient()); } else if (getTestMode() == TestMode.RECORD) { diff --git a/typespec-tests/src/test/java/com/azure/specialheaders/xmsclientrequestid/generated/XmsClientRequestIdClientTestBase.java b/typespec-tests/src/test/java/com/azure/specialheaders/xmsclientrequestid/generated/XmsClientRequestIdClientTestBase.java index bf87ba32d7..0a4be4cc4e 100644 --- a/typespec-tests/src/test/java/com/azure/specialheaders/xmsclientrequestid/generated/XmsClientRequestIdClientTestBase.java +++ b/typespec-tests/src/test/java/com/azure/specialheaders/xmsclientrequestid/generated/XmsClientRequestIdClientTestBase.java @@ -13,6 +13,7 @@ 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; @@ -21,9 +22,10 @@ class XmsClientRequestIdClientTestBase extends TestProxyTestBase { @Override protected void beforeTest() { - XmsClientRequestIdClientBuilder xmsClientRequestIdClientbuilder - = new XmsClientRequestIdClientBuilder().httpClient(HttpClient.createDefault()) - .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + 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) { diff --git a/typespec-tests/src/test/java/com/cadl/server/generated/HttpbinClientTestBase.java b/typespec-tests/src/test/java/com/cadl/server/generated/HttpbinClientTestBase.java index 0341ab5890..2a9a04579b 100644 --- a/typespec-tests/src/test/java/com/cadl/server/generated/HttpbinClientTestBase.java +++ b/typespec-tests/src/test/java/com/cadl/server/generated/HttpbinClientTestBase.java @@ -27,8 +27,9 @@ class HttpbinClientTestBase extends TestProxyTestBase { @Override protected void beforeTest() { HttpbinClientBuilder httpbinClientbuilder - = new HttpbinClientBuilder().domain(Configuration.getGlobalConfiguration().get("DOMAIN", "domain")) - .tld(Configuration.getGlobalConfiguration().get("TLD", "tld")) + = 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) { diff --git a/typespec-tests/src/test/java/com/client/naming/NamingTests.java b/typespec-tests/src/test/java/com/client/naming/NamingTests.java index 6d6c83a638..9a6993599d 100644 --- a/typespec-tests/src/test/java/com/client/naming/NamingTests.java +++ b/typespec-tests/src/test/java/com/client/naming/NamingTests.java @@ -10,6 +10,7 @@ import com.client.naming.models.ExtensibleEnum; import com.client.naming.models.JavaModel; import com.client.naming.models.LanguageClientNameModel; +import org.eclipse.jetty.io.ssl.ALPNProcessor; import org.junit.jupiter.api.Test; public class NamingTests { diff --git a/typespec-tests/src/test/java/com/client/naming/generated/NamingClientTestBase.java b/typespec-tests/src/test/java/com/client/naming/generated/NamingClientTestBase.java index 966f8e88d1..27c50ae9de 100644 --- a/typespec-tests/src/test/java/com/client/naming/generated/NamingClientTestBase.java +++ b/typespec-tests/src/test/java/com/client/naming/generated/NamingClientTestBase.java @@ -13,6 +13,7 @@ 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; @@ -27,7 +28,9 @@ class NamingClientTestBase extends TestProxyTestBase { @Override protected void beforeTest() { - NamingClientBuilder namingClientbuilder = new NamingClientBuilder().httpClient(HttpClient.createDefault()) + 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()); @@ -36,7 +39,9 @@ protected void beforeTest() { } namingClient = namingClientbuilder.buildClient(); - NamingClientBuilder clientModelClientbuilder = new NamingClientBuilder().httpClient(HttpClient.createDefault()) + 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()); @@ -45,7 +50,9 @@ protected void beforeTest() { } clientModelClient = clientModelClientbuilder.buildClientModelClient(); - NamingClientBuilder unionEnumClientbuilder = new NamingClientBuilder().httpClient(HttpClient.createDefault()) + 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()); diff --git a/typespec-tests/src/test/java/com/encode/bytes/generated/BytesClientTestBase.java b/typespec-tests/src/test/java/com/encode/bytes/generated/BytesClientTestBase.java index a54927d29b..4cab5d91d9 100644 --- a/typespec-tests/src/test/java/com/encode/bytes/generated/BytesClientTestBase.java +++ b/typespec-tests/src/test/java/com/encode/bytes/generated/BytesClientTestBase.java @@ -13,6 +13,7 @@ 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; @@ -33,7 +34,9 @@ class BytesClientTestBase extends TestProxyTestBase { @Override protected void beforeTest() { - BytesClientBuilder queryClientbuilder = new BytesClientBuilder().httpClient(HttpClient.createDefault()) + 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()); @@ -42,7 +45,9 @@ protected void beforeTest() { } queryClient = queryClientbuilder.buildQueryClient(); - BytesClientBuilder propertyClientbuilder = new BytesClientBuilder().httpClient(HttpClient.createDefault()) + 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()); @@ -51,7 +56,9 @@ protected void beforeTest() { } propertyClient = propertyClientbuilder.buildPropertyClient(); - BytesClientBuilder headerClientbuilder = new BytesClientBuilder().httpClient(HttpClient.createDefault()) + 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()); @@ -60,7 +67,9 @@ protected void beforeTest() { } headerClient = headerClientbuilder.buildHeaderClient(); - BytesClientBuilder requestBodyClientbuilder = new BytesClientBuilder().httpClient(HttpClient.createDefault()) + 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()); @@ -69,7 +78,9 @@ protected void beforeTest() { } requestBodyClient = requestBodyClientbuilder.buildRequestBodyClient(); - BytesClientBuilder responseBodyClientbuilder = new BytesClientBuilder().httpClient(HttpClient.createDefault()) + 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()); diff --git a/typespec-tests/src/test/java/com/encode/datetime/generated/DatetimeClientTestBase.java b/typespec-tests/src/test/java/com/encode/datetime/generated/DatetimeClientTestBase.java index 5031e7badb..05d83226c6 100644 --- a/typespec-tests/src/test/java/com/encode/datetime/generated/DatetimeClientTestBase.java +++ b/typespec-tests/src/test/java/com/encode/datetime/generated/DatetimeClientTestBase.java @@ -13,6 +13,7 @@ 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; @@ -30,7 +31,9 @@ class DatetimeClientTestBase extends TestProxyTestBase { @Override protected void beforeTest() { - DatetimeClientBuilder queryClientbuilder = new DatetimeClientBuilder().httpClient(HttpClient.createDefault()) + 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()); @@ -39,7 +42,9 @@ protected void beforeTest() { } queryClient = queryClientbuilder.buildQueryClient(); - DatetimeClientBuilder propertyClientbuilder = new DatetimeClientBuilder().httpClient(HttpClient.createDefault()) + 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()); @@ -48,7 +53,9 @@ protected void beforeTest() { } propertyClient = propertyClientbuilder.buildPropertyClient(); - DatetimeClientBuilder headerClientbuilder = new DatetimeClientBuilder().httpClient(HttpClient.createDefault()) + 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()); @@ -57,9 +64,10 @@ protected void beforeTest() { } headerClient = headerClientbuilder.buildHeaderClient(); - DatetimeClientBuilder responseHeaderClientbuilder - = new DatetimeClientBuilder().httpClient(HttpClient.createDefault()) - .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + 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) { diff --git a/typespec-tests/src/test/java/com/encode/duration/generated/DurationClientTestBase.java b/typespec-tests/src/test/java/com/encode/duration/generated/DurationClientTestBase.java index d100873197..ff419aed9b 100644 --- a/typespec-tests/src/test/java/com/encode/duration/generated/DurationClientTestBase.java +++ b/typespec-tests/src/test/java/com/encode/duration/generated/DurationClientTestBase.java @@ -13,6 +13,7 @@ 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; @@ -27,7 +28,9 @@ class DurationClientTestBase extends TestProxyTestBase { @Override protected void beforeTest() { - DurationClientBuilder queryClientbuilder = new DurationClientBuilder().httpClient(HttpClient.createDefault()) + 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()); @@ -36,7 +39,9 @@ protected void beforeTest() { } queryClient = queryClientbuilder.buildQueryClient(); - DurationClientBuilder propertyClientbuilder = new DurationClientBuilder().httpClient(HttpClient.createDefault()) + 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()); @@ -45,7 +50,9 @@ protected void beforeTest() { } propertyClient = propertyClientbuilder.buildPropertyClient(); - DurationClientBuilder headerClientbuilder = new DurationClientBuilder().httpClient(HttpClient.createDefault()) + 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()); diff --git a/typespec-tests/src/test/java/com/encode/numeric/generated/NumericClientTestBase.java b/typespec-tests/src/test/java/com/encode/numeric/generated/NumericClientTestBase.java index 50713b9843..8b865bf807 100644 --- a/typespec-tests/src/test/java/com/encode/numeric/generated/NumericClientTestBase.java +++ b/typespec-tests/src/test/java/com/encode/numeric/generated/NumericClientTestBase.java @@ -13,6 +13,7 @@ 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.numeric.NumericClient; import com.encode.numeric.NumericClientBuilder; @@ -21,7 +22,9 @@ class NumericClientTestBase extends TestProxyTestBase { @Override protected void beforeTest() { - NumericClientBuilder numericClientbuilder = new NumericClientBuilder().httpClient(HttpClient.createDefault()) + NumericClientBuilder numericClientbuilder = new NumericClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); if (getTestMode() == TestMode.PLAYBACK) { numericClientbuilder.httpClient(interceptorManager.getPlaybackClient()); diff --git a/typespec-tests/src/test/java/com/parameters/basic/generated/BasicClientTestBase.java b/typespec-tests/src/test/java/com/parameters/basic/generated/BasicClientTestBase.java index fbe920f8e2..7196d63b31 100644 --- a/typespec-tests/src/test/java/com/parameters/basic/generated/BasicClientTestBase.java +++ b/typespec-tests/src/test/java/com/parameters/basic/generated/BasicClientTestBase.java @@ -13,6 +13,7 @@ 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; @@ -24,7 +25,9 @@ class BasicClientTestBase extends TestProxyTestBase { @Override protected void beforeTest() { - BasicClientBuilder explicitBodyClientbuilder = new BasicClientBuilder().httpClient(HttpClient.createDefault()) + 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()); @@ -33,7 +36,9 @@ protected void beforeTest() { } explicitBodyClient = explicitBodyClientbuilder.buildExplicitBodyClient(); - BasicClientBuilder implicitBodyClientbuilder = new BasicClientBuilder().httpClient(HttpClient.createDefault()) + 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()); diff --git a/typespec-tests/src/test/java/com/parameters/bodyoptionality/generated/BodyOptionalityClientTestBase.java b/typespec-tests/src/test/java/com/parameters/bodyoptionality/generated/BodyOptionalityClientTestBase.java index 08f56ea305..1c0c67e14b 100644 --- a/typespec-tests/src/test/java/com/parameters/bodyoptionality/generated/BodyOptionalityClientTestBase.java +++ b/typespec-tests/src/test/java/com/parameters/bodyoptionality/generated/BodyOptionalityClientTestBase.java @@ -13,6 +13,7 @@ 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; @@ -24,9 +25,10 @@ class BodyOptionalityClientTestBase extends TestProxyTestBase { @Override protected void beforeTest() { - BodyOptionalityClientBuilder bodyOptionalityClientbuilder - = new BodyOptionalityClientBuilder().httpClient(HttpClient.createDefault()) - .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + 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) { @@ -34,9 +36,10 @@ protected void beforeTest() { } bodyOptionalityClient = bodyOptionalityClientbuilder.buildClient(); - BodyOptionalityClientBuilder optionalExplicitClientbuilder - = new BodyOptionalityClientBuilder().httpClient(HttpClient.createDefault()) - .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + 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) { diff --git a/typespec-tests/src/test/java/com/parameters/collectionformat/generated/CollectionFormatClientTestBase.java b/typespec-tests/src/test/java/com/parameters/collectionformat/generated/CollectionFormatClientTestBase.java index ddc63c98a3..52bded4726 100644 --- a/typespec-tests/src/test/java/com/parameters/collectionformat/generated/CollectionFormatClientTestBase.java +++ b/typespec-tests/src/test/java/com/parameters/collectionformat/generated/CollectionFormatClientTestBase.java @@ -13,6 +13,7 @@ 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; @@ -24,9 +25,10 @@ class CollectionFormatClientTestBase extends TestProxyTestBase { @Override protected void beforeTest() { - CollectionFormatClientBuilder queryClientbuilder - = new CollectionFormatClientBuilder().httpClient(HttpClient.createDefault()) - .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + 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) { @@ -34,9 +36,10 @@ protected void beforeTest() { } queryClient = queryClientbuilder.buildQueryClient(); - CollectionFormatClientBuilder headerClientbuilder - = new CollectionFormatClientBuilder().httpClient(HttpClient.createDefault()) - .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + 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) { diff --git a/typespec-tests/src/test/java/com/parameters/spread/SpreadTests.java b/typespec-tests/src/test/java/com/parameters/spread/SpreadTests.java index 23142e8ecb..933c5459ae 100644 --- a/typespec-tests/src/test/java/com/parameters/spread/SpreadTests.java +++ b/typespec-tests/src/test/java/com/parameters/spread/SpreadTests.java @@ -22,9 +22,9 @@ public void testSpread() { aliasClient.spreadWithMultipleParameters("1", "bar", "foo", List.of(1, 2), 1, List.of("foo", "bar")); - aliasClient.spreadParameterWithInnerAlias("1", "foo", 1, "bar"); + aliasClient.spreadParameterWithInnerAlias("1", "bar", "foo", 1); - aliasClient.spreadParameterWithInnerModel("1", "foo", "bar"); + aliasClient.spreadParameterWithInnerModel("1", "bar", "foo"); } @Test diff --git a/typespec-tests/src/test/java/com/parameters/spread/generated/SpreadClientTestBase.java b/typespec-tests/src/test/java/com/parameters/spread/generated/SpreadClientTestBase.java index 6c0ae001b6..eb5434fc39 100644 --- a/typespec-tests/src/test/java/com/parameters/spread/generated/SpreadClientTestBase.java +++ b/typespec-tests/src/test/java/com/parameters/spread/generated/SpreadClientTestBase.java @@ -13,6 +13,7 @@ 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; @@ -24,7 +25,9 @@ class SpreadClientTestBase extends TestProxyTestBase { @Override protected void beforeTest() { - SpreadClientBuilder modelClientbuilder = new SpreadClientBuilder().httpClient(HttpClient.createDefault()) + 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()); @@ -33,7 +36,9 @@ protected void beforeTest() { } modelClient = modelClientbuilder.buildModelClient(); - SpreadClientBuilder aliasClientbuilder = new SpreadClientBuilder().httpClient(HttpClient.createDefault()) + 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()); diff --git a/typespec-tests/src/test/java/com/payload/contentnegotiation/generated/ContentNegotiationClientTestBase.java b/typespec-tests/src/test/java/com/payload/contentnegotiation/generated/ContentNegotiationClientTestBase.java index 1bc401cbb8..fe4c66c652 100644 --- a/typespec-tests/src/test/java/com/payload/contentnegotiation/generated/ContentNegotiationClientTestBase.java +++ b/typespec-tests/src/test/java/com/payload/contentnegotiation/generated/ContentNegotiationClientTestBase.java @@ -13,6 +13,7 @@ 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; @@ -24,9 +25,10 @@ class ContentNegotiationClientTestBase extends TestProxyTestBase { @Override protected void beforeTest() { - ContentNegotiationClientBuilder sameBodyClientbuilder - = new ContentNegotiationClientBuilder().httpClient(HttpClient.createDefault()) - .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + 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) { @@ -34,9 +36,10 @@ protected void beforeTest() { } sameBodyClient = sameBodyClientbuilder.buildSameBodyClient(); - ContentNegotiationClientBuilder differentBodyClientbuilder - = new ContentNegotiationClientBuilder().httpClient(HttpClient.createDefault()) - .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + 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) { diff --git a/typespec-tests/src/test/java/com/payload/jsonmergepatch/generated/JsonMergePatchClientTestBase.java b/typespec-tests/src/test/java/com/payload/jsonmergepatch/generated/JsonMergePatchClientTestBase.java index 171cca5870..bb9a6ab6df 100644 --- a/typespec-tests/src/test/java/com/payload/jsonmergepatch/generated/JsonMergePatchClientTestBase.java +++ b/typespec-tests/src/test/java/com/payload/jsonmergepatch/generated/JsonMergePatchClientTestBase.java @@ -13,6 +13,7 @@ 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; @@ -21,9 +22,10 @@ class JsonMergePatchClientTestBase extends TestProxyTestBase { @Override protected void beforeTest() { - JsonMergePatchClientBuilder jsonMergePatchClientbuilder - = new JsonMergePatchClientBuilder().httpClient(HttpClient.createDefault()) - .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + 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) { diff --git a/typespec-tests/src/test/java/com/payload/mediatype/generated/MediaTypeClientTestBase.java b/typespec-tests/src/test/java/com/payload/mediatype/generated/MediaTypeClientTestBase.java index 708444f112..8a5752d00a 100644 --- a/typespec-tests/src/test/java/com/payload/mediatype/generated/MediaTypeClientTestBase.java +++ b/typespec-tests/src/test/java/com/payload/mediatype/generated/MediaTypeClientTestBase.java @@ -13,6 +13,7 @@ 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; @@ -21,9 +22,10 @@ class MediaTypeClientTestBase extends TestProxyTestBase { @Override protected void beforeTest() { - MediaTypeClientBuilder mediaTypeClientbuilder - = new MediaTypeClientBuilder().httpClient(HttpClient.createDefault()) - .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + 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) { diff --git a/typespec-tests/src/test/java/com/payload/multipart/generated/MultiPartClientTestBase.java b/typespec-tests/src/test/java/com/payload/multipart/generated/MultiPartClientTestBase.java index 94e07654e9..5b1b0baf87 100644 --- a/typespec-tests/src/test/java/com/payload/multipart/generated/MultiPartClientTestBase.java +++ b/typespec-tests/src/test/java/com/payload/multipart/generated/MultiPartClientTestBase.java @@ -13,6 +13,7 @@ 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; @@ -21,9 +22,10 @@ class MultiPartClientTestBase extends TestProxyTestBase { @Override protected void beforeTest() { - MultiPartClientBuilder multiPartClientbuilder - = new MultiPartClientBuilder().httpClient(HttpClient.createDefault()) - .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + 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) { diff --git a/typespec-tests/src/test/java/com/payload/pageable/generated/PageableClientTestBase.java b/typespec-tests/src/test/java/com/payload/pageable/generated/PageableClientTestBase.java index cb767d29f9..457250402c 100644 --- a/typespec-tests/src/test/java/com/payload/pageable/generated/PageableClientTestBase.java +++ b/typespec-tests/src/test/java/com/payload/pageable/generated/PageableClientTestBase.java @@ -13,6 +13,7 @@ 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; @@ -21,7 +22,9 @@ class PageableClientTestBase extends TestProxyTestBase { @Override protected void beforeTest() { - PageableClientBuilder pageableClientbuilder = new PageableClientBuilder().httpClient(HttpClient.createDefault()) + 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()); diff --git a/typespec-tests/src/test/java/com/serialization/encodedname/json/generated/JsonClientTestBase.java b/typespec-tests/src/test/java/com/serialization/encodedname/json/generated/JsonClientTestBase.java index 68d33b5bf7..48e63770d1 100644 --- a/typespec-tests/src/test/java/com/serialization/encodedname/json/generated/JsonClientTestBase.java +++ b/typespec-tests/src/test/java/com/serialization/encodedname/json/generated/JsonClientTestBase.java @@ -13,6 +13,7 @@ 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; @@ -21,7 +22,9 @@ class JsonClientTestBase extends TestProxyTestBase { @Override protected void beforeTest() { - JsonClientBuilder jsonClientbuilder = new JsonClientBuilder().httpClient(HttpClient.createDefault()) + 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()); diff --git a/typespec-tests/src/test/java/com/specialheaders/conditionalrequest/generated/ConditionalRequestClientTestBase.java b/typespec-tests/src/test/java/com/specialheaders/conditionalrequest/generated/ConditionalRequestClientTestBase.java index d1aabccaed..6f58744175 100644 --- a/typespec-tests/src/test/java/com/specialheaders/conditionalrequest/generated/ConditionalRequestClientTestBase.java +++ b/typespec-tests/src/test/java/com/specialheaders/conditionalrequest/generated/ConditionalRequestClientTestBase.java @@ -13,6 +13,7 @@ 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; @@ -21,9 +22,10 @@ class ConditionalRequestClientTestBase extends TestProxyTestBase { @Override protected void beforeTest() { - ConditionalRequestClientBuilder conditionalRequestClientbuilder - = new ConditionalRequestClientBuilder().httpClient(HttpClient.createDefault()) - .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + 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) { diff --git a/typespec-tests/src/test/java/com/specialheaders/repeatability/generated/RepeatabilityClientTestBase.java b/typespec-tests/src/test/java/com/specialheaders/repeatability/generated/RepeatabilityClientTestBase.java index d481688f3f..9dd8381c25 100644 --- a/typespec-tests/src/test/java/com/specialheaders/repeatability/generated/RepeatabilityClientTestBase.java +++ b/typespec-tests/src/test/java/com/specialheaders/repeatability/generated/RepeatabilityClientTestBase.java @@ -13,6 +13,7 @@ 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; @@ -21,9 +22,10 @@ class RepeatabilityClientTestBase extends TestProxyTestBase { @Override protected void beforeTest() { - RepeatabilityClientBuilder repeatabilityClientbuilder - = new RepeatabilityClientBuilder().httpClient(HttpClient.createDefault()) - .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + 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) { diff --git a/typespec-tests/src/test/java/com/specialwords/generated/SpecialWordsClientTestBase.java b/typespec-tests/src/test/java/com/specialwords/generated/SpecialWordsClientTestBase.java index 1e96e513ff..a9f0e5e147 100644 --- a/typespec-tests/src/test/java/com/specialwords/generated/SpecialWordsClientTestBase.java +++ b/typespec-tests/src/test/java/com/specialwords/generated/SpecialWordsClientTestBase.java @@ -13,6 +13,7 @@ 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; @@ -30,9 +31,10 @@ class SpecialWordsClientTestBase extends TestProxyTestBase { @Override protected void beforeTest() { - SpecialWordsClientBuilder modelsClientbuilder - = new SpecialWordsClientBuilder().httpClient(HttpClient.createDefault()) - .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + 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) { @@ -40,9 +42,10 @@ protected void beforeTest() { } modelsClient = modelsClientbuilder.buildModelsClient(); - SpecialWordsClientBuilder modelPropertiesClientbuilder - = new SpecialWordsClientBuilder().httpClient(HttpClient.createDefault()) - .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + 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) { @@ -50,9 +53,10 @@ protected void beforeTest() { } modelPropertiesClient = modelPropertiesClientbuilder.buildModelPropertiesClient(); - SpecialWordsClientBuilder operationsClientbuilder - = new SpecialWordsClientBuilder().httpClient(HttpClient.createDefault()) - .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + 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) { @@ -60,9 +64,10 @@ protected void beforeTest() { } operationsClient = operationsClientbuilder.buildOperationsClient(); - SpecialWordsClientBuilder parametersClientbuilder - = new SpecialWordsClientBuilder().httpClient(HttpClient.createDefault()) - .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + 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) { diff --git a/typespec-tests/src/test/java/com/type/array/generated/ArrayClientTestBase.java b/typespec-tests/src/test/java/com/type/array/generated/ArrayClientTestBase.java index 32c12c87c4..dff94f0fac 100644 --- a/typespec-tests/src/test/java/com/type/array/generated/ArrayClientTestBase.java +++ b/typespec-tests/src/test/java/com/type/array/generated/ArrayClientTestBase.java @@ -13,6 +13,7 @@ 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; @@ -60,7 +61,9 @@ class ArrayClientTestBase extends TestProxyTestBase { @Override protected void beforeTest() { - ArrayClientBuilder int32ValueClientbuilder = new ArrayClientBuilder().httpClient(HttpClient.createDefault()) + 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()); @@ -69,7 +72,9 @@ protected void beforeTest() { } int32ValueClient = int32ValueClientbuilder.buildInt32ValueClient(); - ArrayClientBuilder int64ValueClientbuilder = new ArrayClientBuilder().httpClient(HttpClient.createDefault()) + 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()); @@ -78,7 +83,9 @@ protected void beforeTest() { } int64ValueClient = int64ValueClientbuilder.buildInt64ValueClient(); - ArrayClientBuilder booleanValueClientbuilder = new ArrayClientBuilder().httpClient(HttpClient.createDefault()) + 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()); @@ -87,7 +94,9 @@ protected void beforeTest() { } booleanValueClient = booleanValueClientbuilder.buildBooleanValueClient(); - ArrayClientBuilder stringValueClientbuilder = new ArrayClientBuilder().httpClient(HttpClient.createDefault()) + 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()); @@ -96,7 +105,9 @@ protected void beforeTest() { } stringValueClient = stringValueClientbuilder.buildStringValueClient(); - ArrayClientBuilder float32ValueClientbuilder = new ArrayClientBuilder().httpClient(HttpClient.createDefault()) + 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()); @@ -105,7 +116,9 @@ protected void beforeTest() { } float32ValueClient = float32ValueClientbuilder.buildFloat32ValueClient(); - ArrayClientBuilder datetimeValueClientbuilder = new ArrayClientBuilder().httpClient(HttpClient.createDefault()) + 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()); @@ -114,7 +127,9 @@ protected void beforeTest() { } datetimeValueClient = datetimeValueClientbuilder.buildDatetimeValueClient(); - ArrayClientBuilder durationValueClientbuilder = new ArrayClientBuilder().httpClient(HttpClient.createDefault()) + 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()); @@ -123,7 +138,9 @@ protected void beforeTest() { } durationValueClient = durationValueClientbuilder.buildDurationValueClient(); - ArrayClientBuilder unknownValueClientbuilder = new ArrayClientBuilder().httpClient(HttpClient.createDefault()) + 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()); @@ -132,7 +149,9 @@ protected void beforeTest() { } unknownValueClient = unknownValueClientbuilder.buildUnknownValueClient(); - ArrayClientBuilder modelValueClientbuilder = new ArrayClientBuilder().httpClient(HttpClient.createDefault()) + 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()); @@ -141,9 +160,10 @@ protected void beforeTest() { } modelValueClient = modelValueClientbuilder.buildModelValueClient(); - ArrayClientBuilder nullableFloatValueClientbuilder - = new ArrayClientBuilder().httpClient(HttpClient.createDefault()) - .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + 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) { @@ -151,9 +171,10 @@ protected void beforeTest() { } nullableFloatValueClient = nullableFloatValueClientbuilder.buildNullableFloatValueClient(); - ArrayClientBuilder nullableInt32ValueClientbuilder - = new ArrayClientBuilder().httpClient(HttpClient.createDefault()) - .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + 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) { @@ -161,9 +182,10 @@ protected void beforeTest() { } nullableInt32ValueClient = nullableInt32ValueClientbuilder.buildNullableInt32ValueClient(); - ArrayClientBuilder nullableBooleanValueClientbuilder - = new ArrayClientBuilder().httpClient(HttpClient.createDefault()) - .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + 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) { @@ -171,9 +193,10 @@ protected void beforeTest() { } nullableBooleanValueClient = nullableBooleanValueClientbuilder.buildNullableBooleanValueClient(); - ArrayClientBuilder nullableStringValueClientbuilder - = new ArrayClientBuilder().httpClient(HttpClient.createDefault()) - .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + 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) { @@ -181,9 +204,10 @@ protected void beforeTest() { } nullableStringValueClient = nullableStringValueClientbuilder.buildNullableStringValueClient(); - ArrayClientBuilder nullableModelValueClientbuilder - = new ArrayClientBuilder().httpClient(HttpClient.createDefault()) - .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + 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) { diff --git a/typespec-tests/src/test/java/com/type/dictionary/generated/DictionaryClientTestBase.java b/typespec-tests/src/test/java/com/type/dictionary/generated/DictionaryClientTestBase.java index 03dd67334e..eb6b0bd8ad 100644 --- a/typespec-tests/src/test/java/com/type/dictionary/generated/DictionaryClientTestBase.java +++ b/typespec-tests/src/test/java/com/type/dictionary/generated/DictionaryClientTestBase.java @@ -13,6 +13,7 @@ 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; @@ -51,9 +52,10 @@ class DictionaryClientTestBase extends TestProxyTestBase { @Override protected void beforeTest() { - DictionaryClientBuilder int32ValueClientbuilder - = new DictionaryClientBuilder().httpClient(HttpClient.createDefault()) - .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + 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) { @@ -61,9 +63,10 @@ protected void beforeTest() { } int32ValueClient = int32ValueClientbuilder.buildInt32ValueClient(); - DictionaryClientBuilder int64ValueClientbuilder - = new DictionaryClientBuilder().httpClient(HttpClient.createDefault()) - .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + 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) { @@ -71,9 +74,10 @@ protected void beforeTest() { } int64ValueClient = int64ValueClientbuilder.buildInt64ValueClient(); - DictionaryClientBuilder booleanValueClientbuilder - = new DictionaryClientBuilder().httpClient(HttpClient.createDefault()) - .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + 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) { @@ -81,9 +85,10 @@ protected void beforeTest() { } booleanValueClient = booleanValueClientbuilder.buildBooleanValueClient(); - DictionaryClientBuilder stringValueClientbuilder - = new DictionaryClientBuilder().httpClient(HttpClient.createDefault()) - .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + 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) { @@ -91,9 +96,10 @@ protected void beforeTest() { } stringValueClient = stringValueClientbuilder.buildStringValueClient(); - DictionaryClientBuilder float32ValueClientbuilder - = new DictionaryClientBuilder().httpClient(HttpClient.createDefault()) - .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + 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) { @@ -101,9 +107,10 @@ protected void beforeTest() { } float32ValueClient = float32ValueClientbuilder.buildFloat32ValueClient(); - DictionaryClientBuilder datetimeValueClientbuilder - = new DictionaryClientBuilder().httpClient(HttpClient.createDefault()) - .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + 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) { @@ -111,9 +118,10 @@ protected void beforeTest() { } datetimeValueClient = datetimeValueClientbuilder.buildDatetimeValueClient(); - DictionaryClientBuilder durationValueClientbuilder - = new DictionaryClientBuilder().httpClient(HttpClient.createDefault()) - .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + 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) { @@ -121,9 +129,10 @@ protected void beforeTest() { } durationValueClient = durationValueClientbuilder.buildDurationValueClient(); - DictionaryClientBuilder unknownValueClientbuilder - = new DictionaryClientBuilder().httpClient(HttpClient.createDefault()) - .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + 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) { @@ -131,9 +140,10 @@ protected void beforeTest() { } unknownValueClient = unknownValueClientbuilder.buildUnknownValueClient(); - DictionaryClientBuilder modelValueClientbuilder - = new DictionaryClientBuilder().httpClient(HttpClient.createDefault()) - .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + 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) { @@ -141,9 +151,10 @@ protected void beforeTest() { } modelValueClient = modelValueClientbuilder.buildModelValueClient(); - DictionaryClientBuilder recursiveModelValueClientbuilder - = new DictionaryClientBuilder().httpClient(HttpClient.createDefault()) - .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + 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) { @@ -151,9 +162,10 @@ protected void beforeTest() { } recursiveModelValueClient = recursiveModelValueClientbuilder.buildRecursiveModelValueClient(); - DictionaryClientBuilder nullableFloatValueClientbuilder - = new DictionaryClientBuilder().httpClient(HttpClient.createDefault()) - .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + 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) { diff --git a/typespec-tests/src/test/java/com/type/enums/extensible/generated/ExtensibleClientTestBase.java b/typespec-tests/src/test/java/com/type/enums/extensible/generated/ExtensibleClientTestBase.java index 080401739c..c69dc45559 100644 --- a/typespec-tests/src/test/java/com/type/enums/extensible/generated/ExtensibleClientTestBase.java +++ b/typespec-tests/src/test/java/com/type/enums/extensible/generated/ExtensibleClientTestBase.java @@ -13,6 +13,7 @@ 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; @@ -21,9 +22,10 @@ class ExtensibleClientTestBase extends TestProxyTestBase { @Override protected void beforeTest() { - ExtensibleClientBuilder extensibleClientbuilder - = new ExtensibleClientBuilder().httpClient(HttpClient.createDefault()) - .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + 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) { diff --git a/typespec-tests/src/test/java/com/type/enums/fixed/generated/FixedClientTestBase.java b/typespec-tests/src/test/java/com/type/enums/fixed/generated/FixedClientTestBase.java index 27371c3c2a..42c3443dba 100644 --- a/typespec-tests/src/test/java/com/type/enums/fixed/generated/FixedClientTestBase.java +++ b/typespec-tests/src/test/java/com/type/enums/fixed/generated/FixedClientTestBase.java @@ -13,6 +13,7 @@ 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; @@ -21,7 +22,9 @@ class FixedClientTestBase extends TestProxyTestBase { @Override protected void beforeTest() { - FixedClientBuilder fixedClientbuilder = new FixedClientBuilder().httpClient(HttpClient.createDefault()) + 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()); diff --git a/typespec-tests/src/test/java/com/type/model/empty/generated/EmptyClientTestBase.java b/typespec-tests/src/test/java/com/type/model/empty/generated/EmptyClientTestBase.java index 22d948add5..b79668911d 100644 --- a/typespec-tests/src/test/java/com/type/model/empty/generated/EmptyClientTestBase.java +++ b/typespec-tests/src/test/java/com/type/model/empty/generated/EmptyClientTestBase.java @@ -13,6 +13,7 @@ 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; @@ -21,7 +22,9 @@ class EmptyClientTestBase extends TestProxyTestBase { @Override protected void beforeTest() { - EmptyClientBuilder emptyClientbuilder = new EmptyClientBuilder().httpClient(HttpClient.createDefault()) + 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()); diff --git a/typespec-tests/src/test/java/com/type/model/inheritance/enumdiscriminator/generated/EnumDiscriminatorClientTestBase.java b/typespec-tests/src/test/java/com/type/model/inheritance/enumdiscriminator/generated/EnumDiscriminatorClientTestBase.java index c96683a156..3dfa60ccab 100644 --- a/typespec-tests/src/test/java/com/type/model/inheritance/enumdiscriminator/generated/EnumDiscriminatorClientTestBase.java +++ b/typespec-tests/src/test/java/com/type/model/inheritance/enumdiscriminator/generated/EnumDiscriminatorClientTestBase.java @@ -13,6 +13,7 @@ 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; @@ -21,9 +22,10 @@ class EnumDiscriminatorClientTestBase extends TestProxyTestBase { @Override protected void beforeTest() { - EnumDiscriminatorClientBuilder enumDiscriminatorClientbuilder - = new EnumDiscriminatorClientBuilder().httpClient(HttpClient.createDefault()) - .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + 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) { diff --git a/typespec-tests/src/test/java/com/type/model/inheritance/enumnesteddiscriminator/generated/EnumNestedDiscriminatorClientTestBase.java b/typespec-tests/src/test/java/com/type/model/inheritance/enumnesteddiscriminator/generated/EnumNestedDiscriminatorClientTestBase.java index 5abc47f79e..ccc4713985 100644 --- a/typespec-tests/src/test/java/com/type/model/inheritance/enumnesteddiscriminator/generated/EnumNestedDiscriminatorClientTestBase.java +++ b/typespec-tests/src/test/java/com/type/model/inheritance/enumnesteddiscriminator/generated/EnumNestedDiscriminatorClientTestBase.java @@ -13,6 +13,7 @@ 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; @@ -22,7 +23,9 @@ class EnumNestedDiscriminatorClientTestBase extends TestProxyTestBase { @Override protected void beforeTest() { EnumNestedDiscriminatorClientBuilder enumNestedDiscriminatorClientbuilder - = new EnumNestedDiscriminatorClientBuilder().httpClient(HttpClient.createDefault()) + = 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()); diff --git a/typespec-tests/src/test/java/com/type/model/inheritance/nesteddiscriminator/generated/NestedDiscriminatorClientTestBase.java b/typespec-tests/src/test/java/com/type/model/inheritance/nesteddiscriminator/generated/NestedDiscriminatorClientTestBase.java index abfe43b5ef..f22e376b2c 100644 --- a/typespec-tests/src/test/java/com/type/model/inheritance/nesteddiscriminator/generated/NestedDiscriminatorClientTestBase.java +++ b/typespec-tests/src/test/java/com/type/model/inheritance/nesteddiscriminator/generated/NestedDiscriminatorClientTestBase.java @@ -13,6 +13,7 @@ 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; @@ -21,9 +22,10 @@ class NestedDiscriminatorClientTestBase extends TestProxyTestBase { @Override protected void beforeTest() { - NestedDiscriminatorClientBuilder nestedDiscriminatorClientbuilder - = new NestedDiscriminatorClientBuilder().httpClient(HttpClient.createDefault()) - .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + 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) { diff --git a/typespec-tests/src/test/java/com/type/model/inheritance/notdiscriminated/generated/NotDiscriminatedClientTestBase.java b/typespec-tests/src/test/java/com/type/model/inheritance/notdiscriminated/generated/NotDiscriminatedClientTestBase.java index fbd619b176..980407e0d3 100644 --- a/typespec-tests/src/test/java/com/type/model/inheritance/notdiscriminated/generated/NotDiscriminatedClientTestBase.java +++ b/typespec-tests/src/test/java/com/type/model/inheritance/notdiscriminated/generated/NotDiscriminatedClientTestBase.java @@ -13,6 +13,7 @@ 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; @@ -21,9 +22,10 @@ class NotDiscriminatedClientTestBase extends TestProxyTestBase { @Override protected void beforeTest() { - NotDiscriminatedClientBuilder notDiscriminatedClientbuilder - = new NotDiscriminatedClientBuilder().httpClient(HttpClient.createDefault()) - .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + 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) { diff --git a/typespec-tests/src/test/java/com/type/model/inheritance/recursive/generated/RecursiveClientTestBase.java b/typespec-tests/src/test/java/com/type/model/inheritance/recursive/generated/RecursiveClientTestBase.java index 80dd9b4404..15cc609f64 100644 --- a/typespec-tests/src/test/java/com/type/model/inheritance/recursive/generated/RecursiveClientTestBase.java +++ b/typespec-tests/src/test/java/com/type/model/inheritance/recursive/generated/RecursiveClientTestBase.java @@ -13,6 +13,7 @@ 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; @@ -21,9 +22,10 @@ class RecursiveClientTestBase extends TestProxyTestBase { @Override protected void beforeTest() { - RecursiveClientBuilder recursiveClientbuilder - = new RecursiveClientBuilder().httpClient(HttpClient.createDefault()) - .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + 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) { diff --git a/typespec-tests/src/test/java/com/type/model/inheritance/singlediscriminator/generated/SingleDiscriminatorClientTestBase.java b/typespec-tests/src/test/java/com/type/model/inheritance/singlediscriminator/generated/SingleDiscriminatorClientTestBase.java index cc9703bcec..a871b2e7ac 100644 --- a/typespec-tests/src/test/java/com/type/model/inheritance/singlediscriminator/generated/SingleDiscriminatorClientTestBase.java +++ b/typespec-tests/src/test/java/com/type/model/inheritance/singlediscriminator/generated/SingleDiscriminatorClientTestBase.java @@ -13,6 +13,7 @@ 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; @@ -21,9 +22,10 @@ class SingleDiscriminatorClientTestBase extends TestProxyTestBase { @Override protected void beforeTest() { - SingleDiscriminatorClientBuilder singleDiscriminatorClientbuilder - = new SingleDiscriminatorClientBuilder().httpClient(HttpClient.createDefault()) - .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + 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) { diff --git a/typespec-tests/src/test/java/com/type/model/usage/generated/UsageClientTestBase.java b/typespec-tests/src/test/java/com/type/model/usage/generated/UsageClientTestBase.java index 4d739c036a..e135b9c68c 100644 --- a/typespec-tests/src/test/java/com/type/model/usage/generated/UsageClientTestBase.java +++ b/typespec-tests/src/test/java/com/type/model/usage/generated/UsageClientTestBase.java @@ -13,6 +13,7 @@ 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; @@ -21,7 +22,9 @@ class UsageClientTestBase extends TestProxyTestBase { @Override protected void beforeTest() { - UsageClientBuilder usageClientbuilder = new UsageClientBuilder().httpClient(HttpClient.createDefault()) + 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()); diff --git a/typespec-tests/src/test/java/com/type/model/visibility/generated/VisibilityClientTestBase.java b/typespec-tests/src/test/java/com/type/model/visibility/generated/VisibilityClientTestBase.java index 0aeeca4b63..b610274bf6 100644 --- a/typespec-tests/src/test/java/com/type/model/visibility/generated/VisibilityClientTestBase.java +++ b/typespec-tests/src/test/java/com/type/model/visibility/generated/VisibilityClientTestBase.java @@ -13,6 +13,7 @@ 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; @@ -21,9 +22,10 @@ class VisibilityClientTestBase extends TestProxyTestBase { @Override protected void beforeTest() { - VisibilityClientBuilder visibilityClientbuilder - = new VisibilityClientBuilder().httpClient(HttpClient.createDefault()) - .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + 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) { diff --git a/typespec-tests/src/test/java/com/type/property/additionalproperties/generated/AdditionalPropertiesClientTestBase.java b/typespec-tests/src/test/java/com/type/property/additionalproperties/generated/AdditionalPropertiesClientTestBase.java index 21d97bbda8..2b3a3758dc 100644 --- a/typespec-tests/src/test/java/com/type/property/additionalproperties/generated/AdditionalPropertiesClientTestBase.java +++ b/typespec-tests/src/test/java/com/type/property/additionalproperties/generated/AdditionalPropertiesClientTestBase.java @@ -13,6 +13,7 @@ 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; @@ -114,9 +115,10 @@ class AdditionalPropertiesClientTestBase extends TestProxyTestBase { @Override protected void beforeTest() { - AdditionalPropertiesClientBuilder extendsUnknownClientbuilder - = new AdditionalPropertiesClientBuilder().httpClient(HttpClient.createDefault()) - .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + 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) { @@ -124,9 +126,10 @@ protected void beforeTest() { } extendsUnknownClient = extendsUnknownClientbuilder.buildExtendsUnknownClient(); - AdditionalPropertiesClientBuilder extendsUnknownDerivedClientbuilder - = new AdditionalPropertiesClientBuilder().httpClient(HttpClient.createDefault()) - .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + 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) { @@ -135,7 +138,9 @@ protected void beforeTest() { extendsUnknownDerivedClient = extendsUnknownDerivedClientbuilder.buildExtendsUnknownDerivedClient(); AdditionalPropertiesClientBuilder extendsUnknownDiscriminatedClientbuilder - = new AdditionalPropertiesClientBuilder().httpClient(HttpClient.createDefault()) + = 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()); @@ -145,9 +150,10 @@ protected void beforeTest() { extendsUnknownDiscriminatedClient = extendsUnknownDiscriminatedClientbuilder.buildExtendsUnknownDiscriminatedClient(); - AdditionalPropertiesClientBuilder isUnknownClientbuilder - = new AdditionalPropertiesClientBuilder().httpClient(HttpClient.createDefault()) - .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + 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) { @@ -155,9 +161,10 @@ protected void beforeTest() { } isUnknownClient = isUnknownClientbuilder.buildIsUnknownClient(); - AdditionalPropertiesClientBuilder isUnknownDerivedClientbuilder - = new AdditionalPropertiesClientBuilder().httpClient(HttpClient.createDefault()) - .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + 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) { @@ -165,9 +172,10 @@ protected void beforeTest() { } isUnknownDerivedClient = isUnknownDerivedClientbuilder.buildIsUnknownDerivedClient(); - AdditionalPropertiesClientBuilder isUnknownDiscriminatedClientbuilder - = new AdditionalPropertiesClientBuilder().httpClient(HttpClient.createDefault()) - .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + 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) { @@ -175,9 +183,10 @@ protected void beforeTest() { } isUnknownDiscriminatedClient = isUnknownDiscriminatedClientbuilder.buildIsUnknownDiscriminatedClient(); - AdditionalPropertiesClientBuilder extendsStringClientbuilder - = new AdditionalPropertiesClientBuilder().httpClient(HttpClient.createDefault()) - .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + 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) { @@ -185,9 +194,10 @@ protected void beforeTest() { } extendsStringClient = extendsStringClientbuilder.buildExtendsStringClient(); - AdditionalPropertiesClientBuilder isStringClientbuilder - = new AdditionalPropertiesClientBuilder().httpClient(HttpClient.createDefault()) - .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + 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) { @@ -195,9 +205,10 @@ protected void beforeTest() { } isStringClient = isStringClientbuilder.buildIsStringClient(); - AdditionalPropertiesClientBuilder spreadStringClientbuilder - = new AdditionalPropertiesClientBuilder().httpClient(HttpClient.createDefault()) - .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + 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) { @@ -205,9 +216,10 @@ protected void beforeTest() { } spreadStringClient = spreadStringClientbuilder.buildSpreadStringClient(); - AdditionalPropertiesClientBuilder extendsFloatClientbuilder - = new AdditionalPropertiesClientBuilder().httpClient(HttpClient.createDefault()) - .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + 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) { @@ -215,9 +227,10 @@ protected void beforeTest() { } extendsFloatClient = extendsFloatClientbuilder.buildExtendsFloatClient(); - AdditionalPropertiesClientBuilder isFloatClientbuilder - = new AdditionalPropertiesClientBuilder().httpClient(HttpClient.createDefault()) - .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + 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) { @@ -225,9 +238,10 @@ protected void beforeTest() { } isFloatClient = isFloatClientbuilder.buildIsFloatClient(); - AdditionalPropertiesClientBuilder spreadFloatClientbuilder - = new AdditionalPropertiesClientBuilder().httpClient(HttpClient.createDefault()) - .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + 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) { @@ -235,9 +249,10 @@ protected void beforeTest() { } spreadFloatClient = spreadFloatClientbuilder.buildSpreadFloatClient(); - AdditionalPropertiesClientBuilder extendsModelClientbuilder - = new AdditionalPropertiesClientBuilder().httpClient(HttpClient.createDefault()) - .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + 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) { @@ -245,9 +260,10 @@ protected void beforeTest() { } extendsModelClient = extendsModelClientbuilder.buildExtendsModelClient(); - AdditionalPropertiesClientBuilder isModelClientbuilder - = new AdditionalPropertiesClientBuilder().httpClient(HttpClient.createDefault()) - .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + 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) { @@ -255,9 +271,10 @@ protected void beforeTest() { } isModelClient = isModelClientbuilder.buildIsModelClient(); - AdditionalPropertiesClientBuilder spreadModelClientbuilder - = new AdditionalPropertiesClientBuilder().httpClient(HttpClient.createDefault()) - .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + 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) { @@ -265,9 +282,10 @@ protected void beforeTest() { } spreadModelClient = spreadModelClientbuilder.buildSpreadModelClient(); - AdditionalPropertiesClientBuilder extendsModelArrayClientbuilder - = new AdditionalPropertiesClientBuilder().httpClient(HttpClient.createDefault()) - .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + 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) { @@ -275,9 +293,10 @@ protected void beforeTest() { } extendsModelArrayClient = extendsModelArrayClientbuilder.buildExtendsModelArrayClient(); - AdditionalPropertiesClientBuilder isModelArrayClientbuilder - = new AdditionalPropertiesClientBuilder().httpClient(HttpClient.createDefault()) - .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + 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) { @@ -285,9 +304,10 @@ protected void beforeTest() { } isModelArrayClient = isModelArrayClientbuilder.buildIsModelArrayClient(); - AdditionalPropertiesClientBuilder spreadModelArrayClientbuilder - = new AdditionalPropertiesClientBuilder().httpClient(HttpClient.createDefault()) - .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + 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) { @@ -295,9 +315,10 @@ protected void beforeTest() { } spreadModelArrayClient = spreadModelArrayClientbuilder.buildSpreadModelArrayClient(); - AdditionalPropertiesClientBuilder spreadDifferentStringClientbuilder - = new AdditionalPropertiesClientBuilder().httpClient(HttpClient.createDefault()) - .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + 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) { @@ -305,9 +326,10 @@ protected void beforeTest() { } spreadDifferentStringClient = spreadDifferentStringClientbuilder.buildSpreadDifferentStringClient(); - AdditionalPropertiesClientBuilder spreadDifferentFloatClientbuilder - = new AdditionalPropertiesClientBuilder().httpClient(HttpClient.createDefault()) - .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + 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) { @@ -315,9 +337,10 @@ protected void beforeTest() { } spreadDifferentFloatClient = spreadDifferentFloatClientbuilder.buildSpreadDifferentFloatClient(); - AdditionalPropertiesClientBuilder spreadDifferentModelClientbuilder - = new AdditionalPropertiesClientBuilder().httpClient(HttpClient.createDefault()) - .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + 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) { @@ -326,7 +349,9 @@ protected void beforeTest() { spreadDifferentModelClient = spreadDifferentModelClientbuilder.buildSpreadDifferentModelClient(); AdditionalPropertiesClientBuilder spreadDifferentModelArrayClientbuilder - = new AdditionalPropertiesClientBuilder().httpClient(HttpClient.createDefault()) + = 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()); @@ -336,7 +361,9 @@ protected void beforeTest() { spreadDifferentModelArrayClient = spreadDifferentModelArrayClientbuilder.buildSpreadDifferentModelArrayClient(); AdditionalPropertiesClientBuilder extendsDifferentSpreadStringClientbuilder - = new AdditionalPropertiesClientBuilder().httpClient(HttpClient.createDefault()) + = 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()); @@ -347,7 +374,9 @@ protected void beforeTest() { = extendsDifferentSpreadStringClientbuilder.buildExtendsDifferentSpreadStringClient(); AdditionalPropertiesClientBuilder extendsDifferentSpreadFloatClientbuilder - = new AdditionalPropertiesClientBuilder().httpClient(HttpClient.createDefault()) + = 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()); @@ -358,7 +387,9 @@ protected void beforeTest() { = extendsDifferentSpreadFloatClientbuilder.buildExtendsDifferentSpreadFloatClient(); AdditionalPropertiesClientBuilder extendsDifferentSpreadModelClientbuilder - = new AdditionalPropertiesClientBuilder().httpClient(HttpClient.createDefault()) + = 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()); @@ -369,7 +400,9 @@ protected void beforeTest() { = extendsDifferentSpreadModelClientbuilder.buildExtendsDifferentSpreadModelClient(); AdditionalPropertiesClientBuilder extendsDifferentSpreadModelArrayClientbuilder - = new AdditionalPropertiesClientBuilder().httpClient(HttpClient.createDefault()) + = 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()); @@ -379,9 +412,10 @@ protected void beforeTest() { extendsDifferentSpreadModelArrayClient = extendsDifferentSpreadModelArrayClientbuilder.buildExtendsDifferentSpreadModelArrayClient(); - AdditionalPropertiesClientBuilder multipleSpreadClientbuilder - = new AdditionalPropertiesClientBuilder().httpClient(HttpClient.createDefault()) - .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + 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) { @@ -389,9 +423,10 @@ protected void beforeTest() { } multipleSpreadClient = multipleSpreadClientbuilder.buildMultipleSpreadClient(); - AdditionalPropertiesClientBuilder spreadRecordUnionClientbuilder - = new AdditionalPropertiesClientBuilder().httpClient(HttpClient.createDefault()) - .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + 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) { @@ -400,7 +435,9 @@ protected void beforeTest() { spreadRecordUnionClient = spreadRecordUnionClientbuilder.buildSpreadRecordUnionClient(); AdditionalPropertiesClientBuilder spreadRecordDiscriminatedUnionClientbuilder - = new AdditionalPropertiesClientBuilder().httpClient(HttpClient.createDefault()) + = 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()); @@ -411,7 +448,9 @@ protected void beforeTest() { = spreadRecordDiscriminatedUnionClientbuilder.buildSpreadRecordDiscriminatedUnionClient(); AdditionalPropertiesClientBuilder spreadRecordNonDiscriminatedUnionClientbuilder - = new AdditionalPropertiesClientBuilder().httpClient(HttpClient.createDefault()) + = 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()); @@ -422,7 +461,9 @@ protected void beforeTest() { = spreadRecordNonDiscriminatedUnionClientbuilder.buildSpreadRecordNonDiscriminatedUnionClient(); AdditionalPropertiesClientBuilder spreadRecordNonDiscriminatedUnion2Clientbuilder - = new AdditionalPropertiesClientBuilder().httpClient(HttpClient.createDefault()) + = 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()); @@ -433,7 +474,9 @@ protected void beforeTest() { = spreadRecordNonDiscriminatedUnion2Clientbuilder.buildSpreadRecordNonDiscriminatedUnion2Client(); AdditionalPropertiesClientBuilder spreadRecordNonDiscriminatedUnion3Clientbuilder - = new AdditionalPropertiesClientBuilder().httpClient(HttpClient.createDefault()) + = 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()); diff --git a/typespec-tests/src/test/java/com/type/property/nullable/generated/NullableClientTestBase.java b/typespec-tests/src/test/java/com/type/property/nullable/generated/NullableClientTestBase.java index 2026b4a037..cc371f12ce 100644 --- a/typespec-tests/src/test/java/com/type/property/nullable/generated/NullableClientTestBase.java +++ b/typespec-tests/src/test/java/com/type/property/nullable/generated/NullableClientTestBase.java @@ -13,6 +13,7 @@ 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; @@ -39,9 +40,10 @@ class NullableClientTestBase extends TestProxyTestBase { @Override protected void beforeTest() { - NullableClientBuilder stringOperationClientbuilder - = new NullableClientBuilder().httpClient(HttpClient.createDefault()) - .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + 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) { @@ -49,7 +51,9 @@ protected void beforeTest() { } stringOperationClient = stringOperationClientbuilder.buildStringOperationClient(); - NullableClientBuilder bytesClientbuilder = new NullableClientBuilder().httpClient(HttpClient.createDefault()) + 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()); @@ -58,9 +62,10 @@ protected void beforeTest() { } bytesClient = bytesClientbuilder.buildBytesClient(); - NullableClientBuilder datetimeOperationClientbuilder - = new NullableClientBuilder().httpClient(HttpClient.createDefault()) - .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + 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) { @@ -68,9 +73,10 @@ protected void beforeTest() { } datetimeOperationClient = datetimeOperationClientbuilder.buildDatetimeOperationClient(); - NullableClientBuilder durationOperationClientbuilder - = new NullableClientBuilder().httpClient(HttpClient.createDefault()) - .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + 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) { @@ -78,9 +84,10 @@ protected void beforeTest() { } durationOperationClient = durationOperationClientbuilder.buildDurationOperationClient(); - NullableClientBuilder collectionsByteClientbuilder - = new NullableClientBuilder().httpClient(HttpClient.createDefault()) - .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + 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) { @@ -88,9 +95,10 @@ protected void beforeTest() { } collectionsByteClient = collectionsByteClientbuilder.buildCollectionsByteClient(); - NullableClientBuilder collectionsModelClientbuilder - = new NullableClientBuilder().httpClient(HttpClient.createDefault()) - .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + 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) { @@ -98,9 +106,10 @@ protected void beforeTest() { } collectionsModelClient = collectionsModelClientbuilder.buildCollectionsModelClient(); - NullableClientBuilder collectionsStringClientbuilder - = new NullableClientBuilder().httpClient(HttpClient.createDefault()) - .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + 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) { diff --git a/typespec-tests/src/test/java/com/type/property/optional/generated/OptionalClientTestBase.java b/typespec-tests/src/test/java/com/type/property/optional/generated/OptionalClientTestBase.java index 35cec525da..f376090519 100644 --- a/typespec-tests/src/test/java/com/type/property/optional/generated/OptionalClientTestBase.java +++ b/typespec-tests/src/test/java/com/type/property/optional/generated/OptionalClientTestBase.java @@ -13,6 +13,7 @@ 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; @@ -66,9 +67,10 @@ class OptionalClientTestBase extends TestProxyTestBase { @Override protected void beforeTest() { - OptionalClientBuilder stringOperationClientbuilder - = new OptionalClientBuilder().httpClient(HttpClient.createDefault()) - .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + 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) { @@ -76,7 +78,9 @@ protected void beforeTest() { } stringOperationClient = stringOperationClientbuilder.buildStringOperationClient(); - OptionalClientBuilder bytesClientbuilder = new OptionalClientBuilder().httpClient(HttpClient.createDefault()) + 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()); @@ -85,9 +89,10 @@ protected void beforeTest() { } bytesClient = bytesClientbuilder.buildBytesClient(); - OptionalClientBuilder datetimeOperationClientbuilder - = new OptionalClientBuilder().httpClient(HttpClient.createDefault()) - .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + 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) { @@ -95,9 +100,10 @@ protected void beforeTest() { } datetimeOperationClient = datetimeOperationClientbuilder.buildDatetimeOperationClient(); - OptionalClientBuilder durationOperationClientbuilder - = new OptionalClientBuilder().httpClient(HttpClient.createDefault()) - .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + 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) { @@ -105,9 +111,10 @@ protected void beforeTest() { } durationOperationClient = durationOperationClientbuilder.buildDurationOperationClient(); - OptionalClientBuilder plainDateClientbuilder - = new OptionalClientBuilder().httpClient(HttpClient.createDefault()) - .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + 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) { @@ -115,9 +122,10 @@ protected void beforeTest() { } plainDateClient = plainDateClientbuilder.buildPlainDateClient(); - OptionalClientBuilder plainTimeClientbuilder - = new OptionalClientBuilder().httpClient(HttpClient.createDefault()) - .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + 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) { @@ -125,9 +133,10 @@ protected void beforeTest() { } plainTimeClient = plainTimeClientbuilder.buildPlainTimeClient(); - OptionalClientBuilder collectionsByteClientbuilder - = new OptionalClientBuilder().httpClient(HttpClient.createDefault()) - .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + 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) { @@ -135,9 +144,10 @@ protected void beforeTest() { } collectionsByteClient = collectionsByteClientbuilder.buildCollectionsByteClient(); - OptionalClientBuilder collectionsModelClientbuilder - = new OptionalClientBuilder().httpClient(HttpClient.createDefault()) - .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + 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) { @@ -145,9 +155,10 @@ protected void beforeTest() { } collectionsModelClient = collectionsModelClientbuilder.buildCollectionsModelClient(); - OptionalClientBuilder stringLiteralClientbuilder - = new OptionalClientBuilder().httpClient(HttpClient.createDefault()) - .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + 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) { @@ -155,9 +166,10 @@ protected void beforeTest() { } stringLiteralClient = stringLiteralClientbuilder.buildStringLiteralClient(); - OptionalClientBuilder intLiteralClientbuilder - = new OptionalClientBuilder().httpClient(HttpClient.createDefault()) - .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + 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) { @@ -165,9 +177,10 @@ protected void beforeTest() { } intLiteralClient = intLiteralClientbuilder.buildIntLiteralClient(); - OptionalClientBuilder floatLiteralClientbuilder - = new OptionalClientBuilder().httpClient(HttpClient.createDefault()) - .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + 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) { @@ -175,9 +188,10 @@ protected void beforeTest() { } floatLiteralClient = floatLiteralClientbuilder.buildFloatLiteralClient(); - OptionalClientBuilder booleanLiteralClientbuilder - = new OptionalClientBuilder().httpClient(HttpClient.createDefault()) - .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + 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) { @@ -185,9 +199,10 @@ protected void beforeTest() { } booleanLiteralClient = booleanLiteralClientbuilder.buildBooleanLiteralClient(); - OptionalClientBuilder unionStringLiteralClientbuilder - = new OptionalClientBuilder().httpClient(HttpClient.createDefault()) - .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + 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) { @@ -195,9 +210,10 @@ protected void beforeTest() { } unionStringLiteralClient = unionStringLiteralClientbuilder.buildUnionStringLiteralClient(); - OptionalClientBuilder unionIntLiteralClientbuilder - = new OptionalClientBuilder().httpClient(HttpClient.createDefault()) - .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + 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) { @@ -205,9 +221,10 @@ protected void beforeTest() { } unionIntLiteralClient = unionIntLiteralClientbuilder.buildUnionIntLiteralClient(); - OptionalClientBuilder unionFloatLiteralClientbuilder - = new OptionalClientBuilder().httpClient(HttpClient.createDefault()) - .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + 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) { @@ -215,9 +232,10 @@ protected void beforeTest() { } unionFloatLiteralClient = unionFloatLiteralClientbuilder.buildUnionFloatLiteralClient(); - OptionalClientBuilder requiredAndOptionalClientbuilder - = new OptionalClientBuilder().httpClient(HttpClient.createDefault()) - .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + 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) { diff --git a/typespec-tests/src/test/java/com/type/property/valuetypes/generated/ValueTypesClientTestBase.java b/typespec-tests/src/test/java/com/type/property/valuetypes/generated/ValueTypesClientTestBase.java index 09eb11aa3f..6a9e20c137 100644 --- a/typespec-tests/src/test/java/com/type/property/valuetypes/generated/ValueTypesClientTestBase.java +++ b/typespec-tests/src/test/java/com/type/property/valuetypes/generated/ValueTypesClientTestBase.java @@ -13,6 +13,7 @@ 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; @@ -105,9 +106,10 @@ class ValueTypesClientTestBase extends TestProxyTestBase { @Override protected void beforeTest() { - ValueTypesClientBuilder booleanOperationClientbuilder - = new ValueTypesClientBuilder().httpClient(HttpClient.createDefault()) - .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + 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) { @@ -115,9 +117,10 @@ protected void beforeTest() { } booleanOperationClient = booleanOperationClientbuilder.buildBooleanOperationClient(); - ValueTypesClientBuilder stringOperationClientbuilder - = new ValueTypesClientBuilder().httpClient(HttpClient.createDefault()) - .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + 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) { @@ -125,9 +128,10 @@ protected void beforeTest() { } stringOperationClient = stringOperationClientbuilder.buildStringOperationClient(); - ValueTypesClientBuilder bytesClientbuilder - = new ValueTypesClientBuilder().httpClient(HttpClient.createDefault()) - .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + 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) { @@ -135,7 +139,9 @@ protected void beforeTest() { } bytesClient = bytesClientbuilder.buildBytesClient(); - ValueTypesClientBuilder intClientbuilder = new ValueTypesClientBuilder().httpClient(HttpClient.createDefault()) + 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()); @@ -144,9 +150,10 @@ protected void beforeTest() { } intClient = intClientbuilder.buildIntClient(); - ValueTypesClientBuilder floatOperationClientbuilder - = new ValueTypesClientBuilder().httpClient(HttpClient.createDefault()) - .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + 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) { @@ -154,9 +161,10 @@ protected void beforeTest() { } floatOperationClient = floatOperationClientbuilder.buildFloatOperationClient(); - ValueTypesClientBuilder decimalClientbuilder - = new ValueTypesClientBuilder().httpClient(HttpClient.createDefault()) - .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + 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) { @@ -164,9 +172,10 @@ protected void beforeTest() { } decimalClient = decimalClientbuilder.buildDecimalClient(); - ValueTypesClientBuilder decimal128Clientbuilder - = new ValueTypesClientBuilder().httpClient(HttpClient.createDefault()) - .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + 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) { @@ -174,9 +183,10 @@ protected void beforeTest() { } decimal128Client = decimal128Clientbuilder.buildDecimal128Client(); - ValueTypesClientBuilder datetimeOperationClientbuilder - = new ValueTypesClientBuilder().httpClient(HttpClient.createDefault()) - .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + 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) { @@ -184,9 +194,10 @@ protected void beforeTest() { } datetimeOperationClient = datetimeOperationClientbuilder.buildDatetimeOperationClient(); - ValueTypesClientBuilder durationOperationClientbuilder - = new ValueTypesClientBuilder().httpClient(HttpClient.createDefault()) - .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + 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) { @@ -194,7 +205,9 @@ protected void beforeTest() { } durationOperationClient = durationOperationClientbuilder.buildDurationOperationClient(); - ValueTypesClientBuilder enumClientbuilder = new ValueTypesClientBuilder().httpClient(HttpClient.createDefault()) + 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()); @@ -203,9 +216,10 @@ protected void beforeTest() { } enumClient = enumClientbuilder.buildEnumClient(); - ValueTypesClientBuilder extensibleEnumClientbuilder - = new ValueTypesClientBuilder().httpClient(HttpClient.createDefault()) - .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + 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) { @@ -213,9 +227,10 @@ protected void beforeTest() { } extensibleEnumClient = extensibleEnumClientbuilder.buildExtensibleEnumClient(); - ValueTypesClientBuilder modelClientbuilder - = new ValueTypesClientBuilder().httpClient(HttpClient.createDefault()) - .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + 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) { @@ -223,9 +238,10 @@ protected void beforeTest() { } modelClient = modelClientbuilder.buildModelClient(); - ValueTypesClientBuilder collectionsStringClientbuilder - = new ValueTypesClientBuilder().httpClient(HttpClient.createDefault()) - .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + 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) { @@ -233,9 +249,10 @@ protected void beforeTest() { } collectionsStringClient = collectionsStringClientbuilder.buildCollectionsStringClient(); - ValueTypesClientBuilder collectionsIntClientbuilder - = new ValueTypesClientBuilder().httpClient(HttpClient.createDefault()) - .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + 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) { @@ -243,9 +260,10 @@ protected void beforeTest() { } collectionsIntClient = collectionsIntClientbuilder.buildCollectionsIntClient(); - ValueTypesClientBuilder collectionsModelClientbuilder - = new ValueTypesClientBuilder().httpClient(HttpClient.createDefault()) - .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + 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) { @@ -253,9 +271,10 @@ protected void beforeTest() { } collectionsModelClient = collectionsModelClientbuilder.buildCollectionsModelClient(); - ValueTypesClientBuilder dictionaryStringClientbuilder - = new ValueTypesClientBuilder().httpClient(HttpClient.createDefault()) - .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + 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) { @@ -263,9 +282,10 @@ protected void beforeTest() { } dictionaryStringClient = dictionaryStringClientbuilder.buildDictionaryStringClient(); - ValueTypesClientBuilder neverClientbuilder - = new ValueTypesClientBuilder().httpClient(HttpClient.createDefault()) - .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + 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) { @@ -273,9 +293,10 @@ protected void beforeTest() { } neverClient = neverClientbuilder.buildNeverClient(); - ValueTypesClientBuilder unknownStringClientbuilder - = new ValueTypesClientBuilder().httpClient(HttpClient.createDefault()) - .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + 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) { @@ -283,9 +304,10 @@ protected void beforeTest() { } unknownStringClient = unknownStringClientbuilder.buildUnknownStringClient(); - ValueTypesClientBuilder unknownIntClientbuilder - = new ValueTypesClientBuilder().httpClient(HttpClient.createDefault()) - .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + 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) { @@ -293,9 +315,10 @@ protected void beforeTest() { } unknownIntClient = unknownIntClientbuilder.buildUnknownIntClient(); - ValueTypesClientBuilder unknownDictClientbuilder - = new ValueTypesClientBuilder().httpClient(HttpClient.createDefault()) - .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + 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) { @@ -303,9 +326,10 @@ protected void beforeTest() { } unknownDictClient = unknownDictClientbuilder.buildUnknownDictClient(); - ValueTypesClientBuilder unknownArrayClientbuilder - = new ValueTypesClientBuilder().httpClient(HttpClient.createDefault()) - .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + 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) { @@ -313,9 +337,10 @@ protected void beforeTest() { } unknownArrayClient = unknownArrayClientbuilder.buildUnknownArrayClient(); - ValueTypesClientBuilder stringLiteralClientbuilder - = new ValueTypesClientBuilder().httpClient(HttpClient.createDefault()) - .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + 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) { @@ -323,9 +348,10 @@ protected void beforeTest() { } stringLiteralClient = stringLiteralClientbuilder.buildStringLiteralClient(); - ValueTypesClientBuilder intLiteralClientbuilder - = new ValueTypesClientBuilder().httpClient(HttpClient.createDefault()) - .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + 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) { @@ -333,9 +359,10 @@ protected void beforeTest() { } intLiteralClient = intLiteralClientbuilder.buildIntLiteralClient(); - ValueTypesClientBuilder floatLiteralClientbuilder - = new ValueTypesClientBuilder().httpClient(HttpClient.createDefault()) - .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + 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) { @@ -343,9 +370,10 @@ protected void beforeTest() { } floatLiteralClient = floatLiteralClientbuilder.buildFloatLiteralClient(); - ValueTypesClientBuilder booleanLiteralClientbuilder - = new ValueTypesClientBuilder().httpClient(HttpClient.createDefault()) - .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + 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) { @@ -353,9 +381,10 @@ protected void beforeTest() { } booleanLiteralClient = booleanLiteralClientbuilder.buildBooleanLiteralClient(); - ValueTypesClientBuilder unionStringLiteralClientbuilder - = new ValueTypesClientBuilder().httpClient(HttpClient.createDefault()) - .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + 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) { @@ -363,9 +392,10 @@ protected void beforeTest() { } unionStringLiteralClient = unionStringLiteralClientbuilder.buildUnionStringLiteralClient(); - ValueTypesClientBuilder unionIntLiteralClientbuilder - = new ValueTypesClientBuilder().httpClient(HttpClient.createDefault()) - .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + 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) { @@ -373,9 +403,10 @@ protected void beforeTest() { } unionIntLiteralClient = unionIntLiteralClientbuilder.buildUnionIntLiteralClient(); - ValueTypesClientBuilder unionFloatLiteralClientbuilder - = new ValueTypesClientBuilder().httpClient(HttpClient.createDefault()) - .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + 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) { @@ -383,9 +414,10 @@ protected void beforeTest() { } unionFloatLiteralClient = unionFloatLiteralClientbuilder.buildUnionFloatLiteralClient(); - ValueTypesClientBuilder unionEnumValueClientbuilder - = new ValueTypesClientBuilder().httpClient(HttpClient.createDefault()) - .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + 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) { diff --git a/typespec-tests/src/test/java/com/type/scalar/generated/ScalarClientTestBase.java b/typespec-tests/src/test/java/com/type/scalar/generated/ScalarClientTestBase.java index 3759c34811..63b9007c62 100644 --- a/typespec-tests/src/test/java/com/type/scalar/generated/ScalarClientTestBase.java +++ b/typespec-tests/src/test/java/com/type/scalar/generated/ScalarClientTestBase.java @@ -13,6 +13,7 @@ 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; @@ -39,9 +40,10 @@ class ScalarClientTestBase extends TestProxyTestBase { @Override protected void beforeTest() { - ScalarClientBuilder stringOperationClientbuilder - = new ScalarClientBuilder().httpClient(HttpClient.createDefault()) - .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + 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) { @@ -49,9 +51,10 @@ protected void beforeTest() { } stringOperationClient = stringOperationClientbuilder.buildStringOperationClient(); - ScalarClientBuilder booleanOperationClientbuilder - = new ScalarClientBuilder().httpClient(HttpClient.createDefault()) - .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + 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) { @@ -59,7 +62,9 @@ protected void beforeTest() { } booleanOperationClient = booleanOperationClientbuilder.buildBooleanOperationClient(); - ScalarClientBuilder unknownClientbuilder = new ScalarClientBuilder().httpClient(HttpClient.createDefault()) + 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()); @@ -68,7 +73,9 @@ protected void beforeTest() { } unknownClient = unknownClientbuilder.buildUnknownClient(); - ScalarClientBuilder decimalTypeClientbuilder = new ScalarClientBuilder().httpClient(HttpClient.createDefault()) + 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()); @@ -77,9 +84,10 @@ protected void beforeTest() { } decimalTypeClient = decimalTypeClientbuilder.buildDecimalTypeClient(); - ScalarClientBuilder decimal128TypeClientbuilder - = new ScalarClientBuilder().httpClient(HttpClient.createDefault()) - .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + 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) { @@ -87,9 +95,10 @@ protected void beforeTest() { } decimal128TypeClient = decimal128TypeClientbuilder.buildDecimal128TypeClient(); - ScalarClientBuilder decimalVerifyClientbuilder - = new ScalarClientBuilder().httpClient(HttpClient.createDefault()) - .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + 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) { @@ -97,9 +106,10 @@ protected void beforeTest() { } decimalVerifyClient = decimalVerifyClientbuilder.buildDecimalVerifyClient(); - ScalarClientBuilder decimal128VerifyClientbuilder - = new ScalarClientBuilder().httpClient(HttpClient.createDefault()) - .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + 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) { diff --git a/typespec-tests/src/test/java/com/type/union/generated/UnionClientTestBase.java b/typespec-tests/src/test/java/com/type/union/generated/UnionClientTestBase.java index 44b16bf194..4c8e1671b5 100644 --- a/typespec-tests/src/test/java/com/type/union/generated/UnionClientTestBase.java +++ b/typespec-tests/src/test/java/com/type/union/generated/UnionClientTestBase.java @@ -13,6 +13,7 @@ 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; @@ -48,7 +49,9 @@ class UnionClientTestBase extends TestProxyTestBase { @Override protected void beforeTest() { - UnionClientBuilder stringsOnlyClientbuilder = new UnionClientBuilder().httpClient(HttpClient.createDefault()) + 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()); @@ -57,9 +60,10 @@ protected void beforeTest() { } stringsOnlyClient = stringsOnlyClientbuilder.buildStringsOnlyClient(); - UnionClientBuilder stringExtensibleClientbuilder - = new UnionClientBuilder().httpClient(HttpClient.createDefault()) - .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + 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) { @@ -67,9 +71,10 @@ protected void beforeTest() { } stringExtensibleClient = stringExtensibleClientbuilder.buildStringExtensibleClient(); - UnionClientBuilder stringExtensibleNamedClientbuilder - = new UnionClientBuilder().httpClient(HttpClient.createDefault()) - .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + 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) { @@ -77,7 +82,9 @@ protected void beforeTest() { } stringExtensibleNamedClient = stringExtensibleNamedClientbuilder.buildStringExtensibleNamedClient(); - UnionClientBuilder intsOnlyClientbuilder = new UnionClientBuilder().httpClient(HttpClient.createDefault()) + 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()); @@ -86,7 +93,9 @@ protected void beforeTest() { } intsOnlyClient = intsOnlyClientbuilder.buildIntsOnlyClient(); - UnionClientBuilder floatsOnlyClientbuilder = new UnionClientBuilder().httpClient(HttpClient.createDefault()) + 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()); @@ -95,7 +104,9 @@ protected void beforeTest() { } floatsOnlyClient = floatsOnlyClientbuilder.buildFloatsOnlyClient(); - UnionClientBuilder modelsOnlyClientbuilder = new UnionClientBuilder().httpClient(HttpClient.createDefault()) + 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()); @@ -104,7 +115,9 @@ protected void beforeTest() { } modelsOnlyClient = modelsOnlyClientbuilder.buildModelsOnlyClient(); - UnionClientBuilder enumsOnlyClientbuilder = new UnionClientBuilder().httpClient(HttpClient.createDefault()) + 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()); @@ -113,7 +126,9 @@ protected void beforeTest() { } enumsOnlyClient = enumsOnlyClientbuilder.buildEnumsOnlyClient(); - UnionClientBuilder stringAndArrayClientbuilder = new UnionClientBuilder().httpClient(HttpClient.createDefault()) + 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()); @@ -122,7 +137,9 @@ protected void beforeTest() { } stringAndArrayClient = stringAndArrayClientbuilder.buildStringAndArrayClient(); - UnionClientBuilder mixedLiteralsClientbuilder = new UnionClientBuilder().httpClient(HttpClient.createDefault()) + 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()); @@ -131,7 +148,9 @@ protected void beforeTest() { } mixedLiteralsClient = mixedLiteralsClientbuilder.buildMixedLiteralsClient(); - UnionClientBuilder mixedTypesClientbuilder = new UnionClientBuilder().httpClient(HttpClient.createDefault()) + 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()); diff --git a/typespec-tests/tsp/error.tsp b/typespec-tests/tsp/error.tsp index aa02f36a61..2d8c225a7b 100644 --- a/typespec-tests/tsp/error.tsp +++ b/typespec-tests/tsp/error.tsp @@ -16,7 +16,18 @@ model Diagnostic { error: Error; } +@error +model UserError { + @statusCode + @minValue(400) + @maxValue(404) + status: int32; +} + @route("/error") interface ErrorOp { read(): ResourceCreatedOrOkResponse | ErrorResponse; + + @route("/statuscoderange") + readWithCustomizedError(): ResourceCreatedOrOkResponse | UserError; } diff --git a/typespec-tests/tsp/internal.tsp b/typespec-tests/tsp/internal.tsp index 2da6ff253e..6efe8711a5 100644 --- a/typespec-tests/tsp/internal.tsp +++ b/typespec-tests/tsp/internal.tsp @@ -94,7 +94,7 @@ model ProtocolInternalModel { interface InternalOp { // test ApiRequest with Access.public @access(Access.public, "python") - @access(Access.internal, "client") + @access(Access.internal, "java") @post postInternal(@body body: ApiRequest): ResponseInternal;