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 4bb8473039..2f688c833f 100644 --- a/packages/http-client-java/emitter/src/code-model-builder.ts +++ b/packages/http-client-java/emitter/src/code-model-builder.ts @@ -152,7 +152,9 @@ import { getUsage, isStable, modelIs, + processSchemaUsageFromSdkType, pushDistinct, + trackSchemaUsage, } from "./type-utils.js"; import { getNamespace, @@ -265,7 +267,7 @@ export class CodeModelBuilder { this.processModels(); - this.processSchemaUsage(); + this.postProcessSchemaUsage(); this.deduplicateSchemaName(); @@ -280,9 +282,6 @@ export class CodeModelBuilder { parameter = this.createApiVersionParameter(arg.name, ParameterLocation.Uri); } else { const schema = this.processSchema(arg.type, arg.name); - this.trackSchemaUsage(schema, { - usage: [SchemaContext.Input, SchemaContext.Output /*SchemaContext.Public*/], - }); parameter = new Parameter(arg.name, arg.doc ?? "", schema, { implementation: ImplementationLocation.Client, origin: "modelerfour:synthesized/host", @@ -383,47 +382,21 @@ 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); - - this.trackSchemaUsage(schema, { - usage: [SchemaContext.Internal], - }); + if (access) { + this.processSchema(model, ""); } const usage = getUsage(model.__raw, usageCache); if (usage) { - const schema = this.processSchema(model, ""); - - this.trackSchemaUsage(schema, { - usage: usage, - }); + this.processSchema(model, ""); } - - processedSdkModels.add(model); } } } - 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(); @@ -930,7 +903,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; @@ -1004,7 +977,6 @@ export class CodeModelBuilder { } } - // track usage if (pollingSchema) { this.trackSchemaUsage(pollingSchema, { usage: [SchemaContext.Output] }); if (trackConvenienceApi) { @@ -1013,14 +985,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, @@ -1199,14 +1163,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], - }); - } } } @@ -1307,13 +1263,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 ( @@ -1385,20 +1334,11 @@ 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 + 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], }); - } - - if (jsonMergePatch) { this.trackSchemaUsage(schema, { usage: [SchemaContext.JsonMergePatch] }); } if (op.convenienceApi && operationIsMultipart(sdkHttpOperation)) { @@ -1433,14 +1373,6 @@ export class CodeModelBuilder { 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] }); - } - if (op.convenienceApi && op.parameters) { op.convenienceApi.requests = []; const request = new Request({ @@ -1606,11 +1538,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 | "*", @@ -1628,6 +1555,7 @@ export class CodeModelBuilder { if (sdkResponse.headers) { for (const header of sdkResponse.headers) { const schema = this.processSchema(header.type, header.serializedName); + headers.push( new HttpHeader(header.serializedName, schema, { language: { @@ -1642,7 +1570,6 @@ export class CodeModelBuilder { } const bodyType: SdkType | undefined = sdkResponse.type; - let trackConvenienceApi: boolean = Boolean(op.convenienceApi); const unknownResponseBody = sdkResponse.contentTypes && @@ -1671,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"); } @@ -1719,16 +1642,6 @@ export class CodeModelBuilder { } } else { 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], - }); - } - } } } @@ -1964,6 +1877,7 @@ export class CodeModelBuilder { }, }); schema.crossLanguageDefinitionId = type.crossLanguageDefinitionId; + schema.usage = processSchemaUsageFromSdkType(type, schema.usage); return this.codeModel.schemas.add(schema); } @@ -2066,6 +1980,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)) { @@ -2623,83 +2539,24 @@ export class CodeModelBuilder { private _subscriptionParameter?: Parameter; - private propagateSchemaUsage(schema: Schema): void { - const processedSchemas = new Set(); - - const innerApplySchemaUsage = (schema: Schema, schemaUsage: SchemaUsage) => { - this.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); + private postProcessSchemaUsage(): void { + 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 + usages.splice(usages.indexOf(SchemaContext.Internal), 1); } }; - - // 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); + 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 { diff --git a/packages/http-client-java/emitter/src/external-schemas.ts b/packages/http-client-java/emitter/src/external-schemas.ts index 448f420b66..b0d6f35cc6 100644 --- a/packages/http-client-java/emitter/src/external-schemas.ts +++ b/packages/http-client-java/emitter/src/external-schemas.ts @@ -15,6 +15,8 @@ import { SdkType, } from "@azure-tools/typespec-client-generator-core"; import { CrossLanguageDefinition } from "./common/client.js"; +import { SchemaContext } from "./common/schemas/usage.js"; +import { trackSchemaUsage } from "./type-utils.js"; import { getNamespace, pascalCase } from "./utils.js"; /* @@ -369,6 +371,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 @@ -388,6 +392,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 ab5e6e6bee..1a3e228bdd 100644 --- a/packages/http-client-java/emitter/src/type-utils.ts +++ b/packages/http-client-java/emitter/src/type-utils.ts @@ -1,8 +1,17 @@ +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"; @@ -27,8 +36,11 @@ import { isTemplateInstance, isTypeSpecValueTypeOf, } from "@typespec/compiler"; +import { ChoiceSchema, SealedChoiceSchema } from "./common/schemas/choice.js"; +import { ConstantSchema } from "./common/schemas/constant.js"; +import { OrSchema } from "./common/schemas/relationship.js"; import { DurationSchema } from "./common/schemas/time.js"; -import { SchemaContext } from "./common/schemas/usage.js"; +import { SchemaContext, SchemaUsage } from "./common/schemas/usage.js"; import { getNamespace } from "./utils.js"; /** Acts as a cache for processing inputs. @@ -341,6 +353,62 @@ 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.ApiVersionEnum) { + return []; + } + 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) + 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, 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 new file mode 100644 index 0000000000..c76a950252 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/_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 _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/_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 new file mode 100644 index 0000000000..f9c5737260 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/_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 _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/_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 new file mode 100644 index 0000000000..4d8f45d0e2 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/_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 _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/_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 new file mode 100644 index 0000000000..bcd10aa38e --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/_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 _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/_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 new file mode 100644 index 0000000000..6c698a53f6 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/_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 _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/_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 new file mode 100644 index 0000000000..4a1da39f68 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/_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 _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/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 new file mode 100644 index 0000000000..81bc9c8ad8 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/client/structure/service/models/ClientType.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 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"), + + /** + * Enum value client-operation-group. + */ + CLIENT_OPERATION_GROUP("client-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/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 new file mode 100644 index 0000000000..39f210ff84 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/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 client.structure.service.models; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/specialheaders/repeatability/models/ImmediateSuccessResponseRepeatabilityResult.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/specialheaders/repeatability/models/ImmediateSuccessResponseRepeatabilityResult.java new file mode 100644 index 0000000000..57ca7659ec --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/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 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/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 new file mode 100644 index 0000000000..3faae9a09c --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/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 specialheaders.repeatability.models; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/builtin/models/Builtin.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/builtin/models/Builtin.java index fa9e91e2fe..48fc385b5c 100644 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/builtin/models/Builtin.java +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/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/tsptest/builtin/models/Encoded.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/builtin/models/Encoded.java index e615447969..b7c43bd7c3 100644 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/builtin/models/Encoded.java +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/builtin/models/Encoded.java @@ -4,8 +4,8 @@ package tsptest.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/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/literalservice/models/PutRequestOptionalLiteralParam.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/literalservice/models/PutRequestOptionalLiteralParam.java deleted file mode 100644 index cb7a97ebb0..0000000000 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/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 tsptest.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/tsptest/longrunning/models/LroOperationStatusError.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/longrunning/models/LroOperationStatusError.java new file mode 100644 index 0000000000..afd4890dff --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/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 tsptest.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/tsptest/longrunning/models/RepeatabilityResult.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/longrunning/models/RepeatabilityResult.java new file mode 100644 index 0000000000..05cf843ef2 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/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 tsptest.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/tsptest/multicontenttypes/MultiContentTypesAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/multicontenttypes/MultiContentTypesAsyncClient.java index e6797a78d5..9348eb186c 100644 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/multicontenttypes/MultiContentTypesAsyncClient.java +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/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/tsptest/multicontenttypes/MultiContentTypesClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/multicontenttypes/MultiContentTypesClient.java index 0d180e1264..0370c46580 100644 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/multicontenttypes/MultiContentTypesClient.java +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/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/tsptest/multicontenttypes/MultipleContentTypesOnRequestAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/multicontenttypes/MultipleContentTypesOnRequestAsyncClient.java index 4e95de7133..0d1ee045a7 100644 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/multicontenttypes/MultipleContentTypesOnRequestAsyncClient.java +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/multicontenttypes/MultipleContentTypesOnRequestAsyncClient.java @@ -62,8 +62,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 +90,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,8 +147,6 @@ 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); } diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/multicontenttypes/MultipleContentTypesOnRequestClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/multicontenttypes/MultipleContentTypesOnRequestClient.java index 897df58acb..11f781dce5 100644 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/multicontenttypes/MultipleContentTypesOnRequestClient.java +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/multicontenttypes/MultipleContentTypesOnRequestClient.java @@ -60,8 +60,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 +88,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,8 +144,6 @@ 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); } 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 new file mode 100644 index 0000000000..b003da3d3f --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/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 tsptest.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 + public 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/tsptest/protocolandconvenient/models/ResourceH.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/protocolandconvenient/models/ResourceH.java new file mode 100644 index 0000000000..df2abaa895 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/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 tsptest.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 + public 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/tsptest/specialheaders/models/RepeatabilityResult.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/specialheaders/models/RepeatabilityResult.java new file mode 100644 index 0000000000..3e1ec798ef --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/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 tsptest.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/tsptest/longrunning/models/OperationState.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/union/models/OperationState.java similarity index 98% rename from packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/longrunning/models/OperationState.java rename to packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/union/models/OperationState.java index 441a3282a8..8ec1bb7ca9 100644 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/longrunning/models/OperationState.java +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/union/models/OperationState.java @@ -2,7 +2,7 @@ // Licensed under the MIT License. // Code generated by Microsoft (R) TypeSpec Code Generator. -package tsptest.longrunning.models; +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 new file mode 100644 index 0000000000..6b2f97745b --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/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 tsptest.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/tsptest/versioning/models/OperationState.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/versioning/models/OperationState.java new file mode 100644 index 0000000000..6fd3a2b89e --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/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 tsptest.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/tsptest/versioning/models/ResourceOperationStatusResourceExportedResourceError.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/versioning/models/ResourceOperationStatusResourceExportedResourceError.java new file mode 100644 index 0000000000..81461a0db8 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/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 tsptest.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/type/property/optional/models/BooleanLiteralPropertyProperty.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/type/property/optional/models/BooleanLiteralPropertyProperty.java deleted file mode 100644 index fb21e83d31..0000000000 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/java/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 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/type/property/optional/models/FloatLiteralPropertyProperty.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/type/property/optional/models/FloatLiteralPropertyProperty.java deleted file mode 100644 index f52f360a7d..0000000000 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/java/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 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/type/property/optional/models/IntLiteralPropertyProperty.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/type/property/optional/models/IntLiteralPropertyProperty.java deleted file mode 100644 index 2b5ec41e17..0000000000 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/java/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 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/type/property/optional/models/StringLiteralPropertyProperty.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/type/property/optional/models/StringLiteralPropertyProperty.java deleted file mode 100644 index cbaebc95a3..0000000000 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/java/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 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 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/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", 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 3a0185f09d..8b0ae7c321 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; 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 6a53e01d6a..7e4705d7bf 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", @@ -71,6 +73,7 @@ interface MultipleContentTypesOnRequest { @route("upload/multi-body-types") @sharedRoute @post + @convenientAPI(false) uploadJsonOrBytesWithMultiBodyTypesForMultiContentTypes( @body data: bytes | Resource, @header contentType: @@ -106,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: @@ -126,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", @@ -135,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",