insert method

Future<User> insert(
  1. User request, {
  2. bool? resolveConflictAccount,
  3. String? $fields,
})

Creates a user.

Mutate calls immediately following user creation might sometimes fail as the user isn't fully created due to propagation delay in our backends. Check the error details for the "User creation is not complete" message to see if this is the case. Retrying the calls after some time can help in this case. If resolve_conflict_account is set to true, the option selected for Find and add unmanaged users will apply to resolve conflicting accounts: - A 200 response code indicates the user was created (or replaced an existing unmanaged personal account). - A 202 response code means that a conflicting unmanaged personal account exists and was invited to join the organization. - A 409 response code means that a conflicting account exists so the user wasn't created (e.g. based on the option selected to preserve the account, or if the email conflicts with an unmanaged work account or existing managed user). For details on resolving duplicate account errors, see Resolve duplicate account errors and Transfer unmanaged work accounts.

request - The metadata request object.

Request parameters:

resolveConflictAccount - Optional. Applies the option selected for Find and add unmanaged users to resolve conflicting accounts when set to true. Default: false

$fields - Selector specifying which fields to include in a partial response.

Completes with a User.

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<User> insert(
  User request, {
  core.bool? resolveConflictAccount,
  core.String? $fields,
}) async {
  final body_ = convert.json.encode(request);
  final queryParams_ = <core.String, core.List<core.String>>{
    'resolveConflictAccount': ?resolveConflictAccount == null
        ? null
        : ['${resolveConflictAccount}'],
    'fields': ?$fields == null ? null : [$fields],
  };

  const url_ = 'admin/directory/v1/users';

  final response_ = await _requester.request(
    url_,
    'POST',
    body: body_,
    queryParams: queryParams_,
  );
  return User.fromJson(response_ as core.Map<core.String, core.dynamic>);
}