create method
Creates a space.
Can be used to create a named space, or a group chat in Import mode
. For
an example, see
Create a space.
Supports the following types of
authentication:
App authentication
with
administrator approval and
one of the following authorization scopes: -
https://www.googleapis.com/auth/chat.app.spaces.create
-
https://www.googleapis.com/auth/chat.app.spaces
-
User authentication
with one of the following authorization scopes: -
https://www.googleapis.com/auth/chat.spaces.create
-
https://www.googleapis.com/auth/chat.spaces
-
https://www.googleapis.com/auth/chat.import
(import mode spaces only)
When authenticating as an app, the space.customer
field must be set in
the request. When authenticating as an app, the Chat app is added as a
member of the space. However, unlike human authentication, the Chat app is
not added as a space manager. By default, the Chat app can be removed from
the space by all space members. To allow only space managers to remove the
app from a space, set space.permission_settings.manage_apps
to
managers_allowed
. Space membership upon creation depends on whether the
space is created in Import mode
: * Import mode: No members are
created. * All other modes: The calling user is added as a member.
This is: * The app itself when using app authentication. * The human user
when using user authentication. If you receive the error message
ALREADY_EXISTS
when creating a space, try a different displayName
. An
existing space within the Google Workspace organization might already use
this display name.
request
- The metadata request object.
Request parameters:
requestId
- Optional. A unique identifier for this request. A random
UUID is recommended. Specifying an existing request ID returns the space
created with that ID instead of creating a new space. Specifying an
existing request ID from the same Chat app with a different authenticated
user returns an error.
$fields
- Selector specifying which fields to include in a partial
response.
Completes with a Space.
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<Space> create(
Space request, {
core.String? requestId,
core.String? $fields,
}) async {
final body_ = convert.json.encode(request);
final queryParams_ = <core.String, core.List<core.String>>{
if (requestId != null) 'requestId': [requestId],
if ($fields != null) 'fields': [$fields],
};
const url_ = 'v1/spaces';
final response_ = await _requester.request(
url_,
'POST',
body: body_,
queryParams: queryParams_,
);
return Space.fromJson(response_ as core.Map<core.String, core.dynamic>);
}