Skip to content

Commit

Permalink
Merge pull request #93 from IBM/avir_q1
Browse files Browse the repository at this point in the history
patch: API enhancements
  • Loading branch information
IdanAdar authored Mar 11, 2024
2 parents 8e0f82b + 32a1261 commit c67ce70
Show file tree
Hide file tree
Showing 14 changed files with 148 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,8 @@ public static void main(String[] args) throws Exception {
.sort("created_at")
.search("example")
.groups(java.util.Arrays.asList("default", "cac40995-c37a-4dcb-9506-472869077634"))
.secretTypes(java.util.Arrays.asList("arbitrary", "kv"))
.matchAllLabels(java.util.Arrays.asList("dev", "us-south"))
.build();

SecretsPager pager = new SecretsPager(secretsManagerService, listSecretsOptions);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*/

/*
* IBM OpenAPI SDK Code Generator Version: 3.84.2-a032c73d-20240125-175315
* IBM OpenAPI SDK Code Generator Version: 3.86.1-c3d7bcef-20240308-215042
*/

package com.ibm.cloud.secrets_manager_sdk.secrets_manager.v2;
Expand Down Expand Up @@ -375,6 +375,12 @@ public ServiceCall<SecretMetadataPaginatedCollection> listSecrets(ListSecretsOpt
if (listSecretsOptions.groups() != null) {
builder.query("groups", RequestUtils.join(listSecretsOptions.groups(), ","));
}
if (listSecretsOptions.secretTypes() != null) {
builder.query("secret_types", RequestUtils.join(listSecretsOptions.secretTypes(), ","));
}
if (listSecretsOptions.matchAllLabels() != null) {
builder.query("match_all_labels", RequestUtils.join(listSecretsOptions.matchAllLabels(), ","));
}
ResponseConverter<SecretMetadataPaginatedCollection> responseConverter =
ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken<SecretMetadataPaginatedCollection>() { }.getType());
return createServiceCall(builder.build(), responseConverter);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,32 @@
*/
public class ListSecretsOptions extends GenericModel {

public interface SecretTypes {
/** arbitrary. */
String ARBITRARY = "arbitrary";
/** iam_credentials. */
String IAM_CREDENTIALS = "iam_credentials";
/** imported_cert. */
String IMPORTED_CERT = "imported_cert";
/** kv. */
String KV = "kv";
/** private_cert. */
String PRIVATE_CERT = "private_cert";
/** public_cert. */
String PUBLIC_CERT = "public_cert";
/** service_credentials. */
String SERVICE_CREDENTIALS = "service_credentials";
/** username_password. */
String USERNAME_PASSWORD = "username_password";
}

protected Long offset;
protected Long limit;
protected String sort;
protected String search;
protected List<String> groups;
protected List<String> secretTypes;
protected List<String> matchAllLabels;

/**
* Builder.
Expand All @@ -37,6 +58,8 @@ public static class Builder {
private String sort;
private String search;
private List<String> groups;
private List<String> secretTypes;
private List<String> matchAllLabels;

/**
* Instantiates a new Builder from an existing ListSecretsOptions instance.
Expand All @@ -49,6 +72,8 @@ private Builder(ListSecretsOptions listSecretsOptions) {
this.sort = listSecretsOptions.sort;
this.search = listSecretsOptions.search;
this.groups = listSecretsOptions.groups;
this.secretTypes = listSecretsOptions.secretTypes;
this.matchAllLabels = listSecretsOptions.matchAllLabels;
}

/**
Expand Down Expand Up @@ -82,6 +107,38 @@ public Builder addGroups(String groups) {
return this;
}

/**
* Adds a new element to secretTypes.
*
* @param secretTypes the new element to be added
* @return the ListSecretsOptions builder
*/
public Builder addSecretTypes(String secretTypes) {
com.ibm.cloud.sdk.core.util.Validator.notNull(secretTypes,
"secretTypes cannot be null");
if (this.secretTypes == null) {
this.secretTypes = new ArrayList<String>();
}
this.secretTypes.add(secretTypes);
return this;
}

/**
* Adds a new element to matchAllLabels.
*
* @param matchAllLabels the new element to be added
* @return the ListSecretsOptions builder
*/
public Builder addMatchAllLabels(String matchAllLabels) {
com.ibm.cloud.sdk.core.util.Validator.notNull(matchAllLabels,
"matchAllLabels cannot be null");
if (this.matchAllLabels == null) {
this.matchAllLabels = new ArrayList<String>();
}
this.matchAllLabels.add(matchAllLabels);
return this;
}

/**
* Set the offset.
*
Expand Down Expand Up @@ -137,6 +194,30 @@ public Builder groups(List<String> groups) {
this.groups = groups;
return this;
}

/**
* Set the secretTypes.
* Existing secretTypes will be replaced.
*
* @param secretTypes the secretTypes
* @return the ListSecretsOptions builder
*/
public Builder secretTypes(List<String> secretTypes) {
this.secretTypes = secretTypes;
return this;
}

/**
* Set the matchAllLabels.
* Existing matchAllLabels will be replaced.
*
* @param matchAllLabels the matchAllLabels
* @return the ListSecretsOptions builder
*/
public Builder matchAllLabels(List<String> matchAllLabels) {
this.matchAllLabels = matchAllLabels;
return this;
}
}

protected ListSecretsOptions() { }
Expand All @@ -147,6 +228,8 @@ protected ListSecretsOptions(Builder builder) {
sort = builder.sort;
search = builder.search;
groups = builder.groups;
secretTypes = builder.secretTypes;
matchAllLabels = builder.matchAllLabels;
}

/**
Expand Down Expand Up @@ -239,5 +322,37 @@ public String search() {
public List<String> groups() {
return groups;
}

/**
* Gets the secretTypes.
*
* Filter secrets by types.
*
* You can apply multiple filters by using a comma-separated list of secret types.
*
* **Usage:** To retrieve a list of imported certificates and public certificates use
* `..?secret_types=imported_cert,public_cert`.
*
* @return the secretTypes
*/
public List<String> secretTypes() {
return secretTypes;
}

/**
* Gets the matchAllLabels.
*
* Filter secrets by labels.
*
* You can use a comma-separated list of labels to filter secrets that include all of the labels in the list.
*
* **Usage:** To retrieve a list of secrets that include both the label "dev" and the label "us-south" in their list
* of labels, use `..?labels=dev,us-south`.
*
* @return the matchAllLabels
*/
public List<String> matchAllLabels() {
return matchAllLabels;
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ public String getId() {
*
* Labels that you can use to search secrets in your instance. Only 30 labels can be created.
*
* Label can be between 2-30 characters, including spaces.
* Label can be between 2-64 characters, including spaces.
*
* To protect your privacy, do not use personal data, such as your name or location, as a label for your secret.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ public String getId() {
*
* Labels that you can use to search secrets in your instance. Only 30 labels can be created.
*
* Label can be between 2-30 characters, including spaces.
* Label can be between 2-64 characters, including spaces.
*
* To protect your privacy, do not use personal data, such as your name or location, as a label for your secret.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public String description() {
*
* Labels that you can use to search secrets in your instance. Only 30 labels can be created.
*
* Label can be between 2-30 characters, including spaces.
* Label can be between 2-64 characters, including spaces.
*
* To protect your privacy, do not use personal data, such as your name or location, as a label for your secret.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ public Date expirationDate() {
*
* Labels that you can use to search secrets in your instance. Only 30 labels can be created.
*
* Label can be between 2-30 characters, including spaces.
* Label can be between 2-64 characters, including spaces.
*
* To protect your privacy, do not use personal data, such as your name or location, as a label for your secret.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -578,6 +578,8 @@ public void testListSecrets() throws Exception {
.sort("created_at")
.search("example")
.groups(java.util.Arrays.asList("default", "cac40995-c37a-4dcb-9506-472869077634"))
.secretTypes(java.util.Arrays.asList("arbitrary", "kv"))
.matchAllLabels(java.util.Arrays.asList("dev", "us-south"))
.build();

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

// Test getNext().
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -608,6 +608,8 @@ public void testListSecretsWOptions() throws Throwable {
.sort("created_at")
.search("example")
.groups(java.util.Arrays.asList("default", "cac40995-c37a-4dcb-9506-472869077634"))
.secretTypes(java.util.Arrays.asList("arbitrary", "kv"))
.matchAllLabels(java.util.Arrays.asList("dev", "us-south"))
.build();

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

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

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

SecretsPager pager = new SecretsPager(secretsManagerService, listSecretsOptions);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,6 @@ public void testIAMCredentialsSecretMetadata() throws Throwable {
assertNull(iamCredentialsSecretMetadataModel.getServiceId());
assertNull(iamCredentialsSecretMetadataModel.isReuseApiKey());
assertNull(iamCredentialsSecretMetadataModel.getRotation());
assertNull(iamCredentialsSecretMetadataModel.getExpirationDate());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,6 @@ public void testIAMCredentialsSecret() throws Throwable {
assertNull(iamCredentialsSecretModel.getServiceId());
assertNull(iamCredentialsSecretModel.isReuseApiKey());
assertNull(iamCredentialsSecretModel.getRotation());
assertNull(iamCredentialsSecretModel.getExpirationDate());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,15 @@ public void testListSecretsOptions() throws Throwable {
.sort("created_at")
.search("example")
.groups(java.util.Arrays.asList("default", "cac40995-c37a-4dcb-9506-472869077634"))
.secretTypes(java.util.Arrays.asList("arbitrary", "kv"))
.matchAllLabels(java.util.Arrays.asList("dev", "us-south"))
.build();
assertEquals(listSecretsOptionsModel.offset(), Long.valueOf("0"));
assertEquals(listSecretsOptionsModel.limit(), Long.valueOf("200"));
assertEquals(listSecretsOptionsModel.sort(), "created_at");
assertEquals(listSecretsOptionsModel.search(), "example");
assertEquals(listSecretsOptionsModel.groups(), java.util.Arrays.asList("default", "cac40995-c37a-4dcb-9506-472869077634"));
assertEquals(listSecretsOptionsModel.secretTypes(), java.util.Arrays.asList("arbitrary", "kv"));
assertEquals(listSecretsOptionsModel.matchAllLabels(), java.util.Arrays.asList("dev", "us-south"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ public void testServiceCredentialsSecretMetadata() throws Throwable {
assertNull(serviceCredentialsSecretMetadataModel.getVersionsTotal());
assertNull(serviceCredentialsSecretMetadataModel.getRotation());
assertNull(serviceCredentialsSecretMetadataModel.getTtl());
assertNull(serviceCredentialsSecretMetadataModel.getExpirationDate());
assertNull(serviceCredentialsSecretMetadataModel.getSourceService());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ public void testServiceCredentialsSecret() throws Throwable {
assertNull(serviceCredentialsSecretModel.getVersionsTotal());
assertNull(serviceCredentialsSecretModel.getRotation());
assertNull(serviceCredentialsSecretModel.getTtl());
assertNull(serviceCredentialsSecretModel.getExpirationDate());
assertNull(serviceCredentialsSecretModel.getSourceService());
assertNull(serviceCredentialsSecretModel.getCredentials());
}
Expand Down

0 comments on commit c67ce70

Please sign in to comment.