|
18 | 18 |
|
19 | 19 | import com.softlayer.api.annotation.ApiMethod; |
20 | 20 | import com.softlayer.api.annotation.ApiService; |
| 21 | +import com.softlayer.api.http.HttpCredentials; |
21 | 22 | import com.softlayer.api.http.HttpBasicAuthCredentials; |
| 23 | +import com.softlayer.api.http.HttpBearerCredentials; |
22 | 24 | import com.softlayer.api.http.HttpClient; |
23 | 25 | import com.softlayer.api.http.HttpClientFactory; |
24 | 26 | import com.softlayer.api.http.HttpResponse; |
@@ -64,7 +66,7 @@ public class RestApiClient implements ApiClient { |
64 | 66 | private HttpClientFactory httpClientFactory; |
65 | 67 | private JsonMarshallerFactory jsonMarshallerFactory; |
66 | 68 | private boolean loggingEnabled = false; |
67 | | - private HttpBasicAuthCredentials credentials; |
| 69 | + private HttpCredentials credentials; |
68 | 70 |
|
69 | 71 | /** |
70 | 72 | * Create a Rest client that uses the publically available API. |
@@ -114,6 +116,7 @@ public void setLoggingEnabled(boolean loggingEnabled) { |
114 | 116 | this.loggingEnabled = loggingEnabled; |
115 | 117 | } |
116 | 118 |
|
| 119 | + @Override |
117 | 120 | public RestApiClient withLoggingEnabled() { |
118 | 121 | this.loggingEnabled = true; |
119 | 122 | return this; |
@@ -141,7 +144,14 @@ public RestApiClient withCredentials(String username, String apiKey) { |
141 | 144 | return this; |
142 | 145 | } |
143 | 146 |
|
144 | | - public HttpBasicAuthCredentials getCredentials() { |
| 147 | + @Override |
| 148 | + public RestApiClient withBearerToken(String token) { |
| 149 | + credentials = new HttpBearerCredentials(token); |
| 150 | + return this; |
| 151 | + } |
| 152 | + |
| 153 | + @Override |
| 154 | + public HttpCredentials getCredentials() { |
145 | 155 | return credentials; |
146 | 156 | } |
147 | 157 |
|
|
0 commit comments