client

package
v0.7.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 6, 2020 License: Apache-2.0 Imports: 20 Imported by: 1

Documentation

Overview

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 godoc.org/cloud.google.com/go.

Index

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 BlurbIterator

type BlurbIterator 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 []*genprotopb.Blurb, nextPageToken string, err error)
	// contains filtered or unexported fields
}

BlurbIterator manages a stream of *genprotopb.Blurb.

func (*BlurbIterator) Next

func (it *BlurbIterator) Next() (*genprotopb.Blurb, 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 (*BlurbIterator) PageInfo

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

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

type EchoCallOptions

type EchoCallOptions struct {
	Echo        []gax.CallOption
	Expand      []gax.CallOption
	Collect     []gax.CallOption
	Chat        []gax.CallOption
	PagedExpand []gax.CallOption
	Wait        []gax.CallOption
	Block       []gax.CallOption
}

EchoCallOptions contains the retry settings for each method of EchoClient.

type EchoClient

type EchoClient 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 *EchoCallOptions
	// contains filtered or unexported fields
}

EchoClient is a client for interacting with .

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

func NewEchoClient

func NewEchoClient(ctx context.Context, opts ...option.ClientOption) (*EchoClient, error)

NewEchoClient creates a new echo client.

This service is used showcase the four main types of rpcs - unary, server side streaming, client side streaming, and bidirectional streaming. This service also exposes methods that explicitly implement server delay, and paginated calls. Set the ‘showcase-trailer’ metadata key on any method to have the values echoed in the response trailers.

Example
package main

import (
	"context"

	client "github.com/googleapis/gapic-showcase/client"
)

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

func (*EchoClient) Block added in v0.3.0

Block this method will block (wait) for the requested amount of time and then return the response or error. This method showcases how a client handles delays or retries.

Example
package main

import (
	"context"

	client "github.com/googleapis/gapic-showcase/client"
	genprotopb "github.com/googleapis/gapic-showcase/server/genproto"
)

func main() {
	// import genprotopb "github.com/googleapis/gapic-showcase/server/genproto"

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

	req := &genprotopb.BlockRequest{
		// TODO: Fill request struct fields.
	}
	resp, err := c.Block(ctx, req)
	if err != nil {
		// TODO: Handle error.
	}
	// TODO: Use resp.
	_ = resp
}
Output:

func (*EchoClient) Chat

Chat this method, upon receiving a request on the stream, the same content will be passed back on the stream. This method showcases bidirectional streaming rpcs.

Example
package main

import (
	"context"
	"io"

	client "github.com/googleapis/gapic-showcase/client"
	genprotopb "github.com/googleapis/gapic-showcase/server/genproto"
)

func main() {
	// import genprotopb "github.com/googleapis/gapic-showcase/server/genproto"

	ctx := context.Background()
	c, err := client.NewEchoClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}
	stream, err := c.Chat(ctx)
	if err != nil {
		// TODO: Handle error.
	}
	go func() {
		reqs := []*genprotopb.EchoRequest{
			// TODO: Create requests.
		}
		for _, req := range reqs {
			if err := stream.Send(req); err != nil {
				// TODO: Handle error.
			}
		}
		stream.CloseSend()
	}()
	for {
		resp, err := stream.Recv()
		if err == io.EOF {
			break
		}
		if err != nil {
			// TODO: handle error.
		}
		// TODO: Use resp.
		_ = resp
	}
}
Output:

func (*EchoClient) Close

func (c *EchoClient) Close() error

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

func (*EchoClient) Collect

Collect this method will collect the words given to it. When the stream is closed by the client, this method will return the a concatenation of the strings passed to it. This method showcases client-side streaming rpcs.

func (*EchoClient) Connection

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

Connection returns the client's connection to the API service.

func (*EchoClient) Echo

Echo this method simply echos the request. This method is showcases unary rpcs.

Example
package main

import (
	"context"

	client "github.com/googleapis/gapic-showcase/client"
	genprotopb "github.com/googleapis/gapic-showcase/server/genproto"
)

