Cloud AutoML API v1 - Package cloud.google.com/go/automl/apiv1 (v0.80.0)

Package automl is an auto-generated package for the Cloud AutoML API.

Train high-quality custom machine learning models with minimum effort and machine learning expertise.

Use of Context

The ctx passed to NewClient is used for authentication requests and for creating the underlying connection, but is not used for subsequent calls. Individual methods on the client use the ctx given to them.

To close the open connection, use the Close() method.

For information about setting deadlines, reusing contexts, and more please visit pkg.go.dev/cloud.google.com/go.

Functions

func DefaultAuthScopes

func DefaultAuthScopes() []string

DefaultAuthScopes reports the default set of authentication scopes to use with this package.

BatchPredictOperation

type BatchPredictOperation struct {
	// contains filtered or unexported fields
}

BatchPredictOperation manages a long-running operation from BatchPredict.

func (*BatchPredictOperation) Done

func (op *BatchPredictOperation) Done() bool

Done reports whether the long-running operation has completed.

func (*BatchPredictOperation) Metadata

Metadata returns metadata associated with the long-running operation. Metadata itself does not contact the server, but Poll does. To get the latest metadata, call this method after a successful call to Poll. If the metadata is not available, the returned metadata and error are both nil.

func (*BatchPredictOperation) Name

func (op *BatchPredictOperation) Name() string

Name returns the name of the long-running operation. The name is assigned by the server and is unique within the service from which the operation is created.

func (*BatchPredictOperation) Poll

Poll fetches the latest state of the long-running operation.

Poll also fetches the latest metadata, which can be retrieved by Metadata.

If Poll fails, the error is returned and op is unmodified. If Poll succeeds and the operation has completed with failure, the error is returned and op.Done will return true. If Poll succeeds and the operation has completed successfully, op.Done will return true, and the response of the operation is returned. If Poll succeeds and the operation has not completed, the returned response and error are both nil.

func (*BatchPredictOperation) Wait

Wait blocks until the long-running operation is completed, returning the response and any errors encountered.

See documentation of Poll for error-handling information.

CallOptions

type CallOptions struct {
	CreateDataset        []gax.CallOption
	GetDataset           []gax.CallOption
	ListDatasets         []gax.CallOption
	UpdateDataset        []gax.CallOption
	DeleteDataset        []gax.CallOption
	ImportData           []gax.CallOption
	ExportData           []gax.CallOption
	GetAnnotationSpec    []gax.CallOption
	CreateModel          []gax.CallOption
	GetModel             []gax.CallOption
	ListModels           []gax.CallOption
	DeleteModel          []gax.CallOption
	UpdateModel          []gax.CallOption
	DeployModel          []gax.CallOption
	UndeployModel        []gax.CallOption
	ExportModel          []gax.CallOption
	GetModelEvaluation   []gax.CallOption
	ListModelEvaluations []gax.CallOption
}

CallOptions contains the retry settings for each method of Client.

Client

type Client struct {

	// LROClient is used internally to handle longrunning operations.
	// It is exposed so that its CallOptions can be modified if required.
	// Users should not Close this client.
	LROClient *lroauto.OperationsClient

	// The call options for this service.
	CallOptions *CallOptions
	// contains filtered or unexported fields
}

Client is a client for interacting with Cloud AutoML API.

Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.

func NewClient

func NewClient(ctx context.Context, opts ...option.ClientOption) (*Client, error)

NewClient creates a new auto ml client.

AutoML Server API.

The resource names are assigned by the server. The server never reuses names that it has created after the resources with those names are deleted.

An ID of a resource is the last element of the item’s resource name. For projects/{project_id}/locations/{location_id}/datasets/{dataset_id}, then the id for the item is {dataset_id}.

Currently the only supported location_id is “us-central1”.

On any input that is documented to expect a string parameter in snake_case or kebab-case, either of those cases is accepted.

Example

package main

import (
	"context"

	automl "cloud.google.com/go/automl/apiv1"
)

func main() {
	ctx := context.Background()
	c, err := automl.NewClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}
	// TODO: Use client.
	_ = c
}

func (*Client) Close

func (c *Client) Close() error

Close closes the connection to the API service. The user should invoke this when the client is no longer required.

func (*Client) Connection

func (c *Client) Connection() *grpc.ClientConn

Connection returns a connection to the API service.

Deprecated.

func (*Client) CreateDataset

CreateDataset creates a dataset.

Example

package main

import (
	"context"

	automl "cloud.google.com/go/automl/apiv1"

	automlpb "google.golang.org/genproto/googleapis/cloud/automl/v1"
)

func main() {
	// import automlpb "google.golang.org/genproto/googleapis/cloud/automl/v1"

	ctx := context.Background()
	c, err := automl.NewClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}

	req := &automlpb.CreateDatasetRequest{
		// TODO: Fill request struct fields.
	}
	op, err := c.CreateDataset(ctx, req)
	if err != nil {
		// TODO: Handle error.
	}

	resp, err := op.Wait(ctx)
	if err != nil {
		// TODO: Handle error.
	}
	// TODO: Use resp.
	_ = resp
}

func (*Client) CreateDatasetOperation

func (c *Client) CreateDatasetOperation(name string) *CreateDatasetOperation

CreateDatasetOperation returns a new CreateDatasetOperation from a given name. The name must be that of a previously created CreateDatasetOperation, possibly from a different process.

func (*Client) CreateModel

func (c *Client) CreateModel(ctx context.Context, req *automlpb.CreateModelRequest, opts ...gax.CallOption) (*CreateModelOperation, error)

