Skip to content

Commit 721debf

Browse files
committed
Correct comments and javadoc, extract public interface for CallParams
1 parent 231a099 commit 721debf

File tree

5 files changed

+175
-91
lines changed

5 files changed

+175
-91
lines changed
Lines changed: 61 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -1,91 +1,67 @@
1+
// Copyright 2018, Oracle Corporation and/or its affiliates. All rights reserved.
2+
// Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl.
13
package oracle.kubernetes.operator.builders;
24

35
import io.kubernetes.client.ProgressRequestBody;
46
import io.kubernetes.client.ProgressResponseBody;
57

6-
public class CallParams {
7-
private static final int DEFAULT_LIMIT = 500;
8-
private static final int DEFAULT_TIMEOUT = 30;
9-
10-
private Boolean includeUninitialized;
11-
private Integer limit = CallParams.DEFAULT_LIMIT;
12-
private Integer timeoutSeconds = CallParams.DEFAULT_TIMEOUT;
13-
private String fieldSelector;
14-
private String labelSelector;
15-
private String pretty;
16-
private String resourceVersion;
17-
private ProgressResponseBody.ProgressListener progressListener;
18-
private ProgressRequestBody.ProgressRequestListener progressRequestListener;
19-
20-
public Boolean getIncludeUninitialized() {
21-
return includeUninitialized;
22-
}
23-
24-
public Integer getLimit() {
25-
return limit;
26-
}
27-
28-
public Integer getTimeoutSeconds() {
29-
return timeoutSeconds;
30-
}
31-
32-
public String getFieldSelector() {
33-
return fieldSelector;
34-
}
35-
36-
public String getLabelSelector() {
37-
return labelSelector;
38-
}
39-
40-
public String getPretty() {
41-
return pretty;
42-
}
43-
44-
public String getResourceVersion() {
45-
return resourceVersion;
46-
}
47-
48-
public ProgressResponseBody.ProgressListener getProgressListener() {
49-
return progressListener;
50-
}
51-
52-
public ProgressRequestBody.ProgressRequestListener getProgressRequestListener() {
53-
return progressRequestListener;
54-
}
55-
56-
void setIncludeUninitialized(Boolean includeUninitialized) {
57-
this.includeUninitialized = includeUninitialized;
58-
}
59-
60-
void setLimit(Integer limit) {
61-
this.limit = limit;
62-
}
63-
64-
void setTimeoutSeconds(Integer timeoutSeconds) {
65-
this.timeoutSeconds = timeoutSeconds;
66-
}
67-
68-
void setFieldSelector(String fieldSelector) {
69-
this.fieldSelector = fieldSelector;
70-
}
71-
72-
void setLabelSelector(String labelSelector) {
73-
this.labelSelector = labelSelector;
74-
}
75-
76-
void setPretty(String pretty) {
77-
this.pretty = pretty;
78-
}
79-
80-
void setResourceVersion(String resourceVersion) {
81-
this.resourceVersion = resourceVersion;
82-
}
83-
84-
void setProgressListener(ProgressResponseBody.ProgressListener progressListener) {
85-
this.progressListener = progressListener;
86-
}
87-
88-
void setProgressRequestListener(ProgressRequestBody.ProgressRequestListener progressRequestListener) {
89-
this.progressRequestListener = progressRequestListener;
90-
}
8+
public interface CallParams {
9+
/**
10+
* Returns a boolean indicating whether partially initialized results should be included in the response.
11+
* @return the current setting of the parameter. Defaults to including everything.
12+
*/
13+
Boolean getIncludeUninitialized();
14+
15+
/**
16+
* Returns the limit on the number of updates to send in a single reply.
17+
* @return the current setting of the parameter. Defaults to 500.
18+
*/
19+
Integer getLimit();
20+
21+
/**
22+
* Returns the timeout for the call.
23+
* @return the current setting. Defaults to 30 seconds.
24+
*/
25+
Integer getTimeoutSeconds();
26+
27+
/**
28+
* Returns a selector to limit results to those with matching fields.
29+
* @return the option, if specified. Defaults to null, indicating no record filtering.
30+
*/
31+
String getFieldSelector();
32+
33+
/**
34+
* Returns a selector to limit results to those with matching labels.
35+
* @return the option, if specified. Defaults to null, indicating no record filtering.
36+
*/
37+
String getLabelSelector();
38+
39+
/**
40+
* Returns the 'pretty-print' option to be sent. If 'true', then the output is pretty printed.
41+
* @return the option, if specified. Defaults to null.
42+
*/
43+
String getPretty();
44+
45+
/**
46+
* On a watch call: when specified, shows changes that occur after that particular version of a resource.
47+
* Defaults to changes from the beginning of history.
48+
* On a list call: when specified, requests values at least as recent as the specified value.
49+
* Defaults to returning the result from remote storage based on quorum-read flag;
50+
* - if it's 0, then we simply return what we currently have in cache, no guarantee;
51+
* - if set to non zero, then the result is at least as fresh as given version.
52+
* @return the current setting. Defaults to null.
53+
*/
54+
String getResourceVersion();
55+
56+
/**
57+
* Returns a listener for responses received, to specify on calls.
58+
* @return the set listener. Defaults to null.
59+
*/
60+
ProgressResponseBody.ProgressListener getProgressListener();
61+
62+
/**
63+
* Returns a listener for requests sent, to specify on calls.
64+
* @return the set listener. Defaults to null.
65+
*/
66+
ProgressRequestBody.ProgressRequestListener getProgressRequestListener();
9167
}
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
// Copyright 2018, Oracle Corporation and/or its affiliates. All rights reserved.
2+
// Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl.
3+
package oracle.kubernetes.operator.builders;
4+
5+
import io.kubernetes.client.ProgressRequestBody;
6+
import io.kubernetes.client.ProgressResponseBody;
7+
8+
/**
9+
* An object which encapsulates common parameters for Kubernetes API calls.
10+
*/
11+
class CallParamsImpl implements CallParams {
12+
private static final int DEFAULT_LIMIT = 500;
13+
private static final int DEFAULT_TIMEOUT = 30;
14+
15+
private Boolean includeUninitialized;
16+
private Integer limit = CallParamsImpl.DEFAULT_LIMIT;
17+
private Integer timeoutSeconds = CallParamsImpl.DEFAULT_TIMEOUT;
18+
private String fieldSelector;
19+
private String labelSelector;
20+
private String pretty;
21+
private String resourceVersion;
22+
private ProgressResponseBody.ProgressListener progressListener;
23+
private ProgressRequestBody.ProgressRequestListener progressRequestListener;
24+
25+
@Override
26+
public Boolean getIncludeUninitialized() {
27+
return includeUninitialized;
28+
}
29+
30+
@Override
31+
public Integer getLimit() {
32+
return limit;
33+
}
34+
35+
@Override
36+
public Integer getTimeoutSeconds() {
37+
return timeoutSeconds;
38+
}
39+
40+
@Override
41+
public String getFieldSelector() {
42+
return fieldSelector;
43+
}
44+
45+
@Override
46+
public String getLabelSelector() {
47+
return labelSelector;
48+
}
49+
50+
@Override
51+
public String getPretty() {
52+
return pretty;
53+
}
54+
55+
@Override
56+
public String getResourceVersion() {
57+
return resourceVersion;
58+
}
59+
60+
@Override
61+
public ProgressResponseBody.ProgressListener getProgressListener() {
62+
return progressListener;
63+
}
64+
65+
@Override
66+
public ProgressRequestBody.ProgressRequestListener getProgressRequestListener() {
67+
return progressRequestListener;
68+
}
69+
70+
void setIncludeUninitialized(Boolean includeUninitialized) {
71+
this.includeUninitialized = includeUninitialized;
72+
}
73+
74+
void setLimit(Integer limit) {
75+
this.limit = limit;
76+
}
77+
78+
void setTimeoutSeconds(Integer timeoutSeconds) {
79+
this.timeoutSeconds = timeoutSeconds;
80+
}
81+
82+
void setFieldSelector(String fieldSelector) {
83+
this.fieldSelector = fieldSelector;
84+
}
85+
86+
void setLabelSelector(String labelSelector) {
87+
this.labelSelector = labelSelector;
88+
}
89+
90+
void setPretty(String pretty) {
91+
this.pretty = pretty;
92+
}
93+
94+
void setResourceVersion(String resourceVersion) {
95+
this.resourceVersion = resourceVersion;
96+
}
97+
98+
void setProgressListener(ProgressResponseBody.ProgressListener progressListener) {
99+
this.progressListener = progressListener;
100+
}
101+
102+
void setProgressRequestListener(ProgressRequestBody.ProgressRequestListener progressRequestListener) {
103+
this.progressRequestListener = progressRequestListener;
104+
}
105+
}

src/main/java/oracle/kubernetes/operator/builders/WatchBuilder.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,16 @@
2222
@SuppressWarnings("unused")
2323
public class WatchBuilder {
2424

25-
private static final String START_LIST = "";
25+
/** Always true for watches. */
2626
private static final boolean WATCH = true;
27+
28+
/** Ignored for watches. */
29+
private static final String START_LIST = null;
30+
2731
private static WatchFactory FACTORY = new WatchFactoryImpl();
28-
private ClientHolder clientHolder;
2932

30-
private CallParams callParams = new CallParams();
33+
private ClientHolder clientHolder;
34+
private CallParamsImpl callParams = new CallParamsImpl();
3135

3236
public interface WatchFactory {
3337
<T> Watch<T> createWatch(ClientHolder clientHolder, CallParams callParams, Class<?> responseBodyType, BiFunction<ClientHolder, CallParams, Call> function) throws ApiException;

src/test/java/oracle/kubernetes/custom/CustomObjectApisTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2017-2018, Oracle Corporation and/or its affiliates. All rights reserved.
1+
// Copyright 2017,2018, Oracle Corporation and/or its affiliates. All rights reserved.
22

33
package oracle.kubernetes.custom;
44

src/test/java/oracle/kubernetes/operator/WatchTest.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2017-2018, Oracle Corporation and/or its affiliates. All rights reserved.
1+
// Copyright 2017,2018, Oracle Corporation and/or its affiliates. All rights reserved.
22

33
package oracle.kubernetes.operator;
44

@@ -58,7 +58,6 @@ public void testCustomResourceWatch() throws Exception {
5858

5959
@SuppressWarnings("unused")
6060
Watch<Domain> watch = new WatchBuilder(client).createDomainsInAllNamespacesWatch();
61-
6261
}
6362

6463

0 commit comments

Comments
 (0)