create method
- PlatformPolicy request,
- String parent, {
- String? policyId,
- String? $fields,
Creates a platform policy, and returns a copy of it.
Returns NOT_FOUND
if the project or platform doesn't exist,
INVALID_ARGUMENT
if the request is malformed, ALREADY_EXISTS
if the
policy already exists, and INVALID_ARGUMENT
if the policy contains a
platform-specific policy that does not match the platform value specified
in the URL.
request
- The metadata request object.
Request parameters:
parent
- Required. The parent of this platform policy.
Value must have pattern ^projects/\[^/\]+/platforms/\[^/\]+$
.
policyId
- Required. The platform policy ID.
$fields
- Selector specifying which fields to include in a partial
response.
Completes with a PlatformPolicy.
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<PlatformPolicy> create(
PlatformPolicy request,
core.String parent, {
core.String? policyId,
core.String? $fields,
}) async {
final body_ = convert.json.encode(request);
final queryParams_ = <core.String, core.List<core.String>>{
if (policyId != null) 'policyId': [policyId],
if ($fields != null) 'fields': [$fields],
};
final url_ = 'v1/' + core.Uri.encodeFull('$parent') + '/policies';
final response_ = await _requester.request(
url_,
'POST',
body: body_,
queryParams: queryParams_,
);
return PlatformPolicy.fromJson(
response_ as core.Map<core.String, core.dynamic>);
}