2018-01-23 19:40:42 +01:00
|
|
|
// Copyright 2018 Google LLC
|
2017-09-13 14:09:48 +02:00
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
|
// You may obtain a copy of the License at
|
|
|
|
//
|
2018-01-23 19:40:42 +01:00
|
|
|
// https://www.apache.org/licenses/LICENSE-2.0
|
2017-09-13 14:09:48 +02:00
|
|
|
//
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
|
|
|
|
|
|
|
// AUTO-GENERATED CODE. DO NOT EDIT.
|
|
|
|
|
|
|
|
package spanner_test
|
|
|
|
|
|
|
|
import (
|
|
|
|
"io"
|
|
|
|
|
|
|
|
"cloud.google.com/go/spanner/apiv1"
|
|
|
|
"golang.org/x/net/context"
|
2017-12-03 21:01:25 +01:00
|
|
|
"google.golang.org/api/iterator"
|
2017-09-13 14:09:48 +02:00
|
|
|
spannerpb "google.golang.org/genproto/googleapis/spanner/v1"
|
|
|
|
)
|
|
|
|
|
|
|
|
func ExampleNewClient() {
|
|
|
|
ctx := context.Background()
|
|
|
|
c, err := spanner.NewClient(ctx)
|
|
|
|
if err != nil {
|
|
|
|
// TODO: Handle error.
|
|
|
|
}
|
|
|
|
// TODO: Use client.
|
|
|
|
_ = c
|
|
|
|
}
|
|
|
|
|
|
|
|
func ExampleClient_CreateSession() {
|
|
|
|
ctx := context.Background()
|
|
|
|
c, err := spanner.NewClient(ctx)
|
|
|
|
if err != nil {
|
|
|
|
// TODO: Handle error.
|
|
|
|
}
|
|
|
|
|
|
|
|
req := &spannerpb.CreateSessionRequest{
|
2018-01-23 19:40:42 +01:00
|
|
|
// TODO: Fill request struct fields.
|
2017-09-13 14:09:48 +02:00
|
|
|
}
|
|
|
|
resp, err := c.CreateSession(ctx, req)
|
|
|
|
if err != nil {
|
|
|
|
// TODO: Handle error.
|
|
|
|
}
|
|
|
|
// TODO: Use resp.
|
|
|
|
_ = resp
|
|
|
|
}
|
|
|
|
|
|
|
|
func ExampleClient_GetSession() {
|
|
|
|
ctx := context.Background()
|
|
|
|
c, err := spanner.NewClient(ctx)
|
|
|
|
if err != nil {
|
|
|
|
// TODO: Handle error.
|
|
|
|
}
|
|
|
|
|
|
|
|
req := &spannerpb.GetSessionRequest{
|
2018-01-23 19:40:42 +01:00
|
|
|
// TODO: Fill request struct fields.
|
2017-09-13 14:09:48 +02:00
|
|
|
}
|
|
|
|
resp, err := c.GetSession(ctx, req)
|
|
|
|
if err != nil {
|
|
|
|
// TODO: Handle error.
|
|
|
|
}
|
|
|
|
// TODO: Use resp.
|
|
|
|
_ = resp
|
|
|
|
}
|
|
|
|
|
2017-12-03 21:01:25 +01:00
|
|
|
func ExampleClient_ListSessions() {
|
|
|
|
ctx := context.Background()
|
|
|
|
c, err := spanner.NewClient(ctx)
|
|
|
|
if err != nil {
|
|
|
|
// TODO: Handle error.
|
|
|
|
}
|
|
|
|
|
|
|
|
req := &spannerpb.ListSessionsRequest{
|
2018-01-23 19:40:42 +01:00
|
|
|
// TODO: Fill request struct fields.
|
2017-12-03 21:01:25 +01:00
|
|
|
}
|
|
|
|
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
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-09-13 14:09:48 +02:00
|
|
|
func ExampleClient_DeleteSession() {
|
|
|
|
ctx := context.Background()
|
|
|
|
c, err := spanner.NewClient(ctx)
|
|
|
|
if err != nil {
|
|
|
|
// TODO: Handle error.
|
|
|
|
}
|
|
|
|
|
|
|
|
req := &spannerpb.DeleteSessionRequest{
|
2018-01-23 19:40:42 +01:00
|
|
|
// TODO: Fill request struct fields.
|
2017-09-13 14:09:48 +02:00
|
|
|
}
|
|
|
|
err = c.DeleteSession(ctx, req)
|
|
|
|
if err != nil {
|
|
|
|
// TODO: Handle error.
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func ExampleClient_ExecuteSql() {
|
|
|
|
ctx := context.Background()
|
|
|
|
c, err := spanner.NewClient(ctx)
|
|
|
|
if err != nil {
|
|
|
|
// TODO: Handle error.
|
|
|
|
}
|
|
|
|
|
|
|
|
req := &spannerpb.ExecuteSqlRequest{
|
2018-01-23 19:40:42 +01:00
|
|
|
// TODO: Fill request struct fields.
|
2017-09-13 14:09:48 +02:00
|
|
|
}
|
|
|
|
resp, err := c.ExecuteSql(ctx, req)
|
|
|
|
if err != nil {
|
|
|
|
// TODO: Handle error.
|
|
|
|
}
|
|
|
|
// TODO: Use resp.
|
|
|
|
_ = resp
|
|
|
|
}
|
|
|
|
|
|
|
|
func ExampleClient_ExecuteStreamingSql() {
|
|
|
|
ctx := context.Background()
|
|
|
|
c, err := spanner.NewClient(ctx)
|
|
|
|
if err != nil {
|
|
|
|
// TODO: Handle error.
|
|
|
|
}
|
|
|
|
|
|
|
|
req := &spannerpb.ExecuteSqlRequest{
|
2018-01-23 19:40:42 +01:00
|
|
|
// TODO: Fill request struct fields.
|
2017-09-13 14:09:48 +02:00
|
|
|
}
|
|
|
|
stream, err := c.ExecuteStreamingSql(ctx, req)
|
|
|
|
if err != nil {
|
|
|
|
// TODO: Handle error.
|
|
|
|
}
|
|
|
|
for {
|
|
|
|
resp, err := stream.Recv()
|
|
|
|
if err == io.EOF {
|
|
|
|
break
|
|
|
|
}
|
|
|
|
if err != nil {
|
|
|
|
// TODO: handle error.
|
|
|
|
}
|
|
|
|
// TODO: Use resp.
|
|
|
|
_ = resp
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func ExampleClient_Read() {
|
|
|
|
ctx := context.Background()
|
|
|
|
c, err := spanner.NewClient(ctx)
|
|
|
|
if err != nil {
|
|
|
|
// TODO: Handle error.
|
|
|
|
}
|
|
|
|
|
|
|
|
req := &spannerpb.ReadRequest{
|
2018-01-23 19:40:42 +01:00
|
|
|
// TODO: Fill request struct fields.
|
2017-09-13 14:09:48 +02:00
|
|
|
}
|
|
|
|
resp, err := c.Read(ctx, req)
|
|
|
|
if err != nil {
|
|
|
|
// TODO: Handle error.
|
|
|
|
}
|
|
|
|
// TODO: Use resp.
|
|
|
|
_ = resp
|
|
|
|
}
|
|
|
|
|
|
|
|
func ExampleClient_StreamingRead() {
|
|
|
|
ctx := context.Background()
|
|
|
|
c, err := spanner.NewClient(ctx)
|
|
|
|
if err != nil {
|
|
|
|
// TODO: Handle error.
|
|
|
|
}
|
|
|
|
|
|
|
|
req := &spannerpb.ReadRequest{
|
2018-01-23 19:40:42 +01:00
|
|
|
// TODO: Fill request struct fields.
|
2017-09-13 14:09:48 +02:00
|
|
|
}
|
|
|
|
stream, err := c.StreamingRead(ctx, req)
|
|
|
|
if err != nil {
|
|
|
|
// TODO: Handle error.
|
|
|
|
}
|
|
|
|
for {
|
|
|
|
resp, err := stream.Recv()
|
|
|
|
if err == io.EOF {
|
|
|
|
break
|
|
|
|
}
|
|
|
|
if err != nil {
|
|
|
|
// TODO: handle error.
|
|
|
|
}
|
|
|
|
// TODO: Use resp.
|
|
|
|
_ = resp
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func ExampleClient_BeginTransaction() {
|
|
|
|
ctx := context.Background()
|
|
|
|
c, err := spanner.NewClient(ctx)
|
|
|
|
if err != nil {
|
|
|
|
// TODO: Handle error.
|
|
|
|
}
|
|
|
|
|
|
|
|
req := &spannerpb.BeginTransactionRequest{
|
2018-01-23 19:40:42 +01:00
|
|
|
// TODO: Fill request struct fields.
|
2017-09-13 14:09:48 +02:00
|
|
|
}
|
|
|
|
resp, err := c.BeginTransaction(ctx, req)
|
|
|
|
if err != nil {
|
|
|
|
// TODO: Handle error.
|
|
|
|
}
|
|
|
|
// TODO: Use resp.
|
|
|
|
_ = resp
|
|
|
|
}
|
|
|
|
|
|
|
|
func ExampleClient_Commit() {
|
|
|
|
ctx := context.Background()
|
|
|
|
c, err := spanner.NewClient(ctx)
|
|
|
|
if err != nil {
|
|
|
|
// TODO: Handle error.
|
|
|
|
}
|
|
|
|
|
|
|
|
req := &spannerpb.CommitRequest{
|
2018-01-23 19:40:42 +01:00
|
|
|
// TODO: Fill request struct fields.
|
2017-09-13 14:09:48 +02:00
|
|
|
}
|
|
|
|
resp, err := c.Commit(ctx, req)
|
|
|
|
if err != nil {
|
|
|
|
// TODO: Handle error.
|
|
|
|
}
|
|
|
|
// TODO: Use resp.
|
|
|
|
_ = resp
|
|
|
|
}
|
|
|
|
|
|
|
|
func ExampleClient_Rollback() {
|
|
|
|
ctx := context.Background()
|
|
|
|
c, err := spanner.NewClient(ctx)
|
|
|
|
if err != nil {
|
|
|
|
// TODO: Handle error.
|
|
|
|
}
|
|
|
|
|
|
|
|
req := &spannerpb.RollbackRequest{
|
2018-01-23 19:40:42 +01:00
|
|
|
// TODO: Fill request struct fields.
|
2017-09-13 14:09:48 +02:00
|
|
|
}
|
|
|
|
err = c.Rollback(ctx, req)
|
|
|
|
if err != nil {
|
|
|
|
// TODO: Handle error.
|
|
|
|
}
|
|
|
|
}
|