Skip to content

Commit 1d2a680

Browse files
authored
Merge pull request #44 from oracle/release_20180222
Releasing version 1.2.28
2 parents e2c3f80 + 681604b commit 1d2a680

File tree

147 files changed

+24625
-4106
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

147 files changed

+24625
-4106
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,14 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/).
1313
### Added
1414
- N/A
1515

16+
## 1.2.28 - 2018-02-22
17+
18+
### Added
19+
- Added support for the File Storage Service. An example on how to call this service can be found [here](https://github.com/oracle/oci-java-sdk/blob/master/bmc-examples/src/main/java/FileStorageServiceExample.java)
20+
- Added support for tagging Bucket resources in the Object Storage Service
21+
- Added support for specifying a restore period for archived objects in the `restoreObjects` operation of the Object Storage service
22+
- Added `paginators` to provide an `Iterable` interface over list operations offered by the SDK
23+
1624
## 1.2.27 - 2018-02-08
1725

1826
### Fixed

bmc-audit/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<groupId>com.oracle.oci.sdk</groupId>
77
<artifactId>oci-java-sdk</artifactId>
8-
<version>1.2.27</version>
8+
<version>1.2.28</version>
99
<relativePath>../pom.xml</relativePath>
1010
</parent>
1111

@@ -18,7 +18,7 @@
1818
<dependency>
1919
<groupId>com.oracle.oci.sdk</groupId>
2020
<artifactId>oci-java-sdk-common</artifactId>
21-
<version>1.2.27</version>
21+
<version>1.2.28</version>
2222
</dependency>
2323
</dependencies>
2424

bmc-audit/src/main/java/com/oracle/bmc/audit/Audit.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,4 +59,13 @@ public interface Audit extends AutoCloseable {
5959
* @throws BmcException when an error occurs.
6060
*/
6161
UpdateConfigurationResponse updateConfiguration(UpdateConfigurationRequest request);
62+
63+
/**
64+
* Gets the pre-configured paginators available for list operations in this service which may return multiple
65+
* pages of data. These paginators provide an {@link java.lang.Iterable} interface so that service responses, or
66+
* resources/records, can be iterated through without having to manually deal with pagination and page tokens.
67+
*
68+
* @return The service paginators.
69+
*/
70+
AuditPaginators getPaginators();
6271
}

bmc-audit/src/main/java/com/oracle/bmc/audit/AuditClient.java

Lines changed: 39 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ public class AuditClient implements Audit {
1616
*/
1717
public static final com.oracle.bmc.Service SERVICE =
1818
com.oracle.bmc.Services.create("AUDIT", "audit");
19+
// attempt twice if it's instance principals, immediately failures will try to refresh the token
20+
private static final int MAX_IMMEDIATE_RETRIES_IF_USING_INSTANCE_PRINCIPALS = 2;
21+
22+
private final AuditPaginators paginators;
1923

2024
@lombok.Getter(value = lombok.AccessLevel.PACKAGE)
2125
private final com.oracle.bmc.http.internal.RestClient client;
@@ -87,6 +91,8 @@ public AuditClient(
8791
SERVICE, this.authenticationDetailsProvider);
8892
this.client = restClientFactory.create(requestSigner, configuration);
8993

94+
this.paginators = new AuditPaginators(this);
95+
9096
if (this.authenticationDetailsProvider instanceof com.oracle.bmc.auth.RegionProvider) {
9197
com.oracle.bmc.auth.RegionProvider provider =
9298
(com.oracle.bmc.auth.RegionProvider) this.authenticationDetailsProvider;
@@ -141,25 +147,19 @@ public GetConfigurationResponse getConfiguration(GetConfigurationRequest request
141147
com.google.common.base.Function<javax.ws.rs.core.Response, GetConfigurationResponse>
142148
transformer = GetConfigurationConverter.fromResponse();
143149

144-
if (this.authenticationDetailsProvider
145-
instanceof com.oracle.bmc.auth.InstancePrincipalsAuthenticationDetailsProvider) {
150+
int attempts = 0;
151+
while (true) {
146152
try {
147153
javax.ws.rs.core.Response response = client.get(ib, request);
148154
return transformer.apply(response);
149155
} catch (com.oracle.bmc.model.BmcException e) {
150-
if (e.getStatusCode() == 401) {
151-
((com.oracle.bmc.auth.InstancePrincipalsAuthenticationDetailsProvider)
152-
this.authenticationDetailsProvider)
153-
.refreshSecurityToken();
154-
javax.ws.rs.core.Response response = client.get(ib, request);
155-
return transformer.apply(response);
156+
if (++attempts < MAX_IMMEDIATE_RETRIES_IF_USING_INSTANCE_PRINCIPALS
157+
&& canRetryRequestIfInstancePrincipalsUsed(e)) {
158+
continue;
156159
} else {
157160
throw e;
158161
}
159162
}
160-
} else {
161-
javax.ws.rs.core.Response response = client.get(ib, request);
162-
return transformer.apply(response);
163163
}
164164
}
165165

@@ -172,25 +172,19 @@ public ListEventsResponse listEvents(ListEventsRequest request) {
172172
com.google.common.base.Function<javax.ws.rs.core.Response, ListEventsResponse> transformer =
173173
ListEventsConverter.fromResponse();
174174

175-
if (this.authenticationDetailsProvider
176-
instanceof com.oracle.bmc.auth.InstancePrincipalsAuthenticationDetailsProvider) {
175+
int attempts = 0;
176+
while (true) {
177177
try {
178178
javax.ws.rs.core.Response response = client.get(ib, request);
179179
return transformer.apply(response);
180180
} catch (com.oracle.bmc.model.BmcException e) {
181-
if (e.getStatusCode() == 401) {
182-
((com.oracle.bmc.auth.InstancePrincipalsAuthenticationDetailsProvider)
183-
this.authenticationDetailsProvider)
184-
.refreshSecurityToken();
185-
javax.ws.rs.core.Response response = client.get(ib, request);
186-
return transformer.apply(response);
181+
if (++attempts < MAX_IMMEDIATE_RETRIES_IF_USING_INSTANCE_PRINCIPALS
182+
&& canRetryRequestIfInstancePrincipalsUsed(e)) {
183+
continue;
187184
} else {
188185
throw e;
189186
}
190187
}
191-
} else {
192-
javax.ws.rs.core.Response response = client.get(ib, request);
193-
return transformer.apply(response);
194188
}
195189
}
196190

@@ -203,28 +197,38 @@ public UpdateConfigurationResponse updateConfiguration(UpdateConfigurationReques
203197
com.google.common.base.Function<javax.ws.rs.core.Response, UpdateConfigurationResponse>
204198
transformer = UpdateConfigurationConverter.fromResponse();
205199

206-
if (this.authenticationDetailsProvider
207-
instanceof com.oracle.bmc.auth.InstancePrincipalsAuthenticationDetailsProvider) {
200+
int attempts = 0;
201+
while (true) {
208202
try {
209203
javax.ws.rs.core.Response response =
210204
client.put(ib, request.getUpdateConfigurationDetails(), request);
211205
return transformer.apply(response);
212206
} catch (com.oracle.bmc.model.BmcException e) {
213-
if (e.getStatusCode() == 401) {
214-
((com.oracle.bmc.auth.InstancePrincipalsAuthenticationDetailsProvider)
215-
this.authenticationDetailsProvider)
216-
.refreshSecurityToken();
217-
javax.ws.rs.core.Response response =
218-
client.put(ib, request.getUpdateConfigurationDetails(), request);
219-
return transformer.apply(response);
207+
if (++attempts < MAX_IMMEDIATE_RETRIES_IF_USING_INSTANCE_PRINCIPALS
208+
&& canRetryRequestIfInstancePrincipalsUsed(e)) {
209+
continue;
220210
} else {
221211
throw e;
222212
}
223213
}
224-
} else {
225-
javax.ws.rs.core.Response response =
226-
client.put(ib, request.getUpdateConfigurationDetails(), request);
227-
return transformer.apply(response);
228214
}
229215
}
216+
217+
private boolean canRetryRequestIfInstancePrincipalsUsed(com.oracle.bmc.model.BmcException e) {
218+
if (e.getStatusCode() == 401
219+
&& this.authenticationDetailsProvider
220+
instanceof
221+
com.oracle.bmc.auth.InstancePrincipalsAuthenticationDetailsProvider) {
222+
((com.oracle.bmc.auth.InstancePrincipalsAuthenticationDetailsProvider)
223+
this.authenticationDetailsProvider)
224+
.refreshSecurityToken();
225+
return true;
226+
}
227+
return false;
228+
}
229+
230+
@Override
231+
public AuditPaginators getPaginators() {
232+
return paginators;
233+
}
230234
}
Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
/**
2+
* Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
3+
*/
4+
package com.oracle.bmc.audit;
5+
6+
import com.oracle.bmc.audit.requests.*;
7+
import com.oracle.bmc.audit.responses.*;
8+
9+
/**
10+
* Collection of helper methods that can be used to provide an {@link java.lang.Iterable} interface
11+
* to any list operations of Audit where multiple pages of data may be fetched.
12+
* Two styles of iteration are supported:
13+
*
14+
* <ul>
15+
* <li>Iterating over the Response objects returned by the list operation. These are referred to as ResponseIterators, and the methods are suffixed with ResponseIterator. For example: <i>listUsersResponseIterator</i></li>
16+
* <li>Iterating over the resources/records being listed. These are referred to as RecordIterators, and the methods are suffixed with RecordIterator. For example: <i>listUsersRecordIterator</i></li>
17+
* </ul>
18+
*
19+
* These iterables abstract away the need to write code to manually handle pagination via looping and using the page tokens.
20+
* They will automatically fetch more data from the service when required.
21+
*
22+
* As an example, if we were using the ListUsers operation in IdentityService, then the {@link java.lang.Interable} returned by calling a
23+
* ResponseIterator method would iterate over the ListUsersResponse objects returned by each ListUsers call, whereas the {@link java.lang.Iterable}
24+
* returned by calling a RecordIterator method would iterate over the User records and we don't have to deal with ListUsersResponse objects at all.
25+
* In either case, pagination will be automatically handled so we can iterate until there are no more responses or no more resources/records available.
26+
*/
27+
@javax.annotation.Generated(value = "OracleSDKGenerator", comments = "API Version: 20160918")
28+
@lombok.RequiredArgsConstructor
29+
public class AuditPaginators {
30+
private final Audit client;
31+
32+
/**
33+
* Creates a new iterable which will iterate over the responses received from the listEvents operation. This iterable
34+
* will fetch more data from the server as needed.
35+
*
36+
* @param request a request which can be sent to the service operation
37+
* @return an {@link java.lang.Iterable} which can be used to iterate over the responses received from the service.
38+
*/
39+
public Iterable<ListEventsResponse> listEventsResponseIterator(
40+
final ListEventsRequest request) {
41+
return new com.oracle.bmc.paginator.internal.ResponseIterable<
42+
ListEventsRequest.Builder, ListEventsRequest, ListEventsResponse>(
43+
new com.google.common.base.Supplier<ListEventsRequest.Builder>() {
44+
@Override
45+
public ListEventsRequest.Builder get() {
46+
return ListEventsRequest.builder().copy(request);
47+
}
48+
},
49+
new com.google.common.base.Function<ListEventsResponse, String>() {
50+
@Override
51+
public String apply(ListEventsResponse response) {
52+
return response.getOpcNextPage();
53+
}
54+
},
55+
new com.google.common.base.Function<
56+
com.oracle.bmc.paginator.internal.RequestBuilderAndToken<
57+
ListEventsRequest.Builder>,
58+
ListEventsRequest>() {
59+
@Override
60+
public ListEventsRequest apply(
61+
com.oracle.bmc.paginator.internal.RequestBuilderAndToken<
62+
ListEventsRequest.Builder>
63+
input) {
64+
if (input.getToken() == null) {
65+
return input.getRequestBuilder().build();
66+
} else {
67+
return input.getRequestBuilder()
68+
.page(input.getToken().orNull())
69+
.build();
70+
}
71+
}
72+
},
73+
new com.google.common.base.Function<ListEventsRequest, ListEventsResponse>() {
74+
@Override
75+
public ListEventsResponse apply(ListEventsRequest request) {
76+
return client.listEvents(request);
77+
}
78+
});
79+
}
80+
81+
/**
82+
* Creates a new iterable which will iterate over the {@link com.oracle.bmc.audit.model.AuditEvent} objects
83+
* contained in responses from the listEvents operation. This iterable will fetch more data from the
84+
* server as needed.
85+
*
86+
* @param request a request which can be sent to the service operation
87+
* @return an {@link java.lang.Iterable} which can be used to iterate over the {@link com.oracle.bmc.audit.model.AuditEvent} objects
88+
* contained in responses received from the service.
89+
*/
90+
public Iterable<com.oracle.bmc.audit.model.AuditEvent> listEventsRecordIterator(
91+
final ListEventsRequest request) {
92+
return new com.oracle.bmc.paginator.internal.ResponseRecordIterable<
93+
ListEventsRequest.Builder, ListEventsRequest, ListEventsResponse,
94+
com.oracle.bmc.audit.model.AuditEvent>(
95+
new com.google.common.base.Supplier<ListEventsRequest.Builder>() {
96+
@Override
97+
public ListEventsRequest.Builder get() {
98+
return ListEventsRequest.builder().copy(request);
99+
}
100+
},
101+
new com.google.common.base.Function<ListEventsResponse, String>() {
102+
@Override
103+
public String apply(ListEventsResponse response) {
104+
return response.getOpcNextPage();
105+
}
106+
},
107+
new com.google.common.base.Function<
108+
com.oracle.bmc.paginator.internal.RequestBuilderAndToken<
109+
ListEventsRequest.Builder>,
110+
ListEventsRequest>() {
111+
@Override
112+
public ListEventsRequest apply(
113+
com.oracle.bmc.paginator.internal.RequestBuilderAndToken<
114+
ListEventsRequest.Builder>
115+
input) {
116+
if (input.getToken() == null) {
117+
return input.getRequestBuilder().build();
118+
} else {
119+
return input.getRequestBuilder()
120+
.page(input.getToken().orNull())
121+
.build();
122+
}
123+
}
124+
},
125+
new com.google.common.base.Function<ListEventsRequest, ListEventsResponse>() {
126+
@Override
127+
public ListEventsResponse apply(ListEventsRequest request) {
128+
return client.listEvents(request);
129+
}
130+
},
131+
new com.google.common.base.Function<
132+
ListEventsResponse,
133+
java.util.List<com.oracle.bmc.audit.model.AuditEvent>>() {
134+
@Override
135+
public java.util.List<com.oracle.bmc.audit.model.AuditEvent> apply(
136+
ListEventsResponse response) {
137+
return response.getItems();
138+
}
139+
});
140+
}
141+
}

0 commit comments

Comments
 (0)