google-cloud-dialogflow-v2 0.3.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (28) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +48 -1
  3. data/lib/google-cloud-dialogflow-v2.rb +21 -1
  4. data/lib/google/cloud/dialogflow/v2.rb +16 -0
  5. data/lib/google/cloud/dialogflow/v2/agents.rb +58 -2
  6. data/lib/google/cloud/dialogflow/v2/agents/client.rb +88 -65
  7. data/lib/google/cloud/dialogflow/v2/agents/operations.rb +39 -33
  8. data/lib/google/cloud/dialogflow/v2/contexts.rb +47 -1
  9. data/lib/google/cloud/dialogflow/v2/contexts/client.rb +62 -39
  10. data/lib/google/cloud/dialogflow/v2/contexts/paths.rb +43 -0
  11. data/lib/google/cloud/dialogflow/v2/entity_types.rb +58 -2
  12. data/lib/google/cloud/dialogflow/v2/entity_types/client.rb +103 -65
  13. data/lib/google/cloud/dialogflow/v2/entity_types/operations.rb +39 -33
  14. data/lib/google/cloud/dialogflow/v2/entity_types/paths.rb +14 -0
  15. data/lib/google/cloud/dialogflow/v2/intents.rb +62 -2
  16. data/lib/google/cloud/dialogflow/v2/intents/client.rb +74 -47
  17. data/lib/google/cloud/dialogflow/v2/intents/operations.rb +39 -33
  18. data/lib/google/cloud/dialogflow/v2/intents/paths.rb +14 -0
  19. data/lib/google/cloud/dialogflow/v2/session_entity_types.rb +46 -1
  20. data/lib/google/cloud/dialogflow/v2/session_entity_types/client.rb +48 -53
  21. data/lib/google/cloud/dialogflow/v2/session_entity_types/paths.rb +43 -0
  22. data/lib/google/cloud/dialogflow/v2/sessions.rb +33 -1
  23. data/lib/google/cloud/dialogflow/v2/sessions/client.rb +15 -28
  24. data/lib/google/cloud/dialogflow/v2/version.rb +1 -1
  25. data/proto_docs/google/cloud/dialogflow/v2/agent.rb +0 -2
  26. data/proto_docs/google/cloud/dialogflow/v2/context.rb +1 -1
  27. data/proto_docs/google/cloud/dialogflow/v2/session.rb +28 -1
  28. metadata +2 -2
@@ -16,11 +16,7 @@
16
16
 
17
17
  # Auto-generated by gapic-generator-ruby. DO NOT EDIT!
18
18
 
19
- require "gapic/common"
20
19
  require "gapic/operation"
21
-
22
- require "google/cloud/dialogflow/v2/version"
23
- require "google/cloud/dialogflow/v2/agents/client"
24
20
  require "google/longrunning/operations_pb"
25
21
 
26
22
  module Google
@@ -109,16 +105,20 @@ module Google
109
105
  # to use different resource name schemes, such as `users/*/operations`.
110
106
  #
111
107
  # @overload list_operations(request, options = nil)
112
- # @param request [Google::Longrunning::ListOperationsRequest | Hash]
113
- # Lists operations that match the specified filter in the request. If the
114
- # server doesn't support this method, it returns `UNIMPLEMENTED`.
108
+ # Pass arguments to `list_operations` via a request object, either of type
109
+ # {Google::Longrunning::ListOperationsRequest} or an equivalent Hash.
115
110
  #
116
- # NOTE: the `name` binding below allows API services to override the binding
117
- # to use different resource name schemes, such as `users/*/operations`.
111
+ # @param request [Google::Longrunning::ListOperationsRequest, Hash]
112
+ # A request object representing the call parameters. Required. To specify no
113
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
118
114
  # @param options [Gapic::CallOptions, Hash]
119
115
  # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
120
116
  #
121
117
  # @overload list_operations(name: nil, filter: nil, page_size: nil, page_token: nil)
118
+ # Pass arguments to `list_operations` via keyword arguments. Note that at
119
+ # least one keyword argument is required. To specify no parameters, or to keep all
120
+ # the default parameter values, pass an empty Hash as a request object (see above).
121
+ #
122
122
  # @param name [String]
123
123
  # The name of the operation collection.
124
124
  # @param filter [String]
@@ -128,7 +128,6 @@ module Google
128
128
  # @param page_token [String]
