create method

Creates a new enrollment token for a browser device.

Creation fails if there is already an active token for this customer under the same org unit.

request - The metadata request object.

Request parameters:

parent - Required. The parent resource where this enrollment token will be created. Format: customers/{customer} Value must have pattern ^customers/\[^/\]+$.

enrollmentTokenId - Optional. The ID to use for the enrollment token, which will become the final component of the enrollment token's resource name. This value must be local-unique under the customer and is optional. If not provided, it will be auto-generated. If provided, it must be 1-63 characters long and match the regular expression [a-zA-Z0-9._-]+.

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

Completes with a GoogleChromeManagementVersionsV1EnrollmentToken.

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

  final url_ = 'v1/' + core.Uri.encodeFull('$parent') + '/enrollmentTokens';

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