|
9 | 9 | *
|
10 | 10 | */
|
11 | 11 |
|
12 |
| -import { getResource, ICMCIApiResponse } from "@zowe/cics-for-zowe-sdk"; |
| 12 | +import { getCache, getResource, ICMCIApiResponse } from "@zowe/cics-for-zowe-sdk"; |
13 | 13 | import { Session } from "@zowe/imperative";
|
14 | 14 | import { imperative, Types, ZoweVsCodeExtension } from "@zowe/zowe-explorer-api";
|
15 |
| -import axios, { AxiosRequestConfig } from "axios"; |
16 | 15 | import { window } from "vscode";
|
17 | 16 | import { xml2json } from "xml-js";
|
18 | 17 | import { CICSPlexTree } from "../trees/CICSPlexTree";
|
@@ -70,17 +69,6 @@ export class ProfileManagement {
|
70 | 69 | return mProfileInfo;
|
71 | 70 | }
|
72 | 71 |
|
73 |
| - /** |
74 |
| - * Makes axios GET request with path and axios config object given |
75 |
| - * @param path |
76 |
| - * @param config |
77 |
| - * @returns |
78 |
| - */ |
79 |
| - public static async makeRequest(path: string, config: AxiosRequestConfig) { |
80 |
| - const response = await axios.get(path, config); |
81 |
| - return response; |
82 |
| - } |
83 |
| - |
84 | 72 | public static cmciResponseXml2Json(data: string) {
|
85 | 73 | return JSON.parse(xml2json(data, { compact: true, spaces: 4 }));
|
86 | 74 | }
|
@@ -330,21 +318,25 @@ export class ProfileManagement {
|
330 | 318 |
|
331 | 319 | public static async getCachedResources(profile: imperative.IProfileLoaded, cacheToken: string, resourceName: string, start = 1, increment = 800) {
|
332 | 320 | try {
|
333 |
| - const config: AxiosRequestConfig = { |
334 |
| - baseURL: `${profile.profile.protocol}://${profile.profile.host}:${profile.profile.port}/CICSSystemManagement`, |
335 |
| - auth: { |
336 |
| - username: profile.profile.user, |
337 |
| - password: profile.profile.password, |
338 |
| - }, |
339 |
| - }; |
340 |
| - const allItemsResponse = await ProfileManagement.makeRequest(`/CICSResultCache/${cacheToken}/${start}/${increment}`, config); |
341 |
| - if (allItemsResponse.status === 200) { |
342 |
| - const jsonFromXml = ProfileManagement.cmciResponseXml2Json(allItemsResponse.data); |
343 |
| - if (jsonFromXml.response && jsonFromXml.response.records && jsonFromXml.response.records[resourceName.toLowerCase()]) { |
344 |
| - const recordAttributes = jsonFromXml.response.records[resourceName.toLowerCase()]; |
345 |
| - const recordAttributesArr = toArray(recordAttributes); |
346 |
| - const returnedResources = recordAttributesArr.map((item: { _attributes: any; }) => item._attributes); |
347 |
| - return returnedResources; |
| 321 | + const session = new Session({ |
| 322 | + protocol: profile.profile.protocol, |
| 323 | + hostname: profile.profile.host, |
| 324 | + port: profile.profile.port, |
| 325 | + type: "basic", |
| 326 | + user: profile.profile.user, |
| 327 | + password: profile.profile.password, |
| 328 | + rejectUnauthorized: profile.profile && 'rejectUnauthorized' in profile.profile ? profile.profile.rejectUnauthorized : true, |
| 329 | + }); |
| 330 | + const allItemsresponse = await getCache(session, { |
| 331 | + cacheToken, |
| 332 | + startIndex: start, |
| 333 | + count: increment, |
| 334 | + }); |
| 335 | + |
| 336 | + if (allItemsresponse.response.resultsummary.api_response1_alt === "OK") { |
| 337 | + if (allItemsresponse.response && allItemsresponse.response.records && allItemsresponse.response.records[resourceName.toLowerCase()]) { |
| 338 | + const recordAttributes = allItemsresponse.response.records[resourceName.toLowerCase()]; |
| 339 | + return toArray(recordAttributes); |
348 | 340 | }
|
349 | 341 | }
|
350 | 342 | } catch (error) {
|
|
0 commit comments