CreateModel creates a model. Returns a Model in the response field when it completes. When you create a model, several model evaluations are created for it: a global evaluation, and one evaluation for each annotation spec.

Example

package main

import (
	"context"

	automl "cloud.google.com/go/automl/apiv1"

	automlpb "google.golang.org/genproto/googleapis/cloud/automl/v1"
)

func main() {
	// import automlpb "google.golang.org/genproto/googleapis/cloud/automl/v1"

	ctx := context.Background()
	c, err := automl.NewClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}

	req := &automlpb.CreateModelRequest{
		// TODO: Fill request struct fields.
	}
	op, err := c.CreateModel(ctx, req)
	if err != nil {
		// TODO: Handle error.
	}

	resp, err := op.Wait(ctx)
	if err != nil {
		// TODO: Handle error.
	}
	// TODO: Use resp.
	_ = resp
}

func (*Client) CreateModelOperation

func (c *Client) CreateModelOperation(name string) *CreateModelOperation

CreateModelOperation returns a new CreateModelOperation from a given name. The name must be that of a previously created CreateModelOperation, possibly from a different process.

func (*Client) DeleteDataset

DeleteDataset deletes a dataset and all of its contents. Returns empty response in the response field when it completes, and delete_details in the metadata field.

Example

package main

import (
	"context"

	automl "cloud.google.com/go/automl/apiv1"

	automlpb "google.golang.org/genproto/googleapis/cloud/automl/v1"
)

func main() {
	// import automlpb "google.golang.org/genproto/googleapis/cloud/automl/v1"

	ctx := context.Background()
	c, err := automl.NewClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}

	req := &automlpb.DeleteDatasetRequest{
		// TODO: Fill request struct fields.
	}
	op, err := c.DeleteDataset(ctx, req)
	if err != nil {
		// TODO: Handle error.
	}

	err = op.Wait(ctx)
	if err != nil {
		// TODO: Handle error.
	}
}

func (*Client) DeleteDatasetOperation

func (c *Client) DeleteDatasetOperation(name string) *DeleteDatasetOperation

DeleteDatasetOperation returns a new DeleteDatasetOperation from a given name. The name must be that of a previously created DeleteDatasetOperation, possibly from a different process.

func (*Client) DeleteModel

func (c *Client) DeleteModel(ctx context.Context, req *automlpb.DeleteModelRequest, opts ...gax.CallOption) (*DeleteModelOperation, error)

DeleteModel deletes a model. Returns google.protobuf.Empty in the response field when it completes, and delete_details in the metadata field.

Example

package main

import (
	"context"

	automl "cloud.google.com/go/automl/apiv1"

	automlpb "google.golang.org/genproto/googleapis/cloud/automl/v1"
)

func main() {
	// import automlpb "google.golang.org/genproto/googleapis/cloud/automl/v1"

	ctx := context.Background()
	c, err := automl.NewClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}

	req := &automlpb.DeleteModelRequest{
		// TODO: Fill request struct fields.
	}
	op, err := c.DeleteModel(ctx, req)
	if err != nil {
		// TODO: Handle error.
	}

	err = op.Wait(ctx)
	if err != nil {
		// TODO: Handle error.
	}
}

func (*Client) DeleteModelOperation

func (c *Client) DeleteModelOperation(name string) *DeleteModelOperation

DeleteModelOperation returns a new DeleteModelOperation from a given name. The name must be that of a previously created DeleteModelOperation, possibly from a different process.

func (*Client) DeployModel

func (c *Client) DeployModel(ctx context.Context, req *automlpb.DeployModelRequest, opts ...gax.CallOption) (*DeployModelOperation, error)

DeployModel deploys a model. If a model is already deployed, deploying it with the same parameters has no effect. Deploying with different parametrs (as e.g. changing

node_number) will reset the deployment state without pausing the model’s availability.

Only applicable for Text Classification, Image Object Detection , Tables, and Image Segmentation; all other domains manage deployment automatically.

Returns an empty response in the response field when it completes.

Example

package main

import (
	"context"

	automl "cloud.google.com/go/automl/apiv1"

	automlpb "google.golang.org/genproto/googleapis/cloud/automl/v1"
)

func main() {
	// import automlpb "google.golang.org/genproto/googleapis/cloud/automl/v1"

	ctx := context.Background()
	c, err := automl.NewClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}

	req := &automlpb.DeployModelRequest{
		// TODO: Fill request struct fields.
	}
	op, err := c.DeployModel(ctx, req)
	if err != nil {
		// TODO: Handle error.
	}

	err = op.Wait(ctx)
	if err != nil {
		// TODO: Handle error.
	}
}

func (*Client) DeployModelOperation

func (c *Client) DeployModelOperation(name string) *DeployModelOperation

DeployModelOperation returns a new DeployModelOperation from a given name. The name must be that of a previously created DeployModelOperation, possibly from a different process.

func (*Client) ExportData

func (c *Client) ExportData(ctx context.Context, req *automlpb.ExportDataRequest, opts ...gax.CallOption) (*ExportDataOperation, error)

ExportData exports dataset’s data to the provided output location. Returns an empty response in the response field when it completes.

Example

package main

import (
	"context"

	automl "cloud.google.com/go/automl/apiv1"

	automlpb "google.golang.org/genproto/googleapis/cloud/automl/v1"
)

func main() {
	// import automlpb "google.golang.org/genproto/googleapis/cloud/automl/v1"

	ctx := context.Background()
	c, err := automl.NewClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}

	req := &automlpb.ExportDataRequest{
		// TODO: Fill request struct fields.
	}
	op, err := c.ExportData(ctx, req)
	if err != nil {
		// TODO: Handle error.
	}

	err = op.Wait(ctx)
	if err != nil {
		// TODO: Handle error.
	}
}

