Documentation
¶
Overview ¶
General documentation
For information about setting deadlines, reusing contexts, and more please visit https://pkg.go.dev/cloud.google.com/go.
Example usage ¶
To get started with this package, create a client.
ctx := context.Background() // This snippet 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 as shown in: // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options c, err := gapic.NewSearchClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close()
The client will use your default application credentials. Clients should be reused instead of created as needed. The methods of Client are safe for concurrent use by multiple goroutines. The returned client must be Closed when it is done being used.
Using the Client ¶
The following is an example of making an API call with the newly created client.
ctx := context.Background() // This snippet 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 as shown in: // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options c, err := gapic.NewSearchClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &rpcpb.IndexRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/github.com/apigee/registry-experimental/rpc#IndexRequest. } op, err := c.Index(ctx, req) if err != nil { // TODO: Handle error. } resp, err := op.Wait(ctx) if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp
Use of Context ¶
The ctx passed to NewSearchClient 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.
Index ¶
- func DefaultAuthScopes() []string
- type IndexOperation
- func (op *IndexOperation) Done() bool
- func (op *IndexOperation) Metadata() (*rpcpb.IndexMetadata, error)
- func (op *IndexOperation) Name() string
- func (op *IndexOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*rpcpb.IndexResponse, error)
- func (op *IndexOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*rpcpb.IndexResponse, error)
- type QueryResponse_ResultIterator
- type SearchCallOptions
- type SearchClient
- func (c *SearchClient) Close() error
- func (c *SearchClient) Connection() *grpc.ClientConndeprecated
- func (c *SearchClient) GrpcClient() rpcpb.SearchClient
- func (c *SearchClient) Index(ctx context.Context, req *rpcpb.IndexRequest, opts ...gax.CallOption) (*IndexOperation, error)
- func (c *SearchClient) IndexOperation(name string) *IndexOperation
- func (c *SearchClient) Query(ctx context.Context, req *rpcpb.QueryRequest, opts ...gax.CallOption) *QueryResponse_ResultIterator
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultAuthScopes ¶
func DefaultAuthScopes() []string
DefaultAuthScopes reports the default set of authentication scopes to use with this package.
Types ¶
type IndexOperation ¶
type IndexOperation struct {
// contains filtered or unexported fields
}
IndexOperation manages a long-running operation from Index.
func (*IndexOperation) Done ¶
func (op *IndexOperation) Done() bool
Done reports whether the long-running operation has completed.
func (*IndexOperation) Metadata ¶
func (op *IndexOperation) Metadata() (*rpcpb.IndexMetadata, error)
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 (*IndexOperation) Name ¶
func (op *IndexOperation) 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 (*IndexOperation) Poll ¶
func (op *IndexOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*rpcpb.IndexResponse, 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 (*IndexOperation) Wait ¶
func (op *IndexOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*rpcpb.IndexResponse, 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.
type QueryResponse_ResultIterator ¶
type QueryResponse_ResultIterator 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 []*rpcpb.QueryResponse_Result, nextPageToken string, err error) // contains filtered or unexported fields }
QueryResponse_ResultIterator manages a stream of *rpcpb.QueryResponse_Result.
func (*QueryResponse_ResultIterator) Next ¶
func (it *QueryResponse_ResultIterator) Next() (*rpcpb.QueryResponse_Result, 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 (*QueryResponse_ResultIterator) PageInfo ¶
func (it *QueryResponse_ResultIterator) PageInfo() *iterator.PageInfo
PageInfo supports pagination. See the google.golang.org/api/iterator package for details.
type SearchCallOptions ¶
type SearchCallOptions struct { Index []gax.CallOption Query []gax.CallOption }
SearchCallOptions contains the retry settings for each method of SearchClient.
type SearchClient ¶
type SearchClient struct { // The call options for this service. CallOptions *SearchCallOptions // LROClient is used internally to handle long-running operations. // It is exposed so that its CallOptions can be modified if required. // Users should not Close this client. LROClient *lroauto.OperationsClient // contains filtered or unexported fields }
SearchClient is a client for interacting with . Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
Build and search an index of APIs.
func NewSearchClient ¶
func NewSearchClient(ctx context.Context, opts ...option.ClientOption) (*SearchClient, error)
NewSearchClient creates a new search client based on gRPC. The returned client must be Closed when it is done being used to clean up its underlying connections.
Build and search an index of APIs.
Example ¶
package main import ( "context" gapic "github.com/apigee/registry-experimental/gapic" ) func main() { ctx := context.Background() // This snippet 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 as shown in: // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options c, err := gapic.NewSearchClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() // TODO: Use client. _ = c }
Output:
func (*SearchClient) Close ¶
func (c *SearchClient) Close() error
Close closes the connection to the API service. The user should invoke this when the client is no longer required.
func (*SearchClient) Connection
deprecated
func (c *SearchClient) Connection() *grpc.ClientConn
Connection returns a connection to the API service.
Deprecated: Connections are now pooled so this method does not always return the same resource.
func (*SearchClient) GrpcClient ¶
func (c *SearchClient) GrpcClient() rpcpb.SearchClient
func (*SearchClient) Index ¶
func (c *SearchClient) Index(ctx context.Context, req *rpcpb.IndexRequest, opts ...gax.CallOption) (*IndexOperation, error)
Index add a resource to the search index.
Example ¶
package main import ( "context" gapic "github.com/apigee/registry-experimental/gapic" rpcpb "github.com/apigee/registry-experimental/rpc" ) func main() { ctx := context.Background() // This snippet 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 as shown in: // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options c, err := gapic.NewSearchClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &rpcpb.IndexRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/github.com/apigee/registry-experimental/rpc#IndexRequest. } op, err := c.Index(ctx, req) if err != nil { // TODO: Handle error. } resp, err := op.Wait(ctx) if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp }
Output:
func (*SearchClient) IndexOperation ¶
func (c *SearchClient) IndexOperation(name string) *IndexOperation
IndexOperation returns a new IndexOperation from a given name. The name must be that of a previously created IndexOperation, possibly from a different process.
func (*SearchClient) Query ¶
func (c *SearchClient) Query(ctx context.Context, req *rpcpb.QueryRequest, opts ...gax.CallOption) *QueryResponse_ResultIterator
Query query the index.
Example ¶
package main import ( "context" gapic "github.com/apigee/registry-experimental/gapic" rpcpb "github.com/apigee/registry-experimental/rpc" "google.golang.org/api/iterator" ) func main() { ctx := context.Background() // This snippet 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 as shown in: // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options c, err := gapic.NewSearchClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &rpcpb.QueryRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/github.com/apigee/registry-experimental/rpc#QueryRequest. } it := c.Query(ctx, req) for { resp, err := it.Next() if err == iterator.Done { break } if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp } }
Output: