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IACH,OAAO,CAAC,YAAY;IAapB;;;;;;;OAOG;IACH,OAAO,CAAC,uBAAuB;CAclC","file":"cim-connection.d.ts","sourcesContent":["import { Observable, throwError } from 'rxjs';\r\nimport { AjaxError } from 'rxjs/ajax';\r\nimport { catchError, tap } from 'rxjs/operators';\r\nimport { BatchConnection, BatchResponseItem } from './batch-connection';\r\nimport { Cim, CimMultiple, CimResult, CimSingle } from './cim';\r\nimport { headerConstants } from './http-constants';\r\nimport { Net } from './net';\r\nimport { NodeCimOutput, NodeConnection, NodeRequest, NodeRequestOptions } from './node-connection';\r\nimport { PowerShellAlternate } from './powershell-alternate';\r\n\r\n/**\r\n * The CIM Connection class.\r\n */\r\nexport class CimConnection {\r\n    /**\r\n     * Initializes a new instance of the CimService class.\r\n     *\r\n     * @param nodeConnection the NodeConnection class instance injected.\r\n     * @param batchConnection the BatchConnection class instance injected.\r\n     */\r\n    constructor(private nodeConnection: NodeConnection, private batchConnection: BatchConnection) { }\r\n\r\n    /**\r\n     * CIM GET MultipleInstances\r\n     *\r\n     * @param nodeName the name of the node to use for this request\r\n     * @param namespace the cim namespace.\r\n     * @param className the class name.\r\n     * @param options the options for this request.\r\n     * @return Observable<any> the query observable.\r\n     */\r\n    public getInstanceMultiple(\r\n            nodeName: string,\r\n            namespace: string,\r\n            className: string,\r\n            options?: NodeRequestOptions): Observable<CimMultiple> {\r\n        this.setPowerShellParameters(options, NodeCimOutput.Multiple);\r\n        const observable = PowerShellAlternate.create<CimMultiple>(this.nodeConnection, nodeName, options);\r\n        if (observable) {\r\n            return observable;\r\n        }\r\n\r\n        const cimUrl = Cim.cimUrlMultipleInstances(namespace, className);\r\n        return this.nodeConnection.get(nodeName, cimUrl, <NodeRequest>options)\r\n            .pipe(catchError(error => this.handleJeaFallback<CimMultiple>(error, nodeName, options)));\r\n    }\r\n\r\n    /**\r\n     * CIM GET SingleInstance\r\n     *\r\n     * @param nodeName the name of the node to use for this request\r\n     * @param namespace the cim namespace.\r\n     * @param className the class name.\r\n     * @param keyProperties the key properties object.\r\n     * @param options the options for this request.\r\n     * @return Observable<any> the query observable.\r\n     */\r\n    public getInstanceSingle(\r\n            nodeName: string,\r\n            namespace: string,\r\n            className: string,\r\n            keyProperties: any,\r\n            options?: NodeRequestOptions): Observable<CimSingle> {\r\n        this.setPowerShellParameters(options, NodeCimOutput.Single, keyProperties);\r\n        const observable = PowerShellAlternate.create<CimSingle>(this.nodeConnection, nodeName, options);\r\n        if (observable) {\r\n            return observable;\r\n        }\r\n\r\n        const cimUrl = Cim.cimUrlSingleInstance(namespace, className, keyProperties);\r\n        return this.nodeConnection.get(nodeName, cimUrl, <NodeRequest>options)\r\n            .pipe(catchError(error => this.handleJeaFallback<CimSingle>(error, nodeName, options)));\r\n    }\r\n\r\n    /**\r\n     * CIM POST InstanceMethod\r\n     *\r\n     * @param nodeName the name of the node to use for this request\r\n     * @param namespace the cim namespace.\r\n     * @param className the class name.\r\n     * @param methodName the method name.\r\n     * @param keyProperties the key properties object.\r\n     * @param data the method input data.\r\n     * @param options the options for this request.\r\n     * @return Observable<any> the query observable.\r\n     */\r\n    public invokeMethodInstance(\r\n            nodeName: string,\r\n            namespace: string,\r\n            className: string,\r\n            methodName: string,\r\n            keyProperties: any,\r\n            data?: any,\r\n            options?: NodeRequestOptions): Observable<CimResult> {\r\n        this.setPowerShellParameters(options, NodeCimOutput.Result, keyProperties, data && data.parameters);\r\n        const observable = PowerShellAlternate.create<CimResult>(this.nodeConnection, nodeName, options);\r\n        if (observable) {\r\n            return observable;\r\n        }\r\n\r\n        const cimUrl = Cim.cimUrlInstanceMethod(namespace, className, methodName, keyProperties);\r\n        return this.nodeConnection.post(nodeName, cimUrl, data, <NodeRequest>options)\r\n                .pipe(catchError(error => this.handleJeaFallback<CimResult>(error, nodeName, options)));\r\n    }\r\n\r\n    /**\r\n     * CIM POST StaticMethod\r\n     *\r\n     * @param nodeName the name of the node to use for this request\r\n     * @param namespace the cim namespace.\r\n     * @param className the class name.\r\n     * @param methodName the method name.\r\n     * @param data the method input data.\r\n     * @param options the options for this request.\r\n     * @return Observable<any> the query observable.\r\n     */\r\n    public invokeMethodStatic(\r\n            nodeName: string,\r\n            namespace: string,\r\n            className: string,\r\n            methodName: string,\r\n            data?: any,\r\n            options?: NodeRequestOptions): Observable<CimResult> {\r\n        this.setPowerShellParameters(options, NodeCimOutput.Result, data && data.parameters);\r\n        const observable = PowerShellAlternate.create<CimResult>(this.nodeConnection, nodeName, options);\r\n        if (observable) {\r\n            return observable;\r\n        }\r\n\r\n        const cimUrl = Cim.cimUrlStaticMethod(namespace, className, methodName);\r\n        return this.nodeConnection.post(nodeName, cimUrl, data, <NodeRequest>options)\r\n                .pipe(catchError(error => this.handleJeaFallback<CimResult>(error, nodeName, options)));\r\n    }\r\n\r\n    /**\r\n     * CIM PUT SingleInstance\r\n     *\r\n     * @param nodeName the name of the node to use for this request\r\n     * @param namespace the cim namespace.\r\n     * @param className the class name.\r\n     * @param keyProperties the key properties object.\r\n     * @param data the method input data.\r\n     * @param options the options for this request.\r\n     * @return Observable<any> the query observable.\r\n     */\r\n    public setInstance(\r\n            nodeName: string,\r\n            namespace: string,\r\n            className: string,\r\n            keyProperties: any,\r\n            data: any,\r\n            options?: NodeRequestOptions): Observable<CimSingle> {\r\n        this.setPowerShellParameters(options, NodeCimOutput.Single, keyProperties, data && data.properties);\r\n        const observable = PowerShellAlternate.create<CimSingle>(this.nodeConnection, nodeName, options);\r\n        if (observable) {\r\n            return observable;\r\n        }\r\n\r\n        const cimUrl = Cim.cimUrlSingleInstance(namespace, className, keyProperties);\r\n        return this.nodeConnection.put(nodeName, cimUrl, data, <NodeRequest>options)\r\n                .pipe(catchError(error => this.handleJeaFallback<CimSingle>(error, nodeName, options)));\r\n    }\r\n\r\n    /**\r\n     * CIM PATCH SingleInstance\r\n     *\r\n     * @param nodeName the name of the node to use for this request\r\n     * @param namespace the cim namespace.\r\n     * @param className the class name.\r\n     * @param keyProperties the key properties object.\r\n     * @param data the method input data.\r\n     * @param options the options for this request.\r\n     * @return Observable<any> the query observable.\r\n     */\r\n    public modifyInstance(\r\n            nodeName: string,\r\n            namespace: string,\r\n            className: string,\r\n            keyProperties: any,\r\n            data: any,\r\n            options?: NodeRequestOptions): Observable<CimSingle> {\r\n        this.setPowerShellParameters(options, NodeCimOutput.Single, keyProperties, data && data.properties);\r\n        const observable = PowerShellAlternate.create<CimSingle>(this.nodeConnection, nodeName, options);\r\n        if (observable) {\r\n            return observable;\r\n        }\r\n\r\n        const cimUrl = Cim.cimUrlSingleInstance(namespace, className, keyProperties);\r\n        return this.nodeConnection.patch(nodeName, cimUrl, data, <NodeRequest>options)\r\n                .pipe(catchError(error => this.handleJeaFallback<CimSingle>(error, nodeName, options)));\r\n    }\r\n\r\n    /**\r\n     * CIM DELETE SingleInstance\r\n     *\r\n     * @param nodeName the name of the node to use for this request\r\n     * @param namespace the cim namespace.\r\n     * @param className the class name.\r\n     * @param keyProperties the key properties object.\r\n     * @param options the options for this request.\r\n     * @return Observable<any> the query observable.\r\n     */\r\n    public deleteInstance(\r\n            nodeName: string,\r\n            namespace: string,\r\n            className: string,\r\n            keyProperties: any,\r\n            options?: NodeRequestOptions): Observable<CimSingle> {\r\n        this.setPowerShellParameters(options, NodeCimOutput.Single, keyProperties);\r\n        const observable = PowerShellAlternate.create<CimSingle>(this.nodeConnection, nodeName, options);\r\n        if (observable) {\r\n            return observable;\r\n        }\r\n\r\n        const cimUrl = Cim.cimUrlSingleInstance(namespace, className, keyProperties);\r\n        return this.nodeConnection.delete(nodeName, cimUrl, null, <NodeRequest>options)\r\n                .pipe(catchError(error => this.handleJeaFallback<CimSingle>(error, nodeName, options)));\r\n    }\r\n\r\n    /**\r\n     * CIM POST WqlQuery\r\n     *\r\n     * @param nodeName the name of the node to use for this request\r\n     * @param namespace the cim namespace.\r\n     * @param query the WQL string.\r\n     * @param options the options for this request.\r\n     * @return Observable<any> the query observable.\r\n     */\r\n    public getInstanceQuery(\r\n            nodeName: string,\r\n            namespace: string,\r\n            query: string,\r\n            options?: NodeRequestOptions): Observable<CimMultiple> {\r\n        this.setPowerShellParameters(options, NodeCimOutput.Query, options && options.powerShellParameters);\r\n        const observable = PowerShellAlternate.create<CimMultiple>(this.nodeConnection, nodeName, options);\r\n        if (observable) {\r\n            return observable;\r\n        }\r\n\r\n        const cimUrl = Cim.cimUrlWqlQuery(namespace);\r\n        return this.nodeConnection.post(nodeName, cimUrl, JSON.stringify({ query: query }), <NodeRequest>options)\r\n                .pipe(catchError(error => this.handleJeaFallback<CimMultiple>(error, nodeName, options)));\r\n    }\r\n\r\n    /**\r\n     * Handle the fallback from CIM to powershell with JEA, if applicable\r\n     * @param error The error to handle\r\n     * @param nodeName The node name\r\n     * @param options The request options\r\n     */\r\n    private handleJeaFallback<T>(error: AjaxError, nodeName: string, options: NodeRequestOptions): Observable<T> {\r\n        const authError = Net.isUnauthorized(error);\r\n        const responseEndpoint = error && error.xhr && error.xhr.getResponseHeader(headerConstants.POWERSHELL_ENDPOINT);\r\n        const requestEndpoint = options && options.powerShellEndpoint;\r\n\r\n        if (authError && responseEndpoint && requestEndpoint !== responseEndpoint) {\r\n            options.powerShellEndpoint = responseEndpoint;\r\n            const powershellRequest = PowerShellAlternate.create<T>(this.nodeConnection, nodeName, options);\r\n            if (powershellRequest) {\r\n                return powershellRequest\r\n                    .pipe(\r\n                        tap(() => {\r\n                            // The JEA request went through - persist this context in authorization manager.\r\n                            this.nodeConnection.saveJeaContext(nodeName, responseEndpoint);\r\n                        }));\r\n            }\r\n        }\r\n\r\n        return throwError(() => error);\r\n    }\r\n\r\n    /**********************************\r\n     * Cim Batch Section\r\n     **********************************/\r\n\r\n    /**\r\n     * CIM GET MultipleInstances for list of nodes\r\n     *\r\n     * @param nodeNamesList the Nodes to use for this request.\r\n     * @param namespace the cim namespace.\r\n     * @param className the class name.\r\n     * @param options the options for this request.\r\n     * @return Observable<BatchResponseItem[]> the query observable.\r\n     */\r\n    public getBatchInstanceMultiple(\r\n            nodeNamesList: string[],\r\n            namespace: string,\r\n            className: string,\r\n            options?: NodeRequestOptions): Observable<BatchResponseItem[]> {\r\n        this.setPowerShellParameters(options, NodeCimOutput.Multiple);\r\n        const observable = PowerShellAlternate.createBatch(this.nodeConnection, this.batchConnection, nodeNamesList, options);\r\n\r\n        if (observable) {\r\n            return observable;\r\n        }\r\n\r\n        const cimUrl = Cim.cimUrlMultipleInstances(namespace, className);\r\n        const urlList: string[] = [];\r\n        for (let index = 0; index < nodeNamesList.length; index++) {\r\n            urlList.push(cimUrl);\r\n        }\r\n\r\n        return this.batchConnection.get(nodeNamesList, urlList, <NodeRequest>options);\r\n    }\r\n\r\n    /**\r\n     * CIM GET SingleInstance for list of nodes\r\n     *\r\n     * @param nodeNamesList the Nodes to use for this request.\r\n     * @param namespace the cim namespace.\r\n     * @param className the class name.\r\n     * @param keyProperties the key properties object.\r\n     * @param options the options for this request.\r\n     * @return Observable<BatchResponseItem[]> the query observable.\r\n     */\r\n    public getBatchInstanceSingle(\r\n            nodeNamesList: string[],\r\n            namespace: string,\r\n            className: string,\r\n            keyProperties: any,\r\n            options?: NodeRequestOptions): Observable<BatchResponseItem[]> {\r\n        this.setPowerShellParameters(options, NodeCimOutput.Single, keyProperties);\r\n        const observable = PowerShellAlternate.createBatch(this.nodeConnection, this.batchConnection, nodeNamesList, options);\r\n\r\n        if (observable) {\r\n            return observable;\r\n        }\r\n\r\n        const cimUrl = Cim.cimUrlSingleInstance(namespace, className, keyProperties);\r\n        const urlList: string[] = [];\r\n        for (let index = 0; index < nodeNamesList.length; index++) {\r\n            urlList.push(cimUrl);\r\n        }\r\n\r\n        return this.batchConnection.get(nodeNamesList, urlList, <NodeRequest>options);\r\n    }\r\n\r\n    /**\r\n     * CIM POST InstanceMethod for list of nodes\r\n     *\r\n     * @param nodeNamesList the Nodes to use for this request.\r\n     * @param namespace the cim namespace.\r\n     * @param className the class name.\r\n     * @param methodName the method name.\r\n     * @param keyProperties the key properties object.\r\n     * @param data the method input data.\r\n     * @param options the options for this request.\r\n     * @return Observable<BatchResponseItem[]> the query observable.\r\n     */\r\n    public invokeBatchMethodInstance(\r\n            nodeNamesList: string[],\r\n            namespace: string,\r\n            className: string,\r\n            methodName: string,\r\n            keyProperties: any,\r\n            data?: any,\r\n            options?: NodeRequestOptions): Observable<BatchResponseItem[]> {\r\n        this.setPowerShellParameters(options, NodeCimOutput.Result, keyProperties, data && data.parameters);\r\n        const observable = PowerShellAlternate.createBatch(this.nodeConnection, this.batchConnection, nodeNamesList, options);\r\n\r\n        if (observable) {\r\n            return observable;\r\n        }\r\n\r\n        const cimUrl = Cim.cimUrlInstanceMethod(namespace, className, methodName, keyProperties);\r\n        const body = data ? JSON.stringify(data) : null;\r\n        return this.cimBatchPost(nodeNamesList, cimUrl, body, options);\r\n    }\r\n\r\n    /**\r\n     * CIM POST StaticMethod for list of nodes\r\n     *\r\n     * @param nodeNamesList the Nodes to use for this request.\r\n     * @param namespace the cim namespace.\r\n     * @param className the class name.\r\n     * @param methodName the method name.\r\n     * @param data the method input data.\r\n     * @param options the options for this request.\r\n     * @return Observable<BatchResponseItem[]> the query observable.\r\n     */\r\n    public invokeBatchMethodStatic(\r\n            nodeNamesList: string[],\r\n            namespace: string,\r\n            className: string,\r\n            methodName: string,\r\n            data?: any,\r\n            options?: NodeRequestOptions): Observable<BatchResponseItem[]> {\r\n        this.setPowerShellParameters(options, NodeCimOutput.Result, data && data.parameters);\r\n        const observable = PowerShellAlternate.createBatch(this.nodeConnection, this.batchConnection, nodeNamesList, options);\r\n\r\n        if (observable) {\r\n            return observable;\r\n        }\r\n\r\n        const cimUrl = Cim.cimUrlStaticMethod(namespace, className, methodName);\r\n        const body = data ? JSON.stringify(data) : null;\r\n        return this.cimBatchPost(nodeNamesList, cimUrl, body, options);\r\n    }\r\n\r\n    /**\r\n     * CIM PUT SingleInstance for list of nodes\r\n     *\r\n     * @param nodeName the name of the node to use for this request\r\n     * @param namespace the cim namespace.\r\n     * @param className the class name.\r\n     * @param keyProperties the key properties object.\r\n     * @param data the method input data.\r\n     * @param options the options for this request.\r\n     * @return Observable<BatchResponseItem[]> the query observable.\r\n     */\r\n    public setBatchInstance(\r\n            nodeNamesList: string[],\r\n            namespace: string,\r\n            className: string,\r\n            keyProperties: any,\r\n            data: any,\r\n            options?: NodeRequestOptions): Observable<BatchResponseItem[]> {\r\n        this.setPowerShellParameters(options, NodeCimOutput.Single, keyProperties, data && data.properties);\r\n        const observable = PowerShellAlternate.createBatch(this.nodeConnection, this.batchConnection, nodeNamesList, options);\r\n        if (observable) {\r\n            return observable;\r\n        }\r\n\r\n        const cimUrl = Cim.cimUrlSingleInstance(namespace, className, keyProperties);\r\n        const urlList: string[] = [];\r\n        const dataList: string[] = [];\r\n        for (let index = 0; index < nodeNamesList.length; index++) {\r\n            urlList.push(cimUrl);\r\n            dataList.push(JSON.stringify(data));\r\n        }\r\n\r\n        return this.batchConnection.put(nodeNamesList, urlList, dataList, <NodeRequest>options);\r\n    }\r\n\r\n    /**\r\n     * CIM DELETE SingleInstance for list of nodes\r\n     *\r\n     * @param nodeNamesList the Nodes to use for this request.\r\n     * @param namespace the cim namespace.\r\n     * @param className the class name.\r\n     * @param keyProperties the key properties object.\r\n     * @param options the options for this request.\r\n     * @return Observable<BatchResponseItem[]> the query observable.\r\n     */\r\n    public deleteBatchInstance(\r\n            nodeNamesList: string[],\r\n            namespace: string,\r\n            className: string,\r\n            keyProperties: any,\r\n            options?: NodeRequestOptions): Observable<BatchResponseItem[]> {\r\n        this.setPowerShellParameters(options, NodeCimOutput.Single, keyProperties);\r\n        const observable = PowerShellAlternate.createBatch(this.nodeConnection, this.batchConnection, nodeNamesList, options);\r\n        if (observable) {\r\n            return observable;\r\n        }\r\n\r\n        const cimUrl = Cim.cimUrlSingleInstance(namespace, className, keyProperties);\r\n        const urlList: string[] = [];\r\n        for (let index = 0; index < nodeNamesList.length; index++) {\r\n            urlList.push(cimUrl);\r\n        }\r\n\r\n        return this.batchConnection.delete(nodeNamesList, urlList, <NodeRequest>options);\r\n    }\r\n\r\n    /**\r\n     * CIM POST WqlQuery for list of nodes\r\n     *\r\n     * @param nodeNamesList the Nodes to use for this request.\r\n     * @param namespace the cim namespace.\r\n     * @param query the WQL string.\r\n     * @param options the options for this request.\r\n     * @return Observable<BatchResponseItem[]> the query observable.\r\n     */\r\n    public getBatchInstanceQuery(nodeNamesList: string[], namespace: string, query: string, options?: NodeRequestOptions): Observable<BatchResponseItem[]> {\r\n        this.setPowerShellParameters(options, NodeCimOutput.Query, options && options.powerShellParameters);\r\n        const observable = PowerShellAlternate.createBatch(this.nodeConnection, this.batchConnection, nodeNamesList, options);\r\n        if (observable) {\r\n            return observable;\r\n        }\r\n\r\n        const cimUrl = Cim.cimUrlWqlQuery(namespace);\r\n        const body = JSON.stringify({ query: query });\r\n        return this.cimBatchPost(nodeNamesList, cimUrl, body, options);\r\n    }\r\n\r\n    /**\r\n     * Cim batch post helper\r\n     *\r\n     * @param nodeNamesList The list of Nodes to run the call against\r\n     * @param cimUrl The CIM end point to call\r\n     * @param jsonBody The body of Post in json format.\r\n     * @param options the request options.\r\n     */\r\n    private cimBatchPost(nodeNamesList: string[], cimUrl: string, jsonBody: string, options?: NodeRequestOptions): Observable<BatchResponseItem[]> {\r\n        const urlList: string[] = [];\r\n        const bodyList: string[] = [];\r\n        for (let index = 0; index < nodeNamesList.length; index++) {\r\n            urlList.push(cimUrl);\r\n            if (jsonBody) {\r\n                bodyList.push(jsonBody);\r\n            }\r\n        }\r\n\r\n        return this.batchConnection.post(nodeNamesList, urlList, bodyList, <NodeRequest>options);\r\n    }\r\n\r\n    /**\r\n     * Set PowerShell parameters to the options object.\r\n     *\r\n     * @param options The node request options.\r\n     * @param outputType The output data type.\r\n     * @param keys The key data.\r\n     * @param data The arguments data.\r\n     */\r\n    private setPowerShellParameters(\r\n            options: NodeRequestOptions,\r\n            cimOutput: NodeCimOutput,\r\n            keys?: any,\r\n            data?: any): void {\r\n        if (options == null || options.powerShell == null) {\r\n            return;\r\n        }\r\n\r\n        options.powerShellContext = {\r\n            cimOutput,\r\n            parameters: { ...(keys || {}), ...(data || {}) }\r\n        };\r\n    }\r\n}\r\n"]}