func (*Client) ExportDataOperation

func (c *Client) ExportDataOperation(name string) *ExportDataOperation

ExportDataOperation returns a new ExportDataOperation from a given name. The name must be that of a previously created ExportDataOperation, possibly from a different process.

func (*Client) ExportModel

func (c *Client) ExportModel(ctx context.Context, req *automlpb.ExportModelRequest, opts ...gax.CallOption) (*ExportModelOperation, error)

ExportModel exports a trained, “export-able”, model to a user specified Google Cloud Storage location. A model is considered export-able if and only if it has an export format defined for it in ModelExportOutputConfig.

Returns an empty response in the response field when it completes.

Example

package main

import (
	"context"

	automl "cloud.google.com/go/automl/apiv1"

	automlpb "google.golang.org/genproto/googleapis/cloud/automl/v1"
)

func main() {
	// import automlpb "google.golang.org/genproto/googleapis/cloud/automl/v1"

	ctx := context.Background()
	c, err := automl.NewClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}

	req := &automlpb.ExportModelRequest{
		// TODO: Fill request struct fields.
	}
	op, err := c.ExportModel(ctx, req)
	if err != nil {
		// TODO: Handle error.
	}

	err = op.Wait(ctx)
	if err != nil {
		// TODO: Handle error.
	}
}

func (*Client) ExportModelOperation

func (c *Client) ExportModelOperation(name string) *ExportModelOperation

ExportModelOperation returns a new ExportModelOperation from a given name. The name must be that of a previously created ExportModelOperation, possibly from a different process.

func (*Client) GetAnnotationSpec

func (c *Client) GetAnnotationSpec(ctx context.Context, req *automlpb.GetAnnotationSpecRequest, opts ...gax.CallOption) (*automlpb.AnnotationSpec, error)

GetAnnotationSpec gets an annotation spec.

Example

package main

import (
	"context"

	automl "cloud.google.com/go/automl/apiv1"

	automlpb "google.golang.org/genproto/googleapis/cloud/automl/v1"
)

func main() {
	// import automlpb "google.golang.org/genproto/googleapis/cloud/automl/v1"

	ctx := context.Background()
	c, err := automl.NewClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}

	req := &automlpb.GetAnnotationSpecRequest{
		// TODO: Fill request struct fields.
	}
	resp, err := c.GetAnnotationSpec(ctx, req)
	if err != nil {
		// TODO: Handle error.
	}
	// TODO: Use resp.
	_ = resp
}

func (*Client) GetDataset

func (c *Client) GetDataset(ctx context.Context, req *automlpb.GetDatasetRequest, opts ...gax.CallOption) (*automlpb.Dataset, error)

GetDataset gets a dataset.

Example

package main

import (
	"context"

	automl "cloud.google.com/go/automl/apiv1"

	automlpb "google.golang.org/genproto/googleapis/cloud/automl/v1"
)

func main() {
	// import automlpb "google.golang.org/genproto/googleapis/cloud/automl/v1"

	ctx := context.Background()
	c, err := automl.NewClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}

	req := &automlpb.GetDatasetRequest{
		// TODO: Fill request struct fields.
	}
	resp, err := c.GetDataset(ctx, req)
	if err != nil {
		// TODO: Handle error.
	}
	// TODO: Use resp.
	_ = resp
}

func (*Client) GetModel

func (c *Client) GetModel(ctx context.Context, req *automlpb.GetModelRequest, opts ...gax.CallOption) (*automlpb.Model, error)

GetModel gets a model.

Example

package main

import (
	"context"

	automl "cloud.google.com/go/automl/apiv1"

	automlpb "google.golang.org/genproto/googleapis/cloud/automl/v1"
)

func main() {
	// import automlpb "google.golang.org/genproto/googleapis/cloud/automl/v1"

	ctx := context.Background()
	c, err := automl.NewClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}

	req := &automlpb.GetModelRequest{
		// TODO: Fill request struct fields.
	}
	resp, err := c.GetModel(ctx, req)
	if err != nil {
		// TODO: Handle error.
	}
	// TODO: Use resp.
	_ = resp
}

func (*Client) GetModelEvaluation

func (c *Client) GetModelEvaluation(ctx context.Context, req *automlpb.GetModelEvaluationRequest, opts ...gax.CallOption) (*automlpb.ModelEvaluation, error)

GetModelEvaluation gets a model evaluation.

Example

package main

import (
	"context"

	automl "cloud.google.com/go/automl/apiv1"

	automlpb "google.golang.org/genproto/googleapis/cloud/automl/v1"
)

func main() {
	// import automlpb "google.golang.org/genproto/googleapis/cloud/automl/v1"

	ctx := context.Background()
	c, err := automl.NewClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}

	req := &automlpb.GetModelEvaluationRequest{
		// TODO: Fill request struct fields.
	}
	resp, err := c.GetModelEvaluation(ctx, req)
	if err != nil {
		// TODO: Handle error.
	}
	// TODO: Use resp.
	_ = resp
}

func (*Client) ImportData

func (c *Client) ImportData(ctx context.Context, req *automlpb.ImportDataRequest, opts ...gax.CallOption) (*ImportDataOperation, error)

ImportData imports data into a dataset. For Tables this method can only be called on an empty Dataset.

For Tables:

A schema_inference_version parameter must be explicitly set. Returns an empty response in the response field when it completes.

Example

package main

import (
	"context"

	automl "cloud.google.com/go/automl/apiv1"

	automlpb "google.golang.org/genproto/googleapis/cloud/automl/v1"
)

