create method
Creates a cluster within an instance.
Note that exactly one of Cluster.serve_nodes and Cluster.cluster_config.cluster_autoscaling_config can be set. If serve_nodes is set to non-zero, then the cluster is manually scaled. If cluster_config.cluster_autoscaling_config is non-empty, then autoscaling is enabled.
request
- The metadata request object.
Request parameters:
parent
- Required. The unique name of the instance in which to create
the new cluster. Values are of the form
projects/{project}/instances/{instance}
.
Value must have pattern ^projects/\[^/\]+/instances/\[^/\]+$
.
clusterId
- Required. The ID to be used when referring to the new
cluster within its instance, e.g., just mycluster
rather than
projects/myproject/instances/myinstance/clusters/mycluster
.
$fields
- Selector specifying which fields to include in a partial
response.
Completes with a Operation.
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<Operation> create(
Cluster request,
core.String parent, {
core.String? clusterId,
core.String? $fields,
}) async {
final body_ = convert.json.encode(request);
final queryParams_ = <core.String, core.List<core.String>>{
if (clusterId != null) 'clusterId': [clusterId],
if ($fields != null) 'fields': [$fields],
};
final url_ = 'v2/' + core.Uri.encodeFull('$parent') + '/clusters';
final response_ = await _requester.request(
url_,
'POST',
body: body_,
queryParams: queryParams_,
);
return Operation.fromJson(response_ as core.Map<core.String, core.dynamic>);
}