UNPKG

@azure-tools/typespec-java

Version:

TypeSpec library for emitting Java client from the TypeSpec REST protocol binding

84 lines 2.81 kB
/* eslint-disable @typescript-eslint/no-unsafe-declaration-merging */ import { Aspect, ImplementationLocation, Metadata, SchemaType, } from "@autorest/codemodel"; export class ConvenienceApi extends Metadata { constructor(name, initializer) { super(); this.apply({ language: { default: { name: name, }, }, }, initializer); } } export class Request extends Metadata { constructor(initializer) { super(); this.apply(initializer); } addParameter(parameter) { (this.parameters = this.parameters || []).push(parameter); this.updateSignatureParameters(); return parameter; } updateSignatureParameters() { var _a; if (this.parameters) { this.signatureParameters = ((_a = this.parameters) !== null && _a !== void 0 ? _a : []).filter((each) => each.schema.type !== SchemaType.Constant && each.implementation !== ImplementationLocation.Client && !each.groupedBy && !each.flattened); } } } export class Operation extends Aspect { constructor($key, description, initializer) { super($key, description); this.apply(initializer); } /** add a request to the operation */ addRequest(request) { (this.requests = this.requests || []).push(request); return request; } addParameter(parameter) { (this.parameters = this.parameters || []).push(parameter); this.updateSignatureParameters(); return parameter; } updateSignatureParameters() { var _a; if (this.parameters) { this.signatureParameters = ((_a = this.parameters) !== null && _a !== void 0 ? _a : []).filter((each) => each.schema.type !== SchemaType.Constant && each.implementation !== ImplementationLocation.Client && !each.groupedBy && !each.flattened); } } addResponse(response) { (this.responses = this.responses || []).push(response); return response; } addException(exception) { (this.exceptions = this.exceptions || []).push(exception); return exception; } addProfile(profileName, apiVersion) { (this.profile = this.profile || {})[profileName] = apiVersion; return this; } } export class OperationGroup extends Metadata { constructor(name, objectInitializer) { super(); this.$key = name; this.apply(objectInitializer); this.language.default.name = name; } addOperation(operation) { (this.operations = this.operations || []).push(operation); return operation; } } //# sourceMappingURL=operation.js.map