func main() {
	// import automlpb "google.golang.org/genproto/googleapis/cloud/automl/v1"

	ctx := context.Background()
	c, err := automl.NewClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}

	req := &automlpb.ImportDataRequest{
		// TODO: Fill request struct fields.
	}
	op, err := c.ImportData(ctx, req)
	if err != nil {
		// TODO: Handle error.
	}

	err = op.Wait(ctx)
	if err != nil {
		// TODO: Handle error.
	}
}

func (*Client) ImportDataOperation

func (c *Client) ImportDataOperation(name string) *ImportDataOperation

ImportDataOperation returns a new ImportDataOperation from a given name. The name must be that of a previously created ImportDataOperation, possibly from a different process.

func (*Client) ListDatasets

func (c *Client) ListDatasets(ctx context.Context, req *automlpb.ListDatasetsRequest, opts ...gax.CallOption) *DatasetIterator

ListDatasets lists datasets in a project.

Example

package main

import (
	"context"

	automl "cloud.google.com/go/automl/apiv1"
	"google.golang.org/api/iterator"

	automlpb "google.golang.org/genproto/googleapis/cloud/automl/v1"
)

func main() {
	// import automlpb "google.golang.org/genproto/googleapis/cloud/automl/v1"
	// import "google.golang.org/api/iterator"

	ctx := context.Background()
	c, err := automl.NewClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}

	req := &automlpb.ListDatasetsRequest{
		// TODO: Fill request struct fields.
	}
	it := c.ListDatasets(ctx, req)
	for {
		resp, err := it.Next()
		if err == iterator.Done {
			break
		}
		if err != nil {
			// TODO: Handle error.
		}
		// TODO: Use resp.
		_ = resp
	}
}

func (*Client) ListModelEvaluations

func (c *Client) ListModelEvaluations(ctx context.Context, req *automlpb.ListModelEvaluationsRequest, opts ...gax.CallOption) *ModelEvaluationIterator

ListModelEvaluations lists model evaluations.

Example

package main

import (
	"context"

	automl "cloud.google.com/go/automl/apiv1"
	"google.golang.org/api/iterator"

	automlpb "google.golang.org/genproto/googleapis/cloud/automl/v1"
)

func main() {
	// import automlpb "google.golang.org/genproto/googleapis/cloud/automl/v1"
	// import "google.golang.org/api/iterator"

	ctx := context.Background()
	c, err := automl.NewClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}

	req := &automlpb.ListModelEvaluationsRequest{
		// TODO: Fill request struct fields.
	}
	it := c.ListModelEvaluations(ctx, req)
	for {
		resp, err := it.Next()
		if err == iterator.Done {
			break
		}
		if err != nil {
			// TODO: Handle error.
		}
		// TODO: Use resp.
		_ = resp
	}
}

func (*Client) ListModels

func (c *Client) ListModels(ctx context.Context, req *automlpb.ListModelsRequest, opts ...gax.CallOption) *ModelIterator

ListModels lists models.

Example

package main

import (
	"context"

	automl "cloud.google.com/go/automl/apiv1"
	"google.golang.org/api/iterator"

	automlpb "google.golang.org/genproto/googleapis/cloud/automl/v1"
)

func main() {
	// import automlpb "google.golang.org/genproto/googleapis/cloud/automl/v1"
	// import "google.golang.org/api/iterator"

	ctx := context.Background()
	c, err := automl.NewClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}

	req := &automlpb.ListModelsRequest{
		// TODO: Fill request struct fields.
	}
	it := c.ListModels(ctx, req)
	for {
		resp, err := it.Next()
		if err == iterator.Done {
			break
		}
		if err != nil {
			// TODO: Handle error.
		}
		// TODO: Use resp.
		_ = resp
	}
}

func (*Client) UndeployModel

UndeployModel undeploys a model. If the model is not deployed this method has no effect.

Only applicable for Text Classification, Image Object Detection and Tables; all other domains manage deployment automatically.

Returns an empty response in the response field when it completes.

Example

package main

import (
	"context"

	automl "cloud.google.com/go/automl/apiv1"

	automlpb "google.golang.org/genproto/googleapis/cloud/automl/v1"
)

func main() {
	// import automlpb "google.golang.org/genproto/googleapis/cloud/automl/v1"

	ctx := context.Background()
	c, err := automl.NewClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}

	req := &automlpb.UndeployModelRequest{
		// TODO: Fill request struct fields.
	}
	op, err := c.UndeployModel(ctx, req)
	if err != nil {
		// TODO: Handle error.
	}

	err = op.Wait(ctx)
	if err != nil {
		// TODO: Handle error.
	}
}

func (*Client) UndeployModelOperation

func (c *Client) UndeployModelOperation(name string) *UndeployModelOperation

UndeployModelOperation returns a new UndeployModelOperation from a given name. The name must be that of a previously created UndeployModelOperation, possibly from a different process.

func (*Client) UpdateDataset

func (c *Client) UpdateDataset(ctx context.Context, req *automlpb.UpdateDatasetRequest, opts ...gax.CallOption) (*automlpb.Dataset, error)

UpdateDataset updates a dataset.

Example

package main

import (
	"context"

	automl "cloud.google.com/go/automl/apiv1"

	automlpb "google.golang.org/genproto/googleapis/cloud/automl/v1"
)

func main() {
	// import automlpb "google.golang.org/genproto/googleapis/cloud/automl/v1"

	ctx := context.Background()
	c, err := automl.NewClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}

	req := &automlpb.UpdateDatasetRequest{
		// TODO: Fill request struct fields.
	}
	resp, err := c.UpdateDataset(ctx, req)
	if err != nil {
		// TODO: Handle error.
	}
	// TODO: Use resp.
	_ = resp
}

