Skip to content

Commit c67ce70

Browse files
authored
Merge pull request #93 from IBM/avir_q1
patch: API enhancements
2 parents 8e0f82b + 32a1261 commit c67ce70

File tree

14 files changed

+148
-5
lines changed

14 files changed

+148
-5
lines changed

modules/examples/src/main/java/com/ibm/cloud/secrets_manager_sdk/secrets_manager/v2/SecretsManagerExamples.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,8 @@ public static void main(String[] args) throws Exception {
368368
.sort("created_at")
369369
.search("example")
370370
.groups(java.util.Arrays.asList("default", "cac40995-c37a-4dcb-9506-472869077634"))
371+
.secretTypes(java.util.Arrays.asList("arbitrary", "kv"))
372+
.matchAllLabels(java.util.Arrays.asList("dev", "us-south"))
371373
.build();
372374

373375
SecretsPager pager = new SecretsPager(secretsManagerService, listSecretsOptions);

modules/secrets-manager/src/main/java/com/ibm/cloud/secrets_manager_sdk/secrets_manager/v2/SecretsManager.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
*/
1313

1414
/*
15-
* IBM OpenAPI SDK Code Generator Version: 3.84.2-a032c73d-20240125-175315
15+
* IBM OpenAPI SDK Code Generator Version: 3.86.1-c3d7bcef-20240308-215042
1616
*/
1717

1818
package com.ibm.cloud.secrets_manager_sdk.secrets_manager.v2;
@@ -375,6 +375,12 @@ public ServiceCall<SecretMetadataPaginatedCollection> listSecrets(ListSecretsOpt
375375
if (listSecretsOptions.groups() != null) {
376376
builder.query("groups", RequestUtils.join(listSecretsOptions.groups(), ","));
377377
}
378+
if (listSecretsOptions.secretTypes() != null) {
379+
builder.query("secret_types", RequestUtils.join(listSecretsOptions.secretTypes(), ","));
380+
}
381+
if (listSecretsOptions.matchAllLabels() != null) {
382+
builder.query("match_all_labels", RequestUtils.join(listSecretsOptions.matchAllLabels(), ","));
383+
}
378384
ResponseConverter<SecretMetadataPaginatedCollection> responseConverter =
379385
ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken<SecretMetadataPaginatedCollection>() { }.getType());
380386
return createServiceCall(builder.build(), responseConverter);

modules/secrets-manager/src/main/java/com/ibm/cloud/secrets_manager_sdk/secrets_manager/v2/model/ListSecretsOptions.java

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,32 @@
2222
*/
2323
public class ListSecretsOptions extends GenericModel {
2424

25+
public interface SecretTypes {
26+
/** arbitrary. */
27+
String ARBITRARY = "arbitrary";
28+
/** iam_credentials. */
29+
String IAM_CREDENTIALS = "iam_credentials";
30+
/** imported_cert. */
31+
String IMPORTED_CERT = "imported_cert";
32+
/** kv. */
33+
String KV = "kv";
34+
/** private_cert. */
35+
String PRIVATE_CERT = "private_cert";
36+
/** public_cert. */
37+
String PUBLIC_CERT = "public_cert";
38+
/** service_credentials. */
39+
String SERVICE_CREDENTIALS = "service_credentials";
40+
/** username_password. */
41+
String USERNAME_PASSWORD = "username_password";
42+
}
43+
2544
protected Long offset;
2645
protected Long limit;
2746
protected String sort;
2847
protected String search;
2948
protected List<String> groups;
49+
protected List<String> secretTypes;
50+
protected List<String> matchAllLabels;
3051

3152
/**
3253
* Builder.
@@ -37,6 +58,8 @@ public static class Builder {
3758
private String sort;
3859
private String search;
3960
private List<String> groups;
61+
private List<String> secretTypes;
62+
private List<String> matchAllLabels;
4063

4164
/**
4265
* Instantiates a new Builder from an existing ListSecretsOptions instance.
@@ -49,6 +72,8 @@ private Builder(ListSecretsOptions listSecretsOptions) {
4972
this.sort = listSecretsOptions.sort;
5073
this.search = listSecretsOptions.search;
5174
this.groups = listSecretsOptions.groups;
75+
this.secretTypes = listSecretsOptions.secretTypes;
76+
this.matchAllLabels = listSecretsOptions.matchAllLabels;
5277
}
5378

5479
/**
@@ -82,6 +107,38 @@ public Builder addGroups(String groups) {
82107
return this;
83108
}
84109

110+
/**
111+
* Adds a new element to secretTypes.
112+
*
113+
* @param secretTypes the new element to be added
114+
* @return the ListSecretsOptions builder
115+
*/
116+
public Builder addSecretTypes(String secretTypes) {
117+
com.ibm.cloud.sdk.core.util.Validator.notNull(secretTypes,
118+
"secretTypes cannot be null");
119+
if (this.secretTypes == null) {
120+
this.secretTypes = new ArrayList<String>();
121+
}
122+
this.secretTypes.add(secretTypes);
123+
return this;
124+
}
125+
126+
/**
127+
* Adds a new element to matchAllLabels.
128+
*
129+
* @param matchAllLabels the new element to be added
130+
* @return the ListSecretsOptions builder
131+
*/
132+
public Builder addMatchAllLabels(String matchAllLabels) {
133+
com.ibm.cloud.sdk.core.util.Validator.notNull(matchAllLabels,
134+
"matchAllLabels cannot be null");
135+
if (this.matchAllLabels == null) {
136+
this.matchAllLabels = new ArrayList<String>();
137+
}
138+
this.matchAllLabels.add(matchAllLabels);
139+
return this;
140+
}
141+
85142
/**
86143
* Set the offset.
87144
*
@@ -137,6 +194,30 @@ public Builder groups(List<String> groups) {
137194
this.groups = groups;
138195
return this;
139196
}
197+
198+
/**
199+
* Set the secretTypes.
200+
* Existing secretTypes will be replaced.
201+
*
202+
* @param secretTypes the secretTypes
203+
* @return the ListSecretsOptions builder
204+
*/
205+
public Builder secretTypes(List<String> secretTypes) {
206+
this.secretTypes = secretTypes;
207+
return this;
208+
}
209+
210+
/**
211+
* Set the matchAllLabels.
212+
* Existing matchAllLabels will be replaced.
213+
*
214+
* @param matchAllLabels the matchAllLabels
215+
* @return the ListSecretsOptions builder
216+
*/
217+
public Builder matchAllLabels(List<String> matchAllLabels) {
218+
this.matchAllLabels = matchAllLabels;
219+
return this;
220+
}
140221
}
141222

142223
protected ListSecretsOptions() { }
@@ -147,6 +228,8 @@ protected ListSecretsOptions(Builder builder) {
147228
sort = builder.sort;
148229
search = builder.search;
149230
groups = builder.groups;
231+
secretTypes = builder.secretTypes;
232+
matchAllLabels = builder.matchAllLabels;
150233
}
151234

152235
/**
@@ -239,5 +322,37 @@ public String search() {
239322
public List<String> groups() {
240323
return groups;
241324
}
325+
326+
/**
327+
* Gets the secretTypes.
328+
*
329+
* Filter secrets by types.
330+
*
331+
* You can apply multiple filters by using a comma-separated list of secret types.
332+
*
333+
* **Usage:** To retrieve a list of imported certificates and public certificates use
334+
* `..?secret_types=imported_cert,public_cert`.
335+
*
336+
* @return the secretTypes
337+
*/
338+
public List<String> secretTypes() {
339+
return secretTypes;
340+
}
341+
342+
/**
343+
* Gets the matchAllLabels.
344+
*
345+
* Filter secrets by labels.
346+
*
347+
* You can use a comma-separated list of labels to filter secrets that include all of the labels in the list.
348+
*
349+
* **Usage:** To retrieve a list of secrets that include both the label "dev" and the label "us-south" in their list
350+
* of labels, use `..?labels=dev,us-south`.
351+
*
352+
* @return the matchAllLabels
353+
*/
354+
public List<String> matchAllLabels() {
355+
return matchAllLabels;
356+
}
242357
}
243358

