mongodb-atlas-api-client 2.29.0 → 2.32.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -5,6 +5,8 @@ A mongdb atlas api client for nodejs.
5
5
  [![Known Vulnerabilities](https://snyk.io/test/github/montumodi/mongodb-atlas-api-client/badge.svg)](https://snyk.io/test/github/montumodi/mongodb-atlas-api-client)
6
6
  [![Coverage Status](https://coveralls.io/repos/github/montumodi/mongodb-atlas-api-client/badge.svg?branch=master)](https://coveralls.io/github/montumodi/mongodb-atlas-api-client?branch=master)
7
7
  [![Build Status](https://travis-ci.com/montumodi/mongodb-atlas-api-client.svg?branch=master)](https://travis-ci.com/montumodi/mongodb-atlas-api-client)
8
+ ![NPM Publish](https://github.com/montumodi/mongodb-atlas-api-client/actions/workflows/.github/workflows/npmpublish.yml/badge.svg)
9
+
8
10
  [![Deps](https://david-dm.org/montumodi/mongodb-atlas-api-client.svg)](https://david-dm.org/montumodi/mongodb-atlas-api-client#info=dependencies)
9
11
  [![devDependency Status](https://david-dm.org/montumodi/mongodb-atlas-api-client/dev-status.svg)](https://david-dm.org/montumodi/mongodb-atlas-api-client#info=devDependencies)
10
12
 
@@ -572,6 +574,23 @@ Function - Renames the organization
572
574
 
573
575
  More details - https://docs.atlas.mongodb.com/reference/api/organization-rename/
574
576
 
577
+ ### organization.invite(organizationId, body, [options]) ⇒ <code>Promise</code>
578
+ Function - Sends an invitation to the given email (username) to join the Organization
579
+
580
+ **Returns**: <code>Promise</code> - - promise which resolves on success and rejects on error
581
+
582
+ | Param | Type | Default | Description |
583
+ | --- | --- | --- | --- |
584
+ | organizationId | <code>String</code> | | Id of the organization for which needs to be renamed |
585
+ | body | <code>Object</code> | | Organization invitation details
586
+ | body.roles | <code>string[]</code> | | Atlas roles to assign to the invited user. If the user accepts the invitation, Atlas assigns these roles to them. |
587
+ | body.teamIds | <code>string[]</code> | | *(Optional)* Unique 24-hexadecimal digit strings that identify the teams that you invite the user to join.
588
+ | body.username | <code>string</code> | | Email address of the invited user. This is the address to which Atlas sends the invite.
589
+ | [options] | <code>Object</code> | <code>{}</code> | Optional object containing extra query strings which will be passed to atlas api |
590
+
591
+ More details - https://docs.atlas.mongodb.com/reference/api/organization-create-one-invitation/
592
+
593
+
575
594
  ### organization.delete(organizationId, [options]) ⇒ <code>Promise</code>
576
595
  Function - Deletes the project id passed.
577
596
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mongodb-atlas-api-client",
3
- "version": "2.29.0",
3
+ "version": "2.32.0",
4
4
  "description": "A mongodb atlas api client for nodejs.",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -17,6 +17,24 @@ export interface RenameOrganizationRequest {
17
17
  */
18
18
  name: string;
19
19
  }
20
+
21
+ export interface InviteOneToOrganizationRequest {
22
+ roles: string[],
23
+ teamIds?: string[],
24
+ username: string,
25
+ }
26
+
27
+ export interface InviteOneToOrganizationResponse {
28
+ createdAt: string,
29
+ expiresAt: string,
30
+ id: string,
31
+ inviterUsername: string,
32
+ orgId: string,
33
+ orgName: string,
34
+ roles: string[],
35
+ teamIds: string[],
36
+ username: string,
37
+ }
20
38
  export type RenameOrganizationResponse = GetOrganizationResponse;
21
39
  export interface Organization {
22
40
  getById(organizationId: OrganizationId, options?: AtlasClientOptions): Promise<GetOrganizationResponse | AtlasError>;
@@ -25,4 +43,5 @@ export interface Organization {
25
43
  getAll(options?: AtlasClientOptions): Promise<GetAllOrganizationsResponse | AtlasError>;
26
44
  delete(organizationId: OrganizationId, options?: AtlasClientOptions): Promise<void | AtlasError>;
27
45
  rename(organizationId: OrganizationId, organization: RenameOrganizationRequest, options?: AtlasClientOptions): Promise<RenameOrganizationResponse | AtlasError>;
46
+ invite(organizationId: OrganizationId, organization: InviteOneToOrganizationRequest, options?: AtlasClientOptions): Promise<InviteOneToOrganizationResponse | AtlasError>;
28
47
  }
@@ -62,6 +62,19 @@ class Organization {
62
62
  ).json();
63
63
  return response;
64
64
  }
65
+
66
+ async invite(organizationId, body, options) {
67
+ const urlparams = new URLSearchParams(options);
68
+ const queryString = urlparams.toString();
69
+ const response = (
70
+ await this.client_.fetch(`${this.baseUrl_}/orgs/${organizationId}/invites?${queryString}`, {
71
+ "method": "POST",
72
+ "body": JSON.stringify(body),
73
+ "headers": {"Content-Type": "application/json"}
74
+ })
75
+ ).json();
76
+ return response;
77
+ }
65
78
  }
66
79
 
67
80
  module.exports = Organization;
@@ -21,6 +21,7 @@ describe("Mongo Atlas Api Client - Organization", () => {
21
21
  expect(client.organization.rename).to.be.function();
22
22
  expect(client.organization.getAllUsersForOrganization).to.be.function();
23
23
  expect(client.organization.getAllProjectsForOrganization).to.be.function();
24
+ expect(client.organization.invite).to.be.function();
24
25
  });
25
26
  });
26
27
 
@@ -89,4 +90,15 @@ describe("Mongo Atlas Api Client - Organization", () => {
89
90
  expect(expectedRequest.isDone()).to.be.true();
90
91
  });
91
92
  });
93
+
94
+ describe("When invite is called with querystring parameters", () => {
95
+ it("should return response", async () => {
96
+ const expectedRequest = nock(baseUrl)
97
+ .post("/orgs/orgId/invites?key1=value1&key2=value2")
98
+ .reply(200, [{"organization": "name"}]);
99
+ const result = await client.organization.invite("orgId", {"body": "value"}, {"key1": "value1", "key2": "value2"});
100
+ expect(result).to.equal([{"organization": "name"}]);
101
+ expect(expectedRequest.isDone()).to.be.true();
102
+ });
103
+ });
92
104
  });