create method
Creates a human membership or app membership for the calling app.
Creating memberships for other apps isn't supported. For an example, see
Invite or add a user or a Google Chat app to a space.
When creating a membership, if the specified member has their auto-accept
policy turned off, then they're invited, and must accept the space
invitation before joining. Otherwise, creating a membership adds the
member directly to the specified space. Requires
user authentication.
To specify the member to add, set the membership.member.name
for the
human or app member. - To add the calling app to a space or a direct
message between two human users, use users/app
. Unable to add other apps
to the space. - To add a human user, use users/{user}
, where {user}
can be the email address for the user. For users in the same Workspace
organization {user}
can also be the id
for the person from the People
API, or the id
for the user in the Directory API. For example, if the
People API Person profile ID for user@example.com
is 123456789
, you
can add the user to the space by setting the membership.member.name
to
users/user@example.com
or users/123456789
.
request
- The metadata request object.
Request parameters:
parent
- Required. The resource name of the space for which to create
the membership. Format: spaces/{space}
Value must have pattern ^spaces/\[^/\]+$
.
$fields
- Selector specifying which fields to include in a partial
response.
Completes with a Membership.
Completes with a commons.ApiRequestError if the API endpoint returned an error.
If the used http.Client
completes with an error when making a REST call,
this method will complete with the same error.
Implementation
async.Future<Membership> create(
Membership request,
core.String parent, {
core.String? $fields,
}) async {
final body_ = convert.json.encode(request);
final queryParams_ = <core.String, core.List<core.String>>{
if ($fields != null) 'fields': [$fields],
};
final url_ = 'v1/' + core.Uri.encodeFull('$parent') + '/members';
final response_ = await _requester.request(
url_,
'POST',
body: body_,
queryParams: queryParams_,
);
return Membership.fromJson(
response_ as core.Map<core.String, core.dynamic>);
}