129
129
  # The standard list page token.
130
130
  #
131
- #
132
131
  # @yield [response, operation] Access the result along with the RPC operation
133
132
  # @yieldparam response [Gapic::PagedEnumerable<Gapic::Operation>]
134
133
  # @yieldparam operation [GRPC::ActiveCall::Operation]
@@ -182,18 +181,23 @@ module Google
182
181
  # service.
183
182
  #
184
183
  # @overload get_operation(request, options = nil)
185
- # @param request [Google::Longrunning::GetOperationRequest | Hash]
186
- # Gets the latest state of a long-running operation. Clients can use this
187
- # method to poll the operation result at intervals as recommended by the API
188
- # service.
184
+ # Pass arguments to `get_operation` via a request object, either of type
185
+ # {Google::Longrunning::GetOperationRequest} or an equivalent Hash.
186
+ #
187
+ # @param request [Google::Longrunning::GetOperationRequest, Hash]
188
+ # A request object representing the call parameters. Required. To specify no
189
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
189
190
  # @param options [Gapic::CallOptions, Hash]
190
191
  # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
191
192
  #
192
193
  # @overload get_operation(name: nil)
194
+ # Pass arguments to `get_operation` via keyword arguments. Note that at
195
+ # least one keyword argument is required. To specify no parameters, or to keep all
196
+ # the default parameter values, pass an empty Hash as a request object (see above).
197
+ #
193
198
  # @param name [String]
194
199
  # The name of the operation resource.
195
200
  #
196
- #
197
201
  # @yield [response, operation] Access the result along with the RPC operation
198
202
  # @yieldparam response [Gapic::Operation]
199
203
  # @yieldparam operation [GRPC::ActiveCall::Operation]
@@ -247,19 +251,23 @@ module Google
247
251
  # `google.rpc.Code.UNIMPLEMENTED`.
248
252
  #
249
253
  # @overload delete_operation(request, options = nil)
250
- # @param request [Google::Longrunning::DeleteOperationRequest | Hash]
251
- # Deletes a long-running operation. This method indicates that the client is
252
- # no longer interested in the operation result. It does not cancel the
253
- # operation. If the server doesn't support this method, it returns
254
- # `google.rpc.Code.UNIMPLEMENTED`.
254
+ # Pass arguments to `delete_operation` via a request object, either of type
255
+ # {Google::Longrunning::DeleteOperationRequest} or an equivalent Hash.
256
+ #
257
+ # @param request [Google::Longrunning::DeleteOperationRequest, Hash]
258
+ # A request object representing the call parameters. Required. To specify no
259
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
255
260
  # @param options [Gapic::CallOptions, Hash]
256
261
  # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
257
262
  #
258
263
  # @overload delete_operation(name: nil)
264
+ # Pass arguments to `delete_operation` via keyword arguments. Note that at
265
+ # least one keyword argument is required. To specify no parameters, or to keep all
266
+ # the default parameter values, pass an empty Hash as a request object (see above).
267
+ #
259
268
  # @param name [String]
260
269
  # The name of the operation resource to be deleted.
261
270
  #
262
- #
263
271
  # @yield [response, operation] Access the result along with the RPC operation
264
272
  # @yieldparam response [Google::Protobuf::Empty]
265
273
  # @yieldparam operation [GRPC::ActiveCall::Operation]
@@ -318,25 +326,23 @@ module Google
318
326
  # corresponding to `Code.CANCELLED`.
319
327
  #
320
328
  # @overload cancel_operation(request, options = nil)
321
- # @param request [Google::Longrunning::CancelOperationRequest | Hash]
322
- # Starts asynchronous cancellation on a long-running operation. The server
323
- # makes a best effort to cancel the operation, but success is not
324
- # guaranteed. If the server doesn't support this method, it returns
325
- # `google.rpc.Code.UNIMPLEMENTED`. Clients can use
326
- # Operations.GetOperation or
327
- # other methods to check whether the cancellation succeeded or whether the
328
- # operation completed despite cancellation. On successful cancellation,
329
- # the operation is not deleted; instead, it becomes an operation with
330
- # an {Google::Longrunning::Operation#error Operation.error} value with a {Google::Rpc::Status#code google.rpc.Status.code} of 1,
331
- # corresponding to `Code.CANCELLED`.
329
+ # Pass arguments to `cancel_operation` via a request object, either of type
330
+ # {Google::Longrunning::CancelOperationRequest} or an equivalent Hash.
331
+ #
332
+ # @param request [Google::Longrunning::CancelOperationRequest, Hash]
333
+ # A request object representing the call parameters. Required. To specify no
334
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
332
335
  # @param options [Gapic::CallOptions, Hash]
