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 migration_test 18 19 import ( 20 "context" 21 22 migration "cloud.google.com/go/bigquery/migration/apiv2" 23 migrationpb "cloud.google.com/go/bigquery/migration/apiv2/migrationpb" 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 := migration.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 ExampleClient_CreateMigrationWorkflow() { 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 := migration.NewClient(ctx) 52 if err != nil { 53 // TODO: Handle error. 54 } 55 defer c.Close() 56 57 req := &migrationpb.CreateMigrationWorkflowRequest{ 58 // TODO: Fill request struct fields. 59 // See https://pkg.go.dev/cloud.google.com/go/bigquery/migration/apiv2/migrationpb#CreateMigrationWorkflowRequest. 60 } 61 resp, err := c.CreateMigrationWorkflow(ctx, req) 62 if err != nil { 63 // TODO: Handle error. 64 } 65 // TODO: Use resp. 66 _ = resp 67 } 68 69 func ExampleClient_DeleteMigrationWorkflow() { 70 ctx := context.Background() 71 // This snippet has been automatically generated and should be regarded as a code template only. 72 // It will require modifications to work: 73 // - It may require correct/in-range values for request initialization. 74 // - It may require specifying regional endpoints when creating the service client as shown in: 75 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 76 c, err := migration.NewClient(ctx) 77 if err != nil { 78 // TODO: Handle error. 79 } 80 defer c.Close() 81 82 req := &migrationpb.DeleteMigrationWorkflowRequest{ 83 // TODO: Fill request struct fields. 84 // See https://pkg.go.dev/cloud.google.com/go/bigquery/migration/apiv2/migrationpb#DeleteMigrationWorkflowRequest. 85 } 86 err = c.DeleteMigrationWorkflow(ctx, req) 87 if err != nil { 88 // TODO: Handle error. 89 } 90 } 91 92 func ExampleClient_GetMigrationSubtask() { 93 ctx := context.Background() 94 // This snippet has been automatically generated and should be regarded as a code template only. 95 // It will require modifications to work: 96 // - It may require correct/in-range values for request initialization. 97 // - It may require specifying regional endpoints when creating the service client as shown in: 98 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 99 c, err := migration.NewClient(ctx) 100 if err != nil { 101 // TODO: Handle error. 102 } 103 defer c.Close() 104 105 req := &migrationpb.GetMigrationSubtaskRequest{ 106 // TODO: Fill request struct fields. 107 // See https://pkg.go.dev/cloud.google.com/go/bigquery/migration/apiv2/migrationpb#GetMigrationSubtaskRequest. 108 } 109 resp, err := c.GetMigrationSubtask(ctx, req) 110 if err != nil { 111 // TODO: Handle error. 112 } 113 // TODO: Use resp. 114 _ = resp 115 } 116 117 func ExampleClient_GetMigrationWorkflow() { 118 ctx := context.Background() 119 // This snippet has been automatically generated and should be regarded as a code template only. 120 // It will require modifications to work: 121 // - It may require correct/in-range values for request initialization. 122 // - It may require specifying regional endpoints when creating the service client as shown in: 123 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 124 c, err := migration.NewClient(ctx) 125 if err != nil { 126 // TODO: Handle error. 127 } 128 defer c.Close() 129 130 req := &migrationpb.GetMigrationWorkflowRequest{ 131 // TODO: Fill request struct fields. 132 // See https://pkg.go.dev/cloud.google.com/go/bigquery/migration/apiv2/migrationpb#GetMigrationWorkflowRequest. 133 } 134 resp, err := c.GetMigrationWorkflow(ctx, req) 135 if err != nil { 136 // TODO: Handle error. 137 } 138 // TODO: Use resp. 139 _ = resp 140 } 141 142 func ExampleClient_ListMigrationSubtasks() { 143 ctx := context.Background() 144 // This snippet has been automatically generated and should be regarded as a code template only. 145 // It will require modifications to work: 146 // - It may require correct/in-range values for request initialization. 147 // - It may require specifying regional endpoints when creating the service client as shown in: 148 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 149 c, err := migration.NewClient(ctx) 150 if err != nil { 151 // TODO: Handle error. 152 } 153 defer c.Close() 154 155 req := &migrationpb.ListMigrationSubtasksRequest{ 156 // TODO: Fill request struct fields. 157 // See https://pkg.go.dev/cloud.google.com/go/bigquery/migration/apiv2/migrationpb#ListMigrationSubtasksRequest. 158 } 159 it := c.ListMigrationSubtasks(ctx, req) 160 for { 161 resp, err := it.Next() 162 if err == iterator.Done { 163 break 164 } 165 if err != nil { 166 // TODO: Handle error. 167 } 168 // TODO: Use resp. 169 _ = resp 170 171 // If you need to access the underlying RPC response, 172 // you can do so by casting the `Response` as below. 173 // Otherwise, remove this line. Only populated after 174 // first call to Next(). Not safe for concurrent access. 175 _ = it.Response.(*migrationpb.ListMigrationSubtasksResponse) 176 } 177 } 178 179 func ExampleClient_ListMigrationWorkflows() { 180 ctx := context.Background() 181 // This snippet has been automatically generated and should be regarded as a code template only. 182 // It will require modifications to work: 183 // - It may require correct/in-range values for request initialization. 184 // - It may require specifying regional endpoints when creating the service client as shown in: 185 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 186 c, err := migration.NewClient(ctx) 187 if err != nil { 188 // TODO: Handle error. 189 } 190 defer c.Close() 191 192 req := &migrationpb.ListMigrationWorkflowsRequest{ 193 // TODO: Fill request struct fields. 194 // See https://pkg.go.dev/cloud.google.com/go/bigquery/migration/apiv2/migrationpb#ListMigrationWorkflowsRequest. 195 } 196 it := c.ListMigrationWorkflows(ctx, req) 197 for { 198 resp, err := it.Next() 199 if err == iterator.Done { 200 break 201 } 202 if err != nil { 203 // TODO: Handle error. 204 } 205 // TODO: Use resp. 206 _ = resp 207 208 // If you need to access the underlying RPC response, 209 // you can do so by casting the `Response` as below. 210 // Otherwise, remove this line. Only populated after 211 // first call to Next(). Not safe for concurrent access. 212 _ = it.Response.(*migrationpb.ListMigrationWorkflowsResponse) 213 } 214 } 215 216 func ExampleClient_StartMigrationWorkflow() { 217 ctx := context.Background() 218 // This snippet has been automatically generated and should be regarded as a code template only. 219 // It will require modifications to work: 220 // - It may require correct/in-range values for request initialization. 221 // - It may require specifying regional endpoints when creating the service client as shown in: 222 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 223 c, err := migration.NewClient(ctx) 224 if err != nil { 225 // TODO: Handle error. 226 } 227 defer c.Close() 228 229 req := &migrationpb.StartMigrationWorkflowRequest{ 230 // TODO: Fill request struct fields. 231 // See https://pkg.go.dev/cloud.google.com/go/bigquery/migration/apiv2/migrationpb#StartMigrationWorkflowRequest. 232 } 233 err = c.StartMigrationWorkflow(ctx, req) 234 if err != nil { 235 // TODO: Handle error. 236 } 237 } 238