func (*Client) UpdateModel

func (c *Client) UpdateModel(ctx context.Context, req *automlpb.UpdateModelRequest, opts ...gax.CallOption) (*automlpb.Model, error)

UpdateModel updates a model.

Example

package main

import (
	"context"

	automl "cloud.google.com/go/automl/apiv1"

	automlpb "google.golang.org/genproto/googleapis/cloud/automl/v1"
)

func main() {
	// import automlpb "google.golang.org/genproto/googleapis/cloud/automl/v1"

	ctx := context.Background()
	c, err := automl.NewClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}

	req := &automlpb.UpdateModelRequest{
		// TODO: Fill request struct fields.
	}
	resp, err := c.UpdateModel(ctx, req)
	if err != nil {
		// TODO: Handle error.
	}
	// TODO: Use resp.
	_ = resp
}

CreateDatasetOperation

type CreateDatasetOperation struct {
	// contains filtered or unexported fields
}

CreateDatasetOperation manages a long-running operation from CreateDataset.

func (*CreateDatasetOperation) Done

func (op *CreateDatasetOperation) Done() bool

Done reports whether the long-running operation has completed.

func (*CreateDatasetOperation) Metadata

Metadata returns metadata associated with the long-running operation. Metadata itself does not contact the server, but Poll does. To get the latest metadata, call this method after a successful call to Poll. If the metadata is not available, the returned metadata and error are both nil.

func (*CreateDatasetOperation) Name

func (op *CreateDatasetOperation) Name() string

Name returns the name of the long-running operation. The name is assigned by the server and is unique within the service from which the operation is created.

func (*CreateDatasetOperation) Poll

Poll fetches the latest state of the long-running operation.

Poll also fetches the latest metadata, which can be retrieved by Metadata.

If Poll fails, the error is returned and op is unmodified. If Poll succeeds and the operation has completed with failure, the error is returned and op.Done will return true. If Poll succeeds and the operation has completed successfully, op.Done will return true, and the response of the operation is returned. If Poll succeeds and the operation has not completed, the returned response and error are both nil.

func (*CreateDatasetOperation) Wait

Wait blocks until the long-running operation is completed, returning the response and any errors encountered.

See documentation of Poll for error-handling information.

CreateModelOperation

type CreateModelOperation struct {
	// contains filtered or unexported fields
}

CreateModelOperation manages a long-running operation from CreateModel.

func (*CreateModelOperation) Done

func (op *CreateModelOperation) Done() bool

Done reports whether the long-running operation has completed.

func (*CreateModelOperation) Metadata

Metadata returns metadata associated with the long-running operation. Metadata itself does not contact the server, but Poll does. To get the latest metadata, call this method after a successful call to Poll. If the metadata is not available, the returned metadata and error are both nil.

func (*CreateModelOperation) Name

func (op *CreateModelOperation) Name() string

Name returns the name of the long-running operation. The name is assigned by the server and is unique within the service from which the operation is created.

func (*CreateModelOperation) Poll

Poll fetches the latest state of the long-running operation.

Poll also fetches the latest metadata, which can be retrieved by Metadata.

If Poll fails, the error is returned and op is unmodified. If Poll succeeds and the operation has completed with failure, the error is returned and op.Done will return true. If Poll succeeds and the operation has completed successfully, op.Done will return true, and the response of the operation is returned. If Poll succeeds and the operation has not completed, the returned response and error are both nil.

func (*CreateModelOperation) Wait

Wait blocks until the long-running operation is completed, returning the response and any errors encountered.

See documentation of Poll for error-handling information.

DatasetIterator

type DatasetIterator struct {

	// Response is the raw response for the current page.
	// It must be cast to the RPC response type.
	// Calling Next() or InternalFetch() updates this value.
	Response interface{}

	// InternalFetch is for use by the Google Cloud Libraries only.
	// It is not part of the stable interface of this package.
	//
	// InternalFetch returns results from a single call to the underlying RPC.
	// The number of results is no greater than pageSize.
	// If there are no more results, nextPageToken is empty and err is nil.
	InternalFetch func(pageSize int, pageToken string) (results []*automlpb.Dataset, nextPageToken string, err error)
	// contains filtered or unexported fields
}

DatasetIterator manages a stream of *automlpb.Dataset.

func (*DatasetIterator) Next

func (it *DatasetIterator) Next() (*automlpb.Dataset, error)

Next returns the next result. Its second return value is iterator.Done if there are no more results. Once Next returns Done, all subsequent calls will return Done.

func (*DatasetIterator) PageInfo

func (it *DatasetIterator) PageInfo() *iterator.PageInfo

PageInfo supports pagination. See the google.golang.org/api/iterator package for details.

DeleteDatasetOperation

type DeleteDatasetOperation struct {
	// contains filtered or unexported fields
}

DeleteDatasetOperation manages a long-running operation from DeleteDataset.

func (*DeleteDatasetOperation) Done

func (op *DeleteDatasetOperation) Done() bool

Done reports whether the long-running operation has completed.

func (*DeleteDatasetOperation) Metadata

Metadata returns metadata associated with the long-running operation. Metadata itself does not contact the server, but Poll does. To get the latest metadata, call this method after a successful call to Poll. If the metadata is not available, the returned metadata and error are both nil.

func (*DeleteDatasetOperation) Name

func (op *DeleteDatasetOperation) Name() string

Name returns the name of the long-running operation. The name is assigned by the server and is unique within the service from which the operation is created.

func (*DeleteDatasetOperation) Poll

func (op *DeleteDatasetOperation) Poll(ctx context.Context, opts ...gax.CallOption) error