333
336
  # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
334
337
  #
335
338
  # @overload cancel_operation(name: nil)
339
+ # Pass arguments to `cancel_operation` via keyword arguments. Note that at
340
+ # least one keyword argument is required. To specify no parameters, or to keep all
341
+ # the default parameter values, pass an empty Hash as a request object (see above).
342
+ #
336
343
  # @param name [String]
337
344
  # The name of the operation resource to be cancelled.
338
345
  #
339
- #
340
346
  # @yield [response, operation] Access the result along with the RPC operation
341
347
  # @yieldparam response [Google::Protobuf::Empty]
342
348
  # @yieldparam operation [GRPC::ActiveCall::Operation]
@@ -16,5 +16,51 @@
16
16
 
17
17
  # Auto-generated by gapic-generator-ruby. DO NOT EDIT!
18
18
 
19
- require "google/cloud/dialogflow/v2/contexts/client"
19
+ require "gapic/common"
20
+ require "gapic/config"
21
+ require "gapic/config/method"
22
+
23
+ require "google/cloud/dialogflow/v2/version"
24
+
20
25
  require "google/cloud/dialogflow/v2/contexts/credentials"
26
+ require "google/cloud/dialogflow/v2/contexts/paths"
27
+ require "google/cloud/dialogflow/v2/contexts/client"
28
+
29
+ module Google
30
+ module Cloud
31
+ module Dialogflow
32
+ module V2
33
+ ##
34
+ # A context represents additional information included with user input or with
35
+ # an intent returned by the Dialogflow API. Contexts are helpful for
36
+ # differentiating user input which may be vague or have a different meaning
37
+ # depending on additional details from your application such as user setting
38
+ # and preferences, previous user input, where the user is in your application,
39
+ # geographic location, and so on.
40
+ #
41
+ # You can include contexts as input parameters of a
42
+ # {Google::Cloud::Dialogflow::V2::Sessions::Client#detect_intent DetectIntent} (or
43
+ # {Google::Cloud::Dialogflow::V2::Sessions::Client#streaming_detect_intent StreamingDetectIntent}) request,
44
+ # or as output contexts included in the returned intent.
45
+ # Contexts expire when an intent is matched, after the number of `DetectIntent`
46
+ # requests specified by the `lifespan_count` parameter, or after 20 minutes
47
+ # if no intents are matched for a `DetectIntent` request.
48
+ #
49
+ # For more information about contexts, see the
50
+ # [Dialogflow
51
+ # documentation](https://cloud.google.com/dialogflow/docs/contexts-overview).
52
+ #
53
+ # To load this service and instantiate a client:
54
+ #
55
+ # require "google/cloud/dialogflow/v2/contexts"
56
+ # client = Google::Cloud::Dialogflow::V2::Contexts::Client.new
57
+ #
58
+ module Contexts
59
+ end
60
+ end
61
+ end
62
+ end
63
+ end
64
+
65
+ helper_path = ::File.join __dir__, "contexts", "helpers.rb"
66
+ require "google/cloud/dialogflow/v2/contexts/helpers" if ::File.file? helper_path
@@ -16,15 +16,8 @@
16
16
 
17
17
  # Auto-generated by gapic-generator-ruby. DO NOT EDIT!
18
18
 
19
- require "gapic/common"
20
- require "gapic/config"
21
- require "gapic/config/method"
22
-
23
19
  require "google/cloud/errors"
24
- require "google/cloud/dialogflow/v2/version"
25
20
  require "google/cloud/dialogflow/v2/context_pb"
26
- require "google/cloud/dialogflow/v2/contexts/credentials"
27
- require "google/cloud/dialogflow/v2/contexts/paths"
28
21
 
29
22
  module Google
30
23
  module Cloud
@@ -207,12 +200,20 @@ module Google
207
200
  # Returns the list of all contexts in the specified session.
208
201
  #
209
202
  # @overload list_contexts(request, options = nil)