func main() {
	// import genprotopb "github.com/googleapis/gapic-showcase/server/genproto"

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

	req := &genprotopb.EchoRequest{
		// TODO: Fill request struct fields.
	}
	resp, err := c.Echo(ctx, req)
	if err != nil {
		// TODO: Handle error.
	}
	// TODO: Use resp.
	_ = resp
}
Output:

func (*EchoClient) Expand

Expand this method split the given content into words and will pass each word back through the stream. This method showcases server-side streaming rpcs.

func (*EchoClient) PagedExpand

PagedExpand this is similar to the Expand method but instead of returning a stream of expanded words, this method returns a paged list of expanded words.

Example
package main

import (
	"context"

	client "github.com/googleapis/gapic-showcase/client"
	genprotopb "github.com/googleapis/gapic-showcase/server/genproto"
	"google.golang.org/api/iterator"
)

func main() {
	// import genprotopb "github.com/googleapis/gapic-showcase/server/genproto"
	// import "google.golang.org/api/iterator"

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

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

func (*EchoClient) Wait

Wait this method will wait the requested amount of and then return. This method showcases how a client handles a request timing out.

Example
package main

import (
	"context"

	client "github.com/googleapis/gapic-showcase/client"
	genprotopb "github.com/googleapis/gapic-showcase/server/genproto"
)

func main() {
	// import genprotopb "github.com/googleapis/gapic-showcase/server/genproto"

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

	req := &genprotopb.WaitRequest{
		// TODO: Fill request struct fields.
	}
	op, err := c.Wait(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 (*EchoClient) WaitOperation

func (c *EchoClient) WaitOperation(name string) *WaitOperation

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

type EchoResponseIterator

type EchoResponseIterator 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 []*genprotopb.EchoResponse, nextPageToken string, err error)
	// contains filtered or unexported fields
}

EchoResponseIterator manages a stream of *genprotopb.EchoResponse.

func (*EchoResponseIterator) 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 (*EchoResponseIterator) PageInfo

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

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

type IdentityCallOptions

type IdentityCallOptions struct {
	CreateUser []gax.CallOption
	GetUser    []gax.CallOption
	UpdateUser []gax.CallOption
	DeleteUser []gax.CallOption
	ListUsers  []gax.CallOption
}

IdentityCallOptions contains the retry settings for each method of IdentityClient.

type IdentityClient

type IdentityClient struct {

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

IdentityClient is a client for interacting with .

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

func NewIdentityClient

func NewIdentityClient(ctx context.Context, opts ...option.ClientOption) (*IdentityClient, error)

NewIdentityClient creates a new identity client.

A simple identity service.

Example
package main

import (
	"context"

	client "github.com/googleapis/gapic-showcase/client"
)

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

func (*IdentityClient) Close

func (c *IdentityClient) Close() error

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

func (*IdentityClient) Connection

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

Connection returns the client's connection to the API service.

func (*IdentityClient) CreateUser

CreateUser creates a user.

Example
package main

import (
	"context"

	client "github.com/googleapis/gapic-showcase/client"
	genprotopb "github.com/googleapis/gapic-showcase/server/genproto"
)

func main() {
	// import genprotopb "github.com/googleapis/gapic-showcase/server/genproto"

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

	req := &genprotopb.CreateUserRequest{
		// TODO: Fill request struct fields.
	}
	resp, err := c.CreateUser(ctx, req)
	if err != nil {
		// TODO: Handle error.
	}
	// TODO: Use resp.
	_ = resp
}
Output:

func (*IdentityClient) DeleteUser

func (c *IdentityClient) DeleteUser(ctx context.Context, req *genprotopb.DeleteUserRequest, opts ...gax.CallOption) error

DeleteUser deletes a user, their profile, and all of their authored messages.

Example
package main

import (
	"context"

	client "github.com/googleapis/gapic-showcase/client"
	genprotopb "github.com/googleapis/gapic-showcase/server/genproto"
)

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

	req := &genprotopb.DeleteUserRequest{
		// TODO: Fill request struct fields.
	}
	err = c.DeleteUser(ctx, req)
	if err != nil {
		// TODO: Handle error.
	}
}
Output:

func (*IdentityClient) GetUser

GetUser retrieves the User with the given uri.

Example
package main

import (
	"context"

	client "github.com/googleapis/gapic-showcase/client"
	genprotopb "github.com/googleapis/gapic-showcase/server/genproto"
)

func main() {
	// import genprotopb "github.com/googleapis/gapic-showcase/server/genproto"

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

	req := &genprotopb.GetUserRequest{
		// TODO: Fill request struct fields.
	}
	resp, err := c.GetUser(ctx, req)
	if err != nil {
		// TODO: Handle error.
	}
	// TODO: Use resp.
	_ = resp
}
Output:

func (*IdentityClient) ListUsers

ListUsers lists all users.

Example
package main

import (
	"context"

	client "github.com/googleapis/gapic-showcase/client"
	genprotopb "github.com/googleapis/gapic-showcase/server/genproto"
	"google.golang.org/api/iterator"
)

func main() {
	// import genprotopb "github.com/googleapis/gapic-showcase/server/genproto"
	// import "google.golang.org/api/iterator"

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

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

func (*IdentityClient) UpdateUser

UpdateUser updates a user.

Example
package main

import (
	"context"

	client "github.com/googleapis/gapic-showcase/client"
	genprotopb "github.com/googleapis/gapic-showcase/server/genproto"
)

func main() {
	// import genprotopb "github.com/googleapis/gapic-showcase/server/genproto"

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

	req := &genprotopb.UpdateUserRequest{
		// TODO: Fill request struct fields.
	}
	resp, err := c.UpdateUser(ctx, req)
	if err != nil {
		// TODO: Handle error.
	}
	// TODO: Use resp.
	_ = resp
}
Output:

type MessagingCallOptions

type MessagingCallOptions struct {
	CreateRoom   []gax.CallOption
	GetRoom      []gax.CallOption
	UpdateRoom   []gax.CallOption
	DeleteRoom   []gax.CallOption
	ListRooms    []gax.CallOption
	CreateBlurb  []gax.CallOption
	GetBlurb     []gax.CallOption
	UpdateBlurb  []gax.CallOption
	DeleteBlurb  []gax.CallOption
	ListBlurbs   []gax.CallOption
	SearchBlurbs []gax.CallOption
	StreamBlurbs []gax.CallOption
	SendBlurbs   []gax.CallOption
	Connect      []gax.CallOption
}

MessagingCallOptions contains the retry settings for each method of MessagingClient.

type MessagingClient

type MessagingClient 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 *MessagingCallOptions
	// contains filtered or unexported fields
}

MessagingClient is a client for interacting with .

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

func NewMessagingClient

func NewMessagingClient(ctx context.Context, opts ...option.ClientOption) (*MessagingClient, error)

NewMessagingClient creates a new messaging client.

A simple messaging service that implements chat rooms and profile posts.

This messaging service showcases the features that API clients generated by gapic-generators implement.

Example
package main

import (
	"context"

	client "github.com/googleapis/gapic-showcase/client"
)

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

func (*MessagingClient) Close

func (c *MessagingClient) Close() error

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

func (*MessagingClient) Connect

Connect this method starts a bidirectional stream that receives all blurbs that are being created after the stream has started and sends requests to create blurbs. If an invalid blurb is requested to be created, the stream will close with an error.

Example
package main

import (
	"context"
	"io"

	client "github.com/googleapis/gapic-showcase/client"
	genprotopb "github.com/googleapis/gapic-showcase/server/genproto"
)

func main() {
	// import genprotopb "github.com/googleapis/gapic-showcase/server/genproto"

	ctx := context.Background()
	c, err := client.NewMessagingClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}
	stream, err := c.Connect(ctx)
	if err != nil {
		// TODO: Handle error.
	}
	go func() {
		reqs := []*genprotopb.ConnectRequest{
			// TODO: Create requests.
		}
		for _, req := range reqs {
			if err := stream.Send(req); err != nil {
				// TODO: Handle error.
			}
		}
		stream.CloseSend()
	}()
	for {
		resp, err := stream.Recv()
		if err == io.EOF {
			break
		}
		if err != nil {
			// TODO: handle error.
		}
		// TODO: Use resp.
		_ = resp
	}
}
Output:

func (*MessagingClient) Connection

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

Connection returns the client's connection to the API service.

func (*MessagingClient) CreateBlurb

CreateBlurb creates a blurb. If the parent is a room, the blurb is understood to be a message in that room. If the parent is a profile, the blurb is understood to be a post on the profile.

Example
package main

import (
	"context"

	client "github.com/googleapis/gapic-showcase/client"
	genprotopb "github.com/googleapis/gapic-showcase/server/genproto"
)

func main() {
	// import genprotopb "github.com/googleapis/gapic-showcase/server/genproto"

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

	req := &genprotopb.CreateBlurbRequest{
		// TODO: Fill request struct fields.
	}
	resp, err := c.CreateBlurb(ctx, req)
	if err != nil {
		// TODO: Handle error.
	}
	// TODO: Use resp.
	_ = resp
}
Output:

func (*MessagingClient) CreateRoom

CreateRoom creates a room.

Example
package main

import (
	"context"

	client "github.com/googleapis/gapic-showcase/client"
	genprotopb "github.com/googleapis/gapic-showcase/server/genproto"
)

func main() {
	// import genprotopb "github.com/googleapis/gapic-showcase/server/genproto"

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

	req := &genprotopb.CreateRoomRequest{
		// TODO: Fill request struct fields.
	}
	resp, err := c.CreateRoom(ctx, req)
	if err != nil {
		// TODO: Handle error.
	}
	// TODO: Use resp.
	_ = resp
}
Output:

func (*MessagingClient) DeleteBlurb

func (c *MessagingClient) DeleteBlurb(ctx context.Context, req *genprotopb.DeleteBlurbRequest, opts ...gax.CallOption) error

DeleteBlurb deletes a blurb.

Example
package main

import (
	"context"

	client "github.com/googleapis/gapic-showcase/client"
	genprotopb "github.com/googleapis/gapic-showcase/server/genproto"
)

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

	req := &genprotopb.DeleteBlurbRequest{
		// TODO: Fill request struct fields.
	}
	err = c.DeleteBlurb(ctx, req)
	if err != nil {
		// TODO: Handle error.
	}
}
Output:

func (*MessagingClient) DeleteRoom

func (c *MessagingClient) DeleteRoom(ctx context.Context, req *genprotopb.DeleteRoomRequest, opts ...gax.CallOption) error

DeleteRoom deletes a room and all of its blurbs.

Example
package main

import (
	"context"

	client "github.com/googleapis/gapic-showcase/client"
	genprotopb "github.com/googleapis/gapic-showcase/server/genproto"
)

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

	req := &genprotopb.DeleteRoomRequest{
		// TODO: Fill request struct fields.
	}
	err = c.DeleteRoom(ctx, req)
	if err != nil {
		// TODO: Handle error.
	}
}
Output:

func (*MessagingClient) GetBlurb

GetBlurb retrieves the Blurb with the given resource name.

Example
package main

import (
	"context"

	client "github.com/googleapis/gapic-showcase/client"
	genprotopb "github.com/googleapis/gapic-showcase/server/genproto"
)

func main() {
	// import genprotopb "github.com/googleapis/gapic-showcase/server/genproto"

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

	req := &genprotopb.GetBlurbRequest{
		// TODO: Fill request struct fields.
	}
	resp, err := c.GetBlurb(ctx, req)
	if err != nil {
		// TODO: Handle error.
	}
	// TODO: Use resp.
	_ = resp
}
Output:

func (*MessagingClient) GetRoom

GetRoom retrieves the Room with the given resource name.

Example
package main

