Skip to content

Commit d1abd04

Browse files
authored
Merge pull request #53 from elasticio/migrate-platform-api-clients
Migrate platform api clients
2 parents dc3dbef + ae165e9 commit d1abd04

15 files changed

+1617
-4
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
## 1.1.7 (August 30, 2021)
2+
* Added `PlatformApiRestClient` and `PlatformApiLogicClient` classes from `IPaaS-core-component`
3+
14
## 1.1.6 (July 29, 2021)
25
* Now `getAttachment` from `AttachmentProcessor` may retrieve items from `Maester`
36

README.md

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
- [ApiKeyRestClient](#ApiKeyRestClient)
1010
- [CookieRestClient](#CookieRestClient)
1111
- [OAuth2AuthorizationCodeRestClient](#OAuth2AuthorizationCodeRestClient)
12+
- [Platform API Clients](#PlatformAPI-Clients)
13+
- [PlatformApiRestClient](#PlatformApiRestClient)
14+
- [PlatformApiLogicClient](#PlatformApiLogicClient)
1215
- [JSON Schema Converter](#JSON-Schema-Converter)
1316
- [JSON Transformation](#JSON-Transformation)
1417
- [Attachment Processor](#Attachment-Processor)
@@ -29,7 +32,7 @@ npm install @elastic.io/component-commons-library
2932
## REST Clients
3033
A number of REST Client classes are available to use and extend to create Clients for a given API.
3134

32-
Each of the REST Clients extends from the `NoAuthRestClient`, overriding the relevant methods.
35+
Each of the REST Clients extends from the `NoAuthRestClient`, overriding the relevant methods. Exception is PlatformApiRestClient and PlatformApiLogicClient.
3336

3437
### NoAuthRestClient
3538
[NoAuthRestClient](https://github.com/elasticio/component-commons-library/blob/master/lib/authentication/NoAuthRestClient.ts) class to make rest requests no no auth APIs by provided options.
@@ -135,6 +138,52 @@ Handles both V1 and V2 of the NTLM Protocol.
135138
const Client = new NtlmRestClient(emitter, cfg);
136139
```
137140

141+
## Platform API Clients
142+
A number of Platform API Client classes are available to use and extend them to create Clients for Platform API.
143+
144+
### PlatformApiRestClient
145+
[PlatformApiRestClient](https://github.com/elasticio/component-commons-library/blob/master/lib/authentication/PlatformApiRestClient.ts)
146+
class extends [BasicAuthRestClient](#BasicAuthRestClient) class.
147+
The method inside this class checks for the status code 200, if not, then throws an error. And also checks that the response came with the correct data in the JSON format and the other expected response headers.
148+
149+
#### constructor(emitter, cfg)
150+
- emitter - EIO emitting context.
151+
- cfg - configuration of EIO component object.
152+
153+
```
154+
const Client = new PlatformApiRestClient(emitter, cfg);
155+
```
156+
157+
### PlatformApiLogicClient
158+
[PlatformApiLogicClient](https://github.com/elasticio/component-commons-library/blob/master/lib/authentication/PlatformApiLogicClient.ts)
159+
class extends [PlatformApiRestClient](#PlatformApiRestClient) class.
160+
Contains useful methods to manipulate flow's state to set it either to active running or to inactive stopped, searching flows, workspaces, credentials and more.
161+
162+
#### constructor(emitter, cfg)
163+
- emitter - EIO emitting context.
164+
- cfg - configuration of EIO component object.
165+
166+
```
167+
const Client = new PlatformApiLogicClient(emitter, cfg);
168+
```
169+
170+
#### List of methods
171+
- fetchAllFlowsForWorkspace(options) - Fetch all flows for a given workspace
172+
- fetchAllCredentialsForWorkspace(options) - Fetch all credentials for a given workspace
173+
- fetchComponentsAccessibleFromContract(options) - Fetch All Components Accessible From a Given Workspace
174+
- splitParallelization(maxParallelization, splitFactor) - Helping method to calculate right number of parallel calls
175+
- fetchFlowList(options) - Fetches a list of flows
176+
- fetchWorkspaceList(options) - Fetch a list of all workspaces across all contracts for a user
177+
- fetchWorkspaceId(workspaceUniqueCriteria) - Given a set of unique criteria, find the workspace that matches
178+
- removeNonWritableProperties(flow, includeDataSamples) - Given a flow, remove the properties of the flow that are regularly changed by the system such as last executed time
179+
- fetchFlowId(flowUniqueCriteria) - Fetch flow by it's unique criteria
180+
- fetchFlowById(id) - Fetch flow by it's id
181+
- fetchFlowByNameAndWorkspaceId(flowName, workspaceId) - Fetch flow by flow name and workspace id
182+
- changeFlowState(options) - Given a flow, change the flow to a given state (running, stopped, etc)
183+
- startFlow(flowId, options) - sets the flow to active running state
184+
- stopFlow(flowId, options) - sets the flow to inactive stopped state
185+
- hydrateFlow(options) - Hydrates the flow using removeNonWritableProperties method, but additionally enriches the flow with all data samples, credential names, command and component Id fields.
186+
138187
## JSON Schema Converter
139188
Contains tools for JSON metadata generation
140189

0 commit comments

Comments
 (0)