210
- # @param request [Google::Cloud::Dialogflow::V2::ListContextsRequest | Hash]
211
- # Returns the list of all contexts in the specified session.
203
+ # Pass arguments to `list_contexts` via a request object, either of type
204
+ # {Google::Cloud::Dialogflow::V2::ListContextsRequest} or an equivalent Hash.
205
+ #
206
+ # @param request [Google::Cloud::Dialogflow::V2::ListContextsRequest, Hash]
207
+ # A request object representing the call parameters. Required. To specify no
208
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
212
209
  # @param options [Gapic::CallOptions, Hash]
213
210
  # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
214
211
  #
215
212
  # @overload list_contexts(parent: nil, page_size: nil, page_token: nil)
213
+ # Pass arguments to `list_contexts` via keyword arguments. Note that at
214
+ # least one keyword argument is required. To specify no parameters, or to keep all
215
+ # the default parameter values, pass an empty Hash as a request object (see above).
216
+ #
216
217
  # @param parent [String]
217
218
  # Required. The session to list all contexts from.
218
219
  # Format: `projects/<Project ID>/agent/sessions/<Session ID>` or
@@ -226,7 +227,6 @@ module Google
226
227
  # @param page_token [String]
227
228
  # Optional. The next_page_token value returned from a previous list request.
228
229
  #
229
- #
230
230
  # @yield [response, operation] Access the result along with the RPC operation
231
231
  # @yieldparam response [Gapic::PagedEnumerable<Google::Cloud::Dialogflow::V2::Context>]
232
232
  # @yieldparam operation [GRPC::ActiveCall::Operation]
@@ -277,12 +277,20 @@ module Google
277
277
  # Retrieves the specified context.
278
278
  #
279
279
  # @overload get_context(request, options = nil)
280
- # @param request [Google::Cloud::Dialogflow::V2::GetContextRequest | Hash]
281
- # Retrieves the specified context.
280
+ # Pass arguments to `get_context` via a request object, either of type
281
+ # {Google::Cloud::Dialogflow::V2::GetContextRequest} or an equivalent Hash.
282
+ #
283
+ # @param request [Google::Cloud::Dialogflow::V2::GetContextRequest, Hash]
284
+ # A request object representing the call parameters. Required. To specify no
285
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
282
286
  # @param options [Gapic::CallOptions, Hash]
283
287
  # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
284
288
  #
285
289
  # @overload get_context(name: nil)
290
+ # Pass arguments to `get_context` via keyword arguments. Note that at
291
+ # least one keyword argument is required. To specify no parameters, or to keep all
292
+ # the default parameter values, pass an empty Hash as a request object (see above).
293
+ #
286
294
  # @param name [String]
287
295
  # Required. The name of the context. Format:
288
296
  # `projects/<Project ID>/agent/sessions/<Session ID>/contexts/<Context ID>`
@@ -291,7 +299,6 @@ module Google
291
299
  # If `Environment ID` is not specified, we assume default 'draft'
292
300
  # environment. If `User ID` is not specified, we assume default '-' user.
293
301
  #
294
- #
295
302
  # @yield [response, operation] Access the result along with the RPC operation
296
303
  # @yieldparam response [Google::Cloud::Dialogflow::V2::Context]
297
304
  # @yieldparam operation [GRPC::ActiveCall::Operation]
@@ -343,14 +350,20 @@ module Google
343
350
  # If the specified context already exists, overrides the context.
344
351
  #
345
352
  # @overload create_context(request, options = nil)
346
- # @param request [Google::Cloud::Dialogflow::V2::CreateContextRequest | Hash]
347
- # Creates a context.
353
+ # Pass arguments to `create_context` via a request object, either of type
354
+ # {Google::Cloud::Dialogflow::V2::CreateContextRequest} or an equivalent Hash.
348
355
  #
349
- # If the specified context already exists, overrides the context.
356
+ # @param request [Google::Cloud::Dialogflow::V2::CreateContextRequest, Hash]
357
+ # A request object representing the call parameters. Required. To specify no
358
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
350
359
  # @param options [Gapic::CallOptions, Hash]
351
360
  # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
352
361
  #
353
362
  # @overload create_context(parent: nil, context: nil)
363
+ # Pass arguments to `create_context` via keyword arguments. Note that at
364
+ # least one keyword argument is required. To specify no parameters, or to keep all
365
+ # the default parameter values, pass an empty Hash as a request object (see above).
366
+ #
354
367
  # @param parent [String]