Poll fetches the latest state of the long-running operation.

Poll also fetches the latest metadata, which can be retrieved by Metadata.

If Poll fails, the error is returned and op is unmodified. If Poll succeeds and the operation has completed with failure, the error is returned and op.Done will return true. If Poll succeeds and the operation has completed successfully, op.Done will return true, and the response of the operation is returned. If Poll succeeds and the operation has not completed, the returned response and error are both nil.

func (*DeleteDatasetOperation) Wait

func (op *DeleteDatasetOperation) Wait(ctx context.Context, opts ...gax.CallOption) error

Wait blocks until the long-running operation is completed, returning the response and any errors encountered.

See documentation of Poll for error-handling information.

DeleteModelOperation

type DeleteModelOperation struct {
	// contains filtered or unexported fields
}

DeleteModelOperation manages a long-running operation from DeleteModel.

func (*DeleteModelOperation) Done

func (op *DeleteModelOperation) Done() bool

Done reports whether the long-running operation has completed.

func (*DeleteModelOperation) Metadata

Metadata returns metadata associated with the long-running operation. Metadata itself does not contact the server, but Poll does. To get the latest metadata, call this method after a successful call to Poll. If the metadata is not available, the returned metadata and error are both nil.

func (*DeleteModelOperation) Name

func (op *DeleteModelOperation) Name() string

Name returns the name of the long-running operation. The name is assigned by the server and is unique within the service from which the operation is created.

func (*DeleteModelOperation) Poll

func (op *DeleteModelOperation) Poll(ctx context.Context, opts ...gax.CallOption) error

Poll fetches the latest state of the long-running operation.

Poll also fetches the latest metadata, which can be retrieved by Metadata.

If Poll fails, the error is returned and op is unmodified. If Poll succeeds and the operation has completed with failure, the error is returned and op.Done will return true. If Poll succeeds and the operation has completed successfully, op.Done will return true, and the response of the operation is returned. If Poll succeeds and the operation has not completed, the returned response and error are both nil.

func (*DeleteModelOperation) Wait

func (op *DeleteModelOperation) Wait(ctx context.Context, opts ...gax.CallOption) error

Wait blocks until the long-running operation is completed, returning the response and any errors encountered.

See documentation of Poll for error-handling information.

DeployModelOperation

type DeployModelOperation struct {
	// contains filtered or unexported fields
}

DeployModelOperation manages a long-running operation from DeployModel.

func (*DeployModelOperation) Done

func (op *DeployModelOperation) Done() bool

Done reports whether the long-running operation has completed.

func (*DeployModelOperation) Metadata

Metadata returns metadata associated with the long-running operation. Metadata itself does not contact the server, but Poll does. To get the latest metadata, call this method after a successful call to Poll. If the metadata is not available, the returned metadata and error are both nil.

func (*DeployModelOperation) Name

func (op *DeployModelOperation) Name() string

Name returns the name of the long-running operation. The name is assigned by the server and is unique within the service from which the operation is created.

func (*DeployModelOperation) Poll

func (op *DeployModelOperation) Poll(ctx context.Context, opts ...gax.CallOption) error

Poll fetches the latest state of the long-running operation.

Poll also fetches the latest metadata, which can be retrieved by Metadata.

If Poll fails, the error is returned and op is unmodified. If Poll succeeds and the operation has completed with failure, the error is returned and op.Done will return true. If Poll succeeds and the operation has completed successfully, op.Done will return true, and the response of the operation is returned. If Poll succeeds and the operation has not completed, the returned response and error are both nil.

func (*DeployModelOperation) Wait

func (op *DeployModelOperation) Wait(ctx context.Context, opts ...gax.CallOption) error

Wait blocks until the long-running operation is completed, returning the response and any errors encountered.

See documentation of Poll for error-handling information.

ExportDataOperation

type ExportDataOperation struct {
	// contains filtered or unexported fields
}

ExportDataOperation manages a long-running operation from ExportData.

func (*ExportDataOperation) Done

func (op *ExportDataOperation) Done() bool

Done reports whether the long-running operation has completed.

func (*ExportDataOperation) Metadata

Metadata returns metadata associated with the long-running operation. Metadata itself does not contact the server, but Poll does. To get the latest metadata, call this method after a successful call to Poll. If the metadata is not available, the returned metadata and error are both nil.

func (*ExportDataOperation) Name

func (op *ExportDataOperation) Name() string

Name returns the name of the long-running operation. The name is assigned by the server and is unique within the service from which the operation is created.

func (*ExportDataOperation) Poll

func (op *ExportDataOperation) Poll(ctx context.Context, opts ...gax.CallOption) error

Poll fetches the latest state of the long-running operation.

Poll also fetches the latest metadata, which can be retrieved by Metadata.

If Poll fails, the error is returned and op is unmodified. If Poll succeeds and the operation has completed with failure, the error is returned and op.Done will return true. If Poll succeeds and the operation has completed successfully, op.Done will return true, and the response of the operation is returned. If Poll succeeds and the operation has not completed, the returned response and error are both nil.

func (*ExportDataOperation) Wait

func (op *ExportDataOperation) Wait(ctx context.Context, opts ...gax.CallOption) error

Wait blocks until the long-running operation is completed, returning the response and any errors encountered.

See documentation of Poll for error-handling information.

ExportModelOperation

type ExportModelOperation struct {
	// contains filtered or unexported fields
}

ExportModelOperation manages a long-running operation from ExportModel.

func (*ExportModelOperation) Done

func (op *ExportModelOperation) Done() bool

Done reports whether the long-running operation has completed.

func (*ExportModelOperation) Metadata

