mongodb-atlas-api-client 2.29.0 → 2.30.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
@@ -572,6 +572,23 @@ Function - Renames the organization
572
572
 
573
573
  More details - https://docs.atlas.mongodb.com/reference/api/organization-rename/
574
574
 
575
+ ### organization.invite(organizationId, body, [options]) ⇒ <code>Promise</code>
576
+ Function - Sends an invitation to the given email (username) to join the Organization
577
+
578
+ **Returns**: <code>Promise</code> - - promise which resolves on success and rejects on error
579
+
580
+ | Param | Type | Default | Description |
581
+ | --- | --- | --- | --- |
582
+ | organizationId | <code>String</code> | | Id of the organization for which needs to be renamed |
583
+ | body | <code>Object</code> | | Organization invitation details
584
+ | 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. |
585
+ | body.teamIds | <code>string[]</code> | | *(Optional)* Unique 24-hexadecimal digit strings that identify the teams that you invite the user to join.
586
+ | body.username | <code>string</code> | | Email address of the invited user. This is the address to which Atlas sends the invite.
587
+ | [options] | <code>Object</code> | <code>{}</code> | Optional object containing extra query strings which will be passed to atlas api |
588
+
589
+ More details - https://docs.atlas.mongodb.com/reference/api/organization-create-one-invitation/
590
+
591
+
575
592
  ### organization.delete(organizationId, [options]) ⇒ <code>Promise</code>
576
593
  Function - Deletes the project id passed.
577
594
 
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.30.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
  });