import (
	"context"

	client "github.com/googleapis/gapic-showcase/client"
	genprotopb "github.com/googleapis/gapic-showcase/server/genproto"
)

func main() {
	// import genprotopb "github.com/googleapis/gapic-showcase/server/genproto"

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

	req := &genprotopb.GetRoomRequest{
		// TODO: Fill request struct fields.
	}
	resp, err := c.GetRoom(ctx, req)
	if err != nil {
		// TODO: Handle error.
	}
	// TODO: Use resp.
	_ = resp
}
Output:

func (*MessagingClient) ListBlurbs

ListBlurbs lists blurbs for a specific chat room or user profile depending on the parent resource name.

Example
package main

import (
	"context"

	client "github.com/googleapis/gapic-showcase/client"
	genprotopb "github.com/googleapis/gapic-showcase/server/genproto"
	"google.golang.org/api/iterator"
)

func main() {
	// import genprotopb "github.com/googleapis/gapic-showcase/server/genproto"
	// import "google.golang.org/api/iterator"

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

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

func (*MessagingClient) ListRooms

ListRooms lists all chat rooms.

Example
package main

import (
	"context"

	client "github.com/googleapis/gapic-showcase/client"
	genprotopb "github.com/googleapis/gapic-showcase/server/genproto"
	"google.golang.org/api/iterator"
)

func main() {
	// import genprotopb "github.com/googleapis/gapic-showcase/server/genproto"
	// import "google.golang.org/api/iterator"

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

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

func (*MessagingClient) SearchBlurbs

SearchBlurbs this method searches through all blurbs across all rooms and profiles for blurbs containing to words found in the query. Only posts that contain an exact match of a queried word will be returned.

Example
package main

import (
	"context"

	client "github.com/googleapis/gapic-showcase/client"
	genprotopb "github.com/googleapis/gapic-showcase/server/genproto"
)

func main() {
	// import genprotopb "github.com/googleapis/gapic-showcase/server/genproto"

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

	req := &genprotopb.SearchBlurbsRequest{
		// TODO: Fill request struct fields.
	}
	op, err := c.SearchBlurbs(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 (*MessagingClient) SearchBlurbsOperation

func (c *MessagingClient) SearchBlurbsOperation(name string) *SearchBlurbsOperation

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

func (*MessagingClient) SendBlurbs

SendBlurbs this is a stream to create multiple blurbs. If an invalid blurb is requested to be created, the stream will close with an error.

func (*MessagingClient) StreamBlurbs

StreamBlurbs this returns a stream that emits the blurbs that are created for a particular chat room or user profile.

func (*MessagingClient) UpdateBlurb

UpdateBlurb updates a blurb.

Example
package main

import (
	"context"

	client "github.com/googleapis/gapic-showcase/client"
	genprotopb "github.com/googleapis/gapic-showcase/server/genproto"
)

func main() {
	// import genprotopb "github.com/googleapis/gapic-showcase/server/genproto"

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

	req := &genprotopb.UpdateBlurbRequest{
		// TODO: Fill request struct fields.
	}
	resp, err := c.UpdateBlurb(ctx, req)
	if err != nil {
		// TODO: Handle error.
	}
	// TODO: Use resp.
	_ = resp
}
Output:

func (*MessagingClient) UpdateRoom

UpdateRoom updates a room.

Example
package main

import (
	"context"

	client "github.com/googleapis/gapic-showcase/client"
	genprotopb "github.com/googleapis/gapic-showcase/server/genproto"
)

func main() {
	// import genprotopb "github.com/googleapis/gapic-showcase/server/genproto"

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

	req := &genprotopb.UpdateRoomRequest{
		// TODO: Fill request struct fields.
	}
	resp, err := c.UpdateRoom(ctx, req)
	if err != nil {
		// TODO: Handle error.
	}
	// TODO: Use resp.
	_ = resp
}
Output:

type RoomIterator

type RoomIterator 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 []*genprotopb.Room, nextPageToken string, err error)
	// contains filtered or unexported fields
}

RoomIterator manages a stream of *genprotopb.Room.

func (*RoomIterator) Next

func (it *RoomIterator) Next() (*genprotopb.Room, 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 (*RoomIterator) PageInfo

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

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

type SearchBlurbsOperation

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

SearchBlurbsOperation manages a long-running operation from SearchBlurbs.

func (*SearchBlurbsOperation) Done

func (op *SearchBlurbsOperation) Done() bool

Done reports whether the long-running operation has completed.

func (*SearchBlurbsOperation) 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 (*SearchBlurbsOperation) Name

func (op *SearchBlurbsOperation) 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 (*SearchBlurbsOperation) 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 (*SearchBlurbsOperation) 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.

type SessionIterator

type SessionIterator 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 []*genprotopb.Session, nextPageToken string, err error)
	// contains filtered or unexported fields
}

SessionIterator manages a stream of *genprotopb.Session.

func (*SessionIterator) Next

func (it *SessionIterator) Next() (*genprotopb.Session, 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 (*SessionIterator) PageInfo

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

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

type TestIterator

type TestIterator 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 []*genprotopb.Test, nextPageToken string, err error)
	// contains filtered or unexported fields
}

