From 41cf4bf882bf60dbdcffd3fbe4acca3b89f86098 Mon Sep 17 00:00:00 2001 From: Haoling Dong Date: Wed, 18 Sep 2024 11:41:10 +0800 Subject: [PATCH 01/26] code to use TCGC usage and access --- .../emitter/src/code-model-builder.ts | 108 ++++++++++++------ .../emitter/src/external-schemas.ts | 5 + .../emitter/src/type-utils.ts | 66 +++++++++-- 3 files changed, 136 insertions(+), 43 deletions(-) diff --git a/packages/http-client-java/emitter/src/code-model-builder.ts b/packages/http-client-java/emitter/src/code-model-builder.ts index 263da6dd15..0946e67d83 100644 --- a/packages/http-client-java/emitter/src/code-model-builder.ts +++ b/packages/http-client-java/emitter/src/code-model-builder.ts @@ -30,6 +30,7 @@ import { Response, Schema, SchemaResponse, + Schemas, SchemaType, Security, SecurityScheme, @@ -152,7 +153,9 @@ import { getUsage, isStable, modelIs, + processSchemaUsageFromSdkType, pushDistinct, + trackSchemaUsage, } from "./type-utils.js"; import { getNamespace, @@ -177,7 +180,7 @@ export class CodeModelBuilder { private loggingEnabled: boolean = false; readonly schemaCache = new ProcessingCache((type: SdkType, name: string) => - this.processSchemaFromSdkTypeImpl(type, name) + this.processSchemaFromSdkTypeImpl(type, name), ); 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 @@ -261,7 +264,8 @@ export class CodeModelBuilder { this.processModels(); - this.processSchemaUsage(); + this.postProcessSchemaUsage(); + this.deduplicateSchemaName(); @@ -276,7 +280,7 @@ export class CodeModelBuilder { parameter = this.createApiVersionParameter(arg.name, ParameterLocation.Uri); } else { const schema = this.processSchemaFromSdkType(arg.type, arg.name); - this.trackSchemaUsage(schema, { + trackSchemaUsage(schema, { usage: [SchemaContext.Input, SchemaContext.Output /*SchemaContext.Public*/], }); parameter = new Parameter(arg.name, arg.description ?? "", schema, { @@ -372,7 +376,7 @@ export class CodeModelBuilder { const modelAsPublic = (model: SdkModelType | SdkEnumType) => { const schema = this.processSchemaFromSdkType(model, ""); - this.trackSchemaUsage(schema, { + trackSchemaUsage(schema, { usage: [SchemaContext.Public], }); }; @@ -388,7 +392,7 @@ export class CodeModelBuilder { } else if (access === "internal") { const schema = this.processSchemaFromSdkType(model, model.name); - this.trackSchemaUsage(schema, { + trackSchemaUsage(schema, { usage: [SchemaContext.Internal], }); } @@ -397,9 +401,9 @@ export class CodeModelBuilder { if (usage) { const schema = this.processSchemaFromSdkType(model, ""); - this.trackSchemaUsage(schema, { - usage: usage, - }); + // trackSchemaUsage(schema, { + // usage: usage, + // }); } processedSdkModels.add(model); @@ -407,17 +411,17 @@ export class CodeModelBuilder { } } - private processSchemaUsage() { - this.codeModel.schemas.objects?.forEach((it) => this.propagateSchemaUsage(it)); + // private processSchemaUsage() { + // this.codeModel.schemas.objects?.forEach((it) => this.propagateSchemaUsage(it)); - // post process for schema usage - this.codeModel.schemas.objects?.forEach((it) => this.resolveSchemaUsage(it)); - this.codeModel.schemas.groups?.forEach((it) => this.resolveSchemaUsage(it)); - this.codeModel.schemas.choices?.forEach((it) => this.resolveSchemaUsage(it)); - this.codeModel.schemas.sealedChoices?.forEach((it) => this.resolveSchemaUsage(it)); - this.codeModel.schemas.ors?.forEach((it) => this.resolveSchemaUsage(it)); - this.codeModel.schemas.constants?.forEach((it) => this.resolveSchemaUsage(it)); - } + // // post process for schema usage + // this.codeModel.schemas.objects?.forEach((it) => this.resolveSchemaUsage(it)); + // this.codeModel.schemas.groups?.forEach((it) => this.resolveSchemaUsage(it)); + // this.codeModel.schemas.choices?.forEach((it) => this.resolveSchemaUsage(it)); + // this.codeModel.schemas.sealedChoices?.forEach((it) => this.resolveSchemaUsage(it)); + // this.codeModel.schemas.ors?.forEach((it) => this.resolveSchemaUsage(it)); + // this.codeModel.schemas.constants?.forEach((it) => this.resolveSchemaUsage(it)); + // } private deduplicateSchemaName() { // deduplicate model name @@ -906,7 +910,7 @@ export class CodeModelBuilder { op.responses?.forEach((r) => { if (r instanceof SchemaResponse) { - this.trackSchemaUsage(r.schema, { usage: [SchemaContext.Paged] }); + trackSchemaUsage(r.schema, { usage: [SchemaContext.Paged] }); } }); break; @@ -1354,20 +1358,23 @@ export class CodeModelBuilder { const jsonMergePatch = operationIsJsonMergePatch(sdkHttpOperation); - const schemaIsPublicBeforeProcess = - schema instanceof ObjectSchema && - (schema as SchemaUsage).usage?.includes(SchemaContext.Public); + // const schemaIsPublicBeforeProcess = + // schema instanceof ObjectSchema && + // (schema as SchemaUsage).usage?.includes(SchemaContext.Public); this.trackSchemaUsage(schema, { usage: [SchemaContext.Input] }); - if (op.convenienceApi) { - // model/schema does not need to be Public or Internal, if it is not to be used in convenience API - this.trackSchemaUsage(schema, { - usage: [op.internalApi ? SchemaContext.Internal : SchemaContext.Public], - }); - } + // if (op.convenienceApi) { + // // model/schema does not need to be Public or Internal, if it is not to be used in convenience API + // this.trackSchemaUsage(schema, { + // usage: [op.internalApi ? SchemaContext.Internal : SchemaContext.Public], + // }); + // } + if (jsonMergePatch) { + // TODO haoling: consider move it out + this.trackSchemaUsage(schema, { usage: [op.internalApi ? SchemaContext.Internal : SchemaContext.Public] }); this.trackSchemaUsage(schema, { usage: [SchemaContext.JsonMergePatch] }); } if (op.convenienceApi && operationIsMultipart(sdkHttpOperation)) { @@ -1399,16 +1406,20 @@ export class CodeModelBuilder { if (sdkType.isGeneratedName) { schema.language.default.name = pascalCase(op.language.default.name) + "PatchRequest"; } - return; + // // TODO haoling: maybe put to a global post processing + // this.postProcessSchemaUsage(schema); + // return; } const schemaUsage = (schema as SchemaUsage).usage; - if (!schemaIsPublicBeforeProcess && schemaUsage?.includes(SchemaContext.Public)) { - // Public added in this op, change it to PublicSpread - // This means that if this op would originally add Public to this schema, it adds PublicSpread instead - schemaUsage?.splice(schemaUsage?.indexOf(SchemaContext.Public), 1); - this.trackSchemaUsage(schema, { usage: [SchemaContext.PublicSpread] }); - } + trackSchemaUsage(schema, { usage: schemaUsage }); + // if (!schemaIsPublicBeforeProcess && schemaUsage?.includes(SchemaContext.Public)) { + // // Public added in this op, change it to PublicSpread + // // This means that if this op would originally add Public to this schema, it adds PublicSpread instead + // schemaUsage?.splice(schemaUsage?.indexOf(SchemaContext.Public), 1); + // trackSchemaUsage(schema, { usage: [SchemaContext.Public] }); + // } + if (op.convenienceApi && op.parameters) { op.convenienceApi.requests = []; @@ -1940,6 +1951,7 @@ export class CodeModelBuilder { }, }); schema.crossLanguageDefinitionId = type.crossLanguageDefinitionId; + schema.usage = processSchemaUsageFromSdkType(type, schema.usage); return this.codeModel.schemas.add(schema); } @@ -2045,6 +2057,8 @@ export class CodeModelBuilder { (objectSchema as CrossLanguageDefinition).crossLanguageDefinitionId = type.crossLanguageDefinitionId; this.codeModel.schemas.add(objectSchema); + // TODO haoling: fix as any + objectSchema.usage = processSchemaUsageFromSdkType(type, objectSchema.usage) as any; // cache this now before we accidentally recurse on this type. if (!this.schemaCache.has(type)) { @@ -2606,7 +2620,7 @@ export class CodeModelBuilder { const processedSchemas = new Set(); const innerApplySchemaUsage = (schema: Schema, schemaUsage: SchemaUsage) => { - this.trackSchemaUsage(schema, schemaUsage); + trackSchemaUsage(schema, schemaUsage); innerPropagateSchemaUsage(schema, schemaUsage); }; @@ -2681,6 +2695,28 @@ export class CodeModelBuilder { innerPropagateSchemaUsage(schema, schemaUsage); } + // private postProcessSchemaUsage(schemaUsage: SchemaUsage): void { + // if (schemaUsage.usage?.includes(SchemaContext.Public) && schemaUsage.usage?.includes(SchemaContext.Internal)) { + // // remove internal + // schemaUsage.usage.splice(schemaUsage.usage.indexOf(SchemaContext.Internal), 1); + // } + // } + + private postProcessSchemaUsage(): void { + this.codeModel.schemas.objects?.forEach((schema) => { + const usages = (schema as SchemaUsage).usage; + if (usages && usages.includes(SchemaContext.Public) && usages.includes(SchemaContext.Internal)) { // TODO haoling: add check to apply only to json-merge-patch and multipart + // remove internal + usages.splice(usages.indexOf(SchemaContext.Internal), 1); + } + // if (usages && usages.includes(SchemaContext.Exception)) { + // // remove internal + // usages.length = 0; // remove all items in the usages array + // trackSchemaUsage(schema, { usage: [SchemaContext.Exception] }); + // } + }); + } + private trackSchemaUsage(schema: Schema, schemaUsage: SchemaUsage): void { if ( schema instanceof ObjectSchema || diff --git a/packages/http-client-java/emitter/src/external-schemas.ts b/packages/http-client-java/emitter/src/external-schemas.ts index 5f974927ea..7216e0223d 100644 --- a/packages/http-client-java/emitter/src/external-schemas.ts +++ b/packages/http-client-java/emitter/src/external-schemas.ts @@ -16,6 +16,8 @@ import { } from "@azure-tools/typespec-client-generator-core"; import { CrossLanguageDefinition } from "./common/client.js"; import { getNamespace, pascalCase } from "./utils.js"; +import { trackSchemaUsage } from "./type-utils.js"; +import { SchemaContext } from "./common/schemas/usage.js"; /* * These schema need to reflect @@ -336,6 +338,9 @@ export function getFileDetailsSchema( addFilenameProperty(fileDetailsSchema, stringSchema); addContentTypeProperty(fileDetailsSchema, stringSchema); } + // set the schema usage to public access, later we will have post processor to propagate operation's access to the model + trackSchemaUsage(fileDetailsSchema, { usage: [SchemaContext.Input, SchemaContext.Public] }); + return fileDetailsSchema; } } diff --git a/packages/http-client-java/emitter/src/type-utils.ts b/packages/http-client-java/emitter/src/type-utils.ts index 62daa6349a..d2843cbffc 100644 --- a/packages/http-client-java/emitter/src/type-utils.ts +++ b/packages/http-client-java/emitter/src/type-utils.ts @@ -1,11 +1,4 @@ -import { SchemaContext } from "@autorest/codemodel"; import { getUnionAsEnum } from "@azure-tools/typespec-azure-core"; -import { - SdkDurationType, - SdkType, - isSdkFloatKind, - isSdkIntKind, -} from "@azure-tools/typespec-client-generator-core"; import { DecoratedType, DecoratorApplication, @@ -28,6 +21,13 @@ import { } from "@typespec/compiler"; import { DurationSchema } from "./common/schemas/time.js"; import { getNamespace } from "./utils.js"; +import { SdkDurationType, SdkEnumType, SdkModelType, SdkType, UsageFlags, isSdkFloatKind, isSdkIntKind } from "@azure-tools/typespec-client-generator-core"; +import { SchemaContext, SchemaUsage } from "./common/schemas/usage.js"; +import { ChoiceSchema, SealedChoiceSchema } from "./common/schemas/choice.js"; +import { OrSchema } from "./common/schemas/relationship.js"; +import { ConstantSchema } from "./common/schemas/constant.js"; +import { ArraySchema, DictionarySchema, GroupSchema, ObjectSchema, Schema } from "@autorest/codemodel"; + /** Acts as a cache for processing inputs. * @@ -310,6 +310,58 @@ export function isArmCommonType(entity: Type): boolean { return false; } +export function processSchemaUsageFromSdkType(sdkType: SdkModelType | SdkEnumType, schemaUsage: SchemaContext[] | undefined): SchemaContext[] { + let usage: SchemaContext[] = schemaUsage ?? []; + const usageFlags: UsageFlags = sdkType.usage; + if (usageFlags & UsageFlags.Error) { + usage = [SchemaContext.Exception]; + return usage; + } + if (usageFlags & UsageFlags.Input) + usage = pushDistinct(usage, SchemaContext.Input); + if (usageFlags & UsageFlags.Output) + usage = pushDistinct(usage, SchemaContext.Output); + if (usageFlags & UsageFlags.JsonMergePatch) + usage = pushDistinct(usage, SchemaContext.JsonMergePatch); + if (usageFlags & UsageFlags.Spread) + usage = pushDistinct(usage, SchemaContext.Input); + + + const accessFlags = sdkType.access; + if (accessFlags === "internal") { + usage = pushDistinct(usage ?? [], SchemaContext.Internal); + } else { + usage = pushDistinct(usage ?? [], SchemaContext.Public); + } + return usage; +} + +export function trackSchemaUsage(schema: Schema, schemaUsage: SchemaUsage): void { + if ( + schema instanceof ObjectSchema || + schema instanceof GroupSchema || + schema instanceof ChoiceSchema || + schema instanceof SealedChoiceSchema || + schema instanceof OrSchema || + schema instanceof ConstantSchema + ) { + if (schemaUsage.usage) { + pushDistinct((schema.usage = schema.usage || []), ...schemaUsage.usage); + } + if (schemaUsage.serializationFormats) { + pushDistinct( + (schema.serializationFormats = schema.serializationFormats || []), + ...schemaUsage.serializationFormats, + ); + } + } else if (schema instanceof DictionarySchema) { + trackSchemaUsage(schema.elementType, schemaUsage); + } else if (schema instanceof ArraySchema) { + trackSchemaUsage(schema.elementType, schemaUsage); + } +} + + function getDecoratorScopedValue( type: DecoratedType, decorator: string, From efc36ec5d8f954eaca6b6a50304bed707aff57d3 Mon Sep 17 00:00:00 2001 From: Haoling Dong Date: Wed, 18 Sep 2024 16:26:20 +0800 Subject: [PATCH 02/26] refine logic --- packages/http-client-java/emitter/src/code-model-builder.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/http-client-java/emitter/src/code-model-builder.ts b/packages/http-client-java/emitter/src/code-model-builder.ts index 0946e67d83..9d47d7cce0 100644 --- a/packages/http-client-java/emitter/src/code-model-builder.ts +++ b/packages/http-client-java/emitter/src/code-model-builder.ts @@ -1408,7 +1408,7 @@ export class CodeModelBuilder { } // // TODO haoling: maybe put to a global post processing // this.postProcessSchemaUsage(schema); - // return; + return; } const schemaUsage = (schema as SchemaUsage).usage; @@ -2707,7 +2707,9 @@ export class CodeModelBuilder { const usages = (schema as SchemaUsage).usage; if (usages && usages.includes(SchemaContext.Public) && usages.includes(SchemaContext.Internal)) { // TODO haoling: add check to apply only to json-merge-patch and multipart // remove internal - usages.splice(usages.indexOf(SchemaContext.Internal), 1); + if (usages.includes(SchemaContext.JsonMergePatch) || schema.serializationFormats?.includes(KnownMediaType.Multipart)) { + usages.splice(usages.indexOf(SchemaContext.Internal), 1); + } } // if (usages && usages.includes(SchemaContext.Exception)) { // // remove internal From 374e3a68bf1c3b647abff50194c7f1731e579736 Mon Sep 17 00:00:00 2001 From: Haoling Dong Date: Thu, 19 Sep 2024 11:37:34 +0800 Subject: [PATCH 03/26] remove track usage logic in process response --- .../emitter/src/code-model-builder.ts | 29 ++++++++++++++----- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/packages/http-client-java/emitter/src/code-model-builder.ts b/packages/http-client-java/emitter/src/code-model-builder.ts index be1e0f59a7..d1f2df5525 100644 --- a/packages/http-client-java/emitter/src/code-model-builder.ts +++ b/packages/http-client-java/emitter/src/code-model-builder.ts @@ -987,7 +987,6 @@ export class CodeModelBuilder { } } - // track usage if (pollingSchema) { this.trackSchemaUsage(pollingSchema, { usage: [SchemaContext.Output] }); if (trackConvenienceApi) { @@ -1715,13 +1714,18 @@ export class CodeModelBuilder { op.addResponse(response); if (response instanceof SchemaResponse) { - this.trackSchemaUsage(response.schema, { usage: [SchemaContext.Output] }); - - if (trackConvenienceApi) { - this.trackSchemaUsage(response.schema, { - usage: [op.internalApi ? SchemaContext.Internal : SchemaContext.Public], + if (!trackConvenienceApi) { + trackSchemaUsage(response.schema, { + usage: [SchemaContext.None] }); } + // this.trackSchemaUsage(response.schema, { usage: [SchemaContext.Output] }); + + // if (trackConvenienceApi) { + // this.trackSchemaUsage(response.schema, { + // usage: [op.internalApi ? SchemaContext.Internal : SchemaContext.Public], + // }); + // } } } } @@ -2707,12 +2711,21 @@ export class CodeModelBuilder { private postProcessSchemaUsage(): void { this.codeModel.schemas.objects?.forEach((schema) => { const usages = (schema as SchemaUsage).usage; + // if (usages && usages.includes(SchemaContext.Public) && usages.includes(SchemaContext.Internal)) { // TODO haoling: add check to apply only to json-merge-patch and multipart + // // remove internal + // if (usages.includes(SchemaContext.JsonMergePatch) || schema.serializationFormats?.includes(KnownMediaType.Multipart)) { + // usages.splice(usages.indexOf(SchemaContext.Internal), 1); + // } + // } if (usages && usages.includes(SchemaContext.Public) && usages.includes(SchemaContext.Internal)) { // TODO haoling: add check to apply only to json-merge-patch and multipart // remove internal - if (usages.includes(SchemaContext.JsonMergePatch) || schema.serializationFormats?.includes(KnownMediaType.Multipart)) { usages.splice(usages.indexOf(SchemaContext.Internal), 1); - } } + if (usages && usages.includes(SchemaContext.None)) { + // no usage + (schema as SchemaUsage).usage = []; + } + // if (usages && usages.includes(SchemaContext.Exception)) { // // remove internal // usages.length = 0; // remove all items in the usages array From e6612bf300291bd2123ac9f47ad342bcd5eb172c Mon Sep 17 00:00:00 2001 From: Haoling Dong Date: Thu, 19 Sep 2024 15:36:39 +0800 Subject: [PATCH 04/26] logics for handling lro schema usage --- .../emitter/src/code-model-builder.ts | 59 +++++++++++-------- .../emitter/src/common/schemas/usage.ts | 3 + .../emitter/src/external-schemas.ts | 2 + 3 files changed, 41 insertions(+), 23 deletions(-) diff --git a/packages/http-client-java/emitter/src/code-model-builder.ts b/packages/http-client-java/emitter/src/code-model-builder.ts index d1f2df5525..b92977597b 100644 --- a/packages/http-client-java/emitter/src/code-model-builder.ts +++ b/packages/http-client-java/emitter/src/code-model-builder.ts @@ -871,13 +871,13 @@ export class CodeModelBuilder { } // responses - for (const [code, response] of sdkMethod.operation.responses) { - this.processResponse(codeModelOperation, code, response, lroMetadata.longRunning, false); + for (const response of sdkMethod.operation.responses) { + this.processResponse(codeModelOperation, response.statusCodes, response, lroMetadata.longRunning, false); } // exception - for (const [code, response] of sdkMethod.operation.exceptions) { - this.processResponse(codeModelOperation, code, response, lroMetadata.longRunning, true); + for (const response of sdkMethod.operation.exceptions) { + this.processResponse(codeModelOperation, response.statusCodes, response, lroMetadata.longRunning, true); } // check for paged @@ -893,11 +893,11 @@ export class CodeModelBuilder { private processRouteForPaged( op: CodeModelOperation, - responses: Map, + responses: SdkHttpResponse[], sdkMethod: SdkMethod, ) { if (sdkMethod.kind === "paging" || sdkMethod.kind === "lropaging") { - for (const [_, response] of responses) { + for (const response of responses) { const bodyType = response.type; if (bodyType && bodyType.kind === "model") { const itemName = sdkMethod.response.resultPath; @@ -993,6 +993,10 @@ export class CodeModelBuilder { this.trackSchemaUsage(pollingSchema, { usage: [op.internalApi ? SchemaContext.Internal : SchemaContext.Public], }); + } else { + trackSchemaUsage(pollingSchema, { + usage: [SchemaContext.None] + }); } } if (finalSchema) { @@ -1001,6 +1005,10 @@ export class CodeModelBuilder { this.trackSchemaUsage(finalSchema, { usage: [op.internalApi ? SchemaContext.Internal : SchemaContext.Public], }); + } else { // overwrite the schema usage set by tcgc + trackSchemaUsage(finalSchema, { + usage: [SchemaContext.None] + }); } } @@ -1019,7 +1027,7 @@ export class CodeModelBuilder { private processRouteForLongRunning( op: CodeModelOperation, - responses: Map, + responses: SdkHttpResponse[], lroMetadata: LongRunningMetadata, ) { if (lroMetadata.longRunning) { @@ -1621,6 +1629,10 @@ export class CodeModelBuilder { if (sdkResponse.headers) { for (const header of sdkResponse.headers) { const schema = this.processSchema(header.type, header.serializedName); + // TODO haoling: why header schema do not need usage tracking? no usage tracking for header schema? + trackSchemaUsage(schema, { + usage: [SchemaContext.None] + }); headers.push( new HttpHeader(header.serializedName, schema, { language: { @@ -1714,18 +1726,22 @@ export class CodeModelBuilder { op.addResponse(response); if (response instanceof SchemaResponse) { - if (!trackConvenienceApi) { + // if (!trackConvenienceApi) { + // trackSchemaUsage(response.schema, { + // usage: [SchemaContext.None] + // }); + // } + this.trackSchemaUsage(response.schema, { usage: [SchemaContext.Output] }); + + if (trackConvenienceApi) { + this.trackSchemaUsage(response.schema, { + usage: [op.internalApi ? SchemaContext.Internal : SchemaContext.Public], + }); + } else { trackSchemaUsage(response.schema, { usage: [SchemaContext.None] }); } - // this.trackSchemaUsage(response.schema, { usage: [SchemaContext.Output] }); - - // if (trackConvenienceApi) { - // this.trackSchemaUsage(response.schema, { - // usage: [op.internalApi ? SchemaContext.Internal : SchemaContext.Public], - // }); - // } } } } @@ -2709,7 +2725,7 @@ export class CodeModelBuilder { // } private postProcessSchemaUsage(): void { - this.codeModel.schemas.objects?.forEach((schema) => { + const innerProcessUsage = (schema: ObjectSchema | ChoiceSchema | SealedChoiceSchema) => { const usages = (schema as SchemaUsage).usage; // if (usages && usages.includes(SchemaContext.Public) && usages.includes(SchemaContext.Internal)) { // TODO haoling: add check to apply only to json-merge-patch and multipart // // remove internal @@ -2725,13 +2741,10 @@ export class CodeModelBuilder { // no usage (schema as SchemaUsage).usage = []; } - - // if (usages && usages.includes(SchemaContext.Exception)) { - // // remove internal - // usages.length = 0; // remove all items in the usages array - // trackSchemaUsage(schema, { usage: [SchemaContext.Exception] }); - // } - }); + }; + this.codeModel.schemas.choices?.forEach(innerProcessUsage); + this.codeModel.schemas.objects?.forEach(innerProcessUsage); + this.codeModel.schemas.sealedChoices?.forEach(innerProcessUsage); } private trackSchemaUsage(schema: Schema, schemaUsage: SchemaUsage): void { diff --git a/packages/http-client-java/emitter/src/common/schemas/usage.ts b/packages/http-client-java/emitter/src/common/schemas/usage.ts index 59e69d2c8e..71a0b27be9 100644 --- a/packages/http-client-java/emitter/src/common/schemas/usage.ts +++ b/packages/http-client-java/emitter/src/common/schemas/usage.ts @@ -24,6 +24,9 @@ export enum SchemaContext { /** Schema is used in json-merge-patch operation */ JsonMergePatch = "json-merge-patch", + + /** Schema is not used */ + None = "None" } export interface SchemaUsage { diff --git a/packages/http-client-java/emitter/src/external-schemas.ts b/packages/http-client-java/emitter/src/external-schemas.ts index 612dcab8a9..e9d0b5d45d 100644 --- a/packages/http-client-java/emitter/src/external-schemas.ts +++ b/packages/http-client-java/emitter/src/external-schemas.ts @@ -319,6 +319,8 @@ export function getFileDetailsSchema( processSchemaFunc, ); } + // set the schema usage to public access, later we will have post processor to propagate operation's access to the model + trackSchemaUsage(fileDetailsSchema, { usage: [SchemaContext.Input, SchemaContext.Public] }); return fileDetailsSchema; } else { // property.type is bytes, create a File schema From d98945757998a8b09a4fa2bb984a33f220b74ff0 Mon Sep 17 00:00:00 2001 From: Haoling Dong Date: Fri, 20 Sep 2024 14:29:34 +0800 Subject: [PATCH 05/26] solve conflict --- .../emitter/src/code-model-builder.ts | 21 ++++--------------- 1 file changed, 4 insertions(+), 17 deletions(-) diff --git a/packages/http-client-java/emitter/src/code-model-builder.ts b/packages/http-client-java/emitter/src/code-model-builder.ts index e1db013fef..f281d01017 100644 --- a/packages/http-client-java/emitter/src/code-model-builder.ts +++ b/packages/http-client-java/emitter/src/code-model-builder.ts @@ -872,9 +872,6 @@ export class CodeModelBuilder { // responses for (const response of sdkMethod.operation.responses) { -<<<<<<< HEAD - this.processResponse(codeModelOperation, response.statusCodes, response, lroMetadata.longRunning, false); -======= this.processResponse( codeModelOperation, response.statusCodes, @@ -882,14 +879,10 @@ export class CodeModelBuilder { lroMetadata.longRunning, false, ); ->>>>>>> remote/main } // exception for (const response of sdkMethod.operation.exceptions) { -<<<<<<< HEAD - this.processResponse(codeModelOperation, response.statusCodes, response, lroMetadata.longRunning, true); -======= this.processResponse( codeModelOperation, response.statusCodes, @@ -897,7 +890,6 @@ export class CodeModelBuilder { lroMetadata.longRunning, true, ); ->>>>>>> remote/main } // check for paged @@ -1045,15 +1037,7 @@ export class CodeModelBuilder { return new LongRunningMetadata(false); } -<<<<<<< HEAD - private processRouteForLongRunning( - op: CodeModelOperation, - responses: SdkHttpResponse[], - lroMetadata: LongRunningMetadata, - ) { -======= private processRouteForLongRunning(op: CodeModelOperation, lroMetadata: LongRunningMetadata) { ->>>>>>> remote/main if (lroMetadata.longRunning) { op.extensions = op.extensions ?? {}; op.extensions["x-ms-long-running-operation"] = true; @@ -2749,7 +2733,7 @@ export class CodeModelBuilder { // } private postProcessSchemaUsage(): void { - const innerProcessUsage = (schema: ObjectSchema | ChoiceSchema | SealedChoiceSchema) => { + const innerProcessUsage = (schema: Schema) => { const usages = (schema as SchemaUsage).usage; // if (usages && usages.includes(SchemaContext.Public) && usages.includes(SchemaContext.Internal)) { // TODO haoling: add check to apply only to json-merge-patch and multipart // // remove internal @@ -2769,6 +2753,9 @@ export class CodeModelBuilder { this.codeModel.schemas.choices?.forEach(innerProcessUsage); this.codeModel.schemas.objects?.forEach(innerProcessUsage); this.codeModel.schemas.sealedChoices?.forEach(innerProcessUsage); + this.codeModel.schemas.constants?.forEach(innerProcessUsage); + this.codeModel.schemas.groups?.forEach(innerProcessUsage); + this.codeModel.schemas.ors?.forEach(innerProcessUsage); } private trackSchemaUsage(schema: Schema, schemaUsage: SchemaUsage): void { From de378a1f5b28e22b984181b93b7910e1e51b0cd5 Mon Sep 17 00:00:00 2001 From: Haoling Dong Date: Fri, 20 Sep 2024 14:46:11 +0800 Subject: [PATCH 06/26] solve conflict --- packages/http-client-java/emitter/src/type-utils.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/http-client-java/emitter/src/type-utils.ts b/packages/http-client-java/emitter/src/type-utils.ts index f6c77a411d..7d1ab61b7e 100644 --- a/packages/http-client-java/emitter/src/type-utils.ts +++ b/packages/http-client-java/emitter/src/type-utils.ts @@ -21,7 +21,6 @@ import { isTypeSpecValueTypeOf, } from "@typespec/compiler"; import { DurationSchema } from "./common/schemas/time.js"; -import { SchemaContext } from "./common/schemas/usage.js"; import { getNamespace } from "./utils.js"; import { SdkDurationType, SdkEnumType, SdkModelType, SdkType, UsageFlags, isSdkFloatKind, isSdkIntKind } from "@azure-tools/typespec-client-generator-core"; import { SchemaContext, SchemaUsage } from "./common/schemas/usage.js"; From c3f65c71d8f3f7a6ba1f3caac0a38dfca3b65913 Mon Sep 17 00:00:00 2001 From: Haoling Dong Date: Mon, 30 Sep 2024 15:54:11 +0800 Subject: [PATCH 07/26] remove usage tracking --- .../emitter/src/code-model-builder.ts | 56 ++++++++----------- 1 file changed, 22 insertions(+), 34 deletions(-) diff --git a/packages/http-client-java/emitter/src/code-model-builder.ts b/packages/http-client-java/emitter/src/code-model-builder.ts index 3e1ff6e15f..8edbad3c46 100644 --- a/packages/http-client-java/emitter/src/code-model-builder.ts +++ b/packages/http-client-java/emitter/src/code-model-builder.ts @@ -1006,10 +1006,6 @@ export class CodeModelBuilder { this.trackSchemaUsage(pollingSchema, { usage: [op.internalApi ? SchemaContext.Internal : SchemaContext.Public], }); - } else { - trackSchemaUsage(pollingSchema, { - usage: [SchemaContext.None] - }); } } if (finalSchema) { @@ -1018,10 +1014,6 @@ export class CodeModelBuilder { this.trackSchemaUsage(finalSchema, { usage: [op.internalApi ? SchemaContext.Internal : SchemaContext.Public], }); - } else { // overwrite the schema usage set by tcgc - trackSchemaUsage(finalSchema, { - usage: [SchemaContext.None] - }); } } @@ -1203,13 +1195,13 @@ export class CodeModelBuilder { clientContext.addGlobalParameter(parameter); } - this.trackSchemaUsage(schema, { usage: [SchemaContext.Input] }); + // this.trackSchemaUsage(schema, { usage: [SchemaContext.Input] }); - if (op.convenienceApi) { - this.trackSchemaUsage(schema, { - usage: [op.internalApi ? SchemaContext.Internal : SchemaContext.Public], - }); - } + // if (op.convenienceApi) { + // this.trackSchemaUsage(schema, { + // usage: [op.internalApi ? SchemaContext.Internal : SchemaContext.Public], + // }); + // } } } @@ -1310,12 +1302,12 @@ export class CodeModelBuilder { }, ); - this.trackSchemaUsage(requestConditionsSchema, { usage: [SchemaContext.Input] }); - if (op.convenienceApi) { - this.trackSchemaUsage(requestConditionsSchema, { - usage: [op.internalApi ? SchemaContext.Internal : SchemaContext.Public], - }); - } + // this.trackSchemaUsage(requestConditionsSchema, { usage: [SchemaContext.Input] }); + // if (op.convenienceApi) { + // this.trackSchemaUsage(requestConditionsSchema, { + // usage: [op.internalApi ? SchemaContext.Internal : SchemaContext.Public], + // }); + // } // update group schema for properties for (const parameter of request.parameters) { @@ -1392,7 +1384,7 @@ export class CodeModelBuilder { // schema instanceof ObjectSchema && // (schema as SchemaUsage).usage?.includes(SchemaContext.Public); - this.trackSchemaUsage(schema, { usage: [SchemaContext.Input] }); + // this.trackSchemaUsage(schema, { usage: [SchemaContext.Input] }); // if (op.convenienceApi) { // // model/schema does not need to be Public or Internal, if it is not to be used in convenience API @@ -1638,10 +1630,10 @@ export class CodeModelBuilder { if (sdkResponse.headers) { for (const header of sdkResponse.headers) { const schema = this.processSchema(header.type, header.serializedName); - // TODO haoling: why header schema do not need usage tracking? no usage tracking for header schema? - trackSchemaUsage(schema, { - usage: [SchemaContext.None] - }); + // // TODO haoling: why header schema do not need usage tracking? no usage tracking for header schema? + // trackSchemaUsage(schema, { + // usage: [SchemaContext.None] + // }); headers.push( new HttpHeader(header.serializedName, schema, { language: { @@ -1746,11 +1738,7 @@ export class CodeModelBuilder { this.trackSchemaUsage(response.schema, { usage: [op.internalApi ? SchemaContext.Internal : SchemaContext.Public], }); - } else { - trackSchemaUsage(response.schema, { - usage: [SchemaContext.None] - }); - } + } } } } @@ -2746,10 +2734,10 @@ export class CodeModelBuilder { // remove internal usages.splice(usages.indexOf(SchemaContext.Internal), 1); } - if (usages && usages.includes(SchemaContext.None)) { - // no usage - (schema as SchemaUsage).usage = []; - } + // if (usages && usages.includes(SchemaContext.None)) { + // // no usage + // (schema as SchemaUsage).usage = []; + // } }; this.codeModel.schemas.choices?.forEach(innerProcessUsage); this.codeModel.schemas.objects?.forEach(innerProcessUsage); From 14bdceb0736c0192cbcafbadc061bbe952fbdace Mon Sep 17 00:00:00 2001 From: Haoling Dong Date: Wed, 9 Oct 2024 13:39:50 +0800 Subject: [PATCH 08/26] do not track usage if it is api version --- packages/http-client-java/emitter/src/type-utils.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/http-client-java/emitter/src/type-utils.ts b/packages/http-client-java/emitter/src/type-utils.ts index 7d1ab61b7e..3577079fea 100644 --- a/packages/http-client-java/emitter/src/type-utils.ts +++ b/packages/http-client-java/emitter/src/type-utils.ts @@ -346,6 +346,10 @@ export function processSchemaUsageFromSdkType(sdkType: SdkModelType | SdkEnumTyp usage = [SchemaContext.Exception]; return usage; } + if (usageFlags & UsageFlags.ApiVersionEnum) { + usage = []; + return usage; + } if (usageFlags & UsageFlags.Input) usage = pushDistinct(usage, SchemaContext.Input); if (usageFlags & UsageFlags.Output) From 00ef14a0cae61bc19bc14e5f62d2716af08d833a Mon Sep 17 00:00:00 2001 From: Haoling Dong Date: Thu, 10 Oct 2024 10:37:14 +0800 Subject: [PATCH 09/26] regen --- .../core/lro/rpc/models/OperationState.java | 75 ++++++++ ...nerationResponseGenerationResultError.java | 152 +++++++++++++++ .../lro/standard/models/OperationState.java | 75 ++++++++ .../standard/models/OperationStatusError.java | 129 +++++++++++++ ...eOperationStatusUserExportedUserError.java | 150 +++++++++++++++ .../traits/models/RepeatabilityResult.java | 59 ++++++ .../java/com/cadl/builtin/models/Builtin.java | 2 +- .../java/com/cadl/builtin/models/Encoded.java | 110 +---------- .../cadl/enumservice/models/Operation.java | 18 +- .../models/ProtocolInternalModel.java | 83 ++++++++ .../models/ModelOptionalLiteral.java | 51 ----- .../PutRequestOptionalLiteralParam.java | 51 ----- .../models/LroOperationStatusError.java | 177 ++++++++++++++++++ .../models/RepeatabilityResult.java | 59 ++++++ ...orMultiContentTypesRequestContentType.java | 63 +++++++ ...orMultiContentTypesRequestContentType.java | 68 +++++++ ...orMultiContentTypesRequestContentType.java | 70 +++++++ .../UploadWithOverloadRequestContentType.java | 71 +++++++ .../models/ResourceC.java | 105 +++++++++++ .../models/ResourceD.java | 105 +++++++++++ .../models/ResourceG.java | 105 +++++++++++ .../models/ResourceH.java | 105 +++++++++++ .../models/RepeatabilityResult.java | 59 ++++++ .../com/cadl/union/models/OperationState.java | 75 ++++++++ ...ationStatusOperationStatusResultError.java | 150 +++++++++++++++ .../versioning/models/OperationState.java | 75 ++++++++ ...onStatusResourceExportedResourceError.java | 151 +++++++++++++++ .../structure/service/models/ClientType.java | 66 +++++++ .../service/models/package-info.java | 18 ++ ...ateSuccessResponseRepeatabilityResult.java | 56 ++++++ .../repeatability/models/package-info.java | 11 ++ .../BooleanLiteralPropertyProperty.java | 49 ----- .../models/FloatLiteralPropertyProperty.java | 49 ----- .../models/IntLiteralPropertyProperty.java | 49 ----- .../models/StringLiteralPropertyProperty.java | 51 ----- ...azure-core-lro-rpc_apiview_properties.json | 4 +- ...-core-lro-standard_apiview_properties.json | 3 + ...-azure-core-traits_apiview_properties.json | 1 + .../cadl-builtin_apiview_properties.json | 4 + .../cadl-internal_apiview_properties.json | 1 + ...adl-literalservice_apiview_properties.json | 4 +- .../cadl-longrunning_apiview_properties.json | 4 +- ...-multicontenttypes_apiview_properties.json | 6 +- ...tocolandconvenient_apiview_properties.json | 4 + ...adl-specialheaders_apiview_properties.json | 1 + .../cadl-union_apiview_properties.json | 2 + .../cadl-versioning_apiview_properties.json | 4 +- ...ders-repeatability_apiview_properties.json | 3 +- ...-property-optional_apiview_properties.json | 4 - 49 files changed, 2352 insertions(+), 435 deletions(-) create mode 100644 packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/lro/rpc/models/OperationState.java create mode 100644 packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/lro/rpc/models/ResourceOperationStatusGenerationResponseGenerationResultError.java create mode 100644 packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/lro/standard/models/OperationState.java create mode 100644 packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/lro/standard/models/OperationStatusError.java create mode 100644 packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/lro/standard/models/ResourceOperationStatusUserExportedUserError.java create mode 100644 packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/traits/models/RepeatabilityResult.java create mode 100644 packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/internal/implementation/models/ProtocolInternalModel.java delete mode 100644 packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/literalservice/models/ModelOptionalLiteral.java delete mode 100644 packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/literalservice/models/PutRequestOptionalLiteralParam.java create mode 100644 packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/longrunning/models/LroOperationStatusError.java create mode 100644 packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/longrunning/models/RepeatabilityResult.java create mode 100644 packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multicontenttypes/models/UploadBytesWithMultiBodyTypesForMultiContentTypesRequestContentType.java create mode 100644 packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multicontenttypes/models/UploadBytesWithSingleBodyTypeForMultiContentTypesRequestContentType.java create mode 100644 packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multicontenttypes/models/UploadJsonOrBytesWithMultiBodyTypesForMultiContentTypesRequestContentType.java create mode 100644 packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multicontenttypes/models/UploadWithOverloadRequestContentType.java create mode 100644 packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/protocolandconvenient/models/ResourceC.java create mode 100644 packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/protocolandconvenient/models/ResourceD.java create mode 100644 packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/protocolandconvenient/models/ResourceG.java create mode 100644 packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/protocolandconvenient/models/ResourceH.java create mode 100644 packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/specialheaders/models/RepeatabilityResult.java create mode 100644 packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/union/models/OperationState.java create mode 100644 packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/union/models/ResourceOperationStatusOperationStatusResultError.java create mode 100644 packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/versioning/models/OperationState.java create mode 100644 packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/versioning/models/ResourceOperationStatusResourceExportedResourceError.java create mode 100644 packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/structure/service/models/ClientType.java create mode 100644 packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/structure/service/models/package-info.java create mode 100644 packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialheaders/repeatability/models/ImmediateSuccessResponseRepeatabilityResult.java create mode 100644 packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialheaders/repeatability/models/package-info.java delete mode 100644 packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/models/BooleanLiteralPropertyProperty.java delete mode 100644 packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/models/FloatLiteralPropertyProperty.java delete mode 100644 packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/models/IntLiteralPropertyProperty.java delete mode 100644 packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/models/StringLiteralPropertyProperty.java diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/lro/rpc/models/OperationState.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/lro/rpc/models/OperationState.java new file mode 100644 index 0000000000..69593dba1f --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/lro/rpc/models/OperationState.java @@ -0,0 +1,75 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com._specs_.azure.core.lro.rpc.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * Enum describing allowed operation states. + */ +public final class OperationState extends ExpandableStringEnum { + /** + * The operation has not started. + */ + @Generated + public static final OperationState NOT_STARTED = fromString("NotStarted"); + + /** + * The operation is in progress. + */ + @Generated + public static final OperationState RUNNING = fromString("Running"); + + /** + * The operation has completed successfully. + */ + @Generated + public static final OperationState SUCCEEDED = fromString("Succeeded"); + + /** + * The operation has failed. + */ + @Generated + public static final OperationState FAILED = fromString("Failed"); + + /** + * The operation has been canceled by the user. + */ + @Generated + public static final OperationState CANCELED = fromString("Canceled"); + + /** + * Creates a new instance of OperationState value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Generated + @Deprecated + public OperationState() { + } + + /** + * Creates or finds a OperationState from its string representation. + * + * @param name a name to look for. + * @return the corresponding OperationState. + */ + @Generated + public static OperationState fromString(String name) { + return fromString(name, OperationState.class); + } + + /** + * Gets known OperationState values. + * + * @return known OperationState values. + */ + @Generated + public static Collection values() { + return values(OperationState.class); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/lro/rpc/models/ResourceOperationStatusGenerationResponseGenerationResultError.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/lro/rpc/models/ResourceOperationStatusGenerationResponseGenerationResultError.java new file mode 100644 index 0000000000..17f485cf69 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/lro/rpc/models/ResourceOperationStatusGenerationResponseGenerationResultError.java @@ -0,0 +1,152 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com._specs_.azure.core.lro.rpc.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.core.models.ResponseError; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * Provides status details for long running operations. + */ +@Immutable +public final class ResourceOperationStatusGenerationResponseGenerationResultError + implements JsonSerializable { + /* + * The unique ID of the operation. + */ + @Generated + private String id; + + /* + * The status of the operation + */ + @Generated + private final OperationState status; + + /* + * Error object that describes the error when status is "Failed". + */ + @Generated + private ResponseError error; + + /* + * The result of the operation. + */ + @Generated + private GenerationResult result; + + /** + * Creates an instance of ResourceOperationStatusGenerationResponseGenerationResultError class. + * + * @param status the status value to set. + */ + @Generated + private ResourceOperationStatusGenerationResponseGenerationResultError(OperationState status) { + this.status = status; + } + + /** + * Get the id property: The unique ID of the operation. + * + * @return the id value. + */ + @Generated + public String getId() { + return this.id; + } + + /** + * Get the status property: The status of the operation. + * + * @return the status value. + */ + @Generated + public OperationState getStatus() { + return this.status; + } + + /** + * Get the error property: Error object that describes the error when status is "Failed". + * + * @return the error value. + */ + @Generated + public ResponseError getError() { + return this.error; + } + + /** + * Get the result property: The result of the operation. + * + * @return the result value. + */ + @Generated + public GenerationResult getResult() { + return this.result; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("status", this.status == null ? null : this.status.toString()); + jsonWriter.writeJsonField("error", this.error); + jsonWriter.writeJsonField("result", this.result); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ResourceOperationStatusGenerationResponseGenerationResultError from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ResourceOperationStatusGenerationResponseGenerationResultError if the JsonReader was + * pointing to an instance of it, or null if it was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the + * ResourceOperationStatusGenerationResponseGenerationResultError. + */ + @Generated + public static ResourceOperationStatusGenerationResponseGenerationResultError fromJson(JsonReader jsonReader) + throws IOException { + return jsonReader.readObject(reader -> { + String id = null; + OperationState status = null; + ResponseError error = null; + GenerationResult result = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("id".equals(fieldName)) { + id = reader.getString(); + } else if ("status".equals(fieldName)) { + status = OperationState.fromString(reader.getString()); + } else if ("error".equals(fieldName)) { + error = ResponseError.fromJson(reader); + } else if ("result".equals(fieldName)) { + result = GenerationResult.fromJson(reader); + } else { + reader.skipChildren(); + } + } + ResourceOperationStatusGenerationResponseGenerationResultError deserializedResourceOperationStatusGenerationResponseGenerationResultError + = new ResourceOperationStatusGenerationResponseGenerationResultError(status); + deserializedResourceOperationStatusGenerationResponseGenerationResultError.id = id; + deserializedResourceOperationStatusGenerationResponseGenerationResultError.error = error; + deserializedResourceOperationStatusGenerationResponseGenerationResultError.result = result; + + return deserializedResourceOperationStatusGenerationResponseGenerationResultError; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/lro/standard/models/OperationState.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/lro/standard/models/OperationState.java new file mode 100644 index 0000000000..070ef6faa2 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/lro/standard/models/OperationState.java @@ -0,0 +1,75 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com._specs_.azure.core.lro.standard.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * Enum describing allowed operation states. + */ +public final class OperationState extends ExpandableStringEnum { + /** + * The operation has not started. + */ + @Generated + public static final OperationState NOT_STARTED = fromString("NotStarted"); + + /** + * The operation is in progress. + */ + @Generated + public static final OperationState RUNNING = fromString("Running"); + + /** + * The operation has completed successfully. + */ + @Generated + public static final OperationState SUCCEEDED = fromString("Succeeded"); + + /** + * The operation has failed. + */ + @Generated + public static final OperationState FAILED = fromString("Failed"); + + /** + * The operation has been canceled by the user. + */ + @Generated + public static final OperationState CANCELED = fromString("Canceled"); + + /** + * Creates a new instance of OperationState value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Generated + @Deprecated + public OperationState() { + } + + /** + * Creates or finds a OperationState from its string representation. + * + * @param name a name to look for. + * @return the corresponding OperationState. + */ + @Generated + public static OperationState fromString(String name) { + return fromString(name, OperationState.class); + } + + /** + * Gets known OperationState values. + * + * @return known OperationState values. + */ + @Generated + public static Collection values() { + return values(OperationState.class); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/lro/standard/models/OperationStatusError.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/lro/standard/models/OperationStatusError.java new file mode 100644 index 0000000000..6683d6e3ab --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/lro/standard/models/OperationStatusError.java @@ -0,0 +1,129 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com._specs_.azure.core.lro.standard.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.core.models.ResponseError; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * Provides status details for long running operations. + */ +@Immutable +public final class OperationStatusError implements JsonSerializable { + /* + * The unique ID of the operation. + */ + @Generated + private final String id; + + /* + * The status of the operation + */ + @Generated + private final OperationState status; + + /* + * Error object that describes the error when status is "Failed". + */ + @Generated + private ResponseError error; + + /** + * Creates an instance of OperationStatusError class. + * + * @param id the id value to set. + * @param status the status value to set. + */ + @Generated + private OperationStatusError(String id, OperationState status) { + this.id = id; + this.status = status; + } + + /** + * Get the id property: The unique ID of the operation. + * + * @return the id value. + */ + @Generated + public String getId() { + return this.id; + } + + /** + * Get the status property: The status of the operation. + * + * @return the status value. + */ + @Generated + public OperationState getStatus() { + return this.status; + } + + /** + * Get the error property: Error object that describes the error when status is "Failed". + * + * @return the error value. + */ + @Generated + public ResponseError getError() { + return this.error; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("id", this.id); + jsonWriter.writeStringField("status", this.status == null ? null : this.status.toString()); + jsonWriter.writeJsonField("error", this.error); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of OperationStatusError from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of OperationStatusError if the JsonReader was pointing to an instance of it, or null if it + * was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the OperationStatusError. + */ + @Generated + public static OperationStatusError fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String id = null; + OperationState status = null; + ResponseError error = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("id".equals(fieldName)) { + id = reader.getString(); + } else if ("status".equals(fieldName)) { + status = OperationState.fromString(reader.getString()); + } else if ("error".equals(fieldName)) { + error = ResponseError.fromJson(reader); + } else { + reader.skipChildren(); + } + } + OperationStatusError deserializedOperationStatusError = new OperationStatusError(id, status); + deserializedOperationStatusError.error = error; + + return deserializedOperationStatusError; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/lro/standard/models/ResourceOperationStatusUserExportedUserError.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/lro/standard/models/ResourceOperationStatusUserExportedUserError.java new file mode 100644 index 0000000000..f93bd09a87 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/lro/standard/models/ResourceOperationStatusUserExportedUserError.java @@ -0,0 +1,150 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com._specs_.azure.core.lro.standard.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.core.models.ResponseError; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * Provides status details for long running operations. + */ +@Immutable +public final class ResourceOperationStatusUserExportedUserError + implements JsonSerializable { + /* + * The unique ID of the operation. + */ + @Generated + private String id; + + /* + * The status of the operation + */ + @Generated + private final OperationState status; + + /* + * Error object that describes the error when status is "Failed". + */ + @Generated + private ResponseError error; + + /* + * The result of the operation. + */ + @Generated + private ExportedUser result; + + /** + * Creates an instance of ResourceOperationStatusUserExportedUserError class. + * + * @param status the status value to set. + */ + @Generated + private ResourceOperationStatusUserExportedUserError(OperationState status) { + this.status = status; + } + + /** + * Get the id property: The unique ID of the operation. + * + * @return the id value. + */ + @Generated + public String getId() { + return this.id; + } + + /** + * Get the status property: The status of the operation. + * + * @return the status value. + */ + @Generated + public OperationState getStatus() { + return this.status; + } + + /** + * Get the error property: Error object that describes the error when status is "Failed". + * + * @return the error value. + */ + @Generated + public ResponseError getError() { + return this.error; + } + + /** + * Get the result property: The result of the operation. + * + * @return the result value. + */ + @Generated + public ExportedUser getResult() { + return this.result; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("status", this.status == null ? null : this.status.toString()); + jsonWriter.writeJsonField("error", this.error); + jsonWriter.writeJsonField("result", this.result); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ResourceOperationStatusUserExportedUserError from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ResourceOperationStatusUserExportedUserError if the JsonReader was pointing to an instance + * of it, or null if it was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the ResourceOperationStatusUserExportedUserError. + */ + @Generated + public static ResourceOperationStatusUserExportedUserError fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String id = null; + OperationState status = null; + ResponseError error = null; + ExportedUser result = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("id".equals(fieldName)) { + id = reader.getString(); + } else if ("status".equals(fieldName)) { + status = OperationState.fromString(reader.getString()); + } else if ("error".equals(fieldName)) { + error = ResponseError.fromJson(reader); + } else if ("result".equals(fieldName)) { + result = ExportedUser.fromJson(reader); + } else { + reader.skipChildren(); + } + } + ResourceOperationStatusUserExportedUserError deserializedResourceOperationStatusUserExportedUserError + = new ResourceOperationStatusUserExportedUserError(status); + deserializedResourceOperationStatusUserExportedUserError.id = id; + deserializedResourceOperationStatusUserExportedUserError.error = error; + deserializedResourceOperationStatusUserExportedUserError.result = result; + + return deserializedResourceOperationStatusUserExportedUserError; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/traits/models/RepeatabilityResult.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/traits/models/RepeatabilityResult.java new file mode 100644 index 0000000000..7fac135832 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/traits/models/RepeatabilityResult.java @@ -0,0 +1,59 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com._specs_.azure.core.traits.models; + +/** + * Repeatability Result header options. + */ +public enum RepeatabilityResult { + /** + * If the request was accepted and the server guarantees that the server state reflects a single execution of the + * operation. + */ + ACCEPTED("accepted"), + + /** + * If the request was rejected because the combination of Repeatability-First-Sent and Repeatability-Request-ID were + * invalid + * or because the Repeatability-First-Sent value was outside the range of values held by the server. + */ + REJECTED("rejected"); + + /** + * The actual serialized value for a RepeatabilityResult instance. + */ + private final String value; + + RepeatabilityResult(String value) { + this.value = value; + } + + /** + * Parses a serialized value to a RepeatabilityResult instance. + * + * @param value the serialized value to parse. + * @return the parsed RepeatabilityResult object, or null if unable to parse. + */ + public static RepeatabilityResult fromString(String value) { + if (value == null) { + return null; + } + RepeatabilityResult[] items = RepeatabilityResult.values(); + for (RepeatabilityResult item : items) { + if (item.toString().equalsIgnoreCase(value)) { + return item; + } + } + return null; + } + + /** + * {@inheritDoc} + */ + @Override + public String toString() { + return this.value; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/builtin/models/Builtin.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/builtin/models/Builtin.java index 31f5db273d..7eca22d0ec 100644 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/builtin/models/Builtin.java +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/builtin/models/Builtin.java @@ -150,7 +150,7 @@ public final class Builtin implements JsonSerializable { * @param encoded the encoded value to set. */ @Generated - public Builtin(boolean booleanProperty, String string, byte[] bytes, int intProperty, long safeint, + private Builtin(boolean booleanProperty, String string, byte[] bytes, int intProperty, long safeint, BigDecimal decimal, long longProperty, double floatProperty, double doubleProperty, Duration duration, LocalDate date, OffsetDateTime dateTime, List stringList, Map bytesDict, String url, Map nullableFloatDict, Encoded encoded) { diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/builtin/models/Encoded.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/builtin/models/Encoded.java index ec6c81b648..24fb0bee0c 100644 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/builtin/models/Encoded.java +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/builtin/models/Encoded.java @@ -4,8 +4,8 @@ package com.cadl.builtin.models; -import com.azure.core.annotation.Fluent; import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; import com.azure.core.util.Base64Url; import com.azure.core.util.CoreUtils; import com.azure.core.util.DateTimeRfc1123; @@ -24,7 +24,7 @@ /** * The Encoded model. */ -@Fluent +@Immutable public final class Encoded implements JsonSerializable { /* * The timeInSeconds property. @@ -72,7 +72,7 @@ public final class Encoded implements JsonSerializable { * Creates an instance of Encoded class. */ @Generated - public Encoded() { + private Encoded() { } /** @@ -88,22 +88,6 @@ public Duration getTimeInSeconds() { return Duration.ofSeconds(this.timeInSeconds); } - /** - * Set the timeInSeconds property: The timeInSeconds property. - * - * @param timeInSeconds the timeInSeconds value to set. - * @return the Encoded object itself. - */ - @Generated - public Encoded setTimeInSeconds(Duration timeInSeconds) { - if (timeInSeconds == null) { - this.timeInSeconds = null; - } else { - this.timeInSeconds = timeInSeconds.getSeconds(); - } - return this; - } - /** * Get the timeInSecondsFraction property: The timeInSecondsFraction property. * @@ -117,22 +101,6 @@ public Duration getTimeInSecondsFraction() { return Duration.ofNanos((long) (this.timeInSecondsFraction * 1000_000_000L)); } - /** - * Set the timeInSecondsFraction property: The timeInSecondsFraction property. - * - * @param timeInSecondsFraction the timeInSecondsFraction value to set. - * @return the Encoded object itself. - */ - @Generated - public Encoded setTimeInSecondsFraction(Duration timeInSecondsFraction) { - if (timeInSecondsFraction == null) { - this.timeInSecondsFraction = null; - } else { - this.timeInSecondsFraction = (double) timeInSecondsFraction.toNanos() / 1000_000_000L; - } - return this; - } - /** * Get the dateTime property: The dateTime property. * @@ -143,18 +111,6 @@ public OffsetDateTime getDateTime() { return this.dateTime; } - /** - * Set the dateTime property: The dateTime property. - * - * @param dateTime the dateTime value to set. - * @return the Encoded object itself. - */ - @Generated - public Encoded setDateTime(OffsetDateTime dateTime) { - this.dateTime = dateTime; - return this; - } - /** * Get the dateTimeRfc7231 property: The dateTimeRfc7231 property. * @@ -168,22 +124,6 @@ public OffsetDateTime getDateTimeRfc7231() { return this.dateTimeRfc7231.getDateTime(); } - /** - * Set the dateTimeRfc7231 property: The dateTimeRfc7231 property. - * - * @param dateTimeRfc7231 the dateTimeRfc7231 value to set. - * @return the Encoded object itself. - */ - @Generated - public Encoded setDateTimeRfc7231(OffsetDateTime dateTimeRfc7231) { - if (dateTimeRfc7231 == null) { - this.dateTimeRfc7231 = null; - } else { - this.dateTimeRfc7231 = new DateTimeRfc1123(dateTimeRfc7231); - } - return this; - } - /** * Get the unixTimestamp property: The unixTimestamp property. * @@ -197,22 +137,6 @@ public OffsetDateTime getUnixTimestamp() { return OffsetDateTime.ofInstant(Instant.ofEpochSecond(this.unixTimestamp), ZoneOffset.UTC); } - /** - * Set the unixTimestamp property: The unixTimestamp property. - * - * @param unixTimestamp the unixTimestamp value to set. - * @return the Encoded object itself. - */ - @Generated - public Encoded setUnixTimestamp(OffsetDateTime unixTimestamp) { - if (unixTimestamp == null) { - this.unixTimestamp = null; - } else { - this.unixTimestamp = unixTimestamp.toEpochSecond(); - } - return this; - } - /** * Get the base64 property: The base64 property. * @@ -223,18 +147,6 @@ public byte[] getBase64() { return CoreUtils.clone(this.base64); } - /** - * Set the base64 property: The base64 property. - * - * @param base64 the base64 value to set. - * @return the Encoded object itself. - */ - @Generated - public Encoded setBase64(byte[] base64) { - this.base64 = CoreUtils.clone(base64); - return this; - } - /** * Get the base64url property: The base64url property. * @@ -248,22 +160,6 @@ public byte[] getBase64url() { return this.base64url.decodedBytes(); } - /** - * Set the base64url property: The base64url property. - * - * @param base64url the base64url value to set. - * @return the Encoded object itself. - */ - @Generated - public Encoded setBase64url(byte[] base64url) { - if (base64url == null) { - this.base64url = null; - } else { - this.base64url = Base64Url.encode(CoreUtils.clone(base64url)); - } - return this; - } - /** * {@inheritDoc} */ diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/enumservice/models/Operation.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/enumservice/models/Operation.java index ccadb18682..804ec21d2c 100644 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/enumservice/models/Operation.java +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/enumservice/models/Operation.java @@ -4,8 +4,8 @@ package com.cadl.enumservice.models; -import com.azure.core.annotation.Fluent; import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; import com.azure.json.JsonReader; import com.azure.json.JsonSerializable; import com.azure.json.JsonToken; @@ -15,7 +15,7 @@ /** * The Operation model. */ -@Fluent +@Immutable public final class Operation implements JsonSerializable { /* * The name property. @@ -86,7 +86,7 @@ public final class Operation implements JsonSerializable { * @param unit the unit value to set. */ @Generated - public Operation(OperationName name, Priority priority, ColorModel color, Unit unit) { + private Operation(OperationName name, Priority priority, ColorModel color, Unit unit) { this.name = name; this.priority = priority; this.color = color; @@ -193,18 +193,6 @@ public Unit getUnitValue() { return this.unitValue; } - /** - * Set the unitValue property: The unitValue property. - * - * @param unitValue the unitValue value to set. - * @return the Operation object itself. - */ - @Generated - public Operation setUnitValue(Unit unitValue) { - this.unitValue = unitValue; - return this; - } - /** * {@inheritDoc} */ diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/internal/implementation/models/ProtocolInternalModel.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/internal/implementation/models/ProtocolInternalModel.java new file mode 100644 index 0000000000..2d59ca0374 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/internal/implementation/models/ProtocolInternalModel.java @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.internal.implementation.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * The ProtocolInternalModel model. + */ +@Immutable +public final class ProtocolInternalModel implements JsonSerializable { + /* + * The name property. + */ + @Generated + private final String name; + + /** + * Creates an instance of ProtocolInternalModel class. + * + * @param name the name value to set. + */ + @Generated + public ProtocolInternalModel(String name) { + this.name = name; + } + + /** + * Get the name property: The name property. + * + * @return the name value. + */ + @Generated + public String getName() { + return this.name; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ProtocolInternalModel from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ProtocolInternalModel if the JsonReader was pointing to an instance of it, or null if it + * was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the ProtocolInternalModel. + */ + @Generated + public static ProtocolInternalModel fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String name = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + name = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new ProtocolInternalModel(name); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/literalservice/models/ModelOptionalLiteral.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/literalservice/models/ModelOptionalLiteral.java deleted file mode 100644 index d91cb650df..0000000000 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/literalservice/models/ModelOptionalLiteral.java +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) TypeSpec Code Generator. - -package com.cadl.literalservice.models; - -/** - * Defines values for ModelOptionalLiteral. - */ -public enum ModelOptionalLiteral { - /** - * Enum value optionalLiteral. - */ - OPTIONAL_LITERAL("optionalLiteral"); - - /** - * The actual serialized value for a ModelOptionalLiteral instance. - */ - private final String value; - - ModelOptionalLiteral(String value) { - this.value = value; - } - - /** - * Parses a serialized value to a ModelOptionalLiteral instance. - * - * @param value the serialized value to parse. - * @return the parsed ModelOptionalLiteral object, or null if unable to parse. - */ - public static ModelOptionalLiteral fromString(String value) { - if (value == null) { - return null; - } - ModelOptionalLiteral[] items = ModelOptionalLiteral.values(); - for (ModelOptionalLiteral item : items) { - if (item.toString().equalsIgnoreCase(value)) { - return item; - } - } - return null; - } - - /** - * {@inheritDoc} - */ - @Override - public String toString() { - return this.value; - } -} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/literalservice/models/PutRequestOptionalLiteralParam.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/literalservice/models/PutRequestOptionalLiteralParam.java deleted file mode 100644 index f0141ba725..0000000000 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/literalservice/models/PutRequestOptionalLiteralParam.java +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) TypeSpec Code Generator. - -package com.cadl.literalservice.models; - -/** - * Defines values for PutRequestOptionalLiteralParam. - */ -public enum PutRequestOptionalLiteralParam { - /** - * Enum value optionalLiteralParam. - */ - OPTIONAL_LITERAL_PARAM("optionalLiteralParam"); - - /** - * The actual serialized value for a PutRequestOptionalLiteralParam instance. - */ - private final String value; - - PutRequestOptionalLiteralParam(String value) { - this.value = value; - } - - /** - * Parses a serialized value to a PutRequestOptionalLiteralParam instance. - * - * @param value the serialized value to parse. - * @return the parsed PutRequestOptionalLiteralParam object, or null if unable to parse. - */ - public static PutRequestOptionalLiteralParam fromString(String value) { - if (value == null) { - return null; - } - PutRequestOptionalLiteralParam[] items = PutRequestOptionalLiteralParam.values(); - for (PutRequestOptionalLiteralParam item : items) { - if (item.toString().equalsIgnoreCase(value)) { - return item; - } - } - return null; - } - - /** - * {@inheritDoc} - */ - @Override - public String toString() { - return this.value; - } -} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/longrunning/models/LroOperationStatusError.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/longrunning/models/LroOperationStatusError.java new file mode 100644 index 0000000000..6604299687 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/longrunning/models/LroOperationStatusError.java @@ -0,0 +1,177 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.longrunning.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.core.models.ResponseError; +import com.azure.core.util.CoreUtils; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.time.OffsetDateTime; + +/** + * The LroOperationStatusError model. + */ +@Immutable +public final class LroOperationStatusError implements JsonSerializable { + /* + * The id property. + */ + @Generated + private String id; + + /* + * The status property. + */ + @Generated + private JobStatus status; + + /* + * The createdDateTime property. + */ + @Generated + private OffsetDateTime createdDateTime; + + /* + * The expirationDateTime property. + */ + @Generated + private OffsetDateTime expirationDateTime; + + /* + * The lastUpdateDateTime property. + */ + @Generated + private OffsetDateTime lastUpdateDateTime; + + /* + * The error property. + */ + @Generated + private ResponseError error; + + /** + * Creates an instance of LroOperationStatusError class. + */ + @Generated + private LroOperationStatusError() { + } + + /** + * Get the id property: The id property. + * + * @return the id value. + */ + @Generated + public String getId() { + return this.id; + } + + /** + * Get the status property: The status property. + * + * @return the status value. + */ + @Generated + public JobStatus getStatus() { + return this.status; + } + + /** + * Get the createdDateTime property: The createdDateTime property. + * + * @return the createdDateTime value. + */ + @Generated + public OffsetDateTime getCreatedDateTime() { + return this.createdDateTime; + } + + /** + * Get the expirationDateTime property: The expirationDateTime property. + * + * @return the expirationDateTime value. + */ + @Generated + public OffsetDateTime getExpirationDateTime() { + return this.expirationDateTime; + } + + /** + * Get the lastUpdateDateTime property: The lastUpdateDateTime property. + * + * @return the lastUpdateDateTime value. + */ + @Generated + public OffsetDateTime getLastUpdateDateTime() { + return this.lastUpdateDateTime; + } + + /** + * Get the error property: The error property. + * + * @return the error value. + */ + @Generated + public ResponseError getError() { + return this.error; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeJsonField("error", this.error); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of LroOperationStatusError from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of LroOperationStatusError if the JsonReader was pointing to an instance of it, or null if it + * was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the LroOperationStatusError. + */ + @Generated + public static LroOperationStatusError fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + LroOperationStatusError deserializedLroOperationStatusError = new LroOperationStatusError(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("id".equals(fieldName)) { + deserializedLroOperationStatusError.id = reader.getString(); + } else if ("status".equals(fieldName)) { + deserializedLroOperationStatusError.status = JobStatus.fromString(reader.getString()); + } else if ("createdDateTime".equals(fieldName)) { + deserializedLroOperationStatusError.createdDateTime = reader + .getNullable(nonNullReader -> CoreUtils.parseBestOffsetDateTime(nonNullReader.getString())); + } else if ("expirationDateTime".equals(fieldName)) { + deserializedLroOperationStatusError.expirationDateTime = reader + .getNullable(nonNullReader -> CoreUtils.parseBestOffsetDateTime(nonNullReader.getString())); + } else if ("lastUpdateDateTime".equals(fieldName)) { + deserializedLroOperationStatusError.lastUpdateDateTime = reader + .getNullable(nonNullReader -> CoreUtils.parseBestOffsetDateTime(nonNullReader.getString())); + } else if ("error".equals(fieldName)) { + deserializedLroOperationStatusError.error = ResponseError.fromJson(reader); + } else { + reader.skipChildren(); + } + } + + return deserializedLroOperationStatusError; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/longrunning/models/RepeatabilityResult.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/longrunning/models/RepeatabilityResult.java new file mode 100644 index 0000000000..2e5e4d3d91 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/longrunning/models/RepeatabilityResult.java @@ -0,0 +1,59 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.longrunning.models; + +/** + * Repeatability Result header options. + */ +public enum RepeatabilityResult { + /** + * If the request was accepted and the server guarantees that the server state reflects a single execution of the + * operation. + */ + ACCEPTED("accepted"), + + /** + * If the request was rejected because the combination of Repeatability-First-Sent and Repeatability-Request-ID were + * invalid + * or because the Repeatability-First-Sent value was outside the range of values held by the server. + */ + REJECTED("rejected"); + + /** + * The actual serialized value for a RepeatabilityResult instance. + */ + private final String value; + + RepeatabilityResult(String value) { + this.value = value; + } + + /** + * Parses a serialized value to a RepeatabilityResult instance. + * + * @param value the serialized value to parse. + * @return the parsed RepeatabilityResult object, or null if unable to parse. + */ + public static RepeatabilityResult fromString(String value) { + if (value == null) { + return null; + } + RepeatabilityResult[] items = RepeatabilityResult.values(); + for (RepeatabilityResult item : items) { + if (item.toString().equalsIgnoreCase(value)) { + return item; + } + } + return null; + } + + /** + * {@inheritDoc} + */ + @Override + public String toString() { + return this.value; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multicontenttypes/models/UploadBytesWithMultiBodyTypesForMultiContentTypesRequestContentType.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multicontenttypes/models/UploadBytesWithMultiBodyTypesForMultiContentTypesRequestContentType.java new file mode 100644 index 0000000000..1e80e500aa --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multicontenttypes/models/UploadBytesWithMultiBodyTypesForMultiContentTypesRequestContentType.java @@ -0,0 +1,63 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.multicontenttypes.models; + +/** + * Defines values for UploadBytesWithMultiBodyTypesForMultiContentTypesRequestContentType. + */ +public enum UploadBytesWithMultiBodyTypesForMultiContentTypesRequestContentType { + /** + * Enum value application/octet-stream. + */ + APPLICATION_OCTET_STREAM("application/octet-stream"), + + /** + * Enum value image/jpeg. + */ + IMAGE_JPEG("image/jpeg"), + + /** + * Enum value image/png. + */ + IMAGE_PNG("image/png"); + + /** + * The actual serialized value for a UploadBytesWithMultiBodyTypesForMultiContentTypesRequestContentType instance. + */ + private final String value; + + UploadBytesWithMultiBodyTypesForMultiContentTypesRequestContentType(String value) { + this.value = value; + } + + /** + * Parses a serialized value to a UploadBytesWithMultiBodyTypesForMultiContentTypesRequestContentType instance. + * + * @param value the serialized value to parse. + * @return the parsed UploadBytesWithMultiBodyTypesForMultiContentTypesRequestContentType object, or null if unable + * to parse. + */ + public static UploadBytesWithMultiBodyTypesForMultiContentTypesRequestContentType fromString(String value) { + if (value == null) { + return null; + } + UploadBytesWithMultiBodyTypesForMultiContentTypesRequestContentType[] items + = UploadBytesWithMultiBodyTypesForMultiContentTypesRequestContentType.values(); + for (UploadBytesWithMultiBodyTypesForMultiContentTypesRequestContentType item : items) { + if (item.toString().equalsIgnoreCase(value)) { + return item; + } + } + return null; + } + + /** + * {@inheritDoc} + */ + @Override + public String toString() { + return this.value; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multicontenttypes/models/UploadBytesWithSingleBodyTypeForMultiContentTypesRequestContentType.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multicontenttypes/models/UploadBytesWithSingleBodyTypeForMultiContentTypesRequestContentType.java new file mode 100644 index 0000000000..f61569a68c --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multicontenttypes/models/UploadBytesWithSingleBodyTypeForMultiContentTypesRequestContentType.java @@ -0,0 +1,68 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.multicontenttypes.models; + +/** + * Defines values for UploadBytesWithSingleBodyTypeForMultiContentTypesRequestContentType. + */ +public enum UploadBytesWithSingleBodyTypeForMultiContentTypesRequestContentType { + /** + * Enum value application/octet-stream. + */ + APPLICATION_OCTET_STREAM("application/octet-stream"), + + /** + * Enum value image/jpeg. + */ + IMAGE_JPEG("image/jpeg"), + + /** + * Enum value image/png. + */ + IMAGE_PNG("image/png"), + + /** + * Enum value application/json-patch+json. + */ + APPLICATION_JSON_PATCH_JSON("application/json-patch+json"); + + /** + * The actual serialized value for a UploadBytesWithSingleBodyTypeForMultiContentTypesRequestContentType instance. + */ + private final String value; + + UploadBytesWithSingleBodyTypeForMultiContentTypesRequestContentType(String value) { + this.value = value; + } + + /** + * Parses a serialized value to a UploadBytesWithSingleBodyTypeForMultiContentTypesRequestContentType instance. + * + * @param value the serialized value to parse. + * @return the parsed UploadBytesWithSingleBodyTypeForMultiContentTypesRequestContentType object, or null if unable + * to parse. + */ + public static UploadBytesWithSingleBodyTypeForMultiContentTypesRequestContentType fromString(String value) { + if (value == null) { + return null; + } + UploadBytesWithSingleBodyTypeForMultiContentTypesRequestContentType[] items + = UploadBytesWithSingleBodyTypeForMultiContentTypesRequestContentType.values(); + for (UploadBytesWithSingleBodyTypeForMultiContentTypesRequestContentType item : items) { + if (item.toString().equalsIgnoreCase(value)) { + return item; + } + } + return null; + } + + /** + * {@inheritDoc} + */ + @Override + public String toString() { + return this.value; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multicontenttypes/models/UploadJsonOrBytesWithMultiBodyTypesForMultiContentTypesRequestContentType.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multicontenttypes/models/UploadJsonOrBytesWithMultiBodyTypesForMultiContentTypesRequestContentType.java new file mode 100644 index 0000000000..a1210715ed --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multicontenttypes/models/UploadJsonOrBytesWithMultiBodyTypesForMultiContentTypesRequestContentType.java @@ -0,0 +1,70 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.multicontenttypes.models; + +/** + * Defines values for UploadJsonOrBytesWithMultiBodyTypesForMultiContentTypesRequestContentType. + */ +public enum UploadJsonOrBytesWithMultiBodyTypesForMultiContentTypesRequestContentType { + /** + * Enum value application/json. + */ + APPLICATION_JSON("application/json"), + + /** + * Enum value application/octet-stream. + */ + APPLICATION_OCTET_STREAM("application/octet-stream"), + + /** + * Enum value image/jpeg. + */ + IMAGE_JPEG("image/jpeg"), + + /** + * Enum value image/png. + */ + IMAGE_PNG("image/png"); + + /** + * The actual serialized value for a UploadJsonOrBytesWithMultiBodyTypesForMultiContentTypesRequestContentType + * instance. + */ + private final String value; + + UploadJsonOrBytesWithMultiBodyTypesForMultiContentTypesRequestContentType(String value) { + this.value = value; + } + + /** + * Parses a serialized value to a UploadJsonOrBytesWithMultiBodyTypesForMultiContentTypesRequestContentType + * instance. + * + * @param value the serialized value to parse. + * @return the parsed UploadJsonOrBytesWithMultiBodyTypesForMultiContentTypesRequestContentType object, or null if + * unable to parse. + */ + public static UploadJsonOrBytesWithMultiBodyTypesForMultiContentTypesRequestContentType fromString(String value) { + if (value == null) { + return null; + } + UploadJsonOrBytesWithMultiBodyTypesForMultiContentTypesRequestContentType[] items + = UploadJsonOrBytesWithMultiBodyTypesForMultiContentTypesRequestContentType.values(); + for (UploadJsonOrBytesWithMultiBodyTypesForMultiContentTypesRequestContentType item : items) { + if (item.toString().equalsIgnoreCase(value)) { + return item; + } + } + return null; + } + + /** + * {@inheritDoc} + */ + @Override + public String toString() { + return this.value; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multicontenttypes/models/UploadWithOverloadRequestContentType.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multicontenttypes/models/UploadWithOverloadRequestContentType.java new file mode 100644 index 0000000000..e5f877f5da --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multicontenttypes/models/UploadWithOverloadRequestContentType.java @@ -0,0 +1,71 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.multicontenttypes.models; + +/** + * Defines values for UploadWithOverloadRequestContentType. + */ +public enum UploadWithOverloadRequestContentType { + /** + * Enum value text/plain. + */ + TEXT_PLAIN("text/plain"), + + /** + * Enum value application/json. + */ + APPLICATION_JSON("application/json"), + + /** + * Enum value application/octet-stream. + */ + APPLICATION_OCTET_STREAM("application/octet-stream"), + + /** + * Enum value image/jpeg. + */ + IMAGE_JPEG("image/jpeg"), + + /** + * Enum value image/png. + */ + IMAGE_PNG("image/png"); + + /** + * The actual serialized value for a UploadWithOverloadRequestContentType instance. + */ + private final String value; + + UploadWithOverloadRequestContentType(String value) { + this.value = value; + } + + /** + * Parses a serialized value to a UploadWithOverloadRequestContentType instance. + * + * @param value the serialized value to parse. + * @return the parsed UploadWithOverloadRequestContentType object, or null if unable to parse. + */ + public static UploadWithOverloadRequestContentType fromString(String value) { + if (value == null) { + return null; + } + UploadWithOverloadRequestContentType[] items = UploadWithOverloadRequestContentType.values(); + for (UploadWithOverloadRequestContentType item : items) { + if (item.toString().equalsIgnoreCase(value)) { + return item; + } + } + return null; + } + + /** + * {@inheritDoc} + */ + @Override + public String toString() { + return this.value; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/protocolandconvenient/models/ResourceC.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/protocolandconvenient/models/ResourceC.java new file mode 100644 index 0000000000..c5a926a591 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/protocolandconvenient/models/ResourceC.java @@ -0,0 +1,105 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.protocolandconvenient.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * The ResourceC model. + */ +@Immutable +public final class ResourceC implements JsonSerializable { + /* + * The id property. + */ + @Generated + private String id; + + /* + * The name property. + */ + @Generated + private final String name; + + /** + * Creates an instance of ResourceC class. + * + * @param name the name value to set. + */ + @Generated + public ResourceC(String name) { + this.name = name; + } + + /** + * Get the id property: The id property. + * + * @return the id value. + */ + @Generated + public String getId() { + return this.id; + } + + /** + * Get the name property: The name property. + * + * @return the name value. + */ + @Generated + public String getName() { + return this.name; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ResourceC from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ResourceC if the JsonReader was pointing to an instance of it, or null if it was pointing + * to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the ResourceC. + */ + @Generated + public static ResourceC fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String id = null; + String name = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("id".equals(fieldName)) { + id = reader.getString(); + } else if ("name".equals(fieldName)) { + name = reader.getString(); + } else { + reader.skipChildren(); + } + } + ResourceC deserializedResourceC = new ResourceC(name); + deserializedResourceC.id = id; + + return deserializedResourceC; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/protocolandconvenient/models/ResourceD.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/protocolandconvenient/models/ResourceD.java new file mode 100644 index 0000000000..bbc7615781 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/protocolandconvenient/models/ResourceD.java @@ -0,0 +1,105 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.protocolandconvenient.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * The ResourceD model. + */ +@Immutable +public final class ResourceD implements JsonSerializable { + /* + * The id property. + */ + @Generated + private String id; + + /* + * The name property. + */ + @Generated + private final String name; + + /** + * Creates an instance of ResourceD class. + * + * @param name the name value to set. + */ + @Generated + private ResourceD(String name) { + this.name = name; + } + + /** + * Get the id property: The id property. + * + * @return the id value. + */ + @Generated + public String getId() { + return this.id; + } + + /** + * Get the name property: The name property. + * + * @return the name value. + */ + @Generated + public String getName() { + return this.name; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ResourceD from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ResourceD if the JsonReader was pointing to an instance of it, or null if it was pointing + * to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the ResourceD. + */ + @Generated + public static ResourceD fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String id = null; + String name = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("id".equals(fieldName)) { + id = reader.getString(); + } else if ("name".equals(fieldName)) { + name = reader.getString(); + } else { + reader.skipChildren(); + } + } + ResourceD deserializedResourceD = new ResourceD(name); + deserializedResourceD.id = id; + + return deserializedResourceD; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/protocolandconvenient/models/ResourceG.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/protocolandconvenient/models/ResourceG.java new file mode 100644 index 0000000000..552bcf8d04 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/protocolandconvenient/models/ResourceG.java @@ -0,0 +1,105 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.protocolandconvenient.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * The ResourceG model. + */ +@Immutable +public final class ResourceG implements JsonSerializable { + /* + * The id property. + */ + @Generated + private String id; + + /* + * The name property. + */ + @Generated + private final String name; + + /** + * Creates an instance of ResourceG class. + * + * @param name the name value to set. + */ + @Generated + public ResourceG(String name) { + this.name = name; + } + + /** + * Get the id property: The id property. + * + * @return the id value. + */ + @Generated + public String getId() { + return this.id; + } + + /** + * Get the name property: The name property. + * + * @return the name value. + */ + @Generated + public String getName() { + return this.name; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ResourceG from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ResourceG if the JsonReader was pointing to an instance of it, or null if it was pointing + * to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the ResourceG. + */ + @Generated + public static ResourceG fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String id = null; + String name = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("id".equals(fieldName)) { + id = reader.getString(); + } else if ("name".equals(fieldName)) { + name = reader.getString(); + } else { + reader.skipChildren(); + } + } + ResourceG deserializedResourceG = new ResourceG(name); + deserializedResourceG.id = id; + + return deserializedResourceG; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/protocolandconvenient/models/ResourceH.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/protocolandconvenient/models/ResourceH.java new file mode 100644 index 0000000000..b85a801561 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/protocolandconvenient/models/ResourceH.java @@ -0,0 +1,105 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.protocolandconvenient.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * The ResourceH model. + */ +@Immutable +public final class ResourceH implements JsonSerializable { + /* + * The id property. + */ + @Generated + private String id; + + /* + * The name property. + */ + @Generated + private final String name; + + /** + * Creates an instance of ResourceH class. + * + * @param name the name value to set. + */ + @Generated + private ResourceH(String name) { + this.name = name; + } + + /** + * Get the id property: The id property. + * + * @return the id value. + */ + @Generated + public String getId() { + return this.id; + } + + /** + * Get the name property: The name property. + * + * @return the name value. + */ + @Generated + public String getName() { + return this.name; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ResourceH from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ResourceH if the JsonReader was pointing to an instance of it, or null if it was pointing + * to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the ResourceH. + */ + @Generated + public static ResourceH fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String id = null; + String name = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("id".equals(fieldName)) { + id = reader.getString(); + } else if ("name".equals(fieldName)) { + name = reader.getString(); + } else { + reader.skipChildren(); + } + } + ResourceH deserializedResourceH = new ResourceH(name); + deserializedResourceH.id = id; + + return deserializedResourceH; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/specialheaders/models/RepeatabilityResult.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/specialheaders/models/RepeatabilityResult.java new file mode 100644 index 0000000000..603bd54011 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/specialheaders/models/RepeatabilityResult.java @@ -0,0 +1,59 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.specialheaders.models; + +/** + * Repeatability Result header options. + */ +public enum RepeatabilityResult { + /** + * If the request was accepted and the server guarantees that the server state reflects a single execution of the + * operation. + */ + ACCEPTED("accepted"), + + /** + * If the request was rejected because the combination of Repeatability-First-Sent and Repeatability-Request-ID were + * invalid + * or because the Repeatability-First-Sent value was outside the range of values held by the server. + */ + REJECTED("rejected"); + + /** + * The actual serialized value for a RepeatabilityResult instance. + */ + private final String value; + + RepeatabilityResult(String value) { + this.value = value; + } + + /** + * Parses a serialized value to a RepeatabilityResult instance. + * + * @param value the serialized value to parse. + * @return the parsed RepeatabilityResult object, or null if unable to parse. + */ + public static RepeatabilityResult fromString(String value) { + if (value == null) { + return null; + } + RepeatabilityResult[] items = RepeatabilityResult.values(); + for (RepeatabilityResult item : items) { + if (item.toString().equalsIgnoreCase(value)) { + return item; + } + } + return null; + } + + /** + * {@inheritDoc} + */ + @Override + public String toString() { + return this.value; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/union/models/OperationState.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/union/models/OperationState.java new file mode 100644 index 0000000000..202a15ce22 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/union/models/OperationState.java @@ -0,0 +1,75 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.union.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * Enum describing allowed operation states. + */ +public final class OperationState extends ExpandableStringEnum { + /** + * The operation has not started. + */ + @Generated + public static final OperationState NOT_STARTED = fromString("NotStarted"); + + /** + * The operation is in progress. + */ + @Generated + public static final OperationState RUNNING = fromString("Running"); + + /** + * The operation has completed successfully. + */ + @Generated + public static final OperationState SUCCEEDED = fromString("Succeeded"); + + /** + * The operation has failed. + */ + @Generated + public static final OperationState FAILED = fromString("Failed"); + + /** + * The operation has been canceled by the user. + */ + @Generated + public static final OperationState CANCELED = fromString("Canceled"); + + /** + * Creates a new instance of OperationState value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Generated + @Deprecated + public OperationState() { + } + + /** + * Creates or finds a OperationState from its string representation. + * + * @param name a name to look for. + * @return the corresponding OperationState. + */ + @Generated + public static OperationState fromString(String name) { + return fromString(name, OperationState.class); + } + + /** + * Gets known OperationState values. + * + * @return known OperationState values. + */ + @Generated + public static Collection values() { + return values(OperationState.class); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/union/models/ResourceOperationStatusOperationStatusResultError.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/union/models/ResourceOperationStatusOperationStatusResultError.java new file mode 100644 index 0000000000..42e3ddbf64 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/union/models/ResourceOperationStatusOperationStatusResultError.java @@ -0,0 +1,150 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.union.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.core.models.ResponseError; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * Provides status details for long running operations. + */ +@Immutable +public final class ResourceOperationStatusOperationStatusResultError + implements JsonSerializable { + /* + * The unique ID of the operation. + */ + @Generated + private String id; + + /* + * The status of the operation + */ + @Generated + private final OperationState status; + + /* + * Error object that describes the error when status is "Failed". + */ + @Generated + private ResponseError error; + + /* + * The result of the operation. + */ + @Generated + private Result result; + + /** + * Creates an instance of ResourceOperationStatusOperationStatusResultError class. + * + * @param status the status value to set. + */ + @Generated + private ResourceOperationStatusOperationStatusResultError(OperationState status) { + this.status = status; + } + + /** + * Get the id property: The unique ID of the operation. + * + * @return the id value. + */ + @Generated + public String getId() { + return this.id; + } + + /** + * Get the status property: The status of the operation. + * + * @return the status value. + */ + @Generated + public OperationState getStatus() { + return this.status; + } + + /** + * Get the error property: Error object that describes the error when status is "Failed". + * + * @return the error value. + */ + @Generated + public ResponseError getError() { + return this.error; + } + + /** + * Get the result property: The result of the operation. + * + * @return the result value. + */ + @Generated + public Result getResult() { + return this.result; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("status", this.status == null ? null : this.status.toString()); + jsonWriter.writeJsonField("error", this.error); + jsonWriter.writeJsonField("result", this.result); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ResourceOperationStatusOperationStatusResultError from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ResourceOperationStatusOperationStatusResultError if the JsonReader was pointing to an + * instance of it, or null if it was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the ResourceOperationStatusOperationStatusResultError. + */ + @Generated + public static ResourceOperationStatusOperationStatusResultError fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String id = null; + OperationState status = null; + ResponseError error = null; + Result result = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("id".equals(fieldName)) { + id = reader.getString(); + } else if ("status".equals(fieldName)) { + status = OperationState.fromString(reader.getString()); + } else if ("error".equals(fieldName)) { + error = ResponseError.fromJson(reader); + } else if ("result".equals(fieldName)) { + result = Result.fromJson(reader); + } else { + reader.skipChildren(); + } + } + ResourceOperationStatusOperationStatusResultError deserializedResourceOperationStatusOperationStatusResultError + = new ResourceOperationStatusOperationStatusResultError(status); + deserializedResourceOperationStatusOperationStatusResultError.id = id; + deserializedResourceOperationStatusOperationStatusResultError.error = error; + deserializedResourceOperationStatusOperationStatusResultError.result = result; + + return deserializedResourceOperationStatusOperationStatusResultError; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/versioning/models/OperationState.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/versioning/models/OperationState.java new file mode 100644 index 0000000000..a7a4931780 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/versioning/models/OperationState.java @@ -0,0 +1,75 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.versioning.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * Enum describing allowed operation states. + */ +public final class OperationState extends ExpandableStringEnum { + /** + * The operation has not started. + */ + @Generated + public static final OperationState NOT_STARTED = fromString("NotStarted"); + + /** + * The operation is in progress. + */ + @Generated + public static final OperationState RUNNING = fromString("Running"); + + /** + * The operation has completed successfully. + */ + @Generated + public static final OperationState SUCCEEDED = fromString("Succeeded"); + + /** + * The operation has failed. + */ + @Generated + public static final OperationState FAILED = fromString("Failed"); + + /** + * The operation has been canceled by the user. + */ + @Generated + public static final OperationState CANCELED = fromString("Canceled"); + + /** + * Creates a new instance of OperationState value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Generated + @Deprecated + public OperationState() { + } + + /** + * Creates or finds a OperationState from its string representation. + * + * @param name a name to look for. + * @return the corresponding OperationState. + */ + @Generated + public static OperationState fromString(String name) { + return fromString(name, OperationState.class); + } + + /** + * Gets known OperationState values. + * + * @return known OperationState values. + */ + @Generated + public static Collection values() { + return values(OperationState.class); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/versioning/models/ResourceOperationStatusResourceExportedResourceError.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/versioning/models/ResourceOperationStatusResourceExportedResourceError.java new file mode 100644 index 0000000000..de9a241510 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/versioning/models/ResourceOperationStatusResourceExportedResourceError.java @@ -0,0 +1,151 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.versioning.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.core.models.ResponseError; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * Provides status details for long running operations. + */ +@Immutable +public final class ResourceOperationStatusResourceExportedResourceError + implements JsonSerializable { + /* + * The unique ID of the operation. + */ + @Generated + private String id; + + /* + * The status of the operation + */ + @Generated + private final OperationState status; + + /* + * Error object that describes the error when status is "Failed". + */ + @Generated + private ResponseError error; + + /* + * The result of the operation. + */ + @Generated + private ExportedResource result; + + /** + * Creates an instance of ResourceOperationStatusResourceExportedResourceError class. + * + * @param status the status value to set. + */ + @Generated + private ResourceOperationStatusResourceExportedResourceError(OperationState status) { + this.status = status; + } + + /** + * Get the id property: The unique ID of the operation. + * + * @return the id value. + */ + @Generated + public String getId() { + return this.id; + } + + /** + * Get the status property: The status of the operation. + * + * @return the status value. + */ + @Generated + public OperationState getStatus() { + return this.status; + } + + /** + * Get the error property: Error object that describes the error when status is "Failed". + * + * @return the error value. + */ + @Generated + public ResponseError getError() { + return this.error; + } + + /** + * Get the result property: The result of the operation. + * + * @return the result value. + */ + @Generated + public ExportedResource getResult() { + return this.result; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("status", this.status == null ? null : this.status.toString()); + jsonWriter.writeJsonField("error", this.error); + jsonWriter.writeJsonField("result", this.result); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ResourceOperationStatusResourceExportedResourceError from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ResourceOperationStatusResourceExportedResourceError if the JsonReader was pointing to an + * instance of it, or null if it was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the ResourceOperationStatusResourceExportedResourceError. + */ + @Generated + public static ResourceOperationStatusResourceExportedResourceError fromJson(JsonReader jsonReader) + throws IOException { + return jsonReader.readObject(reader -> { + String id = null; + OperationState status = null; + ResponseError error = null; + ExportedResource result = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("id".equals(fieldName)) { + id = reader.getString(); + } else if ("status".equals(fieldName)) { + status = OperationState.fromString(reader.getString()); + } else if ("error".equals(fieldName)) { + error = ResponseError.fromJson(reader); + } else if ("result".equals(fieldName)) { + result = ExportedResource.fromJson(reader); + } else { + reader.skipChildren(); + } + } + ResourceOperationStatusResourceExportedResourceError deserializedResourceOperationStatusResourceExportedResourceError + = new ResourceOperationStatusResourceExportedResourceError(status); + deserializedResourceOperationStatusResourceExportedResourceError.id = id; + deserializedResourceOperationStatusResourceExportedResourceError.error = error; + deserializedResourceOperationStatusResourceExportedResourceError.result = result; + + return deserializedResourceOperationStatusResourceExportedResourceError; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/structure/service/models/ClientType.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/structure/service/models/ClientType.java new file mode 100644 index 0000000000..ea56f83d74 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/structure/service/models/ClientType.java @@ -0,0 +1,66 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.client.structure.service.models; + +/** + * Defines values for ClientType. + */ +public enum ClientType { + /** + * Enum value default. + */ + DEFAULT("default"), + + /** + * Enum value multi-client. + */ + MULTI_CLIENT("multi-client"), + + /** + * Enum value renamed-operation. + */ + RENAMED_OPERATION("renamed-operation"), + + /** + * Enum value two-operation-group. + */ + TWO_OPERATION_GROUP("two-operation-group"); + + /** + * The actual serialized value for a ClientType instance. + */ + private final String value; + + ClientType(String value) { + this.value = value; + } + + /** + * Parses a serialized value to a ClientType instance. + * + * @param value the serialized value to parse. + * @return the parsed ClientType object, or null if unable to parse. + */ + public static ClientType fromString(String value) { + if (value == null) { + return null; + } + ClientType[] items = ClientType.values(); + for (ClientType item : items) { + if (item.toString().equalsIgnoreCase(value)) { + return item; + } + } + return null; + } + + /** + * {@inheritDoc} + */ + @Override + public String toString() { + return this.value; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/structure/service/models/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/structure/service/models/package-info.java new file mode 100644 index 0000000000..d9a21e6dad --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/structure/service/models/package-info.java @@ -0,0 +1,18 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +/** + * + * Package containing the data models for Service. + * Test that we can use @client and @operationGroup decorators to customize client side code structure, such + * as: + * 1. have everything as default. + * 2. to rename client or operation group + * 3. one client can have more than one operations groups + * 4. split one interface into two clients + * 5. have two clients with operations come from different interfaces + * 6. have two clients with a hierarchy relation. + * + */ +package com.client.structure.service.models; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialheaders/repeatability/models/ImmediateSuccessResponseRepeatabilityResult.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialheaders/repeatability/models/ImmediateSuccessResponseRepeatabilityResult.java new file mode 100644 index 0000000000..b705a13cf5 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialheaders/repeatability/models/ImmediateSuccessResponseRepeatabilityResult.java @@ -0,0 +1,56 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.specialheaders.repeatability.models; + +/** + * Defines values for ImmediateSuccessResponseRepeatabilityResult. + */ +public enum ImmediateSuccessResponseRepeatabilityResult { + /** + * Enum value accepted. + */ + ACCEPTED("accepted"), + + /** + * Enum value rejected. + */ + REJECTED("rejected"); + + /** + * The actual serialized value for a ImmediateSuccessResponseRepeatabilityResult instance. + */ + private final String value; + + ImmediateSuccessResponseRepeatabilityResult(String value) { + this.value = value; + } + + /** + * Parses a serialized value to a ImmediateSuccessResponseRepeatabilityResult instance. + * + * @param value the serialized value to parse. + * @return the parsed ImmediateSuccessResponseRepeatabilityResult object, or null if unable to parse. + */ + public static ImmediateSuccessResponseRepeatabilityResult fromString(String value) { + if (value == null) { + return null; + } + ImmediateSuccessResponseRepeatabilityResult[] items = ImmediateSuccessResponseRepeatabilityResult.values(); + for (ImmediateSuccessResponseRepeatabilityResult item : items) { + if (item.toString().equalsIgnoreCase(value)) { + return item; + } + } + return null; + } + + /** + * {@inheritDoc} + */ + @Override + public String toString() { + return this.value; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialheaders/repeatability/models/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialheaders/repeatability/models/package-info.java new file mode 100644 index 0000000000..5cede2531e --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialheaders/repeatability/models/package-info.java @@ -0,0 +1,11 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +/** + * + * Package containing the data models for Repeatability. + * Illustrates OASIS repeatability headers. + * + */ +package com.specialheaders.repeatability.models; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/models/BooleanLiteralPropertyProperty.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/models/BooleanLiteralPropertyProperty.java deleted file mode 100644 index 9a51ba705d..0000000000 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/models/BooleanLiteralPropertyProperty.java +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) TypeSpec Code Generator. - -package com.type.property.optional.models; - -/** - * Defines values for BooleanLiteralPropertyProperty. - */ -public enum BooleanLiteralPropertyProperty { - /** - * Enum value true. - */ - TRUE(true); - - /** - * The actual serialized value for a BooleanLiteralPropertyProperty instance. - */ - private final boolean value; - - BooleanLiteralPropertyProperty(boolean value) { - this.value = value; - } - - /** - * Parses a serialized value to a BooleanLiteralPropertyProperty instance. - * - * @param value the serialized value to parse. - * @return the parsed BooleanLiteralPropertyProperty object, or null if unable to parse. - */ - public static BooleanLiteralPropertyProperty fromBoolean(boolean value) { - BooleanLiteralPropertyProperty[] items = BooleanLiteralPropertyProperty.values(); - for (BooleanLiteralPropertyProperty item : items) { - if (item.toBoolean() == value) { - return item; - } - } - return null; - } - - /** - * De-serializes the instance to boolean value. - * - * @return the boolean value. - */ - public boolean toBoolean() { - return this.value; - } -} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/models/FloatLiteralPropertyProperty.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/models/FloatLiteralPropertyProperty.java deleted file mode 100644 index 8c313b5eb0..0000000000 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/models/FloatLiteralPropertyProperty.java +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) TypeSpec Code Generator. - -package com.type.property.optional.models; - -/** - * Defines values for FloatLiteralPropertyProperty. - */ -public enum FloatLiteralPropertyProperty { - /** - * Enum value 1.25. - */ - ONE_TWO_FIVE(1.25); - - /** - * The actual serialized value for a FloatLiteralPropertyProperty instance. - */ - private final double value; - - FloatLiteralPropertyProperty(double value) { - this.value = value; - } - - /** - * Parses a serialized value to a FloatLiteralPropertyProperty instance. - * - * @param value the serialized value to parse. - * @return the parsed FloatLiteralPropertyProperty object, or null if unable to parse. - */ - public static FloatLiteralPropertyProperty fromDouble(double value) { - FloatLiteralPropertyProperty[] items = FloatLiteralPropertyProperty.values(); - for (FloatLiteralPropertyProperty item : items) { - if (Double.doubleToLongBits(item.toDouble()) == Double.doubleToLongBits(value)) { - return item; - } - } - return null; - } - - /** - * De-serializes the instance to double value. - * - * @return the double value. - */ - public double toDouble() { - return this.value; - } -} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/models/IntLiteralPropertyProperty.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/models/IntLiteralPropertyProperty.java deleted file mode 100644 index 9aeb70262d..0000000000 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/models/IntLiteralPropertyProperty.java +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) TypeSpec Code Generator. - -package com.type.property.optional.models; - -/** - * Defines values for IntLiteralPropertyProperty. - */ -public enum IntLiteralPropertyProperty { - /** - * Enum value 1. - */ - ONE(1); - - /** - * The actual serialized value for a IntLiteralPropertyProperty instance. - */ - private final int value; - - IntLiteralPropertyProperty(int value) { - this.value = value; - } - - /** - * Parses a serialized value to a IntLiteralPropertyProperty instance. - * - * @param value the serialized value to parse. - * @return the parsed IntLiteralPropertyProperty object, or null if unable to parse. - */ - public static IntLiteralPropertyProperty fromInt(int value) { - IntLiteralPropertyProperty[] items = IntLiteralPropertyProperty.values(); - for (IntLiteralPropertyProperty item : items) { - if (item.toInt() == value) { - return item; - } - } - return null; - } - - /** - * De-serializes the instance to int value. - * - * @return the int value. - */ - public int toInt() { - return this.value; - } -} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/models/StringLiteralPropertyProperty.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/models/StringLiteralPropertyProperty.java deleted file mode 100644 index e9e47354f7..0000000000 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/models/StringLiteralPropertyProperty.java +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) TypeSpec Code Generator. - -package com.type.property.optional.models; - -/** - * Defines values for StringLiteralPropertyProperty. - */ -public enum StringLiteralPropertyProperty { - /** - * Enum value hello. - */ - HELLO("hello"); - - /** - * The actual serialized value for a StringLiteralPropertyProperty instance. - */ - private final String value; - - StringLiteralPropertyProperty(String value) { - this.value = value; - } - - /** - * Parses a serialized value to a StringLiteralPropertyProperty instance. - * - * @param value the serialized value to parse. - * @return the parsed StringLiteralPropertyProperty object, or null if unable to parse. - */ - public static StringLiteralPropertyProperty fromString(String value) { - if (value == null) { - return null; - } - StringLiteralPropertyProperty[] items = StringLiteralPropertyProperty.values(); - for (StringLiteralPropertyProperty item : items) { - if (item.toString().equalsIgnoreCase(value)) { - return item; - } - } - return null; - } - - /** - * {@inheritDoc} - */ - @Override - public String toString() { - return this.value; - } -} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/_specs_-azure-core-lro-rpc_apiview_properties.json b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/_specs_-azure-core-lro-rpc_apiview_properties.json index b8ff6a75d3..69dfa49ee0 100644 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/_specs_-azure-core-lro-rpc_apiview_properties.json +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/_specs_-azure-core-lro-rpc_apiview_properties.json @@ -9,6 +9,8 @@ "com._specs_.azure.core.lro.rpc.RpcClient.beginLongRunningRpcWithModel": "_Specs_.Azure.Core.Lro.Rpc.longRunningRpc", "com._specs_.azure.core.lro.rpc.RpcClientBuilder": "_Specs_.Azure.Core.Lro.Rpc", "com._specs_.azure.core.lro.rpc.models.GenerationOptions": "_Specs_.Azure.Core.Lro.Rpc.GenerationOptions", - "com._specs_.azure.core.lro.rpc.models.GenerationResult": "_Specs_.Azure.Core.Lro.Rpc.GenerationResult" + "com._specs_.azure.core.lro.rpc.models.GenerationResult": "_Specs_.Azure.Core.Lro.Rpc.GenerationResult", + "com._specs_.azure.core.lro.rpc.models.OperationState": "Azure.Core.Foundations.OperationState", + "com._specs_.azure.core.lro.rpc.models.ResourceOperationStatusGenerationResponseGenerationResultError": "Azure.Core.ResourceOperationStatus" } } diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/_specs_-azure-core-lro-standard_apiview_properties.json b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/_specs_-azure-core-lro-standard_apiview_properties.json index fd433fed62..9fdcaaacc7 100644 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/_specs_-azure-core-lro-standard_apiview_properties.json +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/_specs_-azure-core-lro-standard_apiview_properties.json @@ -17,6 +17,9 @@ "com._specs_.azure.core.lro.standard.StandardClient.beginExportWithModel": "_Specs_.Azure.Core.Lro.Standard.export", "com._specs_.azure.core.lro.standard.StandardClientBuilder": "_Specs_.Azure.Core.Lro.Standard", "com._specs_.azure.core.lro.standard.models.ExportedUser": "_Specs_.Azure.Core.Lro.Standard.ExportedUser", + "com._specs_.azure.core.lro.standard.models.OperationState": "Azure.Core.Foundations.OperationState", + "com._specs_.azure.core.lro.standard.models.OperationStatusError": "Azure.Core.Foundations.OperationStatus", + "com._specs_.azure.core.lro.standard.models.ResourceOperationStatusUserExportedUserError": "Azure.Core.ResourceOperationStatus", "com._specs_.azure.core.lro.standard.models.User": "_Specs_.Azure.Core.Lro.Standard.User" } } diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/_specs_-azure-core-traits_apiview_properties.json b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/_specs_-azure-core-traits_apiview_properties.json index 772035cfcc..2814ef1a41 100644 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/_specs_-azure-core-traits_apiview_properties.json +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/_specs_-azure-core-traits_apiview_properties.json @@ -12,6 +12,7 @@ "com._specs_.azure.core.traits.TraitsClient.smokeTest": "_Specs_.Azure.Core.Traits.smokeTest", "com._specs_.azure.core.traits.TraitsClient.smokeTestWithResponse": "_Specs_.Azure.Core.Traits.smokeTest", "com._specs_.azure.core.traits.TraitsClientBuilder": "_Specs_.Azure.Core.Traits", + "com._specs_.azure.core.traits.models.RepeatabilityResult": "Azure.Core.RepeatabilityResult", "com._specs_.azure.core.traits.models.User": "_Specs_.Azure.Core.Traits.User", "com._specs_.azure.core.traits.models.UserActionParam": "_Specs_.Azure.Core.Traits.UserActionParam", "com._specs_.azure.core.traits.models.UserActionResponse": "_Specs_.Azure.Core.Traits.UserActionResponse" diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/cadl-builtin_apiview_properties.json b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/cadl-builtin_apiview_properties.json index e8050fdba3..26a497a95e 100644 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/cadl-builtin_apiview_properties.json +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/cadl-builtin_apiview_properties.json @@ -4,9 +4,13 @@ "com.cadl.builtin.BuiltinAsyncClient": "null", "com.cadl.builtin.BuiltinAsyncClient.read": "Cadl.Builtin.BuiltinOp.read", "com.cadl.builtin.BuiltinAsyncClient.readWithResponse": "Cadl.Builtin.BuiltinOp.read", + "com.cadl.builtin.BuiltinAsyncClient.write": "Cadl.Builtin.BuiltinOp.write", + "com.cadl.builtin.BuiltinAsyncClient.writeWithResponse": "Cadl.Builtin.BuiltinOp.write", "com.cadl.builtin.BuiltinClient": "null", "com.cadl.builtin.BuiltinClient.read": "Cadl.Builtin.BuiltinOp.read", "com.cadl.builtin.BuiltinClient.readWithResponse": "Cadl.Builtin.BuiltinOp.read", + "com.cadl.builtin.BuiltinClient.write": "Cadl.Builtin.BuiltinOp.write", + "com.cadl.builtin.BuiltinClient.writeWithResponse": "Cadl.Builtin.BuiltinOp.write", "com.cadl.builtin.BuiltinClientBuilder": "Cadl.Builtin", "com.cadl.builtin.models.Builtin": "Cadl.Builtin.Builtin", "com.cadl.builtin.models.Encoded": "Cadl.Builtin.Encoded" diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/cadl-internal_apiview_properties.json b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/cadl-internal_apiview_properties.json index 9ce9484730..2e3cb8b499 100644 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/cadl-internal_apiview_properties.json +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/cadl-internal_apiview_properties.json @@ -14,6 +14,7 @@ "com.cadl.internal.InternalClientBuilder": "Cadl.Internal", "com.cadl.internal.implementation.models.Color": "Cadl.Internal.Color", "com.cadl.internal.implementation.models.ColorModel": "Cadl.Internal.ColorModel", + "com.cadl.internal.implementation.models.ProtocolInternalModel": "Cadl.Internal.ProtocolInternalModel", "com.cadl.internal.models.ApiRequest": "Cadl.Internal.ApiRequest", "com.cadl.internal.models.ApiResponse": "Cadl.Internal.ApiResponse", "com.cadl.internal.models.RequestInner": "Cadl.Internal.RequestInner", diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/cadl-literalservice_apiview_properties.json b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/cadl-literalservice_apiview_properties.json index 7a6e7e1f0a..b580b99691 100644 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/cadl-literalservice_apiview_properties.json +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/cadl-literalservice_apiview_properties.json @@ -8,8 +8,6 @@ "com.cadl.literalservice.LiteralServiceClient.put": "Cadl.LiteralService.LiteralOp.put", "com.cadl.literalservice.LiteralServiceClient.putWithResponse": "Cadl.LiteralService.LiteralOp.put", "com.cadl.literalservice.LiteralServiceClientBuilder": "Cadl.LiteralService", - "com.cadl.literalservice.models.Model": "Cadl.LiteralService.Model", - "com.cadl.literalservice.models.ModelOptionalLiteral": "null", - "com.cadl.literalservice.models.PutRequestOptionalLiteralParam": "null" + "com.cadl.literalservice.models.Model": "Cadl.LiteralService.Model" } } diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/cadl-longrunning_apiview_properties.json b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/cadl-longrunning_apiview_properties.json index 26f9ae99a1..1bb4928f3b 100644 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/cadl-longrunning_apiview_properties.json +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/cadl-longrunning_apiview_properties.json @@ -20,7 +20,9 @@ "com.cadl.longrunning.models.JobResult": "Cadl.LongRunning.JobResult", "com.cadl.longrunning.models.JobResultResult": "Cadl.LongRunning.JobResult.result.anonymous", "com.cadl.longrunning.models.JobStatus": "Cadl.LongRunning.JobStatus", + "com.cadl.longrunning.models.LroOperationStatusError": "Cadl.LongRunning.LroOperationStatus", "com.cadl.longrunning.models.OperationState": "Azure.Core.Foundations.OperationState", - "com.cadl.longrunning.models.PollResponse": "Cadl.LongRunning.PollResponse" + "com.cadl.longrunning.models.PollResponse": "Cadl.LongRunning.PollResponse", + "com.cadl.longrunning.models.RepeatabilityResult": "Azure.Core.RepeatabilityResult" } } diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/cadl-multicontenttypes_apiview_properties.json b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/cadl-multicontenttypes_apiview_properties.json index 4577e1de5d..5616a96f96 100644 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/cadl-multicontenttypes_apiview_properties.json +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/cadl-multicontenttypes_apiview_properties.json @@ -20,6 +20,10 @@ "com.cadl.multicontenttypes.SingleContentTypeClient.downloadImageForSingleContentTypeWithResponse": "Cadl.MultiContentTypes.SingleContentType.downloadImageForSingleContentType", "com.cadl.multicontenttypes.SingleContentTypeClient.uploadImageForSingleContentType": "Cadl.MultiContentTypes.SingleContentType.uploadImageForSingleContentType", "com.cadl.multicontenttypes.SingleContentTypeClient.uploadImageForSingleContentTypeWithResponse": "Cadl.MultiContentTypes.SingleContentType.uploadImageForSingleContentType", - "com.cadl.multicontenttypes.models.Resource": "Cadl.MultiContentTypes.Resource" + "com.cadl.multicontenttypes.models.Resource": "Cadl.MultiContentTypes.Resource", + "com.cadl.multicontenttypes.models.UploadBytesWithMultiBodyTypesForMultiContentTypesRequestContentType": "uploadBytesWithMultiBodyTypesForMultiContentTypes.RequestContentType.anonymous", + "com.cadl.multicontenttypes.models.UploadBytesWithSingleBodyTypeForMultiContentTypesRequestContentType": "uploadBytesWithSingleBodyTypeForMultiContentTypes.RequestContentType.anonymous", + "com.cadl.multicontenttypes.models.UploadJsonOrBytesWithMultiBodyTypesForMultiContentTypesRequestContentType": "uploadJsonOrBytesWithMultiBodyTypesForMultiContentTypes.RequestContentType.anonymous", + "com.cadl.multicontenttypes.models.UploadWithOverloadRequestContentType": "uploadWithOverload.RequestContentType.anonymous" } } diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/cadl-protocolandconvenient_apiview_properties.json b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/cadl-protocolandconvenient_apiview_properties.json index f83ed0baaf..81c4a70987 100644 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/cadl-protocolandconvenient_apiview_properties.json +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/cadl-protocolandconvenient_apiview_properties.json @@ -20,8 +20,12 @@ "com.cadl.protocolandconvenient.ProtocolAndConvenientClientBuilder": "Cadl.ProtocolAndConvenient", "com.cadl.protocolandconvenient.models.ResourceA": "Cadl.ProtocolAndConvenient.ResourceA", "com.cadl.protocolandconvenient.models.ResourceB": "Cadl.ProtocolAndConvenient.ResourceB", + "com.cadl.protocolandconvenient.models.ResourceC": "Cadl.ProtocolAndConvenient.ResourceC", + "com.cadl.protocolandconvenient.models.ResourceD": "Cadl.ProtocolAndConvenient.ResourceD", "com.cadl.protocolandconvenient.models.ResourceE": "Cadl.ProtocolAndConvenient.ResourceE", "com.cadl.protocolandconvenient.models.ResourceF": "Cadl.ProtocolAndConvenient.ResourceF", + "com.cadl.protocolandconvenient.models.ResourceG": "Cadl.ProtocolAndConvenient.ResourceG", + "com.cadl.protocolandconvenient.models.ResourceH": "Cadl.ProtocolAndConvenient.ResourceH", "com.cadl.protocolandconvenient.models.ResourceI": "Cadl.ProtocolAndConvenient.ResourceI", "com.cadl.protocolandconvenient.models.ResourceJ": "Cadl.ProtocolAndConvenient.ResourceJ" } diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/cadl-specialheaders_apiview_properties.json b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/cadl-specialheaders_apiview_properties.json index 58e3376a2b..28513701fe 100644 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/cadl-specialheaders_apiview_properties.json +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/cadl-specialheaders_apiview_properties.json @@ -44,6 +44,7 @@ "com.cadl.specialheaders.SkipSpecialHeadersClient.deleteWithSpecialHeaders": "Cadl.SpecialHeaders.SkipSpecialHeaders.deleteWithSpecialHeaders", "com.cadl.specialheaders.SkipSpecialHeadersClient.deleteWithSpecialHeadersWithResponse": "Cadl.SpecialHeaders.SkipSpecialHeaders.deleteWithSpecialHeaders", "com.cadl.specialheaders.SpecialHeadersClientBuilder": "Cadl.SpecialHeaders", + "com.cadl.specialheaders.models.RepeatabilityResult": "Azure.Core.RepeatabilityResult", "com.cadl.specialheaders.models.Resource": "Cadl.SpecialHeaders.Resource" } } diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/cadl-union_apiview_properties.json b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/cadl-union_apiview_properties.json index 6c2e368409..569ffac7e4 100644 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/cadl-union_apiview_properties.json +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/cadl-union_apiview_properties.json @@ -24,6 +24,8 @@ "com.cadl.union.implementation.models.SendRequest": "send.Request.anonymous", "com.cadl.union.implementation.models.SubResult": "Cadl.Union.SubResult", "com.cadl.union.models.ArrayData": "Cadl.Union.ArrayData", + "com.cadl.union.models.OperationState": "Azure.Core.Foundations.OperationState", + "com.cadl.union.models.ResourceOperationStatusOperationStatusResultError": "Azure.Core.ResourceOperationStatus", "com.cadl.union.models.Result": "Cadl.Union.Result", "com.cadl.union.models.SendLongOptions": "null", "com.cadl.union.models.User": "Cadl.Union.User" diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/cadl-versioning_apiview_properties.json b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/cadl-versioning_apiview_properties.json index 90dbdda49a..aa5cd197a6 100644 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/cadl-versioning_apiview_properties.json +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/cadl-versioning_apiview_properties.json @@ -15,6 +15,8 @@ "com.cadl.versioning.VersioningClient.list": "Cadl.Versioning.VersioningOp.list", "com.cadl.versioning.VersioningClientBuilder": "Cadl.Versioning", "com.cadl.versioning.models.ExportedResource": "Cadl.Versioning.ExportedResource", - "com.cadl.versioning.models.Resource": "Cadl.Versioning.Resource" + "com.cadl.versioning.models.OperationState": "Azure.Core.Foundations.OperationState", + "com.cadl.versioning.models.Resource": "Cadl.Versioning.Resource", + "com.cadl.versioning.models.ResourceOperationStatusResourceExportedResourceError": "Azure.Core.ResourceOperationStatus" } } diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/specialheaders-repeatability_apiview_properties.json b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/specialheaders-repeatability_apiview_properties.json index 734dbfc578..990b053105 100644 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/specialheaders-repeatability_apiview_properties.json +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/specialheaders-repeatability_apiview_properties.json @@ -7,6 +7,7 @@ "com.specialheaders.repeatability.RepeatabilityClient": "SpecialHeaders.Repeatability", "com.specialheaders.repeatability.RepeatabilityClient.immediateSuccess": "SpecialHeaders.Repeatability.immediateSuccess", "com.specialheaders.repeatability.RepeatabilityClient.immediateSuccessWithResponse": "SpecialHeaders.Repeatability.immediateSuccess", - "com.specialheaders.repeatability.RepeatabilityClientBuilder": "SpecialHeaders.Repeatability" + "com.specialheaders.repeatability.RepeatabilityClientBuilder": "SpecialHeaders.Repeatability", + "com.specialheaders.repeatability.models.ImmediateSuccessResponseRepeatabilityResult": "immediateSuccess.ResponseRepeatabilityResult.anonymous" } } diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/type-property-optional_apiview_properties.json b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/type-property-optional_apiview_properties.json index 7e62e36cc4..7f5be6930a 100644 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/type-property-optional_apiview_properties.json +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/type-property-optional_apiview_properties.json @@ -291,21 +291,17 @@ "com.type.property.optional.UnionStringLiteralClient.putDefault": "Type.Property.Optional.UnionStringLiteral.putDefault", "com.type.property.optional.UnionStringLiteralClient.putDefaultWithResponse": "Type.Property.Optional.UnionStringLiteral.putDefault", "com.type.property.optional.models.BooleanLiteralProperty": "Type.Property.Optional.BooleanLiteralProperty", - "com.type.property.optional.models.BooleanLiteralPropertyProperty": "null", "com.type.property.optional.models.BytesProperty": "Type.Property.Optional.BytesProperty", "com.type.property.optional.models.CollectionsByteProperty": "Type.Property.Optional.CollectionsByteProperty", "com.type.property.optional.models.CollectionsModelProperty": "Type.Property.Optional.CollectionsModelProperty", "com.type.property.optional.models.DatetimeProperty": "Type.Property.Optional.DatetimeProperty", "com.type.property.optional.models.DurationProperty": "Type.Property.Optional.DurationProperty", "com.type.property.optional.models.FloatLiteralProperty": "Type.Property.Optional.FloatLiteralProperty", - "com.type.property.optional.models.FloatLiteralPropertyProperty": "null", "com.type.property.optional.models.IntLiteralProperty": "Type.Property.Optional.IntLiteralProperty", - "com.type.property.optional.models.IntLiteralPropertyProperty": "null", "com.type.property.optional.models.PlainDateProperty": "Type.Property.Optional.PlainDateProperty", "com.type.property.optional.models.PlainTimeProperty": "Type.Property.Optional.PlainTimeProperty", "com.type.property.optional.models.RequiredAndOptionalProperty": "Type.Property.Optional.RequiredAndOptionalProperty", "com.type.property.optional.models.StringLiteralProperty": "Type.Property.Optional.StringLiteralProperty", - "com.type.property.optional.models.StringLiteralPropertyProperty": "null", "com.type.property.optional.models.StringProperty": "Type.Property.Optional.StringProperty", "com.type.property.optional.models.UnionFloatLiteralProperty": "Type.Property.Optional.UnionFloatLiteralProperty", "com.type.property.optional.models.UnionFloatLiteralPropertyProperty": "UnionFloatLiteralProperty.property.anonymous", From 005ab218c9feaf1aaa0597d67b5fc15b190e0764 Mon Sep 17 00:00:00 2001 From: Haoling Dong <87355844+haolingdong-msft@users.noreply.github.com> Date: Thu, 24 Oct 2024 14:06:23 +0800 Subject: [PATCH 10/26] not generate the model if usageFlag === 0 --- packages/http-client-java/emitter/src/type-utils.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/http-client-java/emitter/src/type-utils.ts b/packages/http-client-java/emitter/src/type-utils.ts index c120b91f40..23ff0d9c39 100644 --- a/packages/http-client-java/emitter/src/type-utils.ts +++ b/packages/http-client-java/emitter/src/type-utils.ts @@ -348,8 +348,10 @@ export function processSchemaUsageFromSdkType(sdkType: SdkModelType | SdkEnumTyp return usage; } if (usageFlags & UsageFlags.ApiVersionEnum) { - usage = []; - return usage; + return []; + } + if (usageFlags === 0) { + return []; } if (usageFlags & UsageFlags.Input) usage = pushDistinct(usage, SchemaContext.Input); From 272b8df4ce54443b0bf97405f0e72f19a833ce4b Mon Sep 17 00:00:00 2001 From: Haoling Dong <87355844+haolingdong-msft@users.noreply.github.com> Date: Thu, 24 Oct 2024 14:06:38 +0800 Subject: [PATCH 11/26] regen --- .../cadl/enumservice/models/Operation.java | 42 +------ .../models/ProtocolInternalModel.java | 83 -------------- .../longrunning/models/OperationState.java | 75 ------------- .../models/ResourceC.java | 105 ------------------ .../models/ResourceG.java | 105 ------------------ .../structure/service/models/ClientType.java | 7 +- .../cadl-builtin_apiview_properties.json | 4 - .../cadl-internal_apiview_properties.json | 1 - .../cadl-longrunning_apiview_properties.json | 1 - ...tocolandconvenient_apiview_properties.json | 2 - 10 files changed, 9 insertions(+), 416 deletions(-) delete mode 100644 packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/internal/implementation/models/ProtocolInternalModel.java delete mode 100644 packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/longrunning/models/OperationState.java delete mode 100644 packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/protocolandconvenient/models/ResourceC.java delete mode 100644 packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/protocolandconvenient/models/ResourceG.java diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/enumservice/models/Operation.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/enumservice/models/Operation.java index 9d7002f5a5..52e33beb4f 100644 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/enumservice/models/Operation.java +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/enumservice/models/Operation.java @@ -4,8 +4,8 @@ package com.cadl.enumservice.models; -import com.azure.core.annotation.Fluent; import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; import com.azure.json.JsonReader; import com.azure.json.JsonSerializable; import com.azure.json.JsonToken; @@ -15,7 +15,7 @@ /** * The Operation model. */ -@Fluent +@Immutable public final class Operation implements JsonSerializable { /* * The name property. @@ -98,7 +98,7 @@ public final class Operation implements JsonSerializable { * @param unit the unit value to set. */ @Generated - public Operation(OperationName name, Priority priority, ColorModel color, Unit unit) { + private Operation(OperationName name, Priority priority, ColorModel color, Unit unit) { this.name = name; this.priority = priority; this.color = color; @@ -205,18 +205,6 @@ public Unit getUnitValue() { return this.unitValue; } - /** - * Set the unitValue property: The unitValue property. - * - * @param unitValue the unitValue value to set. - * @return the Operation object itself. - */ - @Generated - public Operation setUnitValue(Unit unitValue) { - this.unitValue = unitValue; - return this; - } - /** * Get the olympicRecord property: The olympicRecord property. * @@ -227,18 +215,6 @@ public OlympicRecordModel getOlympicRecord() { return this.olympicRecord; } - /** - * Set the olympicRecord property: The olympicRecord property. - * - * @param olympicRecord the olympicRecord value to set. - * @return the Operation object itself. - */ - @Generated - public Operation setOlympicRecord(OlympicRecordModel olympicRecord) { - this.olympicRecord = olympicRecord; - return this; - } - /** * Get the olympicRecordValue property: The olympicRecordValue property. * @@ -249,18 +225,6 @@ public OlympicRecordModel getOlympicRecordValue() { return this.olympicRecordValue; } - /** - * Set the olympicRecordValue property: The olympicRecordValue property. - * - * @param olympicRecordValue the olympicRecordValue value to set. - * @return the Operation object itself. - */ - @Generated - public Operation setOlympicRecordValue(OlympicRecordModel olympicRecordValue) { - this.olympicRecordValue = olympicRecordValue; - return this; - } - /** * {@inheritDoc} */ diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/internal/implementation/models/ProtocolInternalModel.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/internal/implementation/models/ProtocolInternalModel.java deleted file mode 100644 index 2d59ca0374..0000000000 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/internal/implementation/models/ProtocolInternalModel.java +++ /dev/null @@ -1,83 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) TypeSpec Code Generator. - -package com.cadl.internal.implementation.models; - -import com.azure.core.annotation.Generated; -import com.azure.core.annotation.Immutable; -import com.azure.json.JsonReader; -import com.azure.json.JsonSerializable; -import com.azure.json.JsonToken; -import com.azure.json.JsonWriter; -import java.io.IOException; - -/** - * The ProtocolInternalModel model. - */ -@Immutable -public final class ProtocolInternalModel implements JsonSerializable { - /* - * The name property. - */ - @Generated - private final String name; - - /** - * Creates an instance of ProtocolInternalModel class. - * - * @param name the name value to set. - */ - @Generated - public ProtocolInternalModel(String name) { - this.name = name; - } - - /** - * Get the name property: The name property. - * - * @return the name value. - */ - @Generated - public String getName() { - return this.name; - } - - /** - * {@inheritDoc} - */ - @Generated - @Override - public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { - jsonWriter.writeStartObject(); - jsonWriter.writeStringField("name", this.name); - return jsonWriter.writeEndObject(); - } - - /** - * Reads an instance of ProtocolInternalModel from the JsonReader. - * - * @param jsonReader The JsonReader being read. - * @return An instance of ProtocolInternalModel if the JsonReader was pointing to an instance of it, or null if it - * was pointing to JSON null. - * @throws IllegalStateException If the deserialized JSON object was missing any required properties. - * @throws IOException If an error occurs while reading the ProtocolInternalModel. - */ - @Generated - public static ProtocolInternalModel fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject(reader -> { - String name = null; - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); - - if ("name".equals(fieldName)) { - name = reader.getString(); - } else { - reader.skipChildren(); - } - } - return new ProtocolInternalModel(name); - }); - } -} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/longrunning/models/OperationState.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/longrunning/models/OperationState.java deleted file mode 100644 index 30784b9a26..0000000000 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/longrunning/models/OperationState.java +++ /dev/null @@ -1,75 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) TypeSpec Code Generator. - -package com.cadl.longrunning.models; - -import com.azure.core.annotation.Generated; -import com.azure.core.util.ExpandableStringEnum; -import java.util.Collection; - -/** - * Enum describing allowed operation states. - */ -public final class OperationState extends ExpandableStringEnum { - /** - * The operation has not started. - */ - @Generated - public static final OperationState NOT_STARTED = fromString("NotStarted"); - - /** - * The operation is in progress. - */ - @Generated - public static final OperationState RUNNING = fromString("Running"); - - /** - * The operation has completed successfully. - */ - @Generated - public static final OperationState SUCCEEDED = fromString("Succeeded"); - - /** - * The operation has failed. - */ - @Generated - public static final OperationState FAILED = fromString("Failed"); - - /** - * The operation has been canceled by the user. - */ - @Generated - public static final OperationState CANCELED = fromString("Canceled"); - - /** - * Creates a new instance of OperationState value. - * - * @deprecated Use the {@link #fromString(String)} factory method. - */ - @Generated - @Deprecated - public OperationState() { - } - - /** - * Creates or finds a OperationState from its string representation. - * - * @param name a name to look for. - * @return the corresponding OperationState. - */ - @Generated - public static OperationState fromString(String name) { - return fromString(name, OperationState.class); - } - - /** - * Gets known OperationState values. - * - * @return known OperationState values. - */ - @Generated - public static Collection values() { - return values(OperationState.class); - } -} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/protocolandconvenient/models/ResourceC.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/protocolandconvenient/models/ResourceC.java deleted file mode 100644 index c5a926a591..0000000000 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/protocolandconvenient/models/ResourceC.java +++ /dev/null @@ -1,105 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) TypeSpec Code Generator. - -package com.cadl.protocolandconvenient.models; - -import com.azure.core.annotation.Generated; -import com.azure.core.annotation.Immutable; -import com.azure.json.JsonReader; -import com.azure.json.JsonSerializable; -import com.azure.json.JsonToken; -import com.azure.json.JsonWriter; -import java.io.IOException; - -/** - * The ResourceC model. - */ -@Immutable -public final class ResourceC implements JsonSerializable { - /* - * The id property. - */ - @Generated - private String id; - - /* - * The name property. - */ - @Generated - private final String name; - - /** - * Creates an instance of ResourceC class. - * - * @param name the name value to set. - */ - @Generated - public ResourceC(String name) { - this.name = name; - } - - /** - * Get the id property: The id property. - * - * @return the id value. - */ - @Generated - public String getId() { - return this.id; - } - - /** - * Get the name property: The name property. - * - * @return the name value. - */ - @Generated - public String getName() { - return this.name; - } - - /** - * {@inheritDoc} - */ - @Generated - @Override - public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { - jsonWriter.writeStartObject(); - jsonWriter.writeStringField("name", this.name); - return jsonWriter.writeEndObject(); - } - - /** - * Reads an instance of ResourceC from the JsonReader. - * - * @param jsonReader The JsonReader being read. - * @return An instance of ResourceC if the JsonReader was pointing to an instance of it, or null if it was pointing - * to JSON null. - * @throws IllegalStateException If the deserialized JSON object was missing any required properties. - * @throws IOException If an error occurs while reading the ResourceC. - */ - @Generated - public static ResourceC fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject(reader -> { - String id = null; - String name = null; - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); - - if ("id".equals(fieldName)) { - id = reader.getString(); - } else if ("name".equals(fieldName)) { - name = reader.getString(); - } else { - reader.skipChildren(); - } - } - ResourceC deserializedResourceC = new ResourceC(name); - deserializedResourceC.id = id; - - return deserializedResourceC; - }); - } -} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/protocolandconvenient/models/ResourceG.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/protocolandconvenient/models/ResourceG.java deleted file mode 100644 index 552bcf8d04..0000000000 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/protocolandconvenient/models/ResourceG.java +++ /dev/null @@ -1,105 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) TypeSpec Code Generator. - -package com.cadl.protocolandconvenient.models; - -import com.azure.core.annotation.Generated; -import com.azure.core.annotation.Immutable; -import com.azure.json.JsonReader; -import com.azure.json.JsonSerializable; -import com.azure.json.JsonToken; -import com.azure.json.JsonWriter; -import java.io.IOException; - -/** - * The ResourceG model. - */ -@Immutable -public final class ResourceG implements JsonSerializable { - /* - * The id property. - */ - @Generated - private String id; - - /* - * The name property. - */ - @Generated - private final String name; - - /** - * Creates an instance of ResourceG class. - * - * @param name the name value to set. - */ - @Generated - public ResourceG(String name) { - this.name = name; - } - - /** - * Get the id property: The id property. - * - * @return the id value. - */ - @Generated - public String getId() { - return this.id; - } - - /** - * Get the name property: The name property. - * - * @return the name value. - */ - @Generated - public String getName() { - return this.name; - } - - /** - * {@inheritDoc} - */ - @Generated - @Override - public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { - jsonWriter.writeStartObject(); - jsonWriter.writeStringField("name", this.name); - return jsonWriter.writeEndObject(); - } - - /** - * Reads an instance of ResourceG from the JsonReader. - * - * @param jsonReader The JsonReader being read. - * @return An instance of ResourceG if the JsonReader was pointing to an instance of it, or null if it was pointing - * to JSON null. - * @throws IllegalStateException If the deserialized JSON object was missing any required properties. - * @throws IOException If an error occurs while reading the ResourceG. - */ - @Generated - public static ResourceG fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject(reader -> { - String id = null; - String name = null; - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); - - if ("id".equals(fieldName)) { - id = reader.getString(); - } else if ("name".equals(fieldName)) { - name = reader.getString(); - } else { - reader.skipChildren(); - } - } - ResourceG deserializedResourceG = new ResourceG(name); - deserializedResourceG.id = id; - - return deserializedResourceG; - }); - } -} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/structure/service/models/ClientType.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/structure/service/models/ClientType.java index ea56f83d74..d77c15cdd1 100644 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/structure/service/models/ClientType.java +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/structure/service/models/ClientType.java @@ -26,7 +26,12 @@ public enum ClientType { /** * Enum value two-operation-group. */ - TWO_OPERATION_GROUP("two-operation-group"); + TWO_OPERATION_GROUP("two-operation-group"), + + /** + * Enum value client-operation-group. + */ + CLIENT_OPERATION_GROUP("client-operation-group"); /** * The actual serialized value for a ClientType instance. diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/cadl-builtin_apiview_properties.json b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/cadl-builtin_apiview_properties.json index 26a497a95e..e8050fdba3 100644 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/cadl-builtin_apiview_properties.json +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/cadl-builtin_apiview_properties.json @@ -4,13 +4,9 @@ "com.cadl.builtin.BuiltinAsyncClient": "null", "com.cadl.builtin.BuiltinAsyncClient.read": "Cadl.Builtin.BuiltinOp.read", "com.cadl.builtin.BuiltinAsyncClient.readWithResponse": "Cadl.Builtin.BuiltinOp.read", - "com.cadl.builtin.BuiltinAsyncClient.write": "Cadl.Builtin.BuiltinOp.write", - "com.cadl.builtin.BuiltinAsyncClient.writeWithResponse": "Cadl.Builtin.BuiltinOp.write", "com.cadl.builtin.BuiltinClient": "null", "com.cadl.builtin.BuiltinClient.read": "Cadl.Builtin.BuiltinOp.read", "com.cadl.builtin.BuiltinClient.readWithResponse": "Cadl.Builtin.BuiltinOp.read", - "com.cadl.builtin.BuiltinClient.write": "Cadl.Builtin.BuiltinOp.write", - "com.cadl.builtin.BuiltinClient.writeWithResponse": "Cadl.Builtin.BuiltinOp.write", "com.cadl.builtin.BuiltinClientBuilder": "Cadl.Builtin", "com.cadl.builtin.models.Builtin": "Cadl.Builtin.Builtin", "com.cadl.builtin.models.Encoded": "Cadl.Builtin.Encoded" diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/cadl-internal_apiview_properties.json b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/cadl-internal_apiview_properties.json index 2e3cb8b499..9ce9484730 100644 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/cadl-internal_apiview_properties.json +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/cadl-internal_apiview_properties.json @@ -14,7 +14,6 @@ "com.cadl.internal.InternalClientBuilder": "Cadl.Internal", "com.cadl.internal.implementation.models.Color": "Cadl.Internal.Color", "com.cadl.internal.implementation.models.ColorModel": "Cadl.Internal.ColorModel", - "com.cadl.internal.implementation.models.ProtocolInternalModel": "Cadl.Internal.ProtocolInternalModel", "com.cadl.internal.models.ApiRequest": "Cadl.Internal.ApiRequest", "com.cadl.internal.models.ApiResponse": "Cadl.Internal.ApiResponse", "com.cadl.internal.models.RequestInner": "Cadl.Internal.RequestInner", diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/cadl-longrunning_apiview_properties.json b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/cadl-longrunning_apiview_properties.json index 1bb4928f3b..77ec49c70a 100644 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/cadl-longrunning_apiview_properties.json +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/cadl-longrunning_apiview_properties.json @@ -21,7 +21,6 @@ "com.cadl.longrunning.models.JobResultResult": "Cadl.LongRunning.JobResult.result.anonymous", "com.cadl.longrunning.models.JobStatus": "Cadl.LongRunning.JobStatus", "com.cadl.longrunning.models.LroOperationStatusError": "Cadl.LongRunning.LroOperationStatus", - "com.cadl.longrunning.models.OperationState": "Azure.Core.Foundations.OperationState", "com.cadl.longrunning.models.PollResponse": "Cadl.LongRunning.PollResponse", "com.cadl.longrunning.models.RepeatabilityResult": "Azure.Core.RepeatabilityResult" } diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/cadl-protocolandconvenient_apiview_properties.json b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/cadl-protocolandconvenient_apiview_properties.json index 81c4a70987..6e4588b7c8 100644 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/cadl-protocolandconvenient_apiview_properties.json +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/cadl-protocolandconvenient_apiview_properties.json @@ -20,11 +20,9 @@ "com.cadl.protocolandconvenient.ProtocolAndConvenientClientBuilder": "Cadl.ProtocolAndConvenient", "com.cadl.protocolandconvenient.models.ResourceA": "Cadl.ProtocolAndConvenient.ResourceA", "com.cadl.protocolandconvenient.models.ResourceB": "Cadl.ProtocolAndConvenient.ResourceB", - "com.cadl.protocolandconvenient.models.ResourceC": "Cadl.ProtocolAndConvenient.ResourceC", "com.cadl.protocolandconvenient.models.ResourceD": "Cadl.ProtocolAndConvenient.ResourceD", "com.cadl.protocolandconvenient.models.ResourceE": "Cadl.ProtocolAndConvenient.ResourceE", "com.cadl.protocolandconvenient.models.ResourceF": "Cadl.ProtocolAndConvenient.ResourceF", - "com.cadl.protocolandconvenient.models.ResourceG": "Cadl.ProtocolAndConvenient.ResourceG", "com.cadl.protocolandconvenient.models.ResourceH": "Cadl.ProtocolAndConvenient.ResourceH", "com.cadl.protocolandconvenient.models.ResourceI": "Cadl.ProtocolAndConvenient.ResourceI", "com.cadl.protocolandconvenient.models.ResourceJ": "Cadl.ProtocolAndConvenient.ResourceJ" From 515b1348c347d10f9074cab7322a70814838fcbd Mon Sep 17 00:00:00 2001 From: Haoling Dong <87355844+haolingdong-msft@users.noreply.github.com> Date: Thu, 24 Oct 2024 14:27:30 +0800 Subject: [PATCH 12/26] update multiple content types case --- ...tipleContentTypesOnRequestAsyncClient.java | 29 -------- .../MultipleContentTypesOnRequestClient.java | 27 ------- ...orMultiContentTypesRequestContentType.java | 63 ----------------- ...orMultiContentTypesRequestContentType.java | 68 ------------------ ...orMultiContentTypesRequestContentType.java | 70 ------------------- ...-multicontenttypes_apiview_properties.json | 7 -- .../tsp/multiple-content-types.tsp | 6 +- 7 files changed, 5 insertions(+), 265 deletions(-) delete mode 100644 packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multicontenttypes/models/UploadBytesWithMultiBodyTypesForMultiContentTypesRequestContentType.java delete mode 100644 packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multicontenttypes/models/UploadBytesWithSingleBodyTypeForMultiContentTypesRequestContentType.java delete mode 100644 packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multicontenttypes/models/UploadJsonOrBytesWithMultiBodyTypesForMultiContentTypesRequestContentType.java diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multicontenttypes/MultipleContentTypesOnRequestAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multicontenttypes/MultipleContentTypesOnRequestAsyncClient.java index 1140682b49..f78240f7a0 100644 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multicontenttypes/MultipleContentTypesOnRequestAsyncClient.java +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multicontenttypes/MultipleContentTypesOnRequestAsyncClient.java @@ -15,9 +15,7 @@ import com.azure.core.http.rest.RequestOptions; import com.azure.core.http.rest.Response; import com.azure.core.util.BinaryData; -import com.azure.core.util.FluxUtil; import com.cadl.multicontenttypes.implementation.MultipleContentTypesOnRequestsImpl; -import com.cadl.multicontenttypes.models.Resource; import reactor.core.publisher.Mono; /** @@ -62,8 +60,6 @@ public final class MultipleContentTypesOnRequestAsyncClient { @ServiceMethod(returns = ReturnType.SINGLE) public Mono> uploadBytesWithSingleBodyTypeForMultiContentTypesWithResponse(String contentType, BinaryData data, RequestOptions requestOptions) { - // Convenience API is not generated, as operation 'uploadBytesWithSingleBodyTypeForMultiContentTypes' is - // multiple content-type return this.serviceClient.uploadBytesWithSingleBodyTypeForMultiContentTypesWithResponseAsync(contentType, data, requestOptions); } @@ -92,8 +88,6 @@ public Mono> uploadBytesWithSingleBodyTypeForMultiContentTypesWit @ServiceMethod(returns = ReturnType.SINGLE) public Mono> uploadBytesWithMultiBodyTypesForMultiContentTypesWithResponse(String contentType, BinaryData data, RequestOptions requestOptions) { - // Convenience API is not generated, as operation 'uploadBytesWithMultiBodyTypesForMultiContentTypes' is - // multiple content-type return this.serviceClient.uploadBytesWithMultiBodyTypesForMultiContentTypesWithResponseAsync(contentType, data, requestOptions); } @@ -151,30 +145,7 @@ public Mono> uploadJsonWithMultiBodyTypesForMultiContentTypesWith @ServiceMethod(returns = ReturnType.SINGLE) public Mono> uploadJsonOrBytesWithMultiBodyTypesForMultiContentTypesWithResponse(String contentType, BinaryData data, RequestOptions requestOptions) { - // Convenience API is not generated, as operation 'uploadJsonOrBytesWithMultiBodyTypesForMultiContentTypes' is - // multiple content-type return this.serviceClient.uploadJsonOrBytesWithMultiBodyTypesForMultiContentTypesWithResponseAsync(contentType, data, requestOptions); } - - /** - * multiple data types map to multiple content types using shared route. - * - * @param data The data parameter. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws HttpResponseException thrown if the request is rejected by server. - * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. - * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. - * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return A {@link Mono} that completes when a successful response is received. - */ - @Generated - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono uploadJsonWithMultiBodyTypesForMultiContentTypes(Resource data) { - // Generated convenience method for uploadJsonWithMultiBodyTypesForMultiContentTypesWithResponse - RequestOptions requestOptions = new RequestOptions(); - return uploadJsonWithMultiBodyTypesForMultiContentTypesWithResponse(BinaryData.fromObject(data), requestOptions) - .flatMap(FluxUtil::toMono); - } } diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multicontenttypes/MultipleContentTypesOnRequestClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multicontenttypes/MultipleContentTypesOnRequestClient.java index d4868648ef..7f7d4367d9 100644 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multicontenttypes/MultipleContentTypesOnRequestClient.java +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multicontenttypes/MultipleContentTypesOnRequestClient.java @@ -16,7 +16,6 @@ import com.azure.core.http.rest.Response; import com.azure.core.util.BinaryData; import com.cadl.multicontenttypes.implementation.MultipleContentTypesOnRequestsImpl; -import com.cadl.multicontenttypes.models.Resource; /** * Initializes a new instance of the synchronous MultiContentTypesClient type. @@ -60,8 +59,6 @@ public final class MultipleContentTypesOnRequestClient { @ServiceMethod(returns = ReturnType.SINGLE) public Response uploadBytesWithSingleBodyTypeForMultiContentTypesWithResponse(String contentType, BinaryData data, RequestOptions requestOptions) { - // Convenience API is not generated, as operation 'uploadBytesWithSingleBodyTypeForMultiContentTypes' is - // multiple content-type return this.serviceClient.uploadBytesWithSingleBodyTypeForMultiContentTypesWithResponse(contentType, data, requestOptions); } @@ -90,8 +87,6 @@ public Response uploadBytesWithSingleBodyTypeForMultiContentTypesWithRespo @ServiceMethod(returns = ReturnType.SINGLE) public Response uploadBytesWithMultiBodyTypesForMultiContentTypesWithResponse(String contentType, BinaryData data, RequestOptions requestOptions) { - // Convenience API is not generated, as operation 'uploadBytesWithMultiBodyTypesForMultiContentTypes' is - // multiple content-type return this.serviceClient.uploadBytesWithMultiBodyTypesForMultiContentTypesWithResponse(contentType, data, requestOptions); } @@ -148,29 +143,7 @@ public Response uploadJsonWithMultiBodyTypesForMultiContentTypesWithRespon @ServiceMethod(returns = ReturnType.SINGLE) public Response uploadJsonOrBytesWithMultiBodyTypesForMultiContentTypesWithResponse(String contentType, BinaryData data, RequestOptions requestOptions) { - // Convenience API is not generated, as operation 'uploadJsonOrBytesWithMultiBodyTypesForMultiContentTypes' is - // multiple content-type return this.serviceClient.uploadJsonOrBytesWithMultiBodyTypesForMultiContentTypesWithResponse(contentType, data, requestOptions); } - - /** - * multiple data types map to multiple content types using shared route. - * - * @param data The data parameter. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws HttpResponseException thrown if the request is rejected by server. - * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. - * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. - * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - */ - @Generated - @ServiceMethod(returns = ReturnType.SINGLE) - public void uploadJsonWithMultiBodyTypesForMultiContentTypes(Resource data) { - // Generated convenience method for uploadJsonWithMultiBodyTypesForMultiContentTypesWithResponse - RequestOptions requestOptions = new RequestOptions(); - uploadJsonWithMultiBodyTypesForMultiContentTypesWithResponse(BinaryData.fromObject(data), requestOptions) - .getValue(); - } } diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multicontenttypes/models/UploadBytesWithMultiBodyTypesForMultiContentTypesRequestContentType.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multicontenttypes/models/UploadBytesWithMultiBodyTypesForMultiContentTypesRequestContentType.java deleted file mode 100644 index 1e80e500aa..0000000000 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multicontenttypes/models/UploadBytesWithMultiBodyTypesForMultiContentTypesRequestContentType.java +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) TypeSpec Code Generator. - -package com.cadl.multicontenttypes.models; - -/** - * Defines values for UploadBytesWithMultiBodyTypesForMultiContentTypesRequestContentType. - */ -public enum UploadBytesWithMultiBodyTypesForMultiContentTypesRequestContentType { - /** - * Enum value application/octet-stream. - */ - APPLICATION_OCTET_STREAM("application/octet-stream"), - - /** - * Enum value image/jpeg. - */ - IMAGE_JPEG("image/jpeg"), - - /** - * Enum value image/png. - */ - IMAGE_PNG("image/png"); - - /** - * The actual serialized value for a UploadBytesWithMultiBodyTypesForMultiContentTypesRequestContentType instance. - */ - private final String value; - - UploadBytesWithMultiBodyTypesForMultiContentTypesRequestContentType(String value) { - this.value = value; - } - - /** - * Parses a serialized value to a UploadBytesWithMultiBodyTypesForMultiContentTypesRequestContentType instance. - * - * @param value the serialized value to parse. - * @return the parsed UploadBytesWithMultiBodyTypesForMultiContentTypesRequestContentType object, or null if unable - * to parse. - */ - public static UploadBytesWithMultiBodyTypesForMultiContentTypesRequestContentType fromString(String value) { - if (value == null) { - return null; - } - UploadBytesWithMultiBodyTypesForMultiContentTypesRequestContentType[] items - = UploadBytesWithMultiBodyTypesForMultiContentTypesRequestContentType.values(); - for (UploadBytesWithMultiBodyTypesForMultiContentTypesRequestContentType item : items) { - if (item.toString().equalsIgnoreCase(value)) { - return item; - } - } - return null; - } - - /** - * {@inheritDoc} - */ - @Override - public String toString() { - return this.value; - } -} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multicontenttypes/models/UploadBytesWithSingleBodyTypeForMultiContentTypesRequestContentType.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multicontenttypes/models/UploadBytesWithSingleBodyTypeForMultiContentTypesRequestContentType.java deleted file mode 100644 index f61569a68c..0000000000 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multicontenttypes/models/UploadBytesWithSingleBodyTypeForMultiContentTypesRequestContentType.java +++ /dev/null @@ -1,68 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) TypeSpec Code Generator. - -package com.cadl.multicontenttypes.models; - -/** - * Defines values for UploadBytesWithSingleBodyTypeForMultiContentTypesRequestContentType. - */ -public enum UploadBytesWithSingleBodyTypeForMultiContentTypesRequestContentType { - /** - * Enum value application/octet-stream. - */ - APPLICATION_OCTET_STREAM("application/octet-stream"), - - /** - * Enum value image/jpeg. - */ - IMAGE_JPEG("image/jpeg"), - - /** - * Enum value image/png. - */ - IMAGE_PNG("image/png"), - - /** - * Enum value application/json-patch+json. - */ - APPLICATION_JSON_PATCH_JSON("application/json-patch+json"); - - /** - * The actual serialized value for a UploadBytesWithSingleBodyTypeForMultiContentTypesRequestContentType instance. - */ - private final String value; - - UploadBytesWithSingleBodyTypeForMultiContentTypesRequestContentType(String value) { - this.value = value; - } - - /** - * Parses a serialized value to a UploadBytesWithSingleBodyTypeForMultiContentTypesRequestContentType instance. - * - * @param value the serialized value to parse. - * @return the parsed UploadBytesWithSingleBodyTypeForMultiContentTypesRequestContentType object, or null if unable - * to parse. - */ - public static UploadBytesWithSingleBodyTypeForMultiContentTypesRequestContentType fromString(String value) { - if (value == null) { - return null; - } - UploadBytesWithSingleBodyTypeForMultiContentTypesRequestContentType[] items - = UploadBytesWithSingleBodyTypeForMultiContentTypesRequestContentType.values(); - for (UploadBytesWithSingleBodyTypeForMultiContentTypesRequestContentType item : items) { - if (item.toString().equalsIgnoreCase(value)) { - return item; - } - } - return null; - } - - /** - * {@inheritDoc} - */ - @Override - public String toString() { - return this.value; - } -} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multicontenttypes/models/UploadJsonOrBytesWithMultiBodyTypesForMultiContentTypesRequestContentType.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multicontenttypes/models/UploadJsonOrBytesWithMultiBodyTypesForMultiContentTypesRequestContentType.java deleted file mode 100644 index a1210715ed..0000000000 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multicontenttypes/models/UploadJsonOrBytesWithMultiBodyTypesForMultiContentTypesRequestContentType.java +++ /dev/null @@ -1,70 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) TypeSpec Code Generator. - -package com.cadl.multicontenttypes.models; - -/** - * Defines values for UploadJsonOrBytesWithMultiBodyTypesForMultiContentTypesRequestContentType. - */ -public enum UploadJsonOrBytesWithMultiBodyTypesForMultiContentTypesRequestContentType { - /** - * Enum value application/json. - */ - APPLICATION_JSON("application/json"), - - /** - * Enum value application/octet-stream. - */ - APPLICATION_OCTET_STREAM("application/octet-stream"), - - /** - * Enum value image/jpeg. - */ - IMAGE_JPEG("image/jpeg"), - - /** - * Enum value image/png. - */ - IMAGE_PNG("image/png"); - - /** - * The actual serialized value for a UploadJsonOrBytesWithMultiBodyTypesForMultiContentTypesRequestContentType - * instance. - */ - private final String value; - - UploadJsonOrBytesWithMultiBodyTypesForMultiContentTypesRequestContentType(String value) { - this.value = value; - } - - /** - * Parses a serialized value to a UploadJsonOrBytesWithMultiBodyTypesForMultiContentTypesRequestContentType - * instance. - * - * @param value the serialized value to parse. - * @return the parsed UploadJsonOrBytesWithMultiBodyTypesForMultiContentTypesRequestContentType object, or null if - * unable to parse. - */ - public static UploadJsonOrBytesWithMultiBodyTypesForMultiContentTypesRequestContentType fromString(String value) { - if (value == null) { - return null; - } - UploadJsonOrBytesWithMultiBodyTypesForMultiContentTypesRequestContentType[] items - = UploadJsonOrBytesWithMultiBodyTypesForMultiContentTypesRequestContentType.values(); - for (UploadJsonOrBytesWithMultiBodyTypesForMultiContentTypesRequestContentType item : items) { - if (item.toString().equalsIgnoreCase(value)) { - return item; - } - } - return null; - } - - /** - * {@inheritDoc} - */ - @Override - public String toString() { - return this.value; - } -} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/cadl-multicontenttypes_apiview_properties.json b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/cadl-multicontenttypes_apiview_properties.json index 5616a96f96..01c3a87e99 100644 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/cadl-multicontenttypes_apiview_properties.json +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/cadl-multicontenttypes_apiview_properties.json @@ -5,11 +5,7 @@ "com.cadl.multicontenttypes.MultiContentTypesClient": "Cadl.MultiContentTypes", "com.cadl.multicontenttypes.MultiContentTypesClientBuilder": "Cadl.MultiContentTypes", "com.cadl.multicontenttypes.MultipleContentTypesOnRequestAsyncClient": "null", - "com.cadl.multicontenttypes.MultipleContentTypesOnRequestAsyncClient.uploadJsonWithMultiBodyTypesForMultiContentTypes": "Cadl.MultiContentTypes.MultipleContentTypesOnRequest.uploadJsonWithMultiBodyTypesForMultiContentTypes", - "com.cadl.multicontenttypes.MultipleContentTypesOnRequestAsyncClient.uploadJsonWithMultiBodyTypesForMultiContentTypesWithResponse": "Cadl.MultiContentTypes.MultipleContentTypesOnRequest.uploadJsonWithMultiBodyTypesForMultiContentTypes", "com.cadl.multicontenttypes.MultipleContentTypesOnRequestClient": "null", - "com.cadl.multicontenttypes.MultipleContentTypesOnRequestClient.uploadJsonWithMultiBodyTypesForMultiContentTypes": "Cadl.MultiContentTypes.MultipleContentTypesOnRequest.uploadJsonWithMultiBodyTypesForMultiContentTypes", - "com.cadl.multicontenttypes.MultipleContentTypesOnRequestClient.uploadJsonWithMultiBodyTypesForMultiContentTypesWithResponse": "Cadl.MultiContentTypes.MultipleContentTypesOnRequest.uploadJsonWithMultiBodyTypesForMultiContentTypes", "com.cadl.multicontenttypes.SingleContentTypeAsyncClient": "null", "com.cadl.multicontenttypes.SingleContentTypeAsyncClient.downloadImageForSingleContentType": "Cadl.MultiContentTypes.SingleContentType.downloadImageForSingleContentType", "com.cadl.multicontenttypes.SingleContentTypeAsyncClient.downloadImageForSingleContentTypeWithResponse": "Cadl.MultiContentTypes.SingleContentType.downloadImageForSingleContentType", @@ -21,9 +17,6 @@ "com.cadl.multicontenttypes.SingleContentTypeClient.uploadImageForSingleContentType": "Cadl.MultiContentTypes.SingleContentType.uploadImageForSingleContentType", "com.cadl.multicontenttypes.SingleContentTypeClient.uploadImageForSingleContentTypeWithResponse": "Cadl.MultiContentTypes.SingleContentType.uploadImageForSingleContentType", "com.cadl.multicontenttypes.models.Resource": "Cadl.MultiContentTypes.Resource", - "com.cadl.multicontenttypes.models.UploadBytesWithMultiBodyTypesForMultiContentTypesRequestContentType": "uploadBytesWithMultiBodyTypesForMultiContentTypes.RequestContentType.anonymous", - "com.cadl.multicontenttypes.models.UploadBytesWithSingleBodyTypeForMultiContentTypesRequestContentType": "uploadBytesWithSingleBodyTypeForMultiContentTypes.RequestContentType.anonymous", - "com.cadl.multicontenttypes.models.UploadJsonOrBytesWithMultiBodyTypesForMultiContentTypesRequestContentType": "uploadJsonOrBytesWithMultiBodyTypesForMultiContentTypes.RequestContentType.anonymous", "com.cadl.multicontenttypes.models.UploadWithOverloadRequestContentType": "uploadWithOverload.RequestContentType.anonymous" } } diff --git a/packages/http-client-java/generator/http-client-generator-test/tsp/multiple-content-types.tsp b/packages/http-client-java/generator/http-client-generator-test/tsp/multiple-content-types.tsp index a902677827..68017c0124 100644 --- a/packages/http-client-java/generator/http-client-generator-test/tsp/multiple-content-types.tsp +++ b/packages/http-client-java/generator/http-client-generator-test/tsp/multiple-content-types.tsp @@ -40,6 +40,7 @@ interface MultipleContentTypesOnRequest { @doc("one data type maps to multiple content types") @route("upload/single-body-type") @post + @convenientAPI(false) uploadBytesWithSingleBodyTypeForMultiContentTypes( @body data: bytes, @header contentType: @@ -53,6 +54,7 @@ interface MultipleContentTypesOnRequest { @route("upload/multi-body-types") @sharedRoute @post + @convenientAPI(false) uploadBytesWithMultiBodyTypesForMultiContentTypes( @body data: bytes, @header contentType: "application/octet-stream" | "image/jpeg" | "image/png", @@ -62,6 +64,7 @@ interface MultipleContentTypesOnRequest { @route("upload/multi-body-types") @sharedRoute @post + @convenientAPI(false) uploadJsonWithMultiBodyTypesForMultiContentTypes( @body data: Resource, @header contentType: "application/json", @@ -71,6 +74,7 @@ interface MultipleContentTypesOnRequest { @route("upload/multi-body-types") @sharedRoute @post + @convenientAPI(false) uploadJsonOrBytesWithMultiBodyTypesForMultiContentTypes( @body data: bytes | Resource, @header contentType: @@ -125,7 +129,7 @@ op uploadStringWithOverload(@body data: string, @header contentType: "text/plain @doc("multiple data types map to multiple content types using `@overload`") @route("upload/overload/multi-body-types") @post -@overload(uploadWithOverload) +@overload(uploadWithOverload) op uploadImagesWithOverload( @body data: bytes, @header contentType: "image/jpeg" | "image/png", From e5947e314b2e4393b790adb7d052ebd7f498fcfe Mon Sep 17 00:00:00 2001 From: Haoling Dong <87355844+haolingdong-msft@users.noreply.github.com> Date: Fri, 25 Oct 2024 11:31:49 +0800 Subject: [PATCH 13/26] Remove unnecessary trackSchemaUsage --- .../emitter/src/code-model-builder.ts | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/packages/http-client-java/emitter/src/code-model-builder.ts b/packages/http-client-java/emitter/src/code-model-builder.ts index 735f713fcf..44245933ca 100644 --- a/packages/http-client-java/emitter/src/code-model-builder.ts +++ b/packages/http-client-java/emitter/src/code-model-builder.ts @@ -397,9 +397,9 @@ export class CodeModelBuilder { } else if (access === "internal") { const schema = this.processSchema(model, model.name); - trackSchemaUsage(schema, { - usage: [SchemaContext.Internal], - }); + // trackSchemaUsage(schema, { + // usage: [SchemaContext.Internal], + // }); } const usage = getUsage(model.__raw, usageCache); @@ -1009,14 +1009,14 @@ export class CodeModelBuilder { }); } } - if (finalSchema) { - this.trackSchemaUsage(finalSchema, { usage: [SchemaContext.Output] }); - if (trackConvenienceApi) { - this.trackSchemaUsage(finalSchema, { - usage: [op.internalApi ? SchemaContext.Internal : SchemaContext.Public], - }); - } - } + // if (finalSchema) { + // this.trackSchemaUsage(finalSchema, { usage: [SchemaContext.Output] }); + // if (trackConvenienceApi) { + // this.trackSchemaUsage(finalSchema, { + // usage: [op.internalApi ? SchemaContext.Internal : SchemaContext.Public], + // }); + // } + // } op.lroMetadata = new LongRunningMetadata( true, @@ -1434,8 +1434,8 @@ export class CodeModelBuilder { return; } - const schemaUsage = (schema as SchemaUsage).usage; - trackSchemaUsage(schema, { usage: schemaUsage }); + // const schemaUsage = (schema as SchemaUsage).usage; + // trackSchemaUsage(schema, { usage: schemaUsage }); // if (!schemaIsPublicBeforeProcess && schemaUsage?.includes(SchemaContext.Public)) { // // Public added in this op, change it to PublicSpread // // This means that if this op would originally add Public to this schema, it adds PublicSpread instead From 823916018639899cee9e97cc9748e32835c450bc Mon Sep 17 00:00:00 2001 From: Haoling Dong <87355844+haolingdong-msft@users.noreply.github.com> Date: Fri, 25 Oct 2024 17:26:44 +0800 Subject: [PATCH 14/26] update test case as the definition is invalid --- .../cadl/enumservice/models/Operation.java | 42 +++++++++++++++++-- .../http-client-generator-test/tsp/enum.tsp | 2 +- 2 files changed, 40 insertions(+), 4 deletions(-) diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/enumservice/models/Operation.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/enumservice/models/Operation.java index 52e33beb4f..9d7002f5a5 100644 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/enumservice/models/Operation.java +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/enumservice/models/Operation.java @@ -4,8 +4,8 @@ package com.cadl.enumservice.models; +import com.azure.core.annotation.Fluent; import com.azure.core.annotation.Generated; -import com.azure.core.annotation.Immutable; import com.azure.json.JsonReader; import com.azure.json.JsonSerializable; import com.azure.json.JsonToken; @@ -15,7 +15,7 @@ /** * The Operation model. */ -@Immutable +@Fluent public final class Operation implements JsonSerializable { /* * The name property. @@ -98,7 +98,7 @@ public final class Operation implements JsonSerializable { * @param unit the unit value to set. */ @Generated - private Operation(OperationName name, Priority priority, ColorModel color, Unit unit) { + public Operation(OperationName name, Priority priority, ColorModel color, Unit unit) { this.name = name; this.priority = priority; this.color = color; @@ -205,6 +205,18 @@ public Unit getUnitValue() { return this.unitValue; } + /** + * Set the unitValue property: The unitValue property. + * + * @param unitValue the unitValue value to set. + * @return the Operation object itself. + */ + @Generated + public Operation setUnitValue(Unit unitValue) { + this.unitValue = unitValue; + return this; + } + /** * Get the olympicRecord property: The olympicRecord property. * @@ -215,6 +227,18 @@ public OlympicRecordModel getOlympicRecord() { return this.olympicRecord; } + /** + * Set the olympicRecord property: The olympicRecord property. + * + * @param olympicRecord the olympicRecord value to set. + * @return the Operation object itself. + */ + @Generated + public Operation setOlympicRecord(OlympicRecordModel olympicRecord) { + this.olympicRecord = olympicRecord; + return this; + } + /** * Get the olympicRecordValue property: The olympicRecordValue property. * @@ -225,6 +249,18 @@ public OlympicRecordModel getOlympicRecordValue() { return this.olympicRecordValue; } + /** + * Set the olympicRecordValue property: The olympicRecordValue property. + * + * @param olympicRecordValue the olympicRecordValue value to set. + * @return the Operation object itself. + */ + @Generated + public Operation setOlympicRecordValue(OlympicRecordModel olympicRecordValue) { + this.olympicRecordValue = olympicRecordValue; + return this; + } + /** * {@inheritDoc} */ diff --git a/packages/http-client-java/generator/http-client-generator-test/tsp/enum.tsp b/packages/http-client-java/generator/http-client-generator-test/tsp/enum.tsp index 34de706783..52f7d98040 100644 --- a/packages/http-client-java/generator/http-client-generator-test/tsp/enum.tsp +++ b/packages/http-client-java/generator/http-client-generator-test/tsp/enum.tsp @@ -63,7 +63,7 @@ enum OperationStateValues { Failed, } -@usage(Usage.input) +@usage(Usage.input | Usage.output) model Operation { name: "Read" | "Write"; best: true; From 1589891c0e154da833ec2b0b8b4ad2d10babf9ef Mon Sep 17 00:00:00 2001 From: Haoling Dong <87355844+haolingdong-msft@users.noreply.github.com> Date: Fri, 25 Oct 2024 17:33:59 +0800 Subject: [PATCH 15/26] update multi content type case --- ...tipleContentTypesOnRequestAsyncClient.java | 23 +++++++++++++++++++ .../MultipleContentTypesOnRequestClient.java | 21 +++++++++++++++++ .../tsp/multiple-content-types.tsp | 1 - 3 files changed, 44 insertions(+), 1 deletion(-) diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multicontenttypes/MultipleContentTypesOnRequestAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multicontenttypes/MultipleContentTypesOnRequestAsyncClient.java index f78240f7a0..bb53d2fc98 100644 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multicontenttypes/MultipleContentTypesOnRequestAsyncClient.java +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multicontenttypes/MultipleContentTypesOnRequestAsyncClient.java @@ -15,7 +15,9 @@ import com.azure.core.http.rest.RequestOptions; import com.azure.core.http.rest.Response; import com.azure.core.util.BinaryData; +import com.azure.core.util.FluxUtil; import com.cadl.multicontenttypes.implementation.MultipleContentTypesOnRequestsImpl; +import com.cadl.multicontenttypes.models.Resource; import reactor.core.publisher.Mono; /** @@ -148,4 +150,25 @@ public Mono> uploadJsonOrBytesWithMultiBodyTypesForMultiContentTy return this.serviceClient.uploadJsonOrBytesWithMultiBodyTypesForMultiContentTypesWithResponseAsync(contentType, data, requestOptions); } + + /** + * multiple data types map to multiple content types using shared route. + * + * @param data The data parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return A {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono uploadJsonWithMultiBodyTypesForMultiContentTypes(Resource data) { + // Generated convenience method for uploadJsonWithMultiBodyTypesForMultiContentTypesWithResponse + RequestOptions requestOptions = new RequestOptions(); + return uploadJsonWithMultiBodyTypesForMultiContentTypesWithResponse(BinaryData.fromObject(data), requestOptions) + .flatMap(FluxUtil::toMono); + } } diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multicontenttypes/MultipleContentTypesOnRequestClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multicontenttypes/MultipleContentTypesOnRequestClient.java index 7f7d4367d9..5065439c73 100644 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multicontenttypes/MultipleContentTypesOnRequestClient.java +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multicontenttypes/MultipleContentTypesOnRequestClient.java @@ -16,6 +16,7 @@ import com.azure.core.http.rest.Response; import com.azure.core.util.BinaryData; import com.cadl.multicontenttypes.implementation.MultipleContentTypesOnRequestsImpl; +import com.cadl.multicontenttypes.models.Resource; /** * Initializes a new instance of the synchronous MultiContentTypesClient type. @@ -146,4 +147,24 @@ public Response uploadJsonOrBytesWithMultiBodyTypesForMultiContentTypesWit return this.serviceClient.uploadJsonOrBytesWithMultiBodyTypesForMultiContentTypesWithResponse(contentType, data, requestOptions); } + + /** + * multiple data types map to multiple content types using shared route. + * + * @param data The data parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void uploadJsonWithMultiBodyTypesForMultiContentTypes(Resource data) { + // Generated convenience method for uploadJsonWithMultiBodyTypesForMultiContentTypesWithResponse + RequestOptions requestOptions = new RequestOptions(); + uploadJsonWithMultiBodyTypesForMultiContentTypesWithResponse(BinaryData.fromObject(data), requestOptions) + .getValue(); + } } diff --git a/packages/http-client-java/generator/http-client-generator-test/tsp/multiple-content-types.tsp b/packages/http-client-java/generator/http-client-generator-test/tsp/multiple-content-types.tsp index 68017c0124..8b3f67f073 100644 --- a/packages/http-client-java/generator/http-client-generator-test/tsp/multiple-content-types.tsp +++ b/packages/http-client-java/generator/http-client-generator-test/tsp/multiple-content-types.tsp @@ -64,7 +64,6 @@ interface MultipleContentTypesOnRequest { @route("upload/multi-body-types") @sharedRoute @post - @convenientAPI(false) uploadJsonWithMultiBodyTypesForMultiContentTypes( @body data: Resource, @header contentType: "application/json", From d1a6c1228f759269dd9a98e60b27fa9cd9bdf048 Mon Sep 17 00:00:00 2001 From: Haoling Dong <87355844+haolingdong-msft@users.noreply.github.com> Date: Fri, 25 Oct 2024 17:36:08 +0800 Subject: [PATCH 16/26] remove enpty space --- .../http-client-generator-test/tsp/multiple-content-types.tsp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/http-client-java/generator/http-client-generator-test/tsp/multiple-content-types.tsp b/packages/http-client-java/generator/http-client-generator-test/tsp/multiple-content-types.tsp index 8b3f67f073..8ec53998ac 100644 --- a/packages/http-client-java/generator/http-client-generator-test/tsp/multiple-content-types.tsp +++ b/packages/http-client-java/generator/http-client-generator-test/tsp/multiple-content-types.tsp @@ -128,7 +128,7 @@ op uploadStringWithOverload(@body data: string, @header contentType: "text/plain @doc("multiple data types map to multiple content types using `@overload`") @route("upload/overload/multi-body-types") @post -@overload(uploadWithOverload) +@overload(uploadWithOverload) op uploadImagesWithOverload( @body data: bytes, @header contentType: "image/jpeg" | "image/png", From a5dadd5584d64304c7a8a4402212df0935f98fed Mon Sep 17 00:00:00 2001 From: Haoling Dong <87355844+haolingdong-msft@users.noreply.github.com> Date: Fri, 25 Oct 2024 17:40:31 +0800 Subject: [PATCH 17/26] update multi content type case --- .../MultiContentTypesAsyncClient.java | 1 - .../MultiContentTypesClient.java | 1 - .../UploadWithOverloadRequestContentType.java | 71 ------------------- .../tsp/multiple-content-types.tsp | 3 + 4 files changed, 3 insertions(+), 73 deletions(-) delete mode 100644 packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multicontenttypes/models/UploadWithOverloadRequestContentType.java diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multicontenttypes/MultiContentTypesAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multicontenttypes/MultiContentTypesAsyncClient.java index d0ab24f48f..e1dfc08018 100644 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multicontenttypes/MultiContentTypesAsyncClient.java +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multicontenttypes/MultiContentTypesAsyncClient.java @@ -60,7 +60,6 @@ public final class MultiContentTypesAsyncClient { @ServiceMethod(returns = ReturnType.SINGLE) public Mono> uploadWithOverloadWithResponse(String contentType, BinaryData data, RequestOptions requestOptions) { - // Convenience API is not generated, as operation 'uploadWithOverload' is multiple content-type return this.serviceClient.uploadWithOverloadWithResponseAsync(contentType, data, requestOptions); } } diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multicontenttypes/MultiContentTypesClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multicontenttypes/MultiContentTypesClient.java index 123da79bb9..f021e7569b 100644 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multicontenttypes/MultiContentTypesClient.java +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multicontenttypes/MultiContentTypesClient.java @@ -59,7 +59,6 @@ public final class MultiContentTypesClient { @ServiceMethod(returns = ReturnType.SINGLE) public Response uploadWithOverloadWithResponse(String contentType, BinaryData data, RequestOptions requestOptions) { - // Convenience API is not generated, as operation 'uploadWithOverload' is multiple content-type return this.serviceClient.uploadWithOverloadWithResponse(contentType, data, requestOptions); } } diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multicontenttypes/models/UploadWithOverloadRequestContentType.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multicontenttypes/models/UploadWithOverloadRequestContentType.java deleted file mode 100644 index e5f877f5da..0000000000 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multicontenttypes/models/UploadWithOverloadRequestContentType.java +++ /dev/null @@ -1,71 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) TypeSpec Code Generator. - -package com.cadl.multicontenttypes.models; - -/** - * Defines values for UploadWithOverloadRequestContentType. - */ -public enum UploadWithOverloadRequestContentType { - /** - * Enum value text/plain. - */ - TEXT_PLAIN("text/plain"), - - /** - * Enum value application/json. - */ - APPLICATION_JSON("application/json"), - - /** - * Enum value application/octet-stream. - */ - APPLICATION_OCTET_STREAM("application/octet-stream"), - - /** - * Enum value image/jpeg. - */ - IMAGE_JPEG("image/jpeg"), - - /** - * Enum value image/png. - */ - IMAGE_PNG("image/png"); - - /** - * The actual serialized value for a UploadWithOverloadRequestContentType instance. - */ - private final String value; - - UploadWithOverloadRequestContentType(String value) { - this.value = value; - } - - /** - * Parses a serialized value to a UploadWithOverloadRequestContentType instance. - * - * @param value the serialized value to parse. - * @return the parsed UploadWithOverloadRequestContentType object, or null if unable to parse. - */ - public static UploadWithOverloadRequestContentType fromString(String value) { - if (value == null) { - return null; - } - UploadWithOverloadRequestContentType[] items = UploadWithOverloadRequestContentType.values(); - for (UploadWithOverloadRequestContentType item : items) { - if (item.toString().equalsIgnoreCase(value)) { - return item; - } - } - return null; - } - - /** - * {@inheritDoc} - */ - @Override - public String toString() { - return this.value; - } -} diff --git a/packages/http-client-java/generator/http-client-generator-test/tsp/multiple-content-types.tsp b/packages/http-client-java/generator/http-client-generator-test/tsp/multiple-content-types.tsp index 8ec53998ac..e83c41d7aa 100644 --- a/packages/http-client-java/generator/http-client-generator-test/tsp/multiple-content-types.tsp +++ b/packages/http-client-java/generator/http-client-generator-test/tsp/multiple-content-types.tsp @@ -109,6 +109,7 @@ interface MultipleContentTypesOnRequest { @doc("multiple data types map to multiple content types") @route("upload/overload/multi-body-types") @post +@convenientAPI(false) op uploadWithOverload( @body data: string | bytes | Resource, @header contentType: @@ -129,6 +130,7 @@ op uploadStringWithOverload(@body data: string, @header contentType: "text/plain @route("upload/overload/multi-body-types") @post @overload(uploadWithOverload) +@convenientAPI(false) op uploadImagesWithOverload( @body data: bytes, @header contentType: "image/jpeg" | "image/png", @@ -138,6 +140,7 @@ op uploadImagesWithOverload( @route("upload/overload/multi-body-types") @post @overload(uploadWithOverload) +@convenientAPI(false) op uploadBytesOrJsonWithOverload( @body data: bytes | Resource, @header contentType: "application/octet-stream" | "image/jpeg" | "image/png" | "application/json", From 823f91a16c652d0141f121ce500ae036ccb099d8 Mon Sep 17 00:00:00 2001 From: Haoling Dong <87355844+haolingdong-msft@users.noreply.github.com> Date: Wed, 30 Oct 2024 11:24:55 +0800 Subject: [PATCH 18/26] regen --- .../cadl-multicontenttypes_apiview_properties.json | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/cadl-multicontenttypes_apiview_properties.json b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/cadl-multicontenttypes_apiview_properties.json index 01c3a87e99..4577e1de5d 100644 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/cadl-multicontenttypes_apiview_properties.json +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/cadl-multicontenttypes_apiview_properties.json @@ -5,7 +5,11 @@ "com.cadl.multicontenttypes.MultiContentTypesClient": "Cadl.MultiContentTypes", "com.cadl.multicontenttypes.MultiContentTypesClientBuilder": "Cadl.MultiContentTypes", "com.cadl.multicontenttypes.MultipleContentTypesOnRequestAsyncClient": "null", + "com.cadl.multicontenttypes.MultipleContentTypesOnRequestAsyncClient.uploadJsonWithMultiBodyTypesForMultiContentTypes": "Cadl.MultiContentTypes.MultipleContentTypesOnRequest.uploadJsonWithMultiBodyTypesForMultiContentTypes", + "com.cadl.multicontenttypes.MultipleContentTypesOnRequestAsyncClient.uploadJsonWithMultiBodyTypesForMultiContentTypesWithResponse": "Cadl.MultiContentTypes.MultipleContentTypesOnRequest.uploadJsonWithMultiBodyTypesForMultiContentTypes", "com.cadl.multicontenttypes.MultipleContentTypesOnRequestClient": "null", + "com.cadl.multicontenttypes.MultipleContentTypesOnRequestClient.uploadJsonWithMultiBodyTypesForMultiContentTypes": "Cadl.MultiContentTypes.MultipleContentTypesOnRequest.uploadJsonWithMultiBodyTypesForMultiContentTypes", + "com.cadl.multicontenttypes.MultipleContentTypesOnRequestClient.uploadJsonWithMultiBodyTypesForMultiContentTypesWithResponse": "Cadl.MultiContentTypes.MultipleContentTypesOnRequest.uploadJsonWithMultiBodyTypesForMultiContentTypes", "com.cadl.multicontenttypes.SingleContentTypeAsyncClient": "null", "com.cadl.multicontenttypes.SingleContentTypeAsyncClient.downloadImageForSingleContentType": "Cadl.MultiContentTypes.SingleContentType.downloadImageForSingleContentType", "com.cadl.multicontenttypes.SingleContentTypeAsyncClient.downloadImageForSingleContentTypeWithResponse": "Cadl.MultiContentTypes.SingleContentType.downloadImageForSingleContentType", @@ -16,7 +20,6 @@ "com.cadl.multicontenttypes.SingleContentTypeClient.downloadImageForSingleContentTypeWithResponse": "Cadl.MultiContentTypes.SingleContentType.downloadImageForSingleContentType", "com.cadl.multicontenttypes.SingleContentTypeClient.uploadImageForSingleContentType": "Cadl.MultiContentTypes.SingleContentType.uploadImageForSingleContentType", "com.cadl.multicontenttypes.SingleContentTypeClient.uploadImageForSingleContentTypeWithResponse": "Cadl.MultiContentTypes.SingleContentType.uploadImageForSingleContentType", - "com.cadl.multicontenttypes.models.Resource": "Cadl.MultiContentTypes.Resource", - "com.cadl.multicontenttypes.models.UploadWithOverloadRequestContentType": "uploadWithOverload.RequestContentType.anonymous" + "com.cadl.multicontenttypes.models.Resource": "Cadl.MultiContentTypes.Resource" } } From 7215520dc67efbc2daf3c6397601952f3b11e29b Mon Sep 17 00:00:00 2001 From: Haoling Dong <87355844+haolingdong-msft@users.noreply.github.com> Date: Wed, 30 Oct 2024 15:46:13 +0800 Subject: [PATCH 19/26] remove unnecessary trackSchemaUsage --- .../emitter/src/code-model-builder.ts | 187 +----------------- 1 file changed, 9 insertions(+), 178 deletions(-) diff --git a/packages/http-client-java/emitter/src/code-model-builder.ts b/packages/http-client-java/emitter/src/code-model-builder.ts index 44245933ca..438f847a88 100644 --- a/packages/http-client-java/emitter/src/code-model-builder.ts +++ b/packages/http-client-java/emitter/src/code-model-builder.ts @@ -70,6 +70,7 @@ import { SdkType, SdkUnionType, createSdkContext, + getAccessOverride, getAllModels, getWireName, isApiVersion, @@ -284,9 +285,6 @@ export class CodeModelBuilder { parameter = this.createApiVersionParameter(arg.name, ParameterLocation.Uri); } else { const schema = this.processSchema(arg.type, arg.name); - trackSchemaUsage(schema, { - usage: [SchemaContext.Input, SchemaContext.Output /*SchemaContext.Public*/], - }); parameter = new Parameter(arg.name, arg.doc ?? "", schema, { implementation: ImplementationLocation.Client, origin: "modelerfour:synthesized/host", @@ -386,32 +384,19 @@ export class CodeModelBuilder { // process sdk models for (const model of sdkModels) { + if (!processedSdkModels.has(model)) { + // For this part, we only process models which explicitly set access and use decorator, + // otherwise, there will be isseus, e.g. for multipart models, we generate our own model, but TCGC returns the original multipart model with public access and input usage, so we will generate the original multipart model which is unexpected const access = getAccess(model.__raw, accessCache); - if (access === "public") { - const schema = this.processSchema(model, ""); - - this.trackSchemaUsage(schema, { - usage: [SchemaContext.Public], - }); - } else if (access === "internal") { - const schema = this.processSchema(model, model.name); - - // trackSchemaUsage(schema, { - // usage: [SchemaContext.Internal], - // }); + if (access) { + this.processSchema(model, ""); } const usage = getUsage(model.__raw, usageCache); if (usage) { - const schema = this.processSchema(model, ""); - - // trackSchemaUsage(schema, { - // usage: usage, - // }); + this.processSchema(model, ""); } - - processedSdkModels.add(model); } } } @@ -1009,14 +994,6 @@ export class CodeModelBuilder { }); } } - // if (finalSchema) { - // this.trackSchemaUsage(finalSchema, { usage: [SchemaContext.Output] }); - // if (trackConvenienceApi) { - // this.trackSchemaUsage(finalSchema, { - // usage: [op.internalApi ? SchemaContext.Internal : SchemaContext.Public], - // }); - // } - // } op.lroMetadata = new LongRunningMetadata( true, @@ -1195,14 +1172,6 @@ export class CodeModelBuilder { if (parameterOnClient) { clientContext.addGlobalParameter(parameter); } - - // this.trackSchemaUsage(schema, { usage: [SchemaContext.Input] }); - - // if (op.convenienceApi) { - // this.trackSchemaUsage(schema, { - // usage: [op.internalApi ? SchemaContext.Internal : SchemaContext.Public], - // }); - // } } } @@ -1303,13 +1272,6 @@ export class CodeModelBuilder { }, ); - // this.trackSchemaUsage(requestConditionsSchema, { usage: [SchemaContext.Input] }); - // if (op.convenienceApi) { - // this.trackSchemaUsage(requestConditionsSchema, { - // usage: [op.internalApi ? SchemaContext.Internal : SchemaContext.Public], - // }); - // } - // update group schema for properties for (const parameter of request.parameters) { if ( @@ -1381,22 +1343,8 @@ export class CodeModelBuilder { const jsonMergePatch = operationIsJsonMergePatch(sdkHttpOperation); - // const schemaIsPublicBeforeProcess = - // schema instanceof ObjectSchema && - // (schema as SchemaUsage).usage?.includes(SchemaContext.Public); - - // this.trackSchemaUsage(schema, { usage: [SchemaContext.Input] }); - - // if (op.convenienceApi) { - // // model/schema does not need to be Public or Internal, if it is not to be used in convenience API - // this.trackSchemaUsage(schema, { - // usage: [op.internalApi ? SchemaContext.Internal : SchemaContext.Public], - // }); - // } - - if (jsonMergePatch) { - // TODO haoling: consider move it out + // if it's json-merge-patch body, we need to track the body model's access, see case https://gist.github.com/haolingdong-msft/2d941f452551a6f96e141adbc38ac483#case7-flatten-body--json-merge-patch this.trackSchemaUsage(schema, { usage: [op.internalApi ? SchemaContext.Internal : SchemaContext.Public] }); this.trackSchemaUsage(schema, { usage: [SchemaContext.JsonMergePatch] }); } @@ -1434,16 +1382,6 @@ export class CodeModelBuilder { return; } - // const schemaUsage = (schema as SchemaUsage).usage; - // trackSchemaUsage(schema, { usage: schemaUsage }); - // if (!schemaIsPublicBeforeProcess && schemaUsage?.includes(SchemaContext.Public)) { - // // Public added in this op, change it to PublicSpread - // // This means that if this op would originally add Public to this schema, it adds PublicSpread instead - // schemaUsage?.splice(schemaUsage?.indexOf(SchemaContext.Public), 1); - // trackSchemaUsage(schema, { usage: [SchemaContext.Public] }); - // } - - if (op.convenienceApi && op.parameters) { op.convenienceApi.requests = []; const request = new Request({ @@ -1609,11 +1547,6 @@ export class CodeModelBuilder { } } - private findResponseBody(bodyType: Type): Type { - // find a type that possibly without http metadata like @statusCode - return this.getEffectiveSchemaType(bodyType); - } - private processResponse( op: CodeModelOperation, statusCode: number | HttpStatusCodeRange | "*", @@ -1631,10 +1564,7 @@ export class CodeModelBuilder { if (sdkResponse.headers) { for (const header of sdkResponse.headers) { const schema = this.processSchema(header.type, header.serializedName); - // // TODO haoling: why header schema do not need usage tracking? no usage tracking for header schema? - // trackSchemaUsage(schema, { - // usage: [SchemaContext.None] - // }); + headers.push( new HttpHeader(header.serializedName, schema, { language: { @@ -1726,21 +1656,6 @@ export class CodeModelBuilder { } } else { op.addResponse(response); - - if (response instanceof SchemaResponse) { - // if (!trackConvenienceApi) { - // trackSchemaUsage(response.schema, { - // usage: [SchemaContext.None] - // }); - // } - this.trackSchemaUsage(response.schema, { usage: [SchemaContext.Output] }); - - if (trackConvenienceApi) { - this.trackSchemaUsage(response.schema, { - usage: [op.internalApi ? SchemaContext.Internal : SchemaContext.Public], - }); - } - } } } @@ -2636,91 +2551,7 @@ export class CodeModelBuilder { private _subscriptionParameter?: Parameter; - private propagateSchemaUsage(schema: Schema): void { - const processedSchemas = new Set(); - - const innerApplySchemaUsage = (schema: Schema, schemaUsage: SchemaUsage) => { - trackSchemaUsage(schema, schemaUsage); - innerPropagateSchemaUsage(schema, schemaUsage); - }; - - const innerPropagateSchemaUsage = (schema: Schema, schemaUsage: SchemaUsage) => { - if (processedSchemas.has(schema)) { - return; - } - - processedSchemas.add(schema); - if (schema instanceof ObjectSchema || schema instanceof GroupSchema) { - if (schemaUsage.usage || schemaUsage.serializationFormats) { - schema.properties?.forEach((p) => { - if (p.readOnly && schemaUsage.usage?.includes(SchemaContext.Input)) { - const schemaUsageWithoutInput = { - usage: schemaUsage.usage.filter((it) => it !== SchemaContext.Input), - serializationFormats: schemaUsage.serializationFormats, - }; - innerApplySchemaUsage(p.schema, schemaUsageWithoutInput); - } else { - innerApplySchemaUsage(p.schema, schemaUsage); - } - }); - - if (schema instanceof ObjectSchema) { - schema.parents?.all?.forEach((p) => innerApplySchemaUsage(p, schemaUsage)); - schema.parents?.immediate?.forEach((p) => innerApplySchemaUsage(p, schemaUsage)); - - if (schema.discriminator) { - // propagate access/usage to immediate children, if the schema is a discriminated model - // if the schema is not a discriminated model, its children likely not valid for the mode/API - // TODO: it does not handle the case that concrete model (kind: "type1") for the discriminated model have depth larger than 1 (e.g. kind: "type1" | "type2" in middle) - schema.children?.immediate?.forEach((c) => innerApplySchemaUsage(c, schemaUsage)); - } - - if (schema.discriminator?.property?.schema) { - innerApplySchemaUsage(schema.discriminator?.property?.schema, schemaUsage); - } - } - } - } else if (schema instanceof DictionarySchema) { - innerApplySchemaUsage(schema.elementType, schemaUsage); - } else if (schema instanceof ArraySchema) { - innerApplySchemaUsage(schema.elementType, schemaUsage); - } else if (schema instanceof OrSchema) { - schema.anyOf?.forEach((it) => innerApplySchemaUsage(it, schemaUsage)); - } else if (schema instanceof ConstantSchema) { - innerApplySchemaUsage(schema.valueType, schemaUsage); - } - }; - - // Exclude context that not to be propagated - const updatedSchemaUsage = (schema as SchemaUsage).usage?.filter( - (it) => it !== SchemaContext.Paged && it !== SchemaContext.PublicSpread, - ); - const indexSpread = (schema as SchemaUsage).usage?.indexOf(SchemaContext.PublicSpread); - if ( - updatedSchemaUsage && - indexSpread && - indexSpread >= 0 && - !(schema as SchemaUsage).usage?.includes(SchemaContext.Public) - ) { - // Propagate Public, if schema is PublicSpread - updatedSchemaUsage.push(SchemaContext.Public); - } - const schemaUsage = { - usage: updatedSchemaUsage, - serializationFormats: (schema as SchemaUsage).serializationFormats?.filter( - (it) => it !== KnownMediaType.Multipart, - ), - }; - // Propagate the usage of the initial schema itself - innerPropagateSchemaUsage(schema, schemaUsage); - } - // private postProcessSchemaUsage(schemaUsage: SchemaUsage): void { - // if (schemaUsage.usage?.includes(SchemaContext.Public) && schemaUsage.usage?.includes(SchemaContext.Internal)) { - // // remove internal - // schemaUsage.usage.splice(schemaUsage.usage.indexOf(SchemaContext.Internal), 1); - // } - // } private postProcessSchemaUsage(): void { const innerProcessUsage = (schema: Schema) => { From a190200c29b1b5c82f0c6d6c3393633c891b4310 Mon Sep 17 00:00:00 2001 From: Haoling Dong <87355844+haolingdong-msft@users.noreply.github.com> Date: Wed, 30 Oct 2024 15:46:35 +0800 Subject: [PATCH 20/26] regen --- .../java/com/cadl/protocolandconvenient/models/ResourceD.java | 2 +- .../java/com/cadl/protocolandconvenient/models/ResourceH.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/protocolandconvenient/models/ResourceD.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/protocolandconvenient/models/ResourceD.java index bbc7615781..c5cb70a949 100644 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/protocolandconvenient/models/ResourceD.java +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/protocolandconvenient/models/ResourceD.java @@ -35,7 +35,7 @@ public final class ResourceD implements JsonSerializable { * @param name the name value to set. */ @Generated - private ResourceD(String name) { + public ResourceD(String name) { this.name = name; } diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/protocolandconvenient/models/ResourceH.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/protocolandconvenient/models/ResourceH.java index b85a801561..90aa1edaed 100644 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/protocolandconvenient/models/ResourceH.java +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/protocolandconvenient/models/ResourceH.java @@ -35,7 +35,7 @@ public final class ResourceH implements JsonSerializable { * @param name the name value to set. */ @Generated - private ResourceH(String name) { + public ResourceH(String name) { this.name = name; } From 8d4bbb307e4689de94fa50f4080ad4fd2e932c65 Mon Sep 17 00:00:00 2001 From: Haoling Dong <87355844+haolingdong-msft@users.noreply.github.com> Date: Wed, 30 Oct 2024 15:58:00 +0800 Subject: [PATCH 21/26] code clean up --- .../emitter/src/code-model-builder.ts | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/packages/http-client-java/emitter/src/code-model-builder.ts b/packages/http-client-java/emitter/src/code-model-builder.ts index 438f847a88..ed8bef9ce9 100644 --- a/packages/http-client-java/emitter/src/code-model-builder.ts +++ b/packages/http-client-java/emitter/src/code-model-builder.ts @@ -2551,25 +2551,13 @@ export class CodeModelBuilder { private _subscriptionParameter?: Parameter; - - private postProcessSchemaUsage(): void { const innerProcessUsage = (schema: Schema) => { const usages = (schema as SchemaUsage).usage; - // if (usages && usages.includes(SchemaContext.Public) && usages.includes(SchemaContext.Internal)) { // TODO haoling: add check to apply only to json-merge-patch and multipart - // // remove internal - // if (usages.includes(SchemaContext.JsonMergePatch) || schema.serializationFormats?.includes(KnownMediaType.Multipart)) { - // usages.splice(usages.indexOf(SchemaContext.Internal), 1); - // } - // } - if (usages && usages.includes(SchemaContext.Public) && usages.includes(SchemaContext.Internal)) { // TODO haoling: add check to apply only to json-merge-patch and multipart - // remove internal - usages.splice(usages.indexOf(SchemaContext.Internal), 1); + if (usages && usages.includes(SchemaContext.Public) && usages.includes(SchemaContext.Internal)) { + // If access contains both public and internal, remove internal + usages.splice(usages.indexOf(SchemaContext.Internal), 1); } - // if (usages && usages.includes(SchemaContext.None)) { - // // no usage - // (schema as SchemaUsage).usage = []; - // } }; this.codeModel.schemas.choices?.forEach(innerProcessUsage); this.codeModel.schemas.objects?.forEach(innerProcessUsage); From d1401287092a5800e592d0e140cc6fc555643ea9 Mon Sep 17 00:00:00 2001 From: Haoling Dong <87355844+haolingdong-msft@users.noreply.github.com> Date: Wed, 30 Oct 2024 16:00:18 +0800 Subject: [PATCH 22/26] code clean up --- packages/http-client-java/emitter/src/code-model-builder.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/http-client-java/emitter/src/code-model-builder.ts b/packages/http-client-java/emitter/src/code-model-builder.ts index ed8bef9ce9..093e6aa706 100644 --- a/packages/http-client-java/emitter/src/code-model-builder.ts +++ b/packages/http-client-java/emitter/src/code-model-builder.ts @@ -2555,7 +2555,7 @@ export class CodeModelBuilder { const innerProcessUsage = (schema: Schema) => { const usages = (schema as SchemaUsage).usage; if (usages && usages.includes(SchemaContext.Public) && usages.includes(SchemaContext.Internal)) { - // If access contains both public and internal, remove internal + // If access contains both public and internal, remove internal usages.splice(usages.indexOf(SchemaContext.Internal), 1); } }; From 813b1a6b52004c4cd38b8da61b0930986c8918c2 Mon Sep 17 00:00:00 2001 From: Haoling Dong <87355844+haolingdong-msft@users.noreply.github.com> Date: Fri, 15 Nov 2024 16:24:05 +0800 Subject: [PATCH 23/26] regen --- .../core/lro/rpc/models/OperationState.java | 2 +- ...nerationResponseGenerationResultError.java | 2 +- .../lro/standard/models/OperationState.java | 2 +- .../standard/models/OperationStatusError.java | 2 +- ...eOperationStatusUserExportedUserError.java | 2 +- .../traits/models/RepeatabilityResult.java | 2 +- .../structure/service/models/ClientType.java | 2 +- .../service/models/package-info.java | 2 +- ...ateSuccessResponseRepeatabilityResult.java | 2 +- .../repeatability/models/package-info.java | 2 +- .../models/ModelOptionalLiteral.java | 51 ------------------- .../models/LroOperationStatusError.java | 2 +- .../models/RepeatabilityResult.java | 2 +- .../models/ResourceD.java | 2 +- .../models/ResourceH.java | 2 +- .../models/RepeatabilityResult.java | 2 +- .../tsptest/union/models/OperationState.java | 6 +-- ...ationStatusOperationStatusResultError.java | 2 +- .../versioning/models/OperationState.java | 2 +- ...onStatusResourceExportedResourceError.java | 2 +- ...azure-core-lro-rpc_apiview_properties.json | 4 +- ...-core-lro-standard_apiview_properties.json | 3 ++ ...-azure-core-traits_apiview_properties.json | 1 + ...adl-literalservice_apiview_properties.json | 13 ----- .../cadl-longrunning_apiview_properties.json | 27 ---------- ...tocolandconvenient_apiview_properties.json | 30 ----------- ...adl-specialheaders_apiview_properties.json | 50 ------------------ .../cadl-union_apiview_properties.json | 33 ------------ .../cadl-versioning_apiview_properties.json | 22 -------- ...ders-repeatability_apiview_properties.json | 3 +- ...est-literalservice_apiview_properties.json | 4 +- ...sptest-longrunning_apiview_properties.json | 5 +- ...tocolandconvenient_apiview_properties.json | 2 + ...est-specialheaders_apiview_properties.json | 1 + .../tsptest-union_apiview_properties.json | 2 + ...tsptest-versioning_apiview_properties.json | 4 +- ...-property-optional_apiview_properties.json | 4 -- 37 files changed, 40 insertions(+), 261 deletions(-) rename packages/http-client-java/generator/http-client-generator-test/src/main/java/{com => }/client/structure/service/models/ClientType.java (97%) rename packages/http-client-java/generator/http-client-generator-test/src/main/java/{com => }/client/structure/service/models/package-info.java (93%) rename packages/http-client-java/generator/http-client-generator-test/src/main/java/{com => }/specialheaders/repeatability/models/ImmediateSuccessResponseRepeatabilityResult.java (96%) rename packages/http-client-java/generator/http-client-generator-test/src/main/java/{com => }/specialheaders/repeatability/models/package-info.java (87%) delete mode 100644 packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/literalservice/models/ModelOptionalLiteral.java delete mode 100644 packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/cadl-literalservice_apiview_properties.json delete mode 100644 packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/cadl-longrunning_apiview_properties.json delete mode 100644 packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/cadl-protocolandconvenient_apiview_properties.json delete mode 100644 packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/cadl-specialheaders_apiview_properties.json delete mode 100644 packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/cadl-union_apiview_properties.json delete mode 100644 packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/cadl-versioning_apiview_properties.json diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/_specs_/azure/core/lro/rpc/models/OperationState.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/_specs_/azure/core/lro/rpc/models/OperationState.java index 69593dba1f..c76a950252 100644 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/java/_specs_/azure/core/lro/rpc/models/OperationState.java +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/_specs_/azure/core/lro/rpc/models/OperationState.java @@ -2,7 +2,7 @@ // Licensed under the MIT License. // Code generated by Microsoft (R) TypeSpec Code Generator. -package com._specs_.azure.core.lro.rpc.models; +package _specs_.azure.core.lro.rpc.models; import com.azure.core.annotation.Generated; import com.azure.core.util.ExpandableStringEnum; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/_specs_/azure/core/lro/rpc/models/ResourceOperationStatusGenerationResponseGenerationResultError.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/_specs_/azure/core/lro/rpc/models/ResourceOperationStatusGenerationResponseGenerationResultError.java index 17f485cf69..f9c5737260 100644 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/java/_specs_/azure/core/lro/rpc/models/ResourceOperationStatusGenerationResponseGenerationResultError.java +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/_specs_/azure/core/lro/rpc/models/ResourceOperationStatusGenerationResponseGenerationResultError.java @@ -2,7 +2,7 @@ // Licensed under the MIT License. // Code generated by Microsoft (R) TypeSpec Code Generator. -package com._specs_.azure.core.lro.rpc.models; +package _specs_.azure.core.lro.rpc.models; import com.azure.core.annotation.Generated; import com.azure.core.annotation.Immutable; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/_specs_/azure/core/lro/standard/models/OperationState.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/_specs_/azure/core/lro/standard/models/OperationState.java index 070ef6faa2..4d8f45d0e2 100644 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/java/_specs_/azure/core/lro/standard/models/OperationState.java +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/_specs_/azure/core/lro/standard/models/OperationState.java @@ -2,7 +2,7 @@ // Licensed under the MIT License. // Code generated by Microsoft (R) TypeSpec Code Generator. -package com._specs_.azure.core.lro.standard.models; +package _specs_.azure.core.lro.standard.models; import com.azure.core.annotation.Generated; import com.azure.core.util.ExpandableStringEnum; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/_specs_/azure/core/lro/standard/models/OperationStatusError.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/_specs_/azure/core/lro/standard/models/OperationStatusError.java index 6683d6e3ab..bcd10aa38e 100644 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/java/_specs_/azure/core/lro/standard/models/OperationStatusError.java +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/_specs_/azure/core/lro/standard/models/OperationStatusError.java @@ -2,7 +2,7 @@ // Licensed under the MIT License. // Code generated by Microsoft (R) TypeSpec Code Generator. -package com._specs_.azure.core.lro.standard.models; +package _specs_.azure.core.lro.standard.models; import com.azure.core.annotation.Generated; import com.azure.core.annotation.Immutable; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/_specs_/azure/core/lro/standard/models/ResourceOperationStatusUserExportedUserError.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/_specs_/azure/core/lro/standard/models/ResourceOperationStatusUserExportedUserError.java index f93bd09a87..6c698a53f6 100644 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/java/_specs_/azure/core/lro/standard/models/ResourceOperationStatusUserExportedUserError.java +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/_specs_/azure/core/lro/standard/models/ResourceOperationStatusUserExportedUserError.java @@ -2,7 +2,7 @@ // Licensed under the MIT License. // Code generated by Microsoft (R) TypeSpec Code Generator. -package com._specs_.azure.core.lro.standard.models; +package _specs_.azure.core.lro.standard.models; import com.azure.core.annotation.Generated; import com.azure.core.annotation.Immutable; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/_specs_/azure/core/traits/models/RepeatabilityResult.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/_specs_/azure/core/traits/models/RepeatabilityResult.java index 7fac135832..4a1da39f68 100644 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/java/_specs_/azure/core/traits/models/RepeatabilityResult.java +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/_specs_/azure/core/traits/models/RepeatabilityResult.java @@ -2,7 +2,7 @@ // Licensed under the MIT License. // Code generated by Microsoft (R) TypeSpec Code Generator. -package com._specs_.azure.core.traits.models; +package _specs_.azure.core.traits.models; /** * Repeatability Result header options. diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/structure/service/models/ClientType.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/client/structure/service/models/ClientType.java similarity index 97% rename from packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/structure/service/models/ClientType.java rename to packages/http-client-java/generator/http-client-generator-test/src/main/java/client/structure/service/models/ClientType.java index d77c15cdd1..81bc9c8ad8 100644 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/structure/service/models/ClientType.java +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/client/structure/service/models/ClientType.java @@ -2,7 +2,7 @@ // Licensed under the MIT License. // Code generated by Microsoft (R) TypeSpec Code Generator. -package com.client.structure.service.models; +package client.structure.service.models; /** * Defines values for ClientType. diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/structure/service/models/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/client/structure/service/models/package-info.java similarity index 93% rename from packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/structure/service/models/package-info.java rename to packages/http-client-java/generator/http-client-generator-test/src/main/java/client/structure/service/models/package-info.java index d9a21e6dad..39f210ff84 100644 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/structure/service/models/package-info.java +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/client/structure/service/models/package-info.java @@ -15,4 +15,4 @@ * 6. have two clients with a hierarchy relation. * */ -package com.client.structure.service.models; +package client.structure.service.models; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialheaders/repeatability/models/ImmediateSuccessResponseRepeatabilityResult.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/specialheaders/repeatability/models/ImmediateSuccessResponseRepeatabilityResult.java similarity index 96% rename from packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialheaders/repeatability/models/ImmediateSuccessResponseRepeatabilityResult.java rename to packages/http-client-java/generator/http-client-generator-test/src/main/java/specialheaders/repeatability/models/ImmediateSuccessResponseRepeatabilityResult.java index b705a13cf5..57ca7659ec 100644 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialheaders/repeatability/models/ImmediateSuccessResponseRepeatabilityResult.java +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/specialheaders/repeatability/models/ImmediateSuccessResponseRepeatabilityResult.java @@ -2,7 +2,7 @@ // Licensed under the MIT License. // Code generated by Microsoft (R) TypeSpec Code Generator. -package com.specialheaders.repeatability.models; +package specialheaders.repeatability.models; /** * Defines values for ImmediateSuccessResponseRepeatabilityResult. diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialheaders/repeatability/models/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/specialheaders/repeatability/models/package-info.java similarity index 87% rename from packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialheaders/repeatability/models/package-info.java rename to packages/http-client-java/generator/http-client-generator-test/src/main/java/specialheaders/repeatability/models/package-info.java index 5cede2531e..3faae9a09c 100644 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialheaders/repeatability/models/package-info.java +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/specialheaders/repeatability/models/package-info.java @@ -8,4 +8,4 @@ * Illustrates OASIS repeatability headers. * */ -package com.specialheaders.repeatability.models; +package specialheaders.repeatability.models; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/literalservice/models/ModelOptionalLiteral.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/literalservice/models/ModelOptionalLiteral.java deleted file mode 100644 index eef2eb09fa..0000000000 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/literalservice/models/ModelOptionalLiteral.java +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) TypeSpec Code Generator. - -package tsptest.literalservice.models; - -/** - * Defines values for ModelOptionalLiteral. - */ -public enum ModelOptionalLiteral { - /** - * Enum value optionalLiteral. - */ - OPTIONAL_LITERAL("optionalLiteral"); - - /** - * The actual serialized value for a ModelOptionalLiteral instance. - */ - private final String value; - - ModelOptionalLiteral(String value) { - this.value = value; - } - - /** - * Parses a serialized value to a ModelOptionalLiteral instance. - * - * @param value the serialized value to parse. - * @return the parsed ModelOptionalLiteral object, or null if unable to parse. - */ - public static ModelOptionalLiteral fromString(String value) { - if (value == null) { - return null; - } - ModelOptionalLiteral[] items = ModelOptionalLiteral.values(); - for (ModelOptionalLiteral item : items) { - if (item.toString().equalsIgnoreCase(value)) { - return item; - } - } - return null; - } - - /** - * {@inheritDoc} - */ - @Override - public String toString() { - return this.value; - } -} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/longrunning/models/LroOperationStatusError.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/longrunning/models/LroOperationStatusError.java index 6604299687..afd4890dff 100644 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/longrunning/models/LroOperationStatusError.java +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/longrunning/models/LroOperationStatusError.java @@ -2,7 +2,7 @@ // Licensed under the MIT License. // Code generated by Microsoft (R) TypeSpec Code Generator. -package com.cadl.longrunning.models; +package tsptest.longrunning.models; import com.azure.core.annotation.Generated; import com.azure.core.annotation.Immutable; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/longrunning/models/RepeatabilityResult.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/longrunning/models/RepeatabilityResult.java index 2e5e4d3d91..05cf843ef2 100644 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/longrunning/models/RepeatabilityResult.java +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/longrunning/models/RepeatabilityResult.java @@ -2,7 +2,7 @@ // Licensed under the MIT License. // Code generated by Microsoft (R) TypeSpec Code Generator. -package com.cadl.longrunning.models; +package tsptest.longrunning.models; /** * Repeatability Result header options. diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/protocolandconvenient/models/ResourceD.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/protocolandconvenient/models/ResourceD.java index c5cb70a949..b003da3d3f 100644 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/protocolandconvenient/models/ResourceD.java +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/protocolandconvenient/models/ResourceD.java @@ -2,7 +2,7 @@ // Licensed under the MIT License. // Code generated by Microsoft (R) TypeSpec Code Generator. -package com.cadl.protocolandconvenient.models; +package tsptest.protocolandconvenient.models; import com.azure.core.annotation.Generated; import com.azure.core.annotation.Immutable; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/protocolandconvenient/models/ResourceH.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/protocolandconvenient/models/ResourceH.java index 90aa1edaed..df2abaa895 100644 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/protocolandconvenient/models/ResourceH.java +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/protocolandconvenient/models/ResourceH.java @@ -2,7 +2,7 @@ // Licensed under the MIT License. // Code generated by Microsoft (R) TypeSpec Code Generator. -package com.cadl.protocolandconvenient.models; +package tsptest.protocolandconvenient.models; import com.azure.core.annotation.Generated; import com.azure.core.annotation.Immutable; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/specialheaders/models/RepeatabilityResult.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/specialheaders/models/RepeatabilityResult.java index 603bd54011..3e1ec798ef 100644 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/specialheaders/models/RepeatabilityResult.java +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/specialheaders/models/RepeatabilityResult.java @@ -2,7 +2,7 @@ // Licensed under the MIT License. // Code generated by Microsoft (R) TypeSpec Code Generator. -package com.cadl.specialheaders.models; +package tsptest.specialheaders.models; /** * Repeatability Result header options. diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/union/models/OperationState.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/union/models/OperationState.java index f05c129dc0..8ec1bb7ca9 100644 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/union/models/OperationState.java +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/union/models/OperationState.java @@ -2,11 +2,7 @@ // Licensed under the MIT License. // Code generated by Microsoft (R) TypeSpec Code Generator. -<<<<<<<< HEAD:packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/union/models/OperationState.java -package com.cadl.union.models; -======== -package tsptest.longrunning.models; ->>>>>>>> remote/main:packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/longrunning/models/OperationState.java +package tsptest.union.models; import com.azure.core.annotation.Generated; import com.azure.core.util.ExpandableStringEnum; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/union/models/ResourceOperationStatusOperationStatusResultError.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/union/models/ResourceOperationStatusOperationStatusResultError.java index 42e3ddbf64..6b2f97745b 100644 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/union/models/ResourceOperationStatusOperationStatusResultError.java +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/union/models/ResourceOperationStatusOperationStatusResultError.java @@ -2,7 +2,7 @@ // Licensed under the MIT License. // Code generated by Microsoft (R) TypeSpec Code Generator. -package com.cadl.union.models; +package tsptest.union.models; import com.azure.core.annotation.Generated; import com.azure.core.annotation.Immutable; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/versioning/models/OperationState.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/versioning/models/OperationState.java index a7a4931780..6fd3a2b89e 100644 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/versioning/models/OperationState.java +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/versioning/models/OperationState.java @@ -2,7 +2,7 @@ // Licensed under the MIT License. // Code generated by Microsoft (R) TypeSpec Code Generator. -package com.cadl.versioning.models; +package tsptest.versioning.models; import com.azure.core.annotation.Generated; import com.azure.core.util.ExpandableStringEnum; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/versioning/models/ResourceOperationStatusResourceExportedResourceError.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/versioning/models/ResourceOperationStatusResourceExportedResourceError.java index de9a241510..81461a0db8 100644 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/versioning/models/ResourceOperationStatusResourceExportedResourceError.java +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/versioning/models/ResourceOperationStatusResourceExportedResourceError.java @@ -2,7 +2,7 @@ // Licensed under the MIT License. // Code generated by Microsoft (R) TypeSpec Code Generator. -package com.cadl.versioning.models; +package tsptest.versioning.models; import com.azure.core.annotation.Generated; import com.azure.core.annotation.Immutable; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/_specs_-azure-core-lro-rpc_apiview_properties.json b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/_specs_-azure-core-lro-rpc_apiview_properties.json index 7e37004eb8..88962c212b 100644 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/_specs_-azure-core-lro-rpc_apiview_properties.json +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/_specs_-azure-core-lro-rpc_apiview_properties.json @@ -9,6 +9,8 @@ "_specs_.azure.core.lro.rpc.RpcClient.beginLongRunningRpcWithModel": "_Specs_.Azure.Core.Lro.Rpc.longRunningRpc", "_specs_.azure.core.lro.rpc.RpcClientBuilder": "_Specs_.Azure.Core.Lro.Rpc", "_specs_.azure.core.lro.rpc.models.GenerationOptions": "_Specs_.Azure.Core.Lro.Rpc.GenerationOptions", - "_specs_.azure.core.lro.rpc.models.GenerationResult": "_Specs_.Azure.Core.Lro.Rpc.GenerationResult" + "_specs_.azure.core.lro.rpc.models.GenerationResult": "_Specs_.Azure.Core.Lro.Rpc.GenerationResult", + "_specs_.azure.core.lro.rpc.models.OperationState": "Azure.Core.Foundations.OperationState", + "_specs_.azure.core.lro.rpc.models.ResourceOperationStatusGenerationResponseGenerationResultError": "Azure.Core.ResourceOperationStatus" } } diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/_specs_-azure-core-lro-standard_apiview_properties.json b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/_specs_-azure-core-lro-standard_apiview_properties.json index 9d83c96dcd..6d15f9b4e2 100644 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/_specs_-azure-core-lro-standard_apiview_properties.json +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/_specs_-azure-core-lro-standard_apiview_properties.json @@ -17,6 +17,9 @@ "_specs_.azure.core.lro.standard.StandardClient.beginExportWithModel": "_Specs_.Azure.Core.Lro.Standard.export", "_specs_.azure.core.lro.standard.StandardClientBuilder": "_Specs_.Azure.Core.Lro.Standard", "_specs_.azure.core.lro.standard.models.ExportedUser": "_Specs_.Azure.Core.Lro.Standard.ExportedUser", + "_specs_.azure.core.lro.standard.models.OperationState": "Azure.Core.Foundations.OperationState", + "_specs_.azure.core.lro.standard.models.OperationStatusError": "Azure.Core.Foundations.OperationStatus", + "_specs_.azure.core.lro.standard.models.ResourceOperationStatusUserExportedUserError": "Azure.Core.ResourceOperationStatus", "_specs_.azure.core.lro.standard.models.User": "_Specs_.Azure.Core.Lro.Standard.User" } } diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/_specs_-azure-core-traits_apiview_properties.json b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/_specs_-azure-core-traits_apiview_properties.json index cdffe87de1..1fdefa81b1 100644 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/_specs_-azure-core-traits_apiview_properties.json +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/_specs_-azure-core-traits_apiview_properties.json @@ -12,6 +12,7 @@ "_specs_.azure.core.traits.TraitsClient.smokeTest": "_Specs_.Azure.Core.Traits.smokeTest", "_specs_.azure.core.traits.TraitsClient.smokeTestWithResponse": "_Specs_.Azure.Core.Traits.smokeTest", "_specs_.azure.core.traits.TraitsClientBuilder": "_Specs_.Azure.Core.Traits", + "_specs_.azure.core.traits.models.RepeatabilityResult": "Azure.Core.RepeatabilityResult", "_specs_.azure.core.traits.models.User": "_Specs_.Azure.Core.Traits.User", "_specs_.azure.core.traits.models.UserActionParam": "_Specs_.Azure.Core.Traits.UserActionParam", "_specs_.azure.core.traits.models.UserActionResponse": "_Specs_.Azure.Core.Traits.UserActionResponse" diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/cadl-literalservice_apiview_properties.json b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/cadl-literalservice_apiview_properties.json deleted file mode 100644 index b580b99691..0000000000 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/cadl-literalservice_apiview_properties.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "flavor": "Azure", - "CrossLanguageDefinitionId": { - "com.cadl.literalservice.LiteralServiceAsyncClient": "null", - "com.cadl.literalservice.LiteralServiceAsyncClient.put": "Cadl.LiteralService.LiteralOp.put", - "com.cadl.literalservice.LiteralServiceAsyncClient.putWithResponse": "Cadl.LiteralService.LiteralOp.put", - "com.cadl.literalservice.LiteralServiceClient": "null", - "com.cadl.literalservice.LiteralServiceClient.put": "Cadl.LiteralService.LiteralOp.put", - "com.cadl.literalservice.LiteralServiceClient.putWithResponse": "Cadl.LiteralService.LiteralOp.put", - "com.cadl.literalservice.LiteralServiceClientBuilder": "Cadl.LiteralService", - "com.cadl.literalservice.models.Model": "Cadl.LiteralService.Model" - } -} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/cadl-longrunning_apiview_properties.json b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/cadl-longrunning_apiview_properties.json deleted file mode 100644 index 77ec49c70a..0000000000 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/cadl-longrunning_apiview_properties.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "flavor": "Azure", - "CrossLanguageDefinitionId": { - "com.cadl.longrunning.LongRunningAsyncClient": "Cadl.LongRunning", - "com.cadl.longrunning.LongRunningAsyncClient.beginCreateJob": "Cadl.LongRunning.createJob", - "com.cadl.longrunning.LongRunningAsyncClient.beginCreateJobWithModel": "Cadl.LongRunning.createJob", - "com.cadl.longrunning.LongRunningAsyncClient.beginLongRunning": "Cadl.LongRunning.longRunning", - "com.cadl.longrunning.LongRunningAsyncClient.beginLongRunningWithModel": "Cadl.LongRunning.longRunning", - "com.cadl.longrunning.LongRunningAsyncClient.getJob": "Cadl.LongRunning.getJob", - "com.cadl.longrunning.LongRunningAsyncClient.getJobWithResponse": "Cadl.LongRunning.getJob", - "com.cadl.longrunning.LongRunningClient": "Cadl.LongRunning", - "com.cadl.longrunning.LongRunningClient.beginCreateJob": "Cadl.LongRunning.createJob", - "com.cadl.longrunning.LongRunningClient.beginCreateJobWithModel": "Cadl.LongRunning.createJob", - "com.cadl.longrunning.LongRunningClient.beginLongRunning": "Cadl.LongRunning.longRunning", - "com.cadl.longrunning.LongRunningClient.beginLongRunningWithModel": "Cadl.LongRunning.longRunning", - "com.cadl.longrunning.LongRunningClient.getJob": "Cadl.LongRunning.getJob", - "com.cadl.longrunning.LongRunningClient.getJobWithResponse": "Cadl.LongRunning.getJob", - "com.cadl.longrunning.LongRunningClientBuilder": "Cadl.LongRunning", - "com.cadl.longrunning.models.JobData": "Cadl.LongRunning.JobData", - "com.cadl.longrunning.models.JobResult": "Cadl.LongRunning.JobResult", - "com.cadl.longrunning.models.JobResultResult": "Cadl.LongRunning.JobResult.result.anonymous", - "com.cadl.longrunning.models.JobStatus": "Cadl.LongRunning.JobStatus", - "com.cadl.longrunning.models.LroOperationStatusError": "Cadl.LongRunning.LroOperationStatus", - "com.cadl.longrunning.models.PollResponse": "Cadl.LongRunning.PollResponse", - "com.cadl.longrunning.models.RepeatabilityResult": "Azure.Core.RepeatabilityResult" - } -} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/cadl-protocolandconvenient_apiview_properties.json b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/cadl-protocolandconvenient_apiview_properties.json deleted file mode 100644 index 6e4588b7c8..0000000000 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/cadl-protocolandconvenient_apiview_properties.json +++ /dev/null @@ -1,30 +0,0 @@ -{ - "flavor": "Azure", - "CrossLanguageDefinitionId": { - "com.cadl.protocolandconvenient.ProtocolAndConvenientAsyncClient": "null", - "com.cadl.protocolandconvenient.ProtocolAndConvenientAsyncClient.beginCreateOrReplace": "Cadl.ProtocolAndConvenient.ProtocolAndConvenienceOp.createOrReplace", - "com.cadl.protocolandconvenient.ProtocolAndConvenientAsyncClient.beginCreateOrReplaceWithModel": "Cadl.ProtocolAndConvenient.ProtocolAndConvenienceOp.createOrReplace", - "com.cadl.protocolandconvenient.ProtocolAndConvenientAsyncClient.bothConvenientAndProtocol": "Cadl.ProtocolAndConvenient.ProtocolAndConvenienceOp.bothConvenientAndProtocol", - "com.cadl.protocolandconvenient.ProtocolAndConvenientAsyncClient.bothConvenientAndProtocolWithResponse": "Cadl.ProtocolAndConvenient.ProtocolAndConvenienceOp.bothConvenientAndProtocol", - "com.cadl.protocolandconvenient.ProtocolAndConvenientAsyncClient.list": "Cadl.ProtocolAndConvenient.ProtocolAndConvenienceOp.list", - "com.cadl.protocolandconvenient.ProtocolAndConvenientAsyncClient.onlyConvenient": "Cadl.ProtocolAndConvenient.ProtocolAndConvenienceOp.onlyConvenient", - "com.cadl.protocolandconvenient.ProtocolAndConvenientAsyncClient.onlyConvenientWithResponse": "Cadl.ProtocolAndConvenient.ProtocolAndConvenienceOp.onlyConvenient", - "com.cadl.protocolandconvenient.ProtocolAndConvenientClient": "null", - "com.cadl.protocolandconvenient.ProtocolAndConvenientClient.beginCreateOrReplace": "Cadl.ProtocolAndConvenient.ProtocolAndConvenienceOp.createOrReplace", - "com.cadl.protocolandconvenient.ProtocolAndConvenientClient.beginCreateOrReplaceWithModel": "Cadl.ProtocolAndConvenient.ProtocolAndConvenienceOp.createOrReplace", - "com.cadl.protocolandconvenient.ProtocolAndConvenientClient.bothConvenientAndProtocol": "Cadl.ProtocolAndConvenient.ProtocolAndConvenienceOp.bothConvenientAndProtocol", - "com.cadl.protocolandconvenient.ProtocolAndConvenientClient.bothConvenientAndProtocolWithResponse": "Cadl.ProtocolAndConvenient.ProtocolAndConvenienceOp.bothConvenientAndProtocol", - "com.cadl.protocolandconvenient.ProtocolAndConvenientClient.list": "Cadl.ProtocolAndConvenient.ProtocolAndConvenienceOp.list", - "com.cadl.protocolandconvenient.ProtocolAndConvenientClient.onlyConvenient": "Cadl.ProtocolAndConvenient.ProtocolAndConvenienceOp.onlyConvenient", - "com.cadl.protocolandconvenient.ProtocolAndConvenientClient.onlyConvenientWithResponse": "Cadl.ProtocolAndConvenient.ProtocolAndConvenienceOp.onlyConvenient", - "com.cadl.protocolandconvenient.ProtocolAndConvenientClientBuilder": "Cadl.ProtocolAndConvenient", - "com.cadl.protocolandconvenient.models.ResourceA": "Cadl.ProtocolAndConvenient.ResourceA", - "com.cadl.protocolandconvenient.models.ResourceB": "Cadl.ProtocolAndConvenient.ResourceB", - "com.cadl.protocolandconvenient.models.ResourceD": "Cadl.ProtocolAndConvenient.ResourceD", - "com.cadl.protocolandconvenient.models.ResourceE": "Cadl.ProtocolAndConvenient.ResourceE", - "com.cadl.protocolandconvenient.models.ResourceF": "Cadl.ProtocolAndConvenient.ResourceF", - "com.cadl.protocolandconvenient.models.ResourceH": "Cadl.ProtocolAndConvenient.ResourceH", - "com.cadl.protocolandconvenient.models.ResourceI": "Cadl.ProtocolAndConvenient.ResourceI", - "com.cadl.protocolandconvenient.models.ResourceJ": "Cadl.ProtocolAndConvenient.ResourceJ" - } -} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/cadl-specialheaders_apiview_properties.json b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/cadl-specialheaders_apiview_properties.json deleted file mode 100644 index 28513701fe..0000000000 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/cadl-specialheaders_apiview_properties.json +++ /dev/null @@ -1,50 +0,0 @@ -{ - "flavor": "Azure", - "CrossLanguageDefinitionId": { - "com.cadl.specialheaders.EtagHeadersAsyncClient": "null", - "com.cadl.specialheaders.EtagHeadersAsyncClient.listWithEtag": "Cadl.SpecialHeaders.EtagHeaders.listWithEtag", - "com.cadl.specialheaders.EtagHeadersAsyncClient.patchWithMatchHeaders": "Cadl.SpecialHeaders.EtagHeaders.patchWithMatchHeaders", - "com.cadl.specialheaders.EtagHeadersAsyncClient.patchWithMatchHeadersWithResponse": "Cadl.SpecialHeaders.EtagHeaders.patchWithMatchHeaders", - "com.cadl.specialheaders.EtagHeadersAsyncClient.putWithRequestHeaders": "Cadl.SpecialHeaders.EtagHeaders.putWithRequestHeaders", - "com.cadl.specialheaders.EtagHeadersAsyncClient.putWithRequestHeadersWithResponse": "Cadl.SpecialHeaders.EtagHeaders.putWithRequestHeaders", - "com.cadl.specialheaders.EtagHeadersClient": "null", - "com.cadl.specialheaders.EtagHeadersClient.listWithEtag": "Cadl.SpecialHeaders.EtagHeaders.listWithEtag", - "com.cadl.specialheaders.EtagHeadersClient.patchWithMatchHeaders": "Cadl.SpecialHeaders.EtagHeaders.patchWithMatchHeaders", - "com.cadl.specialheaders.EtagHeadersClient.patchWithMatchHeadersWithResponse": "Cadl.SpecialHeaders.EtagHeaders.patchWithMatchHeaders", - "com.cadl.specialheaders.EtagHeadersClient.putWithRequestHeaders": "Cadl.SpecialHeaders.EtagHeaders.putWithRequestHeaders", - "com.cadl.specialheaders.EtagHeadersClient.putWithRequestHeadersWithResponse": "Cadl.SpecialHeaders.EtagHeaders.putWithRequestHeaders", - "com.cadl.specialheaders.EtagHeadersOptionalBodyAsyncClient": "null", - "com.cadl.specialheaders.EtagHeadersOptionalBodyAsyncClient.putWithOptionalBody": "Cadl.SpecialHeaders.EtagHeadersOptionalBody.putWithOptionalBody", - "com.cadl.specialheaders.EtagHeadersOptionalBodyAsyncClient.putWithOptionalBodyWithResponse": "Cadl.SpecialHeaders.EtagHeadersOptionalBody.putWithOptionalBody", - "com.cadl.specialheaders.EtagHeadersOptionalBodyClient": "null", - "com.cadl.specialheaders.EtagHeadersOptionalBodyClient.putWithOptionalBody": "Cadl.SpecialHeaders.EtagHeadersOptionalBody.putWithOptionalBody", - "com.cadl.specialheaders.EtagHeadersOptionalBodyClient.putWithOptionalBodyWithResponse": "Cadl.SpecialHeaders.EtagHeadersOptionalBody.putWithOptionalBody", - "com.cadl.specialheaders.RepeatabilityHeadersAsyncClient": "null", - "com.cadl.specialheaders.RepeatabilityHeadersAsyncClient.beginCreateLro": "Cadl.SpecialHeaders.RepeatabilityHeaders.createLro", - "com.cadl.specialheaders.RepeatabilityHeadersAsyncClient.beginCreateLroWithModel": "Cadl.SpecialHeaders.RepeatabilityHeaders.createLro", - "com.cadl.specialheaders.RepeatabilityHeadersAsyncClient.get": "Cadl.SpecialHeaders.RepeatabilityHeaders.get", - "com.cadl.specialheaders.RepeatabilityHeadersAsyncClient.getWithResponse": "Cadl.SpecialHeaders.RepeatabilityHeaders.get", - "com.cadl.specialheaders.RepeatabilityHeadersAsyncClient.post": "Cadl.SpecialHeaders.RepeatabilityHeaders.post", - "com.cadl.specialheaders.RepeatabilityHeadersAsyncClient.postWithResponse": "Cadl.SpecialHeaders.RepeatabilityHeaders.post", - "com.cadl.specialheaders.RepeatabilityHeadersAsyncClient.put": "Cadl.SpecialHeaders.RepeatabilityHeaders.put", - "com.cadl.specialheaders.RepeatabilityHeadersAsyncClient.putWithResponse": "Cadl.SpecialHeaders.RepeatabilityHeaders.put", - "com.cadl.specialheaders.RepeatabilityHeadersClient": "null", - "com.cadl.specialheaders.RepeatabilityHeadersClient.beginCreateLro": "Cadl.SpecialHeaders.RepeatabilityHeaders.createLro", - "com.cadl.specialheaders.RepeatabilityHeadersClient.beginCreateLroWithModel": "Cadl.SpecialHeaders.RepeatabilityHeaders.createLro", - "com.cadl.specialheaders.RepeatabilityHeadersClient.get": "Cadl.SpecialHeaders.RepeatabilityHeaders.get", - "com.cadl.specialheaders.RepeatabilityHeadersClient.getWithResponse": "Cadl.SpecialHeaders.RepeatabilityHeaders.get", - "com.cadl.specialheaders.RepeatabilityHeadersClient.post": "Cadl.SpecialHeaders.RepeatabilityHeaders.post", - "com.cadl.specialheaders.RepeatabilityHeadersClient.postWithResponse": "Cadl.SpecialHeaders.RepeatabilityHeaders.post", - "com.cadl.specialheaders.RepeatabilityHeadersClient.put": "Cadl.SpecialHeaders.RepeatabilityHeaders.put", - "com.cadl.specialheaders.RepeatabilityHeadersClient.putWithResponse": "Cadl.SpecialHeaders.RepeatabilityHeaders.put", - "com.cadl.specialheaders.SkipSpecialHeadersAsyncClient": "null", - "com.cadl.specialheaders.SkipSpecialHeadersAsyncClient.deleteWithSpecialHeaders": "Cadl.SpecialHeaders.SkipSpecialHeaders.deleteWithSpecialHeaders", - "com.cadl.specialheaders.SkipSpecialHeadersAsyncClient.deleteWithSpecialHeadersWithResponse": "Cadl.SpecialHeaders.SkipSpecialHeaders.deleteWithSpecialHeaders", - "com.cadl.specialheaders.SkipSpecialHeadersClient": "null", - "com.cadl.specialheaders.SkipSpecialHeadersClient.deleteWithSpecialHeaders": "Cadl.SpecialHeaders.SkipSpecialHeaders.deleteWithSpecialHeaders", - "com.cadl.specialheaders.SkipSpecialHeadersClient.deleteWithSpecialHeadersWithResponse": "Cadl.SpecialHeaders.SkipSpecialHeaders.deleteWithSpecialHeaders", - "com.cadl.specialheaders.SpecialHeadersClientBuilder": "Cadl.SpecialHeaders", - "com.cadl.specialheaders.models.RepeatabilityResult": "Azure.Core.RepeatabilityResult", - "com.cadl.specialheaders.models.Resource": "Cadl.SpecialHeaders.Resource" - } -} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/cadl-union_apiview_properties.json b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/cadl-union_apiview_properties.json deleted file mode 100644 index 569ffac7e4..0000000000 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/cadl-union_apiview_properties.json +++ /dev/null @@ -1,33 +0,0 @@ -{ - "flavor": "Azure", - "CrossLanguageDefinitionId": { - "com.cadl.union.UnionAsyncClient": "null", - "com.cadl.union.UnionAsyncClient.beginGenerate": "Cadl.Union.UnionFlattenOp.generate", - "com.cadl.union.UnionAsyncClient.beginGenerateWithModel": "Cadl.Union.UnionFlattenOp.generate", - "com.cadl.union.UnionAsyncClient.get": "Cadl.Union.UnionFlattenOp.get", - "com.cadl.union.UnionAsyncClient.getWithResponse": "Cadl.Union.UnionFlattenOp.get", - "com.cadl.union.UnionAsyncClient.send": "Cadl.Union.UnionFlattenOp.send", - "com.cadl.union.UnionAsyncClient.sendLong": "Cadl.Union.UnionFlattenOp.sendLong", - "com.cadl.union.UnionAsyncClient.sendLongWithResponse": "Cadl.Union.UnionFlattenOp.sendLong", - "com.cadl.union.UnionAsyncClient.sendWithResponse": "Cadl.Union.UnionFlattenOp.send", - "com.cadl.union.UnionClient": "null", - "com.cadl.union.UnionClient.beginGenerate": "Cadl.Union.UnionFlattenOp.generate", - "com.cadl.union.UnionClient.beginGenerateWithModel": "Cadl.Union.UnionFlattenOp.generate", - "com.cadl.union.UnionClient.get": "Cadl.Union.UnionFlattenOp.get", - "com.cadl.union.UnionClient.getWithResponse": "Cadl.Union.UnionFlattenOp.get", - "com.cadl.union.UnionClient.send": "Cadl.Union.UnionFlattenOp.send", - "com.cadl.union.UnionClient.sendLong": "Cadl.Union.UnionFlattenOp.sendLong", - "com.cadl.union.UnionClient.sendLongWithResponse": "Cadl.Union.UnionFlattenOp.sendLong", - "com.cadl.union.UnionClient.sendWithResponse": "Cadl.Union.UnionFlattenOp.send", - "com.cadl.union.UnionClientBuilder": "Cadl.Union", - "com.cadl.union.implementation.models.SendLongRequest": "sendLong.Request.anonymous", - "com.cadl.union.implementation.models.SendRequest": "send.Request.anonymous", - "com.cadl.union.implementation.models.SubResult": "Cadl.Union.SubResult", - "com.cadl.union.models.ArrayData": "Cadl.Union.ArrayData", - "com.cadl.union.models.OperationState": "Azure.Core.Foundations.OperationState", - "com.cadl.union.models.ResourceOperationStatusOperationStatusResultError": "Azure.Core.ResourceOperationStatus", - "com.cadl.union.models.Result": "Cadl.Union.Result", - "com.cadl.union.models.SendLongOptions": "null", - "com.cadl.union.models.User": "Cadl.Union.User" - } -} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/cadl-versioning_apiview_properties.json b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/cadl-versioning_apiview_properties.json deleted file mode 100644 index aa5cd197a6..0000000000 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/cadl-versioning_apiview_properties.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "flavor": "Azure", - "CrossLanguageDefinitionId": { - "com.cadl.versioning.VersioningAsyncClient": "null", - "com.cadl.versioning.VersioningAsyncClient.beginCreateLongRunning": "Cadl.Versioning.VersioningOp.createLongRunning", - "com.cadl.versioning.VersioningAsyncClient.beginCreateLongRunningWithModel": "Cadl.Versioning.VersioningOp.createLongRunning", - "com.cadl.versioning.VersioningAsyncClient.beginExport": "Cadl.Versioning.VersioningOp.export", - "com.cadl.versioning.VersioningAsyncClient.beginExportWithModel": "Cadl.Versioning.VersioningOp.export", - "com.cadl.versioning.VersioningAsyncClient.list": "Cadl.Versioning.VersioningOp.list", - "com.cadl.versioning.VersioningClient": "null", - "com.cadl.versioning.VersioningClient.beginCreateLongRunning": "Cadl.Versioning.VersioningOp.createLongRunning", - "com.cadl.versioning.VersioningClient.beginCreateLongRunningWithModel": "Cadl.Versioning.VersioningOp.createLongRunning", - "com.cadl.versioning.VersioningClient.beginExport": "Cadl.Versioning.VersioningOp.export", - "com.cadl.versioning.VersioningClient.beginExportWithModel": "Cadl.Versioning.VersioningOp.export", - "com.cadl.versioning.VersioningClient.list": "Cadl.Versioning.VersioningOp.list", - "com.cadl.versioning.VersioningClientBuilder": "Cadl.Versioning", - "com.cadl.versioning.models.ExportedResource": "Cadl.Versioning.ExportedResource", - "com.cadl.versioning.models.OperationState": "Azure.Core.Foundations.OperationState", - "com.cadl.versioning.models.Resource": "Cadl.Versioning.Resource", - "com.cadl.versioning.models.ResourceOperationStatusResourceExportedResourceError": "Azure.Core.ResourceOperationStatus" - } -} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/specialheaders-repeatability_apiview_properties.json b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/specialheaders-repeatability_apiview_properties.json index 78b61690bc..928441a36f 100644 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/specialheaders-repeatability_apiview_properties.json +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/specialheaders-repeatability_apiview_properties.json @@ -7,6 +7,7 @@ "specialheaders.repeatability.RepeatabilityClient": "SpecialHeaders.Repeatability", "specialheaders.repeatability.RepeatabilityClient.immediateSuccess": "SpecialHeaders.Repeatability.immediateSuccess", "specialheaders.repeatability.RepeatabilityClient.immediateSuccessWithResponse": "SpecialHeaders.Repeatability.immediateSuccess", - "specialheaders.repeatability.RepeatabilityClientBuilder": "SpecialHeaders.Repeatability" + "specialheaders.repeatability.RepeatabilityClientBuilder": "SpecialHeaders.Repeatability", + "specialheaders.repeatability.models.ImmediateSuccessResponseRepeatabilityResult": "immediateSuccess.ResponseRepeatabilityResult.anonymous" } } diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/tsptest-literalservice_apiview_properties.json b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/tsptest-literalservice_apiview_properties.json index 90dfd8c70a..9262d1a9b0 100644 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/tsptest-literalservice_apiview_properties.json +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/tsptest-literalservice_apiview_properties.json @@ -8,8 +8,6 @@ "tsptest.literalservice.LiteralServiceClient.put": "TspTest.LiteralService.LiteralOp.put", "tsptest.literalservice.LiteralServiceClient.putWithResponse": "TspTest.LiteralService.LiteralOp.put", "tsptest.literalservice.LiteralServiceClientBuilder": "TspTest.LiteralService", - "tsptest.literalservice.models.Model": "TspTest.LiteralService.Model", - "tsptest.literalservice.models.ModelOptionalLiteral": "null", - "tsptest.literalservice.models.PutRequestOptionalLiteralParam": "null" + "tsptest.literalservice.models.Model": "TspTest.LiteralService.Model" } } diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/tsptest-longrunning_apiview_properties.json b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/tsptest-longrunning_apiview_properties.json index df246d16cf..18cd98b0d7 100644 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/tsptest-longrunning_apiview_properties.json +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/tsptest-longrunning_apiview_properties.json @@ -20,7 +20,8 @@ "tsptest.longrunning.models.JobResult": "TspTest.LongRunning.JobResult", "tsptest.longrunning.models.JobResultResult": "TspTest.LongRunning.JobResult.result.anonymous", "tsptest.longrunning.models.JobStatus": "TspTest.LongRunning.JobStatus", - "tsptest.longrunning.models.OperationState": "Azure.Core.Foundations.OperationState", - "tsptest.longrunning.models.PollResponse": "TspTest.LongRunning.PollResponse" + "tsptest.longrunning.models.LroOperationStatusError": "TspTest.LongRunning.LroOperationStatus", + "tsptest.longrunning.models.PollResponse": "TspTest.LongRunning.PollResponse", + "tsptest.longrunning.models.RepeatabilityResult": "Azure.Core.RepeatabilityResult" } } diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/tsptest-protocolandconvenient_apiview_properties.json b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/tsptest-protocolandconvenient_apiview_properties.json index f13b8ce57b..2f18891462 100644 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/tsptest-protocolandconvenient_apiview_properties.json +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/tsptest-protocolandconvenient_apiview_properties.json @@ -20,8 +20,10 @@ "tsptest.protocolandconvenient.ProtocolAndConvenientClientBuilder": "TspTest.ProtocolAndConvenient", "tsptest.protocolandconvenient.models.ResourceA": "TspTest.ProtocolAndConvenient.ResourceA", "tsptest.protocolandconvenient.models.ResourceB": "TspTest.ProtocolAndConvenient.ResourceB", + "tsptest.protocolandconvenient.models.ResourceD": "TspTest.ProtocolAndConvenient.ResourceD", "tsptest.protocolandconvenient.models.ResourceE": "TspTest.ProtocolAndConvenient.ResourceE", "tsptest.protocolandconvenient.models.ResourceF": "TspTest.ProtocolAndConvenient.ResourceF", + "tsptest.protocolandconvenient.models.ResourceH": "TspTest.ProtocolAndConvenient.ResourceH", "tsptest.protocolandconvenient.models.ResourceI": "TspTest.ProtocolAndConvenient.ResourceI", "tsptest.protocolandconvenient.models.ResourceJ": "TspTest.ProtocolAndConvenient.ResourceJ" } diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/tsptest-specialheaders_apiview_properties.json b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/tsptest-specialheaders_apiview_properties.json index 767ad33240..f9b37035e3 100644 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/tsptest-specialheaders_apiview_properties.json +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/tsptest-specialheaders_apiview_properties.json @@ -44,6 +44,7 @@ "tsptest.specialheaders.SkipSpecialHeadersClient.deleteWithSpecialHeaders": "TspTest.SpecialHeaders.SkipSpecialHeaders.deleteWithSpecialHeaders", "tsptest.specialheaders.SkipSpecialHeadersClient.deleteWithSpecialHeadersWithResponse": "TspTest.SpecialHeaders.SkipSpecialHeaders.deleteWithSpecialHeaders", "tsptest.specialheaders.SpecialHeadersClientBuilder": "TspTest.SpecialHeaders", + "tsptest.specialheaders.models.RepeatabilityResult": "Azure.Core.RepeatabilityResult", "tsptest.specialheaders.models.Resource": "TspTest.SpecialHeaders.Resource" } } diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/tsptest-union_apiview_properties.json b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/tsptest-union_apiview_properties.json index 64b22903bc..d24b1acf6d 100644 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/tsptest-union_apiview_properties.json +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/tsptest-union_apiview_properties.json @@ -24,6 +24,8 @@ "tsptest.union.implementation.models.SendRequest": "send.Request.anonymous", "tsptest.union.implementation.models.SubResult": "TspTest.Union.SubResult", "tsptest.union.models.ArrayData": "TspTest.Union.ArrayData", + "tsptest.union.models.OperationState": "Azure.Core.Foundations.OperationState", + "tsptest.union.models.ResourceOperationStatusOperationStatusResultError": "Azure.Core.ResourceOperationStatus", "tsptest.union.models.Result": "TspTest.Union.Result", "tsptest.union.models.SendLongOptions": "null", "tsptest.union.models.User": "TspTest.Union.User" diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/tsptest-versioning_apiview_properties.json b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/tsptest-versioning_apiview_properties.json index b8e5a5cff3..59dab5caba 100644 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/tsptest-versioning_apiview_properties.json +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/tsptest-versioning_apiview_properties.json @@ -15,6 +15,8 @@ "tsptest.versioning.VersioningClient.list": "TspTest.Versioning.VersioningOp.list", "tsptest.versioning.VersioningClientBuilder": "TspTest.Versioning", "tsptest.versioning.models.ExportedResource": "TspTest.Versioning.ExportedResource", - "tsptest.versioning.models.Resource": "TspTest.Versioning.Resource" + "tsptest.versioning.models.OperationState": "Azure.Core.Foundations.OperationState", + "tsptest.versioning.models.Resource": "TspTest.Versioning.Resource", + "tsptest.versioning.models.ResourceOperationStatusResourceExportedResourceError": "Azure.Core.ResourceOperationStatus" } } diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/type-property-optional_apiview_properties.json b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/type-property-optional_apiview_properties.json index e8680afb17..a704ab3ca9 100644 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/type-property-optional_apiview_properties.json +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/type-property-optional_apiview_properties.json @@ -291,21 +291,17 @@ "type.property.optional.UnionStringLiteralClient.putDefault": "Type.Property.Optional.UnionStringLiteral.putDefault", "type.property.optional.UnionStringLiteralClient.putDefaultWithResponse": "Type.Property.Optional.UnionStringLiteral.putDefault", "type.property.optional.models.BooleanLiteralProperty": "Type.Property.Optional.BooleanLiteralProperty", - "type.property.optional.models.BooleanLiteralPropertyProperty": "null", "type.property.optional.models.BytesProperty": "Type.Property.Optional.BytesProperty", "type.property.optional.models.CollectionsByteProperty": "Type.Property.Optional.CollectionsByteProperty", "type.property.optional.models.CollectionsModelProperty": "Type.Property.Optional.CollectionsModelProperty", "type.property.optional.models.DatetimeProperty": "Type.Property.Optional.DatetimeProperty", "type.property.optional.models.DurationProperty": "Type.Property.Optional.DurationProperty", "type.property.optional.models.FloatLiteralProperty": "Type.Property.Optional.FloatLiteralProperty", - "type.property.optional.models.FloatLiteralPropertyProperty": "null", "type.property.optional.models.IntLiteralProperty": "Type.Property.Optional.IntLiteralProperty", - "type.property.optional.models.IntLiteralPropertyProperty": "null", "type.property.optional.models.PlainDateProperty": "Type.Property.Optional.PlainDateProperty", "type.property.optional.models.PlainTimeProperty": "Type.Property.Optional.PlainTimeProperty", "type.property.optional.models.RequiredAndOptionalProperty": "Type.Property.Optional.RequiredAndOptionalProperty", "type.property.optional.models.StringLiteralProperty": "Type.Property.Optional.StringLiteralProperty", - "type.property.optional.models.StringLiteralPropertyProperty": "null", "type.property.optional.models.StringProperty": "Type.Property.Optional.StringProperty", "type.property.optional.models.UnionFloatLiteralProperty": "Type.Property.Optional.UnionFloatLiteralProperty", "type.property.optional.models.UnionFloatLiteralPropertyProperty": "UnionFloatLiteralProperty.property.anonymous", From 3ef07967d7c2433be6288c2e0c064af54bd125c5 Mon Sep 17 00:00:00 2001 From: Haoling Dong <87355844+haolingdong-msft@users.noreply.github.com> Date: Fri, 15 Nov 2024 16:38:43 +0800 Subject: [PATCH 24/26] code clean up --- .../emitter/src/code-model-builder.ts | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/packages/http-client-java/emitter/src/code-model-builder.ts b/packages/http-client-java/emitter/src/code-model-builder.ts index db7b1077d8..6d3a311aca 100644 --- a/packages/http-client-java/emitter/src/code-model-builder.ts +++ b/packages/http-client-java/emitter/src/code-model-builder.ts @@ -271,7 +271,6 @@ export class CodeModelBuilder { this.postProcessSchemaUsage(); - this.deduplicateSchemaName(); return this.codeModel; @@ -401,18 +400,6 @@ export class CodeModelBuilder { } } - // private processSchemaUsage() { - // this.codeModel.schemas.objects?.forEach((it) => this.propagateSchemaUsage(it)); - - // // post process for schema usage - // this.codeModel.schemas.objects?.forEach((it) => this.resolveSchemaUsage(it)); - // this.codeModel.schemas.groups?.forEach((it) => this.resolveSchemaUsage(it)); - // this.codeModel.schemas.choices?.forEach((it) => this.resolveSchemaUsage(it)); - // this.codeModel.schemas.sealedChoices?.forEach((it) => this.resolveSchemaUsage(it)); - // this.codeModel.schemas.ors?.forEach((it) => this.resolveSchemaUsage(it)); - // this.codeModel.schemas.constants?.forEach((it) => this.resolveSchemaUsage(it)); - // } - private deduplicateSchemaName() { // deduplicate model name const nameCount = new Map(); @@ -1384,8 +1371,6 @@ export class CodeModelBuilder { if (sdkType.isGeneratedName) { schema.language.default.name = pascalCase(op.language.default.name) + "PatchRequest"; } - // // TODO haoling: maybe put to a global post processing - // this.postProcessSchemaUsage(schema); return; } From cb58aa0b3af86b25b55339df33c6c766a25db00d Mon Sep 17 00:00:00 2001 From: Haoling Dong <87355844+haolingdong-msft@users.noreply.github.com> Date: Fri, 15 Nov 2024 17:12:21 +0800 Subject: [PATCH 25/26] format --- .../emitter/src/code-model-builder.ts | 20 ++++----- .../emitter/src/common/schemas/usage.ts | 5 +-- .../emitter/src/external-schemas.ts | 4 +- .../emitter/src/type-utils.ts | 45 ++++++++++++------- 4 files changed, 40 insertions(+), 34 deletions(-) diff --git a/packages/http-client-java/emitter/src/code-model-builder.ts b/packages/http-client-java/emitter/src/code-model-builder.ts index 6d3a311aca..2f688c833f 100644 --- a/packages/http-client-java/emitter/src/code-model-builder.ts +++ b/packages/http-client-java/emitter/src/code-model-builder.ts @@ -30,7 +30,6 @@ import { Response, Schema, SchemaResponse, - Schemas, SchemaType, Security, SecurityScheme, @@ -70,7 +69,6 @@ import { SdkType, SdkUnionType, createSdkContext, - getAccessOverride, getAllModels, getWireName, isApiVersion, @@ -383,9 +381,8 @@ export class CodeModelBuilder { // process sdk models for (const model of sdkModels) { - if (!processedSdkModels.has(model)) { - // For this part, we only process models which explicitly set access and use decorator, + // For this part, we only process models which explicitly set access and use decorator, // otherwise, there will be isseus, e.g. for multipart models, we generate our own model, but TCGC returns the original multipart model with public access and input usage, so we will generate the original multipart model which is unexpected const access = getAccess(model.__raw, accessCache); if (access) { @@ -1339,7 +1336,9 @@ export class CodeModelBuilder { if (jsonMergePatch) { // if it's json-merge-patch body, we need to track the body model's access, see case https://gist.github.com/haolingdong-msft/2d941f452551a6f96e141adbc38ac483#case7-flatten-body--json-merge-patch - this.trackSchemaUsage(schema, { usage: [op.internalApi ? SchemaContext.Internal : SchemaContext.Public] }); + this.trackSchemaUsage(schema, { + usage: [op.internalApi ? SchemaContext.Internal : SchemaContext.Public], + }); this.trackSchemaUsage(schema, { usage: [SchemaContext.JsonMergePatch] }); } if (op.convenienceApi && operationIsMultipart(sdkHttpOperation)) { @@ -1571,7 +1570,6 @@ export class CodeModelBuilder { } const bodyType: SdkType | undefined = sdkResponse.type; - let trackConvenienceApi: boolean = Boolean(op.convenienceApi); const unknownResponseBody = sdkResponse.contentTypes && @@ -1600,10 +1598,6 @@ export class CodeModelBuilder { } 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.processSchema(bodyType, op.language.default.name + "Response"); } @@ -2548,7 +2542,11 @@ export class CodeModelBuilder { private postProcessSchemaUsage(): void { const innerProcessUsage = (schema: Schema) => { const usages = (schema as SchemaUsage).usage; - if (usages && usages.includes(SchemaContext.Public) && usages.includes(SchemaContext.Internal)) { + if ( + usages && + usages.includes(SchemaContext.Public) && + usages.includes(SchemaContext.Internal) + ) { // If access contains both public and internal, remove internal usages.splice(usages.indexOf(SchemaContext.Internal), 1); } diff --git a/packages/http-client-java/emitter/src/common/schemas/usage.ts b/packages/http-client-java/emitter/src/common/schemas/usage.ts index 71a0b27be9..e0e4a47b7b 100644 --- a/packages/http-client-java/emitter/src/common/schemas/usage.ts +++ b/packages/http-client-java/emitter/src/common/schemas/usage.ts @@ -23,10 +23,7 @@ export enum SchemaContext { PublicSpread = "spread", /** Schema is used in json-merge-patch operation */ - JsonMergePatch = "json-merge-patch", - - /** Schema is not used */ - None = "None" + JsonMergePatch = "json-merge-patch" } export interface SchemaUsage { diff --git a/packages/http-client-java/emitter/src/external-schemas.ts b/packages/http-client-java/emitter/src/external-schemas.ts index 231250ea74..b0d6f35cc6 100644 --- a/packages/http-client-java/emitter/src/external-schemas.ts +++ b/packages/http-client-java/emitter/src/external-schemas.ts @@ -15,9 +15,9 @@ import { SdkType, } from "@azure-tools/typespec-client-generator-core"; import { CrossLanguageDefinition } from "./common/client.js"; -import { getNamespace, pascalCase } from "./utils.js"; -import { trackSchemaUsage } from "./type-utils.js"; import { SchemaContext } from "./common/schemas/usage.js"; +import { trackSchemaUsage } from "./type-utils.js"; +import { getNamespace, pascalCase } from "./utils.js"; /* * These schema need to reflect diff --git a/packages/http-client-java/emitter/src/type-utils.ts b/packages/http-client-java/emitter/src/type-utils.ts index 23ff0d9c39..1a3e228bdd 100644 --- a/packages/http-client-java/emitter/src/type-utils.ts +++ b/packages/http-client-java/emitter/src/type-utils.ts @@ -1,4 +1,20 @@ +import { + ArraySchema, + DictionarySchema, + GroupSchema, + ObjectSchema, + Schema, +} from "@autorest/codemodel"; import { getUnionAsEnum } from "@azure-tools/typespec-azure-core"; +import { + SdkDurationType, + SdkEnumType, + SdkModelType, + SdkType, + UsageFlags, + isSdkFloatKind, + isSdkIntKind, +} from "@azure-tools/typespec-client-generator-core"; import { DecoratedType, DecoratorApplication, @@ -20,15 +36,12 @@ import { isTemplateInstance, isTypeSpecValueTypeOf, } from "@typespec/compiler"; -import { DurationSchema } from "./common/schemas/time.js"; -import { getNamespace } from "./utils.js"; -import { SdkDurationType, SdkEnumType, SdkModelType, SdkType, UsageFlags, isSdkFloatKind, isSdkIntKind } from "@azure-tools/typespec-client-generator-core"; -import { SchemaContext, SchemaUsage } from "./common/schemas/usage.js"; import { ChoiceSchema, SealedChoiceSchema } from "./common/schemas/choice.js"; -import { OrSchema } from "./common/schemas/relationship.js"; import { ConstantSchema } from "./common/schemas/constant.js"; -import { ArraySchema, DictionarySchema, GroupSchema, ObjectSchema, Schema } from "@autorest/codemodel"; - +import { OrSchema } from "./common/schemas/relationship.js"; +import { DurationSchema } from "./common/schemas/time.js"; +import { SchemaContext, SchemaUsage } from "./common/schemas/usage.js"; +import { getNamespace } from "./utils.js"; /** Acts as a cache for processing inputs. * @@ -340,7 +353,10 @@ export function isArmCommonType(entity: Type): boolean { return false; } -export function processSchemaUsageFromSdkType(sdkType: SdkModelType | SdkEnumType, schemaUsage: SchemaContext[] | undefined): SchemaContext[] { +export function processSchemaUsageFromSdkType( + sdkType: SdkModelType | SdkEnumType, + schemaUsage: SchemaContext[] | undefined, +): SchemaContext[] { let usage: SchemaContext[] = schemaUsage ?? []; const usageFlags: UsageFlags = sdkType.usage; if (usageFlags & UsageFlags.Error) { @@ -353,15 +369,11 @@ export function processSchemaUsageFromSdkType(sdkType: SdkModelType | SdkEnumTyp if (usageFlags === 0) { return []; } - if (usageFlags & UsageFlags.Input) - usage = pushDistinct(usage, SchemaContext.Input); - if (usageFlags & UsageFlags.Output) - usage = pushDistinct(usage, SchemaContext.Output); - if (usageFlags & UsageFlags.JsonMergePatch) + if (usageFlags & UsageFlags.Input) usage = pushDistinct(usage, SchemaContext.Input); + if (usageFlags & UsageFlags.Output) usage = pushDistinct(usage, SchemaContext.Output); + if (usageFlags & UsageFlags.JsonMergePatch) usage = pushDistinct(usage, SchemaContext.JsonMergePatch); - if (usageFlags & UsageFlags.Spread) - usage = pushDistinct(usage, SchemaContext.Input); - + if (usageFlags & UsageFlags.Spread) usage = pushDistinct(usage, SchemaContext.Input); const accessFlags = sdkType.access; if (accessFlags === "internal") { @@ -397,7 +409,6 @@ export function trackSchemaUsage(schema: Schema, schemaUsage: SchemaUsage): void } } - function getDecoratorScopedValue( type: DecoratedType, decorator: string, From cde7d30f1ebee2fb9e02269e99707aa054e41eb8 Mon Sep 17 00:00:00 2001 From: Haoling Dong <87355844+haolingdong-msft@users.noreply.github.com> Date: Fri, 15 Nov 2024 17:27:33 +0800 Subject: [PATCH 26/26] format --- packages/http-client-java/emitter/src/common/schemas/usage.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/http-client-java/emitter/src/common/schemas/usage.ts b/packages/http-client-java/emitter/src/common/schemas/usage.ts index e0e4a47b7b..59e69d2c8e 100644 --- a/packages/http-client-java/emitter/src/common/schemas/usage.ts +++ b/packages/http-client-java/emitter/src/common/schemas/usage.ts @@ -23,7 +23,7 @@ export enum SchemaContext { PublicSpread = "spread", /** Schema is used in json-merge-patch operation */ - JsonMergePatch = "json-merge-patch" + JsonMergePatch = "json-merge-patch", } export interface SchemaUsage {