/* 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);
    }
    requests;
}
export class Request extends Metadata {
    constructor(initializer) {
        super();
        this.apply(initializer);
    }
    addParameter(parameter) {
        (this.parameters = this.parameters || []).push(parameter);
        this.updateSignatureParameters();
        return parameter;
    }
    updateSignatureParameters() {
        if (this.parameters) {
            this.signatureParameters = (this.parameters ?? []).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() {
        if (this.parameters) {
            this.signatureParameters = (this.parameters ?? []).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