@al/connectors
Version:
A lightweight client library for interacting with the Integrations API
361 lines (357 loc) • 10.7 kB
JavaScript
import { AlLocation, AlDefaultClient, AlGlobalizer } from '@al/core';
/**
* Integrations API client
*/
class AlConnectorsClientInstance {
constructor(client = null) {
this.serviceVersion = 'v1';
this.serviceStack = AlLocation.IntegrationsAPI;
this.client = client || AlDefaultClient;
}
/**
* Get a list of supported integration types
* GET
* /v1/integration_types
* https://integrations.mdr.global.alertlogic.com
*
* @returns a list of integration types
*
* @remarks
*
* */
async getIntegrationTypes() {
return this.client.get({
version: this.serviceVersion,
service_stack: this.serviceStack,
path: '/integration_types'
});
}
/**
* Get a list of supported integration types by account
* GET
* /v1/{account_id}/integration_types/{name}
* https://integrations.mdr.global.alertlogic.com
*
* @param accountId account id
* @param name integration name
* @returns a list of integration types
*
* @remarks
*
* */
async getIntegrationTypeByAccount(accountId, name) {
return this.client.get({
version: this.serviceVersion,
service_stack: this.serviceStack,
path: `/integration_types/${name}`,
account_id: accountId
});
}
/**
* Get integration type details
* GET
* /v1/integration_types/{name}
* https://integrations.mdr.global.alertlogic.com
*
* @returns an integration type
*
* @remarks
*
* */
async getIntegrationTypeByName(name) {
return this.client.get({
version: this.serviceVersion,
service_stack: this.serviceStack,
path: `/integration_types/${name}`
});
}
/**
* Returns Integration Connection Information
* GET
* /v1/{account_id}/connections
* https://integrations.mdr.global.alertlogic.com
*
* @returns an existing connection
*
* @remarks
*
* */
async getConnections(accountId, params) {
return this.client.get({
version: this.serviceVersion,
service_stack: this.serviceStack,
account_id: accountId,
params: params,
path: `/connections`
});
}
/**
* Returns Integration Connection Information
* GET
* /v1/{account_id}/connections/{id}
* https://integrations.mdr.global.alertlogic.com
*
* @returns an existing connection
*
* @remarks
*
* */
async getConnectionById(accountId, connectionId) {
return this.client.get({
version: this.serviceVersion,
service_stack: this.serviceStack,
account_id: accountId,
path: `/connections/${connectionId}`
});
}
/**
* Create a connection
* POST
* /v1/{account_id}/connections
*
* @param accountId account id
* @param payload
* @param dryRun
* @returns a promise with the new connection
*
* @remarks
*/
async createConnection(accountId, payload, dryRun) {
return this.client.post({
version: this.serviceVersion,
service_stack: this.serviceStack,
account_id: accountId,
path: `/connections`,
params: {
dry_run: dryRun
},
data: payload
});
}
/**
* Update a connection
* PUT
* /v1/{account_id}/connections/{id}
*
* @param accountId account id
* @param connectionId connection id
* @param payload
* @param dryRun When present and set to true just tests the connection without updating an existing connection instance.
* @returns a promise with the new connection
*
* @remarks
*/
async updateConnection(accountId, connectionId, payload, dryRun = false) {
return this.client.put({
version: this.serviceVersion,
service_stack: this.serviceStack,
account_id: accountId,
path: `/connections/${connectionId}`,
params: {
dry_run: dryRun
},
data: payload
});
}
/**
* Delete existing integration connection
* DELETE
* /v1/{account_id}/connections/{id}
*
* @param accountId The AIMS Account ID
* @param connectionId id
* @returns just the status code
*
* @remarks
*/
async deleteConnectionById(accountId, connectionId) {
const result = await this.client.delete({
version: this.serviceVersion,
service_stack: this.serviceStack,
account_id: accountId,
path: `/connections/${connectionId}`
});
return result;
}
/**
* Returns list of payload types
* GET
* /v1/payload_types
* https://integrations.mdr.global.alertlogic.com
*
* @remarks
*
* */
async getPayloadTypes() {
return this.client.get({
version: this.serviceVersion,
service_stack: this.serviceStack,
path: '/payload_types'
});
}
/**
* Returns a list of all connections targets for an account
* GET
* /v1/{account_id}/connection_targets
* https://connectors.mdr.product.dev.alertlogic.com
*
* @returns the list of connection targets
*
* @remarks
*
* */
async getConnectionTargets(accountId, params = {}) {
return this.client.get({
version: this.serviceVersion,
service_stack: this.serviceStack,
account_id: accountId,
params: params,
path: `/connection_targets`
});
}
/**
* Returns Get a list of supported connection targets
* GET
* /v1/connection_targets
* https://connectors.mdr.product.dev.alertlogic.com
*
* @returns the List of Connection Target with forms
*
* @remarks
*
* */
async getConnectionTargetsDefinitions() {
return this.client.get({
version: this.serviceVersion,
service_stack: this.serviceStack,
path: `/connection_targets`
});
}
/**
* Returns Connection Target Information
* GET
* /v1/{account_id}/connection_targets/{id}
* https://connectors.mdr.product.dev.alertlogic.com
*
* @param accountId account id
* @param connectionTargetId connection id
* @returns an existing connection target
*
* @remarks
*
* */
async getConnectionTargetById(accountId, connectionTargetId) {
return this.client.get({
version: this.serviceVersion,
service_stack: this.serviceStack,
account_id: accountId,
path: `/connection_targets/${connectionTargetId}`
});
}
/**
* Create a connection target
* POST
* /v1/{account_id}/connection_targets
* https://connectors.mdr.product.dev.alertlogic.com
*
* @param accountId account id
* @param payload connection target
* @returns a promise with the new connection
*
* @remarks
*/
async createConnectionTarget(accountId, payload) {
return this.client.post({
version: this.serviceVersion,
service_stack: this.serviceStack,
account_id: accountId,
path: `/connection_targets`,
data: payload
});
}
/**
* Updates existing connection target
* PUT
* /v1/{account_id}/connection_targets/{id}
* https://connectors.mdr.product.dev.alertlogic.com
*
* @param accountId account id
* @param connectionTargetId connection id
* @param payload
* @returns a promise with the new connection
*
* @remarks
*/
async updateConnectionTarget(accountId, connectionTargetId, payload) {
return this.client.put({
version: this.serviceVersion,
service_stack: this.serviceStack,
account_id: accountId,
path: `/connection_targets/${connectionTargetId}`,
data: payload
});
}
/**
* Deletes existing connection target
* DELETE
* /v1/{account_id}/connection_targets/{id}
* https://connectors.mdr.product.dev.alertlogic.com
*
* @param accountId The AIMS Account ID
* @param connectionTargetId connection id
* @returns just the status code
*
* @remarks
*/
async deleteConnectionTargetById(accountId, connectionTargetId) {
const result = await this.client.delete({
version: this.serviceVersion,
service_stack: this.serviceStack,
account_id: accountId,
path: `/connection_targets/${connectionTargetId}`
});
return result;
}
/**
* Returns Get a list of supported connection targets
* GET
* /v1/{{accountId}}/definitions/connection_targets
* https://connectors.mdr.product.dev.alertlogic.com
*
* @returns the List of Connection Target with forms
*
* @remarks
*
* */
async getConnectionTargetsDefinitionsByAccountId(accountId) {
return this.client.get({
version: this.serviceVersion,
service_stack: this.serviceStack,
account_id: accountId,
path: `/definitions/connection_targets`
});
}
/**
* Returns Get a list of supported notifications
* GET
* /v1/{{accountId}}/notifications
* https://connectors.mdr.product.dev.alertlogic.com
*
* @returns the List of notifications
*
* @remarks
*
* */
async getConnectionNotificationsByAccountId(accountId) {
return this.client.get({
version: this.serviceVersion,
service_stack: this.serviceStack,
account_id: accountId,
path: `/notifications`
});
}
}
/* tslint:disable:variable-name */
const AlConnectorsClient = AlGlobalizer.instantiate("AlConnectorsClient", () => new AlConnectorsClientInstance());
export { AlConnectorsClient, AlConnectorsClientInstance };
//# sourceMappingURL=index.esm2015.js.map