| 1 | // Copyright 2025 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 | |
| 17 | package apigeeregistry_test |
| 18 | |
| 19 | import ( |
| 20 | "context" |
| 21 | |
| 22 | apigeeregistry "cloud.google.com/go/apigeeregistry/apiv1" |
| 23 | apigeeregistrypb "cloud.google.com/go/apigeeregistry/apiv1/apigeeregistrypb" |
| 24 | iampb "cloud.google.com/go/iam/apiv1/iampb" |
| 25 | longrunningpb "cloud.google.com/go/longrunning/autogen/longrunningpb" |
| 26 | "google.golang.org/api/iterator" |
| 27 | locationpb "google.golang.org/genproto/googleapis/cloud/location" |
| 28 | ) |
| 29 | |
| 30 | func ExampleNewProvisioningClient() { |
| 31 | ctx := context.Background() |
| 32 | // This snippet has been automatically generated and should be regarded as a code template only. |
| 33 | // It will require modifications to work: |
| 34 | // - It may require correct/in-range values for request initialization. |
| 35 | // - It may require specifying regional endpoints when creating the service client as shown in: |
| 36 | // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options |
| 37 | c, err := apigeeregistry.NewProvisioningClient(ctx) |
| 38 | if err != nil { |
| 39 | // TODO: Handle error. |
| 40 | } |
| 41 | defer c.Close() |
| 42 | |
| 43 | // TODO: Use client. |
| 44 | _ = c |
| 45 | } |
| 46 | |
| 47 | func ExampleProvisioningClient_CreateInstance() { |
| 48 | ctx := context.Background() |
| 49 | // This snippet has been automatically generated and should be regarded as a code template only. |
| 50 | // It will require modifications to work: |
| 51 | // - It may require correct/in-range values for request initialization. |
| 52 | // - It may require specifying regional endpoints when creating the service client as shown in: |
| 53 | // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options |
| 54 | c, err := apigeeregistry.NewProvisioningClient(ctx) |
| 55 | if err != nil { |
| 56 | // TODO: Handle error. |
| 57 | } |
| 58 | defer c.Close() |
| 59 | |
| 60 | req := &apigeeregistrypb.CreateInstanceRequest{ |
| 61 | // TODO: Fill request struct fields. |
| 62 | // See https://pkg.go.dev/cloud.google.com/go/apigeeregistry/apiv1/apigeeregistrypb#CreateInstanceRequest. |
| 63 | } |
| 64 | op, err := c.CreateInstance(ctx, req) |
| 65 | if err != nil { |
| 66 | // TODO: Handle error. |
| 67 | } |
| 68 | |
| 69 | resp, err := op.Wait(ctx) |
| 70 | if err != nil { |
| 71 | // TODO: Handle error. |
| 72 | } |
| 73 | // TODO: Use resp. |
| 74 | _ = resp |
| 75 | } |
| 76 | |
| 77 | func ExampleProvisioningClient_DeleteInstance() { |
| 78 | ctx := context.Background() |
| 79 | // This snippet has been automatically generated and should be regarded as a code template only. |
| 80 | // It will require modifications to work: |
| 81 | // - It may require correct/in-range values for request initialization. |
| 82 | // - It may require specifying regional endpoints when creating the service client as shown in: |
| 83 | // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options |
| 84 | c, err := apigeeregistry.NewProvisioningClient(ctx) |
| 85 | if err != nil { |
| 86 | // TODO: Handle error. |
| 87 | } |
| 88 | defer c.Close() |
| 89 | |
| 90 | req := &apigeeregistrypb.DeleteInstanceRequest{ |
| 91 | // TODO: Fill request struct fields. |
| 92 | // See https://pkg.go.dev/cloud.google.com/go/apigeeregistry/apiv1/apigeeregistrypb#DeleteInstanceRequest. |
| 93 | } |
| 94 | op, err := c.DeleteInstance(ctx, req) |
| 95 | if err != nil { |
| 96 | // TODO: Handle error. |
| 97 | } |
| 98 | |
| 99 | err = op.Wait(ctx) |
| 100 | if err != nil { |
| 101 | // TODO: Handle error. |
| 102 | } |
| 103 | } |
| 104 | |
| 105 | func ExampleProvisioningClient_GetInstance() { |
| 106 | ctx := context.Background() |
| 107 | // This snippet has been automatically generated and should be regarded as a code template only. |
| 108 | // It will require modifications to work: |
| 109 | // - It may require correct/in-range values for request initialization. |
| 110 | // - It may require specifying regional endpoints when creating the service client as shown in: |
| 111 | // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options |
| 112 | c, err := apigeeregistry.NewProvisioningClient(ctx) |
| 113 | if err != nil { |
| 114 | // TODO: Handle error. |
| 115 | } |
| 116 | defer c.Close() |
| 117 | |
| 118 | req := &apigeeregistrypb.GetInstanceRequest{ |
| 119 | // TODO: Fill request struct fields. |
| 120 | // See https://pkg.go.dev/cloud.google.com/go/apigeeregistry/apiv1/apigeeregistrypb#GetInstanceRequest. |
| 121 | } |
| 122 | resp, err := c.GetInstance(ctx, req) |
| 123 | if err != nil { |
| 124 | // TODO: Handle error. |
| 125 | } |
| 126 | // TODO: Use resp. |
| 127 | _ = resp |
| 128 | } |
| 129 | |
| 130 | func ExampleProvisioningClient_GetLocation() { |
| 131 | ctx := context.Background() |
| 132 | // This snippet has been automatically generated and should be regarded as a code template only. |
| 133 | // It will require modifications to work: |
| 134 | // - It may require correct/in-range values for request initialization. |
| 135 | // - It may require specifying regional endpoints when creating the service client as shown in: |
| 136 | // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options |
| 137 | c, err := apigeeregistry.NewProvisioningClient(ctx) |
| 138 | if err != nil { |
| 139 | // TODO: Handle error. |
| 140 | } |
| 141 | defer c.Close() |
| 142 | |
| 143 | req := &locationpb.GetLocationRequest{ |
| 144 | // TODO: Fill request struct fields. |
| 145 | // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/location#GetLocationRequest. |
| 146 | } |
| 147 | resp, err := c.GetLocation(ctx, req) |
| 148 | if err != nil { |
| 149 | // TODO: Handle error. |
| 150 | } |
| 151 | // TODO: Use resp. |
| 152 | _ = resp |
| 153 | } |
| 154 | |
| 155 | func ExampleProvisioningClient_ListLocations() { |
| 156 | ctx := context.Background() |
| 157 | // This snippet has been automatically generated and should be regarded as a code template only. |
| 158 | // It will require modifications to work: |
| 159 | // - It may require correct/in-range values for request initialization. |
| 160 | // - It may require specifying regional endpoints when creating the service client as shown in: |
| 161 | // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options |
| 162 | c, err := apigeeregistry.NewProvisioningClient(ctx) |
| 163 | if err != nil { |
| 164 | // TODO: Handle error. |
| 165 | } |
| 166 | defer c.Close() |
| 167 | |
| 168 | req := &locationpb.ListLocationsRequest{ |
| 169 | // TODO: Fill request struct fields. |
| 170 | // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/location#ListLocationsRequest. |
| 171 | } |
| 172 | it := c.ListLocations(ctx, req) |
| 173 | for { |
| 174 | resp, err := it.Next() |
| 175 | if err == iterator.Done { |
| 176 | break |
| 177 | } |
| 178 | if err != nil { |
| 179 | // TODO: Handle error. |
| 180 | } |
| 181 | // TODO: Use resp. |
| 182 | _ = resp |
| 183 | |
| 184 | // If you need to access the underlying RPC response, |
| 185 | // you can do so by casting the `Response` as below. |
| 186 | // Otherwise, remove this line. Only populated after |
| 187 | // first call to Next(). Not safe for concurrent access. |
| 188 | _ = it.Response.(*locationpb.ListLocationsResponse) |
| 189 | } |
| 190 | } |
| 191 | |
| 192 | func ExampleProvisioningClient_GetIamPolicy() { |
| 193 | ctx := context.Background() |
| 194 | // This snippet has been automatically generated and should be regarded as a code template only. |
| 195 | // It will require modifications to work: |
| 196 | // - It may require correct/in-range values for request initialization. |
| 197 | // - It may require specifying regional endpoints when creating the service client as shown in: |
| 198 | // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options |
| 199 | c, err := apigeeregistry.NewProvisioningClient(ctx) |
| 200 | if err != nil { |
| 201 | // TODO: Handle error. |
| 202 | } |
| 203 | defer c.Close() |
| 204 | |
| 205 | req := &iampb.GetIamPolicyRequest{ |
| 206 | // TODO: Fill request struct fields. |
| 207 | // See https://pkg.go.dev/cloud.google.com/go/iam/apiv1/iampb#GetIamPolicyRequest. |
| 208 | } |
| 209 | resp, err := c.GetIamPolicy(ctx, req) |
| 210 | if err != nil { |
| 211 | // TODO: Handle error. |
| 212 | } |
| 213 | // TODO: Use resp. |
| 214 | _ = resp |
| 215 | } |
| 216 | |
| 217 | func ExampleProvisioningClient_SetIamPolicy() { |
| 218 | ctx := context.Background() |
| 219 | // This snippet has been automatically generated and should be regarded as a code template only. |
| 220 | // It will require modifications to work: |
| 221 | // - It may require correct/in-range values for request initialization. |
| 222 | // - It may require specifying regional endpoints when creating the service client as shown in: |
| 223 | // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options |
| 224 | c, err := apigeeregistry.NewProvisioningClient(ctx) |
| 225 | if err != nil { |
| 226 | // TODO: Handle error. |
| 227 | } |
| 228 | defer c.Close() |
| 229 | |
| 230 | req := &iampb.SetIamPolicyRequest{ |
| 231 | // TODO: Fill request struct fields. |
| 232 | // See https://pkg.go.dev/cloud.google.com/go/iam/apiv1/iampb#SetIamPolicyRequest. |
| 233 | } |
| 234 | resp, err := c.SetIamPolicy(ctx, req) |
| 235 | if err != nil { |
| 236 | // TODO: Handle error. |
| 237 | } |
| 238 | // TODO: Use resp. |
| 239 | _ = resp |
| 240 | } |
| 241 | |
| 242 | func ExampleProvisioningClient_TestIamPermissions() { |
| 243 | ctx := context.Background() |
| 244 | // This snippet has been automatically generated and should be regarded as a code template only. |
| 245 | // It will require modifications to work: |
| 246 | // - It may require correct/in-range values for request initialization. |
| 247 | // - It may require specifying regional endpoints when creating the service client as shown in: |
| 248 | // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options |
| 249 | c, err := apigeeregistry.NewProvisioningClient(ctx) |
| 250 | if err != nil { |
| 251 | // TODO: Handle error. |
| 252 | } |
| 253 | defer c.Close() |
| 254 | |
| 255 | req := &iampb.TestIamPermissionsRequest{ |
| 256 | // TODO: Fill request struct fields. |
| 257 | // See https://pkg.go.dev/cloud.google.com/go/iam/apiv1/iampb#TestIamPermissionsRequest. |
| 258 | } |
| 259 | resp, err := c.TestIamPermissions(ctx, req) |
| 260 | if err != nil { |
| 261 | // TODO: Handle error. |
| 262 | } |
| 263 | // TODO: Use resp. |
| 264 | _ = resp |
| 265 | } |
| 266 | |
| 267 | func ExampleProvisioningClient_CancelOperation() { |
| 268 | ctx := context.Background() |
| 269 | // This snippet has been automatically generated and should be regarded as a code template only. |
| 270 | // It will require modifications to work: |
| 271 | // - It may require correct/in-range values for request initialization. |
| 272 | // - It may require specifying regional endpoints when creating the service client as shown in: |
| 273 | // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options |
| 274 | c, err := apigeeregistry.NewProvisioningClient(ctx) |
| 275 | if err != nil { |
| 276 | // TODO: Handle error. |
| 277 | } |
| 278 | defer c.Close() |
| 279 | |
| 280 | req := &longrunningpb.CancelOperationRequest{ |
| 281 | // TODO: Fill request struct fields. |
| 282 | // See https://pkg.go.dev/cloud.google.com/go/longrunning/autogen/longrunningpb#CancelOperationRequest. |
| 283 | } |
| 284 | err = c.CancelOperation(ctx, req) |
| 285 | if err != nil { |
| 286 | // TODO: Handle error. |
| 287 | } |
| 288 | } |
| 289 | |
| 290 | func ExampleProvisioningClient_DeleteOperation() { |
| 291 | ctx := context.Background() |
| 292 | // This snippet has been automatically generated and should be regarded as a code template only. |
| 293 | // It will require modifications to work: |
| 294 | // - It may require correct/in-range values for request initialization. |
| 295 | // - It may require specifying regional endpoints when creating the service client as shown in: |
| 296 | // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options |
| 297 | c, err := apigeeregistry.NewProvisioningClient(ctx) |
| 298 | if err != nil { |
| 299 | // TODO: Handle error. |
| 300 | } |
| 301 | defer c.Close() |
| 302 | |
| 303 | req := &longrunningpb.DeleteOperationRequest{ |
| 304 | // TODO: Fill request struct fields. |
| 305 | // See https://pkg.go.dev/cloud.google.com/go/longrunning/autogen/longrunningpb#DeleteOperationRequest. |
| 306 | } |
| 307 | err = c.DeleteOperation(ctx, req) |
| 308 | if err != nil { |
| 309 | // TODO: Handle error. |
| 310 | } |
| 311 | } |
| 312 | |
| 313 | func ExampleProvisioningClient_GetOperation() { |
| 314 | ctx := context.Background() |
| 315 | // This snippet has been automatically generated and should be regarded as a code template only. |
| 316 | // It will require modifications to work: |
| 317 | // - It may require correct/in-range values for request initialization. |
| 318 | // - It may require specifying regional endpoints when creating the service client as shown in: |
| 319 | // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options |
| 320 | c, err := apigeeregistry.NewProvisioningClient(ctx) |
| 321 | if err != nil { |
| 322 | // TODO: Handle error. |
| 323 | } |
| 324 | defer c.Close() |
| 325 | |
| 326 | req := &longrunningpb.GetOperationRequest{ |
| 327 | // TODO: Fill request struct fields. |
| 328 | // See https://pkg.go.dev/cloud.google.com/go/longrunning/autogen/longrunningpb#GetOperationRequest. |
| 329 | } |
| 330 | resp, err := c.GetOperation(ctx, req) |
| 331 | if err != nil { |
| 332 | // TODO: Handle error. |
| 333 | } |
| 334 | // TODO: Use resp. |
| 335 | _ = resp |
| 336 | } |
| 337 | |
| 338 | func ExampleProvisioningClient_ListOperations() { |
| 339 | ctx := context.Background() |
| 340 | // This snippet has been automatically generated and should be regarded as a code template only. |
| 341 | // It will require modifications to work: |
| 342 | // - It may require correct/in-range values for request initialization. |
| 343 | // - It may require specifying regional endpoints when creating the service client as shown in: |
| 344 | // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options |
| 345 | c, err := apigeeregistry.NewProvisioningClient(ctx) |
| 346 | if err != nil { |
| 347 | // TODO: Handle error. |
| 348 | } |
| 349 | defer c.Close() |
| 350 | |
| 351 | req := &longrunningpb.ListOperationsRequest{ |
| 352 | // TODO: Fill request struct fields. |
| 353 | // See https://pkg.go.dev/cloud.google.com/go/longrunning/autogen/longrunningpb#ListOperationsRequest. |
| 354 | } |
| 355 | it := c.ListOperations(ctx, req) |
| 356 | for { |
| 357 | resp, err := it.Next() |
| 358 | if err == iterator.Done { |
| 359 | break |
| 360 | } |
| 361 | if err != nil { |
| 362 | // TODO: Handle error. |
| 363 | } |
| 364 | // TODO: Use resp. |
| 365 | _ = resp |
| 366 | |
| 367 | // If you need to access the underlying RPC response, |
| 368 | // you can do so by casting the `Response` as below. |
| 369 | // Otherwise, remove this line. Only populated after |
| 370 | // first call to Next(). Not safe for concurrent access. |
| 371 | _ = it.Response.(*longrunningpb.ListOperationsResponse) |
| 372 | } |
| 373 | } |