| 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 privatecatalog_test |
| 18 |
|
| 19 |
import ( |
| 20 |
"context" |
| 21 |
|
| 22 |
privatecatalog "cloud.google.com/go/privatecatalog/apiv1beta1" |
| 23 |
privatecatalogpb "cloud.google.com/go/privatecatalog/apiv1beta1/privatecatalogpb" |
| 24 |
"google.golang.org/api/iterator" |
| 25 |
) |
| 26 |
|
| 27 |
func ExampleNewClient() { |
| 28 |
ctx := context.Background() |
| 29 |
// This snippet has been automatically generated and should be regarded as a code template only. |
| 30 |
// It will require modifications to work: |
| 31 |
// - It may require correct/in-range values for request initialization. |
| 32 |
// - It may require specifying regional endpoints when creating the service client as shown in: |
| 33 |
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options |
| 34 |
c, err := privatecatalog.NewClient(ctx) |
| 35 |
if err != nil { |
| 36 |
// TODO: Handle error. |
| 37 |
} |
| 38 |
defer c.Close() |
| 39 |
|
| 40 |
// TODO: Use client. |
| 41 |
_ = c |
| 42 |
} |
| 43 |
|
| 44 |
func ExampleNewRESTClient() { |
| 45 |
ctx := context.Background() |
| 46 |
// This snippet has been automatically generated and should be regarded as a code template only. |
| 47 |
// It will require modifications to work: |
| 48 |
// - It may require correct/in-range values for request initialization. |
| 49 |
// - It may require specifying regional endpoints when creating the service client as shown in: |
| 50 |
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options |
| 51 |
c, err := privatecatalog.NewRESTClient(ctx) |
| 52 |
if err != nil { |
| 53 |
// TODO: Handle error. |
| 54 |
} |
| 55 |
defer c.Close() |
| 56 |
|
| 57 |
// TODO: Use client. |
| 58 |
_ = c |
| 59 |
} |
| 60 |
|
| 61 |
func ExampleClient_SearchCatalogs() { |
| 62 |
ctx := context.Background() |
| 63 |
// This snippet has been automatically generated and should be regarded as a code template only. |
| 64 |
// It will require modifications to work: |
| 65 |
// - It may require correct/in-range values for request initialization. |
| 66 |
// - It may require specifying regional endpoints when creating the service client as shown in: |
| 67 |
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options |
| 68 |
c, err := privatecatalog.NewClient(ctx) |
| 69 |
if err != nil { |
| 70 |
// TODO: Handle error. |
| 71 |
} |
| 72 |
defer c.Close() |
| 73 |
|
| 74 |
req := &privatecatalogpb.SearchCatalogsRequest{ |
| 75 |
// TODO: Fill request struct fields. |
| 76 |
// See https://pkg.go.dev/cloud.google.com/go/privatecatalog/apiv1beta1/privatecatalogpb#SearchCatalogsRequest. |
| 77 |
} |
| 78 |
it := c.SearchCatalogs(ctx, req) |
| 79 |
for { |
| 80 |
resp, err := it.Next() |
| 81 |
if err == iterator.Done { |
| 82 |
break |
| 83 |
} |
| 84 |
if err != nil { |
| 85 |
// TODO: Handle error. |
| 86 |
} |
| 87 |
// TODO: Use resp. |
| 88 |
_ = resp |
| 89 |
|
| 90 |
// If you need to access the underlying RPC response, |
| 91 |
// you can do so by casting the `Response` as below. |
| 92 |
// Otherwise, remove this line. Only populated after |
| 93 |
// first call to Next(). Not safe for concurrent access. |
| 94 |
_ = it.Response.(*privatecatalogpb.SearchCatalogsResponse) |
| 95 |
} |
| 96 |
} |
| 97 |
|
| 98 |
func ExampleClient_SearchProducts() { |
| 99 |
ctx := context.Background() |
| 100 |
// This snippet has been automatically generated and should be regarded as a code template only. |
| 101 |
// It will require modifications to work: |
| 102 |
// - It may require correct/in-range values for request initialization. |
| 103 |
// - It may require specifying regional endpoints when creating the service client as shown in: |
| 104 |
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options |
| 105 |
c, err := privatecatalog.NewClient(ctx) |
| 106 |
if err != nil { |
| 107 |
// TODO: Handle error. |
| 108 |
} |
| 109 |
defer c.Close() |
| 110 |
|
| 111 |
req := &privatecatalogpb.SearchProductsRequest{ |
| 112 |
// TODO: Fill request struct fields. |
| 113 |
// See https://pkg.go.dev/cloud.google.com/go/privatecatalog/apiv1beta1/privatecatalogpb#SearchProductsRequest. |
| 114 |
} |
| 115 |
it := c.SearchProducts(ctx, req) |
| 116 |
for { |
| 117 |
resp, err := it.Next() |
| 118 |
if err == iterator.Done { |
| 119 |
break |
| 120 |
} |
| 121 |
if err != nil { |
| 122 |
// TODO: Handle error. |
| 123 |
} |
| 124 |
// TODO: Use resp. |
| 125 |
_ = resp |
| 126 |
|
| 127 |
// If you need to access the underlying RPC response, |
| 128 |
// you can do so by casting the `Response` as below. |
| 129 |
// Otherwise, remove this line. Only populated after |
| 130 |
// first call to Next(). Not safe for concurrent access. |
| 131 |
_ = it.Response.(*privatecatalogpb.SearchProductsResponse) |
| 132 |
} |
| 133 |
} |
| 134 |
|
| 135 |
func ExampleClient_SearchVersions() { |
| 136 |
ctx := context.Background() |
| 137 |
// This snippet has been automatically generated and should be regarded as a code template only. |
| 138 |
// It will require modifications to work: |
| 139 |
// - It may require correct/in-range values for request initialization. |
| 140 |
// - It may require specifying regional endpoints when creating the service client as shown in: |
| 141 |
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options |
| 142 |
c, err := privatecatalog.NewClient(ctx) |
| 143 |
if err != nil { |
| 144 |
// TODO: Handle error. |
| 145 |
} |
| 146 |
defer c.Close() |
| 147 |
|
| 148 |
req := &privatecatalogpb.SearchVersionsRequest{ |
| 149 |
// TODO: Fill request struct fields. |
| 150 |
// See https://pkg.go.dev/cloud.google.com/go/privatecatalog/apiv1beta1/privatecatalogpb#SearchVersionsRequest. |
| 151 |
} |
| 152 |
it := c.SearchVersions(ctx, req) |
| 153 |
for { |
| 154 |
resp, err := it.Next() |
| 155 |
if err == iterator.Done { |
| 156 |
break |
| 157 |
} |
| 158 |
if err != nil { |
| 159 |
// TODO: Handle error. |
| 160 |
} |
| 161 |
// TODO: Use resp. |
| 162 |
_ = resp |
| 163 |
|
| 164 |
// If you need to access the underlying RPC response, |
| 165 |
// you can do so by casting the `Response` as below. |
| 166 |
// Otherwise, remove this line. Only populated after |
| 167 |
// first call to Next(). Not safe for concurrent access. |
| 168 |
_ = it.Response.(*privatecatalogpb.SearchVersionsResponse) |
| 169 |
} |
| 170 |
} |