create method

Future<CryptoKey> create(
  1. CryptoKey request,
  2. String parent, {
  3. String? cryptoKeyId,
  4. bool? skipInitialVersionCreation,
  5. String? $fields,
})

Create a new CryptoKey within a KeyRing.

CryptoKey.purpose and CryptoKey.version_template.algorithm are required.

request - The metadata request object.

Request parameters:

parent - Required. The name of the KeyRing associated with the CryptoKeys. Value must have pattern ^projects/\[^/\]+/locations/\[^/\]+/keyRings/\[^/\]+$.

cryptoKeyId - Required. It must be unique within a KeyRing and match the regular expression [a-zA-Z0-9_-]{1,63}

skipInitialVersionCreation - If set to true, the request will create a CryptoKey without any CryptoKeyVersions. You must manually call CreateCryptoKeyVersion or ImportCryptoKeyVersion before you can use this CryptoKey.

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

Completes with a CryptoKey.

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

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

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