355
368
  # Required. The session to create a context for.
356
369
  # Format: `projects/<Project ID>/agent/sessions/<Session ID>` or
@@ -358,10 +371,9 @@ module Google
358
371
  # ID>/sessions/<Session ID>`.
359
372
  # If `Environment ID` is not specified, we assume default 'draft'
360
373
  # environment. If `User ID` is not specified, we assume default '-' user.
361
- # @param context [Google::Cloud::Dialogflow::V2::Context | Hash]
374
+ # @param context [Google::Cloud::Dialogflow::V2::Context, Hash]
362
375
  # Required. The context to create.
363
376
  #
364
- #
365
377
  # @yield [response, operation] Access the result along with the RPC operation
366
378
  # @yieldparam response [Google::Cloud::Dialogflow::V2::Context]
367
379
  # @yieldparam operation [GRPC::ActiveCall::Operation]
@@ -411,18 +423,25 @@ module Google
411
423
  # Updates the specified context.
412
424
  #
413
425
  # @overload update_context(request, options = nil)
414
- # @param request [Google::Cloud::Dialogflow::V2::UpdateContextRequest | Hash]
415
- # Updates the specified context.
426
+ # Pass arguments to `update_context` via a request object, either of type
427
+ # {Google::Cloud::Dialogflow::V2::UpdateContextRequest} or an equivalent Hash.
428
+ #
429
+ # @param request [Google::Cloud::Dialogflow::V2::UpdateContextRequest, Hash]
430
+ # A request object representing the call parameters. Required. To specify no
431
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
416
432
  # @param options [Gapic::CallOptions, Hash]
417
433
  # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
418
434
  #
419
435
  # @overload update_context(context: nil, update_mask: nil)
420
- # @param context [Google::Cloud::Dialogflow::V2::Context | Hash]
436
+ # Pass arguments to `update_context` via keyword arguments. Note that at
437
+ # least one keyword argument is required. To specify no parameters, or to keep all
438
+ # the default parameter values, pass an empty Hash as a request object (see above).
439
+ #
440
+ # @param context [Google::Cloud::Dialogflow::V2::Context, Hash]
421
441
  # Required. The context to update.
422
- # @param update_mask [Google::Protobuf::FieldMask | Hash]
442
+ # @param update_mask [Google::Protobuf::FieldMask, Hash]
423
443
  # Optional. The mask to control which fields get updated.
424
444
  #
425
- #
426
445
  # @yield [response, operation] Access the result along with the RPC operation
427
446
  # @yieldparam response [Google::Cloud::Dialogflow::V2::Context]
428
447
  # @yieldparam operation [GRPC::ActiveCall::Operation]
@@ -472,12 +491,20 @@ module Google
472
491
  # Deletes the specified context.
473
492
  #
474
493
  # @overload delete_context(request, options = nil)
475
- # @param request [Google::Cloud::Dialogflow::V2::DeleteContextRequest | Hash]
476
- # Deletes the specified context.
494
+ # Pass arguments to `delete_context` via a request object, either of type
495
+ # {Google::Cloud::Dialogflow::V2::DeleteContextRequest} or an equivalent Hash.
496
+ #
497
+ # @param request [Google::Cloud::Dialogflow::V2::DeleteContextRequest, Hash]
498
+ # A request object representing the call parameters. Required. To specify no
499
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
477
500
  # @param options [Gapic::CallOptions, Hash]
478
501
  # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
479
502
  #
480
503
  # @overload delete_context(name: nil)
504
+ # Pass arguments to `delete_context` via keyword arguments. Note that at
505
+ # least one keyword argument is required. To specify no parameters, or to keep all
506
+ # the default parameter values, pass an empty Hash as a request object (see above).
507
+ #
481
508
  # @param name [String]
482
509
  # Required. The name of the context to delete. Format:
483
510
  # `projects/<Project ID>/agent/sessions/<Session ID>/contexts/<Context ID>`
@@ -486,7 +513,6 @@ module Google
486
513
  # If `Environment ID` is not specified, we assume default 'draft'
487
514
  # environment. If `User ID` is not specified, we assume default '-' user.
488
515
  #
489
- #
490
516
  # @yield [response, operation] Access the result along with the RPC operation
