1// Copyright 2021 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 17package compute_test 18 19import ( 20 "context" 21 22 compute "cloud.google.com/go/compute/apiv1" 23 "google.golang.org/api/iterator" 24 computepb "google.golang.org/genproto/googleapis/cloud/compute/v1" 25) 26 27func ExampleNewFirewallPoliciesRESTClient() { 28 ctx := context.Background() 29 c, err := compute.NewFirewallPoliciesRESTClient(ctx) 30 if err != nil { 31 // TODO: Handle error. 32 } 33 defer c.Close() 34 35 // TODO: Use client. 36 _ = c 37} 38 39func ExampleFirewallPoliciesClient_AddAssociation() { 40 ctx := context.Background() 41 c, err := compute.NewFirewallPoliciesRESTClient(ctx) 42 if err != nil { 43 // TODO: Handle error. 44 } 45 defer c.Close() 46 47 req := &computepb.AddAssociationFirewallPolicyRequest{ 48 // TODO: Fill request struct fields. 49 // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#AddAssociationFirewallPolicyRequest. 50 } 51 resp, err := c.AddAssociation(ctx, req) 52 if err != nil { 53 // TODO: Handle error. 54 } 55 // TODO: Use resp. 56 _ = resp 57} 58 59func ExampleFirewallPoliciesClient_AddRule() { 60 ctx := context.Background() 61 c, err := compute.NewFirewallPoliciesRESTClient(ctx) 62 if err != nil { 63 // TODO: Handle error. 64 } 65 defer c.Close() 66 67 req := &computepb.AddRuleFirewallPolicyRequest{ 68 // TODO: Fill request struct fields. 69 // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#AddRuleFirewallPolicyRequest. 70 } 71 resp, err := c.AddRule(ctx, req) 72 if err != nil { 73 // TODO: Handle error. 74 } 75 // TODO: Use resp. 76 _ = resp 77} 78 79func ExampleFirewallPoliciesClient_CloneRules() { 80 ctx := context.Background() 81 c, err := compute.NewFirewallPoliciesRESTClient(ctx) 82 if err != nil { 83 // TODO: Handle error. 84 } 85 defer c.Close() 86 87 req := &computepb.CloneRulesFirewallPolicyRequest{ 88 // TODO: Fill request struct fields. 89 // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#CloneRulesFirewallPolicyRequest. 90 } 91 resp, err := c.CloneRules(ctx, req) 92 if err != nil { 93 // TODO: Handle error. 94 } 95 // TODO: Use resp. 96 _ = resp 97} 98 99func ExampleFirewallPoliciesClient_Delete() { 100 ctx := context.Background() 101 c, err := compute.NewFirewallPoliciesRESTClient(ctx) 102 if err != nil { 103 // TODO: Handle error. 104 } 105 defer c.Close() 106 107 req := &computepb.DeleteFirewallPolicyRequest{ 108 // TODO: Fill request struct fields. 109 // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#DeleteFirewallPolicyRequest. 110 } 111 resp, err := c.Delete(ctx, req) 112 if err != nil { 113 // TODO: Handle error. 114 } 115 // TODO: Use resp. 116 _ = resp 117} 118 119func ExampleFirewallPoliciesClient_Get() { 120 ctx := context.Background() 121 c, err := compute.NewFirewallPoliciesRESTClient(ctx) 122 if err != nil { 123 // TODO: Handle error. 124 } 125 defer c.Close() 126 127 req := &computepb.GetFirewallPolicyRequest{ 128 // TODO: Fill request struct fields. 129 // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#GetFirewallPolicyRequest. 130 } 131 resp, err := c.Get(ctx, req) 132 if err != nil { 133 // TODO: Handle error. 134 } 135 // TODO: Use resp. 136 _ = resp 137} 138 139func ExampleFirewallPoliciesClient_GetAssociation() { 140 ctx := context.Background() 141 c, err := compute.NewFirewallPoliciesRESTClient(ctx) 142 if err != nil { 143 // TODO: Handle error. 144 } 145 defer c.Close() 146 147 req := &computepb.GetAssociationFirewallPolicyRequest{ 148 // TODO: Fill request struct fields. 149 // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#GetAssociationFirewallPolicyRequest. 150 } 151 resp, err := c.GetAssociation(ctx, req) 152 if err != nil { 153 // TODO: Handle error. 154 } 155 // TODO: Use resp. 156 _ = resp 157} 158 159func ExampleFirewallPoliciesClient_GetIamPolicy() { 160 ctx := context.Background() 161 c, err := compute.NewFirewallPoliciesRESTClient(ctx) 162 if err != nil { 163 // TODO: Handle error. 164 } 165 defer c.Close() 166 167 req := &computepb.GetIamPolicyFirewallPolicyRequest{ 168 // TODO: Fill request struct fields. 169 // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#GetIamPolicyFirewallPolicyRequest. 170 } 171 resp, err := c.GetIamPolicy(ctx, req) 172 if err != nil { 173 // TODO: Handle error. 174 } 175 // TODO: Use resp. 176 _ = resp 177} 178 179func ExampleFirewallPoliciesClient_GetRule() { 180 ctx := context.Background() 181 c, err := compute.NewFirewallPoliciesRESTClient(ctx) 182 if err != nil { 183 // TODO: Handle error. 184 } 185 defer c.Close() 186 187 req := &computepb.GetRuleFirewallPolicyRequest{ 188 // TODO: Fill request struct fields. 189 // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#GetRuleFirewallPolicyRequest. 190 } 191 resp, err := c.GetRule(ctx, req) 192 if err != nil { 193 // TODO: Handle error. 194 } 195 // TODO: Use resp. 196 _ = resp 197} 198 199func ExampleFirewallPoliciesClient_Insert() { 200 ctx := context.Background() 201 c, err := compute.NewFirewallPoliciesRESTClient(ctx) 202 if err != nil { 203 // TODO: Handle error. 204 } 205 defer c.Close() 206 207 req := &computepb.InsertFirewallPolicyRequest{ 208 // TODO: Fill request struct fields. 209 // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#InsertFirewallPolicyRequest. 210 } 211 resp, err := c.Insert(ctx, req) 212 if err != nil { 213 // TODO: Handle error. 214 } 215 // TODO: Use resp. 216 _ = resp 217} 218 219func ExampleFirewallPoliciesClient_List() { 220 ctx := context.Background() 221 c, err := compute.NewFirewallPoliciesRESTClient(ctx) 222 if err != nil { 223 // TODO: Handle error. 224 } 225 defer c.Close() 226 227 req := &computepb.ListFirewallPoliciesRequest{ 228 // TODO: Fill request struct fields. 229 // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#ListFirewallPoliciesRequest. 230 } 231 it := c.List(ctx, req) 232 for { 233 resp, err := it.Next() 234 if err == iterator.Done { 235 break 236 } 237 if err != nil { 238 // TODO: Handle error. 239 } 240 // TODO: Use resp. 241 _ = resp 242 } 243} 244 245func ExampleFirewallPoliciesClient_ListAssociations() { 246 ctx := context.Background() 247 c, err := compute.NewFirewallPoliciesRESTClient(ctx) 248 if err != nil { 249 // TODO: Handle error. 250 } 251 defer c.Close() 252 253 req := &computepb.ListAssociationsFirewallPolicyRequest{ 254 // TODO: Fill request struct fields. 255 // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#ListAssociationsFirewallPolicyRequest. 256 } 257 resp, err := c.ListAssociations(ctx, req) 258 if err != nil { 259 // TODO: Handle error. 260 } 261 // TODO: Use resp. 262 _ = resp 263} 264 265func ExampleFirewallPoliciesClient_Move() { 266 ctx := context.Background() 267 c, err := compute.NewFirewallPoliciesRESTClient(ctx) 268 if err != nil { 269 // TODO: Handle error. 270 } 271 defer c.Close() 272 273 req := &computepb.MoveFirewallPolicyRequest{ 274 // TODO: Fill request struct fields. 275 // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#MoveFirewallPolicyRequest. 276 } 277 resp, err := c.Move(ctx, req) 278 if err != nil { 279 // TODO: Handle error. 280 } 281 // TODO: Use resp. 282 _ = resp 283} 284 285func ExampleFirewallPoliciesClient_Patch() { 286 ctx := context.Background() 287 c, err := compute.NewFirewallPoliciesRESTClient(ctx) 288 if err != nil { 289 // TODO: Handle error. 290 } 291 defer c.Close() 292 293 req := &computepb.PatchFirewallPolicyRequest{ 294 // TODO: Fill request struct fields. 295 // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#PatchFirewallPolicyRequest. 296 } 297 resp, err := c.Patch(ctx, req) 298 if err != nil { 299 // TODO: Handle error. 300 } 301 // TODO: Use resp. 302 _ = resp 303} 304 305func ExampleFirewallPoliciesClient_PatchRule() { 306 ctx := context.Background() 307 c, err := compute.NewFirewallPoliciesRESTClient(ctx) 308 if err != nil { 309 // TODO: Handle error. 310 } 311 defer c.Close() 312 313 req := &computepb.PatchRuleFirewallPolicyRequest{ 314 // TODO: Fill request struct fields. 315 // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#PatchRuleFirewallPolicyRequest. 316 } 317 resp, err := c.PatchRule(ctx, req) 318 if err != nil { 319 // TODO: Handle error. 320 } 321 // TODO: Use resp. 322 _ = resp 323} 324 325func ExampleFirewallPoliciesClient_RemoveAssociation() { 326 ctx := context.Background() 327 c, err := compute.NewFirewallPoliciesRESTClient(ctx) 328 if err != nil { 329 // TODO: Handle error. 330 } 331 defer c.Close() 332 333 req := &computepb.RemoveAssociationFirewallPolicyRequest{ 334 // TODO: Fill request struct fields. 335 // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#RemoveAssociationFirewallPolicyRequest. 336 } 337 resp, err := c.RemoveAssociation(ctx, req) 338 if err != nil { 339 // TODO: Handle error. 340 } 341 // TODO: Use resp. 342 _ = resp 343} 344 345func ExampleFirewallPoliciesClient_RemoveRule() { 346 ctx := context.Background() 347 c, err := compute.NewFirewallPoliciesRESTClient(ctx) 348 if err != nil { 349 // TODO: Handle error. 350 } 351 defer c.Close() 352 353 req := &computepb.RemoveRuleFirewallPolicyRequest{ 354 // TODO: Fill request struct fields. 355 // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#RemoveRuleFirewallPolicyRequest. 356 } 357 resp, err := c.RemoveRule(ctx, req) 358 if err != nil { 359 // TODO: Handle error. 360 } 361 // TODO: Use resp. 362 _ = resp 363} 364 365func ExampleFirewallPoliciesClient_SetIamPolicy() { 366 ctx := context.Background() 367 c, err := compute.NewFirewallPoliciesRESTClient(ctx) 368 if err != nil { 369 // TODO: Handle error. 370 } 371 defer c.Close() 372 373 req := &computepb.SetIamPolicyFirewallPolicyRequest{ 374 // TODO: Fill request struct fields. 375 // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#SetIamPolicyFirewallPolicyRequest. 376 } 377 resp, err := c.SetIamPolicy(ctx, req) 378 if err != nil { 379 // TODO: Handle error. 380 } 381 // TODO: Use resp. 382 _ = resp 383} 384 385func ExampleFirewallPoliciesClient_TestIamPermissions() { 386 ctx := context.Background() 387 c, err := compute.NewFirewallPoliciesRESTClient(ctx) 388 if err != nil { 389 // TODO: Handle error. 390 } 391 defer c.Close() 392 393 req := &computepb.TestIamPermissionsFirewallPolicyRequest{ 394 // TODO: Fill request struct fields. 395 // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#TestIamPermissionsFirewallPolicyRequest. 396 } 397 resp, err := c.TestIamPermissions(ctx, req) 398 if err != nil { 399 // TODO: Handle error. 400 } 401 // TODO: Use resp. 402 _ = resp 403} 404