| 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 datasources_test |
| 18 |
|
| 19 |
import ( |
| 20 |
"context" |
| 21 |
|
| 22 |
datasources "cloud.google.com/go/shopping/merchant/datasources/apiv1" |
| 23 |
datasourcespb "cloud.google.com/go/shopping/merchant/datasources/apiv1/datasourcespb" |
| 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 := datasources.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 := datasources.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_CreateDataSource() { |
| 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 := datasources.NewClient(ctx) |
| 69 |
if err != nil { |
| 70 |
// TODO: Handle error. |
| 71 |
} |
| 72 |
defer c.Close() |
| 73 |
|
| 74 |
req := &datasourcespb.CreateDataSourceRequest{ |
| 75 |
// TODO: Fill request struct fields. |
| 76 |
// See https://pkg.go.dev/cloud.google.com/go/shopping/merchant/datasources/apiv1/datasourcespb#CreateDataSourceRequest. |
| 77 |
} |
| 78 |
resp, err := c.CreateDataSource(ctx, req) |
| 79 |
if err != nil { |
| 80 |
// TODO: Handle error. |
| 81 |
} |
| 82 |
// TODO: Use resp. |
| 83 |
_ = resp |
| 84 |
} |
| 85 |
|
| 86 |
func ExampleClient_DeleteDataSource() { |
| 87 |
ctx := context.Background() |
| 88 |
// This snippet has been automatically generated and should be regarded as a code template only. |
| 89 |
// It will require modifications to work: |
| 90 |
// - It may require correct/in-range values for request initialization. |
| 91 |
// - It may require specifying regional endpoints when creating the service client as shown in: |
| 92 |
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options |
| 93 |
c, err := datasources.NewClient(ctx) |
| 94 |
if err != nil { |
| 95 |
// TODO: Handle error. |
| 96 |
} |
| 97 |
defer c.Close() |
| 98 |
|
| 99 |
req := &datasourcespb.DeleteDataSourceRequest{ |
| 100 |
// TODO: Fill request struct fields. |
| 101 |
// See https://pkg.go.dev/cloud.google.com/go/shopping/merchant/datasources/apiv1/datasourcespb#DeleteDataSourceRequest. |
| 102 |
} |
| 103 |
err = c.DeleteDataSource(ctx, req) |
| 104 |
if err != nil { |
| 105 |
// TODO: Handle error. |
| 106 |
} |
| 107 |
} |
| 108 |
|
| 109 |
func ExampleClient_FetchDataSource() { |
| 110 |
ctx := context.Background() |
| 111 |
// This snippet has been automatically generated and should be regarded as a code template only. |
| 112 |
// It will require modifications to work: |
| 113 |
// - It may require correct/in-range values for request initialization. |
| 114 |
// - It may require specifying regional endpoints when creating the service client as shown in: |
| 115 |
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options |
| 116 |
c, err := datasources.NewClient(ctx) |
| 117 |
if err != nil { |
| 118 |
// TODO: Handle error. |
| 119 |
} |
| 120 |
defer c.Close() |
| 121 |
|
| 122 |
req := &datasourcespb.FetchDataSourceRequest{ |
| 123 |
// TODO: Fill request struct fields. |
| 124 |
// See https://pkg.go.dev/cloud.google.com/go/shopping/merchant/datasources/apiv1/datasourcespb#FetchDataSourceRequest. |
| 125 |
} |
| 126 |
err = c.FetchDataSource(ctx, req) |
| 127 |
if err != nil { |
| 128 |
// TODO: Handle error. |
| 129 |
} |
| 130 |
} |
| 131 |
|
| 132 |
func ExampleClient_GetDataSource() { |
| 133 |
ctx := context.Background() |
| 134 |
// This snippet has been automatically generated and should be regarded as a code template only. |
| 135 |
// It will require modifications to work: |
| 136 |
// - It may require correct/in-range values for request initialization. |
| 137 |
// - It may require specifying regional endpoints when creating the service client as shown in: |
| 138 |
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options |
| 139 |
c, err := datasources.NewClient(ctx) |
| 140 |
if err != nil { |
| 141 |
// TODO: Handle error. |
| 142 |
} |
| 143 |
defer c.Close() |
| 144 |
|
| 145 |
req := &datasourcespb.GetDataSourceRequest{ |
| 146 |
// TODO: Fill request struct fields. |
| 147 |
// See https://pkg.go.dev/cloud.google.com/go/shopping/merchant/datasources/apiv1/datasourcespb#GetDataSourceRequest. |
| 148 |
} |
| 149 |
resp, err := c.GetDataSource(ctx, req) |
| 150 |
if err != nil { |
| 151 |
// TODO: Handle error. |
| 152 |
} |
| 153 |
// TODO: Use resp. |
| 154 |
_ = resp |
| 155 |
} |
| 156 |
|
| 157 |
func ExampleClient_ListDataSources() { |
| 158 |
ctx := context.Background() |
| 159 |
// This snippet has been automatically generated and should be regarded as a code template only. |
| 160 |
// It will require modifications to work: |
| 161 |
// - It may require correct/in-range values for request initialization. |
| 162 |
// - It may require specifying regional endpoints when creating the service client as shown in: |
| 163 |
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options |
| 164 |
c, err := datasources.NewClient(ctx) |
| 165 |
if err != nil { |
| 166 |
// TODO: Handle error. |
| 167 |
} |
| 168 |
defer c.Close() |
| 169 |
|
| 170 |
req := &datasourcespb.ListDataSourcesRequest{ |
| 171 |
// TODO: Fill request struct fields. |
| 172 |
// See https://pkg.go.dev/cloud.google.com/go/shopping/merchant/datasources/apiv1/datasourcespb#ListDataSourcesRequest. |
| 173 |
} |
| 174 |
it := c.ListDataSources(ctx, req) |
| 175 |
for { |
| 176 |
resp, err := it.Next() |
| 177 |
if err == iterator.Done { |
| 178 |
break |
| 179 |
} |
| 180 |
if err != nil { |
| 181 |
// TODO: Handle error. |
| 182 |
} |
| 183 |
// TODO: Use resp. |
| 184 |
_ = resp |
| 185 |
|
| 186 |
// If you need to access the underlying RPC response, |
| 187 |
// you can do so by casting the `Response` as below. |
| 188 |
// Otherwise, remove this line. Only populated after |
| 189 |
// first call to Next(). Not safe for concurrent access. |
| 190 |
_ = it.Response.(*datasourcespb.ListDataSourcesResponse) |
| 191 |
} |
| 192 |
} |
| 193 |
|
| 194 |
func ExampleClient_UpdateDataSource() { |
| 195 |
ctx := context.Background() |
| 196 |
// This snippet has been automatically generated and should be regarded as a code template only. |
| 197 |
// It will require modifications to work: |
| 198 |
// - It may require correct/in-range values for request initialization. |
| 199 |
// - It may require specifying regional endpoints when creating the service client as shown in: |
| 200 |
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options |
| 201 |
c, err := datasources.NewClient(ctx) |
| 202 |
if err != nil { |
| 203 |
// TODO: Handle error. |
| 204 |
} |
| 205 |
defer c.Close() |
| 206 |
|
| 207 |
req := &datasourcespb.UpdateDataSourceRequest{ |
| 208 |
// TODO: Fill request struct fields. |
| 209 |
// See https://pkg.go.dev/cloud.google.com/go/shopping/merchant/datasources/apiv1/datasourcespb#UpdateDataSourceRequest. |
| 210 |
} |
| 211 |
resp, err := c.UpdateDataSource(ctx, req) |
| 212 |
if err != nil { |
| 213 |
// TODO: Handle error. |
| 214 |
} |
| 215 |
// TODO: Use resp. |
| 216 |
_ = resp |
| 217 |
} |