insert method

Future<ServiceAccountKey> insert(
  1. ServiceAccountKey request,
  2. String enterpriseId, {
  3. String? $fields,
})

Generates new credentials for the service account associated with this enterprise.

The calling service account must have been retrieved by calling Enterprises.GetServiceAccount and must have been set as the enterprise service account by calling Enterprises.SetAccount. Only the type of the key should be populated in the resource to be inserted.

request - The metadata request object.

Request parameters:

enterpriseId - The ID of the enterprise.

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

Completes with a ServiceAccountKey.

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<ServiceAccountKey> insert(
  ServiceAccountKey request,
  core.String enterpriseId, {
  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_ = 'androidenterprise/v1/enterprises/' +
      commons.escapeVariable('$enterpriseId') +
      '/serviceAccountKeys';

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