Dataproc/src/V1beta2/Gapic/ClusterControllerGapicClient.php
public function createCluster($projectId, $region, $cluster, array $optionalArgs = [])
    {
        $request = new CreateClusterRequest();
        $request->setProjectId($projectId);
        $request->setRegion($region);
        $request->setCluster($cluster);
        if (isset($optionalArgs['requestId'])) {
            $request->setRequestId($optionalArgs['requestId']);
        }

        return $this->startOperationsCall(
            'CreateCluster',
            $optionalArgs,
            $request,
            $this->getOperationsClient()
        )->wait();
    }
public function createCluster($projectId, $region, $cluster, array $optionalArgs = [])
    {
        $request = new CreateClusterRequest();
        $request->setProjectId($projectId);
        $request->setRegion($region);
        $request->setCluster($cluster);
        if (isset($optionalArgs['requestId'])) {
            $request->setRequestId($optionalArgs['requestId']);
        }

        return $this->startOperationsCall(
            'CreateCluster',
            $optionalArgs,
            $request,
            $this->getOperationsClient()
        )->wait();
    }
public function createCluster ( $ projectId , $ region , $ cluster , array $ optionalArgs = [ ] ) { $ request = new CreateClusterRequest ( ) ; $ request -> setProjectId ( $ projectId ) ; $ request -> setRegion ( $ region ) ; $ request -> setCluster ( $ cluster ) ; if ( isset ( $ optionalArgs [ 'requestId' ] ) ) { $ request -> setRequestId ( $ optionalArgs [ 'requestId' ] ) ; } return $ this -> startOperationsCall ( 'CreateCluster' , $ optionalArgs , $ request , $ this -> getOperationsClient ( ) ) -> wait ( ) ; }
Creates a cluster in a project.

Sample code:
```
$clusterControllerClient = new ClusterControllerClient();
try {
$projectId = '';
$region = '';
$cluster = new Cluster();
$operationResponse = $clusterControllerClient->createCluster($projectId, $region, $cluster);
$operationResponse->pollUntilComplete();
if ($operationResponse->operationSucceeded()) {
$result = $operationResponse->getResult();
// doSomethingWith($result)
} else {
$error = $operationResponse->getError();
// handleError($error)
}


// Alternatively:

// start the operation, keep the operation name, and resume later
$operationResponse = $clusterControllerClient->createCluster($projectId, $region, $cluster);
$operationName = $operationResponse->getName();
// ... do other work
$newOperationResponse = $clusterControllerClient->resumeOperation($operationName, 'createCluster');
while (!$newOperationResponse->isDone()) {
// ... do other work
$newOperationResponse->reload();
}
if ($newOperationResponse->operationSucceeded()) {
$result = $newOperationResponse->getResult();
// doSomethingWith($result)
} else {
$error = $newOperationResponse->getError();
// handleError($error)
}
} finally {
$clusterControllerClient->close();
}
```

@param string  $projectId    Required. The ID of the Google Cloud Platform project that the cluster
belongs to.
@param string  $region       Required. The Cloud Dataproc region in which to handle the request.
@param Cluster $cluster      Required. The cluster to create.
@param array   $optionalArgs {
Optional.

@type string $requestId
Optional. A unique id used to identify the request. If the server
receives two
[CreateClusterRequest][google.cloud.dataproc.v1beta2.CreateClusterRequest]
requests  with the same id, then the second request will be ignored and the
first [google.longrunning.Operation][google.longrunning.Operation] created
and stored in the backend is returned.

It is recommended to always set this value to a
[UUID](https://en.wikipedia.org/wiki/Universally_unique_identifier).

The id must contain only letters (a-z, A-Z), numbers (0-9),
underscores (_), and hyphens (-). The maximum length is 40 characters.
@type RetrySettings|array $retrySettings
Retry settings to use for this call. Can be a
{@see Google\ApiCore\RetrySettings} object, or an associative array
of retry settings parameters. See the documentation on
{@see Google\ApiCore\RetrySettings} for example usage.
}

@return \Google\ApiCore\OperationResponse

@throws ApiException if the remote call fails
@experimental
Creates a cluster in a project .