UNPKG

@autorest/codemodel

Version:
80 lines 2.86 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.OperationGroup = exports.Operation = exports.Request = void 0; const aspect_1 = require("./aspect"); const metadata_1 = require("./metadata"); const parameter_1 = require("./parameter"); const schema_type_1 = require("./schema-type"); class Request extends metadata_1.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 !== schema_type_1.SchemaType.Constant && each.implementation !== parameter_1.ImplementationLocation.Client && !each.groupedBy && !each.flattened); } } } exports.Request = Request; class Operation extends aspect_1.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 !== schema_type_1.SchemaType.Constant && each.implementation !== parameter_1.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; } } exports.Operation = Operation; class OperationGroup extends metadata_1.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; } } exports.OperationGroup = OperationGroup; //# sourceMappingURL=operation.js.map