Reference documentation and code samples for the Cloud AutoML V1 Client class AutoMlClient.
Service Description: AutoML Server API.
The resource names are assigned by the server. The server never reuses names that it has created after the resources with those names are deleted.
An ID of a resource is the last element of the item's resource name. For
projects/{project_id}/locations/{location_id}/datasets/{dataset_id}
, then
the id for the item is {dataset_id}
.
Currently the only supported location_id
is "us-central1".
On any input that is documented to expect a string parameter in snake_case or dash-case, either of those cases is accepted.
This class provides the ability to make remote calls to the backing service through method calls that map to API methods. Sample code to get started:
$autoMlClient = new Google\Cloud\AutoMl\V1\AutoMlClient();
try {
$formattedParent = $autoMlClient->locationName('[PROJECT]', '[LOCATION]');
$dataset = new Google\Cloud\AutoMl\V1\Dataset();
$operationResponse = $autoMlClient->createDataset($formattedParent, $dataset);
$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 = $autoMlClient->createDataset($formattedParent, $dataset);
$operationName = $operationResponse->getName();
// ... do other work
$newOperationResponse = $autoMlClient->resumeOperation($operationName, 'createDataset');
while (!$newOperationResponse->isDone()) {
// ... do other work
$newOperationResponse->reload();
}
if ($newOperationResponse->operationSucceeded()) {
$result = $newOperationResponse->getResult();
// doSomethingWith($result)
} else {
$error = $newOperationResponse->getError();
// handleError($error)
}
} finally {
$autoMlClient->close();
}
Many parameters require resource names to be formatted in a particular way. To assist with these names, this class includes a format method for each type of name, and additionally a parseName method to extract the individual identifiers contained within formatted names that are returned by the API.
This service has a new (beta) implementation. See Google\Cloud\AutoMl\V1\Client\AutoMlClient to use the new surface.
Namespace
Google \ Cloud \ AutoMl \ V1Methods
__construct
Constructor.
Parameters | |
---|---|
Name | Description |
options |
array
Optional. Options for configuring the service API wrapper. |
↳ apiEndpoint |
string
The address of the API remote host. May optionally include the port, formatted as "
|
↳ credentials |
string|array|FetchAuthTokenInterface|CredentialsWrapper
The credentials to be used by the client to authorize API calls. This option accepts either a path to a credentials file, or a decoded credentials file as a PHP array. Advanced usage: In addition, this option can also accept a pre-constructed Google\Auth\FetchAuthTokenInterface object or Google\ApiCore\CredentialsWrapper object. Note that when one of these objects are provided, any settings in $credentialsConfig will be ignored. |
↳ credentialsConfig |
array
Options used to configure credentials, including auth token caching, for the client. For a full list of supporting configuration options, see Google\ApiCore\CredentialsWrapper::build() . |
↳ disableRetries |
bool
Determines whether or not retries defined by the client configuration should be disabled. Defaults to |
↳ clientConfig |
string|array
Client method configuration, including retry settings. This option can be either a path to a JSON file, or a PHP array containing the decoded JSON data. By default this settings points to the default client config file, which is provided in the resources folder. |
↳ transport |
string|TransportInterface
The transport used for executing network requests. May be either the string |
↳ transportConfig |
array
Configuration options that will be used to construct the transport. Options for each supported transport type should be passed in a key for that transport. For example: $transportConfig = [ 'grpc' => [...], 'rest' => [...], ]; See the Google\ApiCore\Transport\GrpcTransport::build() and Google\ApiCore\Transport\RestTransport::build() methods for the supported options. |
↳ clientCertSource |
callable
A callable which returns the client cert as a string. This can be used to provide a certificate and private key to the transport layer for mTLS. |
createDataset
Creates a dataset.
Parameters | |
---|---|
Name | Description |
parent |
string
Required. The resource name of the project to create the dataset for. |
dataset |
Google\Cloud\AutoMl\V1\Dataset
Required. The dataset to create. |
optionalArgs |
array
Optional. |
↳ retrySettings |
RetrySettings|array
Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage. |
Returns | |
---|---|
Type | Description |
Google\ApiCore\OperationResponse |
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\AutoMl\V1\AutoMlClient;
use Google\Cloud\AutoMl\V1\Dataset;
use Google\Rpc\Status;
/**
* @param string $formattedParent The resource name of the project to create the dataset for. Please see
* {@see AutoMlClient::locationName()} for help formatting this field.
*/
function create_dataset_sample(string $formattedParent): void
{
// Create a client.
$autoMlClient = new AutoMlClient();
// Prepare any non-scalar elements to be passed along with the request.
$dataset = new Dataset();
// Call the API and handle any network failures.
try {
/** @var OperationResponse $response */
$response = $autoMlClient->createDataset($formattedParent, $dataset);
$response->pollUntilComplete();
if ($response->operationSucceeded()) {
/** @var Dataset $result */
$result = $response->getResult();
printf('Operation successful with response data: %s' . PHP_EOL, $result->serializeToJsonString());
} else {
/** @var Status $error */
$error = $response->getError();
printf('Operation failed with error data: %s' . PHP_EOL, $error->serializeToJsonString());
}
} catch (ApiException $ex) {
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
}
}
/**
* Helper to execute the sample.
*
* This sample has been automatically generated and should be regarded as a code
* template only. It will require modifications to work:
* - It may require correct/in-range values for request initialization.
* - It may require specifying regional endpoints when creating the service client,
* please see the apiEndpoint client configuration option for more details.
*/
function callSample(): void
{
$formattedParent = AutoMlClient::locationName('[PROJECT]', '[LOCATION]');
create_dataset_sample($formattedParent);
}
createModel
Creates a model.
Returns a Model in the response field when it completes. When you create a model, several model evaluations are created for it: a global evaluation, and one evaluation for each annotation spec.
Parameters | |
---|---|
Name | Description |
parent |
string
Required. Resource name of the parent project where the model is being created. |
model |
Google\Cloud\AutoMl\V1\Model
Required. The model to create. |
optionalArgs |
array
Optional. |
↳ retrySettings |
RetrySettings|array
Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage. |
Returns | |
---|---|
Type | Description |
Google\ApiCore\OperationResponse |
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\AutoMl\V1\AutoMlClient;
use Google\Cloud\AutoMl\V1\Model;
use Google\Rpc\Status;
/**
* @param string $formattedParent Resource name of the parent project where the model is being created. Please see
* {@see AutoMlClient::locationName()} for help formatting this field.
*/
function create_model_sample(string $formattedParent): void
{
// Create a client.
$autoMlClient = new AutoMlClient();
// Prepare any non-scalar elements to be passed along with the request.
$model = new Model();
// Call the API and handle any network failures.
try {
/** @var OperationResponse $response */
$response = $autoMlClient->createModel($formattedParent, $model);
$response->pollUntilComplete();
if ($response->operationSucceeded()) {
/** @var Model $result */
$result = $response->getResult();
printf('Operation successful with response data: %s' . PHP_EOL, $result->serializeToJsonString());
} else {
/** @var Status $error */
$error = $response->getError();
printf('Operation failed with error data: %s' . PHP_EOL, $error->serializeToJsonString());
}
} catch (ApiException $ex) {
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
}
}
/**
* Helper to execute the sample.
*
* This sample has been automatically generated and should be regarded as a code
* template only. It will require modifications to work:
* - It may require correct/in-range values for request initialization.
* - It may require specifying regional endpoints when creating the service client,
* please see the apiEndpoint client configuration option for more details.
*/
function callSample(): void
{
$formattedParent = AutoMlClient::locationName('[PROJECT]', '[LOCATION]');
create_model_sample($formattedParent);
}
deleteDataset
Deletes a dataset and all of its contents.
Returns empty response in the
response field when it completes,
and delete_details
in the
metadata field.
Parameters | |
---|---|
Name | Description |
name |
string
Required. The resource name of the dataset to delete. |
optionalArgs |
array
Optional. |
↳ retrySettings |
RetrySettings|array
Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage. |
Returns | |
---|---|
Type | Description |
Google\ApiCore\OperationResponse |
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\AutoMl\V1\AutoMlClient;
use Google\Rpc\Status;
/**
* @param string $formattedName The resource name of the dataset to delete. Please see
* {@see AutoMlClient::datasetName()} for help formatting this field.
*/
function delete_dataset_sample(string $formattedName): void
{
// Create a client.
$autoMlClient = new AutoMlClient();
// Call the API and handle any network failures.
try {
/** @var OperationResponse $response */
$response = $autoMlClient->deleteDataset($formattedName);
$response->pollUntilComplete();
if ($response->operationSucceeded()) {
printf('Operation completed successfully.' . PHP_EOL);
} else {
/** @var Status $error */
$error = $response->getError();
printf('Operation failed with error data: %s' . PHP_EOL, $error->serializeToJsonString());
}
} catch (ApiException $ex) {
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
}
}
/**
* Helper to execute the sample.
*
* This sample has been automatically generated and should be regarded as a code
* template only. It will require modifications to work:
* - It may require correct/in-range values for request initialization.
* - It may require specifying regional endpoints when creating the service client,
* please see the apiEndpoint client configuration option for more details.
*/
function callSample(): void
{
$formattedName = AutoMlClient::datasetName('[PROJECT]', '[LOCATION]', '[DATASET]');
delete_dataset_sample($formattedName);
}
deleteModel
Deletes a model.
Returns google.protobuf.Empty
in the
response field when it completes,
and delete_details
in the
metadata field.
Parameters | |
---|---|
Name | Description |
name |
string
Required. Resource name of the model being deleted. |
optionalArgs |
array
Optional. |
↳ retrySettings |
RetrySettings|array
Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage. |
Returns | |
---|---|
Type | Description |
Google\ApiCore\OperationResponse |
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\AutoMl\V1\AutoMlClient;
use Google\Rpc\Status;
/**
* @param string $formattedName Resource name of the model being deleted. Please see
* {@see AutoMlClient::modelName()} for help formatting this field.
*/
function delete_model_sample(string $formattedName): void
{
// Create a client.
$autoMlClient = new AutoMlClient();
// Call the API and handle any network failures.
try {
/** @var OperationResponse $response */
$response = $autoMlClient->deleteModel($formattedName);
$response->pollUntilComplete();
if ($response->operationSucceeded()) {
printf('Operation completed successfully.' . PHP_EOL);
} else {
/** @var Status $error */
$error = $response->getError();
printf('Operation failed with error data: %s' . PHP_EOL, $error->serializeToJsonString());
}
} catch (ApiException $ex) {
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
}
}
/**
* Helper to execute the sample.
*
* This sample has been automatically generated and should be regarded as a code
* template only. It will require modifications to work:
* - It may require correct/in-range values for request initialization.
* - It may require specifying regional endpoints when creating the service client,
* please see the apiEndpoint client configuration option for more details.
*/
function callSample(): void
{
$formattedName = AutoMlClient::modelName('[PROJECT]', '[LOCATION]', '[MODEL]');
delete_model_sample($formattedName);
}
deployModel
Deploys a model. If a model is already deployed, deploying it with the same parameters has no effect. Deploying with different parametrs (as e.g. changing node_number) will reset the deployment state without pausing the model's availability.
Only applicable for Text Classification, Image Object Detection , Tables, and Image Segmentation; all other domains manage deployment automatically.
Returns an empty response in the response field when it completes.
Parameters | |
---|---|
Name | Description |
name |
string
Required. Resource name of the model to deploy. |
optionalArgs |
array
Optional. |
↳ imageObjectDetectionModelDeploymentMetadata |
ImageObjectDetectionModelDeploymentMetadata
Model deployment metadata specific to Image Object Detection. |
↳ imageClassificationModelDeploymentMetadata |
ImageClassificationModelDeploymentMetadata
Model deployment metadata specific to Image Classification. |
↳ retrySettings |
RetrySettings|array
Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage. |
Returns | |
---|---|
Type | Description |
Google\ApiCore\OperationResponse |
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\AutoMl\V1\AutoMlClient;
use Google\Rpc\Status;
/**
* @param string $formattedName Resource name of the model to deploy. Please see
* {@see AutoMlClient::modelName()} for help formatting this field.
*/
function deploy_model_sample(string $formattedName): void
{
// Create a client.
$autoMlClient = new AutoMlClient();
// Call the API and handle any network failures.
try {
/** @var OperationResponse $response */
$response = $autoMlClient->deployModel($formattedName);
$response->pollUntilComplete();
if ($response->operationSucceeded()) {
printf('Operation completed successfully.' . PHP_EOL);
} else {
/** @var Status $error */
$error = $response->getError();
printf('Operation failed with error data: %s' . PHP_EOL, $error->serializeToJsonString());
}
} catch (ApiException $ex) {
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
}
}
/**
* Helper to execute the sample.
*
* This sample has been automatically generated and should be regarded as a code
* template only. It will require modifications to work:
* - It may require correct/in-range values for request initialization.
* - It may require specifying regional endpoints when creating the service client,
* please see the apiEndpoint client configuration option for more details.
*/
function callSample(): void
{
$formattedName = AutoMlClient::modelName('[PROJECT]', '[LOCATION]', '[MODEL]');
deploy_model_sample($formattedName);
}
exportData
Exports dataset's data to the provided output location.
Returns an empty response in the response field when it completes.
Parameters | |
---|---|
Name | Description |
name |
string
Required. The resource name of the dataset. |
outputConfig |
Google\Cloud\AutoMl\V1\OutputConfig
Required. The desired output location. |
optionalArgs |
array
Optional. |
↳ retrySettings |
RetrySettings|array
Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage. |
Returns | |
---|---|
Type | Description |
Google\ApiCore\OperationResponse |
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\AutoMl\V1\AutoMlClient;
use Google\Cloud\AutoMl\V1\GcsDestination;
use Google\Cloud\AutoMl\V1\OutputConfig;
use Google\Rpc\Status;
/**
* @param string $formattedName The resource name of the dataset. Please see
* {@see AutoMlClient::datasetName()} for help formatting this field.
* @param string $outputConfigGcsDestinationOutputUriPrefix Google Cloud Storage URI to output directory, up to 2000
* characters long.
* Accepted forms:
* * Prefix path: gs://bucket/directory
* The requesting user must have write permission to the bucket.
* The directory is created if it doesn't exist.
*/
function export_data_sample(
string $formattedName,
string $outputConfigGcsDestinationOutputUriPrefix
): void {
// Create a client.
$autoMlClient = new AutoMlClient();
// Prepare any non-scalar elements to be passed along with the request.
$outputConfigGcsDestination = (new GcsDestination())
->setOutputUriPrefix($outputConfigGcsDestinationOutputUriPrefix);
$outputConfig = (new OutputConfig())
->setGcsDestination($outputConfigGcsDestination);
// Call the API and handle any network failures.
try {
/** @var OperationResponse $response */
$response = $autoMlClient->exportData($formattedName, $outputConfig);
$response->pollUntilComplete();
if ($response->operationSucceeded()) {
printf('Operation completed successfully.' . PHP_EOL);
} else {
/** @var Status $error */
$error = $response->getError();
printf('Operation failed with error data: %s' . PHP_EOL, $error->serializeToJsonString());
}
} catch (ApiException $ex) {
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
}
}
/**
* Helper to execute the sample.
*
* This sample has been automatically generated and should be regarded as a code
* template only. It will require modifications to work:
* - It may require correct/in-range values for request initialization.
* - It may require specifying regional endpoints when creating the service client,
* please see the apiEndpoint client configuration option for more details.
*/
function callSample(): void
{
$formattedName = AutoMlClient::datasetName('[PROJECT]', '[LOCATION]', '[DATASET]');
$outputConfigGcsDestinationOutputUriPrefix = '[OUTPUT_URI_PREFIX]';
export_data_sample($formattedName, $outputConfigGcsDestinationOutputUriPrefix);
}
exportModel
Exports a trained, "export-able", model to a user specified Google Cloud Storage location. A model is considered export-able if and only if it has an export format defined for it in ModelExportOutputConfig.
Returns an empty response in the response field when it completes.
Parameters | |
---|---|
Name | Description |
name |
string
Required. The resource name of the model to export. |
outputConfig |
Google\Cloud\AutoMl\V1\ModelExportOutputConfig
Required. The desired output location and configuration. |
optionalArgs |
array
Optional. |
↳ retrySettings |
RetrySettings|array
Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage. |
Returns | |
---|---|
Type | Description |
Google\ApiCore\OperationResponse |
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\AutoMl\V1\AutoMlClient;
use Google\Cloud\AutoMl\V1\GcsDestination;
use Google\Cloud\AutoMl\V1\ModelExportOutputConfig;
use Google\Rpc\Status;
/**
* @param string $formattedName The resource name of the model to export. Please see
* {@see AutoMlClient::modelName()} for help formatting this field.
* @param string $outputConfigGcsDestinationOutputUriPrefix Google Cloud Storage URI to output directory, up to 2000
* characters long.
* Accepted forms:
* * Prefix path: gs://bucket/directory
* The requesting user must have write permission to the bucket.
* The directory is created if it doesn't exist.
*/
function export_model_sample(
string $formattedName,
string $outputConfigGcsDestinationOutputUriPrefix
): void {
// Create a client.
$autoMlClient = new AutoMlClient();
// Prepare any non-scalar elements to be passed along with the request.
$outputConfigGcsDestination = (new GcsDestination())
->setOutputUriPrefix($outputConfigGcsDestinationOutputUriPrefix);
$outputConfig = (new ModelExportOutputConfig())
->setGcsDestination($outputConfigGcsDestination);
// Call the API and handle any network failures.
try {
/** @var OperationResponse $response */
$response = $autoMlClient->exportModel($formattedName, $outputConfig);
$response->pollUntilComplete();
if ($response->operationSucceeded()) {
printf('Operation completed successfully.' . PHP_EOL);
} else {
/** @var Status $error */
$error = $response->getError();
printf('Operation failed with error data: %s' . PHP_EOL, $error->serializeToJsonString());
}
} catch (ApiException $ex) {
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
}
}
/**
* Helper to execute the sample.
*
* This sample has been automatically generated and should be regarded as a code
* template only. It will require modifications to work:
* - It may require correct/in-range values for request initialization.
* - It may require specifying regional endpoints when creating the service client,
* please see the apiEndpoint client configuration option for more details.
*/
function callSample(): void
{
$formattedName = AutoMlClient::modelName('[PROJECT]', '[LOCATION]', '[MODEL]');
$outputConfigGcsDestinationOutputUriPrefix = '[OUTPUT_URI_PREFIX]';
export_model_sample($formattedName, $outputConfigGcsDestinationOutputUriPrefix);
}
getAnnotationSpec
Gets an annotation spec.
Parameters | |
---|---|
Name | Description |
name |
string
Required. The resource name of the annotation spec to retrieve. |
optionalArgs |
array
Optional. |
↳ retrySettings |
RetrySettings|array
Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage. |
Returns | |
---|---|
Type | Description |
Google\Cloud\AutoMl\V1\AnnotationSpec |
use Google\ApiCore\ApiException;
use Google\Cloud\AutoMl\V1\AnnotationSpec;
use Google\Cloud\AutoMl\V1\AutoMlClient;
/**
* @param string $formattedName The resource name of the annotation spec to retrieve. Please see
* {@see AutoMlClient::annotationSpecName()} for help formatting this field.
*/
function get_annotation_spec_sample(string $formattedName): void
{
// Create a client.
$autoMlClient = new AutoMlClient();
// Call the API and handle any network failures.
try {
/** @var AnnotationSpec $response */
$response = $autoMlClient->getAnnotationSpec($formattedName);
printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
} catch (ApiException $ex) {
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
}
}
/**
* Helper to execute the sample.
*
* This sample has been automatically generated and should be regarded as a code
* template only. It will require modifications to work:
* - It may require correct/in-range values for request initialization.
* - It may require specifying regional endpoints when creating the service client,
* please see the apiEndpoint client configuration option for more details.
*/
function callSample(): void
{
$formattedName = AutoMlClient::annotationSpecName(
'[PROJECT]',
'[LOCATION]',
'[DATASET]',
'[ANNOTATION_SPEC]'
);
get_annotation_spec_sample($formattedName);
}
getDataset
Gets a dataset.
Parameters | |
---|---|
Name | Description |
name |
string
Required. The resource name of the dataset to retrieve. |
optionalArgs |
array
Optional. |
↳ retrySettings |
RetrySettings|array
Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage. |
Returns | |
---|---|
Type | Description |
Google\Cloud\AutoMl\V1\Dataset |
use Google\ApiCore\ApiException;
use Google\Cloud\AutoMl\V1\AutoMlClient;
use Google\Cloud\AutoMl\V1\Dataset;
/**
* @param string $formattedName The resource name of the dataset to retrieve. Please see
* {@see AutoMlClient::datasetName()} for help formatting this field.
*/
function get_dataset_sample(string $formattedName): void
{
// Create a client.
$autoMlClient = new AutoMlClient();
// Call the API and handle any network failures.
try {
/** @var Dataset $response */
$response = $autoMlClient->getDataset($formattedName);
printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
} catch (ApiException $ex) {
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
}
}
/**
* Helper to execute the sample.
*
* This sample has been automatically generated and should be regarded as a code
* template only. It will require modifications to work:
* - It may require correct/in-range values for request initialization.
* - It may require specifying regional endpoints when creating the service client,
* please see the apiEndpoint client configuration option for more details.
*/
function callSample(): void
{
$formattedName = AutoMlClient::datasetName('[PROJECT]', '[LOCATION]', '[DATASET]');
get_dataset_sample($formattedName);
}
getModel
Gets a model.
Parameters | |
---|---|
Name | Description |
name |
string
Required. Resource name of the model. |
optionalArgs |
array
Optional. |
↳ retrySettings |
RetrySettings|array
Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage. |
Returns | |
---|---|
Type | Description |
Google\Cloud\AutoMl\V1\Model |
use Google\ApiCore\ApiException;
use Google\Cloud\AutoMl\V1\AutoMlClient;
use Google\Cloud\AutoMl\V1\Model;
/**
* @param string $formattedName Resource name of the model. Please see
* {@see AutoMlClient::modelName()} for help formatting this field.
*/
function get_model_sample(string $formattedName): void
{
// Create a client.
$autoMlClient = new AutoMlClient();
// Call the API and handle any network failures.
try {
/** @var Model $response */
$response = $autoMlClient->getModel($formattedName);
printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
} catch (ApiException $ex) {
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
}
}
/**
* Helper to execute the sample.
*
* This sample has been automatically generated and should be regarded as a code
* template only. It will require modifications to work:
* - It may require correct/in-range values for request initialization.
* - It may require specifying regional endpoints when creating the service client,
* please see the apiEndpoint client configuration option for more details.
*/
function callSample(): void
{
$formattedName = AutoMlClient::modelName('[PROJECT]', '[LOCATION]', '[MODEL]');
get_model_sample($formattedName);
}
getModelEvaluation
Gets a model evaluation.
Parameters | |
---|---|
Name | Description |
name |
string
Required. Resource name for the model evaluation. |
optionalArgs |
array
Optional. |
↳ retrySettings |
RetrySettings|array
Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage. |
Returns | |
---|---|
Type | Description |
Google\Cloud\AutoMl\V1\ModelEvaluation |
use Google\ApiCore\ApiException;
use Google\Cloud\AutoMl\V1\AutoMlClient;
use Google\Cloud\AutoMl\V1\ModelEvaluation;
/**
* @param string $formattedName Resource name for the model evaluation. Please see
* {@see AutoMlClient::modelEvaluationName()} for help formatting this field.
*/
function get_model_evaluation_sample(string $formattedName): void
{
// Create a client.
$autoMlClient = new AutoMlClient();
// Call the API and handle any network failures.
try {
/** @var ModelEvaluation $response */
$response = $autoMlClient->getModelEvaluation($formattedName);
printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
} catch (ApiException $ex) {
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
}
}
/**
* Helper to execute the sample.
*
* This sample has been automatically generated and should be regarded as a code
* template only. It will require modifications to work:
* - It may require correct/in-range values for request initialization.
* - It may require specifying regional endpoints when creating the service client,
* please see the apiEndpoint client configuration option for more details.
*/
function callSample(): void
{
$formattedName = AutoMlClient::modelEvaluationName(
'[PROJECT]',
'[LOCATION]',
'[MODEL]',
'[MODEL_EVALUATION]'
);
get_model_evaluation_sample($formattedName);
}
importData
Imports data into a dataset.
For Tables this method can only be called on an empty Dataset.
For Tables:
- A schema_inference_version parameter must be explicitly set. Returns an empty response in the response field when it completes.
Parameters | |
---|---|
Name | Description |
name |
string
Required. Dataset name. Dataset must already exist. All imported annotations and examples will be added. |
inputConfig |
Google\Cloud\AutoMl\V1\InputConfig
Required. The desired input location and its domain specific semantics, if any. |
optionalArgs |
array
Optional. |
↳ retrySettings |
RetrySettings|array
Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage. |
Returns | |
---|---|
Type | Description |
Google\ApiCore\OperationResponse |
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\AutoMl\V1\AutoMlClient;
use Google\Cloud\AutoMl\V1\InputConfig;
use Google\Rpc\Status;
/**
* @param string $formattedName Dataset name. Dataset must already exist. All imported
* annotations and examples will be added. Please see
* {@see AutoMlClient::datasetName()} for help formatting this field.
*/
function import_data_sample(string $formattedName): void
{
// Create a client.
$autoMlClient = new AutoMlClient();
// Prepare any non-scalar elements to be passed along with the request.
$inputConfig = new InputConfig();
// Call the API and handle any network failures.
try {
/** @var OperationResponse $response */
$response = $autoMlClient->importData($formattedName, $inputConfig);
$response->pollUntilComplete();
if ($response->operationSucceeded()) {
printf('Operation completed successfully.' . PHP_EOL);
} else {
/** @var Status $error */
$error = $response->getError();
printf('Operation failed with error data: %s' . PHP_EOL, $error->serializeToJsonString());
}
} catch (ApiException $ex) {
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
}
}
/**
* Helper to execute the sample.
*
* This sample has been automatically generated and should be regarded as a code
* template only. It will require modifications to work:
* - It may require correct/in-range values for request initialization.
* - It may require specifying regional endpoints when creating the service client,
* please see the apiEndpoint client configuration option for more details.
*/
function callSample(): void
{
$formattedName = AutoMlClient::datasetName('[PROJECT]', '[LOCATION]', '[DATASET]');
import_data_sample($formattedName);
}
listDatasets
Lists datasets in a project.
Parameters | |
---|---|
Name | Description |
parent |
string
Required. The resource name of the project from which to list datasets. |
optionalArgs |
array
Optional. |
↳ filter |
string
An expression for filtering the results of the request. * |
↳ pageSize |
int
The maximum number of resources contained in the underlying API response. The API may return fewer values in a page, even if there are additional values to be retrieved. |
↳ pageToken |
string
A page token is used to specify a page of values to be returned. If no page token is specified (the default), the first page of values will be returned. Any page token used here must have been generated by a previous call to the API. |
↳ retrySettings |
RetrySettings|array
Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage. |
Returns | |
---|---|
Type | Description |
Google\ApiCore\PagedListResponse |
use Google\ApiCore\ApiException;
use Google\ApiCore\PagedListResponse;
use Google\Cloud\AutoMl\V1\AutoMlClient;
use Google\Cloud\AutoMl\V1\Dataset;
/**
* @param string $formattedParent The resource name of the project from which to list datasets. Please see
* {@see AutoMlClient::locationName()} for help formatting this field.
*/
function list_datasets_sample(string $formattedParent): void
{
// Create a client.
$autoMlClient = new AutoMlClient();
// Call the API and handle any network failures.
try {
/** @var PagedListResponse $response */
$response = $autoMlClient->listDatasets($formattedParent);
/** @var Dataset $element */
foreach ($response as $element) {
printf('Element data: %s' . PHP_EOL, $element->serializeToJsonString());
}
} catch (ApiException $ex) {
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
}
}
/**
* Helper to execute the sample.
*
* This sample has been automatically generated and should be regarded as a code
* template only. It will require modifications to work:
* - It may require correct/in-range values for request initialization.
* - It may require specifying regional endpoints when creating the service client,
* please see the apiEndpoint client configuration option for more details.
*/
function callSample(): void
{
$formattedParent = AutoMlClient::locationName('[PROJECT]', '[LOCATION]');
list_datasets_sample($formattedParent);
}
listModelEvaluations
Lists model evaluations.
Parameters | |
---|---|
Name | Description |
parent |
string
Required. Resource name of the model to list the model evaluations for. If modelId is set as "-", this will list model evaluations from across all models of the parent location. |
filter |
string
Required. An expression for filtering the results of the request.
Some examples of using the filter are:
|
optionalArgs |
array
Optional. |
↳ pageSize |
int
The maximum number of resources contained in the underlying API response. The API may return fewer values in a page, even if there are additional values to be retrieved. |
↳ pageToken |
string
A page token is used to specify a page of values to be returned. If no page token is specified (the default), the first page of values will be returned. Any page token used here must have been generated by a previous call to the API. |
↳ retrySettings |
RetrySettings|array
Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage. |
Returns | |
---|---|
Type | Description |
Google\ApiCore\PagedListResponse |
use Google\ApiCore\ApiException;
use Google\ApiCore\PagedListResponse;
use Google\Cloud\AutoMl\V1\AutoMlClient;
use Google\Cloud\AutoMl\V1\ModelEvaluation;
/**
* @param string $formattedParent Resource name of the model to list the model evaluations for.
* If modelId is set as "-", this will list model evaluations from across all
* models of the parent location. Please see
* {@see AutoMlClient::modelName()} for help formatting this field.
* @param string $filter An expression for filtering the results of the request.
*
* * `annotation_spec_id` - for =, != or existence. See example below for
* the last.
*
* Some examples of using the filter are:
*
* * `annotation_spec_id!=4` --> The model evaluation was done for
* annotation spec with ID different than 4.
* * `NOT annotation_spec_id:*` --> The model evaluation was done for
* aggregate of all annotation specs.
*/
function list_model_evaluations_sample(string $formattedParent, string $filter): void
{
// Create a client.
$autoMlClient = new AutoMlClient();
// Call the API and handle any network failures.
try {
/** @var PagedListResponse $response */
$response = $autoMlClient->listModelEvaluations($formattedParent, $filter);
/** @var ModelEvaluation $element */
foreach ($response as $element) {
printf('Element data: %s' . PHP_EOL, $element->serializeToJsonString());
}
} catch (ApiException $ex) {
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
}
}
/**
* Helper to execute the sample.
*
* This sample has been automatically generated and should be regarded as a code
* template only. It will require modifications to work:
* - It may require correct/in-range values for request initialization.
* - It may require specifying regional endpoints when creating the service client,
* please see the apiEndpoint client configuration option for more details.
*/
function callSample(): void
{
$formattedParent = AutoMlClient::modelName('[PROJECT]', '[LOCATION]', '[MODEL]');
$filter = '[FILTER]';
list_model_evaluations_sample($formattedParent, $filter);
}
listModels
Lists models.
Parameters | |
---|---|
Name | Description |
parent |
string
Required. Resource name of the project, from which to list the models. |
optionalArgs |
array
Optional. |
↳ filter |
string
An expression for filtering the results of the request. * |
↳ pageSize |
int
The maximum number of resources contained in the underlying API response. The API may return fewer values in a page, even if there are additional values to be retrieved. |
↳ pageToken |
string
A page token is used to specify a page of values to be returned. If no page token is specified (the default), the first page of values will be returned. Any page token used here must have been generated by a previous call to the API. |
↳ retrySettings |
RetrySettings|array
Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage. |
Returns | |
---|---|
Type | Description |
Google\ApiCore\PagedListResponse |
use Google\ApiCore\ApiException;
use Google\ApiCore\PagedListResponse;
use Google\Cloud\AutoMl\V1\AutoMlClient;
use Google\Cloud\AutoMl\V1\Model;
/**
* @param string $formattedParent Resource name of the project, from which to list the models. Please see
* {@see AutoMlClient::locationName()} for help formatting this field.
*/
function list_models_sample(string $formattedParent): void
{
// Create a client.
$autoMlClient = new AutoMlClient();
// Call the API and handle any network failures.
try {
/** @var PagedListResponse $response */
$response = $autoMlClient->listModels($formattedParent);
/** @var Model $element */
foreach ($response as $element) {
printf('Element data: %s' . PHP_EOL, $element->serializeToJsonString());
}
} catch (ApiException $ex) {
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
}
}
/**
* Helper to execute the sample.
*
* This sample has been automatically generated and should be regarded as a code
* template only. It will require modifications to work:
* - It may require correct/in-range values for request initialization.
* - It may require specifying regional endpoints when creating the service client,
* please see the apiEndpoint client configuration option for more details.
*/
function callSample(): void
{
$formattedParent = AutoMlClient::locationName('[PROJECT]', '[LOCATION]');
list_models_sample($formattedParent);
}
undeployModel
Undeploys a model. If the model is not deployed this method has no effect.
Only applicable for Text Classification, Image Object Detection and Tables; all other domains manage deployment automatically.
Returns an empty response in the response field when it completes.
Parameters | |
---|---|
Name | Description |
name |
string
Required. Resource name of the model to undeploy. |
optionalArgs |
array
Optional. |
↳ retrySettings |
RetrySettings|array
Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage. |
Returns | |
---|---|
Type | Description |
Google\ApiCore\OperationResponse |
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\AutoMl\V1\AutoMlClient;
use Google\Rpc\Status;
/**
* @param string $formattedName Resource name of the model to undeploy. Please see
* {@see AutoMlClient::modelName()} for help formatting this field.
*/
function undeploy_model_sample(string $formattedName): void
{
// Create a client.
$autoMlClient = new AutoMlClient();
// Call the API and handle any network failures.
try {
/** @var OperationResponse $response */
$response = $autoMlClient->undeployModel($formattedName);
$response->pollUntilComplete();
if ($response->operationSucceeded()) {
printf('Operation completed successfully.' . PHP_EOL);
} else {
/** @var Status $error */
$error = $response->getError();
printf('Operation failed with error data: %s' . PHP_EOL, $error->serializeToJsonString());
}
} catch (ApiException $ex) {
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
}
}
/**
* Helper to execute the sample.
*
* This sample has been automatically generated and should be regarded as a code
* template only. It will require modifications to work:
* - It may require correct/in-range values for request initialization.
* - It may require specifying regional endpoints when creating the service client,
* please see the apiEndpoint client configuration option for more details.
*/
function callSample(): void
{
$formattedName = AutoMlClient::modelName('[PROJECT]', '[LOCATION]', '[MODEL]');
undeploy_model_sample($formattedName);
}
updateDataset
Updates a dataset.
Parameters | |
---|---|
Name | Description |
dataset |
Google\Cloud\AutoMl\V1\Dataset
Required. The dataset which replaces the resource on the server. |
updateMask |
Google\Protobuf\FieldMask
Required. The update mask applies to the resource. |
optionalArgs |
array
Optional. |
↳ retrySettings |
RetrySettings|array
Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage. |
Returns | |
---|---|
Type | Description |
Google\Cloud\AutoMl\V1\Dataset |
use Google\ApiCore\ApiException;
use Google\Cloud\AutoMl\V1\AutoMlClient;
use Google\Cloud\AutoMl\V1\Dataset;
use Google\Protobuf\FieldMask;
/**
* This sample has been automatically generated and should be regarded as a code
* template only. It will require modifications to work:
* - It may require correct/in-range values for request initialization.
* - It may require specifying regional endpoints when creating the service client,
* please see the apiEndpoint client configuration option for more details.
*/
function update_dataset_sample(): void
{
// Create a client.
$autoMlClient = new AutoMlClient();
// Prepare any non-scalar elements to be passed along with the request.
$dataset = new Dataset();
$updateMask = new FieldMask();
// Call the API and handle any network failures.
try {
/** @var Dataset $response */
$response = $autoMlClient->updateDataset($dataset, $updateMask);
printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
} catch (ApiException $ex) {
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
}
}
updateModel
Updates a model.
Parameters | |
---|---|
Name | Description |
model |
Google\Cloud\AutoMl\V1\Model
Required. The model which replaces the resource on the server. |
updateMask |
Google\Protobuf\FieldMask
Required. The update mask applies to the resource. |
optionalArgs |
array
Optional. |
↳ retrySettings |
RetrySettings|array
Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage. |
Returns | |
---|---|
Type | Description |
Google\Cloud\AutoMl\V1\Model |
use Google\ApiCore\ApiException;
use Google\Cloud\AutoMl\V1\AutoMlClient;
use Google\Cloud\AutoMl\V1\Model;
use Google\Protobuf\FieldMask;
/**
* This sample has been automatically generated and should be regarded as a code
* template only. It will require modifications to work:
* - It may require correct/in-range values for request initialization.
* - It may require specifying regional endpoints when creating the service client,
* please see the apiEndpoint client configuration option for more details.
*/
function update_model_sample(): void
{
// Create a client.
$autoMlClient = new AutoMlClient();
// Prepare any non-scalar elements to be passed along with the request.
$model = new Model();
$updateMask = new FieldMask();
// Call the API and handle any network failures.
try {
/** @var Model $response */
$response = $autoMlClient->updateModel($model, $updateMask);
printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
} catch (ApiException $ex) {
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
}
}
getOperationsClient
Return an OperationsClient object with the same endpoint as $this.
Returns | |
---|---|
Type | Description |
Google\ApiCore\LongRunning\OperationsClient |
resumeOperation
Resume an existing long running operation that was previously started by a long running API method. If $methodName is not provided, or does not match a long running API method, then the operation can still be resumed, but the OperationResponse object will not deserialize the final response.
Parameters | |
---|---|
Name | Description |
operationName |
string
The name of the long running operation |
methodName |
string
The name of the method used to start the operation |
Returns | |
---|---|
Type | Description |
Google\ApiCore\OperationResponse |
static::annotationSpecName
Formats a string containing the fully-qualified path to represent a annotation_spec resource.
Parameters | |
---|---|
Name | Description |
project |
string
|
location |
string
|
dataset |
string
|
annotationSpec |
string
|
Returns | |
---|---|
Type | Description |
string | The formatted annotation_spec resource. |
static::datasetName
Formats a string containing the fully-qualified path to represent a dataset resource.
Parameters | |
---|---|
Name | Description |
project |
string
|
location |
string
|
dataset |
string
|
Returns | |
---|---|
Type | Description |
string | The formatted dataset resource. |
static::locationName
Formats a string containing the fully-qualified path to represent a location resource.
Parameters | |
---|---|
Name | Description |
project |
string
|
location |
string
|
Returns | |
---|---|
Type | Description |
string | The formatted location resource. |
static::modelName
Formats a string containing the fully-qualified path to represent a model resource.
Parameters | |
---|---|
Name | Description |
project |
string
|
location |
string
|
model |
string
|
Returns | |
---|---|
Type | Description |
string | The formatted model resource. |
static::modelEvaluationName
Formats a string containing the fully-qualified path to represent a model_evaluation resource.
Parameters | |
---|---|
Name | Description |
project |
string
|
location |
string
|
model |
string
|
modelEvaluation |
string
|
Returns | |
---|---|
Type | Description |
string | The formatted model_evaluation resource. |
static::parseName
Parses a formatted name string and returns an associative array of the components in the name.
The following name formats are supported: Template: Pattern
- annotationSpec: projects/{project}/locations/{location}/datasets/{dataset}/annotationSpecs/{annotation_spec}
- dataset: projects/{project}/locations/{location}/datasets/{dataset}
- location: projects/{project}/locations/{location}
- model: projects/{project}/locations/{location}/models/{model}
- modelEvaluation: projects/{project}/locations/{location}/models/{model}/modelEvaluations/{model_evaluation}
The optional $template argument can be supplied to specify a particular pattern, and must match one of the templates listed above. If no $template argument is provided, or if the $template argument does not match one of the templates listed, then parseName will check each of the supported templates, and return the first match.
Parameters | |
---|---|
Name | Description |
formattedName |
string
The formatted name string |
template |
string
Optional name of template to match |
Returns | |
---|---|
Type | Description |
array | An associative array from name component IDs to component values. |
Constants
SERVICE_NAME
Value: 'google.cloud.automl.v1.AutoMl'
The name of the service.
SERVICE_ADDRESS
Value: 'automl.googleapis.com'
The default address of the service.
DEFAULT_SERVICE_PORT
Value: 443
The default port of the service.
CODEGEN_NAME
Value: 'gapic'
The name of the code generator, to be included in the agent header.