Skip to content

Commit d6b3ac1

Browse files
committed
fetchAllSecretsForWorkspace
1 parent d1abd04 commit d6b3ac1

File tree

6 files changed

+4522
-266
lines changed

6 files changed

+4522
-266
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
## 1.2.0 (August 30, 2021)
2+
* Added `fetchAllSecretsForWorkspace` method to `PlatformApiLogicClient`
3+
14
## 1.1.7 (August 30, 2021)
25
* Added `PlatformApiRestClient` and `PlatformApiLogicClient` classes from `IPaaS-core-component`
36

lib/platformApi/PlatformApiLogicClient.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,33 @@ export class PlatformApiLogicClient extends PlatformApiRestClient {
8080
}));
8181
}
8282

83+
/**
84+
* Fetch all credentials for a given workspace
85+
* @param {string} options.workspaceId
86+
* @returns {Promise<[{{
87+
* secretId: string,
88+
* secretName: string,
89+
* componentIds: string[],
90+
* }}]>}
91+
*/
92+
async fetchAllSecretsForWorkspace(options: any = {}) {
93+
const { workspaceId } = options;
94+
const secrets = await this.makeRequest({ method: 'GET', url: `/workspaces/${workspaceId}/secrets` });
95+
const resp: any = {};
96+
97+
for (const secret of secrets.data) {
98+
resp.secretId = secret.id;
99+
resp.secretName = secret.attributes.name.trim();
100+
if (secret.relationships.component) resp.componentIds = [secret.relationships.component.data.id];
101+
if (secret.relationships.auth_client) {
102+
const clientId = secret.relationships.auth_client.data.id;
103+
const clientResponse = await this.makeRequest({ method: 'GET', url: `/auth-clients/${clientId}` });
104+
resp.componentIds = clientResponse.relationships.components.data.map(x => x.id);
105+
}
106+
}
107+
return resp;
108+
}
109+
83110
/**
84111
* Fetch All Components Accessible From a Given Workspace
85112
* @param {string} options.contractId Contract ID

0 commit comments

Comments
 (0)