1// Copyright 2021 Google LLC 2// 3// Licensed under the Apache License, Version 2.0 (the "License"); 4// you may not use this file except in compliance with the License. 5// You may obtain a copy of the License at 6// 7// https://www.apache.org/licenses/LICENSE-2.0 8// 9// Unless required by applicable law or agreed to in writing, software 10// distributed under the License is distributed on an "AS IS" BASIS, 11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12// See the License for the specific language governing permissions and 13// limitations under the License. 14 15// Code generated by protoc-gen-go_gapic. DO NOT EDIT. 16 17package instance_test 18 19import ( 20 "context" 21 22 instance "cloud.google.com/go/spanner/admin/instance/apiv1" 23 "google.golang.org/api/iterator" 24 iampb "google.golang.org/genproto/googleapis/iam/v1" 25 instancepb "google.golang.org/genproto/googleapis/spanner/admin/instance/v1" 26) 27 28func ExampleNewInstanceAdminClient() { 29 ctx := context.Background() 30 c, err := instance.NewInstanceAdminClient(ctx) 31 if err != nil { 32 // TODO: Handle error. 33 } 34 // TODO: Use client. 35 _ = c 36} 37 38func ExampleInstanceAdminClient_ListInstanceConfigs() { 39 // import instancepb "google.golang.org/genproto/googleapis/spanner/admin/instance/v1" 40 // import "google.golang.org/api/iterator" 41 42 ctx := context.Background() 43 c, err := instance.NewInstanceAdminClient(ctx) 44 if err != nil { 45 // TODO: Handle error. 46 } 47 48 req := &instancepb.ListInstanceConfigsRequest{ 49 // TODO: Fill request struct fields. 50 } 51 it := c.ListInstanceConfigs(ctx, req) 52 for { 53 resp, err := it.Next() 54 if err == iterator.Done { 55 break 56 } 57 if err != nil { 58 // TODO: Handle error. 59 } 60 // TODO: Use resp. 61 _ = resp 62 } 63} 64 65func ExampleInstanceAdminClient_GetInstanceConfig() { 66 // import instancepb "google.golang.org/genproto/googleapis/spanner/admin/instance/v1" 67 68 ctx := context.Background() 69 c, err := instance.NewInstanceAdminClient(ctx) 70 if err != nil { 71 // TODO: Handle error. 72 } 73 74 req := &instancepb.GetInstanceConfigRequest{ 75 // TODO: Fill request struct fields. 76 } 77 resp, err := c.GetInstanceConfig(ctx, req) 78 if err != nil { 79 // TODO: Handle error. 80 } 81 // TODO: Use resp. 82 _ = resp 83} 84 85func ExampleInstanceAdminClient_ListInstances() { 86 // import instancepb "google.golang.org/genproto/googleapis/spanner/admin/instance/v1" 87 // import "google.golang.org/api/iterator" 88 89 ctx := context.Background() 90 c, err := instance.NewInstanceAdminClient(ctx) 91 if err != nil { 92 // TODO: Handle error. 93 } 94 95 req := &instancepb.ListInstancesRequest{ 96 // TODO: Fill request struct fields. 97 } 98 it := c.ListInstances(ctx, req) 99 for { 100 resp, err := it.Next() 101 if err == iterator.Done { 102 break 103 } 104 if err != nil { 105 // TODO: Handle error. 106 } 107 // TODO: Use resp. 108 _ = resp 109 } 110} 111 112func ExampleInstanceAdminClient_GetInstance() { 113 // import instancepb "google.golang.org/genproto/googleapis/spanner/admin/instance/v1" 114 115 ctx := context.Background() 116 c, err := instance.NewInstanceAdminClient(ctx) 117 if err != nil { 118 // TODO: Handle error. 119 } 120 121 req := &instancepb.GetInstanceRequest{ 122 // TODO: Fill request struct fields. 123 } 124 resp, err := c.GetInstance(ctx, req) 125 if err != nil { 126 // TODO: Handle error. 127 } 128 // TODO: Use resp. 129 _ = resp 130} 131 132func ExampleInstanceAdminClient_CreateInstance() { 133 // import instancepb "google.golang.org/genproto/googleapis/spanner/admin/instance/v1" 134 135 ctx := context.Background() 136 c, err := instance.NewInstanceAdminClient(ctx) 137 if err != nil { 138 // TODO: Handle error. 139 } 140 141 req := &instancepb.CreateInstanceRequest{ 142 // TODO: Fill request struct fields. 143 } 144 op, err := c.CreateInstance(ctx, req) 145 if err != nil { 146 // TODO: Handle error. 147 } 148 149 resp, err := op.Wait(ctx) 150 if err != nil { 151 // TODO: Handle error. 152 } 153 // TODO: Use resp. 154 _ = resp 155} 156 157func ExampleInstanceAdminClient_UpdateInstance() { 158 // import instancepb "google.golang.org/genproto/googleapis/spanner/admin/instance/v1" 159 160 ctx := context.Background() 161 c, err := instance.NewInstanceAdminClient(ctx) 162 if err != nil { 163 // TODO: Handle error. 164 } 165 166 req := &instancepb.UpdateInstanceRequest{ 167 // TODO: Fill request struct fields. 168 } 169 op, err := c.UpdateInstance(ctx, req) 170 if err != nil { 171 // TODO: Handle error. 172 } 173 174 resp, err := op.Wait(ctx) 175 if err != nil { 176 // TODO: Handle error. 177 } 178 // TODO: Use resp. 179 _ = resp 180} 181 182func ExampleInstanceAdminClient_DeleteInstance() { 183 ctx := context.Background() 184 c, err := instance.NewInstanceAdminClient(ctx) 185 if err != nil { 186 // TODO: Handle error. 187 } 188 189 req := &instancepb.DeleteInstanceRequest{ 190 // TODO: Fill request struct fields. 191 } 192 err = c.DeleteInstance(ctx, req) 193 if err != nil { 194 // TODO: Handle error. 195 } 196} 197 198func ExampleInstanceAdminClient_SetIamPolicy() { 199 // import iampb "google.golang.org/genproto/googleapis/iam/v1" 200 201 ctx := context.Background() 202 c, err := instance.NewInstanceAdminClient(ctx) 203 if err != nil { 204 // TODO: Handle error. 205 } 206 207 req := &iampb.SetIamPolicyRequest{ 208 // TODO: Fill request struct fields. 209 } 210 resp, err := c.SetIamPolicy(ctx, req) 211 if err != nil { 212 // TODO: Handle error. 213 } 214 // TODO: Use resp. 215 _ = resp 216} 217 218func ExampleInstanceAdminClient_GetIamPolicy() { 219 // import iampb "google.golang.org/genproto/googleapis/iam/v1" 220 221 ctx := context.Background() 222 c, err := instance.NewInstanceAdminClient(ctx) 223 if err != nil { 224 // TODO: Handle error. 225 } 226 227 req := &iampb.GetIamPolicyRequest{ 228 // TODO: Fill request struct fields. 229 } 230 resp, err := c.GetIamPolicy(ctx, req) 231 if err != nil { 232 // TODO: Handle error. 233 } 234 // TODO: Use resp. 235 _ = resp 236} 237 238func ExampleInstanceAdminClient_TestIamPermissions() { 239 // import iampb "google.golang.org/genproto/googleapis/iam/v1" 240 241 ctx := context.Background() 242 c, err := instance.NewInstanceAdminClient(ctx) 243 if err != nil { 244 // TODO: Handle error. 245 } 246 247 req := &iampb.TestIamPermissionsRequest{ 248 // TODO: Fill request struct fields. 249 } 250 resp, err := c.TestIamPermissions(ctx, req) 251 if err != nil { 252 // TODO: Handle error. 253 } 254 // TODO: Use resp. 255 _ = resp 256} 257