Skip to content

feat(2022-09-27): updated the sdk as per the api spec released on 2022-09-27 #41

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Original file line number Diff line number Diff line change
Expand Up @@ -1996,7 +1996,11 @@ public static void main(String[] args) throws Exception {
DedicatedHostProfileCollection dedicatedHostProfileCollection = response.getResult();

// end-list_dedicated_host_profiles
dedicatedHostProfileName = dedicatedHostProfileCollection.getProfiles().get(0).getName();
for (DedicatedHostProfile profile : dedicatedHostProfileCollection.getProfiles()) {
if (profile.getFamily().equalsIgnoreCase("balanced-disk")) {
dedicatedHostProfileName = profile.getName();
}
}
} catch (ServiceResponseException e) {
logger.error(String.format("Service returned status code %s: %s%nError details: %s",
e.getStatusCode(), e.getMessage(), e.getDebuggingInfo()), e);
Expand Down
157 changes: 121 additions & 36 deletions modules/vpc/src/main/java/com/ibm/cloud/is/vpc/v1/Vpc.java

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ public static class Builder {
private String networkInterfaceId;
private String id;

/**
* Instantiates a new Builder from an existing AddBareMetalServerNetworkInterfaceFloatingIpOptions instance.
*
* @param addBareMetalServerNetworkInterfaceFloatingIpOptions the instance to initialize the Builder with
*/
private Builder(AddBareMetalServerNetworkInterfaceFloatingIpOptions addBareMetalServerNetworkInterfaceFloatingIpOptions) {
this.bareMetalServerId = addBareMetalServerNetworkInterfaceFloatingIpOptions.bareMetalServerId;
this.networkInterfaceId = addBareMetalServerNetworkInterfaceFloatingIpOptions.networkInterfaceId;
Expand Down Expand Up @@ -99,6 +104,8 @@ public Builder id(String id) {
}
}

protected AddBareMetalServerNetworkInterfaceFloatingIpOptions() { }

protected AddBareMetalServerNetworkInterfaceFloatingIpOptions(Builder builder) {
com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.bareMetalServerId,
"bareMetalServerId cannot be empty");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ public static class Builder {
private String endpointGatewayId;
private String id;

/**
* Instantiates a new Builder from an existing AddEndpointGatewayIpOptions instance.
*
* @param addEndpointGatewayIpOptions the instance to initialize the Builder with
*/
private Builder(AddEndpointGatewayIpOptions addEndpointGatewayIpOptions) {
this.endpointGatewayId = addEndpointGatewayIpOptions.endpointGatewayId;
this.id = addEndpointGatewayIpOptions.id;
Expand Down Expand Up @@ -83,6 +88,8 @@ public Builder id(String id) {
}
}

protected AddEndpointGatewayIpOptions() { }

protected AddEndpointGatewayIpOptions(Builder builder) {
com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.endpointGatewayId,
"endpointGatewayId cannot be empty");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ public static class Builder {
private String networkInterfaceId;
private String id;

/**
* Instantiates a new Builder from an existing AddInstanceNetworkInterfaceFloatingIpOptions instance.
*
* @param addInstanceNetworkInterfaceFloatingIpOptions the instance to initialize the Builder with
*/
private Builder(AddInstanceNetworkInterfaceFloatingIpOptions addInstanceNetworkInterfaceFloatingIpOptions) {
this.instanceId = addInstanceNetworkInterfaceFloatingIpOptions.instanceId;
this.networkInterfaceId = addInstanceNetworkInterfaceFloatingIpOptions.networkInterfaceId;
Expand Down Expand Up @@ -99,6 +104,8 @@ public Builder id(String id) {
}
}

protected AddInstanceNetworkInterfaceFloatingIpOptions() { }

protected AddInstanceNetworkInterfaceFloatingIpOptions(Builder builder) {
com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.instanceId,
"instanceId cannot be empty");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ public static class Builder {
private String cidrPrefix;
private String prefixLength;

/**
* Instantiates a new Builder from an existing AddVpnGatewayConnectionLocalCidrOptions instance.
*
* @param addVpnGatewayConnectionLocalCidrOptions the instance to initialize the Builder with
*/
private Builder(AddVpnGatewayConnectionLocalCidrOptions addVpnGatewayConnectionLocalCidrOptions) {
this.vpnGatewayId = addVpnGatewayConnectionLocalCidrOptions.vpnGatewayId;
this.id = addVpnGatewayConnectionLocalCidrOptions.id;
Expand Down Expand Up @@ -115,6 +120,8 @@ public Builder prefixLength(String prefixLength) {
}
}

protected AddVpnGatewayConnectionLocalCidrOptions() { }

protected AddVpnGatewayConnectionLocalCidrOptions(Builder builder) {
com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.vpnGatewayId,
"vpnGatewayId cannot be empty");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ public static class Builder {
private String cidrPrefix;
private String prefixLength;

/**
* Instantiates a new Builder from an existing AddVpnGatewayConnectionPeerCidrOptions instance.
*
* @param addVpnGatewayConnectionPeerCidrOptions the instance to initialize the Builder with
*/
private Builder(AddVpnGatewayConnectionPeerCidrOptions addVpnGatewayConnectionPeerCidrOptions) {
this.vpnGatewayId = addVpnGatewayConnectionPeerCidrOptions.vpnGatewayId;
this.id = addVpnGatewayConnectionPeerCidrOptions.id;
Expand Down Expand Up @@ -115,6 +120,8 @@ public Builder prefixLength(String prefixLength) {
}
}

protected AddVpnGatewayConnectionPeerCidrOptions() { }

protected AddVpnGatewayConnectionPeerCidrOptions(Builder builder) {
com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.vpnGatewayId,
"vpnGatewayId cannot be empty");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ public class AddressPrefix extends GenericModel {
protected String name;
protected ZoneReference zone;

protected AddressPrefix() { }

/**
* Gets the cidr.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ public class AddressPrefixCollection extends GenericModel {
@SerializedName("total_count")
protected Long totalCount;

protected AddressPrefixCollection() { }

/**
* Gets the addressPrefixes.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ public class AddressPrefixCollectionFirst extends GenericModel {

protected String href;

protected AddressPrefixCollectionFirst() { }

/**
* Gets the href.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ public class AddressPrefixCollectionNext extends GenericModel {

protected String href;

protected AddressPrefixCollectionNext() { }

/**
* Gets the href.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ public static class Builder {
private Boolean isDefault;
private String name;

/**
* Instantiates a new Builder from an existing AddressPrefixPatch instance.
*
* @param addressPrefixPatch the instance to initialize the Builder with
*/
private Builder(AddressPrefixPatch addressPrefixPatch) {
this.isDefault = addressPrefixPatch.isDefault;
this.name = addressPrefixPatch.name;
Expand Down Expand Up @@ -77,6 +82,8 @@ public Builder name(String name) {
}
}

protected AddressPrefixPatch() { }

protected AddressPrefixPatch(Builder builder) {
isDefault = builder.isDefault;
name = builder.name;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
/*
* (C) Copyright IBM Corp. 2020, 2021, 2022.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
*/
package com.ibm.cloud.is.vpc.v1.model;

import com.ibm.cloud.is.vpc.v1.Vpc;
import com.ibm.cloud.sdk.core.util.UrlHelper;
import java.util.ArrayList;
import java.util.List;
import java.util.NoSuchElementException;

/**
* BackupPoliciesPager can be used to simplify the use of the "listBackupPolicies" method.
*/
public class BackupPoliciesPager {
private static class PageContext {
private String next;
public String getNext() {
return next;
}
public void setNext(String next) {
this.next = next;
}
}

protected boolean hasNext;
protected ListBackupPoliciesOptions options;
protected Vpc client;
protected PageContext pageContext;

// Hide the default ctor.
protected BackupPoliciesPager() { }

/**
* Constructs a new BackupPoliciesPager instance with the specified client and options model instance.
* @param client the Vpc instance to be used to invoke the "listBackupPolicies" method
* @param options the ListBackupPoliciesOptions instance to be used to invoke the "listBackupPolicies" method
*/
public BackupPoliciesPager(Vpc client, ListBackupPoliciesOptions options) {
if (options.start() != null) {
throw new IllegalArgumentException("The options 'start' field should not be set");
}

this.hasNext = true;
this.client = client;
this.options = options.newBuilder().build();
this.pageContext = new PageContext();
}

/**
* Returns true if there are more results to be retrieved.
* @return boolean
*/
public boolean hasNext() {
return hasNext;
}

/**
* Returns the next page of results.
* @return a List<BackupPolicy> that contains the next page of results
*/
public List<BackupPolicy> getNext() {
if (!hasNext()) {
throw new NoSuchElementException("No more results available");
}

ListBackupPoliciesOptions.Builder builder = this.options.newBuilder();
if (this.pageContext.getNext() != null) {
builder.start(this.pageContext.getNext());
}
this.options = builder.build();

BackupPolicyCollection result = client.listBackupPolicies(options).execute().getResult();

String next = null;
if (result.getNext() != null) {
String queryParam = UrlHelper.getQueryParam(result.getNext().getHref(), "start");
if (queryParam != null) {
next = queryParam;
}
}
this.pageContext.setNext(next);
if (next == null) {
this.hasNext = false;
}

return result.getBackupPolicies();
}

/**
* Returns all results by invoking getNext() repeatedly until all pages of results have been retrieved.
* @return a List&lt;BackupPolicy&gt; containing all results returned by the "listBackupPolicies" method
*/
public List<BackupPolicy> getAll() {
List<BackupPolicy> results = new ArrayList<>();
while (hasNext()) {
List<BackupPolicy> nextPage = getNext();
results.addAll(nextPage);
}
return results;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ public interface ResourceType {
@SerializedName("resource_type")
protected String resourceType;

protected BackupPolicy() { }

/**
* Gets the createdAt.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ public class BackupPolicyCollection extends GenericModel {
@SerializedName("total_count")
protected Long totalCount;

protected BackupPolicyCollection() { }

/**
* Gets the backupPolicies.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ public class BackupPolicyCollectionFirst extends GenericModel {

protected String href;

protected BackupPolicyCollectionFirst() { }

/**
* Gets the href.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ public class BackupPolicyCollectionNext extends GenericModel {

protected String href;

protected BackupPolicyCollectionNext() { }

/**
* Gets the href.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ public static class Builder {
private List<String> matchUserTags;
private String name;

/**
* Instantiates a new Builder from an existing BackupPolicyPatch instance.
*
* @param backupPolicyPatch the instance to initialize the Builder with
*/
private Builder(BackupPolicyPatch backupPolicyPatch) {
this.matchUserTags = backupPolicyPatch.matchUserTags;
this.name = backupPolicyPatch.name;
Expand Down Expand Up @@ -96,6 +101,8 @@ public Builder name(String name) {
}
}

protected BackupPolicyPatch() { }

protected BackupPolicyPatch(Builder builder) {
matchUserTags = builder.matchUserTags;
name = builder.name;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ public interface ResourceType {
@SerializedName("resource_type")
protected String resourceType;

protected BackupPolicyPlan() { }

/**
* Gets the active.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ public class BackupPolicyPlanCollection extends GenericModel {

protected List<BackupPolicyPlan> plans;

protected BackupPolicyPlanCollection() { }

/**
* Gets the plans.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ public class BackupPolicyPlanDeletionTrigger extends GenericModel {
@SerializedName("delete_over_count")
protected Long deleteOverCount;

protected BackupPolicyPlanDeletionTrigger() { }

/**
* Gets the deleteAfter.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ public static class Builder {
private Long deleteAfter;
private Long deleteOverCount;

/**
* Instantiates a new Builder from an existing BackupPolicyPlanDeletionTriggerPatch instance.
*
* @param backupPolicyPlanDeletionTriggerPatch the instance to initialize the Builder with
*/
private Builder(BackupPolicyPlanDeletionTriggerPatch backupPolicyPlanDeletionTriggerPatch) {
this.deleteAfter = backupPolicyPlanDeletionTriggerPatch.deleteAfter;
this.deleteOverCount = backupPolicyPlanDeletionTriggerPatch.deleteOverCount;
Expand Down Expand Up @@ -75,6 +80,8 @@ public Builder deleteOverCount(long deleteOverCount) {
}
}

protected BackupPolicyPlanDeletionTriggerPatch() { }

protected BackupPolicyPlanDeletionTriggerPatch(Builder builder) {
deleteAfter = builder.deleteAfter;
deleteOverCount = builder.deleteOverCount;
Expand Down
Loading