Skip to content
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions src/main/java/cloud/dnation/hetznerclient/HetznerApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -213,4 +213,26 @@ Call<GetServersBySelectorResponse> getServersBySelector(@Query("label_selector")
*/
@GET("/v1/primary_ips")
Call<GetAllPrimaryIpsResponse> getAllPrimaryIps(@Query("label_selector") String selector);


/**
* Get volume detail based on ID.
*
* @param id volume ID
* @return volume detail
* see <a href="https://docs.hetzner.cloud/#volumes-get-a-volume">API reference</a>
*/
@GET("/v1/volumes/{id}")
Call<GetVolumeByIdResponse> getVolumeById(@Path("id") long id);

/**
* Get all volumes.
*
* @param selector Can be used to filter resources by labels.
* The response will only contain resources matching the label selector.
* @return list of volumes
* see <a href="https://docs.hetzner.cloud/#volumes-get-all-volumes">API reference</a>
*/
@GET("/v1/volumes")
Call<GetVolumesResponse> getVolumes(@Query("label_selector") String selector);
}
56 changes: 56 additions & 0 deletions src/main/resources/api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,23 @@ components:
description: The total number of entries that exist in the database for this query. Nullable if unknown.
example: 100

GetVolumesResponse:
allOf:
- $ref: "#/components/schemas/AbstractSearchResponse"
properties:
volumes:
type: array
items:
$ref: "#/components/schemas/VolumeDetail"
type: object

GetVolumeByIdResponse:
properties:
volume:
$ref: "#/components/schemas/VolumeDetail"
type: object


GetDatacentersResponse:
allOf:
- $ref: "#/components/schemas/AbstractSearchResponse"
Expand Down Expand Up @@ -222,6 +239,9 @@ components:

CreateServerRequest:
properties:
automount:
description: Auto-mount Volumes after attach
type: boolean
datacenter:
description: ID or name of Datacenter to create Server in (must
not be used together with location)
Expand Down Expand Up @@ -283,6 +303,12 @@ components:
runcmd:
- [touch, /root/cloud-init-worked]
type: string
volumes:
description: Volume IDs which should be attached to the Server at the creation time. Volumes must be in the same Location.
type: array
items:
$ref: "#/components/schemas/Identifier"

title: CreateServerRequest
type: object

Expand Down Expand Up @@ -633,3 +659,33 @@ components:
example: false
type: boolean
type: object
VolumeDetail:
allOf:
- $ref: "#/components/schemas/IdentifiableResource"
properties:
name:
type: string
description: Name of the Resource. Must be unique per Project.
format:
description: Filesystem of the Volume if formatted on creation, null if not formatted on creation
type: string
server:
$ref: "#/components/schemas/Identifier"
description: ID of the Server the Volume is attached to, null if it is not attached at all
size:
description: Size in GB of the Volume
example: 40
type: integer
format: int32
linux_device:
description: Device path on the file system for the Volume
type: string
status:
description: Current status of the Volume
type: string
location:
description: Location of the Volume. Volume can only be attached to Servers in the same Location.
$ref: '#/components/schemas/LocationDetail'
labels:
description: User-defined labels (key-value pairs)
$ref: "#/components/schemas/Labeled"