Skip to content
This repository has been archived by the owner on Dec 23, 2024. It is now read-only.

Commit

Permalink
Merge pull request #31 from VamshikShetty/05-vrf-patch
Browse files Browse the repository at this point in the history
Add patch to make vrf param required
  • Loading branch information
displague authored Aug 4, 2022
2 parents b0809cc + 8ec2eae commit 44b815b
Show file tree
Hide file tree
Showing 9 changed files with 80 additions and 7 deletions.
3 changes: 3 additions & 0 deletions equinix-openapi-metal/api/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19527,6 +19527,9 @@ components:
type: string
vrf:
$ref: '#/components/schemas/Vrf'
required:
- vrf
type: object
VrfIpReservationCreateInput:
properties:
cidr:
Expand Down
2 changes: 1 addition & 1 deletion equinix-openapi-metal/docs/FindIPAddressById200Response.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
|**details** | **String** | | [optional] |
|**project** | [**Project**](Project.md) | | [optional] |
|**type** | **String** | | [optional] |
|**vrf** | [**Vrf**](Vrf.md) | | [optional] |
|**vrf** | [**Vrf**](Vrf.md) | | |



Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
|**details** | **String** | | [optional] |
|**project** | [**Project**](Project.md) | | [optional] |
|**type** | **String** | | [optional] |
|**vrf** | [**Vrf**](Vrf.md) | | [optional] |
|**vrf** | [**Vrf**](Vrf.md) | | |



Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
|**details** | **String** | | [optional] |
|**project** | [**Project**](Project.md) | | [optional] |
|**type** | **String** | | [optional] |
|**vrf** | [**Vrf**](Vrf.md) | | [optional] |
|**vrf** | [**Vrf**](Vrf.md) | | |



2 changes: 1 addition & 1 deletion equinix-openapi-metal/docs/VrfIpReservation.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
|**state** | **String** | | [optional] |
|**tags** | **List<String>** | | [optional] |
|**type** | **String** | | [optional] |
|**vrf** | [**Vrf**](Vrf.md) | | [optional] |
|**vrf** | [**Vrf**](Vrf.md) | | |



Original file line number Diff line number Diff line change
Expand Up @@ -460,8 +460,8 @@ public VrfIpReservation vrf(Vrf vrf) {
* Get vrf
* @return vrf
**/
@javax.annotation.Nullable
@ApiModelProperty(value = "")
@javax.annotation.Nonnull
@ApiModelProperty(required = true, value = "")

public Vrf getVrf() {
return vrf;
Expand Down Expand Up @@ -601,6 +601,7 @@ private String toIndentedString(Object o) {

// a set of required properties/fields (JSON key names)
openapiRequiredFields = new HashSet<String>();
openapiRequiredFields.add("vrf");
}

/**
Expand All @@ -617,6 +618,13 @@ public static void validateJsonObject(JsonObject jsonObj) throws IOException {
throw new IllegalArgumentException(String.format("The required field(s) %s in VrfIpReservation is not found in the empty JSON string", VrfIpReservation.openapiRequiredFields.toString()));
}
}

// check to make sure all required properties/fields are present in the JSON string
for (String requiredField : VrfIpReservation.openapiRequiredFields) {
if (jsonObj.get(requiredField) == null) {
throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString()));
}
}
// validate the optional field `created_by`
if (jsonObj.get("created_by") != null && !jsonObj.get("created_by").isJsonNull()) {
Href.validateJsonObject(jsonObj.getAsJsonObject("created_by"));
Expand Down
41 changes: 41 additions & 0 deletions examples/ReserveIpAddresses.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import com.equinix.openapi.ApiClient;
import com.equinix.openapi.ApiException;
import com.equinix.openapi.Configuration;
import com.equinix.openapi.auth.ApiKeyAuth;
import com.equinix.openapi.metal.v1.api.IpAddressesApi;
import com.equinix.openapi.metal.v1.model.IPReservationRequestInput;
import com.equinix.openapi.metal.v1.model.RequestIPReservationRequest;

import java.util.UUID;

public class ReserveIpAddresses {
public static void main(String[] args) {
ApiClient defaultClient = Configuration.getDefaultApiClient();

// Spec is maintaing base path hence dont have to set it explicitly
// defaultClient.setBasePath("<Metal API base path>");

// Configure API key authorization: x_auth_token
ApiKeyAuth x_auth_token = (ApiKeyAuth) defaultClient.getAuthentication("x_auth_token");
x_auth_token.setApiKey(args[0]);

IpAddressesApi ipAddressesApiInst = new IpAddressesApi(defaultClient);
try {

UUID uuid = UUID.fromString(args[1]);
IPReservationRequestInput iPReservationRequestInput = new IPReservationRequestInput();
iPReservationRequestInput.setType("public_ipv4");
iPReservationRequestInput.setQuantity(4);
iPReservationRequestInput.setMetro("DA");
RequestIPReservationRequest requestIPReservationRequest = new RequestIPReservationRequest(iPReservationRequestInput);

System.out.println(ipAddressesApiInst.requestIPReservation(uuid, requestIPReservationRequest));
} catch (ApiException e) {
System.out.println(String.format("Response HTTP status code : %s", e.getCode()));
System.out.println(String.format("Response HTTP headers : %s", e.getResponseHeaders()));
System.out.println(String.format("Response HTTP body : %s", e.getResponseBody()));
System.out.println(String.format("Exception message : %s", e.getMessage()));
e.printStackTrace();
}
}
}
17 changes: 17 additions & 0 deletions patches/spec.fetched.json/05-reserveIp-oneof-vrf-required.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
diff --git a/spec/oas3.patched.json b/spec/oas3.patched.json
index 26cc226..c74f6f9 100644
--- a/spec/oas3.patched.json
+++ b/spec/oas3.patched.json
@@ -4745,7 +4745,11 @@
"vrf": {
"$ref": "#/components/schemas/Vrf"
}
- }
+ },
+ "required": [
+ "vrf"
+ ],
+ "type": "object"
},
"VrfIpReservationCreateInput": {
"properties": {
6 changes: 5 additions & 1 deletion spec/oas3.patched.json
Original file line number Diff line number Diff line change
Expand Up @@ -4745,7 +4745,11 @@
"vrf": {
"$ref": "#/components/schemas/Vrf"
}
}
},
"required": [
"vrf"
],
"type": "object"
},
"VrfIpReservationCreateInput": {
"properties": {
Expand Down

0 comments on commit 44b815b

Please sign in to comment.