Metadata returns metadata associated with the long-running operation. Metadata itself does not contact the server, but Poll does. To get the latest metadata, call this method after a successful call to Poll. If the metadata is not available, the returned metadata and error are both nil.

func (*ExportModelOperation) Name

func (op *ExportModelOperation) Name() string

Name returns the name of the long-running operation. The name is assigned by the server and is unique within the service from which the operation is created.

func (*ExportModelOperation) Poll

func (op *ExportModelOperation) Poll(ctx context.Context, opts ...gax.CallOption) error

Poll fetches the latest state of the long-running operation.

Poll also fetches the latest metadata, which can be retrieved by Metadata.

If Poll fails, the error is returned and op is unmodified. If Poll succeeds and the operation has completed with failure, the error is returned and op.Done will return true. If Poll succeeds and the operation has completed successfully, op.Done will return true, and the response of the operation is returned. If Poll succeeds and the operation has not completed, the returned response and error are both nil.

func (*ExportModelOperation) Wait

func (op *ExportModelOperation) Wait(ctx context.Context, opts ...gax.CallOption) error

Wait blocks until the long-running operation is completed, returning the response and any errors encountered.

See documentation of Poll for error-handling information.

ImportDataOperation

type ImportDataOperation struct {
	// contains filtered or unexported fields
}

ImportDataOperation manages a long-running operation from ImportData.

func (*ImportDataOperation) Done

func (op *ImportDataOperation) Done() bool

Done reports whether the long-running operation has completed.

func (*ImportDataOperation) Metadata

Metadata returns metadata associated with the long-running operation. Metadata itself does not contact the server, but Poll does. To get the latest metadata, call this method after a successful call to Poll. If the metadata is not available, the returned metadata and error are both nil.

func (*ImportDataOperation) Name

func (op *ImportDataOperation) Name() string

Name returns the name of the long-running operation. The name is assigned by the server and is unique within the service from which the operation is created.

func (*ImportDataOperation) Poll

func (op *ImportDataOperation) Poll(ctx context.Context, opts ...gax.CallOption) error

Poll fetches the latest state of the long-running operation.

Poll also fetches the latest metadata, which can be retrieved by Metadata.

If Poll fails, the error is returned and op is unmodified. If Poll succeeds and the operation has completed with failure, the error is returned and op.Done will return true. If Poll succeeds and the operation has completed successfully, op.Done will return true, and the response of the operation is returned. If Poll succeeds and the operation has not completed, the returned response and error are both nil.

func (*ImportDataOperation) Wait

func (op *ImportDataOperation) Wait(ctx context.Context, opts ...gax.CallOption) error

Wait blocks until the long-running operation is completed, returning the response and any errors encountered.

See documentation of Poll for error-handling information.

ModelEvaluationIterator

type ModelEvaluationIterator struct {

	// Response is the raw response for the current page.
	// It must be cast to the RPC response type.
	// Calling Next() or InternalFetch() updates this value.
	Response interface{}

	// InternalFetch is for use by the Google Cloud Libraries only.
	// It is not part of the stable interface of this package.
	//
	// InternalFetch returns results from a single call to the underlying RPC.
	// The number of results is no greater than pageSize.
	// If there are no more results, nextPageToken is empty and err is nil.
	InternalFetch func(pageSize int, pageToken string) (results []*automlpb.ModelEvaluation, nextPageToken string, err error)
	// contains filtered or unexported fields
}

ModelEvaluationIterator manages a stream of *automlpb.ModelEvaluation.

func (*ModelEvaluationIterator) Next

Next returns the next result. Its second return value is iterator.Done if there are no more results. Once Next returns Done, all subsequent calls will return Done.

func (*ModelEvaluationIterator) PageInfo

func (it *ModelEvaluationIterator) PageInfo() *iterator.PageInfo

PageInfo supports pagination. See the google.golang.org/api/iterator package for details.

ModelIterator

type ModelIterator struct {

	// Response is the raw response for the current page.
	// It must be cast to the RPC response type.
	// Calling Next() or InternalFetch() updates this value.
	Response interface{}

	// InternalFetch is for use by the Google Cloud Libraries only.
	// It is not part of the stable interface of this package.
	//
	// InternalFetch returns results from a single call to the underlying RPC.
	// The number of results is no greater than pageSize.
	// If there are no more results, nextPageToken is empty and err is nil.
	InternalFetch func(pageSize int, pageToken string) (results []*automlpb.Model, nextPageToken string, err error)
	// contains filtered or unexported fields
}

ModelIterator manages a stream of *automlpb.Model.

func (*ModelIterator) Next

func (it *ModelIterator) Next() (*automlpb.Model, error)

Next returns the next result. Its second return value is iterator.Done if there are no more results. Once Next returns Done, all subsequent calls will return Done.

func (*ModelIterator) PageInfo

func (it *ModelIterator) PageInfo() *iterator.PageInfo

PageInfo supports pagination. See the google.golang.org/api/iterator package for details.

PredictionCallOptions

type PredictionCallOptions struct {
	Predict      []gax.CallOption
	BatchPredict []gax.CallOption
}

PredictionCallOptions contains the retry settings for each method of PredictionClient.

PredictionClient

type PredictionClient struct {

	// LROClient is used internally to handle longrunning operations.
	// It is exposed so that its CallOptions can be modified if required.
	// Users should not Close this client.
	LROClient *lroauto.OperationsClient

	// The call options for this service.
	CallOptions *PredictionCallOptions
	// contains filtered or unexported fields
}

PredictionClient is a client for interacting with Cloud AutoML API.

Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.

func NewPredictionClient

