|
| 1 | +/* |
| 2 | + * Copyright 2026 Google LLC |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * |
| 8 | + * https://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + * See the License for the specific language governing permissions and |
| 14 | + * limitations under the License. |
| 15 | + */ |
| 16 | + |
| 17 | +package com.google.ads.admanager.v1; |
| 18 | + |
| 19 | +import com.google.ads.admanager.v1.stub.DaiSessionServiceStub; |
| 20 | +import com.google.ads.admanager.v1.stub.DaiSessionServiceStubSettings; |
| 21 | +import com.google.api.gax.core.BackgroundResource; |
| 22 | +import com.google.api.gax.rpc.UnaryCallable; |
| 23 | +import java.io.IOException; |
| 24 | +import java.util.concurrent.TimeUnit; |
| 25 | +import javax.annotation.Generated; |
| 26 | +import org.jspecify.annotations.NullMarked; |
| 27 | +import org.jspecify.annotations.Nullable; |
| 28 | + |
| 29 | +// AUTO-GENERATED DOCUMENTATION AND CLASS. |
| 30 | +/** |
| 31 | + * Service Description: Provides methods for handling `DaiSession` objects. |
| 32 | + * |
| 33 | + * <p>This class provides the ability to make remote calls to the backing service through method |
| 34 | + * calls that map to API methods. Sample code to get started: |
| 35 | + * |
| 36 | + * <pre>{@code |
| 37 | + * // This snippet has been automatically generated and should be regarded as a code template only. |
| 38 | + * // It will require modifications to work: |
| 39 | + * // - It may require correct/in-range values for request initialization. |
| 40 | + * // - It may require specifying regional endpoints when creating the service client as shown in |
| 41 | + * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library |
| 42 | + * try (DaiSessionServiceClient daiSessionServiceClient = DaiSessionServiceClient.create()) { |
| 43 | + * DaiSessionName name = DaiSessionName.of("[NETWORK_CODE]", "[DAI_SESSION]"); |
| 44 | + * DaiSession response = daiSessionServiceClient.getDaiSession(name); |
| 45 | + * } |
| 46 | + * }</pre> |
| 47 | + * |
| 48 | + * <p>Note: close() needs to be called on the DaiSessionServiceClient object to clean up resources |
| 49 | + * such as threads. In the example above, try-with-resources is used, which automatically calls |
| 50 | + * close(). |
| 51 | + * |
| 52 | + * <table> |
| 53 | + * <caption>Methods</caption> |
| 54 | + * <tr> |
| 55 | + * <th>Method</th> |
| 56 | + * <th>Description</th> |
| 57 | + * <th>Method Variants</th> |
| 58 | + * </tr> |
| 59 | + * <tr> |
| 60 | + * <td><p> GetDaiSession</td> |
| 61 | + * <td><p> Retrieves a `DaiSession` object.</td> |
| 62 | + * <td> |
| 63 | + * <p>Request object method variants only take one parameter, a request object, which must be constructed before the call.</p> |
| 64 | + * <ul> |
| 65 | + * <li><p> getDaiSession(GetDaiSessionRequest request) |
| 66 | + * </ul> |
| 67 | + * <p>"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.</p> |
| 68 | + * <ul> |
| 69 | + * <li><p> getDaiSession(DaiSessionName name) |
| 70 | + * <li><p> getDaiSession(String name) |
| 71 | + * </ul> |
| 72 | + * <p>Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.</p> |
| 73 | + * <ul> |
| 74 | + * <li><p> getDaiSessionCallable() |
| 75 | + * </ul> |
| 76 | + * </td> |
| 77 | + * </tr> |
| 78 | + * </table> |
| 79 | + * |
| 80 | + * <p>See the individual methods for example code. |
| 81 | + * |
| 82 | + * <p>Many parameters require resource names to be formatted in a particular way. To assist with |
| 83 | + * these names, this class includes a format method for each type of name, and additionally a parse |
| 84 | + * method to extract the individual identifiers contained within names that are returned. |
| 85 | + * |
| 86 | + * <p>This class can be customized by passing in a custom instance of DaiSessionServiceSettings to |
| 87 | + * create(). For example: |
| 88 | + * |
| 89 | + * <p>To customize credentials: |
| 90 | + * |
| 91 | + * <pre>{@code |
| 92 | + * // This snippet has been automatically generated and should be regarded as a code template only. |
| 93 | + * // It will require modifications to work: |
| 94 | + * // - It may require correct/in-range values for request initialization. |
| 95 | + * // - It may require specifying regional endpoints when creating the service client as shown in |
| 96 | + * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library |
| 97 | + * DaiSessionServiceSettings daiSessionServiceSettings = |
| 98 | + * DaiSessionServiceSettings.newBuilder() |
| 99 | + * .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)) |
| 100 | + * .build(); |
| 101 | + * DaiSessionServiceClient daiSessionServiceClient = |
| 102 | + * DaiSessionServiceClient.create(daiSessionServiceSettings); |
| 103 | + * }</pre> |
| 104 | + * |
| 105 | + * <p>To customize the endpoint: |
| 106 | + * |
| 107 | + * <pre>{@code |
| 108 | + * // This snippet has been automatically generated and should be regarded as a code template only. |
| 109 | + * // It will require modifications to work: |
| 110 | + * // - It may require correct/in-range values for request initialization. |
| 111 | + * // - It may require specifying regional endpoints when creating the service client as shown in |
| 112 | + * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library |
| 113 | + * DaiSessionServiceSettings daiSessionServiceSettings = |
| 114 | + * DaiSessionServiceSettings.newBuilder().setEndpoint(myEndpoint).build(); |
| 115 | + * DaiSessionServiceClient daiSessionServiceClient = |
| 116 | + * DaiSessionServiceClient.create(daiSessionServiceSettings); |
| 117 | + * }</pre> |
| 118 | + * |
| 119 | + * <p>Please refer to the GitHub repository's samples for more quickstart code snippets. |
| 120 | + */ |
| 121 | +@NullMarked |
| 122 | +@Generated("by gapic-generator-java") |
| 123 | +public class DaiSessionServiceClient implements BackgroundResource { |
| 124 | + private final @Nullable DaiSessionServiceSettings settings; |
| 125 | + private final DaiSessionServiceStub stub; |
| 126 | + |
| 127 | + /** Constructs an instance of DaiSessionServiceClient with default settings. */ |
| 128 | + public static final DaiSessionServiceClient create() throws IOException { |
| 129 | + return create(DaiSessionServiceSettings.newBuilder().build()); |
| 130 | + } |
| 131 | + |
| 132 | + /** |
| 133 | + * Constructs an instance of DaiSessionServiceClient, using the given settings. The channels are |
| 134 | + * created based on the settings passed in, or defaults for any settings that are not set. |
| 135 | + */ |
| 136 | + public static final DaiSessionServiceClient create(DaiSessionServiceSettings settings) |
| 137 | + throws IOException { |
| 138 | + return new DaiSessionServiceClient(settings); |
| 139 | + } |
| 140 | + |
| 141 | + /** |
| 142 | + * Constructs an instance of DaiSessionServiceClient, using the given stub for making calls. This |
| 143 | + * is for advanced usage - prefer using create(DaiSessionServiceSettings). |
| 144 | + */ |
| 145 | + public static final DaiSessionServiceClient create(DaiSessionServiceStub stub) { |
| 146 | + return new DaiSessionServiceClient(stub); |
| 147 | + } |
| 148 | + |
| 149 | + /** |
| 150 | + * Constructs an instance of DaiSessionServiceClient, using the given settings. This is protected |
| 151 | + * so that it is easy to make a subclass, but otherwise, the static factory methods should be |
| 152 | + * preferred. |
| 153 | + */ |
| 154 | + protected DaiSessionServiceClient(DaiSessionServiceSettings settings) throws IOException { |
| 155 | + this.settings = settings; |
| 156 | + this.stub = ((DaiSessionServiceStubSettings) settings.getStubSettings()).createStub(); |
| 157 | + } |
| 158 | + |
| 159 | + protected DaiSessionServiceClient(DaiSessionServiceStub stub) { |
| 160 | + this.settings = null; |
| 161 | + this.stub = stub; |
| 162 | + } |
| 163 | + |
| 164 | + public final @Nullable DaiSessionServiceSettings getSettings() { |
| 165 | + return settings; |
| 166 | + } |
| 167 | + |
| 168 | + public DaiSessionServiceStub getStub() { |
| 169 | + return stub; |
| 170 | + } |
| 171 | + |
| 172 | + // AUTO-GENERATED DOCUMENTATION AND METHOD. |
| 173 | + /** |
| 174 | + * Retrieves a `DaiSession` object. |
| 175 | + * |
| 176 | + * <p>Sample code: |
| 177 | + * |
| 178 | + * <pre>{@code |
| 179 | + * // This snippet has been automatically generated and should be regarded as a code template only. |
| 180 | + * // It will require modifications to work: |
| 181 | + * // - It may require correct/in-range values for request initialization. |
| 182 | + * // - It may require specifying regional endpoints when creating the service client as shown in |
| 183 | + * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library |
| 184 | + * try (DaiSessionServiceClient daiSessionServiceClient = DaiSessionServiceClient.create()) { |
| 185 | + * DaiSessionName name = DaiSessionName.of("[NETWORK_CODE]", "[DAI_SESSION]"); |
| 186 | + * DaiSession response = daiSessionServiceClient.getDaiSession(name); |
| 187 | + * } |
| 188 | + * }</pre> |
| 189 | + * |
| 190 | + * @param name Required. The resource name of the DaiSession. The dai_session can be either the |
| 191 | + * session ID or debug key, that DAI returns on stream create. For details, see [Locate a DAI |
| 192 | + * session ID or debug key](https://support.google.com/admanager/answer/7257678). |
| 193 | + * <p>Format: `networks/{network_code}/daiSessions/{dai_session}` Format: |
| 194 | + * `networks/{network_code}/daiSessions/{session_id}` Format: |
| 195 | + * `networks/{network_code}/daiSessions/{debug_key}` |
| 196 | + * @throws com.google.api.gax.rpc.ApiException if the remote call fails |
| 197 | + */ |
| 198 | + public final DaiSession getDaiSession(@Nullable DaiSessionName name) { |
| 199 | + GetDaiSessionRequest request = |
| 200 | + GetDaiSessionRequest.newBuilder().setName(name == null ? null : name.toString()).build(); |
| 201 | + return getDaiSession(request); |
| 202 | + } |
| 203 | + |
| 204 | + // AUTO-GENERATED DOCUMENTATION AND METHOD. |
| 205 | + /** |
| 206 | + * Retrieves a `DaiSession` object. |
| 207 | + * |
| 208 | + * <p>Sample code: |
| 209 | + * |
| 210 | + * <pre>{@code |
| 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://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library |
| 216 | + * try (DaiSessionServiceClient daiSessionServiceClient = DaiSessionServiceClient.create()) { |
| 217 | + * String name = DaiSessionName.of("[NETWORK_CODE]", "[DAI_SESSION]").toString(); |
| 218 | + * DaiSession response = daiSessionServiceClient.getDaiSession(name); |
| 219 | + * } |
| 220 | + * }</pre> |
| 221 | + * |
| 222 | + * @param name Required. The resource name of the DaiSession. The dai_session can be either the |
| 223 | + * session ID or debug key, that DAI returns on stream create. For details, see [Locate a DAI |
| 224 | + * session ID or debug key](https://support.google.com/admanager/answer/7257678). |
| 225 | + * <p>Format: `networks/{network_code}/daiSessions/{dai_session}` Format: |
| 226 | + * `networks/{network_code}/daiSessions/{session_id}` Format: |
| 227 | + * `networks/{network_code}/daiSessions/{debug_key}` |
| 228 | + * @throws com.google.api.gax.rpc.ApiException if the remote call fails |
| 229 | + */ |
| 230 | + public final DaiSession getDaiSession(String name) { |
| 231 | + GetDaiSessionRequest request = GetDaiSessionRequest.newBuilder().setName(name).build(); |
| 232 | + return getDaiSession(request); |
| 233 | + } |
| 234 | + |
| 235 | + // AUTO-GENERATED DOCUMENTATION AND METHOD. |
| 236 | + /** |
| 237 | + * Retrieves a `DaiSession` object. |
| 238 | + * |
| 239 | + * <p>Sample code: |
| 240 | + * |
| 241 | + * <pre>{@code |
| 242 | + * // This snippet has been automatically generated and should be regarded as a code template only. |
| 243 | + * // It will require modifications to work: |
| 244 | + * // - It may require correct/in-range values for request initialization. |
| 245 | + * // - It may require specifying regional endpoints when creating the service client as shown in |
| 246 | + * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library |
| 247 | + * try (DaiSessionServiceClient daiSessionServiceClient = DaiSessionServiceClient.create()) { |
| 248 | + * GetDaiSessionRequest request = |
| 249 | + * GetDaiSessionRequest.newBuilder() |
| 250 | + * .setName(DaiSessionName.of("[NETWORK_CODE]", "[DAI_SESSION]").toString()) |
| 251 | + * .build(); |
| 252 | + * DaiSession response = daiSessionServiceClient.getDaiSession(request); |
| 253 | + * } |
| 254 | + * }</pre> |
| 255 | + * |
| 256 | + * @param request The request object containing all of the parameters for the API call. |
| 257 | + * @throws com.google.api.gax.rpc.ApiException if the remote call fails |
| 258 | + */ |
| 259 | + public final DaiSession getDaiSession(GetDaiSessionRequest request) { |
| 260 | + return getDaiSessionCallable().call(request); |
| 261 | + } |
| 262 | + |
| 263 | + // AUTO-GENERATED DOCUMENTATION AND METHOD. |
| 264 | + /** |
| 265 | + * Retrieves a `DaiSession` object. |
| 266 | + * |
| 267 | + * <p>Sample code: |
| 268 | + * |
| 269 | + * <pre>{@code |
| 270 | + * // This snippet has been automatically generated and should be regarded as a code template only. |
| 271 | + * // It will require modifications to work: |
| 272 | + * // - It may require correct/in-range values for request initialization. |
| 273 | + * // - It may require specifying regional endpoints when creating the service client as shown in |
| 274 | + * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library |
| 275 | + * try (DaiSessionServiceClient daiSessionServiceClient = DaiSessionServiceClient.create()) { |
| 276 | + * GetDaiSessionRequest request = |
| 277 | + * GetDaiSessionRequest.newBuilder() |
| 278 | + * .setName(DaiSessionName.of("[NETWORK_CODE]", "[DAI_SESSION]").toString()) |
| 279 | + * .build(); |
| 280 | + * ApiFuture<DaiSession> future = |
| 281 | + * daiSessionServiceClient.getDaiSessionCallable().futureCall(request); |
| 282 | + * // Do something. |
| 283 | + * DaiSession response = future.get(); |
| 284 | + * } |
| 285 | + * }</pre> |
| 286 | + */ |
| 287 | + public final UnaryCallable<GetDaiSessionRequest, DaiSession> getDaiSessionCallable() { |
| 288 | + return stub.getDaiSessionCallable(); |
| 289 | + } |
| 290 | + |
| 291 | + @Override |
| 292 | + public final void close() { |
| 293 | + stub.close(); |
| 294 | + } |
| 295 | + |
| 296 | + @Override |
| 297 | + public void shutdown() { |
| 298 | + stub.shutdown(); |
| 299 | + } |
| 300 | + |
| 301 | + @Override |
| 302 | + public boolean isShutdown() { |
| 303 | + return stub.isShutdown(); |
| 304 | + } |
| 305 | + |
| 306 | + @Override |
| 307 | + public boolean isTerminated() { |
| 308 | + return stub.isTerminated(); |
| 309 | + } |
| 310 | + |
| 311 | + @Override |
| 312 | + public void shutdownNow() { |
| 313 | + stub.shutdownNow(); |
| 314 | + } |
| 315 | + |
| 316 | + @Override |
| 317 | + public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException { |
| 318 | + return stub.awaitTermination(duration, unit); |
| 319 | + } |
| 320 | +} |
0 commit comments