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 resourcemanager_test 18 19 import ( 20 "context" 21 22 iampb "cloud.google.com/go/iam/apiv1/iampb" 23 longrunningpb "cloud.google.com/go/longrunning/autogen/longrunningpb" 24 resourcemanager "cloud.google.com/go/resourcemanager/apiv3" 25 resourcemanagerpb "cloud.google.com/go/resourcemanager/apiv3/resourcemanagerpb" 26 "google.golang.org/api/iterator" 27 ) 28 29 func ExampleNewOrganizationsClient() { 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 := resourcemanager.NewOrganizationsClient(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 ExampleNewOrganizationsRESTClient() { 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 := resourcemanager.NewOrganizationsRESTClient(ctx) 54 if err != nil { 55 // TODO: Handle error. 56 } 57 defer c.Close() 58 59 // TODO: Use client. 60 _ = c 61 } 62 63 func ExampleOrganizationsClient_GetIamPolicy() { 64 ctx := context.Background() 65 // This snippet has been automatically generated and should be regarded as a code template only. 66 // It will require modifications to work: 67 // - It may require correct/in-range values for request initialization. 68 // - It may require specifying regional endpoints when creating the service client as shown in: 69 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 70 c, err := resourcemanager.NewOrganizationsClient(ctx) 71 if err != nil { 72 // TODO: Handle error. 73 } 74 defer c.Close() 75 76 req := &iampb.GetIamPolicyRequest{ 77 // TODO: Fill request struct fields. 78 // See https://pkg.go.dev/cloud.google.com/go/iam/apiv1/iampb#GetIamPolicyRequest. 79 } 80 resp, err := c.GetIamPolicy(ctx, req) 81 if err != nil { 82 // TODO: Handle error. 83 } 84 // TODO: Use resp. 85 _ = resp 86 } 87 88 func ExampleOrganizationsClient_GetOrganization() { 89 ctx := context.Background() 90 // This snippet has been automatically generated and should be regarded as a code template only. 91 // It will require modifications to work: 92 // - It may require correct/in-range values for request initialization. 93 // - It may require specifying regional endpoints when creating the service client as shown in: 94 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 95 c, err := resourcemanager.NewOrganizationsClient(ctx) 96 if err != nil { 97 // TODO: Handle error. 98 } 99 defer c.Close() 100 101 req := &resourcemanagerpb.GetOrganizationRequest{ 102 // TODO: Fill request struct fields. 103 // See https://pkg.go.dev/cloud.google.com/go/resourcemanager/apiv3/resourcemanagerpb#GetOrganizationRequest. 104 } 105 resp, err := c.GetOrganization(ctx, req) 106 if err != nil { 107 // TODO: Handle error. 108 } 109 // TODO: Use resp. 110 _ = resp 111 } 112 113 func ExampleOrganizationsClient_SearchOrganizations() { 114 ctx := context.Background() 115 // This snippet has been automatically generated and should be regarded as a code template only. 116 // It will require modifications to work: 117 // - It may require correct/in-range values for request initialization. 118 // - It may require specifying regional endpoints when creating the service client as shown in: 119 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 120 c, err := resourcemanager.NewOrganizationsClient(ctx) 121 if err != nil { 122 // TODO: Handle error. 123 } 124 defer c.Close() 125 126 req := &resourcemanagerpb.SearchOrganizationsRequest{ 127 // TODO: Fill request struct fields. 128 // See https://pkg.go.dev/cloud.google.com/go/resourcemanager/apiv3/resourcemanagerpb#SearchOrganizationsRequest. 129 } 130 it := c.SearchOrganizations(ctx, req) 131 for { 132 resp, err := it.Next() 133 if err == iterator.Done { 134 break 135 } 136 if err != nil { 137 // TODO: Handle error. 138 } 139 // TODO: Use resp. 140 _ = resp 141 142 // If you need to access the underlying RPC response, 143 // you can do so by casting the `Response` as below. 144 // Otherwise, remove this line. Only populated after 145 // first call to Next(). Not safe for concurrent access. 146 _ = it.Response.(*resourcemanagerpb.SearchOrganizationsResponse) 147 } 148 } 149 150 func ExampleOrganizationsClient_SetIamPolicy() { 151 ctx := context.Background() 152 // This snippet has been automatically generated and should be regarded as a code template only. 153 // It will require modifications to work: 154 // - It may require correct/in-range values for request initialization. 155 // - It may require specifying regional endpoints when creating the service client as shown in: 156 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 157 c, err := resourcemanager.NewOrganizationsClient(ctx) 158 if err != nil { 159 // TODO: Handle error. 160 } 161 defer c.Close() 162 163 req := &iampb.SetIamPolicyRequest{ 164 // TODO: Fill request struct fields. 165 // See https://pkg.go.dev/cloud.google.com/go/iam/apiv1/iampb#SetIamPolicyRequest. 166 } 167 resp, err := c.SetIamPolicy(ctx, req) 168 if err != nil { 169 // TODO: Handle error. 170 } 171 // TODO: Use resp. 172 _ = resp 173 } 174 175 func ExampleOrganizationsClient_TestIamPermissions() { 176 ctx := context.Background() 177 // This snippet has been automatically generated and should be regarded as a code template only. 178 // It will require modifications to work: 179 // - It may require correct/in-range values for request initialization. 180 // - It may require specifying regional endpoints when creating the service client as shown in: 181 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 182 c, err := resourcemanager.NewOrganizationsClient(ctx) 183 if err != nil { 184 // TODO: Handle error. 185 } 186 defer c.Close() 187 188 req := &iampb.TestIamPermissionsRequest{ 189 // TODO: Fill request struct fields. 190 // See https://pkg.go.dev/cloud.google.com/go/iam/apiv1/iampb#TestIamPermissionsRequest. 191 } 192 resp, err := c.TestIamPermissions(ctx, req) 193 if err != nil { 194 // TODO: Handle error. 195 } 196 // TODO: Use resp. 197 _ = resp 198 } 199 200 func ExampleOrganizationsClient_GetOperation() { 201 ctx := context.Background() 202 // This snippet has been automatically generated and should be regarded as a code template only. 203 // It will require modifications to work: 204 // - It may require correct/in-range values for request initialization. 205 // - It may require specifying regional endpoints when creating the service client as shown in: 206 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 207 c, err := resourcemanager.NewOrganizationsClient(ctx) 208 if err != nil { 209 // TODO: Handle error. 210 } 211 defer c.Close() 212 213 req := &longrunningpb.GetOperationRequest{ 214 // TODO: Fill request struct fields. 215 // See https://pkg.go.dev/cloud.google.com/go/longrunning/autogen/longrunningpb#GetOperationRequest. 216 } 217 resp, err := c.GetOperation(ctx, req) 218 if err != nil { 219 // TODO: Handle error. 220 } 221 // TODO: Use resp. 222 _ = resp 223 } 224