UNPKG

mongodb-atlas-api-client

Version:
61 lines (52 loc) 1.88 kB
const {getQueryStringFromOptions} = require("./helper"); class CloudProviderAccess { constructor(client, baseUrl, projectId) { this.client_ = client; this.baseUrl_ = baseUrl; this.projectId_ = projectId; } async getAll(options = {}) { const queryString = getQueryStringFromOptions(options); const httpOptions = options.httpOptions; const response = ( await this.client_.fetch(`${this.baseUrl_}/groups/${this.projectId_}/cloudProviderAccess?${queryString}`, httpOptions) ); return response; } async delete(cloudProvider, roleId, options = {}) { const queryString = getQueryStringFromOptions(options); const httpOptions = options.httpOptions; await this.client_.fetch(`${this.baseUrl_}/groups/${this.projectId_}/cloudProviderAccess/${cloudProvider}/${roleId}?${queryString}`, { "method": "DELETE", ...httpOptions }); return true; } async update(roleId, body, options = {}) { const queryString = getQueryStringFromOptions(options); const httpOptions = options.httpOptions; const response = ( await this.client_.fetch(`${this.baseUrl_}/groups/${this.projectId_}/cloudProviderAccess/${roleId}?${queryString}`, { "method": "PATCH", "data": body, "headers": {"Content-Type": "application/json"}, ...httpOptions }) ); return response; } async create(body, options = {}) { const queryString = getQueryStringFromOptions(options); const httpOptions = options.httpOptions; const response = ( await this.client_.fetch(`${this.baseUrl_}/groups/${this.projectId_}/cloudProviderAccess?${queryString}`, { "method": "POST", "data": body, "headers": {"Content-Type": "application/json"}, ...httpOptions }) ); return response; } } module.exports = CloudProviderAccess;