...

Source file src/cloud.google.com/go/bigquery/connection/apiv1beta1/connection_client_example_test.go

Documentation: cloud.google.com/go/bigquery/connection/apiv1beta1

     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 connection_test
    18  
    19  import (
    20  	"context"
    21  
    22  	connection "cloud.google.com/go/bigquery/connection/apiv1beta1"
    23  	connectionpb "cloud.google.com/go/bigquery/connection/apiv1beta1/connectionpb"
    24  	iampb "cloud.google.com/go/iam/apiv1/iampb"
    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 := connection.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 := connection.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_CreateConnection() {
    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 := connection.NewClient(ctx)
    69  	if err != nil {
    70  		// TODO: Handle error.
    71  	}
    72  	defer c.Close()
    73  
    74  	req := &connectionpb.CreateConnectionRequest{
    75  		// TODO: Fill request struct fields.
    76  		// See https://pkg.go.dev/cloud.google.com/go/bigquery/connection/apiv1beta1/connectionpb#CreateConnectionRequest.
    77  	}
    78  	resp, err := c.CreateConnection(ctx, req)
    79  	if err != nil {
    80  		// TODO: Handle error.
    81  	}
    82  	// TODO: Use resp.
    83  	_ = resp
    84  }
    85  
    86  func ExampleClient_DeleteConnection() {
    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 := connection.NewClient(ctx)
    94  	if err != nil {
    95  		// TODO: Handle error.
    96  	}
    97  	defer c.Close()
    98  
    99  	req := &connectionpb.DeleteConnectionRequest{
   100  		// TODO: Fill request struct fields.
   101  		// See https://pkg.go.dev/cloud.google.com/go/bigquery/connection/apiv1beta1/connectionpb#DeleteConnectionRequest.
   102  	}
   103  	err = c.DeleteConnection(ctx, req)
   104  	if err != nil {
   105  		// TODO: Handle error.
   106  	}
   107  }
   108  
   109  func ExampleClient_GetConnection() {
   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 := connection.NewClient(ctx)
   117  	if err != nil {
   118  		// TODO: Handle error.
   119  	}
   120  	defer c.Close()
   121  
   122  	req := &connectionpb.GetConnectionRequest{
   123  		// TODO: Fill request struct fields.
   124  		// See https://pkg.go.dev/cloud.google.com/go/bigquery/connection/apiv1beta1/connectionpb#GetConnectionRequest.
   125  	}
   126  	resp, err := c.GetConnection(ctx, req)
   127  	if err != nil {
   128  		// TODO: Handle error.
   129  	}
   130  	// TODO: Use resp.
   131  	_ = resp
   132  }
   133  
   134  func ExampleClient_GetIamPolicy() {
   135  	ctx := context.Background()
   136  	// This snippet has been automatically generated and should be regarded as a code template only.
   137  	// It will require modifications to work:
   138  	// - It may require correct/in-range values for request initialization.
   139  	// - It may require specifying regional endpoints when creating the service client as shown in:
   140  	//   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
   141  	c, err := connection.NewClient(ctx)
   142  	if err != nil {
   143  		// TODO: Handle error.
   144  	}
   145  	defer c.Close()
   146  
   147  	req := &iampb.GetIamPolicyRequest{
   148  		// TODO: Fill request struct fields.
   149  		// See https://pkg.go.dev/cloud.google.com/go/iam/apiv1/iampb#GetIamPolicyRequest.
   150  	}
   151  	resp, err := c.GetIamPolicy(ctx, req)
   152  	if err != nil {
   153  		// TODO: Handle error.
   154  	}
   155  	// TODO: Use resp.
   156  	_ = resp
   157  }
   158  
   159  func ExampleClient_ListConnections() {
   160  	ctx := context.Background()
   161  	// This snippet has been automatically generated and should be regarded as a code template only.
   162  	// It will require modifications to work:
   163  	// - It may require correct/in-range values for request initialization.
   164  	// - It may require specifying regional endpoints when creating the service client as shown in:
   165  	//   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
   166  	c, err := connection.NewClient(ctx)
   167  	if err != nil {
   168  		// TODO: Handle error.
   169  	}
   170  	defer c.Close()
   171  
   172  	req := &connectionpb.ListConnectionsRequest{
   173  		// TODO: Fill request struct fields.
   174  		// See https://pkg.go.dev/cloud.google.com/go/bigquery/connection/apiv1beta1/connectionpb#ListConnectionsRequest.
   175  	}
   176  	resp, err := c.ListConnections(ctx, req)
   177  	if err != nil {
   178  		// TODO: Handle error.
   179  	}
   180  	// TODO: Use resp.
   181  	_ = resp
   182  }
   183  
   184  func ExampleClient_SetIamPolicy() {
   185  	ctx := context.Background()
   186  	// This snippet has been automatically generated and should be regarded as a code template only.
   187  	// It will require modifications to work:
   188  	// - It may require correct/in-range values for request initialization.
   189  	// - It may require specifying regional endpoints when creating the service client as shown in:
   190  	//   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
   191  	c, err := connection.NewClient(ctx)
   192  	if err != nil {
   193  		// TODO: Handle error.
   194  	}
   195  	defer c.Close()
   196  
   197  	req := &iampb.SetIamPolicyRequest{
   198  		// TODO: Fill request struct fields.
   199  		// See https://pkg.go.dev/cloud.google.com/go/iam/apiv1/iampb#SetIamPolicyRequest.
   200  	}
   201  	resp, err := c.SetIamPolicy(ctx, req)
   202  	if err != nil {
   203  		// TODO: Handle error.
   204  	}
   205  	// TODO: Use resp.
   206  	_ = resp
   207  }
   208  
   209  func ExampleClient_TestIamPermissions() {
   210  	ctx := context.Background()
   211  	// This snippet has been automatically generated and should be regarded as a code template only.
   212  	// It will require modifications to work:
   213  	// - It may require correct/in-range values for request initialization.
   214  	// - It may require specifying regional endpoints when creating the service client as shown in:
   215  	//   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
   216  	c, err := connection.NewClient(ctx)
   217  	if err != nil {
   218  		// TODO: Handle error.
   219  	}
   220  	defer c.Close()
   221  
   222  	req := &iampb.TestIamPermissionsRequest{
   223  		// TODO: Fill request struct fields.
   224  		// See https://pkg.go.dev/cloud.google.com/go/iam/apiv1/iampb#TestIamPermissionsRequest.
   225  	}
   226  	resp, err := c.TestIamPermissions(ctx, req)
   227  	if err != nil {
   228  		// TODO: Handle error.
   229  	}
   230  	// TODO: Use resp.
   231  	_ = resp
   232  }
   233  
   234  func ExampleClient_UpdateConnection() {
   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 := connection.NewClient(ctx)
   242  	if err != nil {
   243  		// TODO: Handle error.
   244  	}
   245  	defer c.Close()
   246  
   247  	req := &connectionpb.UpdateConnectionRequest{
   248  		// TODO: Fill request struct fields.
   249  		// See https://pkg.go.dev/cloud.google.com/go/bigquery/connection/apiv1beta1/connectionpb#UpdateConnectionRequest.
   250  	}
   251  	resp, err := c.UpdateConnection(ctx, req)
   252  	if err != nil {
   253  		// TODO: Handle error.
   254  	}
   255  	// TODO: Use resp.
   256  	_ = resp
   257  }
   258  
   259  func ExampleClient_UpdateConnectionCredential() {
   260  	ctx := context.Background()
   261  	// This snippet has been automatically generated and should be regarded as a code template only.
   262  	// It will require modifications to work:
   263  	// - It may require correct/in-range values for request initialization.
   264  	// - It may require specifying regional endpoints when creating the service client as shown in:
   265  	//   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
   266  	c, err := connection.NewClient(ctx)
   267  	if err != nil {
   268  		// TODO: Handle error.
   269  	}
   270  	defer c.Close()
   271  
   272  	req := &connectionpb.UpdateConnectionCredentialRequest{
   273  		// TODO: Fill request struct fields.
   274  		// See https://pkg.go.dev/cloud.google.com/go/bigquery/connection/apiv1beta1/connectionpb#UpdateConnectionCredentialRequest.
   275  	}
   276  	err = c.UpdateConnectionCredential(ctx, req)
   277  	if err != nil {
   278  		// TODO: Handle error.
   279  	}
   280  }
   281  

View as plain text