| 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 policysimulator_test |
| 18 | |
| 19 | import ( |
| 20 | "context" |
| 21 | |
| 22 | longrunningpb "cloud.google.com/go/longrunning/autogen/longrunningpb" |
| 23 | policysimulator "cloud.google.com/go/policysimulator/apiv1" |
| 24 | policysimulatorpb "cloud.google.com/go/policysimulator/apiv1/policysimulatorpb" |
| 25 | "google.golang.org/api/iterator" |
| 26 | ) |
| 27 | |
| 28 | func ExampleNewSimulatorClient() { |
| 29 | ctx := context.Background() |
| 30 | // This snippet has been automatically generated and should be regarded as a code template only. |
| 31 | // It will require modifications to work: |
| 32 | // - It may require correct/in-range values for request initialization. |
| 33 | // - It may require specifying regional endpoints when creating the service client as shown in: |
| 34 | // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options |
| 35 | c, err := policysimulator.NewSimulatorClient(ctx) |
| 36 | if err != nil { |
| 37 | // TODO: Handle error. |
| 38 | } |
| 39 | defer c.Close() |
| 40 | |
| 41 | // TODO: Use client. |
| 42 | _ = c |
| 43 | } |
| 44 | |
| 45 | func ExampleNewSimulatorRESTClient() { |
| 46 | ctx := context.Background() |
| 47 | // This snippet has been automatically generated and should be regarded as a code template only. |
| 48 | // It will require modifications to work: |
| 49 | // - It may require correct/in-range values for request initialization. |
| 50 | // - It may require specifying regional endpoints when creating the service client as shown in: |
| 51 | // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options |
| 52 | c, err := policysimulator.NewSimulatorRESTClient(ctx) |
| 53 | if err != nil { |
| 54 | // TODO: Handle error. |
| 55 | } |
| 56 | defer c.Close() |
| 57 | |
| 58 | // TODO: Use client. |
| 59 | _ = c |
| 60 | } |
| 61 | |
| 62 | func ExampleSimulatorClient_CreateReplay() { |
| 63 | ctx := context.Background() |
| 64 | // This snippet has been automatically generated and should be regarded as a code template only. |
| 65 | // It will require modifications to work: |
| 66 | // - It may require correct/in-range values for request initialization. |
| 67 | // - It may require specifying regional endpoints when creating the service client as shown in: |
| 68 | // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options |
| 69 | c, err := policysimulator.NewSimulatorClient(ctx) |
| 70 | if err != nil { |
| 71 | // TODO: Handle error. |
| 72 | } |
| 73 | defer c.Close() |
| 74 | |
| 75 | req := &policysimulatorpb.CreateReplayRequest{ |
| 76 | // TODO: Fill request struct fields. |
| 77 | // See https://pkg.go.dev/cloud.google.com/go/policysimulator/apiv1/policysimulatorpb#CreateReplayRequest. |
| 78 | } |
| 79 | op, err := c.CreateReplay(ctx, req) |
| 80 | if err != nil { |
| 81 | // TODO: Handle error. |
| 82 | } |
| 83 | |
| 84 | resp, err := op.Wait(ctx) |
| 85 | if err != nil { |
| 86 | // TODO: Handle error. |
| 87 | } |
| 88 | // TODO: Use resp. |
| 89 | _ = resp |
| 90 | } |
| 91 | |
| 92 | func ExampleSimulatorClient_GetReplay() { |
| 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 := policysimulator.NewSimulatorClient(ctx) |
| 100 | if err != nil { |
| 101 | // TODO: Handle error. |
| 102 | } |
| 103 | defer c.Close() |
| 104 | |
| 105 | req := &policysimulatorpb.GetReplayRequest{ |
| 106 | // TODO: Fill request struct fields. |
| 107 | // See https://pkg.go.dev/cloud.google.com/go/policysimulator/apiv1/policysimulatorpb#GetReplayRequest. |
| 108 | } |
| 109 | resp, err := c.GetReplay(ctx, req) |
| 110 | if err != nil { |
| 111 | // TODO: Handle error. |
| 112 | } |
| 113 | // TODO: Use resp. |
| 114 | _ = resp |
| 115 | } |
| 116 | |
| 117 | func ExampleSimulatorClient_ListReplayResults() { |
| 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 := policysimulator.NewSimulatorClient(ctx) |
| 125 | if err != nil { |
| 126 | // TODO: Handle error. |
| 127 | } |
| 128 | defer c.Close() |
| 129 | |
| 130 | req := &policysimulatorpb.ListReplayResultsRequest{ |
| 131 | // TODO: Fill request struct fields. |
| 132 | // See https://pkg.go.dev/cloud.google.com/go/policysimulator/apiv1/policysimulatorpb#ListReplayResultsRequest. |
| 133 | } |
| 134 | it := c.ListReplayResults(ctx, req) |
| 135 | for { |
| 136 | resp, err := it.Next() |
| 137 | if err == iterator.Done { |
| 138 | break |
| 139 | } |
| 140 | if err != nil { |
| 141 | // TODO: Handle error. |
| 142 | } |
| 143 | // TODO: Use resp. |
| 144 | _ = resp |
| 145 | |
| 146 | // If you need to access the underlying RPC response, |
| 147 | // you can do so by casting the `Response` as below. |
| 148 | // Otherwise, remove this line. Only populated after |
| 149 | // first call to Next(). Not safe for concurrent access. |
| 150 | _ = it.Response.(*policysimulatorpb.ListReplayResultsResponse) |
| 151 | } |
| 152 | } |
| 153 | |
| 154 | func ExampleSimulatorClient_GetOperation() { |
| 155 | ctx := context.Background() |
| 156 | // This snippet has been automatically generated and should be regarded as a code template only. |
| 157 | // It will require modifications to work: |
| 158 | // - It may require correct/in-range values for request initialization. |
| 159 | // - It may require specifying regional endpoints when creating the service client as shown in: |
| 160 | // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options |
| 161 | c, err := policysimulator.NewSimulatorClient(ctx) |
| 162 | if err != nil { |
| 163 | // TODO: Handle error. |
| 164 | } |
| 165 | defer c.Close() |
| 166 | |
| 167 | req := &longrunningpb.GetOperationRequest{ |
| 168 | // TODO: Fill request struct fields. |
| 169 | // See https://pkg.go.dev/cloud.google.com/go/longrunning/autogen/longrunningpb#GetOperationRequest. |
| 170 | } |
| 171 | resp, err := c.GetOperation(ctx, req) |
| 172 | if err != nil { |
| 173 | // TODO: Handle error. |
| 174 | } |
| 175 | // TODO: Use resp. |
| 176 | _ = resp |
| 177 | } |
| 178 | |
| 179 | func ExampleSimulatorClient_ListOperations() { |
| 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 := policysimulator.NewSimulatorClient(ctx) |
| 187 | if err != nil { |
| 188 | // TODO: Handle error. |
| 189 | } |
| 190 | defer c.Close() |
| 191 | |
| 192 | req := &longrunningpb.ListOperationsRequest{ |
| 193 | // TODO: Fill request struct fields. |
| 194 | // See https://pkg.go.dev/cloud.google.com/go/longrunning/autogen/longrunningpb#ListOperationsRequest. |
| 195 | } |
| 196 | it := c.ListOperations(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.(*longrunningpb.ListOperationsResponse) |
| 213 | } |
| 214 | } |