@cyc-seattle/gsuite-sdk 1.1.0 → 1.2.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 +1 -1
- package/dist/directory.d.ts +6 -0
- package/dist/directory.js +21 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -24,7 +24,7 @@ const members = await new DirectoryClient(auth).listMembers("team@example.org");
|
|
|
24
24
|
const settings = await new GroupSettingsClient(auth).getSettings("team@example.org");
|
|
25
25
|
```
|
|
26
26
|
|
|
27
|
-
`addMember` and `removeMember` are idempotent: adding someone already in a group answers `"already-member"`, raising their role if it's lower, and taking out someone who isn't there answers `"not-member"`. Taking someone out of a group that doesn't exist throws.
|
|
27
|
+
`addMember` and `removeMember` are idempotent: adding someone already in a group answers `"already-member"`, raising their role if it's lower, and taking out someone who isn't there answers `"not-member"`. Taking someone out of a group that doesn't exist throws. `getMember` finds a member by any of their addresses, since Google resolves an alias, and answers with their primary address, or `null` if they aren't in the group.
|
|
28
28
|
|
|
29
29
|
### Client options
|
|
30
30
|
|
package/dist/directory.d.ts
CHANGED
|
@@ -59,6 +59,12 @@ export declare class DirectoryClient {
|
|
|
59
59
|
* Lists all members of a group, following pagination.
|
|
60
60
|
*/
|
|
61
61
|
listMembers(groupKey: string): Promise<GroupMember[]>;
|
|
62
|
+
/**
|
|
63
|
+
* Gets one member of a group by any of their addresses. Google resolves an alias to the member,
|
|
64
|
+
* and answers with their primary address. Returns null when they aren't in the group. A missing
|
|
65
|
+
* group throws.
|
|
66
|
+
*/
|
|
67
|
+
getMember(groupKey: string, memberKey: string): Promise<GroupMember | null>;
|
|
62
68
|
/**
|
|
63
69
|
* Adds a member to a group with the given role. Returns "already-member"
|
|
64
70
|
* instead of throwing when the member is already in the group (HTTP 409),
|
package/dist/directory.js
CHANGED
|
@@ -113,6 +113,27 @@ export class DirectoryClient {
|
|
|
113
113
|
} while (pageToken);
|
|
114
114
|
return members;
|
|
115
115
|
}
|
|
116
|
+
/**
|
|
117
|
+
* Gets one member of a group by any of their addresses. Google resolves an alias to the member,
|
|
118
|
+
* and answers with their primary address. Returns null when they aren't in the group. A missing
|
|
119
|
+
* group throws.
|
|
120
|
+
*/
|
|
121
|
+
async getMember(groupKey, memberKey) {
|
|
122
|
+
winston.debug("Getting group member", { groupKey, memberKey });
|
|
123
|
+
try {
|
|
124
|
+
const member = await safeCall(async () => {
|
|
125
|
+
const response = await this.client.members.get({ groupKey, memberKey });
|
|
126
|
+
return response.data;
|
|
127
|
+
}, this.pacing);
|
|
128
|
+
return convertToGroupMember(member);
|
|
129
|
+
}
|
|
130
|
+
catch (error) {
|
|
131
|
+
if (getHttpStatus(error) === 404 && (await this.getGroup(groupKey)) !== null) {
|
|
132
|
+
return null;
|
|
133
|
+
}
|
|
134
|
+
throw error;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
116
137
|
/**
|
|
117
138
|
* Adds a member to a group with the given role. Returns "already-member"
|
|
118
139
|
* instead of throwing when the member is already in the group (HTTP 409),
|