func NewPredictionClient(ctx context.Context, opts ...option.ClientOption) (*PredictionClient, error)

NewPredictionClient creates a new prediction service client.

AutoML Prediction API.

On any input that is documented to expect a string parameter in snake_case or kebab-case, either of those cases is accepted.

Example

package main

import (
	"context"

	automl "cloud.google.com/go/automl/apiv1"
)

func main() {
	ctx := context.Background()
	c, err := automl.NewPredictionClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}
	// TODO: Use client.
	_ = c
}

func (*PredictionClient) BatchPredict

BatchPredict perform a batch prediction. Unlike the online Predict, batch prediction result won’t be immediately available in the response. Instead, a long running operation object is returned. User can poll the operation result via GetOperation method. Once the operation is done, BatchPredictResult is returned in the response field. Available for following ML scenarios:

AutoML Vision Classification

AutoML Vision Object Detection

AutoML Video Intelligence Classification

AutoML Video Intelligence Object Tracking * AutoML Natural Language Classification

AutoML Natural Language Entity Extraction

AutoML Natural Language Sentiment Analysis

AutoML Tables

Example

package main

import (
	"context"

	automl "cloud.google.com/go/automl/apiv1"
	automlpb "google.golang.org/genproto/googleapis/cloud/automl/v1"
)

func main() {
	// import automlpb "google.golang.org/genproto/googleapis/cloud/automl/v1"

	ctx := context.Background()
	c, err := automl.NewPredictionClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}

	req := &automlpb.BatchPredictRequest{
		// TODO: Fill request struct fields.
	}
	op, err := c.BatchPredict(ctx, req)
	if err != nil {
		// TODO: Handle error.
	}

	resp, err := op.Wait(ctx)
	if err != nil {
		// TODO: Handle error.
	}
	// TODO: Use resp.
	_ = resp
}

func (*PredictionClient) BatchPredictOperation

func (c *PredictionClient) BatchPredictOperation(name string) *BatchPredictOperation

BatchPredictOperation returns a new BatchPredictOperation from a given name. The name must be that of a previously created BatchPredictOperation, possibly from a different process.

func (*PredictionClient) Close

func (c *PredictionClient) Close() error

Close closes the connection to the API service. The user should invoke this when the client is no longer required.

func (*PredictionClient) Connection

func (c *PredictionClient) Connection() *grpc.ClientConn

Connection returns a connection to the API service.

Deprecated.

func (*PredictionClient) Predict

Predict perform an online prediction. The prediction result is directly returned in the response. Available for following ML scenarios, and their expected request payloads:

AutoML Vision Classification

An image in .JPEG, .GIF or .PNG format, image_bytes up to 30MB.

AutoML Vision Object Detection

An image in .JPEG, .GIF or .PNG format, image_bytes up to 30MB.

AutoML Natural Language Classification

A TextSnippet up to 60,000 characters, UTF-8 encoded or a document in .PDF, .TIF or .TIFF format with size upto 2MB.

AutoML Natural Language Entity Extraction

A TextSnippet up to 10,000 characters, UTF-8 NFC encoded or a document in .PDF, .TIF or .TIFF format with size upto 20MB.

AutoML Natural Language Sentiment Analysis

A TextSnippet up to 60,000 characters, UTF-8 encoded or a document in .PDF, .TIF or .TIFF format with size upto 2MB.

AutoML Translation

A TextSnippet up to 25,000 characters, UTF-8 encoded.

AutoML Tables

A row with column values matching the columns of the model, up to 5MB. Not available for FORECASTING prediction_type.

Example

package main

import (
	"context"

	automl "cloud.google.com/go/automl/apiv1"
	automlpb "google.golang.org/genproto/googleapis/cloud/automl/v1"
)

func main() {
	// import automlpb "google.golang.org/genproto/googleapis/cloud/automl/v1"

	ctx := context.Background()
	c, err := automl.NewPredictionClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}

	req := &automlpb.PredictRequest{
		// TODO: Fill request struct fields.
	}
	resp, err := c.Predict(ctx, req)
	if err != nil {
		// TODO: Handle error.
	}
	// TODO: Use resp.
	_ = resp
}

UndeployModelOperation

type UndeployModelOperation struct {
	// contains filtered or unexported fields
}

UndeployModelOperation manages a long-running operation from UndeployModel.

func (*UndeployModelOperation) Done

func (op *UndeployModelOperation) Done() bool

Done reports whether the long-running operation has completed.

func (*UndeployModelOperation) Metadata

Metadata returns metadata associated with the long-running operation. Metadata itself does not contact the server, but Poll does. To get the latest metadata, call this method after a successful call to Poll. If the metadata is not available, the returned metadata and error are both nil.

func (*UndeployModelOperation) Name

func (op *UndeployModelOperation) Name() string

Name returns the name of the long-running operation. The name is assigned by the server and is unique within the service from which the operation is created.

func (*UndeployModelOperation) Poll

func (op *UndeployModelOperation) Poll(ctx context.Context, opts ...gax.CallOption) error

Poll fetches the latest state of the long-running operation.

Poll also fetches the latest metadata, which can be retrieved by Metadata.

If Poll fails, the error is returned and op is unmodified. If Poll succeeds and the operation has completed with failure, the error is returned and op.Done will return true. If Poll succeeds and the operation has completed successfully, op.Done will return true, and the response of the operation is returned. If Poll succeeds and the operation has not completed, the returned response and error are both nil.

func (*UndeployModelOperation) Wait

func (op *UndeployModelOperation) Wait(ctx context.Context, opts ...gax.CallOption) error

Wait blocks until the long-running operation is completed, returning the response and any errors encountered.

See documentation of Poll for error-handling information.