GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — feat(Discovery): Add createGateway method · morristech/java-sdk@bb4d5ba

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1
    • Discovery.java
    • model
      • CreateGatewayOptions.java
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/Discovery.java‎

Copy file name to clipboardExpand all lines: discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/Discovery.java
+24Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import com.ibm.watson.developer_cloud.discovery.v1.model.CreateEventOptions;
2525
import com.ibm.watson.developer_cloud.discovery.v1.model.CreateEventResponse;
2626
import com.ibm.watson.developer_cloud.discovery.v1.model.CreateExpansionsOptions;
27+
import com.ibm.watson.developer_cloud.discovery.v1.model.CreateGatewayOptions;
2728
import com.ibm.watson.developer_cloud.discovery.v1.model.CreateStopwordListOptions;
2829
import com.ibm.watson.developer_cloud.discovery.v1.model.CreateTokenizationDictionaryOptions;
2930
import com.ibm.watson.developer_cloud.discovery.v1.model.CreateTrainingExampleOptions;
@@ -1936,4 +1937,27 @@ public ServiceCall<Credentials> updateCredentials(UpdateCredentialsOptions updat
19361937
return createServiceCall(builder.build(), ResponseConverterUtils.getObject(Credentials.class));
19371938
}
19381939

1940+
/**
1941+
* Create Gateway.
1942+
*
1943+
* Create a gateway configuration to use with a remotely installed gateway.
1944+
*
1945+
* @param createGatewayOptions the {@link CreateGatewayOptions} containing the options for the call
1946+
* @return a {@link ServiceCall} with a response type of {@link Gateway}
1947+
*/
1948+
public ServiceCall<Gateway> createGateway(CreateGatewayOptions createGatewayOptions) {
1949+
Validator.notNull(createGatewayOptions, "createGatewayOptions cannot be null");
1950+
String[] pathSegments = { "v1/environments", "gateways" };
1951+
String[] pathParameters = { createGatewayOptions.environmentId() };
1952+
RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments,
1953+
pathParameters));
1954+
builder.query(VERSION, versionDate);
1955+
final JsonObject contentJson = new JsonObject();
1956+
if (createGatewayOptions.name() != null) {
1957+
contentJson.addProperty("name", createGatewayOptions.name());
1958+
}
1959+
builder.bodyJson(contentJson);
1960+
return createServiceCall(builder.build(), ResponseConverterUtils.getObject(Gateway.class));
1961+
}
1962+
19391963
}
Collapse file

‎discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/CreateGatewayOptions.java‎

Copy file name to clipboard
+121Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
/*
2+
* Copyright 2018 IBM Corp. All Rights Reserved.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
5+
* the License. You may obtain a copy of the License at
6+
*
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
*
9+
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
10+
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
11+
* specific language governing permissions and limitations under the License.
12+
*/
13+
package com.ibm.watson.developer_cloud.discovery.v1.model;
14+
15+
import com.ibm.watson.developer_cloud.service.model.GenericModel;
16+
import com.ibm.watson.developer_cloud.util.Validator;
17+
18+
/**
19+
* The createGateway options.
20+
*/
21+
public class CreateGatewayOptions extends GenericModel {
22+
23+
private String environmentId;
24+
private String name;
25+
26+
/**
27+
* Builder.
28+
*/
29+
public static class Builder {
30+
private String environmentId;
31+
private String name;
32+
33+
private Builder(CreateGatewayOptions createGatewayOptions) {
34+
environmentId = createGatewayOptions.environmentId;
35+
name = createGatewayOptions.name;
36+
}
37+
38+
/**
39+
* Instantiates a new builder.
40+
*/
41+
public Builder() {
42+
}
43+
44+
/**
45+
* Instantiates a new builder with required properties.
46+
*
47+
* @param environmentId the environmentId
48+
*/
49+
public Builder(String environmentId) {
50+
this.environmentId = environmentId;
51+
}
52+
53+
/**
54+
* Builds a CreateGatewayOptions.
55+
*
56+
* @return the createGatewayOptions
57+
*/
58+
public CreateGatewayOptions build() {
59+
return new CreateGatewayOptions(this);
60+
}
61+
62+
/**
63+
* Set the environmentId.
64+
*
65+
* @param environmentId the environmentId
66+
* @return the CreateGatewayOptions builder
67+
*/
68+
public Builder environmentId(String environmentId) {
69+
this.environmentId = environmentId;
70+
return this;
71+
}
72+
73+
/**
74+
* Set the name.
75+
*
76+
* @param name the name
77+
* @return the CreateGatewayOptions builder
78+
*/
79+
public Builder name(String name) {
80+
this.name = name;
81+
return this;
82+
}
83+
}
84+
85+
private CreateGatewayOptions(Builder builder) {
86+
Validator.notEmpty(builder.environmentId, "environmentId cannot be empty");
87+
environmentId = builder.environmentId;
88+
name = builder.name;
89+
}
90+
91+
/**
92+
* New builder.
93+
*
94+
* @return a CreateGatewayOptions builder
95+
*/
96+
public Builder newBuilder() {
97+
return new Builder(this);
98+
}
99+
100+
/**
101+
* Gets the environmentId.
102+
*
103+
* The ID of the environment.
104+
*
105+
* @return the environmentId
106+
*/
107+
public String environmentId() {
108+
return environmentId;
109+
}
110+
111+
/**
112+
* Gets the name.
113+
*
114+
* User-defined name.
115+
*
116+
* @return the name
117+
*/
118+
public String name() {
119+
return name;
120+
}
121+
}

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.