Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions internal/gengapic/client_init.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,12 @@ func (g *generator) serviceDoc(serv *descriptorpb.ServiceDescriptorProto) {
// Prepend new line break before existing service comments.
g.printf("//")
g.comment(com)

apiVersion := proto.GetExtension(serv.Options, annotations.E_ApiVersion).(string)
if apiVersion != "" {
g.printf("//")
g.comment(fmt.Sprintf("This client uses %s version %s.", serv.GetName(), apiVersion))
}
}

func (g *generator) clientInit(serv *descriptorpb.ServiceDescriptorProto, servName string, hasRPCForLRO bool) {
Expand Down
6 changes: 6 additions & 0 deletions internal/gengapic/testdata/empty_client_init.want
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ type internalClient interface {
// Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
//
// Foo service does stuff.
//
// This client uses Foo version v1_20240425.
type Client struct {
// The internal transport-dependent client.
internalClient internalClient
Expand Down Expand Up @@ -70,6 +72,8 @@ type gRPCClient struct {
// The returned client must be Closed when it is done being used to clean up its underlying connections.
//
// Foo service does stuff.
//
// This client uses Foo version v1_20240425.
func NewClient(ctx context.Context, opts ...option.ClientOption) (*Client, error) {
clientOpts := defaultGRPCClientOptions()
if newClientHook != nil {
Expand Down Expand Up @@ -146,6 +150,8 @@ type restClient struct {
// NewRESTClient creates a new foo rest client.
//
// Foo service does stuff.
//
// This client uses Foo version v1_20240425.
func NewRESTClient(ctx context.Context, opts ...option.ClientOption) (*Client, error) {
clientOpts := append(defaultRESTClientOptions(), opts...)
httpClient, endpoint, err := httptransport.NewClient(ctx, clientOpts...)
Expand Down
4 changes: 4 additions & 0 deletions internal/gengapic/testdata/foo_client_init.want
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ type internalFooClient interface {
// Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
//
// Foo service does stuff.
//
// This client uses Foo version v1_20240425.
type FooClient struct {
// The internal transport-dependent client.
internalClient internalFooClient
Expand Down Expand Up @@ -99,6 +101,8 @@ type fooGRPCClient struct {
// The returned client must be Closed when it is done being used to clean up its underlying connections.
//
// Foo service does stuff.
//
// This client uses Foo version v1_20240425.
func NewFooClient(ctx context.Context, opts ...option.ClientOption) (*FooClient, error) {
clientOpts := defaultFooGRPCClientOptions()
if newFooClientHook != nil {
Expand Down
4 changes: 4 additions & 0 deletions internal/gengapic/testdata/foo_rest_client_init.want
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ type internalFooClient interface {
// Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
//
// Foo service does stuff.
//
// This client uses Foo version v1_20240425.
type FooClient struct {
// The internal transport-dependent client.
internalClient internalFooClient
Expand Down Expand Up @@ -92,6 +94,8 @@ type fooRESTClient struct {
// NewFooRESTClient creates a new foo rest client.
//
// Foo service does stuff.
//
// This client uses Foo version v1_20240425.
func NewFooRESTClient(ctx context.Context, opts ...option.ClientOption) (*FooClient, error) {
clientOpts := append(defaultFooRESTClientOptions(), opts...)
httpClient, endpoint, err := httptransport.NewClient(ctx, clientOpts...)
Expand Down
4 changes: 4 additions & 0 deletions internal/gengapic/testdata/lro_client_init.want
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ type internalFooClient interface {
// Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
//
// Foo service does stuff.
//
// This client uses Foo version v1_20240425.
type FooClient struct {
// The internal transport-dependent client.
internalClient internalFooClient
Expand Down Expand Up @@ -114,6 +116,8 @@ type fooGRPCClient struct {
// The returned client must be Closed when it is done being used to clean up its underlying connections.
//
// Foo service does stuff.
//
// This client uses Foo version v1_20240425.
func NewFooClient(ctx context.Context, opts ...option.ClientOption) (*FooClient, error) {
clientOpts := defaultFooGRPCClientOptions()
if newFooClientHook != nil {
Expand Down