...

Source file src/cloud.google.com/go/storage/internal/apiv2/storage_client_example_test.go

Documentation: cloud.google.com/go/storage/internal/apiv2

     1  // Copyright 2024 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 storage_test
    18  
    19  import (
    20  	"context"
    21  	"io"
    22  
    23  	iampb "cloud.google.com/go/iam/apiv1/iampb"
    24  	storage "cloud.google.com/go/storage/internal/apiv2"
    25  	storagepb "cloud.google.com/go/storage/internal/apiv2/storagepb"
    26  	"google.golang.org/api/iterator"
    27  )
    28  
    29  func ExampleNewClient() {
    30  	ctx := context.Background()
    31  	// This snippet has been automatically generated and should be regarded as a code template only.
    32  	// It will require modifications to work:
    33  	// - It may require correct/in-range values for request initialization.
    34  	// - It may require specifying regional endpoints when creating the service client as shown in:
    35  	//   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
    36  	c, err := storage.NewClient(ctx)
    37  	if err != nil {
    38  		// TODO: Handle error.
    39  	}
    40  	defer c.Close()
    41  
    42  	// TODO: Use client.
    43  	_ = c
    44  }
    45  
    46  func ExampleClient_BidiWriteObject() {
    47  	ctx := context.Background()
    48  	// This snippet has been automatically generated and should be regarded as a code template only.
    49  	// It will require modifications to work:
    50  	// - It may require correct/in-range values for request initialization.
    51  	// - It may require specifying regional endpoints when creating the service client as shown in:
    52  	//   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
    53  	c, err := storage.NewClient(ctx)
    54  	if err != nil {
    55  		// TODO: Handle error.
    56  	}
    57  	defer c.Close()
    58  	stream, err := c.BidiWriteObject(ctx)
    59  	if err != nil {
    60  		// TODO: Handle error.
    61  	}
    62  	go func() {
    63  		reqs := []*storagepb.BidiWriteObjectRequest{
    64  			// TODO: Create requests.
    65  		}
    66  		for _, req := range reqs {
    67  			if err := stream.Send(req); err != nil {
    68  				// TODO: Handle error.
    69  			}
    70  		}
    71  		stream.CloseSend()
    72  	}()
    73  	for {
    74  		resp, err := stream.Recv()
    75  		if err == io.EOF {
    76  			break
    77  		}
    78  		if err != nil {
    79  			// TODO: handle error.
    80  		}
    81  		// TODO: Use resp.
    82  		_ = resp
    83  	}
    84  }
    85  
    86  func ExampleClient_CancelResumableWrite() {
    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 := storage.NewClient(ctx)
    94  	if err != nil {
    95  		// TODO: Handle error.
    96  	}
    97  	defer c.Close()
    98  
    99  	req := &storagepb.CancelResumableWriteRequest{
   100  		// TODO: Fill request struct fields.
   101  		// See https://pkg.go.dev/cloud.google.com/go/storage/internal/apiv2/storagepb#CancelResumableWriteRequest.
   102  	}
   103  	resp, err := c.CancelResumableWrite(ctx, req)
   104  	if err != nil {
   105  		// TODO: Handle error.
   106  	}
   107  	// TODO: Use resp.
   108  	_ = resp
   109  }
   110  
   111  func ExampleClient_ComposeObject() {
   112  	ctx := context.Background()
   113  	// This snippet has been automatically generated and should be regarded as a code template only.
   114  	// It will require modifications to work:
   115  	// - It may require correct/in-range values for request initialization.
   116  	// - It may require specifying regional endpoints when creating the service client as shown in:
   117  	//   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
   118  	c, err := storage.NewClient(ctx)
   119  	if err != nil {
   120  		// TODO: Handle error.
   121  	}
   122  	defer c.Close()
   123  
   124  	req := &storagepb.ComposeObjectRequest{
   125  		// TODO: Fill request struct fields.
   126  		// See https://pkg.go.dev/cloud.google.com/go/storage/internal/apiv2/storagepb#ComposeObjectRequest.
   127  	}
   128  	resp, err := c.ComposeObject(ctx, req)
   129  	if err != nil {
   130  		// TODO: Handle error.
   131  	}
   132  	// TODO: Use resp.
   133  	_ = resp
   134  }
   135  
   136  func ExampleClient_CreateBucket() {
   137  	ctx := context.Background()
   138  	// This snippet has been automatically generated and should be regarded as a code template only.
   139  	// It will require modifications to work:
   140  	// - It may require correct/in-range values for request initialization.
   141  	// - It may require specifying regional endpoints when creating the service client as shown in:
   142  	//   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
   143  	c, err := storage.NewClient(ctx)
   144  	if err != nil {
   145  		// TODO: Handle error.
   146  	}
   147  	defer c.Close()
   148  
   149  	req := &storagepb.CreateBucketRequest{
   150  		// TODO: Fill request struct fields.
   151  		// See https://pkg.go.dev/cloud.google.com/go/storage/internal/apiv2/storagepb#CreateBucketRequest.
   152  	}
   153  	resp, err := c.CreateBucket(ctx, req)
   154  	if err != nil {
   155  		// TODO: Handle error.
   156  	}
   157  	// TODO: Use resp.
   158  	_ = resp
   159  }
   160  
   161  func ExampleClient_CreateHmacKey() {
   162  	ctx := context.Background()
   163  	// This snippet has been automatically generated and should be regarded as a code template only.
   164  	// It will require modifications to work:
   165  	// - It may require correct/in-range values for request initialization.
   166  	// - It may require specifying regional endpoints when creating the service client as shown in:
   167  	//   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
   168  	c, err := storage.NewClient(ctx)
   169  	if err != nil {
   170  		// TODO: Handle error.
   171  	}
   172  	defer c.Close()
   173  
   174  	req := &storagepb.CreateHmacKeyRequest{
   175  		// TODO: Fill request struct fields.
   176  		// See https://pkg.go.dev/cloud.google.com/go/storage/internal/apiv2/storagepb#CreateHmacKeyRequest.
   177  	}
   178  	resp, err := c.CreateHmacKey(ctx, req)
   179  	if err != nil {
   180  		// TODO: Handle error.
   181  	}
   182  	// TODO: Use resp.
   183  	_ = resp
   184  }
   185  
   186  func ExampleClient_CreateNotificationConfig() {
   187  	ctx := context.Background()
   188  	// This snippet has been automatically generated and should be regarded as a code template only.
   189  	// It will require modifications to work:
   190  	// - It may require correct/in-range values for request initialization.
   191  	// - It may require specifying regional endpoints when creating the service client as shown in:
   192  	//   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
   193  	c, err := storage.NewClient(ctx)
   194  	if err != nil {
   195  		// TODO: Handle error.
   196  	}
   197  	defer c.Close()
   198  
   199  	req := &storagepb.CreateNotificationConfigRequest{
   200  		// TODO: Fill request struct fields.
   201  		// See https://pkg.go.dev/cloud.google.com/go/storage/internal/apiv2/storagepb#CreateNotificationConfigRequest.
   202  	}
   203  	resp, err := c.CreateNotificationConfig(ctx, req)
   204  	if err != nil {
   205  		// TODO: Handle error.
   206  	}
   207  	// TODO: Use resp.
   208  	_ = resp
   209  }
   210  
   211  func ExampleClient_DeleteBucket() {
   212  	ctx := context.Background()
   213  	// This snippet has been automatically generated and should be regarded as a code template only.
   214  	// It will require modifications to work:
   215  	// - It may require correct/in-range values for request initialization.
   216  	// - It may require specifying regional endpoints when creating the service client as shown in:
   217  	//   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
   218  	c, err := storage.NewClient(ctx)
   219  	if err != nil {
   220  		// TODO: Handle error.
   221  	}
   222  	defer c.Close()
   223  
   224  	req := &storagepb.DeleteBucketRequest{
   225  		// TODO: Fill request struct fields.
   226  		// See https://pkg.go.dev/cloud.google.com/go/storage/internal/apiv2/storagepb#DeleteBucketRequest.
   227  	}
   228  	err = c.DeleteBucket(ctx, req)
   229  	if err != nil {
   230  		// TODO: Handle error.
   231  	}
   232  }
   233  
   234  func ExampleClient_DeleteHmacKey() {
   235  	ctx := context.Background()
   236  	// This snippet has been automatically generated and should be regarded as a code template only.
   237  	// It will require modifications to work:
   238  	// - It may require correct/in-range values for request initialization.
   239  	// - It may require specifying regional endpoints when creating the service client as shown in:
   240  	//   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
   241  	c, err := storage.NewClient(ctx)
   242  	if err != nil {
   243  		// TODO: Handle error.
   244  	}
   245  	defer c.Close()
   246  
   247  	req := &storagepb.DeleteHmacKeyRequest{
   248  		// TODO: Fill request struct fields.
   249  		// See https://pkg.go.dev/cloud.google.com/go/storage/internal/apiv2/storagepb#DeleteHmacKeyRequest.
   250  	}
   251  	err = c.DeleteHmacKey(ctx, req)
   252  	if err != nil {
   253  		// TODO: Handle error.
   254  	}
   255  }
   256  
   257  func ExampleClient_DeleteNotificationConfig() {
   258  	ctx := context.Background()
   259  	// This snippet has been automatically generated and should be regarded as a code template only.
   260  	// It will require modifications to work:
   261  	// - It may require correct/in-range values for request initialization.
   262  	// - It may require specifying regional endpoints when creating the service client as shown in:
   263  	//   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
   264  	c, err := storage.NewClient(ctx)
   265  	if err != nil {
   266  		// TODO: Handle error.
   267  	}
   268  	defer c.Close()
   269  
   270  	req := &storagepb.DeleteNotificationConfigRequest{
   271  		// TODO: Fill request struct fields.
   272  		// See https://pkg.go.dev/cloud.google.com/go/storage/internal/apiv2/storagepb#DeleteNotificationConfigRequest.
   273  	}
   274  	err = c.DeleteNotificationConfig(ctx, req)
   275  	if err != nil {
   276  		// TODO: Handle error.
   277  	}
   278  }
   279  
   280  func ExampleClient_DeleteObject() {
   281  	ctx := context.Background()
   282  	// This snippet has been automatically generated and should be regarded as a code template only.
   283  	// It will require modifications to work:
   284  	// - It may require correct/in-range values for request initialization.
   285  	// - It may require specifying regional endpoints when creating the service client as shown in:
   286  	//   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
   287  	c, err := storage.NewClient(ctx)
   288  	if err != nil {
   289  		// TODO: Handle error.
   290  	}
   291  	defer c.Close()
   292  
   293  	req := &storagepb.DeleteObjectRequest{
   294  		// TODO: Fill request struct fields.
   295  		// See https://pkg.go.dev/cloud.google.com/go/storage/internal/apiv2/storagepb#DeleteObjectRequest.
   296  	}
   297  	err = c.DeleteObject(ctx, req)
   298  	if err != nil {
   299  		// TODO: Handle error.
   300  	}
   301  }
   302  
   303  func ExampleClient_GetBucket() {
   304  	ctx := context.Background()
   305  	// This snippet has been automatically generated and should be regarded as a code template only.
   306  	// It will require modifications to work:
   307  	// - It may require correct/in-range values for request initialization.
   308  	// - It may require specifying regional endpoints when creating the service client as shown in:
   309  	//   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
   310  	c, err := storage.NewClient(ctx)
   311  	if err != nil {
   312  		// TODO: Handle error.
   313  	}
   314  	defer c.Close()
   315  
   316  	req := &storagepb.GetBucketRequest{
   317  		// TODO: Fill request struct fields.
   318  		// See https://pkg.go.dev/cloud.google.com/go/storage/internal/apiv2/storagepb#GetBucketRequest.
   319  	}
   320  	resp, err := c.GetBucket(ctx, req)
   321  	if err != nil {
   322  		// TODO: Handle error.
   323  	}
   324  	// TODO: Use resp.
   325  	_ = resp
   326  }
   327  
   328  func ExampleClient_GetHmacKey() {
   329  	ctx := context.Background()
   330  	// This snippet has been automatically generated and should be regarded as a code template only.
   331  	// It will require modifications to work:
   332  	// - It may require correct/in-range values for request initialization.
   333  	// - It may require specifying regional endpoints when creating the service client as shown in:
   334  	//   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
   335  	c, err := storage.NewClient(ctx)
   336  	if err != nil {
   337  		// TODO: Handle error.
   338  	}
   339  	defer c.Close()
   340  
   341  	req := &storagepb.GetHmacKeyRequest{
   342  		// TODO: Fill request struct fields.
   343  		// See https://pkg.go.dev/cloud.google.com/go/storage/internal/apiv2/storagepb#GetHmacKeyRequest.
   344  	}
   345  	resp, err := c.GetHmacKey(ctx, req)
   346  	if err != nil {
   347  		// TODO: Handle error.
   348  	}
   349  	// TODO: Use resp.
   350  	_ = resp
   351  }
   352  
   353  func ExampleClient_GetIamPolicy() {
   354  	ctx := context.Background()
   355  	// This snippet has been automatically generated and should be regarded as a code template only.
   356  	// It will require modifications to work:
   357  	// - It may require correct/in-range values for request initialization.
   358  	// - It may require specifying regional endpoints when creating the service client as shown in:
   359  	//   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
   360  	c, err := storage.NewClient(ctx)
   361  	if err != nil {
   362  		// TODO: Handle error.
   363  	}
   364  	defer c.Close()
   365  
   366  	req := &iampb.GetIamPolicyRequest{
   367  		// TODO: Fill request struct fields.
   368  		// See https://pkg.go.dev/cloud.google.com/go/iam/apiv1/iampb#GetIamPolicyRequest.
   369  	}
   370  	resp, err := c.GetIamPolicy(ctx, req)
   371  	if err != nil {
   372  		// TODO: Handle error.
   373  	}
   374  	// TODO: Use resp.
   375  	_ = resp
   376  }
   377  
   378  func ExampleClient_GetNotificationConfig() {
   379  	ctx := context.Background()
   380  	// This snippet has been automatically generated and should be regarded as a code template only.
   381  	// It will require modifications to work:
   382  	// - It may require correct/in-range values for request initialization.
   383  	// - It may require specifying regional endpoints when creating the service client as shown in:
   384  	//   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
   385  	c, err := storage.NewClient(ctx)
   386  	if err != nil {
   387  		// TODO: Handle error.
   388  	}
   389  	defer c.Close()
   390  
   391  	req := &storagepb.GetNotificationConfigRequest{
   392  		// TODO: Fill request struct fields.
   393  		// See https://pkg.go.dev/cloud.google.com/go/storage/internal/apiv2/storagepb#GetNotificationConfigRequest.
   394  	}
   395  	resp, err := c.GetNotificationConfig(ctx, req)
   396  	if err != nil {
   397  		// TODO: Handle error.
   398  	}
   399  	// TODO: Use resp.
   400  	_ = resp
   401  }
   402  
   403  func ExampleClient_GetObject() {
   404  	ctx := context.Background()
   405  	// This snippet has been automatically generated and should be regarded as a code template only.
   406  	// It will require modifications to work:
   407  	// - It may require correct/in-range values for request initialization.
   408  	// - It may require specifying regional endpoints when creating the service client as shown in:
   409  	//   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
   410  	c, err := storage.NewClient(ctx)
   411  	if err != nil {
   412  		// TODO: Handle error.
   413  	}
   414  	defer c.Close()
   415  
   416  	req := &storagepb.GetObjectRequest{
   417  		// TODO: Fill request struct fields.
   418  		// See https://pkg.go.dev/cloud.google.com/go/storage/internal/apiv2/storagepb#GetObjectRequest.
   419  	}
   420  	resp, err := c.GetObject(ctx, req)
   421  	if err != nil {
   422  		// TODO: Handle error.
   423  	}
   424  	// TODO: Use resp.
   425  	_ = resp
   426  }
   427  
   428  func ExampleClient_GetServiceAccount() {
   429  	ctx := context.Background()
   430  	// This snippet has been automatically generated and should be regarded as a code template only.
   431  	// It will require modifications to work:
   432  	// - It may require correct/in-range values for request initialization.
   433  	// - It may require specifying regional endpoints when creating the service client as shown in:
   434  	//   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
   435  	c, err := storage.NewClient(ctx)
   436  	if err != nil {
   437  		// TODO: Handle error.
   438  	}
   439  	defer c.Close()
   440  
   441  	req := &storagepb.GetServiceAccountRequest{
   442  		// TODO: Fill request struct fields.
   443  		// See https://pkg.go.dev/cloud.google.com/go/storage/internal/apiv2/storagepb#GetServiceAccountRequest.
   444  	}
   445  	resp, err := c.GetServiceAccount(ctx, req)
   446  	if err != nil {
   447  		// TODO: Handle error.
   448  	}
   449  	// TODO: Use resp.
   450  	_ = resp
   451  }
   452  
   453  func ExampleClient_ListBuckets() {
   454  	ctx := context.Background()
   455  	// This snippet has been automatically generated and should be regarded as a code template only.
   456  	// It will require modifications to work:
   457  	// - It may require correct/in-range values for request initialization.
   458  	// - It may require specifying regional endpoints when creating the service client as shown in:
   459  	//   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
   460  	c, err := storage.NewClient(ctx)
   461  	if err != nil {
   462  		// TODO: Handle error.
   463  	}
   464  	defer c.Close()
   465  
   466  	req := &storagepb.ListBucketsRequest{
   467  		// TODO: Fill request struct fields.
   468  		// See https://pkg.go.dev/cloud.google.com/go/storage/internal/apiv2/storagepb#ListBucketsRequest.
   469  	}
   470  	it := c.ListBuckets(ctx, req)
   471  	for {
   472  		resp, err := it.Next()
   473  		if err == iterator.Done {
   474  			break
   475  		}
   476  		if err != nil {
   477  			// TODO: Handle error.
   478  		}
   479  		// TODO: Use resp.
   480  		_ = resp
   481  
   482  		// If you need to access the underlying RPC response,
   483  		// you can do so by casting the `Response` as below.
   484  		// Otherwise, remove this line. Only populated after
   485  		// first call to Next(). Not safe for concurrent access.
   486  		_ = it.Response.(*storagepb.ListBucketsResponse)
   487  	}
   488  }
   489  
   490  func ExampleClient_ListHmacKeys() {
   491  	ctx := context.Background()
   492  	// This snippet has been automatically generated and should be regarded as a code template only.
   493  	// It will require modifications to work:
   494  	// - It may require correct/in-range values for request initialization.
   495  	// - It may require specifying regional endpoints when creating the service client as shown in:
   496  	//   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
   497  	c, err := storage.NewClient(ctx)
   498  	if err != nil {
   499  		// TODO: Handle error.
   500  	}
   501  	defer c.Close()
   502  
   503  	req := &storagepb.ListHmacKeysRequest{
   504  		// TODO: Fill request struct fields.
   505  		// See https://pkg.go.dev/cloud.google.com/go/storage/internal/apiv2/storagepb#ListHmacKeysRequest.
   506  	}
   507  	it := c.ListHmacKeys(ctx, req)
   508  	for {
   509  		resp, err := it.Next()
   510  		if err == iterator.Done {
   511  			break
   512  		}
   513  		if err != nil {
   514  			// TODO: Handle error.
   515  		}
   516  		// TODO: Use resp.
   517  		_ = resp
   518  
   519  		// If you need to access the underlying RPC response,
   520  		// you can do so by casting the `Response` as below.
   521  		// Otherwise, remove this line. Only populated after
   522  		// first call to Next(). Not safe for concurrent access.
   523  		_ = it.Response.(*storagepb.ListHmacKeysResponse)
   524  	}
   525  }
   526  
   527  func ExampleClient_ListNotificationConfigs() {
   528  	ctx := context.Background()
   529  	// This snippet has been automatically generated and should be regarded as a code template only.
   530  	// It will require modifications to work:
   531  	// - It may require correct/in-range values for request initialization.
   532  	// - It may require specifying regional endpoints when creating the service client as shown in:
   533  	//   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
   534  	c, err := storage.NewClient(ctx)
   535  	if err != nil {
   536  		// TODO: Handle error.
   537  	}
   538  	defer c.Close()
   539  
   540  	req := &storagepb.ListNotificationConfigsRequest{
   541  		// TODO: Fill request struct fields.
   542  		// See https://pkg.go.dev/cloud.google.com/go/storage/internal/apiv2/storagepb#ListNotificationConfigsRequest.
   543  	}
   544  	it := c.ListNotificationConfigs(ctx, req)
   545  	for {
   546  		resp, err := it.Next()
   547  		if err == iterator.Done {
   548  			break
   549  		}
   550  		if err != nil {
   551  			// TODO: Handle error.
   552  		}
   553  		// TODO: Use resp.
   554  		_ = resp
   555  
   556  		// If you need to access the underlying RPC response,
   557  		// you can do so by casting the `Response` as below.
   558  		// Otherwise, remove this line. Only populated after
   559  		// first call to Next(). Not safe for concurrent access.
   560  		_ = it.Response.(*storagepb.ListNotificationConfigsResponse)
   561  	}
   562  }
   563  
   564  func ExampleClient_ListObjects() {
   565  	ctx := context.Background()
   566  	// This snippet has been automatically generated and should be regarded as a code template only.
   567  	// It will require modifications to work:
   568  	// - It may require correct/in-range values for request initialization.
   569  	// - It may require specifying regional endpoints when creating the service client as shown in:
   570  	//   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
   571  	c, err := storage.NewClient(ctx)
   572  	if err != nil {
   573  		// TODO: Handle error.
   574  	}
   575  	defer c.Close()
   576  
   577  	req := &storagepb.ListObjectsRequest{
   578  		// TODO: Fill request struct fields.
   579  		// See https://pkg.go.dev/cloud.google.com/go/storage/internal/apiv2/storagepb#ListObjectsRequest.
   580  	}
   581  	it := c.ListObjects(ctx, req)
   582  	for {
   583  		resp, err := it.Next()
   584  		if err == iterator.Done {
   585  			break
   586  		}
   587  		if err != nil {
   588  			// TODO: Handle error.
   589  		}
   590  		// TODO: Use resp.
   591  		_ = resp
   592  
   593  		// If you need to access the underlying RPC response,
   594  		// you can do so by casting the `Response` as below.
   595  		// Otherwise, remove this line. Only populated after
   596  		// first call to Next(). Not safe for concurrent access.
   597  		_ = it.Response.(*storagepb.ListObjectsResponse)
   598  	}
   599  }
   600  
   601  func ExampleClient_LockBucketRetentionPolicy() {
   602  	ctx := context.Background()
   603  	// This snippet has been automatically generated and should be regarded as a code template only.
   604  	// It will require modifications to work:
   605  	// - It may require correct/in-range values for request initialization.
   606  	// - It may require specifying regional endpoints when creating the service client as shown in:
   607  	//   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
   608  	c, err := storage.NewClient(ctx)
   609  	if err != nil {
   610  		// TODO: Handle error.
   611  	}
   612  	defer c.Close()
   613  
   614  	req := &storagepb.LockBucketRetentionPolicyRequest{
   615  		// TODO: Fill request struct fields.
   616  		// See https://pkg.go.dev/cloud.google.com/go/storage/internal/apiv2/storagepb#LockBucketRetentionPolicyRequest.
   617  	}
   618  	resp, err := c.LockBucketRetentionPolicy(ctx, req)
   619  	if err != nil {
   620  		// TODO: Handle error.
   621  	}
   622  	// TODO: Use resp.
   623  	_ = resp
   624  }
   625  
   626  func ExampleClient_QueryWriteStatus() {
   627  	ctx := context.Background()
   628  	// This snippet has been automatically generated and should be regarded as a code template only.
   629  	// It will require modifications to work:
   630  	// - It may require correct/in-range values for request initialization.
   631  	// - It may require specifying regional endpoints when creating the service client as shown in:
   632  	//   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
   633  	c, err := storage.NewClient(ctx)
   634  	if err != nil {
   635  		// TODO: Handle error.
   636  	}
   637  	defer c.Close()
   638  
   639  	req := &storagepb.QueryWriteStatusRequest{
   640  		// TODO: Fill request struct fields.
   641  		// See https://pkg.go.dev/cloud.google.com/go/storage/internal/apiv2/storagepb#QueryWriteStatusRequest.
   642  	}
   643  	resp, err := c.QueryWriteStatus(ctx, req)
   644  	if err != nil {
   645  		// TODO: Handle error.
   646  	}
   647  	// TODO: Use resp.
   648  	_ = resp
   649  }
   650  
   651  func ExampleClient_RestoreObject() {
   652  	ctx := context.Background()
   653  	// This snippet has been automatically generated and should be regarded as a code template only.
   654  	// It will require modifications to work:
   655  	// - It may require correct/in-range values for request initialization.
   656  	// - It may require specifying regional endpoints when creating the service client as shown in:
   657  	//   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
   658  	c, err := storage.NewClient(ctx)
   659  	if err != nil {
   660  		// TODO: Handle error.
   661  	}
   662  	defer c.Close()
   663  
   664  	req := &storagepb.RestoreObjectRequest{
   665  		// TODO: Fill request struct fields.
   666  		// See https://pkg.go.dev/cloud.google.com/go/storage/internal/apiv2/storagepb#RestoreObjectRequest.
   667  	}
   668  	resp, err := c.RestoreObject(ctx, req)
   669  	if err != nil {
   670  		// TODO: Handle error.
   671  	}
   672  	// TODO: Use resp.
   673  	_ = resp
   674  }
   675  
   676  func ExampleClient_RewriteObject() {
   677  	ctx := context.Background()
   678  	// This snippet has been automatically generated and should be regarded as a code template only.
   679  	// It will require modifications to work:
   680  	// - It may require correct/in-range values for request initialization.
   681  	// - It may require specifying regional endpoints when creating the service client as shown in:
   682  	//   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
   683  	c, err := storage.NewClient(ctx)
   684  	if err != nil {
   685  		// TODO: Handle error.
   686  	}
   687  	defer c.Close()
   688  
   689  	req := &storagepb.RewriteObjectRequest{
   690  		// TODO: Fill request struct fields.
   691  		// See https://pkg.go.dev/cloud.google.com/go/storage/internal/apiv2/storagepb#RewriteObjectRequest.
   692  	}
   693  	resp, err := c.RewriteObject(ctx, req)
   694  	if err != nil {
   695  		// TODO: Handle error.
   696  	}
   697  	// TODO: Use resp.
   698  	_ = resp
   699  }
   700  
   701  func ExampleClient_SetIamPolicy() {
   702  	ctx := context.Background()
   703  	// This snippet has been automatically generated and should be regarded as a code template only.
   704  	// It will require modifications to work:
   705  	// - It may require correct/in-range values for request initialization.
   706  	// - It may require specifying regional endpoints when creating the service client as shown in:
   707  	//   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
   708  	c, err := storage.NewClient(ctx)
   709  	if err != nil {
   710  		// TODO: Handle error.
   711  	}
   712  	defer c.Close()
   713  
   714  	req := &iampb.SetIamPolicyRequest{
   715  		// TODO: Fill request struct fields.
   716  		// See https://pkg.go.dev/cloud.google.com/go/iam/apiv1/iampb#SetIamPolicyRequest.
   717  	}
   718  	resp, err := c.SetIamPolicy(ctx, req)
   719  	if err != nil {
   720  		// TODO: Handle error.
   721  	}
   722  	// TODO: Use resp.
   723  	_ = resp
   724  }
   725  
   726  func ExampleClient_StartResumableWrite() {
   727  	ctx := context.Background()
   728  	// This snippet has been automatically generated and should be regarded as a code template only.
   729  	// It will require modifications to work:
   730  	// - It may require correct/in-range values for request initialization.
   731  	// - It may require specifying regional endpoints when creating the service client as shown in:
   732  	//   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
   733  	c, err := storage.NewClient(ctx)
   734  	if err != nil {
   735  		// TODO: Handle error.
   736  	}
   737  	defer c.Close()
   738  
   739  	req := &storagepb.StartResumableWriteRequest{
   740  		// TODO: Fill request struct fields.
   741  		// See https://pkg.go.dev/cloud.google.com/go/storage/internal/apiv2/storagepb#StartResumableWriteRequest.
   742  	}
   743  	resp, err := c.StartResumableWrite(ctx, req)
   744  	if err != nil {
   745  		// TODO: Handle error.
   746  	}
   747  	// TODO: Use resp.
   748  	_ = resp
   749  }
   750  
   751  func ExampleClient_TestIamPermissions() {
   752  	ctx := context.Background()
   753  	// This snippet has been automatically generated and should be regarded as a code template only.
   754  	// It will require modifications to work:
   755  	// - It may require correct/in-range values for request initialization.
   756  	// - It may require specifying regional endpoints when creating the service client as shown in:
   757  	//   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
   758  	c, err := storage.NewClient(ctx)
   759  	if err != nil {
   760  		// TODO: Handle error.
   761  	}
   762  	defer c.Close()
   763  
   764  	req := &iampb.TestIamPermissionsRequest{
   765  		// TODO: Fill request struct fields.
   766  		// See https://pkg.go.dev/cloud.google.com/go/iam/apiv1/iampb#TestIamPermissionsRequest.
   767  	}
   768  	resp, err := c.TestIamPermissions(ctx, req)
   769  	if err != nil {
   770  		// TODO: Handle error.
   771  	}
   772  	// TODO: Use resp.
   773  	_ = resp
   774  }
   775  
   776  func ExampleClient_UpdateBucket() {
   777  	ctx := context.Background()
   778  	// This snippet has been automatically generated and should be regarded as a code template only.
   779  	// It will require modifications to work:
   780  	// - It may require correct/in-range values for request initialization.
   781  	// - It may require specifying regional endpoints when creating the service client as shown in:
   782  	//   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
   783  	c, err := storage.NewClient(ctx)
   784  	if err != nil {
   785  		// TODO: Handle error.
   786  	}
   787  	defer c.Close()
   788  
   789  	req := &storagepb.UpdateBucketRequest{
   790  		// TODO: Fill request struct fields.
   791  		// See https://pkg.go.dev/cloud.google.com/go/storage/internal/apiv2/storagepb#UpdateBucketRequest.
   792  	}
   793  	resp, err := c.UpdateBucket(ctx, req)
   794  	if err != nil {
   795  		// TODO: Handle error.
   796  	}
   797  	// TODO: Use resp.
   798  	_ = resp
   799  }
   800  
   801  func ExampleClient_UpdateHmacKey() {
   802  	ctx := context.Background()
   803  	// This snippet has been automatically generated and should be regarded as a code template only.
   804  	// It will require modifications to work:
   805  	// - It may require correct/in-range values for request initialization.
   806  	// - It may require specifying regional endpoints when creating the service client as shown in:
   807  	//   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
   808  	c, err := storage.NewClient(ctx)
   809  	if err != nil {
   810  		// TODO: Handle error.
   811  	}
   812  	defer c.Close()
   813  
   814  	req := &storagepb.UpdateHmacKeyRequest{
   815  		// TODO: Fill request struct fields.
   816  		// See https://pkg.go.dev/cloud.google.com/go/storage/internal/apiv2/storagepb#UpdateHmacKeyRequest.
   817  	}
   818  	resp, err := c.UpdateHmacKey(ctx, req)
   819  	if err != nil {
   820  		// TODO: Handle error.
   821  	}
   822  	// TODO: Use resp.
   823  	_ = resp
   824  }
   825  
   826  func ExampleClient_UpdateObject() {
   827  	ctx := context.Background()
   828  	// This snippet has been automatically generated and should be regarded as a code template only.
   829  	// It will require modifications to work:
   830  	// - It may require correct/in-range values for request initialization.
   831  	// - It may require specifying regional endpoints when creating the service client as shown in:
   832  	//   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
   833  	c, err := storage.NewClient(ctx)
   834  	if err != nil {
   835  		// TODO: Handle error.
   836  	}
   837  	defer c.Close()
   838  
   839  	req := &storagepb.UpdateObjectRequest{
   840  		// TODO: Fill request struct fields.
   841  		// See https://pkg.go.dev/cloud.google.com/go/storage/internal/apiv2/storagepb#UpdateObjectRequest.
   842  	}
   843  	resp, err := c.UpdateObject(ctx, req)
   844  	if err != nil {
   845  		// TODO: Handle error.
   846  	}
   847  	// TODO: Use resp.
   848  	_ = resp
   849  }
   850  

View as plain text