"use strict";
/*---------------------------------------------------------------------------------------------
 *  Copyright (c) Microsoft Corporation. All rights reserved.
 *  Licensed under the MIT License. See License.txt in the project root for license information.
 *--------------------------------------------------------------------------------------------*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.isWritableCmdlet = exports.CommandComponents = exports.CommandOperation = exports.CommandType = exports.OperationType = void 0;
const components_1 = require("./components");
const extensions_1 = require("./extensions");
const uid_1 = require("./uid");
const linq_1 = require("@azure-tools/linq");
var OperationType;
(function (OperationType) {
    OperationType["Create"] = "create";
    OperationType["Update"] = "update";
    OperationType["Other"] = "other";
})(OperationType || (exports.OperationType = OperationType = {}));
var CommandType;
(function (CommandType) {
    CommandType[CommandType["Atomic"] = 0] = "Atomic";
    CommandType[CommandType["GetPut"] = 1] = "GetPut";
    CommandType[CommandType["ManagedIdentityUpdate"] = 2] = "ManagedIdentityUpdate";
    CommandType[CommandType["ManagedIdentityNew"] = 3] = "ManagedIdentityNew";
})(CommandType || (exports.CommandType = CommandType = {}));
class CommandOperation extends extensions_1.Extensions {
    constructor(name, initializer, commandType) {
        super();
        this.extensions = new linq_1.Dictionary();
        this.responses = new linq_1.Dictionary();
        this.details = {
            default: {
                uid: `command-operation:${(0, uid_1.uid)()}`,
                description: (initializer === null || initializer === void 0 ? void 0 : initializer.description) || '',
                name,
            }
        };
        this.deprecated = false;
        this.pure = true;
        this.commandType = commandType !== null && commandType !== void 0 ? commandType : CommandType.Atomic;
        this.apply(initializer);
    }
}
exports.CommandOperation = CommandOperation;
class CommandComponents extends components_1.Components {
}
exports.CommandComponents = CommandComponents;
function isWritableCmdlet(operation) {
    var _a, _b, _c;
    if (operation.callGraph.length > 0 && operation.callGraph[operation.callGraph.length - 1].requests) {
        switch ((_c = (_b = (_a = operation.callGraph[operation.callGraph.length - 1].requests) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.protocol.http) === null || _c === void 0 ? void 0 : _c.method.toLowerCase()) {
            case 'put':
            case 'post':
            case 'delete':
            case 'patch':
                return true;
        }
    }
    return false;
}
exports.isWritableCmdlet = isWritableCmdlet;
//# sourceMappingURL=command-operation.js.map