Skip to content

Commit 8f19d90

Browse files
authored
chore(resourcemanager): Generate service/resourcemanager (#9)
update resourcemanager based on stackitcloud/stackit-sdk-generator#184
1 parent 0b7579b commit 8f19d90

File tree

16 files changed

+143
-935
lines changed

16 files changed

+143
-935
lines changed

core/src/main/java/cloud/stackit/sdk/core/auth/SetupAuth.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public class SetupAuth {
3939
* @throws CredentialsInFileNotFoundException when no configuration is set or can be found
4040
*/
4141
public SetupAuth() throws CredentialsInFileNotFoundException {
42-
this(new CoreConfiguration.Builder().build(), new EnvironmentVariables());
42+
this(new CoreConfiguration(), new EnvironmentVariables());
4343
}
4444

4545
/**
@@ -66,7 +66,7 @@ public SetupAuth(CoreConfiguration cfg) throws IOException, CredentialsInFileNot
6666
protected SetupAuth(CoreConfiguration cfg, EnvironmentVariables environmentVariables)
6767
throws CredentialsInFileNotFoundException {
6868

69-
this.cfg = cfg != null ? cfg : new CoreConfiguration.Builder().build();
69+
this.cfg = cfg != null ? cfg : new CoreConfiguration();
7070
this.env = environmentVariables != null ? environmentVariables : new EnvironmentVariables();
7171
}
7272

core/src/main/java/cloud/stackit/sdk/core/config/CoreConfiguration.java

Lines changed: 54 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -3,27 +3,17 @@
33
import java.util.Map;
44

55
public class CoreConfiguration {
6-
private final Map<String, String> defaultHeader;
7-
private final String serviceAccountKey;
8-
private final String serviceAccountKeyPath;
9-
private final String privateKeyPath;
10-
private final String privateKey;
11-
private final String customEndpoint;
12-
private final String credentialsFilePath;
13-
private final String tokenCustomUrl;
14-
private final Long tokenExpirationLeeway;
15-
16-
CoreConfiguration(Builder builder) {
17-
this.defaultHeader = builder.defaultHeader;
18-
this.serviceAccountKey = builder.serviceAccountKey;
19-
this.serviceAccountKeyPath = builder.serviceAccountKeyPath;
20-
this.privateKeyPath = builder.privateKeyPath;
21-
this.privateKey = builder.privateKey;
22-
this.customEndpoint = builder.customEndpoint;
23-
this.credentialsFilePath = builder.credentialsFilePath;
24-
this.tokenCustomUrl = builder.tokenCustomUrl;
25-
this.tokenExpirationLeeway = builder.tokenExpirationLeeway;
26-
}
6+
private Map<String, String> defaultHeader;
7+
private String serviceAccountKey;
8+
private String serviceAccountKeyPath;
9+
private String privateKeyPath;
10+
private String privateKey;
11+
private String customEndpoint;
12+
private String credentialsFilePath;
13+
private String tokenCustomUrl;
14+
private Long tokenExpirationLeeway;
15+
16+
public CoreConfiguration() {}
2717

2818
public Map<String, String> getDefaultHeader() {
2919
return defaultHeader;
@@ -61,64 +51,48 @@ public Long getTokenExpirationLeeway() {
6151
return tokenExpirationLeeway;
6252
}
6353

64-
public static class Builder {
65-
private Map<String, String> defaultHeader;
66-
private String serviceAccountKey;
67-
private String serviceAccountKeyPath;
68-
private String privateKeyPath;
69-
private String privateKey;
70-
private String customEndpoint;
71-
private String credentialsFilePath;
72-
private String tokenCustomUrl;
73-
private Long tokenExpirationLeeway;
74-
75-
public Builder defaultHeader(Map<String, String> defaultHeader) {
76-
this.defaultHeader = defaultHeader;
77-
return this;
78-
}
79-
80-
public Builder serviceAccountKey(String serviceAccountKey) {
81-
this.serviceAccountKey = serviceAccountKey;
82-
return this;
83-
}
84-
85-
public Builder serviceAccountKeyPath(String serviceAccountKeyPath) {
86-
this.serviceAccountKeyPath = serviceAccountKeyPath;
87-
return this;
88-
}
89-
90-
public Builder privateKeyPath(String privateKeyPath) {
91-
this.privateKeyPath = privateKeyPath;
92-
return this;
93-
}
94-
95-
public Builder privateKey(String privateKey) {
96-
this.privateKey = privateKey;
97-
return this;
98-
}
99-
100-
public Builder customEndpoint(String customEndpoint) {
101-
this.customEndpoint = customEndpoint;
102-
return this;
103-
}
104-
105-
public Builder credentialsFilePath(String credentialsFilePath) {
106-
this.credentialsFilePath = credentialsFilePath;
107-
return this;
108-
}
109-
110-
public Builder tokenCustomUrl(String tokenCustomUrl) {
111-
this.tokenCustomUrl = tokenCustomUrl;
112-
return this;
113-
}
114-
115-
public Builder tokenExpirationLeeway(Long tokenExpirationLeeway) {
116-
this.tokenExpirationLeeway = tokenExpirationLeeway;
117-
return this;
118-
}
119-
120-
public CoreConfiguration build() {
121-
return new CoreConfiguration(this);
122-
}
54+
public CoreConfiguration defaultHeader(Map<String, String> defaultHeader) {
55+
this.defaultHeader = defaultHeader;
56+
return this;
57+
}
58+
59+
public CoreConfiguration serviceAccountKey(String serviceAccountKey) {
60+
this.serviceAccountKey = serviceAccountKey;
61+
return this;
62+
}
63+
64+
public CoreConfiguration serviceAccountKeyPath(String serviceAccountKeyPath) {
65+
this.serviceAccountKeyPath = serviceAccountKeyPath;
66+
return this;
67+
}
68+
69+
public CoreConfiguration privateKeyPath(String privateKeyPath) {
70+
this.privateKeyPath = privateKeyPath;
71+
return this;
72+
}
73+
74+
public CoreConfiguration privateKey(String privateKey) {
75+
this.privateKey = privateKey;
76+
return this;
77+
}
78+
79+
public CoreConfiguration customEndpoint(String customEndpoint) {
80+
this.customEndpoint = customEndpoint;
81+
return this;
82+
}
83+
84+
public CoreConfiguration credentialsFilePath(String credentialsFilePath) {
85+
this.credentialsFilePath = credentialsFilePath;
86+
return this;
87+
}
88+
89+
public CoreConfiguration tokenCustomUrl(String tokenCustomUrl) {
90+
this.tokenCustomUrl = tokenCustomUrl;
91+
return this;
92+
}
93+
94+
public CoreConfiguration tokenExpirationLeeway(Long tokenExpirationLeeway) {
95+
this.tokenExpirationLeeway = tokenExpirationLeeway;
96+
return this;
12397
}
12498
}

core/src/test/java/cloud/stackit/sdk/core/KeyFlowAuthenticatorTest.java

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,7 @@ void getAccessToken_response200_noException()
116116
// Config
117117
HttpUrl url = mockWebServer.url("/token");
118118
CoreConfiguration cfg =
119-
new CoreConfiguration.Builder()
120-
.tokenCustomUrl(url.toString()) // Use mockWebServer
121-
.build();
119+
new CoreConfiguration().tokenCustomUrl(url.toString()); // Use mockWebServer
122120

123121
KeyFlowAuthenticator keyFlowAuthenticator = new KeyFlowAuthenticator(cfg, defaultSaKey);
124122

@@ -143,9 +141,7 @@ void getAccessToken_expiredToken_noException()
143141
// Config
144142
HttpUrl url = mockWebServer.url("/token");
145143
CoreConfiguration cfg =
146-
new CoreConfiguration.Builder()
147-
.tokenCustomUrl(url.toString()) // Use mockWebServer
148-
.build();
144+
new CoreConfiguration().tokenCustomUrl(url.toString()); // Use mockWebServer
149145

150146
KeyFlowAuthenticator keyFlowAuthenticator = new KeyFlowAuthenticator(cfg, defaultSaKey);
151147
keyFlowAuthenticator.setToken(expiredKey);
@@ -162,9 +158,7 @@ void createAccessToken_response200WithEmptyBody_throwsException() {
162158

163159
// Config
164160
CoreConfiguration cfg =
165-
new CoreConfiguration.Builder()
166-
.tokenCustomUrl(url.toString()) // Use mockWebServer
167-
.build();
161+
new CoreConfiguration().tokenCustomUrl(url.toString()); // Use mockWebServer
168162

169163
// Init keyFlowAuthenticator
170164
KeyFlowAuthenticator keyFlowAuthenticator =
@@ -182,9 +176,7 @@ void createAccessToken_response400_throwsApiException() {
182176

183177
// Config
184178
CoreConfiguration cfg =
185-
new CoreConfiguration.Builder()
186-
.tokenCustomUrl(url.toString()) // Use mockWebServer
187-
.build();
179+
new CoreConfiguration().tokenCustomUrl(url.toString()); // Use mockWebServer
188180

189181
// Init keyFlowAuthenticator
190182
KeyFlowAuthenticator keyFlowAuthenticator =
@@ -206,9 +198,7 @@ void createAccessToken_response200WithValidResponse_noException()
206198
// Config
207199
HttpUrl url = mockWebServer.url("/token");
208200
CoreConfiguration cfg =
209-
new CoreConfiguration.Builder()
210-
.tokenCustomUrl(url.toString()) // Use mockWebServer
211-
.build();
201+
new CoreConfiguration().tokenCustomUrl(url.toString()); // Use mockWebServer
212202

213203
// Init keyFlowAuthenticator
214204
KeyFlowAuthenticator keyFlowAuthenticator = new KeyFlowAuthenticator(cfg, defaultSaKey);
@@ -229,9 +219,7 @@ void createAccessTokenWithRefreshToken_response200WithValidResponse_noException(
229219
// Config
230220
HttpUrl url = mockWebServer.url("/token");
231221
CoreConfiguration cfg =
232-
new CoreConfiguration.Builder()
233-
.tokenCustomUrl(url.toString()) // Use mockWebServer
234-
.build();
222+
new CoreConfiguration().tokenCustomUrl(url.toString()); // Use mockWebServer
235223

236224
// Prepare keyFlowAuthenticator
237225
KeyFlowAuthenticator keyFlowAuthenticator = new KeyFlowAuthenticator(cfg, defaultSaKey);
@@ -251,9 +239,7 @@ void createAccessTokenWithRefreshToken_response200WithEmptyBody_throwsException(
251239

252240
// Config
253241
CoreConfiguration cfg =
254-
new CoreConfiguration.Builder()
255-
.tokenCustomUrl(url.toString()) // Use mockWebServer
256-
.build();
242+
new CoreConfiguration().tokenCustomUrl(url.toString()); // Use mockWebServer
257243

258244
// Prepare keyFlowAuthenticator
259245
KeyFlowAuthenticator keyFlowAuthenticator =

0 commit comments

Comments
 (0)