491
517
  # @yieldparam response [Google::Protobuf::Empty]
492
518
  # @yieldparam operation [GRPC::ActiveCall::Operation]
@@ -536,12 +562,20 @@ module Google
536
562
  # Deletes all active contexts in the specified session.
537
563
  #
538
564
  # @overload delete_all_contexts(request, options = nil)
539
- # @param request [Google::Cloud::Dialogflow::V2::DeleteAllContextsRequest | Hash]
540
- # Deletes all active contexts in the specified session.
565
+ # Pass arguments to `delete_all_contexts` via a request object, either of type
566
+ # {Google::Cloud::Dialogflow::V2::DeleteAllContextsRequest} or an equivalent Hash.
567
+ #
568
+ # @param request [Google::Cloud::Dialogflow::V2::DeleteAllContextsRequest, Hash]
569
+ # A request object representing the call parameters. Required. To specify no
570
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
541
571
  # @param options [Gapic::CallOptions, Hash]
542
572
  # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
543
573
  #
544
574
  # @overload delete_all_contexts(parent: nil)
575
+ # Pass arguments to `delete_all_contexts` via keyword arguments. Note that at
576
+ # least one keyword argument is required. To specify no parameters, or to keep all
577
+ # the default parameter values, pass an empty Hash as a request object (see above).
578
+ #
545
579
  # @param parent [String]
546
580
  # Required. The name of the session to delete all contexts from. Format:
547
581
  # `projects/<Project ID>/agent/sessions/<Session ID>` or `projects/<Project
@@ -550,7 +584,6 @@ module Google
550
584
  # If `Environment ID` is not specified we assume default 'draft' environment.
551
585
  # If `User ID` is not specified, we assume default '-' user.
552
586
  #
553
- #
554
587
  # @yield [response, operation] Access the result along with the RPC operation
555
588
  # @yieldparam response [Google::Protobuf::Empty]
556
589
  # @yieldparam operation [GRPC::ActiveCall::Operation]
@@ -784,13 +817,3 @@ module Google
784
817
  end
785
818
  end
786
819
  end
787
-
788
- # rubocop:disable Lint/HandleExceptions
789
-
790
- # Once client is loaded, load helpers.rb if it exists.
791
- begin
792
- require "google/cloud/dialogflow/v2/contexts/helpers"
793
- rescue LoadError
794
- end
795
-
796
- # rubocop:enable Lint/HandleExceptions
@@ -71,6 +71,49 @@ module Google
71
71
  resource.call(**args)
72
72
  end
73
73
 
74
+ ##
75
+ # Create a fully-qualified Session resource string.
76
+ #
77
+ # @overload session_path(project:, session:)
78
+ # The resource will be in the following format:
79
+ #
80
+ # `projects/{project}/agent/sessions/{session}`
81
+ #
82
+ # @param project [String]
83
+ # @param session [String]
84
+ #
85
+ # @overload session_path(project:, environment:, user:, session:)
86
+ # The resource will be in the following format:
87
+ #
88
+ # `projects/{project}/agent/environments/{environment}/users/{user}/sessions/{session}`
89
+ #
90
+ # @param project [String]
91
+ # @param environment [String]
92
+ # @param user [String]
93
+ # @param session [String]
94
+ #
95
+ # @return [String]
96
+ def session_path **args
97
+ resources = {
98
+ "project:session" => (proc do |project:, session:|
99
+ raise ArgumentError, "project cannot contain /" if project.to_s.include? "/"
100
+
101
+ "projects/#{project}/agent/sessions/#{session}"
102
+ end),
103
+ "environment:project:session:user" => (proc do |project:, environment:, user:, session:|
104
+ raise ArgumentError, "project cannot contain /" if project.to_s.include? "/"
105
+ raise ArgumentError, "environment cannot contain /" if environment.to_s.include? "/"
106
+ raise ArgumentError, "user cannot contain /" if user.to_s.include? "/"
107
+
108
+ "projects/#{project}/agent/environments/#{environment}/users/#{user}/sessions/#{session}"
109
+ end)
110
+ }
111
+
112
+ resource = resources[args.keys.sort.join(":")]
113
+ raise ArgumentError, "no resource found for values #{args.keys}" if resource.nil?
114
+ resource.call(**args)
115
+ end
116
+
74
117
  extend self
75
118
  end
76
119
  end