Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const operations = resourceName.map(name => {
const operation = new ApplyRecommendationOperation()
operation.setResourceName(name)
return operation
})
request.setOperationsList(operations)
public async applyRecommendation(
resourceName: string | string[],
options?: ServiceCreateOptions
): Promise {
const request = new ApplyRecommendationRequest()
request.setCustomerId(this.cid)
if (resourceName instanceof Array) {
const operations = resourceName.map(name => {
const operation = new ApplyRecommendationOperation()
operation.setResourceName(name)
return operation
})
request.setOperationsList(operations)
} else {
const operation = new ApplyRecommendationOperation()
operation.setResourceName(resourceName)
request.setOperationsList([operation])
}
if (options && options.hasOwnProperty('partial_failure')) {
if (!request.setPartialFailure) {
throw new Error(`This method does not support the partial_failure option.`)
}
request.setPartialFailure(options.partial_failure as boolean)
}
const response: ApplyRecommendationResponse.AsObject = await this.service.applyRecommendation(request)
return {
request: request.toObject(),
partial_failure_error: response.partialFailureError,
results: response.resultsList.map(r => r.resourceName),