modules/secrets-manager/src/main/java/com/ibm/cloud/secrets_manager_sdk/secrets_manager/v2/model/Secret.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ public String getId() {
266266
*
267267
* Labels that you can use to search secrets in your instance. Only 30 labels can be created.
268268
*
269-
* Label can be between 2-30 characters, including spaces.
269+
* Label can be between 2-64 characters, including spaces.
270270
*
271271
* To protect your privacy, do not use personal data, such as your name or location, as a label for your secret.
272272
*

modules/secrets-manager/src/main/java/com/ibm/cloud/secrets_manager_sdk/secrets_manager/v2/model/SecretMetadata.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ public String getId() {
251251
*
252252
* Labels that you can use to search secrets in your instance. Only 30 labels can be created.
253253
*
254-
* Label can be between 2-30 characters, including spaces.
254+
* Label can be between 2-64 characters, including spaces.
255255
*
256256
* To protect your privacy, do not use personal data, such as your name or location, as a label for your secret.
257257
*

modules/secrets-manager/src/main/java/com/ibm/cloud/secrets_manager_sdk/secrets_manager/v2/model/SecretMetadataPatch.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ public String description() {
8181
*
8282
* Labels that you can use to search secrets in your instance. Only 30 labels can be created.
8383
*
84-
* Label can be between 2-30 characters, including spaces.
84+
* Label can be between 2-64 characters, including spaces.
8585
*
8686
* To protect your privacy, do not use personal data, such as your name or location, as a label for your secret.
8787
*

modules/secrets-manager/src/main/java/com/ibm/cloud/secrets_manager_sdk/secrets_manager/v2/model/SecretPrototype.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ public Date expirationDate() {
193193
*
194194
* Labels that you can use to search secrets in your instance. Only 30 labels can be created.
195195
*
196-
* Label can be between 2-30 characters, including spaces.
196+
* Label can be between 2-64 characters, including spaces.
197197
*
198198
* To protect your privacy, do not use personal data, such as your name or location, as a label for your secret.
199199
*

modules/secrets-manager/src/test/java/com/ibm/cloud/secrets_manager_sdk/secrets_manager/v2/SecretsManagerIT.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -578,6 +578,8 @@ public void testListSecrets() throws Exception {
578578
.sort("created_at")
579579
.search("example")
580580
.groups(java.util.Arrays.asList("default", "cac40995-c37a-4dcb-9506-472869077634"))
581+
.secretTypes(java.util.Arrays.asList("arbitrary", "kv"))
582+
.matchAllLabels(java.util.Arrays.asList("dev", "us-south"))
581583
.build();
582584

583585
// Invoke operation
@@ -603,6 +605,8 @@ public void testListSecretsWithPager() throws Exception {
603605
.sort("created_at")
604606
.search("example")
605607
.groups(java.util.Arrays.asList("default", "cac40995-c37a-4dcb-9506-472869077634"))
608+
.secretTypes(java.util.Arrays.asList("arbitrary", "kv"))
609+
.matchAllLabels(java.util.Arrays.asList("dev", "us-south"))
606610
.build();
607611

608612
// Test getNext().

modules/secrets-manager/src/test/java/com/ibm/cloud/secrets_manager_sdk/secrets_manager/v2/SecretsManagerTest.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -608,6 +608,8 @@ public void testListSecretsWOptions() throws Throwable {
608608
.sort("created_at")
609609
.search("example")
610610
.groups(java.util.Arrays.asList("default", "cac40995-c37a-4dcb-9506-472869077634"))
611+
.secretTypes(java.util.Arrays.asList("arbitrary", "kv"))
612+
.matchAllLabels(java.util.Arrays.asList("dev", "us-south"))
611613
.build();
612614

613615
// Invoke listSecrets() with a valid options model and verify the result
@@ -631,6 +633,8 @@ public void testListSecretsWOptions() throws Throwable {
631633
assertEquals(query.get("sort"), "created_at");
632634
assertEquals(query.get("search"), "example");
633635
assertEquals(query.get("groups"), RequestUtils.join(java.util.Arrays.asList("default", "cac40995-c37a-4dcb-9506-472869077634"), ","));
636+
assertEquals(query.get("secret_types"), RequestUtils.join(java.util.Arrays.asList("arbitrary", "kv"), ","));
637+
assertEquals(query.get("match_all_labels"), RequestUtils.join(java.util.Arrays.asList("dev", "us-south"), ","));
634638
}
635639

636640
// Test the listSecrets operation with and without retries enabled
@@ -667,6 +671,8 @@ public void testListSecretsWithPagerGetNext() throws Throwable {
667671
.sort("created_at")
668672
.search("example")
669673
.groups(java.util.Arrays.asList("default", "cac40995-c37a-4dcb-9506-472869077634"))
674+
.secretTypes(java.util.Arrays.asList("arbitrary", "kv"))
675+
.matchAllLabels(java.util.Arrays.asList("dev", "us-south"))
670676
.build();
671677

672678
List<SecretMetadata> allResults = new ArrayList<>();
@@ -703,6 +709,8 @@ public void testListSecretsWithPagerGetAll() throws Throwable {
703709
.sort("created_at")
704710
.search("example")
705711
.groups(java.util.Arrays.asList("default", "cac40995-c37a-4dcb-9506-472869077634"))
712+
.secretTypes(java.util.Arrays.asList("arbitrary", "kv"))
713+
.matchAllLabels(java.util.Arrays.asList("dev", "us-south"))
706714
.build();
707715

708716
SecretsPager pager = new SecretsPager(secretsManagerService, listSecretsOptions);

modules/secrets-manager/src/test/java/com/ibm/cloud/secrets_manager_sdk/secrets_manager/v2/model/IAMCredentialsSecretMetadataTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,5 +49,6 @@ public void testIAMCredentialsSecretMetadata() throws Throwable {
4949
assertNull(iamCredentialsSecretMetadataModel.getServiceId());
5050
assertNull(iamCredentialsSecretMetadataModel.isReuseApiKey());
5151
assertNull(iamCredentialsSecretMetadataModel.getRotation());
52+
assertNull(iamCredentialsSecretMetadataModel.getExpirationDate());
5253
}
5354
}

0 commit comments

Comments
 (0)