@jfvilas/plugin-kwirth-log 0.12.3 → 0.12.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -12,7 +12,7 @@ class KwirthLogClient {
|
|
|
12
12
|
*/
|
|
13
13
|
async getVersion() {
|
|
14
14
|
try {
|
|
15
|
-
const baseUrl = await this.discoveryApi.getBaseUrl("
|
|
15
|
+
const baseUrl = await this.discoveryApi.getBaseUrl("kwirth");
|
|
16
16
|
const targetUrl = `${baseUrl}/version`;
|
|
17
17
|
const result = await this.fetchApi.fetch(targetUrl);
|
|
18
18
|
const data = await result.json();
|
|
@@ -26,7 +26,7 @@ class KwirthLogClient {
|
|
|
26
26
|
}
|
|
27
27
|
async getResources(entity) {
|
|
28
28
|
try {
|
|
29
|
-
const baseUrl = await this.discoveryApi.getBaseUrl("
|
|
29
|
+
const baseUrl = await this.discoveryApi.getBaseUrl("kwirth");
|
|
30
30
|
const targetUrl = `${baseUrl}/start`;
|
|
31
31
|
var payload = JSON.stringify(entity);
|
|
32
32
|
const result = await this.fetchApi.fetch(targetUrl, { method: "POST", body: payload, headers: { "Content-Type": "application/json" } });
|
|
@@ -41,7 +41,7 @@ class KwirthLogClient {
|
|
|
41
41
|
}
|
|
42
42
|
async requestAccess(entity, channel, scopes) {
|
|
43
43
|
try {
|
|
44
|
-
const baseUrl = await this.discoveryApi.getBaseUrl("
|
|
44
|
+
const baseUrl = await this.discoveryApi.getBaseUrl("kwirth");
|
|
45
45
|
var targetUrl = new URL(`${baseUrl}/access`);
|
|
46
46
|
targetUrl.searchParams.append("scopes", scopes.join(","));
|
|
47
47
|
targetUrl.searchParams.append("channel", channel);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"KwirthLogClient.esm.js","sources":["../../src/api/KwirthLogClient.ts"],"sourcesContent":["/*\r\nCopyright 2024 Julio Fernandez\r\n\r\nLicensed under the Apache License, Version 2.0 (the \"License\");\r\nyou may not use this file except in compliance with the License.\r\nYou may obtain a copy of the License at\r\n\r\n http://www.apache.org/licenses/LICENSE-2.0\r\n\r\nUnless required by applicable law or agreed to in writing, software\r\ndistributed under the License is distributed on an \"AS IS\" BASIS,\r\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\nSee the License for the specific language governing permissions and\r\nlimitations under the License.\r\n*/\r\nimport { DiscoveryApi, FetchApi } from '@backstage/core-plugin-api'\r\nimport { KwirthLogApi } from './types'\r\nimport { Entity } from '@backstage/catalog-model'\r\nimport { ClusterValidPods } from '@jfvilas/plugin-kwirth-common'\r\nimport { InstanceConfigScopeEnum } from '@jfvilas/kwirth-common'\r\n\r\nexport interface KwirthLogClientOptions {\r\n discoveryApi: DiscoveryApi\r\n fetchApi: FetchApi\r\n}\r\n\r\nexport class KwirthLogClient implements KwirthLogApi {\r\n private readonly discoveryApi: DiscoveryApi\r\n private readonly fetchApi: FetchApi\r\n\r\n constructor(options: KwirthLogClientOptions) {\r\n this.discoveryApi = options.discoveryApi\r\n this.fetchApi = options.fetchApi\r\n }\r\n\r\n /**\r\n * \r\n * @param entity \r\n * @returns an array of clusters (with their correpsonding info) and a pod list for each, where the entity has been dicovered\r\n */\r\n async getVersion(): Promise<string> {\r\n try {\r\n const baseUrl = await this.discoveryApi.getBaseUrl('
|
|
1
|
+
{"version":3,"file":"KwirthLogClient.esm.js","sources":["../../src/api/KwirthLogClient.ts"],"sourcesContent":["/*\r\nCopyright 2024 Julio Fernandez\r\n\r\nLicensed under the Apache License, Version 2.0 (the \"License\");\r\nyou may not use this file except in compliance with the License.\r\nYou may obtain a copy of the License at\r\n\r\n http://www.apache.org/licenses/LICENSE-2.0\r\n\r\nUnless required by applicable law or agreed to in writing, software\r\ndistributed under the License is distributed on an \"AS IS\" BASIS,\r\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\nSee the License for the specific language governing permissions and\r\nlimitations under the License.\r\n*/\r\nimport { DiscoveryApi, FetchApi } from '@backstage/core-plugin-api'\r\nimport { KwirthLogApi } from './types'\r\nimport { Entity } from '@backstage/catalog-model'\r\nimport { ClusterValidPods } from '@jfvilas/plugin-kwirth-common'\r\nimport { InstanceConfigScopeEnum } from '@jfvilas/kwirth-common'\r\n\r\nexport interface KwirthLogClientOptions {\r\n discoveryApi: DiscoveryApi\r\n fetchApi: FetchApi\r\n}\r\n\r\nexport class KwirthLogClient implements KwirthLogApi {\r\n private readonly discoveryApi: DiscoveryApi\r\n private readonly fetchApi: FetchApi\r\n\r\n constructor(options: KwirthLogClientOptions) {\r\n this.discoveryApi = options.discoveryApi\r\n this.fetchApi = options.fetchApi\r\n }\r\n\r\n /**\r\n * \r\n * @param entity \r\n * @returns an array of clusters (with their correpsonding info) and a pod list for each, where the entity has been dicovered\r\n */\r\n async getVersion(): Promise<string> {\r\n try {\r\n const baseUrl = await this.discoveryApi.getBaseUrl('kwirth')\r\n const targetUrl = `${baseUrl}/version`\r\n\r\n const result = await this.fetchApi.fetch(targetUrl)\r\n const data = await result.json()\r\n\r\n if (!result.ok) {\r\n throw new Error(`getVersion error: not ok`)\r\n }\r\n return data.version\r\n }\r\n catch (err) {\r\n throw new Error(`getVersion error: ${err}`)\r\n }\r\n }\r\n\r\n async getResources(entity:Entity): Promise<ClusterValidPods> {\r\n try {\r\n const baseUrl = await this.discoveryApi.getBaseUrl('kwirth')\r\n const targetUrl = `${baseUrl}/start`\r\n\r\n var payload=JSON.stringify(entity)\r\n const result = await this.fetchApi.fetch(targetUrl, {method:'POST', body:payload, headers:{'Content-Type':'application/json'}})\r\n const data = await result.json() as ClusterValidPods\r\n\r\n if (!result.ok) {\r\n throw new Error(`getResources error: not ok`)\r\n }\r\n return data\r\n }\r\n catch (err) {\r\n throw new Error(`getResources error: ${err}`)\r\n }\r\n }\r\n\r\n async requestAccess(entity:Entity, channel:string, scopes:InstanceConfigScopeEnum[]): Promise<ClusterValidPods[]> {\r\n try {\r\n const baseUrl = await this.discoveryApi.getBaseUrl('kwirth')\r\n var targetUrl:URL= new URL (`${baseUrl}/access`)\r\n targetUrl.searchParams.append('scopes',scopes.join(',')) //+++ poner mas elegante\r\n targetUrl.searchParams.append('channel',channel)\r\n\r\n var payload=JSON.stringify(entity)\r\n const result = await this.fetchApi.fetch(targetUrl, {method:'POST', body:payload, headers:{'Content-Type':'application/json'}})\r\n const data = await result.json() as ClusterValidPods[]\r\n\r\n // we reconstruct the 'Map' from string of arrays\r\n for (var c of data) {\r\n c.accessKeys = new Map(JSON.parse(((c as any).accessKeys)))\r\n }\r\n if (!result.ok) {\r\n throw new Error(`requestAccess error: not ok`)\r\n }\r\n return data\r\n }\r\n catch (err) {\r\n throw new Error(`requestAccess error: ${err}`)\r\n }\r\n }\r\n\r\n}\r\n"],"names":[],"mappings":"AA0BO,MAAM,eAAwC,CAAA;AAAA,EAChC,YAAA;AAAA,EACA,QAAA;AAAA,EAEjB,YAAY,OAAiC,EAAA;AACzC,IAAA,IAAA,CAAK,eAAe,OAAQ,CAAA,YAAA;AAC5B,IAAA,IAAA,CAAK,WAAW,OAAQ,CAAA,QAAA;AAAA;AAC5B;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,MAAM,UAA8B,GAAA;AAChC,IAAI,IAAA;AACA,MAAA,MAAM,OAAU,GAAA,MAAM,IAAK,CAAA,YAAA,CAAa,WAAW,QAAQ,CAAA;AAC3D,MAAM,MAAA,SAAA,GAAY,GAAG,OAAO,CAAA,QAAA,CAAA;AAE5B,MAAA,MAAM,MAAS,GAAA,MAAM,IAAK,CAAA,QAAA,CAAS,MAAM,SAAS,CAAA;AAClD,MAAM,MAAA,IAAA,GAAO,MAAM,MAAA,CAAO,IAAK,EAAA;AAE/B,MAAI,IAAA,CAAC,OAAO,EAAI,EAAA;AACZ,QAAM,MAAA,IAAI,MAAM,CAA0B,wBAAA,CAAA,CAAA;AAAA;AAE9C,MAAA,OAAO,IAAK,CAAA,OAAA;AAAA,aAET,GAAK,EAAA;AACR,MAAA,MAAM,IAAI,KAAA,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