func (cl *Client) GetSecretVersionData(project, id, version string) ([]byte, error) {
	ctx := context.TODO()
	name := "projects/" + project + "/secrets/" + id + "/versions/" + version
	accReq := &secretmanagerpb.AccessSecretVersionRequest{
		Name: name,
	}
	accResult, err := cl.Client.AccessSecretVersion(ctx, accReq)
	if err != nil {
		return nil, err
	}
	return accResult.Payload.Data, nil
}
GetSecretVersionData gets the data of the secret version specified by project, id, version.
Returns secret value if successful, otherwise error
package client
import (
	"context"
	"github.com/golang/protobuf/ptypes"
	"google.golang.org/genproto/protobuf/field_mask"
	"google.golang.org/grpc/codes"
	"google.golang.org/grpc/status"
	"strings"
	"time"
	secretmanager "cloud.google.com/go/secretmanager/apiv1"
	secretmanagerpb "google.golang.org/genproto/googleapis/cloud/secretmanager/v1"
)
type Client struct {
	*secretmanager.Client
}
func NewClient(ctx context.Context) (*Client, error) {
	gsmClient, err := secretmanager.NewClient(ctx)
	if err != nil {
		return nil, err
	}
	return &Client{gsmClient}, nil
}
type Interface interface {
	ValidateSecret(project, id string) error
	ValidateSecretVersion(project, id, version string) error
	CreateSecret(project, id string) error
	UpsertSecret(project, id string, data []byte) (string, error)
	GetCreateTime(project, id, version string) (time.Time, error)
	GetSecretLabels(project, id string) (map[string]string, error)
	GetSecretVersionData(project, id, version string) ([]byte, error)
	GetSecretVersionState(project, id, version string) (secretmanagerpb.SecretVersion_State, error)
	EnableSecretVersion(project, id, version string) error
	DisableSecretVersion(project, id, version string) error
	DestroySecretVersion(project, id, version string) error
	UpsertSecretLabel(project, id, key, val string) error
	DeleteSecretLabel(project, id, key string) error
}
func (cl *Client) ValidateSecret(project, id string) error {
	ctx := context.TODO()
	name := "projects/" + project + "/secrets/" + id
	getReq := &secretmanagerpb.GetSecretRequest{
		Name: name,
	}
	_, err := cl.GetSecret(ctx, getReq)
	return err
}
func (cl *Client) ValidateSecretVersion(project, id, version string) error {
	ctx := context.TODO()
	name := "projects/" + project + "/secrets/" + id + "/versions/" + version
	getReq := &secretmanagerpb.GetSecretVersionRequest{
		Name: name,
	}
	_, err := cl.GetSecretVersion(ctx, getReq)
	return err
}
func (cl *Client) CreateSecret(project, id string) error {
	parent := "projects/" + project
	req := &secretmanagerpb.CreateSecretRequest{
		Parent:   parent,
		SecretId: id,
		Secret: &secretmanagerpb.Secret{
			Replication: &secretmanagerpb.Replication{
				Replication: &secretmanagerpb.Replication_Automatic_{
					Automatic: &secretmanagerpb.Replication_Automatic{},
				},
			},
		},
	}
	_, err := cl.Client.CreateSecret(context.TODO(), req)
	return err
}
func (cl *Client) UpsertSecret(project, id string, data []byte) (string, error) {
	parent := "projects/" + project
	err := cl.ValidateSecret(project, id)
	if err != nil {
		if status.Code(err) == codes.NotFound {
			err := cl.CreateSecret(project, id)
			if err != nil {
				return "", err
			}
		} else {
			return "", err
		}
	}
	verReq := &secretmanagerpb.AddSecretVersionRequest{
		Parent: parent + "/secrets/" + id,
		Payload: &secretmanagerpb.SecretPayload{
			Data: data,
		},
	}
	verResp, err := cl.AddSecretVersion(context.TODO(), verReq)
	if err != nil {
		return "", err
	}
	splits := strings.Split(verResp.Name, "/")
	latestVersion := splits[len(splits)-1]
	return latestVersion, nil
}
func (cl *Client) GetCreateTime(project, id, version string) (time.Time, error) {
	ctx := context.TODO()
	name := "projects/" + project + "/secrets/" + id + "/versions/" + version
	getReq := &secretmanagerpb.GetSecretVersionRequest{
		Name: name,
	}
	getResult, err := cl.GetSecretVersion(ctx, getReq)
	if err != nil {
		return time.Time{}, err
	}
	createTime, err := ptypes.Timestamp(getResult.CreateTime)
	if err != nil {
		return time.Time{}, err
	}
	return createTime, nil
}
func (cl *Client) GetSecretLabels(project, id string) (map[string]string, error) {
	ctx := context.TODO()
	name := "projects/" + project + "/secrets/" + id
	getReq := &secretmanagerpb.GetSecretRequest{
		Name: name,
	}
	getResult, err := cl.GetSecret(ctx, getReq)
	if err != nil {
		return nil, err
	}
	return getResult.Labels, nil
}