ibmcloud-security-advisor-findings
Version:
JavaScript client library for the IBM Cloud Security Advisor Findings API
505 lines (428 loc) • 21.5 kB
JavaScript
/**
* Findings API
* The Findings API
*
* OpenAPI spec version: 1.0.0
*
* NOTE: This class is auto generated by the swagger code generator program.
* https://github.com/swagger-api/swagger-codegen.git
*
* Swagger Codegen version: 2.4.7
*
* Do not edit the class manually.
*
*/
var ApiClient = require('../ApiClient');
var Body2 = require('../model/Body2');
var Body3 = require('../model/Body3');
var InlineResponse2001 = require('../model/InlineResponse2001');
var InlineResponse2001Occurrences = require('../model/InlineResponse2001Occurrences');
var InlineResponse2002 = require('../model/InlineResponse2002');
/**
* FindingsOccurrences service.
* @module api/FindingsOccurrencesApi
*/
/**
* Constructs a new FindingsOccurrencesApi.
* @alias module:api/FindingsOccurrencesApi
* @class
* @param {module:ApiClient} apiClient Optional API client implementation to use,
* default to {@link module:ApiClient#instance} if unspecified.
*/
module.exports = function(apiClient) {
this.apiClient = apiClient || ApiClient.instance;
/**
* Creates a new `Occurrence`. Use this method to create `Occurrences` for a resource.
* @param {String} accountId Account ID
* @param {String} authorization The Identity & Access Management (IAM) Bearer token.
* @param {String} providerId Part of `parent`. This contains the provider_id for example: providers/{provider_id}
* @param {module:model/Body2} body Body for Occurence creation
* @param {Object} opts Optional parameters
* @param {Boolean} opts.replaceIfExists It allows replacing an existing occurrence when set to true.
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:model/InlineResponse2001Occurrences} and HTTP response
*/
this.createOccurrenceWithHttpInfo = function(accountId, authorization, providerId, body, opts) {
opts = opts || {};
var postBody = body;
// verify the required parameter 'accountId' is set
if (accountId === undefined || accountId === null) {
throw new Error("Missing the required parameter 'accountId' when calling createOccurrence");
}
// verify the required parameter 'authorization' is set
if (authorization === undefined || authorization === null) {
throw new Error("Missing the required parameter 'authorization' when calling createOccurrence");
}
// verify the required parameter 'providerId' is set
if (providerId === undefined || providerId === null) {
throw new Error("Missing the required parameter 'providerId' when calling createOccurrence");
}
// verify the required parameter 'body' is set
if (body === undefined || body === null) {
throw new Error("Missing the required parameter 'body' when calling createOccurrence");
}
var pathParams = {
'account_id': accountId,
'provider_id': providerId
};
var queryParams = {
};
var headerParams = {
'Authorization': authorization,
'Replace-If-Exists': opts['replaceIfExists']
};
var formParams = {
};
var authNames = ['UserMin'];
var contentTypes = ['application/json'];
var accepts = ['application/json'];
var returnType = InlineResponse2001Occurrences;
return this.apiClient.callApi(
'/v1/{account_id}/providers/{provider_id}/occurrences', 'POST',
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType
);
}
/**
* Creates a new `Occurrence`. Use this method to create `Occurrences` for a resource.
* @param {String} accountId Account ID
* @param {String} authorization The Identity & Access Management (IAM) Bearer token.
* @param {String} providerId Part of `parent`. This contains the provider_id for example: providers/{provider_id}
* @param {module:model/Body2} body Body for Occurence creation
* @param {Object} opts Optional parameters
* @param {Boolean} opts.replaceIfExists It allows replacing an existing occurrence when set to true.
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/InlineResponse2001Occurrences}
*/
this.createOccurrence = function(accountId, authorization, providerId, body, opts) {
return this.createOccurrenceWithHttpInfo(accountId, authorization, providerId, body, opts)
.then(function(response_and_data) {
return response_and_data.data;
});
}
/**
* Deletes the given `Occurrence` from the system.
* @param {String} accountId Account ID
* @param {String} authorization The Identity & Access Management (IAM) Bearer token.
* @param {String} providerId First part of occurrence `name`: providers/{provider_id}/notes/{occurrence_id}
* @param {String} occurrenceId Second part of occurrence `name`: providers/{provider_id}/notes/{occurrence_id}
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link Object} and HTTP response
*/
this.deleteOccurrenceWithHttpInfo = function(accountId, authorization, providerId, occurrenceId) {
var postBody = null;
// verify the required parameter 'accountId' is set
if (accountId === undefined || accountId === null) {
throw new Error("Missing the required parameter 'accountId' when calling deleteOccurrence");
}
// verify the required parameter 'authorization' is set
if (authorization === undefined || authorization === null) {
throw new Error("Missing the required parameter 'authorization' when calling deleteOccurrence");
}
// verify the required parameter 'providerId' is set
if (providerId === undefined || providerId === null) {
throw new Error("Missing the required parameter 'providerId' when calling deleteOccurrence");
}
// verify the required parameter 'occurrenceId' is set
if (occurrenceId === undefined || occurrenceId === null) {
throw new Error("Missing the required parameter 'occurrenceId' when calling deleteOccurrence");
}
var pathParams = {
'account_id': accountId,
'provider_id': providerId,
'occurrence_id': occurrenceId
};
var queryParams = {
};
var headerParams = {
'Authorization': authorization
};
var formParams = {
};
var authNames = ['UserMin'];
var contentTypes = ['application/json'];
var accepts = ['application/json'];
var returnType = Object;
return this.apiClient.callApi(
'/v1/{account_id}/providers/{provider_id}/occurrences/{occurrence_id}', 'DELETE',
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType
);
}
/**
* Deletes the given `Occurrence` from the system.
* @param {String} accountId Account ID
* @param {String} authorization The Identity & Access Management (IAM) Bearer token.
* @param {String} providerId First part of occurrence `name`: providers/{provider_id}/notes/{occurrence_id}
* @param {String} occurrenceId Second part of occurrence `name`: providers/{provider_id}/notes/{occurrence_id}
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link Object}
*/
this.deleteOccurrence = function(accountId, authorization, providerId, occurrenceId) {
return this.deleteOccurrenceWithHttpInfo(accountId, authorization, providerId, occurrenceId)
.then(function(response_and_data) {
return response_and_data.data;
});
}
/**
* Returns the requested `Occurrence`.
* @param {String} accountId Account ID
* @param {String} authorization The Identity & Access Management (IAM) Bearer token.
* @param {String} providerId First part of occurrence `name`: providers/{provider_id}/occurrences/{occurrence_id}
* @param {String} occurrenceId Second part of occurrence `name`: providers/{provider_id}/occurrences/{occurrence_id}
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:model/InlineResponse2001} and HTTP response
*/
this.getOccurrenceWithHttpInfo = function(accountId, authorization, providerId, occurrenceId) {
var postBody = null;
// verify the required parameter 'accountId' is set
if (accountId === undefined || accountId === null) {
throw new Error("Missing the required parameter 'accountId' when calling getOccurrence");
}
// verify the required parameter 'authorization' is set
if (authorization === undefined || authorization === null) {
throw new Error("Missing the required parameter 'authorization' when calling getOccurrence");
}
// verify the required parameter 'providerId' is set
if (providerId === undefined || providerId === null) {
throw new Error("Missing the required parameter 'providerId' when calling getOccurrence");
}
// verify the required parameter 'occurrenceId' is set
if (occurrenceId === undefined || occurrenceId === null) {
throw new Error("Missing the required parameter 'occurrenceId' when calling getOccurrence");
}
var pathParams = {
'account_id': accountId,
'provider_id': providerId,
'occurrence_id': occurrenceId
};
var queryParams = {
};
var headerParams = {
'Authorization': authorization
};
var formParams = {
};
var authNames = ['UserMin'];
var contentTypes = ['application/json'];
var accepts = ['application/json'];
var returnType = InlineResponse2001;
return this.apiClient.callApi(
'/v1/{account_id}/providers/{provider_id}/occurrences/{occurrence_id}', 'GET',
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType
);
}
/**
* Returns the requested `Occurrence`.
* @param {String} accountId Account ID
* @param {String} authorization The Identity & Access Management (IAM) Bearer token.
* @param {String} providerId First part of occurrence `name`: providers/{provider_id}/occurrences/{occurrence_id}
* @param {String} occurrenceId Second part of occurrence `name`: providers/{provider_id}/occurrences/{occurrence_id}
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/InlineResponse2001}
*/
this.getOccurrence = function(accountId, authorization, providerId, occurrenceId) {
return this.getOccurrenceWithHttpInfo(accountId, authorization, providerId, occurrenceId)
.then(function(response_and_data) {
return response_and_data.data;
});
}
/**
* Lists `Occurrences` referencing the specified `Note`. Use this method to get all occurrences referencing your `Note` across all your customer providers.
* @param {String} accountId Account ID
* @param {String} authorization The Identity & Access Management (IAM) Bearer token.
* @param {String} providerId First part of note `name`: providers/{provider_id}/notes/{note_id}
* @param {String} noteId Second part of note `name`: providers/{provider_id}/notes/{note_id}
* @param {Object} opts Optional parameters
* @param {Number} opts.pageSize Number of notes to return in the list.
* @param {String} opts.pageToken Token to provide to skip to a particular spot in the list.
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:model/InlineResponse2002} and HTTP response
*/
this.listNoteOccurrencesWithHttpInfo = function(accountId, authorization, providerId, noteId, opts) {
opts = opts || {};
var postBody = null;
// verify the required parameter 'accountId' is set
if (accountId === undefined || accountId === null) {
throw new Error("Missing the required parameter 'accountId' when calling listNoteOccurrences");
}
// verify the required parameter 'authorization' is set
if (authorization === undefined || authorization === null) {
throw new Error("Missing the required parameter 'authorization' when calling listNoteOccurrences");
}
// verify the required parameter 'providerId' is set
if (providerId === undefined || providerId === null) {
throw new Error("Missing the required parameter 'providerId' when calling listNoteOccurrences");
}
// verify the required parameter 'noteId' is set
if (noteId === undefined || noteId === null) {
throw new Error("Missing the required parameter 'noteId' when calling listNoteOccurrences");
}
var pathParams = {
'account_id': accountId,
'provider_id': providerId,
'note_id': noteId
};
var queryParams = {
'page_size': opts['pageSize'],
'page_token': opts['pageToken']
};
var headerParams = {
'Authorization': authorization
};
var formParams = {
};
var authNames = ['UserMin'];
var contentTypes = ['application/json'];
var accepts = ['application/json'];
var returnType = InlineResponse2002;
return this.apiClient.callApi(
'/v1/{account_id}/providers/{provider_id}/notes/{note_id}/occurrences', 'GET',
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType
);
}
/**
* Lists `Occurrences` referencing the specified `Note`. Use this method to get all occurrences referencing your `Note` across all your customer providers.
* @param {String} accountId Account ID
* @param {String} authorization The Identity & Access Management (IAM) Bearer token.
* @param {String} providerId First part of note `name`: providers/{provider_id}/notes/{note_id}
* @param {String} noteId Second part of note `name`: providers/{provider_id}/notes/{note_id}
* @param {Object} opts Optional parameters
* @param {Number} opts.pageSize Number of notes to return in the list.
* @param {String} opts.pageToken Token to provide to skip to a particular spot in the list.
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/InlineResponse2002}
*/
this.listNoteOccurrences = function(accountId, authorization, providerId, noteId, opts) {
return this.listNoteOccurrencesWithHttpInfo(accountId, authorization, providerId, noteId, opts)
.then(function(response_and_data) {
return response_and_data.data;
});
}
/**
* Lists active `Occurrences` for a given provider matching the filters.
* @param {String} accountId Account ID
* @param {String} authorization The Identity & Access Management (IAM) Bearer token.
* @param {String} providerId Part of `parent`. This contains the provider_id for example: providers/{provider_id}
* @param {Object} opts Optional parameters
* @param {Number} opts.pageSize Number of occurrences to return in the list.
* @param {String} opts.pageToken Token to provide to skip to a particular spot in the list.
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:model/InlineResponse2001} and HTTP response
*/
this.listOccurrencesWithHttpInfo = function(accountId, authorization, providerId, opts) {
opts = opts || {};
var postBody = null;
// verify the required parameter 'accountId' is set
if (accountId === undefined || accountId === null) {
throw new Error("Missing the required parameter 'accountId' when calling listOccurrences");
}
// verify the required parameter 'authorization' is set
if (authorization === undefined || authorization === null) {
throw new Error("Missing the required parameter 'authorization' when calling listOccurrences");
}
// verify the required parameter 'providerId' is set
if (providerId === undefined || providerId === null) {
throw new Error("Missing the required parameter 'providerId' when calling listOccurrences");
}
var pathParams = {
'account_id': accountId,
'provider_id': providerId
};
var queryParams = {
'page_size': opts['pageSize'],
'page_token': opts['pageToken']
};
var headerParams = {
'Authorization': authorization
};
var formParams = {
};
var authNames = ['UserMin'];
var contentTypes = ['application/json'];
var accepts = ['application/json'];
var returnType = InlineResponse2001;
return this.apiClient.callApi(
'/v1/{account_id}/providers/{provider_id}/occurrences', 'GET',
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType
);
}
/**
* Lists active `Occurrences` for a given provider matching the filters.
* @param {String} accountId Account ID
* @param {String} authorization The Identity & Access Management (IAM) Bearer token.
* @param {String} providerId Part of `parent`. This contains the provider_id for example: providers/{provider_id}
* @param {Object} opts Optional parameters
* @param {Number} opts.pageSize Number of occurrences to return in the list.
* @param {String} opts.pageToken Token to provide to skip to a particular spot in the list.
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/InlineResponse2001}
*/
this.listOccurrences = function(accountId, authorization, providerId, opts) {
return this.listOccurrencesWithHttpInfo(accountId, authorization, providerId, opts)
.then(function(response_and_data) {
return response_and_data.data;
});
}
/**
* Updates an existing `Occurrence`.
* @param {String} accountId Account ID
* @param {String} authorization The Identity & Access Management (IAM) Bearer token.
* @param {String} providerId First part of occurrence `name`: providers/{provider_id}/occurrences/{occurrence_id}
* @param {String} occurrenceId Second part of occurrence `name`: providers/{provider_id}/occurrences/{occurrence_id}
* @param {module:model/Body3} body Body for Occurence updation
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:model/InlineResponse2001Occurrences} and HTTP response
*/
this.updateOccurrenceWithHttpInfo = function(accountId, authorization, providerId, occurrenceId, body) {
var postBody = body;
// verify the required parameter 'accountId' is set
if (accountId === undefined || accountId === null) {
throw new Error("Missing the required parameter 'accountId' when calling updateOccurrence");
}
// verify the required parameter 'authorization' is set
if (authorization === undefined || authorization === null) {
throw new Error("Missing the required parameter 'authorization' when calling updateOccurrence");
}
// verify the required parameter 'providerId' is set
if (providerId === undefined || providerId === null) {
throw new Error("Missing the required parameter 'providerId' when calling updateOccurrence");
}
// verify the required parameter 'occurrenceId' is set
if (occurrenceId === undefined || occurrenceId === null) {
throw new Error("Missing the required parameter 'occurrenceId' when calling updateOccurrence");
}
// verify the required parameter 'body' is set
if (body === undefined || body === null) {
throw new Error("Missing the required parameter 'body' when calling updateOccurrence");
}
var pathParams = {
'account_id': accountId,
'provider_id': providerId,
'occurrence_id': occurrenceId
};
var queryParams = {
};
var headerParams = {
'Authorization': authorization
};
var formParams = {
};
var authNames = ['UserMin'];
var contentTypes = ['application/json'];
var accepts = ['application/json'];
var returnType = InlineResponse2001Occurrences;
return this.apiClient.callApi(
'/v1/{account_id}/providers/{provider_id}/occurrences/{occurrence_id}', 'PUT',
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType
);
}
/**
* Updates an existing `Occurrence`.
* @param {String} accountId Account ID
* @param {String} authorization The Identity & Access Management (IAM) Bearer token.
* @param {String} providerId First part of occurrence `name`: providers/{provider_id}/occurrences/{occurrence_id}
* @param {String} occurrenceId Second part of occurrence `name`: providers/{provider_id}/occurrences/{occurrence_id}
* @param {module:model/Body3} body Body for Occurence updation
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/InlineResponse2001Occurrences}
*/
this.updateOccurrence = function(accountId, authorization, providerId, occurrenceId, body) {
return this.updateOccurrenceWithHttpInfo(accountId, authorization, providerId, occurrenceId, body)
.then(function(response_and_data) {
return response_and_data.data;
});
}
};