1
1
/*
2
- * (C) Copyright IBM Corp. 2019, 2022.
2
+ * (C) Copyright IBM Corp. 2022.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
5
5
* the License. You may obtain a copy of the License at
12
12
*/
13
13
14
14
/*
15
- * IBM OpenAPI SDK Code Generator Version: 3.46 .0-a4e29da0-20220224-210428
15
+ * IBM OpenAPI SDK Code Generator Version: 3.53 .0-9710cac3-20220713-193508
16
16
*/
17
17
18
18
package com .ibm .watson .assistant .v2 ;
30
30
import com .ibm .watson .assistant .v2 .model .CreateSessionOptions ;
31
31
import com .ibm .watson .assistant .v2 .model .DeleteSessionOptions ;
32
32
import com .ibm .watson .assistant .v2 .model .DeleteUserDataOptions ;
33
+ import com .ibm .watson .assistant .v2 .model .DeployReleaseOptions ;
34
+ import com .ibm .watson .assistant .v2 .model .Environment ;
35
+ import com .ibm .watson .assistant .v2 .model .EnvironmentCollection ;
36
+ import com .ibm .watson .assistant .v2 .model .GetEnvironmentOptions ;
37
+ import com .ibm .watson .assistant .v2 .model .GetReleaseOptions ;
38
+ import com .ibm .watson .assistant .v2 .model .ListEnvironmentsOptions ;
33
39
import com .ibm .watson .assistant .v2 .model .ListLogsOptions ;
40
+ import com .ibm .watson .assistant .v2 .model .ListReleasesOptions ;
34
41
import com .ibm .watson .assistant .v2 .model .LogCollection ;
35
42
import com .ibm .watson .assistant .v2 .model .MessageOptions ;
36
43
import com .ibm .watson .assistant .v2 .model .MessageResponse ;
37
44
import com .ibm .watson .assistant .v2 .model .MessageResponseStateless ;
38
45
import com .ibm .watson .assistant .v2 .model .MessageStatelessOptions ;
46
+ import com .ibm .watson .assistant .v2 .model .Release ;
47
+ import com .ibm .watson .assistant .v2 .model .ReleaseCollection ;
39
48
import com .ibm .watson .assistant .v2 .model .SessionResponse ;
40
49
import com .ibm .watson .common .SdkCommon ;
41
50
import java .util .HashMap ;
@@ -164,6 +173,8 @@ public ServiceCall<SessionResponse> createSession(CreateSessionOptions createSes
164
173
}
165
174
builder .header ("Accept" , "application/json" );
166
175
builder .query ("version" , String .valueOf (this .version ));
176
+ final JsonObject contentJson = new JsonObject ();
177
+ builder .bodyJson (contentJson );
167
178
ResponseConverter <SessionResponse > responseConverter =
168
179
ResponseConverterUtils .getValue (
169
180
new com .google .gson .reflect .TypeToken <SessionResponse >() {}.getType ());
@@ -328,12 +339,10 @@ public ServiceCall<BulkClassifyResponse> bulkClassify(BulkClassifyOptions bulkCl
328
339
builder .header ("Accept" , "application/json" );
329
340
builder .query ("version" , String .valueOf (this .version ));
330
341
final JsonObject contentJson = new JsonObject ();
331
- if (bulkClassifyOptions .input () != null ) {
332
- contentJson .add (
333
- "input" ,
334
- com .ibm .cloud .sdk .core .util .GsonSingleton .getGson ()
335
- .toJsonTree (bulkClassifyOptions .input ()));
336
- }
342
+ contentJson .add (
343
+ "input" ,
344
+ com .ibm .cloud .sdk .core .util .GsonSingleton .getGson ()
345
+ .toJsonTree (bulkClassifyOptions .input ()));
337
346
builder .bodyJson (contentJson );
338
347
ResponseConverter <BulkClassifyResponse > responseConverter =
339
348
ResponseConverterUtils .getValue (
@@ -348,6 +357,11 @@ public ServiceCall<BulkClassifyResponse> bulkClassify(BulkClassifyOptions bulkCl
348
357
*
349
358
* <p>This method requires Manager access, and is available only with Enterprise plans.
350
359
*
360
+ * <p>**Note:** If you use the **cursor** parameter to retrieve results one page at a time,
361
+ * subsequent requests must be no more than 5 minutes apart. Any returned value for the **cursor**
362
+ * parameter becomes invalid after 5 minutes. For more information about using pagination, see
363
+ * [Pagination](#pagination).
364
+ *
351
365
* @param listLogsOptions the {@link ListLogsOptions} containing the options for the call
352
366
* @return a {@link ServiceCall} with a result of type {@link LogCollection}
353
367
*/
@@ -420,4 +434,214 @@ public ServiceCall<Void> deleteUserData(DeleteUserDataOptions deleteUserDataOpti
420
434
ResponseConverter <Void > responseConverter = ResponseConverterUtils .getVoid ();
421
435
return createServiceCall (builder .build (), responseConverter );
422
436
}
437
+
438
+ /**
439
+ * List environments.
440
+ *
441
+ * <p>List the environments associated with an assistant.
442
+ *
443
+ * @param listEnvironmentsOptions the {@link ListEnvironmentsOptions} containing the options for
444
+ * the call
445
+ * @return a {@link ServiceCall} with a result of type {@link EnvironmentCollection}
446
+ */
447
+ public ServiceCall <EnvironmentCollection > listEnvironments (
448
+ ListEnvironmentsOptions listEnvironmentsOptions ) {
449
+ com .ibm .cloud .sdk .core .util .Validator .notNull (
450
+ listEnvironmentsOptions , "listEnvironmentsOptions cannot be null" );
451
+ Map <String , String > pathParamsMap = new HashMap <String , String >();
452
+ pathParamsMap .put ("assistant_id" , listEnvironmentsOptions .assistantId ());
453
+ RequestBuilder builder =
454
+ RequestBuilder .get (
455
+ RequestBuilder .resolveRequestUrl (
456
+ getServiceUrl (), "/v2/assistants/{assistant_id}/environments" , pathParamsMap ));
457
+ Map <String , String > sdkHeaders =
458
+ SdkCommon .getSdkHeaders ("conversation" , "v2" , "listEnvironments" );
459
+ for (Entry <String , String > header : sdkHeaders .entrySet ()) {
460
+ builder .header (header .getKey (), header .getValue ());
461
+ }
462
+ builder .header ("Accept" , "application/json" );
463
+ builder .query ("version" , String .valueOf (this .version ));
464
+ if (listEnvironmentsOptions .pageLimit () != null ) {
465
+ builder .query ("page_limit" , String .valueOf (listEnvironmentsOptions .pageLimit ()));
466
+ }
467
+ if (listEnvironmentsOptions .includeCount () != null ) {
468
+ builder .query ("include_count" , String .valueOf (listEnvironmentsOptions .includeCount ()));
469
+ }
470
+ if (listEnvironmentsOptions .sort () != null ) {
471
+ builder .query ("sort" , String .valueOf (listEnvironmentsOptions .sort ()));
472
+ }
473
+ if (listEnvironmentsOptions .cursor () != null ) {
474
+ builder .query ("cursor" , String .valueOf (listEnvironmentsOptions .cursor ()));
475
+ }
476
+ if (listEnvironmentsOptions .includeAudit () != null ) {
477
+ builder .query ("include_audit" , String .valueOf (listEnvironmentsOptions .includeAudit ()));
478
+ }
479
+ ResponseConverter <EnvironmentCollection > responseConverter =
480
+ ResponseConverterUtils .getValue (
481
+ new com .google .gson .reflect .TypeToken <EnvironmentCollection >() {}.getType ());
482
+ return createServiceCall (builder .build (), responseConverter );
483
+ }
484
+
485
+ /**
486
+ * Get environment.
487
+ *
488
+ * <p>Get information about an environment. For more information about environments, see
489
+ * [Environments](https://cloud.ibm.com/docs/watson-assistant?topic=watson-assistant-publish-overview#environments).
490
+ *
491
+ * @param getEnvironmentOptions the {@link GetEnvironmentOptions} containing the options for the
492
+ * call
493
+ * @return a {@link ServiceCall} with a result of type {@link Environment}
494
+ */
495
+ public ServiceCall <Environment > getEnvironment (GetEnvironmentOptions getEnvironmentOptions ) {
496
+ com .ibm .cloud .sdk .core .util .Validator .notNull (
497
+ getEnvironmentOptions , "getEnvironmentOptions cannot be null" );
498
+ Map <String , String > pathParamsMap = new HashMap <String , String >();
499
+ pathParamsMap .put ("assistant_id" , getEnvironmentOptions .assistantId ());
500
+ pathParamsMap .put ("environment_id" , getEnvironmentOptions .environmentId ());
501
+ RequestBuilder builder =
502
+ RequestBuilder .get (
503
+ RequestBuilder .resolveRequestUrl (
504
+ getServiceUrl (),
505
+ "/v2/assistants/{assistant_id}/environments/{environment_id}" ,
506
+ pathParamsMap ));
507
+ Map <String , String > sdkHeaders =
508
+ SdkCommon .getSdkHeaders ("conversation" , "v2" , "getEnvironment" );
509
+ for (Entry <String , String > header : sdkHeaders .entrySet ()) {
510
+ builder .header (header .getKey (), header .getValue ());
511
+ }
512
+ builder .header ("Accept" , "application/json" );
513
+ builder .query ("version" , String .valueOf (this .version ));
514
+ if (getEnvironmentOptions .includeAudit () != null ) {
515
+ builder .query ("include_audit" , String .valueOf (getEnvironmentOptions .includeAudit ()));
516
+ }
517
+ ResponseConverter <Environment > responseConverter =
518
+ ResponseConverterUtils .getValue (
519
+ new com .google .gson .reflect .TypeToken <Environment >() {}.getType ());
520
+ return createServiceCall (builder .build (), responseConverter );
521
+ }
522
+
523
+ /**
524
+ * List releases.
525
+ *
526
+ * <p>List the releases associated with an assistant. (In the Watson Assistant user interface, a
527
+ * release is called a *version*.).
528
+ *
529
+ * @param listReleasesOptions the {@link ListReleasesOptions} containing the options for the call
530
+ * @return a {@link ServiceCall} with a result of type {@link ReleaseCollection}
531
+ */
532
+ public ServiceCall <ReleaseCollection > listReleases (ListReleasesOptions listReleasesOptions ) {
533
+ com .ibm .cloud .sdk .core .util .Validator .notNull (
534
+ listReleasesOptions , "listReleasesOptions cannot be null" );
535
+ Map <String , String > pathParamsMap = new HashMap <String , String >();
536
+ pathParamsMap .put ("assistant_id" , listReleasesOptions .assistantId ());
537
+ RequestBuilder builder =
538
+ RequestBuilder .get (
539
+ RequestBuilder .resolveRequestUrl (
540
+ getServiceUrl (), "/v2/assistants/{assistant_id}/releases" , pathParamsMap ));
541
+ Map <String , String > sdkHeaders = SdkCommon .getSdkHeaders ("conversation" , "v2" , "listReleases" );
542
+ for (Entry <String , String > header : sdkHeaders .entrySet ()) {
543
+ builder .header (header .getKey (), header .getValue ());
544
+ }
545
+ builder .header ("Accept" , "application/json" );
546
+ builder .query ("version" , String .valueOf (this .version ));
547
+ if (listReleasesOptions .pageLimit () != null ) {
548
+ builder .query ("page_limit" , String .valueOf (listReleasesOptions .pageLimit ()));
549
+ }
550
+ if (listReleasesOptions .includeCount () != null ) {
551
+ builder .query ("include_count" , String .valueOf (listReleasesOptions .includeCount ()));
552
+ }
553
+ if (listReleasesOptions .sort () != null ) {
554
+ builder .query ("sort" , String .valueOf (listReleasesOptions .sort ()));
555
+ }
556
+ if (listReleasesOptions .cursor () != null ) {
557
+ builder .query ("cursor" , String .valueOf (listReleasesOptions .cursor ()));
558
+ }
559
+ if (listReleasesOptions .includeAudit () != null ) {
560
+ builder .query ("include_audit" , String .valueOf (listReleasesOptions .includeAudit ()));
561
+ }
562
+ ResponseConverter <ReleaseCollection > responseConverter =
563
+ ResponseConverterUtils .getValue (
564
+ new com .google .gson .reflect .TypeToken <ReleaseCollection >() {}.getType ());
565
+ return createServiceCall (builder .build (), responseConverter );
566
+ }
567
+
568
+ /**
569
+ * Get release.
570
+ *
571
+ * <p>Get information about a release.
572
+ *
573
+ * <p>Release data is not available until publishing of the release completes. If publishing is
574
+ * still in progress, you can continue to poll by calling the same request again and checking the
575
+ * value of the **status** property. When processing has completed, the request returns the
576
+ * release data.
577
+ *
578
+ * @param getReleaseOptions the {@link GetReleaseOptions} containing the options for the call
579
+ * @return a {@link ServiceCall} with a result of type {@link Release}
580
+ */
581
+ public ServiceCall <Release > getRelease (GetReleaseOptions getReleaseOptions ) {
582
+ com .ibm .cloud .sdk .core .util .Validator .notNull (
583
+ getReleaseOptions , "getReleaseOptions cannot be null" );
584
+ Map <String , String > pathParamsMap = new HashMap <String , String >();
585
+ pathParamsMap .put ("assistant_id" , getReleaseOptions .assistantId ());
586
+ pathParamsMap .put ("release" , getReleaseOptions .release ());
587
+ RequestBuilder builder =
588
+ RequestBuilder .get (
589
+ RequestBuilder .resolveRequestUrl (
590
+ getServiceUrl (),
591
+ "/v2/assistants/{assistant_id}/releases/{release}" ,
592
+ pathParamsMap ));
593
+ Map <String , String > sdkHeaders = SdkCommon .getSdkHeaders ("conversation" , "v2" , "getRelease" );
594
+ for (Entry <String , String > header : sdkHeaders .entrySet ()) {
595
+ builder .header (header .getKey (), header .getValue ());
596
+ }
597
+ builder .header ("Accept" , "application/json" );
598
+ builder .query ("version" , String .valueOf (this .version ));
599
+ if (getReleaseOptions .includeAudit () != null ) {
600
+ builder .query ("include_audit" , String .valueOf (getReleaseOptions .includeAudit ()));
601
+ }
602
+ ResponseConverter <Release > responseConverter =
603
+ ResponseConverterUtils .getValue (
604
+ new com .google .gson .reflect .TypeToken <Release >() {}.getType ());
605
+ return createServiceCall (builder .build (), responseConverter );
606
+ }
607
+
608
+ /**
609
+ * Deploy release.
610
+ *
611
+ * <p>Update the environment with the content of the release. All snapshots saved as part of the
612
+ * release become active in the environment.
613
+ *
614
+ * @param deployReleaseOptions the {@link DeployReleaseOptions} containing the options for the
615
+ * call
616
+ * @return a {@link ServiceCall} with a result of type {@link Environment}
617
+ */
618
+ public ServiceCall <Environment > deployRelease (DeployReleaseOptions deployReleaseOptions ) {
619
+ com .ibm .cloud .sdk .core .util .Validator .notNull (
620
+ deployReleaseOptions , "deployReleaseOptions cannot be null" );
621
+ Map <String , String > pathParamsMap = new HashMap <String , String >();
622
+ pathParamsMap .put ("assistant_id" , deployReleaseOptions .assistantId ());
623
+ pathParamsMap .put ("release" , deployReleaseOptions .release ());
624
+ RequestBuilder builder =
625
+ RequestBuilder .post (
626
+ RequestBuilder .resolveRequestUrl (
627
+ getServiceUrl (),
628
+ "/v2/assistants/{assistant_id}/releases/{release}/deploy" ,
629
+ pathParamsMap ));
630
+ Map <String , String > sdkHeaders = SdkCommon .getSdkHeaders ("conversation" , "v2" , "deployRelease" );
631
+ for (Entry <String , String > header : sdkHeaders .entrySet ()) {
632
+ builder .header (header .getKey (), header .getValue ());
633
+ }
634
+ builder .header ("Accept" , "application/json" );
635
+ builder .query ("version" , String .valueOf (this .version ));
636
+ if (deployReleaseOptions .includeAudit () != null ) {
637
+ builder .query ("include_audit" , String .valueOf (deployReleaseOptions .includeAudit ()));
638
+ }
639
+ final JsonObject contentJson = new JsonObject ();
640
+ contentJson .addProperty ("environment_id" , deployReleaseOptions .environmentId ());
641
+ builder .bodyJson (contentJson );
642
+ ResponseConverter <Environment > responseConverter =
643
+ ResponseConverterUtils .getValue (
644
+ new com .google .gson .reflect .TypeToken <Environment >() {}.getType ());
645
+ return createServiceCall (builder .build (), responseConverter );
646
+ }
423
647
}
0 commit comments