Reference documentation and code samples for the Google Cloud Datalabeling V1beta1 Client class DataLabelingServiceClient.
Service Description: Service for the AI Platform Data Labeling API.
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:
$dataLabelingServiceClient = new DataLabelingServiceClient();
try {
$formattedParent = $dataLabelingServiceClient->projectName('[PROJECT]');
$annotationSpecSet = new AnnotationSpecSet();
$response = $dataLabelingServiceClient->createAnnotationSpecSet($formattedParent, $annotationSpecSet);
} finally {
$dataLabelingServiceClient->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.
Namespace
Google \ Cloud \ DataLabeling \ V1beta1Methods
__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. |
createAnnotationSpecSet
Creates an annotation spec set by providing a set of labels.
Parameters | |
---|---|
Name | Description |
parent |
string
Required. AnnotationSpecSet resource parent, format: projects/{project_id} |
annotationSpecSet |
Google\Cloud\DataLabeling\V1beta1\AnnotationSpecSet
Required. Annotation spec set to create. Annotation specs must be included. Only one annotation spec will be accepted for annotation specs with same display_name. |
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\DataLabeling\V1beta1\AnnotationSpecSet |
use Google\ApiCore\ApiException;
use Google\Cloud\DataLabeling\V1beta1\AnnotationSpecSet;
use Google\Cloud\DataLabeling\V1beta1\Client\DataLabelingServiceClient;
use Google\Cloud\DataLabeling\V1beta1\CreateAnnotationSpecSetRequest;
/**
* @param string $formattedParent AnnotationSpecSet resource parent, format:
* projects/{project_id}
* Please see {@see DataLabelingServiceClient::projectName()} for help formatting this field.
*/
function create_annotation_spec_set_sample(string $formattedParent): void
{
// Create a client.
$dataLabelingServiceClient = new DataLabelingServiceClient();
// Prepare the request message.
$annotationSpecSet = new AnnotationSpecSet();
$request = (new CreateAnnotationSpecSetRequest())
->setParent($formattedParent)
->setAnnotationSpecSet($annotationSpecSet);
// Call the API and handle any network failures.
try {
/** @var AnnotationSpecSet $response */
$response = $dataLabelingServiceClient->createAnnotationSpecSet($request);
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
{
$formattedParent = DataLabelingServiceClient::projectName('[PROJECT]');
create_annotation_spec_set_sample($formattedParent);
}
createDataset
Creates dataset. If success return a Dataset resource.
Parameters | |
---|---|
Name | Description |
parent |
string
Required. Dataset resource parent, format: projects/{project_id} |
dataset |
Google\Cloud\DataLabeling\V1beta1\Dataset
Required. The dataset to be created. |
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\DataLabeling\V1beta1\Dataset |
use Google\ApiCore\ApiException;
use Google\Cloud\DataLabeling\V1beta1\Client\DataLabelingServiceClient;
use Google\Cloud\DataLabeling\V1beta1\CreateDatasetRequest;
use Google\Cloud\DataLabeling\V1beta1\Dataset;
/**
* @param string $formattedParent Dataset resource parent, format:
* projects/{project_id}
* Please see {@see DataLabelingServiceClient::projectName()} for help formatting this field.
*/
function create_dataset_sample(string $formattedParent): void
{
// Create a client.
$dataLabelingServiceClient = new DataLabelingServiceClient();
// Prepare the request message.
$dataset = new Dataset();
$request = (new CreateDatasetRequest())
->setParent($formattedParent)
->setDataset($dataset);
// Call the API and handle any network failures.
try {
/** @var Dataset $response */
$response = $dataLabelingServiceClient->createDataset($request);
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
{
$formattedParent = DataLabelingServiceClient::projectName('[PROJECT]');
create_dataset_sample($formattedParent);
}
createEvaluationJob
Creates an evaluation job.
Parameters | |
---|---|
Name | Description |
parent |
string
Required. Evaluation job resource parent. Format: "projects/{project_id}" |
job |
Google\Cloud\DataLabeling\V1beta1\EvaluationJob
Required. The evaluation job 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\Cloud\DataLabeling\V1beta1\EvaluationJob |
use Google\ApiCore\ApiException;
use Google\Cloud\DataLabeling\V1beta1\Client\DataLabelingServiceClient;
use Google\Cloud\DataLabeling\V1beta1\CreateEvaluationJobRequest;
use Google\Cloud\DataLabeling\V1beta1\EvaluationJob;
/**
* @param string $formattedParent Evaluation job resource parent. Format:
* "projects/<var>{project_id}</var>"
* Please see {@see DataLabelingServiceClient::projectName()} for help formatting this field.
*/
function create_evaluation_job_sample(string $formattedParent): void
{
// Create a client.
$dataLabelingServiceClient = new DataLabelingServiceClient();
// Prepare the request message.
$job = new EvaluationJob();
$request = (new CreateEvaluationJobRequest())
->setParent($formattedParent)
->setJob($job);
// Call the API and handle any network failures.
try {
/** @var EvaluationJob $response */
$response = $dataLabelingServiceClient->createEvaluationJob($request);
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
{
$formattedParent = DataLabelingServiceClient::projectName('[PROJECT]');
create_evaluation_job_sample($formattedParent);
}
createInstruction
Creates an instruction for how data should be labeled.
Parameters | |
---|---|
Name | Description |
parent |
string
Required. Instruction resource parent, format: projects/{project_id} |
instruction |
Google\Cloud\DataLabeling\V1beta1\Instruction
Required. Instruction of how to perform the labeling task. |
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\DataLabeling\V1beta1\Client\DataLabelingServiceClient;
use Google\Cloud\DataLabeling\V1beta1\CreateInstructionRequest;
use Google\Cloud\DataLabeling\V1beta1\Instruction;
use Google\Rpc\Status;
/**
* @param string $formattedParent Instruction resource parent, format:
* projects/{project_id}
* Please see {@see DataLabelingServiceClient::projectName()} for help formatting this field.
*/
function create_instruction_sample(string $formattedParent): void
{
// Create a client.
$dataLabelingServiceClient = new DataLabelingServiceClient();
// Prepare the request message.
$instruction = new Instruction();
$request = (new CreateInstructionRequest())
->setParent($formattedParent)
->setInstruction($instruction);
// Call the API and handle any network failures.
try {
/** @var OperationResponse $response */
$response = $dataLabelingServiceClient->createInstruction($request);
$response->pollUntilComplete();
if ($response->operationSucceeded()) {
/** @var Instruction $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 = DataLabelingServiceClient::projectName('[PROJECT]');
create_instruction_sample($formattedParent);
}
deleteAnnotatedDataset
Deletes an annotated dataset by resource name.
Parameters | |
---|---|
Name | Description |
name |
string
Required. Name of the annotated dataset to delete, format: projects/{project_id}/datasets/{dataset_id}/annotatedDatasets/ {annotated_dataset_id} |
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. |
use Google\ApiCore\ApiException;
use Google\Cloud\DataLabeling\V1beta1\Client\DataLabelingServiceClient;
use Google\Cloud\DataLabeling\V1beta1\DeleteAnnotatedDatasetRequest;
/**
* @param string $formattedName Name of the annotated dataset to delete, format:
* projects/{project_id}/datasets/{dataset_id}/annotatedDatasets/
* {annotated_dataset_id}
* Please see {@see DataLabelingServiceClient::annotatedDatasetName()} for help formatting this field.
*/
function delete_annotated_dataset_sample(string $formattedName): void
{
// Create a client.
$dataLabelingServiceClient = new DataLabelingServiceClient();
// Prepare the request message.
$request = (new DeleteAnnotatedDatasetRequest())
->setName($formattedName);
// Call the API and handle any network failures.
try {
$dataLabelingServiceClient->deleteAnnotatedDataset($request);
printf('Call completed successfully.' . PHP_EOL);
} 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 = DataLabelingServiceClient::annotatedDatasetName(
'[PROJECT]',
'[DATASET]',
'[ANNOTATED_DATASET]'
);
delete_annotated_dataset_sample($formattedName);
}
deleteAnnotationSpecSet
Deletes an annotation spec set by resource name.
Parameters | |
---|---|
Name | Description |
name |
string
Required. AnnotationSpec resource name, format:
|
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. |
use Google\ApiCore\ApiException;
use Google\Cloud\DataLabeling\V1beta1\Client\DataLabelingServiceClient;
use Google\Cloud\DataLabeling\V1beta1\DeleteAnnotationSpecSetRequest;
/**
* @param string $formattedName AnnotationSpec resource name, format:
* `projects/{project_id}/annotationSpecSets/{annotation_spec_set_id}`. Please see
* {@see DataLabelingServiceClient::annotationSpecSetName()} for help formatting this field.
*/
function delete_annotation_spec_set_sample(string $formattedName): void
{
// Create a client.
$dataLabelingServiceClient = new DataLabelingServiceClient();
// Prepare the request message.
$request = (new DeleteAnnotationSpecSetRequest())
->setName($formattedName);
// Call the API and handle any network failures.
try {
$dataLabelingServiceClient->deleteAnnotationSpecSet($request);
printf('Call completed successfully.' . PHP_EOL);
} 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 = DataLabelingServiceClient::annotationSpecSetName(
'[PROJECT]',
'[ANNOTATION_SPEC_SET]'
);
delete_annotation_spec_set_sample($formattedName);
}
deleteDataset
Deletes a dataset by resource name.
Parameters | |
---|---|
Name | Description |
name |
string
Required. Dataset resource name, format: projects/{project_id}/datasets/{dataset_id} |
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. |
use Google\ApiCore\ApiException;
use Google\Cloud\DataLabeling\V1beta1\Client\DataLabelingServiceClient;
use Google\Cloud\DataLabeling\V1beta1\DeleteDatasetRequest;
/**
* @param string $formattedName Dataset resource name, format:
* projects/{project_id}/datasets/{dataset_id}
* Please see {@see DataLabelingServiceClient::datasetName()} for help formatting this field.
*/
function delete_dataset_sample(string $formattedName): void
{
// Create a client.
$dataLabelingServiceClient = new DataLabelingServiceClient();
// Prepare the request message.
$request = (new DeleteDatasetRequest())
->setName($formattedName);
// Call the API and handle any network failures.
try {
$dataLabelingServiceClient->deleteDataset($request);
printf('Call completed successfully.' . PHP_EOL);
} 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 = DataLabelingServiceClient::datasetName('[PROJECT]', '[DATASET]');
delete_dataset_sample($formattedName);
}
deleteEvaluationJob
Stops and deletes an evaluation job.
Parameters | |
---|---|
Name | Description |
name |
string
Required. Name of the evaluation job that is going to be deleted. Format: "projects/{project_id}/evaluationJobs/{evaluation_job_id}" |
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. |
use Google\ApiCore\ApiException;
use Google\Cloud\DataLabeling\V1beta1\Client\DataLabelingServiceClient;
use Google\Cloud\DataLabeling\V1beta1\DeleteEvaluationJobRequest;
/**
* @param string $formattedName Name of the evaluation job that is going to be deleted. Format:
*
* "projects/<var>{project_id}</var>/evaluationJobs/<var>{evaluation_job_id}</var>"
* Please see {@see DataLabelingServiceClient::evaluationJobName()} for help formatting this field.
*/
function delete_evaluation_job_sample(string $formattedName): void
{
// Create a client.
$dataLabelingServiceClient = new DataLabelingServiceClient();
// Prepare the request message.
$request = (new DeleteEvaluationJobRequest())
->setName($formattedName);
// Call the API and handle any network failures.
try {
$dataLabelingServiceClient->deleteEvaluationJob($request);
printf('Call completed successfully.' . PHP_EOL);
} 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 = DataLabelingServiceClient::evaluationJobName('[PROJECT]', '[EVALUATION_JOB]');
delete_evaluation_job_sample($formattedName);
}
deleteInstruction
Deletes an instruction object by resource name.
Parameters | |
---|---|
Name | Description |
name |
string
Required. Instruction resource name, format: projects/{project_id}/instructions/{instruction_id} |
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. |
use Google\ApiCore\ApiException;
use Google\Cloud\DataLabeling\V1beta1\Client\DataLabelingServiceClient;
use Google\Cloud\DataLabeling\V1beta1\DeleteInstructionRequest;
/**
* @param string $formattedName Instruction resource name, format:
* projects/{project_id}/instructions/{instruction_id}
* Please see {@see DataLabelingServiceClient::instructionName()} for help formatting this field.
*/
function delete_instruction_sample(string $formattedName): void
{
// Create a client.
$dataLabelingServiceClient = new DataLabelingServiceClient();
// Prepare the request message.
$request = (new DeleteInstructionRequest())
->setName($formattedName);
// Call the API and handle any network failures.
try {
$dataLabelingServiceClient->deleteInstruction($request);
printf('Call completed successfully.' . PHP_EOL);
} 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 = DataLabelingServiceClient::instructionName('[PROJECT]', '[INSTRUCTION]');
delete_instruction_sample($formattedName);
}
exportData
Exports data and annotations from dataset.
Parameters | |
---|---|
Name | Description |
name |
string
Required. Dataset resource name, format: projects/{project_id}/datasets/{dataset_id} |
annotatedDataset |
string
Required. Annotated dataset resource name. DataItem in Dataset and their annotations in specified annotated dataset will be exported. It's in format of projects/{project_id}/datasets/{dataset_id}/annotatedDatasets/ {annotated_dataset_id} |
outputConfig |
Google\Cloud\DataLabeling\V1beta1\OutputConfig
Required. Specify the output destination. |
optionalArgs |
array
Optional. |
↳ filter |
string
Optional. Filter is not supported at this moment. |
↳ userEmailAddress |
string
Email of the user who started the export task and should be notified by email. If empty no notification will be sent. |
↳ 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\DataLabeling\V1beta1\Client\DataLabelingServiceClient;
use Google\Cloud\DataLabeling\V1beta1\ExportDataOperationResponse;
use Google\Cloud\DataLabeling\V1beta1\ExportDataRequest;
use Google\Cloud\DataLabeling\V1beta1\OutputConfig;
use Google\Rpc\Status;
/**
* @param string $formattedName Dataset resource name, format:
* projects/{project_id}/datasets/{dataset_id}
* Please see {@see DataLabelingServiceClient::datasetName()} for help formatting this field.
* @param string $formattedAnnotatedDataset Annotated dataset resource name. DataItem in
* Dataset and their annotations in specified annotated dataset will be
* exported. It's in format of
* projects/{project_id}/datasets/{dataset_id}/annotatedDatasets/
* {annotated_dataset_id}
* Please see {@see DataLabelingServiceClient::annotatedDatasetName()} for help formatting this field.
*/
function export_data_sample(string $formattedName, string $formattedAnnotatedDataset): void
{
// Create a client.
$dataLabelingServiceClient = new DataLabelingServiceClient();
// Prepare the request message.
$outputConfig = new OutputConfig();
$request = (new ExportDataRequest())
->setName($formattedName)
->setAnnotatedDataset($formattedAnnotatedDataset)
->setOutputConfig($outputConfig);
// Call the API and handle any network failures.
try {
/** @var OperationResponse $response */
$response = $dataLabelingServiceClient->exportData($request);
$response->pollUntilComplete();
if ($response->operationSucceeded()) {
/** @var ExportDataOperationResponse $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
{
$formattedName = DataLabelingServiceClient::datasetName('[PROJECT]', '[DATASET]');
$formattedAnnotatedDataset = DataLabelingServiceClient::annotatedDatasetName(
'[PROJECT]',
'[DATASET]',
'[ANNOTATED_DATASET]'
);
export_data_sample($formattedName, $formattedAnnotatedDataset);
}
getAnnotatedDataset
Gets an annotated dataset by resource name.
Parameters | |
---|---|
Name | Description |
name |
string
Required. Name of the annotated dataset to get, format: projects/{project_id}/datasets/{dataset_id}/annotatedDatasets/ {annotated_dataset_id} |
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\DataLabeling\V1beta1\AnnotatedDataset |
use Google\ApiCore\ApiException;
use Google\Cloud\DataLabeling\V1beta1\AnnotatedDataset;
use Google\Cloud\DataLabeling\V1beta1\Client\DataLabelingServiceClient;
use Google\Cloud\DataLabeling\V1beta1\GetAnnotatedDatasetRequest;
/**
* @param string $formattedName Name of the annotated dataset to get, format:
* projects/{project_id}/datasets/{dataset_id}/annotatedDatasets/
* {annotated_dataset_id}
* Please see {@see DataLabelingServiceClient::annotatedDatasetName()} for help formatting this field.
*/
function get_annotated_dataset_sample(string $formattedName): void
{
// Create a client.
$dataLabelingServiceClient = new DataLabelingServiceClient();
// Prepare the request message.
$request = (new GetAnnotatedDatasetRequest())
->setName($formattedName);
// Call the API and handle any network failures.
try {
/** @var AnnotatedDataset $response */
$response = $dataLabelingServiceClient->getAnnotatedDataset($request);
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 = DataLabelingServiceClient::annotatedDatasetName(
'[PROJECT]',
'[DATASET]',
'[ANNOTATED_DATASET]'
);
get_annotated_dataset_sample($formattedName);
}
getAnnotationSpecSet
Gets an annotation spec set by resource name.
Parameters | |
---|---|
Name | Description |
name |
string
Required. AnnotationSpecSet resource name, format: projects/{project_id}/annotationSpecSets/{annotation_spec_set_id} |
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\DataLabeling\V1beta1\AnnotationSpecSet |
use Google\ApiCore\ApiException;
use Google\Cloud\DataLabeling\V1beta1\AnnotationSpecSet;
use Google\Cloud\DataLabeling\V1beta1\Client\DataLabelingServiceClient;
use Google\Cloud\DataLabeling\V1beta1\GetAnnotationSpecSetRequest;
/**
* @param string $formattedName AnnotationSpecSet resource name, format:
* projects/{project_id}/annotationSpecSets/{annotation_spec_set_id}
* Please see {@see DataLabelingServiceClient::annotationSpecSetName()} for help formatting this field.
*/
function get_annotation_spec_set_sample(string $formattedName): void
{
// Create a client.
$dataLabelingServiceClient = new DataLabelingServiceClient();
// Prepare the request message.
$request = (new GetAnnotationSpecSetRequest())
->setName($formattedName);
// Call the API and handle any network failures.
try {
/** @var AnnotationSpecSet $response */
$response = $dataLabelingServiceClient->getAnnotationSpecSet($request);
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 = DataLabelingServiceClient::annotationSpecSetName(
'[PROJECT]',
'[ANNOTATION_SPEC_SET]'
);
get_annotation_spec_set_sample($formattedName);
}
getDataItem
Gets a data item in a dataset by resource name. This API can be called after data are imported into dataset.
Parameters | |
---|---|
Name | Description |
name |
string
Required. The name of the data item to get, format: projects/{project_id}/datasets/{dataset_id}/dataItems/{data_item_id} |
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\DataLabeling\V1beta1\DataItem |
use Google\ApiCore\ApiException;
use Google\Cloud\DataLabeling\V1beta1\Client\DataLabelingServiceClient;
use Google\Cloud\DataLabeling\V1beta1\DataItem;
use Google\Cloud\DataLabeling\V1beta1\GetDataItemRequest;
/**
* @param string $formattedName The name of the data item to get, format:
* projects/{project_id}/datasets/{dataset_id}/dataItems/{data_item_id}
* Please see {@see DataLabelingServiceClient::dataItemName()} for help formatting this field.
*/
function get_data_item_sample(string $formattedName): void
{
// Create a client.
$dataLabelingServiceClient = new DataLabelingServiceClient();
// Prepare the request message.
$request = (new GetDataItemRequest())
->setName($formattedName);
// Call the API and handle any network failures.
try {
/** @var DataItem $response */
$response = $dataLabelingServiceClient->getDataItem($request);
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 = DataLabelingServiceClient::dataItemName('[PROJECT]', '[DATASET]', '[DATA_ITEM]');
get_data_item_sample($formattedName);
}
getDataset
Gets dataset by resource name.
Parameters | |
---|---|
Name | Description |
name |
string
Required. Dataset resource name, format: projects/{project_id}/datasets/{dataset_id} |
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\DataLabeling\V1beta1\Dataset |
use Google\ApiCore\ApiException;
use Google\Cloud\DataLabeling\V1beta1\Client\DataLabelingServiceClient;
use Google\Cloud\DataLabeling\V1beta1\Dataset;
use Google\Cloud\DataLabeling\V1beta1\GetDatasetRequest;
/**
* @param string $formattedName Dataset resource name, format:
* projects/{project_id}/datasets/{dataset_id}
* Please see {@see DataLabelingServiceClient::datasetName()} for help formatting this field.
*/
function get_dataset_sample(string $formattedName): void
{
// Create a client.
$dataLabelingServiceClient = new DataLabelingServiceClient();
// Prepare the request message.
$request = (new GetDatasetRequest())
->setName($formattedName);
// Call the API and handle any network failures.
try {
/** @var Dataset $response */
$response = $dataLabelingServiceClient->getDataset($request);
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 = DataLabelingServiceClient::datasetName('[PROJECT]', '[DATASET]');
get_dataset_sample($formattedName);
}
getEvaluation
Gets an evaluation by resource name (to search, use projects.evaluations.search).
Parameters | |
---|---|
Name | Description |
name |
string
Required. Name of the evaluation. Format: "projects/{project_id}/datasets/{dataset_id}/evaluations/{evaluation_id}' |
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\DataLabeling\V1beta1\Evaluation |
use Google\ApiCore\ApiException;
use Google\Cloud\DataLabeling\V1beta1\Client\DataLabelingServiceClient;
use Google\Cloud\DataLabeling\V1beta1\Evaluation;
use Google\Cloud\DataLabeling\V1beta1\GetEvaluationRequest;
/**
* @param string $formattedName Name of the evaluation. Format:
*
* "projects/<var>{project_id}</var>/datasets/<var>{dataset_id}</var>/evaluations/<var>{evaluation_id}</var>'
* Please see {@see DataLabelingServiceClient::evaluationName()} for help formatting this field.
*/
function get_evaluation_sample(string $formattedName): void
{
// Create a client.
$dataLabelingServiceClient = new DataLabelingServiceClient();
// Prepare the request message.
$request = (new GetEvaluationRequest())
->setName($formattedName);
// Call the API and handle any network failures.
try {
/** @var Evaluation $response */
$response = $dataLabelingServiceClient->getEvaluation($request);
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 = DataLabelingServiceClient::evaluationName(
'[PROJECT]',
'[DATASET]',
'[EVALUATION]'
);
get_evaluation_sample($formattedName);
}
getEvaluationJob
Gets an evaluation job by resource name.
Parameters | |
---|---|
Name | Description |
name |
string
Required. Name of the evaluation job. Format: "projects/{project_id}/evaluationJobs/{evaluation_job_id}" |
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\DataLabeling\V1beta1\EvaluationJob |
use Google\ApiCore\ApiException;
use Google\Cloud\DataLabeling\V1beta1\Client\DataLabelingServiceClient;
use Google\Cloud\DataLabeling\V1beta1\EvaluationJob;
use Google\Cloud\DataLabeling\V1beta1\GetEvaluationJobRequest;
/**
* @param string $formattedName Name of the evaluation job. Format:
*
* "projects/<var>{project_id}</var>/evaluationJobs/<var>{evaluation_job_id}</var>"
* Please see {@see DataLabelingServiceClient::evaluationJobName()} for help formatting this field.
*/
function get_evaluation_job_sample(string $formattedName): void
{
// Create a client.
$dataLabelingServiceClient = new DataLabelingServiceClient();
// Prepare the request message.
$request = (new GetEvaluationJobRequest())
->setName($formattedName);
// Call the API and handle any network failures.
try {
/** @var EvaluationJob $response */
$response = $dataLabelingServiceClient->getEvaluationJob($request);
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 = DataLabelingServiceClient::evaluationJobName('[PROJECT]', '[EVALUATION_JOB]');
get_evaluation_job_sample($formattedName);
}
getExample
Gets an example by resource name, including both data and annotation.
Parameters | |
---|---|
Name | Description |
name |
string
Required. Name of example, format: projects/{project_id}/datasets/{dataset_id}/annotatedDatasets/ {annotated_dataset_id}/examples/{example_id} |
optionalArgs |
array
Optional. |
↳ filter |
string
Optional. An expression for filtering Examples. Filter by annotation_spec.display_name is supported. Format "annotation_spec.display_name = {display_name}" |
↳ 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\DataLabeling\V1beta1\Example |
use Google\ApiCore\ApiException;
use Google\Cloud\DataLabeling\V1beta1\Client\DataLabelingServiceClient;
use Google\Cloud\DataLabeling\V1beta1\Example;
use Google\Cloud\DataLabeling\V1beta1\GetExampleRequest;
/**
* @param string $formattedName Name of example, format:
* projects/{project_id}/datasets/{dataset_id}/annotatedDatasets/
* {annotated_dataset_id}/examples/{example_id}
* Please see {@see DataLabelingServiceClient::exampleName()} for help formatting this field.
*/
function get_example_sample(string $formattedName): void
{
// Create a client.
$dataLabelingServiceClient = new DataLabelingServiceClient();
// Prepare the request message.
$request = (new GetExampleRequest())
->setName($formattedName);
// Call the API and handle any network failures.
try {
/** @var Example $response */
$response = $dataLabelingServiceClient->getExample($request);
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 = DataLabelingServiceClient::exampleName(
'[PROJECT]',
'[DATASET]',
'[ANNOTATED_DATASET]',
'[EXAMPLE]'
);
get_example_sample($formattedName);
}
getInstruction
Gets an instruction by resource name.
Parameters | |
---|---|
Name | Description |
name |
string
Required. Instruction resource name, format: projects/{project_id}/instructions/{instruction_id} |
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\DataLabeling\V1beta1\Instruction |
use Google\ApiCore\ApiException;
use Google\Cloud\DataLabeling\V1beta1\Client\DataLabelingServiceClient;
use Google\Cloud\DataLabeling\V1beta1\GetInstructionRequest;
use Google\Cloud\DataLabeling\V1beta1\Instruction;
/**
* @param string $formattedName Instruction resource name, format:
* projects/{project_id}/instructions/{instruction_id}
* Please see {@see DataLabelingServiceClient::instructionName()} for help formatting this field.
*/
function get_instruction_sample(string $formattedName): void
{
// Create a client.
$dataLabelingServiceClient = new DataLabelingServiceClient();
// Prepare the request message.
$request = (new GetInstructionRequest())
->setName($formattedName);
// Call the API and handle any network failures.
try {
/** @var Instruction $response */
$response = $dataLabelingServiceClient->getInstruction($request);
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 = DataLabelingServiceClient::instructionName('[PROJECT]', '[INSTRUCTION]');
get_instruction_sample($formattedName);
}
importData
Imports data into dataset based on source locations defined in request.
It can be called multiple times for the same dataset. Each dataset can only have one long running operation running on it. For example, no labeling task (also long running operation) can be started while importing is still ongoing. Vice versa.
Parameters | |
---|---|
Name | Description |
name |
string
Required. Dataset resource name, format: projects/{project_id}/datasets/{dataset_id} |
inputConfig |
Google\Cloud\DataLabeling\V1beta1\InputConfig
Required. Specify the input source of the data. |
optionalArgs |
array
Optional. |
↳ userEmailAddress |
string
Email of the user who started the import task and should be notified by email. If empty no notification will be sent. |
↳ 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\DataLabeling\V1beta1\Client\DataLabelingServiceClient;
use Google\Cloud\DataLabeling\V1beta1\ImportDataOperationResponse;
use Google\Cloud\DataLabeling\V1beta1\ImportDataRequest;
use Google\Cloud\DataLabeling\V1beta1\InputConfig;
use Google\Rpc\Status;
/**
* @param string $formattedName Dataset resource name, format:
* projects/{project_id}/datasets/{dataset_id}
* Please see {@see DataLabelingServiceClient::datasetName()} for help formatting this field.
*/
function import_data_sample(string $formattedName): void
{
// Create a client.
$dataLabelingServiceClient = new DataLabelingServiceClient();
// Prepare the request message.
$inputConfig = new InputConfig();
$request = (new ImportDataRequest())
->setName($formattedName)
->setInputConfig($inputConfig);
// Call the API and handle any network failures.
try {
/** @var OperationResponse $response */
$response = $dataLabelingServiceClient->importData($request);
$response->pollUntilComplete();
if ($response->operationSucceeded()) {
/** @var ImportDataOperationResponse $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
{
$formattedName = DataLabelingServiceClient::datasetName('[PROJECT]', '[DATASET]');
import_data_sample($formattedName);
}
labelImage
Starts a labeling task for image. The type of image labeling task is configured by feature in the request.
Parameters | |
---|---|
Name | Description |
parent |
string
Required. Name of the dataset to request labeling task, format: projects/{project_id}/datasets/{dataset_id} |
basicConfig |
Google\Cloud\DataLabeling\V1beta1\HumanAnnotationConfig
Required. Basic human annotation config. |
feature |
int
Required. The type of image labeling task. For allowed values, use constants defined on Google\Cloud\DataLabeling\V1beta1\LabelImageRequest\Feature |
optionalArgs |
array
Optional. |
↳ imageClassificationConfig |
ImageClassificationConfig
Configuration for image classification task. One of image_classification_config, bounding_poly_config, polyline_config and segmentation_config are required. |
↳ boundingPolyConfig |
BoundingPolyConfig
Configuration for bounding box and bounding poly task. One of image_classification_config, bounding_poly_config, polyline_config and segmentation_config are required. |
↳ polylineConfig |
PolylineConfig
Configuration for polyline task. One of image_classification_config, bounding_poly_config, polyline_config and segmentation_config are required. |
↳ segmentationConfig |
SegmentationConfig
Configuration for segmentation task. One of image_classification_config, bounding_poly_config, polyline_config and segmentation_config are required. |
↳ 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\DataLabeling\V1beta1\AnnotatedDataset;
use Google\Cloud\DataLabeling\V1beta1\Client\DataLabelingServiceClient;
use Google\Cloud\DataLabeling\V1beta1\HumanAnnotationConfig;
use Google\Cloud\DataLabeling\V1beta1\LabelImageRequest;
use Google\Cloud\DataLabeling\V1beta1\LabelImageRequest\Feature;
use Google\Rpc\Status;
/**
* @param string $formattedParent Name of the dataset to request labeling task, format:
* projects/{project_id}/datasets/{dataset_id}
* Please see {@see DataLabelingServiceClient::datasetName()} for help formatting this field.
* @param string $basicConfigInstruction Instruction resource name.
* @param string $basicConfigAnnotatedDatasetDisplayName A human-readable name for AnnotatedDataset defined by
* users. Maximum of 64 characters
* .
* @param int $feature The type of image labeling task.
*/
function label_image_sample(
string $formattedParent,
string $basicConfigInstruction,
string $basicConfigAnnotatedDatasetDisplayName,
int $feature
): void {
// Create a client.
$dataLabelingServiceClient = new DataLabelingServiceClient();
// Prepare the request message.
$basicConfig = (new HumanAnnotationConfig())
->setInstruction($basicConfigInstruction)
->setAnnotatedDatasetDisplayName($basicConfigAnnotatedDatasetDisplayName);
$request = (new LabelImageRequest())
->setParent($formattedParent)
->setBasicConfig($basicConfig)
->setFeature($feature);
// Call the API and handle any network failures.
try {
/** @var OperationResponse $response */
$response = $dataLabelingServiceClient->labelImage($request);
$response->pollUntilComplete();
if ($response->operationSucceeded()) {
/** @var AnnotatedDataset $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 = DataLabelingServiceClient::datasetName('[PROJECT]', '[DATASET]');
$basicConfigInstruction = '[INSTRUCTION]';
$basicConfigAnnotatedDatasetDisplayName = '[ANNOTATED_DATASET_DISPLAY_NAME]';
$feature = Feature::FEATURE_UNSPECIFIED;
label_image_sample(
$formattedParent,
$basicConfigInstruction,
$basicConfigAnnotatedDatasetDisplayName,
$feature
);
}
labelText
Starts a labeling task for text. The type of text labeling task is configured by feature in the request.
Parameters | |
---|---|
Name | Description |
parent |
string
Required. Name of the data set to request labeling task, format: projects/{project_id}/datasets/{dataset_id} |
basicConfig |
Google\Cloud\DataLabeling\V1beta1\HumanAnnotationConfig
Required. Basic human annotation config. |
feature |
int
Required. The type of text labeling task. For allowed values, use constants defined on Google\Cloud\DataLabeling\V1beta1\LabelTextRequest\Feature |
optionalArgs |
array
Optional. |
↳ textClassificationConfig |
TextClassificationConfig
Configuration for text classification task. One of text_classification_config and text_entity_extraction_config is required. |
↳ textEntityExtractionConfig |
TextEntityExtractionConfig
Configuration for entity extraction task. One of text_classification_config and text_entity_extraction_config is required. |
↳ 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\DataLabeling\V1beta1\AnnotatedDataset;
use Google\Cloud\DataLabeling\V1beta1\Client\DataLabelingServiceClient;
use Google\Cloud\DataLabeling\V1beta1\HumanAnnotationConfig;
use Google\Cloud\DataLabeling\V1beta1\LabelTextRequest;
use Google\Cloud\DataLabeling\V1beta1\LabelTextRequest\Feature;
use Google\Rpc\Status;
/**
* @param string $formattedParent Name of the data set to request labeling task, format:
* projects/{project_id}/datasets/{dataset_id}
* Please see {@see DataLabelingServiceClient::datasetName()} for help formatting this field.
* @param string $basicConfigInstruction Instruction resource name.
* @param string $basicConfigAnnotatedDatasetDisplayName A human-readable name for AnnotatedDataset defined by
* users. Maximum of 64 characters
* .
* @param int $feature The type of text labeling task.
*/
function label_text_sample(
string $formattedParent,
string $basicConfigInstruction,
string $basicConfigAnnotatedDatasetDisplayName,
int $feature
): void {
// Create a client.
$dataLabelingServiceClient = new DataLabelingServiceClient();
// Prepare the request message.
$basicConfig = (new HumanAnnotationConfig())
->setInstruction($basicConfigInstruction)
->setAnnotatedDatasetDisplayName($basicConfigAnnotatedDatasetDisplayName);
$request = (new LabelTextRequest())
->setParent($formattedParent)
->setBasicConfig($basicConfig)
->setFeature($feature);
// Call the API and handle any network failures.
try {
/** @var OperationResponse $response */
$response = $dataLabelingServiceClient->labelText($request);
$response->pollUntilComplete();
if ($response->operationSucceeded()) {
/** @var AnnotatedDataset $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 = DataLabelingServiceClient::datasetName('[PROJECT]', '[DATASET]');
$basicConfigInstruction = '[INSTRUCTION]';
$basicConfigAnnotatedDatasetDisplayName = '[ANNOTATED_DATASET_DISPLAY_NAME]';
$feature = Feature::FEATURE_UNSPECIFIED;
label_text_sample(
$formattedParent,
$basicConfigInstruction,
$basicConfigAnnotatedDatasetDisplayName,
$feature
);
}
labelVideo
Starts a labeling task for video. The type of video labeling task is configured by feature in the request.
Parameters | |
---|---|
Name | Description |
parent |
string
Required. Name of the dataset to request labeling task, format: projects/{project_id}/datasets/{dataset_id} |
basicConfig |
Google\Cloud\DataLabeling\V1beta1\HumanAnnotationConfig
Required. Basic human annotation config. |
feature |
int
Required. The type of video labeling task. For allowed values, use constants defined on Google\Cloud\DataLabeling\V1beta1\LabelVideoRequest\Feature |
optionalArgs |
array
Optional. |
↳ videoClassificationConfig |
VideoClassificationConfig
Configuration for video classification task. One of video_classification_config, object_detection_config, object_tracking_config and event_config is required. |
↳ objectDetectionConfig |
ObjectDetectionConfig
Configuration for video object detection task. One of video_classification_config, object_detection_config, object_tracking_config and event_config is required. |
↳ objectTrackingConfig |
ObjectTrackingConfig
Configuration for video object tracking task. One of video_classification_config, object_detection_config, object_tracking_config and event_config is required. |
↳ eventConfig |
EventConfig
Configuration for video event task. One of video_classification_config, object_detection_config, object_tracking_config and event_config is required. |
↳ 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\DataLabeling\V1beta1\AnnotatedDataset;
use Google\Cloud\DataLabeling\V1beta1\Client\DataLabelingServiceClient;
use Google\Cloud\DataLabeling\V1beta1\HumanAnnotationConfig;
use Google\Cloud\DataLabeling\V1beta1\LabelVideoRequest;
use Google\Cloud\DataLabeling\V1beta1\LabelVideoRequest\Feature;
use Google\Rpc\Status;
/**
* @param string $formattedParent Name of the dataset to request labeling task, format:
* projects/{project_id}/datasets/{dataset_id}
* Please see {@see DataLabelingServiceClient::datasetName()} for help formatting this field.
* @param string $basicConfigInstruction Instruction resource name.
* @param string $basicConfigAnnotatedDatasetDisplayName A human-readable name for AnnotatedDataset defined by
* users. Maximum of 64 characters
* .
* @param int $feature The type of video labeling task.
*/
function label_video_sample(
string $formattedParent,
string $basicConfigInstruction,
string $basicConfigAnnotatedDatasetDisplayName,
int $feature
): void {
// Create a client.
$dataLabelingServiceClient = new DataLabelingServiceClient();
// Prepare the request message.
$basicConfig = (new HumanAnnotationConfig())
->setInstruction($basicConfigInstruction)
->setAnnotatedDatasetDisplayName($basicConfigAnnotatedDatasetDisplayName);
$request = (new LabelVideoRequest())
->setParent($formattedParent)
->setBasicConfig($basicConfig)
->setFeature($feature);
// Call the API and handle any network failures.
try {
/** @var OperationResponse $response */
$response = $dataLabelingServiceClient->labelVideo($request);
$response->pollUntilComplete();
if ($response->operationSucceeded()) {
/** @var AnnotatedDataset $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 = DataLabelingServiceClient::datasetName('[PROJECT]', '[DATASET]');
$basicConfigInstruction = '[INSTRUCTION]';
$basicConfigAnnotatedDatasetDisplayName = '[ANNOTATED_DATASET_DISPLAY_NAME]';
$feature = Feature::FEATURE_UNSPECIFIED;
label_video_sample(
$formattedParent,
$basicConfigInstruction,
$basicConfigAnnotatedDatasetDisplayName,
$feature
);
}
listAnnotatedDatasets
Lists annotated datasets for a dataset. Pagination is supported.
Parameters | |
---|---|
Name | Description |
parent |
string
Required. Name of the dataset to list annotated datasets, format: projects/{project_id}/datasets/{dataset_id} |
optionalArgs |
array
Optional. |
↳ filter |
string
Optional. Filter is not supported at this moment. |
↳ 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\DataLabeling\V1beta1\AnnotatedDataset;
use Google\Cloud\DataLabeling\V1beta1\Client\DataLabelingServiceClient;
use Google\Cloud\DataLabeling\V1beta1\ListAnnotatedDatasetsRequest;
/**
* @param string $formattedParent Name of the dataset to list annotated datasets, format:
* projects/{project_id}/datasets/{dataset_id}
* Please see {@see DataLabelingServiceClient::datasetName()} for help formatting this field.
*/
function list_annotated_datasets_sample(string $formattedParent): void
{
// Create a client.
$dataLabelingServiceClient = new DataLabelingServiceClient();
// Prepare the request message.
$request = (new ListAnnotatedDatasetsRequest())
->setParent($formattedParent);
// Call the API and handle any network failures.
try {
/** @var PagedListResponse $response */
$response = $dataLabelingServiceClient->listAnnotatedDatasets($request);
/** @var AnnotatedDataset $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 = DataLabelingServiceClient::datasetName('[PROJECT]', '[DATASET]');
list_annotated_datasets_sample($formattedParent);
}
listAnnotationSpecSets
Lists annotation spec sets for a project. Pagination is supported.
Parameters | |
---|---|
Name | Description |
parent |
string
Required. Parent of AnnotationSpecSet resource, format: projects/{project_id} |
optionalArgs |
array
Optional. |
↳ filter |
string
Optional. Filter is not supported at this moment. |
↳ 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\DataLabeling\V1beta1\AnnotationSpecSet;
use Google\Cloud\DataLabeling\V1beta1\Client\DataLabelingServiceClient;
use Google\Cloud\DataLabeling\V1beta1\ListAnnotationSpecSetsRequest;
/**
* @param string $formattedParent Parent of AnnotationSpecSet resource, format:
* projects/{project_id}
* Please see {@see DataLabelingServiceClient::projectName()} for help formatting this field.
*/
function list_annotation_spec_sets_sample(string $formattedParent): void
{
// Create a client.
$dataLabelingServiceClient = new DataLabelingServiceClient();
// Prepare the request message.
$request = (new ListAnnotationSpecSetsRequest())
->setParent($formattedParent);
// Call the API and handle any network failures.
try {
/** @var PagedListResponse $response */
$response = $dataLabelingServiceClient->listAnnotationSpecSets($request);
/** @var AnnotationSpecSet $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 = DataLabelingServiceClient::projectName('[PROJECT]');
list_annotation_spec_sets_sample($formattedParent);
}
listDataItems
Lists data items in a dataset. This API can be called after data are imported into dataset. Pagination is supported.
Parameters | |
---|---|
Name | Description |
parent |
string
Required. Name of the dataset to list data items, format: projects/{project_id}/datasets/{dataset_id} |
optionalArgs |
array
Optional. |
↳ filter |
string
Optional. Filter is not supported at this moment. |
↳ 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\DataLabeling\V1beta1\Client\DataLabelingServiceClient;
use Google\Cloud\DataLabeling\V1beta1\DataItem;
use Google\Cloud\DataLabeling\V1beta1\ListDataItemsRequest;
/**
* @param string $formattedParent Name of the dataset to list data items, format:
* projects/{project_id}/datasets/{dataset_id}
* Please see {@see DataLabelingServiceClient::datasetName()} for help formatting this field.
*/
function list_data_items_sample(string $formattedParent): void
{
// Create a client.
$dataLabelingServiceClient = new DataLabelingServiceClient();
// Prepare the request message.
$request = (new ListDataItemsRequest())
->setParent($formattedParent);
// Call the API and handle any network failures.
try {
/** @var PagedListResponse $response */
$response = $dataLabelingServiceClient->listDataItems($request);
/** @var DataItem $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 = DataLabelingServiceClient::datasetName('[PROJECT]', '[DATASET]');
list_data_items_sample($formattedParent);
}
listDatasets
Lists datasets under a project. Pagination is supported.
Parameters | |
---|---|
Name | Description |
parent |
string
Required. Dataset resource parent, format: projects/{project_id} |
optionalArgs |
array
Optional. |
↳ filter |
string
Optional. Filter on dataset is not supported at this moment. |
↳ 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\DataLabeling\V1beta1\Client\DataLabelingServiceClient;
use Google\Cloud\DataLabeling\V1beta1\Dataset;
use Google\Cloud\DataLabeling\V1beta1\ListDatasetsRequest;
/**
* @param string $formattedParent Dataset resource parent, format:
* projects/{project_id}
* Please see {@see DataLabelingServiceClient::projectName()} for help formatting this field.
*/
function list_datasets_sample(string $formattedParent): void
{
// Create a client.
$dataLabelingServiceClient = new DataLabelingServiceClient();
// Prepare the request message.
$request = (new ListDatasetsRequest())
->setParent($formattedParent);
// Call the API and handle any network failures.
try {
/** @var PagedListResponse $response */
$response = $dataLabelingServiceClient->listDatasets($request);
/** @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 = DataLabelingServiceClient::projectName('[PROJECT]');
list_datasets_sample($formattedParent);
}
listEvaluationJobs
Lists all evaluation jobs within a project with possible filters.
Pagination is supported.
Parameters | |
---|---|
Name | Description |
parent |
string
Required. Evaluation job resource parent. Format: "projects/{project_id}" |
optionalArgs |
array
Optional. |
↳ filter |
string
Optional. You can filter the jobs to list by model_id (also known as model_name, as described in EvaluationJob.modelVersion) or by evaluation job state (as described in EvaluationJob.state). To filter by both criteria, use the |
↳ 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\DataLabeling\V1beta1\Client\DataLabelingServiceClient;
use Google\Cloud\DataLabeling\V1beta1\EvaluationJob;
use Google\Cloud\DataLabeling\V1beta1\ListEvaluationJobsRequest;
/**
* @param string $formattedParent Evaluation job resource parent. Format:
* "projects/<var>{project_id}</var>"
* Please see {@see DataLabelingServiceClient::projectName()} for help formatting this field.
*/
function list_evaluation_jobs_sample(string $formattedParent): void
{
// Create a client.
$dataLabelingServiceClient = new DataLabelingServiceClient();
// Prepare the request message.
$request = (new ListEvaluationJobsRequest())
->setParent($formattedParent);
// Call the API and handle any network failures.
try {
/** @var PagedListResponse $response */
$response = $dataLabelingServiceClient->listEvaluationJobs($request);
/** @var EvaluationJob $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 = DataLabelingServiceClient::projectName('[PROJECT]');
list_evaluation_jobs_sample($formattedParent);
}
listExamples
Lists examples in an annotated dataset. Pagination is supported.
Parameters | |
---|---|
Name | Description |
parent |
string
Required. Example resource parent. |
optionalArgs |
array
Optional. |
↳ filter |
string
Optional. An expression for filtering Examples. For annotated datasets that have annotation spec set, filter by annotation_spec.display_name is supported. Format "annotation_spec.display_name = {display_name}" |
↳ 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\DataLabeling\V1beta1\Client\DataLabelingServiceClient;
use Google\Cloud\DataLabeling\V1beta1\Example;
use Google\Cloud\DataLabeling\V1beta1\ListExamplesRequest;
/**
* @param string $formattedParent Example resource parent. Please see
* {@see DataLabelingServiceClient::annotatedDatasetName()} for help formatting this field.
*/
function list_examples_sample(string $formattedParent): void
{
// Create a client.
$dataLabelingServiceClient = new DataLabelingServiceClient();
// Prepare the request message.
$request = (new ListExamplesRequest())
->setParent($formattedParent);
// Call the API and handle any network failures.
try {
/** @var PagedListResponse $response */
$response = $dataLabelingServiceClient->listExamples($request);
/** @var Example $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 = DataLabelingServiceClient::annotatedDatasetName(
'[PROJECT]',
'[DATASET]',
'[ANNOTATED_DATASET]'
);
list_examples_sample($formattedParent);
}
listInstructions
Lists instructions for a project. Pagination is supported.
Parameters | |
---|---|
Name | Description |
parent |
string
Required. Instruction resource parent, format: projects/{project_id} |
optionalArgs |
array
Optional. |
↳ filter |
string
Optional. Filter is not supported at this moment. |
↳ 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\DataLabeling\V1beta1\Client\DataLabelingServiceClient;
use Google\Cloud\DataLabeling\V1beta1\Instruction;
use Google\Cloud\DataLabeling\V1beta1\ListInstructionsRequest;
/**
* @param string $formattedParent Instruction resource parent, format:
* projects/{project_id}
* Please see {@see DataLabelingServiceClient::projectName()} for help formatting this field.
*/
function list_instructions_sample(string $formattedParent): void
{
// Create a client.
$dataLabelingServiceClient = new DataLabelingServiceClient();
// Prepare the request message.
$request = (new ListInstructionsRequest())
->setParent($formattedParent);
// Call the API and handle any network failures.
try {
/** @var PagedListResponse $response */
$response = $dataLabelingServiceClient->listInstructions($request);
/** @var Instruction $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 = DataLabelingServiceClient::projectName('[PROJECT]');
list_instructions_sample($formattedParent);
}
pauseEvaluationJob
Pauses an evaluation job. Pausing an evaluation job that is already in a
PAUSED
state is a no-op.
Parameters | |
---|---|
Name | Description |
name |
string
Required. Name of the evaluation job that is going to be paused. Format: "projects/{project_id}/evaluationJobs/{evaluation_job_id}" |
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. |
use Google\ApiCore\ApiException;
use Google\Cloud\DataLabeling\V1beta1\Client\DataLabelingServiceClient;
use Google\Cloud\DataLabeling\V1beta1\PauseEvaluationJobRequest;
/**
* @param string $formattedName Name of the evaluation job that is going to be paused. Format:
*
* "projects/<var>{project_id}</var>/evaluationJobs/<var>{evaluation_job_id}</var>"
* Please see {@see DataLabelingServiceClient::evaluationJobName()} for help formatting this field.
*/
function pause_evaluation_job_sample(string $formattedName): void
{
// Create a client.
$dataLabelingServiceClient = new DataLabelingServiceClient();
// Prepare the request message.
$request = (new PauseEvaluationJobRequest())
->setName($formattedName);
// Call the API and handle any network failures.
try {
$dataLabelingServiceClient->pauseEvaluationJob($request);
printf('Call completed successfully.' . PHP_EOL);
} 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 = DataLabelingServiceClient::evaluationJobName('[PROJECT]', '[EVALUATION_JOB]');
pause_evaluation_job_sample($formattedName);
}
resumeEvaluationJob
Resumes a paused evaluation job. A deleted evaluation job can't be resumed.
Resuming a running or scheduled evaluation job is a no-op.
Parameters | |
---|---|
Name | Description |
name |
string
Required. Name of the evaluation job that is going to be resumed. Format: "projects/{project_id}/evaluationJobs/{evaluation_job_id}" |
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. |
use Google\ApiCore\ApiException;
use Google\Cloud\DataLabeling\V1beta1\Client\DataLabelingServiceClient;
use Google\Cloud\DataLabeling\V1beta1\ResumeEvaluationJobRequest;
/**
* @param string $formattedName Name of the evaluation job that is going to be resumed. Format:
*
* "projects/<var>{project_id}</var>/evaluationJobs/<var>{evaluation_job_id}</var>"
* Please see {@see DataLabelingServiceClient::evaluationJobName()} for help formatting this field.
*/
function resume_evaluation_job_sample(string $formattedName): void
{
// Create a client.
$dataLabelingServiceClient = new DataLabelingServiceClient();
// Prepare the request message.
$request = (new ResumeEvaluationJobRequest())
->setName($formattedName);
// Call the API and handle any network failures.
try {
$dataLabelingServiceClient->resumeEvaluationJob($request);
printf('Call completed successfully.' . PHP_EOL);
} 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 = DataLabelingServiceClient::evaluationJobName('[PROJECT]', '[EVALUATION_JOB]');
resume_evaluation_job_sample($formattedName);
}
searchEvaluations
Searches evaluations within a project.
Parameters | |
---|---|
Name | Description |
parent |
string
Required. Evaluation search parent (project ID). Format: "projects/{project_id}" |
optionalArgs |
array
Optional. |
↳ filter |
string
Optional. To search evaluations, you can filter by the following: * evaluationjob.evaluation_job_id (the last part of EvaluationJob.name) * evaluationjob.model_id (the {model_name} portion of EvaluationJob.modelVersion) * evaluationjob.evaluation_job_run_time_start (Minimum threshold for the evaluationJobRunTime that created the evaluation) * evaluationjob.evaluation_job_run_time_end (Maximum threshold for the evaluationJobRunTime that created the evaluation) * evaluationjob.job_state (EvaluationJob.state) * annotationspec.display_name (the Evaluation contains a metric for the annotation spec with this displayName) To filter by multiple critiera, use the |
↳ 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\DataLabeling\V1beta1\Client\DataLabelingServiceClient;
use Google\Cloud\DataLabeling\V1beta1\Evaluation;
use Google\Cloud\DataLabeling\V1beta1\SearchEvaluationsRequest;
/**
* @param string $formattedParent Evaluation search parent (project ID). Format:
* "projects/<var>{project_id}</var>"
* Please see {@see DataLabelingServiceClient::evaluationName()} for help formatting this field.
*/
function search_evaluations_sample(string $formattedParent): void
{
// Create a client.
$dataLabelingServiceClient = new DataLabelingServiceClient();
// Prepare the request message.
$request = (new SearchEvaluationsRequest())
->setParent($formattedParent);
// Call the API and handle any network failures.
try {
/** @var PagedListResponse $response */
$response = $dataLabelingServiceClient->searchEvaluations($request);
/** @var Evaluation $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 = DataLabelingServiceClient::evaluationName(
'[PROJECT]',
'[DATASET]',
'[EVALUATION]'
);
search_evaluations_sample($formattedParent);
}
searchExampleComparisons
Searches example comparisons from an evaluation. The return format is a list of example comparisons that show ground truth and prediction(s) for a single input. Search by providing an evaluation ID.
Parameters | |
---|---|
Name | Description |
parent |
string
Required. Name of the Evaluation resource to search for example comparisons from. Format: "projects/{project_id}/datasets/{dataset_id}/evaluations/{evaluation_id}" |
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\DataLabeling\V1beta1\Client\DataLabelingServiceClient;
use Google\Cloud\DataLabeling\V1beta1\SearchExampleComparisonsRequest;
use Google\Cloud\DataLabeling\V1beta1\SearchExampleComparisonsResponse\ExampleComparison;
/**
* @param string $formattedParent Name of the [Evaluation][google.cloud.datalabeling.v1beta1.Evaluation] resource to search for example
* comparisons from. Format:
*
* "projects/<var>{project_id}</var>/datasets/<var>{dataset_id}</var>/evaluations/<var>{evaluation_id}</var>"
* Please see {@see DataLabelingServiceClient::evaluationName()} for help formatting this field.
*/
function search_example_comparisons_sample(string $formattedParent): void
{
// Create a client.
$dataLabelingServiceClient = new DataLabelingServiceClient();
// Prepare the request message.
$request = (new SearchExampleComparisonsRequest())
->setParent($formattedParent);
// Call the API and handle any network failures.
try {
/** @var PagedListResponse $response */
$response = $dataLabelingServiceClient->searchExampleComparisons($request);
/** @var ExampleComparison $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 = DataLabelingServiceClient::evaluationName(
'[PROJECT]',
'[DATASET]',
'[EVALUATION]'
);
search_example_comparisons_sample($formattedParent);
}
updateEvaluationJob
Updates an evaluation job. You can only update certain fields of the job's
EvaluationJobConfig: humanAnnotationConfig.instruction
,
exampleCount
, and exampleSamplePercentage
.
If you want to change any other aspect of the evaluation job, you must delete the job and create a new one.
Parameters | |
---|---|
Name | Description |
evaluationJob |
Google\Cloud\DataLabeling\V1beta1\EvaluationJob
Required. Evaluation job that is going to be updated. |
optionalArgs |
array
Optional. |
↳ updateMask |
FieldMask
Optional. Mask for which fields to update. You can only provide the following fields: * |
↳ 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\DataLabeling\V1beta1\EvaluationJob |
use Google\ApiCore\ApiException;
use Google\Cloud\DataLabeling\V1beta1\Client\DataLabelingServiceClient;
use Google\Cloud\DataLabeling\V1beta1\EvaluationJob;
use Google\Cloud\DataLabeling\V1beta1\UpdateEvaluationJobRequest;
/**
* 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_evaluation_job_sample(): void
{
// Create a client.
$dataLabelingServiceClient = new DataLabelingServiceClient();
// Prepare the request message.
$evaluationJob = new EvaluationJob();
$request = (new UpdateEvaluationJobRequest())
->setEvaluationJob($evaluationJob);
// Call the API and handle any network failures.
try {
/** @var EvaluationJob $response */
$response = $dataLabelingServiceClient->updateEvaluationJob($request);
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::annotatedDatasetName
Formats a string containing the fully-qualified path to represent a annotated_dataset resource.
Parameters | |
---|---|
Name | Description |
project |
string
|
dataset |
string
|
annotatedDataset |
string
|
Returns | |
---|---|
Type | Description |
string |
The formatted annotated_dataset resource. |
static::annotationSpecSetName
Formats a string containing the fully-qualified path to represent a annotation_spec_set resource.
Parameters | |
---|---|
Name | Description |
project |
string
|
annotationSpecSet |
string
|
Returns | |
---|---|
Type | Description |
string |
The formatted annotation_spec_set resource. |
static::dataItemName
Formats a string containing the fully-qualified path to represent a data_item resource.
Parameters | |
---|---|
Name | Description |
project |
string
|
dataset |
string
|
dataItem |
string
|
Returns | |
---|---|
Type | Description |
string |
The formatted data_item resource. |
static::datasetName
Formats a string containing the fully-qualified path to represent a dataset resource.
Parameters | |
---|---|
Name | Description |
project |
string
|
dataset |
string
|
Returns | |
---|---|
Type | Description |
string |
The formatted dataset resource. |
static::evaluationName
Formats a string containing the fully-qualified path to represent a evaluation resource.
Parameters | |
---|---|
Name | Description |
project |
string
|
dataset |
string
|
evaluation |
string
|
Returns | |
---|---|
Type | Description |
string |
The formatted evaluation resource. |
static::evaluationJobName
Formats a string containing the fully-qualified path to represent a evaluation_job resource.
Parameters | |
---|---|
Name | Description |
project |
string
|
evaluationJob |
string
|
Returns | |
---|---|
Type | Description |
string |
The formatted evaluation_job resource. |
static::exampleName
Formats a string containing the fully-qualified path to represent a example resource.
Parameters | |
---|---|
Name | Description |
project |
string
|
dataset |
string
|
annotatedDataset |
string
|
example |
string
|
Returns | |
---|---|
Type | Description |
string |
The formatted example resource. |
static::instructionName
Formats a string containing the fully-qualified path to represent a instruction resource.
Parameters | |
---|---|
Name | Description |
project |
string
|
instruction |
string
|
Returns | |
---|---|
Type | Description |
string |
The formatted instruction resource. |
static::projectName
Formats a string containing the fully-qualified path to represent a project resource.
Parameter | |
---|---|
Name | Description |
project |
string
|
Returns | |
---|---|
Type | Description |
string |
The formatted project 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
- annotatedDataset: projects/{project}/datasets/{dataset}/annotatedDatasets/{annotated_dataset}
- annotationSpecSet: projects/{project}/annotationSpecSets/{annotation_spec_set}
- dataItem: projects/{project}/datasets/{dataset}/dataItems/{data_item}
- dataset: projects/{project}/datasets/{dataset}
- evaluation: projects/{project}/datasets/{dataset}/evaluations/{evaluation}
- evaluationJob: projects/{project}/evaluationJobs/{evaluation_job}
- example: projects/{project}/datasets/{dataset}/annotatedDatasets/{annotated_dataset}/examples/{example}
- instruction: projects/{project}/instructions/{instruction}
- project: projects/{project}
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.datalabeling.v1beta1.DataLabelingService'
The name of the service.
SERVICE_ADDRESS
Value: 'datalabeling.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.