TestIterator manages a stream of *genprotopb.Test.

func (*TestIterator) Next

func (it *TestIterator) Next() (*genprotopb.Test, 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 (*TestIterator) PageInfo

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

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

type TestingCallOptions

type TestingCallOptions struct {
	CreateSession []gax.CallOption
	GetSession    []gax.CallOption
	ListSessions  []gax.CallOption
	DeleteSession []gax.CallOption
	ReportSession []gax.CallOption
	ListTests     []gax.CallOption
	DeleteTest    []gax.CallOption
	VerifyTest    []gax.CallOption
}

TestingCallOptions contains the retry settings for each method of TestingClient.

type TestingClient

type TestingClient struct {

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

TestingClient is a client for interacting with .

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

func NewTestingClient

func NewTestingClient(ctx context.Context, opts ...option.ClientOption) (*TestingClient, error)

NewTestingClient creates a new testing client.

A service to facilitate running discrete sets of tests against Showcase.

Example
package main

import (
	"context"

	client "github.com/googleapis/gapic-showcase/client"
)

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

func (*TestingClient) Close

func (c *TestingClient) Close() error

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

func (*TestingClient) Connection

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

Connection returns the client's connection to the API service.

func (*TestingClient) CreateSession

CreateSession creates a new testing session.

Example
package main

import (
	"context"

	client "github.com/googleapis/gapic-showcase/client"
	genprotopb "github.com/googleapis/gapic-showcase/server/genproto"
)

func main() {
	// import genprotopb "github.com/googleapis/gapic-showcase/server/genproto"

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

	req := &genprotopb.CreateSessionRequest{
		// TODO: Fill request struct fields.
	}
	resp, err := c.CreateSession(ctx, req)
	if err != nil {
		// TODO: Handle error.
	}
	// TODO: Use resp.
	_ = resp
}
Output:

func (*TestingClient) DeleteSession

func (c *TestingClient) DeleteSession(ctx context.Context, req *genprotopb.DeleteSessionRequest, opts ...gax.CallOption) error

DeleteSession delete a test session.

Example
package main

import (
	"context"

	client "github.com/googleapis/gapic-showcase/client"
	genprotopb "github.com/googleapis/gapic-showcase/server/genproto"
)

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

	req := &genprotopb.DeleteSessionRequest{
		// TODO: Fill request struct fields.
	}
	err = c.DeleteSession(ctx, req)
	if err != nil {
		// TODO: Handle error.
	}
}
Output:

func (*TestingClient) DeleteTest

func (c *TestingClient) DeleteTest(ctx context.Context, req *genprotopb.DeleteTestRequest, opts ...gax.CallOption) error

DeleteTest explicitly decline to implement a test.

This removes the test from subsequent ListTests calls, and attempting to do the test will error.

This method will error if attempting to delete a required test.

Example
package main

import (
	"context"

	client "github.com/googleapis/gapic-showcase/client"
	genprotopb "github.com/googleapis/gapic-showcase/server/genproto"
)

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

	req := &genprotopb.DeleteTestRequest{
		// TODO: Fill request struct fields.
	}
	err = c.DeleteTest(ctx, req)
	if err != nil {
		// TODO: Handle error.
	}
}
Output:

