diff --git a/core/errors_generated.go b/core/errors_generated.go index aacffeb..5dc763d 100644 --- a/core/errors_generated.go +++ b/core/errors_generated.go @@ -44,6 +44,7 @@ var ( ErrNoAvailableAddresses = fmt.Errorf("%w: no_available_addresses", katapult.ErrServiceUnavailable) ErrNoInterfaceAvailable = fmt.Errorf("%w: no_interface_available", katapult.ErrUnprocessableEntity) ErrNoUserAssociatedWithIdentity = fmt.Errorf("%w: no_user_associated_with_identity", katapult.ErrResourceNotFound) + ErrNoVirtualMachineForAPIToken = fmt.Errorf("%w: no_virtual_machine_for_api_token", katapult.ErrResourceNotFound) ErrObjectInTrash = fmt.Errorf("%w: object_in_trash", katapult.ErrNotAcceptable) ErrOperatingSystemNotFound = fmt.Errorf("%w: operating_system_not_found", katapult.ErrResourceNotFound) ErrOrganizationLimitReached = fmt.Errorf("%w: organization_limit_reached", katapult.ErrUnprocessableEntity) @@ -653,6 +654,22 @@ func NewNoUserAssociatedWithIdentityError(theError *katapult.ResponseError) *NoU } } +// NoVirtualMachineForAPITokenError: +// No virtual machine was found for the provided API token. +type NoVirtualMachineForAPITokenError struct { + katapult.CommonError +} + +func NewNoVirtualMachineForAPITokenError(theError *katapult.ResponseError) *NoVirtualMachineForAPITokenError { + return &NoVirtualMachineForAPITokenError{ + CommonError: katapult.NewCommonError( + ErrNoVirtualMachineForAPIToken, + "no_virtual_machine_for_api_token", + theError.Description, + ), + } +} + // ObjectInTrashError: // The object found is in the trash and therefore cannot be manipulated through the API. It should be restored in order to run this operation. type ObjectInTrashError struct { @@ -1252,6 +1269,8 @@ func castResponseError(theError *katapult.ResponseError) error { return NewNoInterfaceAvailableError(theError) case "no_user_associated_with_identity": return NewNoUserAssociatedWithIdentityError(theError) + case "no_virtual_machine_for_api_token": + return NewNoVirtualMachineForAPITokenError(theError) case "object_in_trash": return NewObjectInTrashError(theError) case "operating_system_not_found": diff --git a/schemas/core/v1.json b/schemas/core/v1.json index 197777e..90dd490 100644 --- a/schemas/core/v1.json +++ b/schemas/core/v1.json @@ -202,6 +202,13 @@ "endpoint": "CoreAPI/Endpoints/VirtualMachines/AllocateIPEndpoint", "group": "virtual_machines" }, + { + "path": "virtual_machine/authorized_keys", + "request_method": "GET", + "controller": null, + "endpoint": "CoreAPI/Endpoints/VirtualMachines/AuthorizedKeysEndpoint", + "group": "virtual_machines" + }, { "path": "organizations/:organization/virtual_machines/build", "request_method": "POST", @@ -7539,6 +7546,62 @@ "fields": [] } }, + { + "type": "endpoint", + "value": { + "id": "CoreAPI/Endpoints/VirtualMachines/AuthorizedKeysEndpoint", + "name": "Get authorized keys for a virtual machine", + "description": "Return the authorized keys for the virtual machine associated with the provided API token", + "http_status": 200, + "authenticator": null, + "argument_set": { + "id": "CoreAPI/Endpoints/VirtualMachines/AuthorizedKeysEndpoint/BaseArgumentSet", + "name": null, + "description": null, + "arguments": [] + }, + "fields": [ + { + "id": "CoreAPI/Endpoints/VirtualMachines/AuthorizedKeysEndpoint/AuthorizedKeysField", + "name": "authorized_keys", + "description": null, + "type": "Apia/Scalars/String", + "null": false, + "array": false, + "spec": { + "all": true, + "spec": null + } + } + ], + "potential_errors": [ + "CoreAPI/Endpoints/VirtualMachines/AuthorizedKeysEndpoint/NoVirtualMachineForAPIToken" + ], + "scopes": [ + "virtual_machines:authorized_keys" + ] + } + }, + { + "type": "argument_set", + "value": { + "id": "CoreAPI/Endpoints/VirtualMachines/AuthorizedKeysEndpoint/BaseArgumentSet", + "name": null, + "description": null, + "arguments": [] + } + }, + { + "type": "error", + "value": { + "id": "CoreAPI/Endpoints/VirtualMachines/AuthorizedKeysEndpoint/NoVirtualMachineForAPIToken", + "name": null, + "description": "No virtual machine was found for the provided API token", + "code": "no_virtual_machine_for_api_token", + "http_status": 404, + "fields": [] + } + }, { "type": "endpoint", "value": {