func (*TestingClient) GetSession

GetSession gets a testing session.

Example
package main

import (
	"context"

	client "github.com/googleapis/gapic-showcase/client"
	genprotopb "github.com/googleapis/gapic-showcase/server/genproto"
)

func main() {
	// import genprotopb "github.com/googleapis/gapic-showcase/server/genproto"

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

	req := &genprotopb.GetSessionRequest{
		// TODO: Fill request struct fields.
	}
	resp, err := c.GetSession(ctx, req)
	if err != nil {
		// TODO: Handle error.
	}
	// TODO: Use resp.
	_ = resp
}
Output:

func (*TestingClient) ListSessions

ListSessions lists the current test sessions.

Example
package main

import (
	"context"

	client "github.com/googleapis/gapic-showcase/client"
	genprotopb "github.com/googleapis/gapic-showcase/server/genproto"
	"google.golang.org/api/iterator"
)

func main() {
	// import genprotopb "github.com/googleapis/gapic-showcase/server/genproto"
	// import "google.golang.org/api/iterator"

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

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

func (*TestingClient) ListTests

ListTests list the tests of a sessesion.

Example
package main

import (
	"context"

	client "github.com/googleapis/gapic-showcase/client"
	genprotopb "github.com/googleapis/gapic-showcase/server/genproto"
	"google.golang.org/api/iterator"
)

func main() {
	// import genprotopb "github.com/googleapis/gapic-showcase/server/genproto"
	// import "google.golang.org/api/iterator"

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

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

func (*TestingClient) ReportSession

ReportSession report on the status of a session. This generates a report detailing which tests have been completed, and an overall rollup.

Example
package main

import (
	"context"

	client "github.com/googleapis/gapic-showcase/client"
	genprotopb "github.com/googleapis/gapic-showcase/server/genproto"
)

func main() {
	// import genprotopb "github.com/googleapis/gapic-showcase/server/genproto"

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

	req := &genprotopb.ReportSessionRequest{
		// TODO: Fill request struct fields.
	}
	resp, err := c.ReportSession(ctx, req)
	if err != nil {
		// TODO: Handle error.
	}
	// TODO: Use resp.
	_ = resp
}
Output:

func (*TestingClient) VerifyTest

VerifyTest register a response to a test.

In cases where a test involves registering a final answer at the end of the test, this method provides the means to do so.

Example
package main

import (
	"context"

	client "github.com/googleapis/gapic-showcase/client"
	genprotopb "github.com/googleapis/gapic-showcase/server/genproto"
)

func main() {
	// import genprotopb "github.com/googleapis/gapic-showcase/server/genproto"

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

	req := &genprotopb.VerifyTestRequest{
		// TODO: Fill request struct fields.
	}
	resp, err := c.VerifyTest(ctx, req)
	if err != nil {
		// TODO: Handle error.
	}
	// TODO: Use resp.
	_ = resp
}
Output:

type UserIterator

type UserIterator 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 []*genprotopb.User, nextPageToken string, err error)
	// contains filtered or unexported fields
}

UserIterator manages a stream of *genprotopb.User.

func (*UserIterator) Next

func (it *UserIterator) Next() (*genprotopb.User, 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 (*UserIterator) PageInfo

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

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

type WaitOperation

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

WaitOperation manages a long-running operation from Wait.

func (*WaitOperation) Done

func (op *WaitOperation) Done() bool

Done reports whether the long-running operation has completed.

func (*WaitOperation) Metadata

func (op *WaitOperation) Metadata() (*genprotopb.WaitMetadata, 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 (*WaitOperation) Name

func (op *WaitOperation) 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 (*WaitOperation) 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 (*WaitOperation) 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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL