From c96c855fdac36de49291526d06ef09c515df2f40 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D7=A0=CF=85=CE=B1=CE=B7=20=D7=A0=CF=85=CE=B1=CE=B7=D1=95?= =?UTF-8?q?=CF=83=CE=B7?= Date: Fri, 6 Mar 2026 12:38:44 -0800 Subject: [PATCH 1/3] feat: add file management and deploy SDK support MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add FileService with Upload, List, Get, Delete methods for managing files in the NATS Object Store. Add FileDeploy and FileStatus methods to NodeService for deploying files to agents with SHA-based idempotency and template rendering support. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- docs/gen/gen.md | 1471 +++++++++++++++++++++++++------- docs/gen/osapi.md | 244 +++++- pkg/osapi/file.go | 157 ++++ pkg/osapi/file_public_test.go | 489 +++++++++++ pkg/osapi/file_types.go | 152 ++++ pkg/osapi/file_types_test.go | 256 ++++++ pkg/osapi/gen/api.yaml | 477 +++++++++++ pkg/osapi/gen/client.gen.go | 1379 ++++++++++++++++++++++++++---- pkg/osapi/node.go | 103 +++ pkg/osapi/node_public_test.go | 294 +++++++ pkg/osapi/osapi.go | 4 + pkg/osapi/osapi_public_test.go | 1 + 12 files changed, 4552 insertions(+), 475 deletions(-) create mode 100644 pkg/osapi/file.go create mode 100644 pkg/osapi/file_public_test.go create mode 100644 pkg/osapi/file_types.go create mode 100644 pkg/osapi/file_types_test.go diff --git a/docs/gen/gen.md b/docs/gen/gen.md index 21ae5b9..00d42aa 100644 --- a/docs/gen/gen.md +++ b/docs/gen/gen.md @@ -15,6 +15,7 @@ Package gen contains generated code for the OSAPI REST API client. ## Index - [Constants](<#constants>) +- [func NewDeleteFileByNameRequest\(server string, name FileName\) \(\*http.Request, error\)](<#NewDeleteFileByNameRequest>) - [func NewDeleteJobByIDRequest\(server string, id openapi\_types.UUID\) \(\*http.Request, error\)](<#NewDeleteJobByIDRequest>) - [func NewDrainAgentRequest\(server string, hostname string\) \(\*http.Request, error\)](<#NewDrainAgentRequest>) - [func NewGetAgentDetailsRequest\(server string, hostname string\) \(\*http.Request, error\)](<#NewGetAgentDetailsRequest>) @@ -22,6 +23,8 @@ Package gen contains generated code for the OSAPI REST API client. - [func NewGetAuditExportRequest\(server string\) \(\*http.Request, error\)](<#NewGetAuditExportRequest>) - [func NewGetAuditLogByIDRequest\(server string, id openapi\_types.UUID\) \(\*http.Request, error\)](<#NewGetAuditLogByIDRequest>) - [func NewGetAuditLogsRequest\(server string, params \*GetAuditLogsParams\) \(\*http.Request, error\)](<#NewGetAuditLogsRequest>) +- [func NewGetFileByNameRequest\(server string, name FileName\) \(\*http.Request, error\)](<#NewGetFileByNameRequest>) +- [func NewGetFilesRequest\(server string\) \(\*http.Request, error\)](<#NewGetFilesRequest>) - [func NewGetHealthReadyRequest\(server string\) \(\*http.Request, error\)](<#NewGetHealthReadyRequest>) - [func NewGetHealthRequest\(server string\) \(\*http.Request, error\)](<#NewGetHealthRequest>) - [func NewGetHealthStatusRequest\(server string\) \(\*http.Request, error\)](<#NewGetHealthStatusRequest>) @@ -37,12 +40,18 @@ Package gen contains generated code for the OSAPI REST API client. - [func NewGetNodeStatusRequest\(server string, hostname Hostname\) \(\*http.Request, error\)](<#NewGetNodeStatusRequest>) - [func NewGetNodeUptimeRequest\(server string, hostname Hostname\) \(\*http.Request, error\)](<#NewGetNodeUptimeRequest>) - [func NewGetVersionRequest\(server string\) \(\*http.Request, error\)](<#NewGetVersionRequest>) +- [func NewPostFileRequest\(server string, body PostFileJSONRequestBody\) \(\*http.Request, error\)](<#NewPostFileRequest>) +- [func NewPostFileRequestWithBody\(server string, contentType string, body io.Reader\) \(\*http.Request, error\)](<#NewPostFileRequestWithBody>) - [func NewPostJobRequest\(server string, body PostJobJSONRequestBody\) \(\*http.Request, error\)](<#NewPostJobRequest>) - [func NewPostJobRequestWithBody\(server string, contentType string, body io.Reader\) \(\*http.Request, error\)](<#NewPostJobRequestWithBody>) - [func NewPostNodeCommandExecRequest\(server string, hostname Hostname, body PostNodeCommandExecJSONRequestBody\) \(\*http.Request, error\)](<#NewPostNodeCommandExecRequest>) - [func NewPostNodeCommandExecRequestWithBody\(server string, hostname Hostname, contentType string, body io.Reader\) \(\*http.Request, error\)](<#NewPostNodeCommandExecRequestWithBody>) - [func NewPostNodeCommandShellRequest\(server string, hostname Hostname, body PostNodeCommandShellJSONRequestBody\) \(\*http.Request, error\)](<#NewPostNodeCommandShellRequest>) - [func NewPostNodeCommandShellRequestWithBody\(server string, hostname Hostname, contentType string, body io.Reader\) \(\*http.Request, error\)](<#NewPostNodeCommandShellRequestWithBody>) +- [func NewPostNodeFileDeployRequest\(server string, hostname Hostname, body PostNodeFileDeployJSONRequestBody\) \(\*http.Request, error\)](<#NewPostNodeFileDeployRequest>) +- [func NewPostNodeFileDeployRequestWithBody\(server string, hostname Hostname, contentType string, body io.Reader\) \(\*http.Request, error\)](<#NewPostNodeFileDeployRequestWithBody>) +- [func NewPostNodeFileStatusRequest\(server string, hostname Hostname, body PostNodeFileStatusJSONRequestBody\) \(\*http.Request, error\)](<#NewPostNodeFileStatusRequest>) +- [func NewPostNodeFileStatusRequestWithBody\(server string, hostname Hostname, contentType string, body io.Reader\) \(\*http.Request, error\)](<#NewPostNodeFileStatusRequestWithBody>) - [func NewPostNodeNetworkPingRequest\(server string, hostname Hostname, body PostNodeNetworkPingJSONRequestBody\) \(\*http.Request, error\)](<#NewPostNodeNetworkPingRequest>) - [func NewPostNodeNetworkPingRequestWithBody\(server string, hostname Hostname, contentType string, body io.Reader\) \(\*http.Request, error\)](<#NewPostNodeNetworkPingRequestWithBody>) - [func NewPutNodeNetworkDNSRequest\(server string, hostname Hostname, body PutNodeNetworkDNSJSONRequestBody\) \(\*http.Request, error\)](<#NewPutNodeNetworkDNSRequest>) @@ -59,6 +68,7 @@ Package gen contains generated code for the OSAPI REST API client. - [type AuditEntryResponse](<#AuditEntryResponse>) - [type Client](<#Client>) - [func NewClient\(server string, opts ...ClientOption\) \(\*Client, error\)](<#NewClient>) + - [func \(c \*Client\) DeleteFileByName\(ctx context.Context, name FileName, reqEditors ...RequestEditorFn\) \(\*http.Response, error\)](<#Client.DeleteFileByName>) - [func \(c \*Client\) DeleteJobByID\(ctx context.Context, id openapi\_types.UUID, reqEditors ...RequestEditorFn\) \(\*http.Response, error\)](<#Client.DeleteJobByID>) - [func \(c \*Client\) DrainAgent\(ctx context.Context, hostname string, reqEditors ...RequestEditorFn\) \(\*http.Response, error\)](<#Client.DrainAgent>) - [func \(c \*Client\) GetAgent\(ctx context.Context, reqEditors ...RequestEditorFn\) \(\*http.Response, error\)](<#Client.GetAgent>) @@ -66,6 +76,8 @@ Package gen contains generated code for the OSAPI REST API client. - [func \(c \*Client\) GetAuditExport\(ctx context.Context, reqEditors ...RequestEditorFn\) \(\*http.Response, error\)](<#Client.GetAuditExport>) - [func \(c \*Client\) GetAuditLogByID\(ctx context.Context, id openapi\_types.UUID, reqEditors ...RequestEditorFn\) \(\*http.Response, error\)](<#Client.GetAuditLogByID>) - [func \(c \*Client\) GetAuditLogs\(ctx context.Context, params \*GetAuditLogsParams, reqEditors ...RequestEditorFn\) \(\*http.Response, error\)](<#Client.GetAuditLogs>) + - [func \(c \*Client\) GetFileByName\(ctx context.Context, name FileName, reqEditors ...RequestEditorFn\) \(\*http.Response, error\)](<#Client.GetFileByName>) + - [func \(c \*Client\) GetFiles\(ctx context.Context, reqEditors ...RequestEditorFn\) \(\*http.Response, error\)](<#Client.GetFiles>) - [func \(c \*Client\) GetHealth\(ctx context.Context, reqEditors ...RequestEditorFn\) \(\*http.Response, error\)](<#Client.GetHealth>) - [func \(c \*Client\) GetHealthReady\(ctx context.Context, reqEditors ...RequestEditorFn\) \(\*http.Response, error\)](<#Client.GetHealthReady>) - [func \(c \*Client\) GetHealthStatus\(ctx context.Context, reqEditors ...RequestEditorFn\) \(\*http.Response, error\)](<#Client.GetHealthStatus>) @@ -81,12 +93,18 @@ Package gen contains generated code for the OSAPI REST API client. - [func \(c \*Client\) GetNodeStatus\(ctx context.Context, hostname Hostname, reqEditors ...RequestEditorFn\) \(\*http.Response, error\)](<#Client.GetNodeStatus>) - [func \(c \*Client\) GetNodeUptime\(ctx context.Context, hostname Hostname, reqEditors ...RequestEditorFn\) \(\*http.Response, error\)](<#Client.GetNodeUptime>) - [func \(c \*Client\) GetVersion\(ctx context.Context, reqEditors ...RequestEditorFn\) \(\*http.Response, error\)](<#Client.GetVersion>) + - [func \(c \*Client\) PostFile\(ctx context.Context, body PostFileJSONRequestBody, reqEditors ...RequestEditorFn\) \(\*http.Response, error\)](<#Client.PostFile>) + - [func \(c \*Client\) PostFileWithBody\(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn\) \(\*http.Response, error\)](<#Client.PostFileWithBody>) - [func \(c \*Client\) PostJob\(ctx context.Context, body PostJobJSONRequestBody, reqEditors ...RequestEditorFn\) \(\*http.Response, error\)](<#Client.PostJob>) - [func \(c \*Client\) PostJobWithBody\(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn\) \(\*http.Response, error\)](<#Client.PostJobWithBody>) - [func \(c \*Client\) PostNodeCommandExec\(ctx context.Context, hostname Hostname, body PostNodeCommandExecJSONRequestBody, reqEditors ...RequestEditorFn\) \(\*http.Response, error\)](<#Client.PostNodeCommandExec>) - [func \(c \*Client\) PostNodeCommandExecWithBody\(ctx context.Context, hostname Hostname, contentType string, body io.Reader, reqEditors ...RequestEditorFn\) \(\*http.Response, error\)](<#Client.PostNodeCommandExecWithBody>) - [func \(c \*Client\) PostNodeCommandShell\(ctx context.Context, hostname Hostname, body PostNodeCommandShellJSONRequestBody, reqEditors ...RequestEditorFn\) \(\*http.Response, error\)](<#Client.PostNodeCommandShell>) - [func \(c \*Client\) PostNodeCommandShellWithBody\(ctx context.Context, hostname Hostname, contentType string, body io.Reader, reqEditors ...RequestEditorFn\) \(\*http.Response, error\)](<#Client.PostNodeCommandShellWithBody>) + - [func \(c \*Client\) PostNodeFileDeploy\(ctx context.Context, hostname Hostname, body PostNodeFileDeployJSONRequestBody, reqEditors ...RequestEditorFn\) \(\*http.Response, error\)](<#Client.PostNodeFileDeploy>) + - [func \(c \*Client\) PostNodeFileDeployWithBody\(ctx context.Context, hostname Hostname, contentType string, body io.Reader, reqEditors ...RequestEditorFn\) \(\*http.Response, error\)](<#Client.PostNodeFileDeployWithBody>) + - [func \(c \*Client\) PostNodeFileStatus\(ctx context.Context, hostname Hostname, body PostNodeFileStatusJSONRequestBody, reqEditors ...RequestEditorFn\) \(\*http.Response, error\)](<#Client.PostNodeFileStatus>) + - [func \(c \*Client\) PostNodeFileStatusWithBody\(ctx context.Context, hostname Hostname, contentType string, body io.Reader, reqEditors ...RequestEditorFn\) \(\*http.Response, error\)](<#Client.PostNodeFileStatusWithBody>) - [func \(c \*Client\) PostNodeNetworkPing\(ctx context.Context, hostname Hostname, body PostNodeNetworkPingJSONRequestBody, reqEditors ...RequestEditorFn\) \(\*http.Response, error\)](<#Client.PostNodeNetworkPing>) - [func \(c \*Client\) PostNodeNetworkPingWithBody\(ctx context.Context, hostname Hostname, contentType string, body io.Reader, reqEditors ...RequestEditorFn\) \(\*http.Response, error\)](<#Client.PostNodeNetworkPingWithBody>) - [func \(c \*Client\) PutNodeNetworkDNS\(ctx context.Context, hostname Hostname, body PutNodeNetworkDNSJSONRequestBody, reqEditors ...RequestEditorFn\) \(\*http.Response, error\)](<#Client.PutNodeNetworkDNS>) @@ -101,6 +119,7 @@ Package gen contains generated code for the OSAPI REST API client. - [func WithRequestEditorFn\(fn RequestEditorFn\) ClientOption](<#WithRequestEditorFn>) - [type ClientWithResponses](<#ClientWithResponses>) - [func NewClientWithResponses\(server string, opts ...ClientOption\) \(\*ClientWithResponses, error\)](<#NewClientWithResponses>) + - [func \(c \*ClientWithResponses\) DeleteFileByNameWithResponse\(ctx context.Context, name FileName, reqEditors ...RequestEditorFn\) \(\*DeleteFileByNameResponse, error\)](<#ClientWithResponses.DeleteFileByNameWithResponse>) - [func \(c \*ClientWithResponses\) DeleteJobByIDWithResponse\(ctx context.Context, id openapi\_types.UUID, reqEditors ...RequestEditorFn\) \(\*DeleteJobByIDResponse, error\)](<#ClientWithResponses.DeleteJobByIDWithResponse>) - [func \(c \*ClientWithResponses\) DrainAgentWithResponse\(ctx context.Context, hostname string, reqEditors ...RequestEditorFn\) \(\*DrainAgentResponse, error\)](<#ClientWithResponses.DrainAgentWithResponse>) - [func \(c \*ClientWithResponses\) GetAgentDetailsWithResponse\(ctx context.Context, hostname string, reqEditors ...RequestEditorFn\) \(\*GetAgentDetailsResponse, error\)](<#ClientWithResponses.GetAgentDetailsWithResponse>) @@ -108,6 +127,8 @@ Package gen contains generated code for the OSAPI REST API client. - [func \(c \*ClientWithResponses\) GetAuditExportWithResponse\(ctx context.Context, reqEditors ...RequestEditorFn\) \(\*GetAuditExportResponse, error\)](<#ClientWithResponses.GetAuditExportWithResponse>) - [func \(c \*ClientWithResponses\) GetAuditLogByIDWithResponse\(ctx context.Context, id openapi\_types.UUID, reqEditors ...RequestEditorFn\) \(\*GetAuditLogByIDResponse, error\)](<#ClientWithResponses.GetAuditLogByIDWithResponse>) - [func \(c \*ClientWithResponses\) GetAuditLogsWithResponse\(ctx context.Context, params \*GetAuditLogsParams, reqEditors ...RequestEditorFn\) \(\*GetAuditLogsResponse, error\)](<#ClientWithResponses.GetAuditLogsWithResponse>) + - [func \(c \*ClientWithResponses\) GetFileByNameWithResponse\(ctx context.Context, name FileName, reqEditors ...RequestEditorFn\) \(\*GetFileByNameResponse, error\)](<#ClientWithResponses.GetFileByNameWithResponse>) + - [func \(c \*ClientWithResponses\) GetFilesWithResponse\(ctx context.Context, reqEditors ...RequestEditorFn\) \(\*GetFilesResponse, error\)](<#ClientWithResponses.GetFilesWithResponse>) - [func \(c \*ClientWithResponses\) GetHealthReadyWithResponse\(ctx context.Context, reqEditors ...RequestEditorFn\) \(\*GetHealthReadyResponse, error\)](<#ClientWithResponses.GetHealthReadyWithResponse>) - [func \(c \*ClientWithResponses\) GetHealthStatusWithResponse\(ctx context.Context, reqEditors ...RequestEditorFn\) \(\*GetHealthStatusResponse, error\)](<#ClientWithResponses.GetHealthStatusWithResponse>) - [func \(c \*ClientWithResponses\) GetHealthWithResponse\(ctx context.Context, reqEditors ...RequestEditorFn\) \(\*GetHealthResponse, error\)](<#ClientWithResponses.GetHealthWithResponse>) @@ -123,12 +144,18 @@ Package gen contains generated code for the OSAPI REST API client. - [func \(c \*ClientWithResponses\) GetNodeStatusWithResponse\(ctx context.Context, hostname Hostname, reqEditors ...RequestEditorFn\) \(\*GetNodeStatusResponse, error\)](<#ClientWithResponses.GetNodeStatusWithResponse>) - [func \(c \*ClientWithResponses\) GetNodeUptimeWithResponse\(ctx context.Context, hostname Hostname, reqEditors ...RequestEditorFn\) \(\*GetNodeUptimeResponse, error\)](<#ClientWithResponses.GetNodeUptimeWithResponse>) - [func \(c \*ClientWithResponses\) GetVersionWithResponse\(ctx context.Context, reqEditors ...RequestEditorFn\) \(\*GetVersionResponse, error\)](<#ClientWithResponses.GetVersionWithResponse>) + - [func \(c \*ClientWithResponses\) PostFileWithBodyWithResponse\(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn\) \(\*PostFileResponse, error\)](<#ClientWithResponses.PostFileWithBodyWithResponse>) + - [func \(c \*ClientWithResponses\) PostFileWithResponse\(ctx context.Context, body PostFileJSONRequestBody, reqEditors ...RequestEditorFn\) \(\*PostFileResponse, error\)](<#ClientWithResponses.PostFileWithResponse>) - [func \(c \*ClientWithResponses\) PostJobWithBodyWithResponse\(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn\) \(\*PostJobResponse, error\)](<#ClientWithResponses.PostJobWithBodyWithResponse>) - [func \(c \*ClientWithResponses\) PostJobWithResponse\(ctx context.Context, body PostJobJSONRequestBody, reqEditors ...RequestEditorFn\) \(\*PostJobResponse, error\)](<#ClientWithResponses.PostJobWithResponse>) - [func \(c \*ClientWithResponses\) PostNodeCommandExecWithBodyWithResponse\(ctx context.Context, hostname Hostname, contentType string, body io.Reader, reqEditors ...RequestEditorFn\) \(\*PostNodeCommandExecResponse, error\)](<#ClientWithResponses.PostNodeCommandExecWithBodyWithResponse>) - [func \(c \*ClientWithResponses\) PostNodeCommandExecWithResponse\(ctx context.Context, hostname Hostname, body PostNodeCommandExecJSONRequestBody, reqEditors ...RequestEditorFn\) \(\*PostNodeCommandExecResponse, error\)](<#ClientWithResponses.PostNodeCommandExecWithResponse>) - [func \(c \*ClientWithResponses\) PostNodeCommandShellWithBodyWithResponse\(ctx context.Context, hostname Hostname, contentType string, body io.Reader, reqEditors ...RequestEditorFn\) \(\*PostNodeCommandShellResponse, error\)](<#ClientWithResponses.PostNodeCommandShellWithBodyWithResponse>) - [func \(c \*ClientWithResponses\) PostNodeCommandShellWithResponse\(ctx context.Context, hostname Hostname, body PostNodeCommandShellJSONRequestBody, reqEditors ...RequestEditorFn\) \(\*PostNodeCommandShellResponse, error\)](<#ClientWithResponses.PostNodeCommandShellWithResponse>) + - [func \(c \*ClientWithResponses\) PostNodeFileDeployWithBodyWithResponse\(ctx context.Context, hostname Hostname, contentType string, body io.Reader, reqEditors ...RequestEditorFn\) \(\*PostNodeFileDeployResponse, error\)](<#ClientWithResponses.PostNodeFileDeployWithBodyWithResponse>) + - [func \(c \*ClientWithResponses\) PostNodeFileDeployWithResponse\(ctx context.Context, hostname Hostname, body PostNodeFileDeployJSONRequestBody, reqEditors ...RequestEditorFn\) \(\*PostNodeFileDeployResponse, error\)](<#ClientWithResponses.PostNodeFileDeployWithResponse>) + - [func \(c \*ClientWithResponses\) PostNodeFileStatusWithBodyWithResponse\(ctx context.Context, hostname Hostname, contentType string, body io.Reader, reqEditors ...RequestEditorFn\) \(\*PostNodeFileStatusResponse, error\)](<#ClientWithResponses.PostNodeFileStatusWithBodyWithResponse>) + - [func \(c \*ClientWithResponses\) PostNodeFileStatusWithResponse\(ctx context.Context, hostname Hostname, body PostNodeFileStatusJSONRequestBody, reqEditors ...RequestEditorFn\) \(\*PostNodeFileStatusResponse, error\)](<#ClientWithResponses.PostNodeFileStatusWithResponse>) - [func \(c \*ClientWithResponses\) PostNodeNetworkPingWithBodyWithResponse\(ctx context.Context, hostname Hostname, contentType string, body io.Reader, reqEditors ...RequestEditorFn\) \(\*PostNodeNetworkPingResponse, error\)](<#ClientWithResponses.PostNodeNetworkPingWithBodyWithResponse>) - [func \(c \*ClientWithResponses\) PostNodeNetworkPingWithResponse\(ctx context.Context, hostname Hostname, body PostNodeNetworkPingJSONRequestBody, reqEditors ...RequestEditorFn\) \(\*PostNodeNetworkPingResponse, error\)](<#ClientWithResponses.PostNodeNetworkPingWithResponse>) - [func \(c \*ClientWithResponses\) PutNodeNetworkDNSWithBodyWithResponse\(ctx context.Context, hostname Hostname, contentType string, body io.Reader, reqEditors ...RequestEditorFn\) \(\*PutNodeNetworkDNSResponse, error\)](<#ClientWithResponses.PutNodeNetworkDNSWithBodyWithResponse>) @@ -152,6 +179,10 @@ Package gen contains generated code for the OSAPI REST API client. - [type DNSUpdateCollectionResponse](<#DNSUpdateCollectionResponse>) - [type DNSUpdateResultItem](<#DNSUpdateResultItem>) - [type DNSUpdateResultItemStatus](<#DNSUpdateResultItemStatus>) +- [type DeleteFileByNameResponse](<#DeleteFileByNameResponse>) + - [func ParseDeleteFileByNameResponse\(rsp \*http.Response\) \(\*DeleteFileByNameResponse, error\)](<#ParseDeleteFileByNameResponse>) + - [func \(r DeleteFileByNameResponse\) Status\(\) string](<#DeleteFileByNameResponse.Status>) + - [func \(r DeleteFileByNameResponse\) StatusCode\(\) int](<#DeleteFileByNameResponse.StatusCode>) - [type DeleteJobByIDResponse](<#DeleteJobByIDResponse>) - [func ParseDeleteJobByIDResponse\(rsp \*http.Response\) \(\*DeleteJobByIDResponse, error\)](<#ParseDeleteJobByIDResponse>) - [func \(r DeleteJobByIDResponse\) Status\(\) string](<#DeleteJobByIDResponse.Status>) @@ -165,6 +196,18 @@ Package gen contains generated code for the OSAPI REST API client. - [func \(r DrainAgentResponse\) Status\(\) string](<#DrainAgentResponse.Status>) - [func \(r DrainAgentResponse\) StatusCode\(\) int](<#DrainAgentResponse.StatusCode>) - [type ErrorResponse](<#ErrorResponse>) +- [type FileDeleteResponse](<#FileDeleteResponse>) +- [type FileDeployRequest](<#FileDeployRequest>) +- [type FileDeployRequestContentType](<#FileDeployRequestContentType>) +- [type FileDeployResponse](<#FileDeployResponse>) +- [type FileInfo](<#FileInfo>) +- [type FileInfoResponse](<#FileInfoResponse>) +- [type FileListResponse](<#FileListResponse>) +- [type FileName](<#FileName>) +- [type FileStatusRequest](<#FileStatusRequest>) +- [type FileStatusResponse](<#FileStatusResponse>) +- [type FileUploadRequest](<#FileUploadRequest>) +- [type FileUploadResponse](<#FileUploadResponse>) - [type GetAgentDetailsResponse](<#GetAgentDetailsResponse>) - [func ParseGetAgentDetailsResponse\(rsp \*http.Response\) \(\*GetAgentDetailsResponse, error\)](<#ParseGetAgentDetailsResponse>) - [func \(r GetAgentDetailsResponse\) Status\(\) string](<#GetAgentDetailsResponse.Status>) @@ -186,6 +229,14 @@ Package gen contains generated code for the OSAPI REST API client. - [func ParseGetAuditLogsResponse\(rsp \*http.Response\) \(\*GetAuditLogsResponse, error\)](<#ParseGetAuditLogsResponse>) - [func \(r GetAuditLogsResponse\) Status\(\) string](<#GetAuditLogsResponse.Status>) - [func \(r GetAuditLogsResponse\) StatusCode\(\) int](<#GetAuditLogsResponse.StatusCode>) +- [type GetFileByNameResponse](<#GetFileByNameResponse>) + - [func ParseGetFileByNameResponse\(rsp \*http.Response\) \(\*GetFileByNameResponse, error\)](<#ParseGetFileByNameResponse>) + - [func \(r GetFileByNameResponse\) Status\(\) string](<#GetFileByNameResponse.Status>) + - [func \(r GetFileByNameResponse\) StatusCode\(\) int](<#GetFileByNameResponse.StatusCode>) +- [type GetFilesResponse](<#GetFilesResponse>) + - [func ParseGetFilesResponse\(rsp \*http.Response\) \(\*GetFilesResponse, error\)](<#ParseGetFilesResponse>) + - [func \(r GetFilesResponse\) Status\(\) string](<#GetFilesResponse.Status>) + - [func \(r GetFilesResponse\) StatusCode\(\) int](<#GetFilesResponse.StatusCode>) - [type GetHealthReadyResponse](<#GetHealthReadyResponse>) - [func ParseGetHealthReadyResponse\(rsp \*http.Response\) \(\*GetHealthReadyResponse, error\)](<#ParseGetHealthReadyResponse>) - [func \(r GetHealthReadyResponse\) Status\(\) string](<#GetHealthReadyResponse.Status>) @@ -277,6 +328,11 @@ Package gen contains generated code for the OSAPI REST API client. - [type OSInfoResultItem](<#OSInfoResultItem>) - [type PingCollectionResponse](<#PingCollectionResponse>) - [type PingResponse](<#PingResponse>) +- [type PostFileJSONRequestBody](<#PostFileJSONRequestBody>) +- [type PostFileResponse](<#PostFileResponse>) + - [func ParsePostFileResponse\(rsp \*http.Response\) \(\*PostFileResponse, error\)](<#ParsePostFileResponse>) + - [func \(r PostFileResponse\) Status\(\) string](<#PostFileResponse.Status>) + - [func \(r PostFileResponse\) StatusCode\(\) int](<#PostFileResponse.StatusCode>) - [type PostJobJSONRequestBody](<#PostJobJSONRequestBody>) - [type PostJobResponse](<#PostJobResponse>) - [func ParsePostJobResponse\(rsp \*http.Response\) \(\*PostJobResponse, error\)](<#ParsePostJobResponse>) @@ -292,6 +348,16 @@ Package gen contains generated code for the OSAPI REST API client. - [func ParsePostNodeCommandShellResponse\(rsp \*http.Response\) \(\*PostNodeCommandShellResponse, error\)](<#ParsePostNodeCommandShellResponse>) - [func \(r PostNodeCommandShellResponse\) Status\(\) string](<#PostNodeCommandShellResponse.Status>) - [func \(r PostNodeCommandShellResponse\) StatusCode\(\) int](<#PostNodeCommandShellResponse.StatusCode>) +- [type PostNodeFileDeployJSONRequestBody](<#PostNodeFileDeployJSONRequestBody>) +- [type PostNodeFileDeployResponse](<#PostNodeFileDeployResponse>) + - [func ParsePostNodeFileDeployResponse\(rsp \*http.Response\) \(\*PostNodeFileDeployResponse, error\)](<#ParsePostNodeFileDeployResponse>) + - [func \(r PostNodeFileDeployResponse\) Status\(\) string](<#PostNodeFileDeployResponse.Status>) + - [func \(r PostNodeFileDeployResponse\) StatusCode\(\) int](<#PostNodeFileDeployResponse.StatusCode>) +- [type PostNodeFileStatusJSONRequestBody](<#PostNodeFileStatusJSONRequestBody>) +- [type PostNodeFileStatusResponse](<#PostNodeFileStatusResponse>) + - [func ParsePostNodeFileStatusResponse\(rsp \*http.Response\) \(\*PostNodeFileStatusResponse, error\)](<#ParsePostNodeFileStatusResponse>) + - [func \(r PostNodeFileStatusResponse\) Status\(\) string](<#PostNodeFileStatusResponse.Status>) + - [func \(r PostNodeFileStatusResponse\) StatusCode\(\) int](<#PostNodeFileStatusResponse.StatusCode>) - [type PostNodeNetworkPingJSONBody](<#PostNodeNetworkPingJSONBody>) - [type PostNodeNetworkPingJSONRequestBody](<#PostNodeNetworkPingJSONRequestBody>) - [type PostNodeNetworkPingResponse](<#PostNodeNetworkPingResponse>) @@ -334,8 +400,17 @@ const ( ) ``` + +## func [NewDeleteFileByNameRequest]() + +```go +func NewDeleteFileByNameRequest(server string, name FileName) (*http.Request, error) +``` + +NewDeleteFileByNameRequest generates requests for DeleteFileByName + -## func [NewDeleteJobByIDRequest]() +## func [NewDeleteJobByIDRequest]() ```go func NewDeleteJobByIDRequest(server string, id openapi_types.UUID) (*http.Request, error) @@ -344,7 +419,7 @@ func NewDeleteJobByIDRequest(server string, id openapi_types.UUID) (*http.Reques NewDeleteJobByIDRequest generates requests for DeleteJobByID -## func [NewDrainAgentRequest]() +## func [NewDrainAgentRequest]() ```go func NewDrainAgentRequest(server string, hostname string) (*http.Request, error) @@ -353,7 +428,7 @@ func NewDrainAgentRequest(server string, hostname string) (*http.Request, error) NewDrainAgentRequest generates requests for DrainAgent -## func [NewGetAgentDetailsRequest]() +## func [NewGetAgentDetailsRequest]() ```go func NewGetAgentDetailsRequest(server string, hostname string) (*http.Request, error) @@ -362,7 +437,7 @@ func NewGetAgentDetailsRequest(server string, hostname string) (*http.Request, e NewGetAgentDetailsRequest generates requests for GetAgentDetails -## func [NewGetAgentRequest]() +## func [NewGetAgentRequest]() ```go func NewGetAgentRequest(server string) (*http.Request, error) @@ -371,7 +446,7 @@ func NewGetAgentRequest(server string) (*http.Request, error) NewGetAgentRequest generates requests for GetAgent -## func [NewGetAuditExportRequest]() +## func [NewGetAuditExportRequest]() ```go func NewGetAuditExportRequest(server string) (*http.Request, error) @@ -380,7 +455,7 @@ func NewGetAuditExportRequest(server string) (*http.Request, error) NewGetAuditExportRequest generates requests for GetAuditExport -## func [NewGetAuditLogByIDRequest]() +## func [NewGetAuditLogByIDRequest]() ```go func NewGetAuditLogByIDRequest(server string, id openapi_types.UUID) (*http.Request, error) @@ -389,7 +464,7 @@ func NewGetAuditLogByIDRequest(server string, id openapi_types.UUID) (*http.Requ NewGetAuditLogByIDRequest generates requests for GetAuditLogByID -## func [NewGetAuditLogsRequest]() +## func [NewGetAuditLogsRequest]() ```go func NewGetAuditLogsRequest(server string, params *GetAuditLogsParams) (*http.Request, error) @@ -397,8 +472,26 @@ func NewGetAuditLogsRequest(server string, params *GetAuditLogsParams) (*http.Re NewGetAuditLogsRequest generates requests for GetAuditLogs + +## func [NewGetFileByNameRequest]() + +```go +func NewGetFileByNameRequest(server string, name FileName) (*http.Request, error) +``` + +NewGetFileByNameRequest generates requests for GetFileByName + + +## func [NewGetFilesRequest]() + +```go +func NewGetFilesRequest(server string) (*http.Request, error) +``` + +NewGetFilesRequest generates requests for GetFiles + -## func [NewGetHealthReadyRequest]() +## func [NewGetHealthReadyRequest]() ```go func NewGetHealthReadyRequest(server string) (*http.Request, error) @@ -407,7 +500,7 @@ func NewGetHealthReadyRequest(server string) (*http.Request, error) NewGetHealthReadyRequest generates requests for GetHealthReady -## func [NewGetHealthRequest]() +## func [NewGetHealthRequest]() ```go func NewGetHealthRequest(server string) (*http.Request, error) @@ -416,7 +509,7 @@ func NewGetHealthRequest(server string) (*http.Request, error) NewGetHealthRequest generates requests for GetHealth -## func [NewGetHealthStatusRequest]() +## func [NewGetHealthStatusRequest]() ```go func NewGetHealthStatusRequest(server string) (*http.Request, error) @@ -425,7 +518,7 @@ func NewGetHealthStatusRequest(server string) (*http.Request, error) NewGetHealthStatusRequest generates requests for GetHealthStatus -## func [NewGetJobByIDRequest]() +## func [NewGetJobByIDRequest]() ```go func NewGetJobByIDRequest(server string, id openapi_types.UUID) (*http.Request, error) @@ -434,7 +527,7 @@ func NewGetJobByIDRequest(server string, id openapi_types.UUID) (*http.Request, NewGetJobByIDRequest generates requests for GetJobByID -## func [NewGetJobRequest]() +## func [NewGetJobRequest]() ```go func NewGetJobRequest(server string, params *GetJobParams) (*http.Request, error) @@ -443,7 +536,7 @@ func NewGetJobRequest(server string, params *GetJobParams) (*http.Request, error NewGetJobRequest generates requests for GetJob -## func [NewGetJobStatusRequest]() +## func [NewGetJobStatusRequest]() ```go func NewGetJobStatusRequest(server string) (*http.Request, error) @@ -452,7 +545,7 @@ func NewGetJobStatusRequest(server string) (*http.Request, error) NewGetJobStatusRequest generates requests for GetJobStatus -## func [NewGetNodeDiskRequest]() +## func [NewGetNodeDiskRequest]() ```go func NewGetNodeDiskRequest(server string, hostname Hostname) (*http.Request, error) @@ -461,7 +554,7 @@ func NewGetNodeDiskRequest(server string, hostname Hostname) (*http.Request, err NewGetNodeDiskRequest generates requests for GetNodeDisk -## func [NewGetNodeHostnameRequest]() +## func [NewGetNodeHostnameRequest]() ```go func NewGetNodeHostnameRequest(server string, hostname Hostname) (*http.Request, error) @@ -470,7 +563,7 @@ func NewGetNodeHostnameRequest(server string, hostname Hostname) (*http.Request, NewGetNodeHostnameRequest generates requests for GetNodeHostname -## func [NewGetNodeLoadRequest]() +## func [NewGetNodeLoadRequest]() ```go func NewGetNodeLoadRequest(server string, hostname Hostname) (*http.Request, error) @@ -479,7 +572,7 @@ func NewGetNodeLoadRequest(server string, hostname Hostname) (*http.Request, err NewGetNodeLoadRequest generates requests for GetNodeLoad -## func [NewGetNodeMemoryRequest]() +## func [NewGetNodeMemoryRequest]() ```go func NewGetNodeMemoryRequest(server string, hostname Hostname) (*http.Request, error) @@ -488,7 +581,7 @@ func NewGetNodeMemoryRequest(server string, hostname Hostname) (*http.Request, e NewGetNodeMemoryRequest generates requests for GetNodeMemory -## func [NewGetNodeNetworkDNSByInterfaceRequest]() +## func [NewGetNodeNetworkDNSByInterfaceRequest]() ```go func NewGetNodeNetworkDNSByInterfaceRequest(server string, hostname Hostname, interfaceName string) (*http.Request, error) @@ -497,7 +590,7 @@ func NewGetNodeNetworkDNSByInterfaceRequest(server string, hostname Hostname, in NewGetNodeNetworkDNSByInterfaceRequest generates requests for GetNodeNetworkDNSByInterface -## func [NewGetNodeOSRequest]() +## func [NewGetNodeOSRequest]() ```go func NewGetNodeOSRequest(server string, hostname Hostname) (*http.Request, error) @@ -506,7 +599,7 @@ func NewGetNodeOSRequest(server string, hostname Hostname) (*http.Request, error NewGetNodeOSRequest generates requests for GetNodeOS -## func [NewGetNodeStatusRequest]() +## func [NewGetNodeStatusRequest]() ```go func NewGetNodeStatusRequest(server string, hostname Hostname) (*http.Request, error) @@ -515,7 +608,7 @@ func NewGetNodeStatusRequest(server string, hostname Hostname) (*http.Request, e NewGetNodeStatusRequest generates requests for GetNodeStatus -## func [NewGetNodeUptimeRequest]() +## func [NewGetNodeUptimeRequest]() ```go func NewGetNodeUptimeRequest(server string, hostname Hostname) (*http.Request, error) @@ -524,7 +617,7 @@ func NewGetNodeUptimeRequest(server string, hostname Hostname) (*http.Request, e NewGetNodeUptimeRequest generates requests for GetNodeUptime -## func [NewGetVersionRequest]() +## func [NewGetVersionRequest]() ```go func NewGetVersionRequest(server string) (*http.Request, error) @@ -532,8 +625,26 @@ func NewGetVersionRequest(server string) (*http.Request, error) NewGetVersionRequest generates requests for GetVersion + +## func [NewPostFileRequest]() + +```go +func NewPostFileRequest(server string, body PostFileJSONRequestBody) (*http.Request, error) +``` + +NewPostFileRequest calls the generic PostFile builder with application/json body + + +## func [NewPostFileRequestWithBody]() + +```go +func NewPostFileRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error) +``` + +NewPostFileRequestWithBody generates requests for PostFile with any type of body + -## func [NewPostJobRequest]() +## func [NewPostJobRequest]() ```go func NewPostJobRequest(server string, body PostJobJSONRequestBody) (*http.Request, error) @@ -542,7 +653,7 @@ func NewPostJobRequest(server string, body PostJobJSONRequestBody) (*http.Reques NewPostJobRequest calls the generic PostJob builder with application/json body -## func [NewPostJobRequestWithBody]() +## func [NewPostJobRequestWithBody]() ```go func NewPostJobRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error) @@ -551,7 +662,7 @@ func NewPostJobRequestWithBody(server string, contentType string, body io.Reader NewPostJobRequestWithBody generates requests for PostJob with any type of body -## func [NewPostNodeCommandExecRequest]() +## func [NewPostNodeCommandExecRequest]() ```go func NewPostNodeCommandExecRequest(server string, hostname Hostname, body PostNodeCommandExecJSONRequestBody) (*http.Request, error) @@ -560,7 +671,7 @@ func NewPostNodeCommandExecRequest(server string, hostname Hostname, body PostNo NewPostNodeCommandExecRequest calls the generic PostNodeCommandExec builder with application/json body -## func [NewPostNodeCommandExecRequestWithBody]() +## func [NewPostNodeCommandExecRequestWithBody]() ```go func NewPostNodeCommandExecRequestWithBody(server string, hostname Hostname, contentType string, body io.Reader) (*http.Request, error) @@ -569,7 +680,7 @@ func NewPostNodeCommandExecRequestWithBody(server string, hostname Hostname, con NewPostNodeCommandExecRequestWithBody generates requests for PostNodeCommandExec with any type of body -## func [NewPostNodeCommandShellRequest]() +## func [NewPostNodeCommandShellRequest]() ```go func NewPostNodeCommandShellRequest(server string, hostname Hostname, body PostNodeCommandShellJSONRequestBody) (*http.Request, error) @@ -578,7 +689,7 @@ func NewPostNodeCommandShellRequest(server string, hostname Hostname, body PostN NewPostNodeCommandShellRequest calls the generic PostNodeCommandShell builder with application/json body -## func [NewPostNodeCommandShellRequestWithBody]() +## func [NewPostNodeCommandShellRequestWithBody]() ```go func NewPostNodeCommandShellRequestWithBody(server string, hostname Hostname, contentType string, body io.Reader) (*http.Request, error) @@ -586,8 +697,44 @@ func NewPostNodeCommandShellRequestWithBody(server string, hostname Hostname, co NewPostNodeCommandShellRequestWithBody generates requests for PostNodeCommandShell with any type of body + +## func [NewPostNodeFileDeployRequest]() + +```go +func NewPostNodeFileDeployRequest(server string, hostname Hostname, body PostNodeFileDeployJSONRequestBody) (*http.Request, error) +``` + +NewPostNodeFileDeployRequest calls the generic PostNodeFileDeploy builder with application/json body + + +## func [NewPostNodeFileDeployRequestWithBody]() + +```go +func NewPostNodeFileDeployRequestWithBody(server string, hostname Hostname, contentType string, body io.Reader) (*http.Request, error) +``` + +NewPostNodeFileDeployRequestWithBody generates requests for PostNodeFileDeploy with any type of body + + +## func [NewPostNodeFileStatusRequest]() + +```go +func NewPostNodeFileStatusRequest(server string, hostname Hostname, body PostNodeFileStatusJSONRequestBody) (*http.Request, error) +``` + +NewPostNodeFileStatusRequest calls the generic PostNodeFileStatus builder with application/json body + + +## func [NewPostNodeFileStatusRequestWithBody]() + +```go +func NewPostNodeFileStatusRequestWithBody(server string, hostname Hostname, contentType string, body io.Reader) (*http.Request, error) +``` + +NewPostNodeFileStatusRequestWithBody generates requests for PostNodeFileStatus with any type of body + -## func [NewPostNodeNetworkPingRequest]() +## func [NewPostNodeNetworkPingRequest]() ```go func NewPostNodeNetworkPingRequest(server string, hostname Hostname, body PostNodeNetworkPingJSONRequestBody) (*http.Request, error) @@ -596,7 +743,7 @@ func NewPostNodeNetworkPingRequest(server string, hostname Hostname, body PostNo NewPostNodeNetworkPingRequest calls the generic PostNodeNetworkPing builder with application/json body -## func [NewPostNodeNetworkPingRequestWithBody]() +## func [NewPostNodeNetworkPingRequestWithBody]() ```go func NewPostNodeNetworkPingRequestWithBody(server string, hostname Hostname, contentType string, body io.Reader) (*http.Request, error) @@ -605,7 +752,7 @@ func NewPostNodeNetworkPingRequestWithBody(server string, hostname Hostname, con NewPostNodeNetworkPingRequestWithBody generates requests for PostNodeNetworkPing with any type of body -## func [NewPutNodeNetworkDNSRequest]() +## func [NewPutNodeNetworkDNSRequest]() ```go func NewPutNodeNetworkDNSRequest(server string, hostname Hostname, body PutNodeNetworkDNSJSONRequestBody) (*http.Request, error) @@ -614,7 +761,7 @@ func NewPutNodeNetworkDNSRequest(server string, hostname Hostname, body PutNodeN NewPutNodeNetworkDNSRequest calls the generic PutNodeNetworkDNS builder with application/json body -## func [NewPutNodeNetworkDNSRequestWithBody]() +## func [NewPutNodeNetworkDNSRequestWithBody]() ```go func NewPutNodeNetworkDNSRequestWithBody(server string, hostname Hostname, contentType string, body io.Reader) (*http.Request, error) @@ -623,7 +770,7 @@ func NewPutNodeNetworkDNSRequestWithBody(server string, hostname Hostname, conte NewPutNodeNetworkDNSRequestWithBody generates requests for PutNodeNetworkDNS with any type of body -## func [NewRetryJobByIDRequest]() +## func [NewRetryJobByIDRequest]() ```go func NewRetryJobByIDRequest(server string, id openapi_types.UUID, body RetryJobByIDJSONRequestBody) (*http.Request, error) @@ -632,7 +779,7 @@ func NewRetryJobByIDRequest(server string, id openapi_types.UUID, body RetryJobB NewRetryJobByIDRequest calls the generic RetryJobByID builder with application/json body -## func [NewRetryJobByIDRequestWithBody]() +## func [NewRetryJobByIDRequestWithBody]() ```go func NewRetryJobByIDRequestWithBody(server string, id openapi_types.UUID, contentType string, body io.Reader) (*http.Request, error) @@ -641,7 +788,7 @@ func NewRetryJobByIDRequestWithBody(server string, id openapi_types.UUID, conten NewRetryJobByIDRequestWithBody generates requests for RetryJobByID with any type of body -## func [NewUndrainAgentRequest]() +## func [NewUndrainAgentRequest]() ```go func NewUndrainAgentRequest(server string, hostname string) (*http.Request, error) @@ -650,7 +797,7 @@ func NewUndrainAgentRequest(server string, hostname string) (*http.Request, erro NewUndrainAgentRequest generates requests for UndrainAgent -## type [AgentDetail]() +## type [AgentDetail]() AgentDetail defines model for AgentDetail. @@ -668,7 +815,7 @@ type AgentDetail struct { ``` -## type [AgentInfo]() +## type [AgentInfo]() AgentInfo defines model for AgentInfo. @@ -741,7 +888,7 @@ type AgentInfo struct { ``` -## type [AgentInfoState]() +## type [AgentInfoState]() AgentInfoState Agent scheduling state. @@ -760,7 +907,7 @@ const ( ``` -## type [AgentInfoStatus]() +## type [AgentInfoStatus]() AgentInfoStatus The current status of the agent. @@ -778,7 +925,7 @@ const ( ``` -## type [AgentStats]() +## type [AgentStats]() AgentStats defines model for AgentStats. @@ -796,7 +943,7 @@ type AgentStats struct { ``` -## type [AuditEntry]() +## type [AuditEntry]() AuditEntry defines model for AuditEntry. @@ -835,7 +982,7 @@ type AuditEntry struct { ``` -## type [AuditEntryResponse]() +## type [AuditEntryResponse]() AuditEntryResponse defines model for AuditEntryResponse. @@ -846,7 +993,7 @@ type AuditEntryResponse struct { ``` -## type [Client]() +## type [Client]() Client which conforms to the OpenAPI3 specification for this service. @@ -869,7 +1016,7 @@ type Client struct { ``` -### func [NewClient]() +### func [NewClient]() ```go func NewClient(server string, opts ...ClientOption) (*Client, error) @@ -877,8 +1024,17 @@ func NewClient(server string, opts ...ClientOption) (*Client, error) Creates a new Client, with reasonable defaults + +### func \(\*Client\) [DeleteFileByName]() + +```go +func (c *Client) DeleteFileByName(ctx context.Context, name FileName, reqEditors ...RequestEditorFn) (*http.Response, error) +``` + + + -### func \(\*Client\) [DeleteJobByID]() +### func \(\*Client\) [DeleteJobByID]() ```go func (c *Client) DeleteJobByID(ctx context.Context, id openapi_types.UUID, reqEditors ...RequestEditorFn) (*http.Response, error) @@ -887,7 +1043,7 @@ func (c *Client) DeleteJobByID(ctx context.Context, id openapi_types.UUID, reqEd -### func \(\*Client\) [DrainAgent]() +### func \(\*Client\) [DrainAgent]() ```go func (c *Client) DrainAgent(ctx context.Context, hostname string, reqEditors ...RequestEditorFn) (*http.Response, error) @@ -896,7 +1052,7 @@ func (c *Client) DrainAgent(ctx context.Context, hostname string, reqEditors ... -### func \(\*Client\) [GetAgent]() +### func \(\*Client\) [GetAgent]() ```go func (c *Client) GetAgent(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) @@ -905,7 +1061,7 @@ func (c *Client) GetAgent(ctx context.Context, reqEditors ...RequestEditorFn) (* -### func \(\*Client\) [GetAgentDetails]() +### func \(\*Client\) [GetAgentDetails]() ```go func (c *Client) GetAgentDetails(ctx context.Context, hostname string, reqEditors ...RequestEditorFn) (*http.Response, error) @@ -914,7 +1070,7 @@ func (c *Client) GetAgentDetails(ctx context.Context, hostname string, reqEditor -### func \(\*Client\) [GetAuditExport]() +### func \(\*Client\) [GetAuditExport]() ```go func (c *Client) GetAuditExport(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) @@ -923,7 +1079,7 @@ func (c *Client) GetAuditExport(ctx context.Context, reqEditors ...RequestEditor -### func \(\*Client\) [GetAuditLogByID]() +### func \(\*Client\) [GetAuditLogByID]() ```go func (c *Client) GetAuditLogByID(ctx context.Context, id openapi_types.UUID, reqEditors ...RequestEditorFn) (*http.Response, error) @@ -932,7 +1088,7 @@ func (c *Client) GetAuditLogByID(ctx context.Context, id openapi_types.UUID, req -### func \(\*Client\) [GetAuditLogs]() +### func \(\*Client\) [GetAuditLogs]() ```go func (c *Client) GetAuditLogs(ctx context.Context, params *GetAuditLogsParams, reqEditors ...RequestEditorFn) (*http.Response, error) @@ -940,8 +1096,26 @@ func (c *Client) GetAuditLogs(ctx context.Context, params *GetAuditLogsParams, r + +### func \(\*Client\) [GetFileByName]() + +```go +func (c *Client) GetFileByName(ctx context.Context, name FileName, reqEditors ...RequestEditorFn) (*http.Response, error) +``` + + + + +### func \(\*Client\) [GetFiles]() + +```go +func (c *Client) GetFiles(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) +``` + + + -### func \(\*Client\) [GetHealth]() +### func \(\*Client\) [GetHealth]() ```go func (c *Client) GetHealth(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) @@ -950,7 +1124,7 @@ func (c *Client) GetHealth(ctx context.Context, reqEditors ...RequestEditorFn) ( -### func \(\*Client\) [GetHealthReady]() +### func \(\*Client\) [GetHealthReady]() ```go func (c *Client) GetHealthReady(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) @@ -959,7 +1133,7 @@ func (c *Client) GetHealthReady(ctx context.Context, reqEditors ...RequestEditor -### func \(\*Client\) [GetHealthStatus]() +### func \(\*Client\) [GetHealthStatus]() ```go func (c *Client) GetHealthStatus(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) @@ -968,7 +1142,7 @@ func (c *Client) GetHealthStatus(ctx context.Context, reqEditors ...RequestEdito -### func \(\*Client\) [GetJob]() +### func \(\*Client\) [GetJob]() ```go func (c *Client) GetJob(ctx context.Context, params *GetJobParams, reqEditors ...RequestEditorFn) (*http.Response, error) @@ -977,7 +1151,7 @@ func (c *Client) GetJob(ctx context.Context, params *GetJobParams, reqEditors .. -### func \(\*Client\) [GetJobByID]() +### func \(\*Client\) [GetJobByID]() ```go func (c *Client) GetJobByID(ctx context.Context, id openapi_types.UUID, reqEditors ...RequestEditorFn) (*http.Response, error) @@ -986,7 +1160,7 @@ func (c *Client) GetJobByID(ctx context.Context, id openapi_types.UUID, reqEdito -### func \(\*Client\) [GetJobStatus]() +### func \(\*Client\) [GetJobStatus]() ```go func (c *Client) GetJobStatus(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) @@ -995,7 +1169,7 @@ func (c *Client) GetJobStatus(ctx context.Context, reqEditors ...RequestEditorFn -### func \(\*Client\) [GetNodeDisk]() +### func \(\*Client\) [GetNodeDisk]() ```go func (c *Client) GetNodeDisk(ctx context.Context, hostname Hostname, reqEditors ...RequestEditorFn) (*http.Response, error) @@ -1004,7 +1178,7 @@ func (c *Client) GetNodeDisk(ctx context.Context, hostname Hostname, reqEditors -### func \(\*Client\) [GetNodeHostname]() +### func \(\*Client\) [GetNodeHostname]() ```go func (c *Client) GetNodeHostname(ctx context.Context, hostname Hostname, reqEditors ...RequestEditorFn) (*http.Response, error) @@ -1013,7 +1187,7 @@ func (c *Client) GetNodeHostname(ctx context.Context, hostname Hostname, reqEdit -### func \(\*Client\) [GetNodeLoad]() +### func \(\*Client\) [GetNodeLoad]() ```go func (c *Client) GetNodeLoad(ctx context.Context, hostname Hostname, reqEditors ...RequestEditorFn) (*http.Response, error) @@ -1022,7 +1196,7 @@ func (c *Client) GetNodeLoad(ctx context.Context, hostname Hostname, reqEditors -### func \(\*Client\) [GetNodeMemory]() +### func \(\*Client\) [GetNodeMemory]() ```go func (c *Client) GetNodeMemory(ctx context.Context, hostname Hostname, reqEditors ...RequestEditorFn) (*http.Response, error) @@ -1031,7 +1205,7 @@ func (c *Client) GetNodeMemory(ctx context.Context, hostname Hostname, reqEditor -### func \(\*Client\) [GetNodeNetworkDNSByInterface]() +### func \(\*Client\) [GetNodeNetworkDNSByInterface]() ```go func (c *Client) GetNodeNetworkDNSByInterface(ctx context.Context, hostname Hostname, interfaceName string, reqEditors ...RequestEditorFn) (*http.Response, error) @@ -1040,7 +1214,7 @@ func (c *Client) GetNodeNetworkDNSByInterface(ctx context.Context, hostname Host -### func \(\*Client\) [GetNodeOS]() +### func \(\*Client\) [GetNodeOS]() ```go func (c *Client) GetNodeOS(ctx context.Context, hostname Hostname, reqEditors ...RequestEditorFn) (*http.Response, error) @@ -1049,7 +1223,7 @@ func (c *Client) GetNodeOS(ctx context.Context, hostname Hostname, reqEditors .. -### func \(\*Client\) [GetNodeStatus]() +### func \(\*Client\) [GetNodeStatus]() ```go func (c *Client) GetNodeStatus(ctx context.Context, hostname Hostname, reqEditors ...RequestEditorFn) (*http.Response, error) @@ -1058,7 +1232,7 @@ func (c *Client) GetNodeStatus(ctx context.Context, hostname Hostname, reqEditor -### func \(\*Client\) [GetNodeUptime]() +### func \(\*Client\) [GetNodeUptime]() ```go func (c *Client) GetNodeUptime(ctx context.Context, hostname Hostname, reqEditors ...RequestEditorFn) (*http.Response, error) @@ -1067,7 +1241,7 @@ func (c *Client) GetNodeUptime(ctx context.Context, hostname Hostname, reqEditor -### func \(\*Client\) [GetVersion]() +### func \(\*Client\) [GetVersion]() ```go func (c *Client) GetVersion(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) @@ -1075,8 +1249,26 @@ func (c *Client) GetVersion(ctx context.Context, reqEditors ...RequestEditorFn) + +### func \(\*Client\) [PostFile]() + +```go +func (c *Client) PostFile(ctx context.Context, body PostFileJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) +``` + + + + +### func \(\*Client\) [PostFileWithBody]() + +```go +func (c *Client) PostFileWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) +``` + + + -### func \(\*Client\) [PostJob]() +### func \(\*Client\) [PostJob]() ```go func (c *Client) PostJob(ctx context.Context, body PostJobJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) @@ -1085,7 +1277,7 @@ func (c *Client) PostJob(ctx context.Context, body PostJobJSONRequestBody, reqEd -### func \(\*Client\) [PostJobWithBody]() +### func \(\*Client\) [PostJobWithBody]() ```go func (c *Client) PostJobWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) @@ -1094,7 +1286,7 @@ func (c *Client) PostJobWithBody(ctx context.Context, contentType string, body i -### func \(\*Client\) [PostNodeCommandExec]() +### func \(\*Client\) [PostNodeCommandExec]() ```go func (c *Client) PostNodeCommandExec(ctx context.Context, hostname Hostname, body PostNodeCommandExecJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) @@ -1103,7 +1295,7 @@ func (c *Client) PostNodeCommandExec(ctx context.Context, hostname Hostname, bod -### func \(\*Client\) [PostNodeCommandExecWithBody]() +### func \(\*Client\) [PostNodeCommandExecWithBody]() ```go func (c *Client) PostNodeCommandExecWithBody(ctx context.Context, hostname Hostname, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) @@ -1112,7 +1304,7 @@ func (c *Client) PostNodeCommandExecWithBody(ctx context.Context, hostname Hostn -### func \(\*Client\) [PostNodeCommandShell]() +### func \(\*Client\) [PostNodeCommandShell]() ```go func (c *Client) PostNodeCommandShell(ctx context.Context, hostname Hostname, body PostNodeCommandShellJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) @@ -1121,7 +1313,7 @@ func (c *Client) PostNodeCommandShell(ctx context.Context, hostname Hostname, bo -### func \(\*Client\) [PostNodeCommandShellWithBody]() +### func \(\*Client\) [PostNodeCommandShellWithBody]() ```go func (c *Client) PostNodeCommandShellWithBody(ctx context.Context, hostname Hostname, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) @@ -1129,8 +1321,44 @@ func (c *Client) PostNodeCommandShellWithBody(ctx context.Context, hostname Host + +### func \(\*Client\) [PostNodeFileDeploy]() + +```go +func (c *Client) PostNodeFileDeploy(ctx context.Context, hostname Hostname, body PostNodeFileDeployJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) +``` + + + + +### func \(\*Client\) [PostNodeFileDeployWithBody]() + +```go +func (c *Client) PostNodeFileDeployWithBody(ctx context.Context, hostname Hostname, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) +``` + + + + +### func \(\*Client\) [PostNodeFileStatus]() + +```go +func (c *Client) PostNodeFileStatus(ctx context.Context, hostname Hostname, body PostNodeFileStatusJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) +``` + + + + +### func \(\*Client\) [PostNodeFileStatusWithBody]() + +```go +func (c *Client) PostNodeFileStatusWithBody(ctx context.Context, hostname Hostname, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) +``` + + + -### func \(\*Client\) [PostNodeNetworkPing]() +### func \(\*Client\) [PostNodeNetworkPing]() ```go func (c *Client) PostNodeNetworkPing(ctx context.Context, hostname Hostname, body PostNodeNetworkPingJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) @@ -1139,7 +1367,7 @@ func (c *Client) PostNodeNetworkPing(ctx context.Context, hostname Hostname, bod -### func \(\*Client\) [PostNodeNetworkPingWithBody]() +### func \(\*Client\) [PostNodeNetworkPingWithBody]() ```go func (c *Client) PostNodeNetworkPingWithBody(ctx context.Context, hostname Hostname, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) @@ -1148,7 +1376,7 @@ func (c *Client) PostNodeNetworkPingWithBody(ctx context.Context, hostname Hostn -### func \(\*Client\) [PutNodeNetworkDNS]() +### func \(\*Client\) [PutNodeNetworkDNS]() ```go func (c *Client) PutNodeNetworkDNS(ctx context.Context, hostname Hostname, body PutNodeNetworkDNSJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) @@ -1157,7 +1385,7 @@ func (c *Client) PutNodeNetworkDNS(ctx context.Context, hostname Hostname, body -### func \(\*Client\) [PutNodeNetworkDNSWithBody]() +### func \(\*Client\) [PutNodeNetworkDNSWithBody]() ```go func (c *Client) PutNodeNetworkDNSWithBody(ctx context.Context, hostname Hostname, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) @@ -1166,7 +1394,7 @@ func (c *Client) PutNodeNetworkDNSWithBody(ctx context.Context, hostname Hostnam -### func \(\*Client\) [RetryJobByID]() +### func \(\*Client\) [RetryJobByID]() ```go func (c *Client) RetryJobByID(ctx context.Context, id openapi_types.UUID, body RetryJobByIDJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) @@ -1175,7 +1403,7 @@ func (c *Client) RetryJobByID(ctx context.Context, id openapi_types.UUID, body R -### func \(\*Client\) [RetryJobByIDWithBody]() +### func \(\*Client\) [RetryJobByIDWithBody]() ```go func (c *Client) RetryJobByIDWithBody(ctx context.Context, id openapi_types.UUID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) @@ -1184,7 +1412,7 @@ func (c *Client) RetryJobByIDWithBody(ctx context.Context, id openapi_types.UUID -### func \(\*Client\) [UndrainAgent]() +### func \(\*Client\) [UndrainAgent]() ```go func (c *Client) UndrainAgent(ctx context.Context, hostname string, reqEditors ...RequestEditorFn) (*http.Response, error) @@ -1193,7 +1421,7 @@ func (c *Client) UndrainAgent(ctx context.Context, hostname string, reqEditors . -## type [ClientInterface]() +## type [ClientInterface]() The interface specification for the client above. @@ -1220,6 +1448,20 @@ type ClientInterface interface { // GetAuditLogByID request GetAuditLogByID(ctx context.Context, id openapi_types.UUID, reqEditors ...RequestEditorFn) (*http.Response, error) + // GetFiles request + GetFiles(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) + + // PostFileWithBody request with any body + PostFileWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + PostFile(ctx context.Context, body PostFileJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // DeleteFileByName request + DeleteFileByName(ctx context.Context, name FileName, reqEditors ...RequestEditorFn) (*http.Response, error) + + // GetFileByName request + GetFileByName(ctx context.Context, name FileName, reqEditors ...RequestEditorFn) (*http.Response, error) + // GetHealth request GetHealth(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) @@ -1267,6 +1509,16 @@ type ClientInterface interface { // GetNodeDisk request GetNodeDisk(ctx context.Context, hostname Hostname, reqEditors ...RequestEditorFn) (*http.Response, error) + // PostNodeFileDeployWithBody request with any body + PostNodeFileDeployWithBody(ctx context.Context, hostname Hostname, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + PostNodeFileDeploy(ctx context.Context, hostname Hostname, body PostNodeFileDeployJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // PostNodeFileStatusWithBody request with any body + PostNodeFileStatusWithBody(ctx context.Context, hostname Hostname, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + PostNodeFileStatus(ctx context.Context, hostname Hostname, body PostNodeFileStatusJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + // GetNodeHostname request GetNodeHostname(ctx context.Context, hostname Hostname, reqEditors ...RequestEditorFn) (*http.Response, error) @@ -1301,7 +1553,7 @@ type ClientInterface interface { ``` -## type [ClientOption]() +## type [ClientOption]() ClientOption allows setting custom parameters during construction @@ -1310,7 +1562,7 @@ type ClientOption func(*Client) error ``` -### func [WithBaseURL]() +### func [WithBaseURL]() ```go func WithBaseURL(baseURL string) ClientOption @@ -1319,7 +1571,7 @@ func WithBaseURL(baseURL string) ClientOption WithBaseURL overrides the baseURL. -### func [WithHTTPClient]() +### func [WithHTTPClient]() ```go func WithHTTPClient(doer HttpRequestDoer) ClientOption @@ -1328,7 +1580,7 @@ func WithHTTPClient(doer HttpRequestDoer) ClientOption WithHTTPClient allows overriding the default Doer, which is automatically created using http.Client. This is useful for tests. -### func [WithRequestEditorFn]() +### func [WithRequestEditorFn]() ```go func WithRequestEditorFn(fn RequestEditorFn) ClientOption @@ -1337,7 +1589,7 @@ func WithRequestEditorFn(fn RequestEditorFn) ClientOption WithRequestEditorFn allows setting up a callback function, which will be called right before sending the request. This can be used to mutate the request. -## type [ClientWithResponses]() +## type [ClientWithResponses]() ClientWithResponses builds on ClientInterface to offer response payloads @@ -1348,7 +1600,7 @@ type ClientWithResponses struct { ``` -### func [NewClientWithResponses]() +### func [NewClientWithResponses]() ```go func NewClientWithResponses(server string, opts ...ClientOption) (*ClientWithResponses, error) @@ -1356,8 +1608,17 @@ func NewClientWithResponses(server string, opts ...ClientOption) (*ClientWithRes NewClientWithResponses creates a new ClientWithResponses, which wraps Client with return type handling + +### func \(\*ClientWithResponses\) [DeleteFileByNameWithResponse]() + +```go +func (c *ClientWithResponses) DeleteFileByNameWithResponse(ctx context.Context, name FileName, reqEditors ...RequestEditorFn) (*DeleteFileByNameResponse, error) +``` + +DeleteFileByNameWithResponse request returning \*DeleteFileByNameResponse + -### func \(\*ClientWithResponses\) [DeleteJobByIDWithResponse]() +### func \(\*ClientWithResponses\) [DeleteJobByIDWithResponse]() ```go func (c *ClientWithResponses) DeleteJobByIDWithResponse(ctx context.Context, id openapi_types.UUID, reqEditors ...RequestEditorFn) (*DeleteJobByIDResponse, error) @@ -1366,7 +1627,7 @@ func (c *ClientWithResponses) DeleteJobByIDWithResponse(ctx context.Context, id DeleteJobByIDWithResponse request returning \*DeleteJobByIDResponse -### func \(\*ClientWithResponses\) [DrainAgentWithResponse]() +### func \(\*ClientWithResponses\) [DrainAgentWithResponse]() ```go func (c *ClientWithResponses) DrainAgentWithResponse(ctx context.Context, hostname string, reqEditors ...RequestEditorFn) (*DrainAgentResponse, error) @@ -1375,7 +1636,7 @@ func (c *ClientWithResponses) DrainAgentWithResponse(ctx context.Context, hostna DrainAgentWithResponse request returning \*DrainAgentResponse -### func \(\*ClientWithResponses\) [GetAgentDetailsWithResponse]() +### func \(\*ClientWithResponses\) [GetAgentDetailsWithResponse]() ```go func (c *ClientWithResponses) GetAgentDetailsWithResponse(ctx context.Context, hostname string, reqEditors ...RequestEditorFn) (*GetAgentDetailsResponse, error) @@ -1384,7 +1645,7 @@ func (c *ClientWithResponses) GetAgentDetailsWithResponse(ctx context.Context, h GetAgentDetailsWithResponse request returning \*GetAgentDetailsResponse -### func \(\*ClientWithResponses\) [GetAgentWithResponse]() +### func \(\*ClientWithResponses\) [GetAgentWithResponse]() ```go func (c *ClientWithResponses) GetAgentWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*GetAgentResponse, error) @@ -1393,7 +1654,7 @@ func (c *ClientWithResponses) GetAgentWithResponse(ctx context.Context, reqEdito GetAgentWithResponse request returning \*GetAgentResponse -### func \(\*ClientWithResponses\) [GetAuditExportWithResponse]() +### func \(\*ClientWithResponses\) [GetAuditExportWithResponse]() ```go func (c *ClientWithResponses) GetAuditExportWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*GetAuditExportResponse, error) @@ -1402,7 +1663,7 @@ func (c *ClientWithResponses) GetAuditExportWithResponse(ctx context.Context, re GetAuditExportWithResponse request returning \*GetAuditExportResponse -### func \(\*ClientWithResponses\) [GetAuditLogByIDWithResponse]() +### func \(\*ClientWithResponses\) [GetAuditLogByIDWithResponse]() ```go func (c *ClientWithResponses) GetAuditLogByIDWithResponse(ctx context.Context, id openapi_types.UUID, reqEditors ...RequestEditorFn) (*GetAuditLogByIDResponse, error) @@ -1411,7 +1672,7 @@ func (c *ClientWithResponses) GetAuditLogByIDWithResponse(ctx context.Context, i GetAuditLogByIDWithResponse request returning \*GetAuditLogByIDResponse -### func \(\*ClientWithResponses\) [GetAuditLogsWithResponse]() +### func \(\*ClientWithResponses\) [GetAuditLogsWithResponse]() ```go func (c *ClientWithResponses) GetAuditLogsWithResponse(ctx context.Context, params *GetAuditLogsParams, reqEditors ...RequestEditorFn) (*GetAuditLogsResponse, error) @@ -1419,8 +1680,26 @@ func (c *ClientWithResponses) GetAuditLogsWithResponse(ctx context.Context, para GetAuditLogsWithResponse request returning \*GetAuditLogsResponse + +### func \(\*ClientWithResponses\) [GetFileByNameWithResponse]() + +```go +func (c *ClientWithResponses) GetFileByNameWithResponse(ctx context.Context, name FileName, reqEditors ...RequestEditorFn) (*GetFileByNameResponse, error) +``` + +GetFileByNameWithResponse request returning \*GetFileByNameResponse + + +### func \(\*ClientWithResponses\) [GetFilesWithResponse]() + +```go +func (c *ClientWithResponses) GetFilesWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*GetFilesResponse, error) +``` + +GetFilesWithResponse request returning \*GetFilesResponse + -### func \(\*ClientWithResponses\) [GetHealthReadyWithResponse]() +### func \(\*ClientWithResponses\) [GetHealthReadyWithResponse]() ```go func (c *ClientWithResponses) GetHealthReadyWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*GetHealthReadyResponse, error) @@ -1429,7 +1708,7 @@ func (c *ClientWithResponses) GetHealthReadyWithResponse(ctx context.Context, re GetHealthReadyWithResponse request returning \*GetHealthReadyResponse -### func \(\*ClientWithResponses\) [GetHealthStatusWithResponse]() +### func \(\*ClientWithResponses\) [GetHealthStatusWithResponse]() ```go func (c *ClientWithResponses) GetHealthStatusWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*GetHealthStatusResponse, error) @@ -1438,7 +1717,7 @@ func (c *ClientWithResponses) GetHealthStatusWithResponse(ctx context.Context, r GetHealthStatusWithResponse request returning \*GetHealthStatusResponse -### func \(\*ClientWithResponses\) [GetHealthWithResponse]() +### func \(\*ClientWithResponses\) [GetHealthWithResponse]() ```go func (c *ClientWithResponses) GetHealthWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*GetHealthResponse, error) @@ -1447,7 +1726,7 @@ func (c *ClientWithResponses) GetHealthWithResponse(ctx context.Context, reqEdit GetHealthWithResponse request returning \*GetHealthResponse -### func \(\*ClientWithResponses\) [GetJobByIDWithResponse]() +### func \(\*ClientWithResponses\) [GetJobByIDWithResponse]() ```go func (c *ClientWithResponses) GetJobByIDWithResponse(ctx context.Context, id openapi_types.UUID, reqEditors ...RequestEditorFn) (*GetJobByIDResponse, error) @@ -1456,7 +1735,7 @@ func (c *ClientWithResponses) GetJobByIDWithResponse(ctx context.Context, id ope GetJobByIDWithResponse request returning \*GetJobByIDResponse -### func \(\*ClientWithResponses\) [GetJobStatusWithResponse]() +### func \(\*ClientWithResponses\) [GetJobStatusWithResponse]() ```go func (c *ClientWithResponses) GetJobStatusWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*GetJobStatusResponse, error) @@ -1465,7 +1744,7 @@ func (c *ClientWithResponses) GetJobStatusWithResponse(ctx context.Context, reqE GetJobStatusWithResponse request returning \*GetJobStatusResponse -### func \(\*ClientWithResponses\) [GetJobWithResponse]() +### func \(\*ClientWithResponses\) [GetJobWithResponse]() ```go func (c *ClientWithResponses) GetJobWithResponse(ctx context.Context, params *GetJobParams, reqEditors ...RequestEditorFn) (*GetJobResponse, error) @@ -1474,7 +1753,7 @@ func (c *ClientWithResponses) GetJobWithResponse(ctx context.Context, params *Ge GetJobWithResponse request returning \*GetJobResponse -### func \(\*ClientWithResponses\) [GetNodeDiskWithResponse]() +### func \(\*ClientWithResponses\) [GetNodeDiskWithResponse]() ```go func (c *ClientWithResponses) GetNodeDiskWithResponse(ctx context.Context, hostname Hostname, reqEditors ...RequestEditorFn) (*GetNodeDiskResponse, error) @@ -1483,7 +1762,7 @@ func (c *ClientWithResponses) GetNodeDiskWithResponse(ctx context.Context, hostn GetNodeDiskWithResponse request returning \*GetNodeDiskResponse -### func \(\*ClientWithResponses\) [GetNodeHostnameWithResponse]() +### func \(\*ClientWithResponses\) [GetNodeHostnameWithResponse]() ```go func (c *ClientWithResponses) GetNodeHostnameWithResponse(ctx context.Context, hostname Hostname, reqEditors ...RequestEditorFn) (*GetNodeHostnameResponse, error) @@ -1492,7 +1771,7 @@ func (c *ClientWithResponses) GetNodeHostnameWithResponse(ctx context.Context, h GetNodeHostnameWithResponse request returning \*GetNodeHostnameResponse -### func \(\*ClientWithResponses\) [GetNodeLoadWithResponse]() +### func \(\*ClientWithResponses\) [GetNodeLoadWithResponse]() ```go func (c *ClientWithResponses) GetNodeLoadWithResponse(ctx context.Context, hostname Hostname, reqEditors ...RequestEditorFn) (*GetNodeLoadResponse, error) @@ -1501,7 +1780,7 @@ func (c *ClientWithResponses) GetNodeLoadWithResponse(ctx context.Context, hostn GetNodeLoadWithResponse request returning \*GetNodeLoadResponse -### func \(\*ClientWithResponses\) [GetNodeMemoryWithResponse]() +### func \(\*ClientWithResponses\) [GetNodeMemoryWithResponse]() ```go func (c *ClientWithResponses) GetNodeMemoryWithResponse(ctx context.Context, hostname Hostname, reqEditors ...RequestEditorFn) (*GetNodeMemoryResponse, error) @@ -1510,7 +1789,7 @@ func (c *ClientWithResponses) GetNodeMemoryWithResponse(ctx context.Context, hos GetNodeMemoryWithResponse request returning \*GetNodeMemoryResponse -### func \(\*ClientWithResponses\) [GetNodeNetworkDNSByInterfaceWithResponse]() +### func \(\*ClientWithResponses\) [GetNodeNetworkDNSByInterfaceWithResponse]() ```go func (c *ClientWithResponses) GetNodeNetworkDNSByInterfaceWithResponse(ctx context.Context, hostname Hostname, interfaceName string, reqEditors ...RequestEditorFn) (*GetNodeNetworkDNSByInterfaceResponse, error) @@ -1519,7 +1798,7 @@ func (c *ClientWithResponses) GetNodeNetworkDNSByInterfaceWithResponse(ctx conte GetNodeNetworkDNSByInterfaceWithResponse request returning \*GetNodeNetworkDNSByInterfaceResponse -### func \(\*ClientWithResponses\) [GetNodeOSWithResponse]() +### func \(\*ClientWithResponses\) [GetNodeOSWithResponse]() ```go func (c *ClientWithResponses) GetNodeOSWithResponse(ctx context.Context, hostname Hostname, reqEditors ...RequestEditorFn) (*GetNodeOSResponse, error) @@ -1528,7 +1807,7 @@ func (c *ClientWithResponses) GetNodeOSWithResponse(ctx context.Context, hostnam GetNodeOSWithResponse request returning \*GetNodeOSResponse -### func \(\*ClientWithResponses\) [GetNodeStatusWithResponse]() +### func \(\*ClientWithResponses\) [GetNodeStatusWithResponse]() ```go func (c *ClientWithResponses) GetNodeStatusWithResponse(ctx context.Context, hostname Hostname, reqEditors ...RequestEditorFn) (*GetNodeStatusResponse, error) @@ -1537,7 +1816,7 @@ func (c *ClientWithResponses) GetNodeStatusWithResponse(ctx context.Context, hos GetNodeStatusWithResponse request returning \*GetNodeStatusResponse -### func \(\*ClientWithResponses\) [GetNodeUptimeWithResponse]() +### func \(\*ClientWithResponses\) [GetNodeUptimeWithResponse]() ```go func (c *ClientWithResponses) GetNodeUptimeWithResponse(ctx context.Context, hostname Hostname, reqEditors ...RequestEditorFn) (*GetNodeUptimeResponse, error) @@ -1546,7 +1825,7 @@ func (c *ClientWithResponses) GetNodeUptimeWithResponse(ctx context.Context, hos GetNodeUptimeWithResponse request returning \*GetNodeUptimeResponse -### func \(\*ClientWithResponses\) [GetVersionWithResponse]() +### func \(\*ClientWithResponses\) [GetVersionWithResponse]() ```go func (c *ClientWithResponses) GetVersionWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*GetVersionResponse, error) @@ -1554,8 +1833,26 @@ func (c *ClientWithResponses) GetVersionWithResponse(ctx context.Context, reqEdi GetVersionWithResponse request returning \*GetVersionResponse + +### func \(\*ClientWithResponses\) [PostFileWithBodyWithResponse]() + +```go +func (c *ClientWithResponses) PostFileWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostFileResponse, error) +``` + +PostFileWithBodyWithResponse request with arbitrary body returning \*PostFileResponse + + +### func \(\*ClientWithResponses\) [PostFileWithResponse]() + +```go +func (c *ClientWithResponses) PostFileWithResponse(ctx context.Context, body PostFileJSONRequestBody, reqEditors ...RequestEditorFn) (*PostFileResponse, error) +``` + + + -### func \(\*ClientWithResponses\) [PostJobWithBodyWithResponse]() +### func \(\*ClientWithResponses\) [PostJobWithBodyWithResponse]() ```go func (c *ClientWithResponses) PostJobWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostJobResponse, error) @@ -1564,7 +1861,7 @@ func (c *ClientWithResponses) PostJobWithBodyWithResponse(ctx context.Context, c PostJobWithBodyWithResponse request with arbitrary body returning \*PostJobResponse -### func \(\*ClientWithResponses\) [PostJobWithResponse]() +### func \(\*ClientWithResponses\) [PostJobWithResponse]() ```go func (c *ClientWithResponses) PostJobWithResponse(ctx context.Context, body PostJobJSONRequestBody, reqEditors ...RequestEditorFn) (*PostJobResponse, error) @@ -1573,7 +1870,7 @@ func (c *ClientWithResponses) PostJobWithResponse(ctx context.Context, body Post -### func \(\*ClientWithResponses\) [PostNodeCommandExecWithBodyWithResponse]() +### func \(\*ClientWithResponses\) [PostNodeCommandExecWithBodyWithResponse]() ```go func (c *ClientWithResponses) PostNodeCommandExecWithBodyWithResponse(ctx context.Context, hostname Hostname, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostNodeCommandExecResponse, error) @@ -1582,7 +1879,7 @@ func (c *ClientWithResponses) PostNodeCommandExecWithBodyWithResponse(ctx contex PostNodeCommandExecWithBodyWithResponse request with arbitrary body returning \*PostNodeCommandExecResponse -### func \(\*ClientWithResponses\) [PostNodeCommandExecWithResponse]() +### func \(\*ClientWithResponses\) [PostNodeCommandExecWithResponse]() ```go func (c *ClientWithResponses) PostNodeCommandExecWithResponse(ctx context.Context, hostname Hostname, body PostNodeCommandExecJSONRequestBody, reqEditors ...RequestEditorFn) (*PostNodeCommandExecResponse, error) @@ -1591,7 +1888,7 @@ func (c *ClientWithResponses) PostNodeCommandExecWithResponse(ctx context.Contex -### func \(\*ClientWithResponses\) [PostNodeCommandShellWithBodyWithResponse]() +### func \(\*ClientWithResponses\) [PostNodeCommandShellWithBodyWithResponse]() ```go func (c *ClientWithResponses) PostNodeCommandShellWithBodyWithResponse(ctx context.Context, hostname Hostname, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostNodeCommandShellResponse, error) @@ -1600,7 +1897,7 @@ func (c *ClientWithResponses) PostNodeCommandShellWithBodyWithResponse(ctx conte PostNodeCommandShellWithBodyWithResponse request with arbitrary body returning \*PostNodeCommandShellResponse -### func \(\*ClientWithResponses\) [PostNodeCommandShellWithResponse]() +### func \(\*ClientWithResponses\) [PostNodeCommandShellWithResponse]() ```go func (c *ClientWithResponses) PostNodeCommandShellWithResponse(ctx context.Context, hostname Hostname, body PostNodeCommandShellJSONRequestBody, reqEditors ...RequestEditorFn) (*PostNodeCommandShellResponse, error) @@ -1608,8 +1905,44 @@ func (c *ClientWithResponses) PostNodeCommandShellWithResponse(ctx context.Conte + +### func \(\*ClientWithResponses\) [PostNodeFileDeployWithBodyWithResponse]() + +```go +func (c *ClientWithResponses) PostNodeFileDeployWithBodyWithResponse(ctx context.Context, hostname Hostname, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostNodeFileDeployResponse, error) +``` + +PostNodeFileDeployWithBodyWithResponse request with arbitrary body returning \*PostNodeFileDeployResponse + + +### func \(\*ClientWithResponses\) [PostNodeFileDeployWithResponse]() + +```go +func (c *ClientWithResponses) PostNodeFileDeployWithResponse(ctx context.Context, hostname Hostname, body PostNodeFileDeployJSONRequestBody, reqEditors ...RequestEditorFn) (*PostNodeFileDeployResponse, error) +``` + + + + +### func \(\*ClientWithResponses\) [PostNodeFileStatusWithBodyWithResponse]() + +```go +func (c *ClientWithResponses) PostNodeFileStatusWithBodyWithResponse(ctx context.Context, hostname Hostname, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostNodeFileStatusResponse, error) +``` + +PostNodeFileStatusWithBodyWithResponse request with arbitrary body returning \*PostNodeFileStatusResponse + + +### func \(\*ClientWithResponses\) [PostNodeFileStatusWithResponse]() + +```go +func (c *ClientWithResponses) PostNodeFileStatusWithResponse(ctx context.Context, hostname Hostname, body PostNodeFileStatusJSONRequestBody, reqEditors ...RequestEditorFn) (*PostNodeFileStatusResponse, error) +``` + + + -### func \(\*ClientWithResponses\) [PostNodeNetworkPingWithBodyWithResponse]() +### func \(\*ClientWithResponses\) [PostNodeNetworkPingWithBodyWithResponse]() ```go func (c *ClientWithResponses) PostNodeNetworkPingWithBodyWithResponse(ctx context.Context, hostname Hostname, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostNodeNetworkPingResponse, error) @@ -1618,7 +1951,7 @@ func (c *ClientWithResponses) PostNodeNetworkPingWithBodyWithResponse(ctx contex PostNodeNetworkPingWithBodyWithResponse request with arbitrary body returning \*PostNodeNetworkPingResponse -### func \(\*ClientWithResponses\) [PostNodeNetworkPingWithResponse]() +### func \(\*ClientWithResponses\) [PostNodeNetworkPingWithResponse]() ```go func (c *ClientWithResponses) PostNodeNetworkPingWithResponse(ctx context.Context, hostname Hostname, body PostNodeNetworkPingJSONRequestBody, reqEditors ...RequestEditorFn) (*PostNodeNetworkPingResponse, error) @@ -1627,7 +1960,7 @@ func (c *ClientWithResponses) PostNodeNetworkPingWithResponse(ctx context.Contex -### func \(\*ClientWithResponses\) [PutNodeNetworkDNSWithBodyWithResponse]() +### func \(\*ClientWithResponses\) [PutNodeNetworkDNSWithBodyWithResponse]() ```go func (c *ClientWithResponses) PutNodeNetworkDNSWithBodyWithResponse(ctx context.Context, hostname Hostname, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PutNodeNetworkDNSResponse, error) @@ -1636,7 +1969,7 @@ func (c *ClientWithResponses) PutNodeNetworkDNSWithBodyWithResponse(ctx context. PutNodeNetworkDNSWithBodyWithResponse request with arbitrary body returning \*PutNodeNetworkDNSResponse -### func \(\*ClientWithResponses\) [PutNodeNetworkDNSWithResponse]() +### func \(\*ClientWithResponses\) [PutNodeNetworkDNSWithResponse]() ```go func (c *ClientWithResponses) PutNodeNetworkDNSWithResponse(ctx context.Context, hostname Hostname, body PutNodeNetworkDNSJSONRequestBody, reqEditors ...RequestEditorFn) (*PutNodeNetworkDNSResponse, error) @@ -1645,7 +1978,7 @@ func (c *ClientWithResponses) PutNodeNetworkDNSWithResponse(ctx context.Context, -### func \(\*ClientWithResponses\) [RetryJobByIDWithBodyWithResponse]() +### func \(\*ClientWithResponses\) [RetryJobByIDWithBodyWithResponse]() ```go func (c *ClientWithResponses) RetryJobByIDWithBodyWithResponse(ctx context.Context, id openapi_types.UUID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*RetryJobByIDResponse, error) @@ -1654,7 +1987,7 @@ func (c *ClientWithResponses) RetryJobByIDWithBodyWithResponse(ctx context.Conte RetryJobByIDWithBodyWithResponse request with arbitrary body returning \*RetryJobByIDResponse -### func \(\*ClientWithResponses\) [RetryJobByIDWithResponse]() +### func \(\*ClientWithResponses\) [RetryJobByIDWithResponse]() ```go func (c *ClientWithResponses) RetryJobByIDWithResponse(ctx context.Context, id openapi_types.UUID, body RetryJobByIDJSONRequestBody, reqEditors ...RequestEditorFn) (*RetryJobByIDResponse, error) @@ -1663,7 +1996,7 @@ func (c *ClientWithResponses) RetryJobByIDWithResponse(ctx context.Context, id o -### func \(\*ClientWithResponses\) [UndrainAgentWithResponse]() +### func \(\*ClientWithResponses\) [UndrainAgentWithResponse]() ```go func (c *ClientWithResponses) UndrainAgentWithResponse(ctx context.Context, hostname string, reqEditors ...RequestEditorFn) (*UndrainAgentResponse, error) @@ -1672,7 +2005,7 @@ func (c *ClientWithResponses) UndrainAgentWithResponse(ctx context.Context, host UndrainAgentWithResponse request returning \*UndrainAgentResponse -## type [ClientWithResponsesInterface]() +## type [ClientWithResponsesInterface]() ClientWithResponsesInterface is the interface specification for the client with responses above. @@ -1699,6 +2032,20 @@ type ClientWithResponsesInterface interface { // GetAuditLogByIDWithResponse request GetAuditLogByIDWithResponse(ctx context.Context, id openapi_types.UUID, reqEditors ...RequestEditorFn) (*GetAuditLogByIDResponse, error) + // GetFilesWithResponse request + GetFilesWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*GetFilesResponse, error) + + // PostFileWithBodyWithResponse request with any body + PostFileWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostFileResponse, error) + + PostFileWithResponse(ctx context.Context, body PostFileJSONRequestBody, reqEditors ...RequestEditorFn) (*PostFileResponse, error) + + // DeleteFileByNameWithResponse request + DeleteFileByNameWithResponse(ctx context.Context, name FileName, reqEditors ...RequestEditorFn) (*DeleteFileByNameResponse, error) + + // GetFileByNameWithResponse request + GetFileByNameWithResponse(ctx context.Context, name FileName, reqEditors ...RequestEditorFn) (*GetFileByNameResponse, error) + // GetHealthWithResponse request GetHealthWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*GetHealthResponse, error) @@ -1746,6 +2093,16 @@ type ClientWithResponsesInterface interface { // GetNodeDiskWithResponse request GetNodeDiskWithResponse(ctx context.Context, hostname Hostname, reqEditors ...RequestEditorFn) (*GetNodeDiskResponse, error) + // PostNodeFileDeployWithBodyWithResponse request with any body + PostNodeFileDeployWithBodyWithResponse(ctx context.Context, hostname Hostname, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostNodeFileDeployResponse, error) + + PostNodeFileDeployWithResponse(ctx context.Context, hostname Hostname, body PostNodeFileDeployJSONRequestBody, reqEditors ...RequestEditorFn) (*PostNodeFileDeployResponse, error) + + // PostNodeFileStatusWithBodyWithResponse request with any body + PostNodeFileStatusWithBodyWithResponse(ctx context.Context, hostname Hostname, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostNodeFileStatusResponse, error) + + PostNodeFileStatusWithResponse(ctx context.Context, hostname Hostname, body PostNodeFileStatusJSONRequestBody, reqEditors ...RequestEditorFn) (*PostNodeFileStatusResponse, error) + // GetNodeHostnameWithResponse request GetNodeHostnameWithResponse(ctx context.Context, hostname Hostname, reqEditors ...RequestEditorFn) (*GetNodeHostnameResponse, error) @@ -1780,7 +2137,7 @@ type ClientWithResponsesInterface interface { ``` -## type [CommandExecRequest]() +## type [CommandExecRequest]() CommandExecRequest defines model for CommandExecRequest. @@ -1801,7 +2158,7 @@ type CommandExecRequest struct { ``` -## type [CommandResultCollectionResponse]() +## type [CommandResultCollectionResponse]() CommandResultCollectionResponse defines model for CommandResultCollectionResponse. @@ -1814,7 +2171,7 @@ type CommandResultCollectionResponse struct { ``` -## type [CommandResultItem]() +## type [CommandResultItem]() CommandResultItem defines model for CommandResultItem. @@ -1844,7 +2201,7 @@ type CommandResultItem struct { ``` -## type [CommandShellRequest]() +## type [CommandShellRequest]() CommandShellRequest defines model for CommandShellRequest. @@ -1862,7 +2219,7 @@ type CommandShellRequest struct { ``` -## type [ComponentHealth]() +## type [ComponentHealth]() ComponentHealth defines model for ComponentHealth. @@ -1877,7 +2234,7 @@ type ComponentHealth struct { ``` -## type [ConsumerDetail]() +## type [ConsumerDetail]() ConsumerDetail defines model for ConsumerDetail. @@ -1898,7 +2255,7 @@ type ConsumerDetail struct { ``` -## type [ConsumerStats]() +## type [ConsumerStats]() ConsumerStats defines model for ConsumerStats. @@ -1913,7 +2270,7 @@ type ConsumerStats struct { ``` -## type [CreateJobRequest]() +## type [CreateJobRequest]() CreateJobRequest defines model for CreateJobRequest. @@ -1928,7 +2285,7 @@ type CreateJobRequest struct { ``` -## type [CreateJobResponse]() +## type [CreateJobResponse]() CreateJobResponse defines model for CreateJobResponse. @@ -1949,7 +2306,7 @@ type CreateJobResponse struct { ``` -## type [DNSConfigCollectionResponse]() +## type [DNSConfigCollectionResponse]() DNSConfigCollectionResponse defines model for DNSConfigCollectionResponse. @@ -1962,7 +2319,7 @@ type DNSConfigCollectionResponse struct { ``` -## type [DNSConfigResponse]() +## type [DNSConfigResponse]() DNSConfigResponse defines model for DNSConfigResponse. @@ -1983,7 +2340,7 @@ type DNSConfigResponse struct { ``` -## type [DNSConfigUpdateRequest]() +## type [DNSConfigUpdateRequest]() DNSConfigUpdateRequest defines model for DNSConfigUpdateRequest. @@ -2001,7 +2358,7 @@ type DNSConfigUpdateRequest struct { ``` -## type [DNSUpdateCollectionResponse]() +## type [DNSUpdateCollectionResponse]() DNSUpdateCollectionResponse defines model for DNSUpdateCollectionResponse. @@ -2014,7 +2371,7 @@ type DNSUpdateCollectionResponse struct { ``` -## type [DNSUpdateResultItem]() +## type [DNSUpdateResultItem]() DNSUpdateResultItem defines model for DNSUpdateResultItem. @@ -2029,7 +2386,7 @@ type DNSUpdateResultItem struct { ``` -## type [DNSUpdateResultItemStatus]() +## type [DNSUpdateResultItemStatus]() DNSUpdateResultItemStatus defines model for DNSUpdateResultItem.Status. @@ -2046,8 +2403,52 @@ const ( ) ``` + +## type [DeleteFileByNameResponse]() + + + +```go +type DeleteFileByNameResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *FileDeleteResponse + JSON401 *ErrorResponse + JSON403 *ErrorResponse + JSON404 *ErrorResponse + JSON500 *ErrorResponse +} +``` + + +### func [ParseDeleteFileByNameResponse]() + +```go +func ParseDeleteFileByNameResponse(rsp *http.Response) (*DeleteFileByNameResponse, error) +``` + +ParseDeleteFileByNameResponse parses an HTTP response from a DeleteFileByNameWithResponse call + + +### func \(DeleteFileByNameResponse\) [Status]() + +```go +func (r DeleteFileByNameResponse) Status() string +``` + +Status returns HTTPResponse.Status + + +### func \(DeleteFileByNameResponse\) [StatusCode]() + +```go +func (r DeleteFileByNameResponse) StatusCode() int +``` + +StatusCode returns HTTPResponse.StatusCode + -## type [DeleteJobByIDResponse]() +## type [DeleteJobByIDResponse]() @@ -2064,7 +2465,7 @@ type DeleteJobByIDResponse struct { ``` -### func [ParseDeleteJobByIDResponse]() +### func [ParseDeleteJobByIDResponse]() ```go func ParseDeleteJobByIDResponse(rsp *http.Response) (*DeleteJobByIDResponse, error) @@ -2073,7 +2474,7 @@ func ParseDeleteJobByIDResponse(rsp *http.Response) (*DeleteJobByIDResponse, err ParseDeleteJobByIDResponse parses an HTTP response from a DeleteJobByIDWithResponse call -### func \(DeleteJobByIDResponse\) [Status]() +### func \(DeleteJobByIDResponse\) [Status]() ```go func (r DeleteJobByIDResponse) Status() string @@ -2082,7 +2483,7 @@ func (r DeleteJobByIDResponse) Status() string Status returns HTTPResponse.Status -### func \(DeleteJobByIDResponse\) [StatusCode]() +### func \(DeleteJobByIDResponse\) [StatusCode]() ```go func (r DeleteJobByIDResponse) StatusCode() int @@ -2091,7 +2492,7 @@ func (r DeleteJobByIDResponse) StatusCode() int StatusCode returns HTTPResponse.StatusCode -## type [DiskCollectionResponse]() +## type [DiskCollectionResponse]() DiskCollectionResponse defines model for DiskCollectionResponse. @@ -2104,7 +2505,7 @@ type DiskCollectionResponse struct { ``` -## type [DiskResponse]() +## type [DiskResponse]() DiskResponse Local disk usage information. @@ -2125,7 +2526,7 @@ type DiskResponse struct { ``` -## type [DiskResultItem]() +## type [DiskResultItem]() DiskResultItem defines model for DiskResultItem. @@ -2143,7 +2544,7 @@ type DiskResultItem struct { ``` -## type [DisksResponse]() +## type [DisksResponse]() DisksResponse List of local disk usage information. @@ -2152,7 +2553,7 @@ type DisksResponse = []DiskResponse ``` -## type [DrainAgentResponse]() +## type [DrainAgentResponse]() @@ -2171,7 +2572,7 @@ type DrainAgentResponse struct { ``` -### func [ParseDrainAgentResponse]() +### func [ParseDrainAgentResponse]() ```go func ParseDrainAgentResponse(rsp *http.Response) (*DrainAgentResponse, error) @@ -2180,7 +2581,7 @@ func ParseDrainAgentResponse(rsp *http.Response) (*DrainAgentResponse, error) ParseDrainAgentResponse parses an HTTP response from a DrainAgentWithResponse call -### func \(DrainAgentResponse\) [Status]() +### func \(DrainAgentResponse\) [Status]() ```go func (r DrainAgentResponse) Status() string @@ -2189,7 +2590,7 @@ func (r DrainAgentResponse) Status() string Status returns HTTPResponse.Status -### func \(DrainAgentResponse\) [StatusCode]() +### func \(DrainAgentResponse\) [StatusCode]() ```go func (r DrainAgentResponse) StatusCode() int @@ -2198,7 +2599,7 @@ func (r DrainAgentResponse) StatusCode() int StatusCode returns HTTPResponse.StatusCode -## type [ErrorResponse]() +## type [ErrorResponse]() ErrorResponse defines model for ErrorResponse. @@ -2215,8 +2616,218 @@ type ErrorResponse struct { } ``` + +## type [FileDeleteResponse]() + +FileDeleteResponse defines model for FileDeleteResponse. + +```go +type FileDeleteResponse struct { + // Deleted Whether the file was deleted. + Deleted bool `json:"deleted"` + + // Name The name of the deleted file. + Name string `json:"name"` +} +``` + + +## type [FileDeployRequest]() + +FileDeployRequest defines model for FileDeployRequest. + +```go +type FileDeployRequest struct { + // ContentType Content type — "raw" or "template". + ContentType FileDeployRequestContentType `json:"content_type" validate:"required,oneof=raw template"` + + // Group File owner group. + Group *string `json:"group,omitempty"` + + // Mode File permission mode (e.g., "0644"). + Mode *string `json:"mode,omitempty"` + + // ObjectName Name of the file in the Object Store. + ObjectName string `json:"object_name" validate:"required,min=1,max=255"` + + // Owner File owner user. + Owner *string `json:"owner,omitempty"` + + // Path Destination path on the target filesystem. + Path string `json:"path" validate:"required,min=1"` + + // Vars Template variables when content_type is "template". + Vars *map[string]interface{} `json:"vars,omitempty"` +} +``` + + +## type [FileDeployRequestContentType]() + +FileDeployRequestContentType Content type — "raw" or "template". + +```go +type FileDeployRequestContentType string +``` + +Defines values for FileDeployRequestContentType. + +```go +const ( + Raw FileDeployRequestContentType = "raw" + Template FileDeployRequestContentType = "template" +) +``` + + +## type [FileDeployResponse]() + +FileDeployResponse defines model for FileDeployResponse. + +```go +type FileDeployResponse struct { + // Changed Whether the file was actually written. + Changed bool `json:"changed"` + + // Hostname The agent that processed the job. + Hostname string `json:"hostname"` + + // JobId The ID of the created job. + JobId string `json:"job_id"` +} +``` + + +## type [FileInfo]() + +FileInfo defines model for FileInfo. + +```go +type FileInfo struct { + // Name The name of the file. + Name string `json:"name"` + + // Sha256 SHA-256 hash of the file content. + Sha256 string `json:"sha256"` + + // Size File size in bytes. + Size int `json:"size"` +} +``` + + +## type [FileInfoResponse]() + +FileInfoResponse defines model for FileInfoResponse. + +```go +type FileInfoResponse struct { + // Name The name of the file. + Name string `json:"name"` + + // Sha256 SHA-256 hash of the file content. + Sha256 string `json:"sha256"` + + // Size File size in bytes. + Size int `json:"size"` +} +``` + + +## type [FileListResponse]() + +FileListResponse defines model for FileListResponse. + +```go +type FileListResponse struct { + // Files List of stored files. + Files []FileInfo `json:"files"` + + // Total Total number of files. + Total int `json:"total"` +} +``` + + +## type [FileName]() + +FileName defines model for FileName. + +```go +type FileName = string +``` + + +## type [FileStatusRequest]() + +FileStatusRequest defines model for FileStatusRequest. + +```go +type FileStatusRequest struct { + // Path Filesystem path to check. + Path string `json:"path" validate:"required,min=1"` +} +``` + + +## type [FileStatusResponse]() + +FileStatusResponse defines model for FileStatusResponse. + +```go +type FileStatusResponse struct { + // Hostname The agent that processed the job. + Hostname string `json:"hostname"` + + // JobId The ID of the created job. + JobId string `json:"job_id"` + + // Path The filesystem path. + Path string `json:"path"` + + // Sha256 Current SHA-256 of the file on disk. + Sha256 *string `json:"sha256,omitempty"` + + // Status File state — "in-sync", "drifted", or "missing". + Status string `json:"status"` +} +``` + + +## type [FileUploadRequest]() + +FileUploadRequest defines model for FileUploadRequest. + +```go +type FileUploadRequest struct { + // Content Base64-encoded file content. + Content []byte `json:"content" validate:"required"` + + // Name The name of the file. + Name string `json:"name" validate:"required,min=1,max=255"` +} +``` + + +## type [FileUploadResponse]() + +FileUploadResponse defines model for FileUploadResponse. + +```go +type FileUploadResponse struct { + // Name The name of the uploaded file. + Name string `json:"name"` + + // Sha256 SHA-256 hash of the file content. + Sha256 string `json:"sha256"` + + // Size File size in bytes. + Size int `json:"size"` +} +``` + -## type [GetAgentDetailsResponse]() +## type [GetAgentDetailsResponse]() @@ -2233,7 +2844,7 @@ type GetAgentDetailsResponse struct { ``` -### func [ParseGetAgentDetailsResponse]() +### func [ParseGetAgentDetailsResponse]() ```go func ParseGetAgentDetailsResponse(rsp *http.Response) (*GetAgentDetailsResponse, error) @@ -2242,7 +2853,7 @@ func ParseGetAgentDetailsResponse(rsp *http.Response) (*GetAgentDetailsResponse, ParseGetAgentDetailsResponse parses an HTTP response from a GetAgentDetailsWithResponse call -### func \(GetAgentDetailsResponse\) [Status]() +### func \(GetAgentDetailsResponse\) [Status]() ```go func (r GetAgentDetailsResponse) Status() string @@ -2251,7 +2862,7 @@ func (r GetAgentDetailsResponse) Status() string Status returns HTTPResponse.Status -### func \(GetAgentDetailsResponse\) [StatusCode]() +### func \(GetAgentDetailsResponse\) [StatusCode]() ```go func (r GetAgentDetailsResponse) StatusCode() int @@ -2260,7 +2871,7 @@ func (r GetAgentDetailsResponse) StatusCode() int StatusCode returns HTTPResponse.StatusCode -## type [GetAgentResponse]() +## type [GetAgentResponse]() @@ -2276,7 +2887,7 @@ type GetAgentResponse struct { ``` -### func [ParseGetAgentResponse]() +### func [ParseGetAgentResponse]() ```go func ParseGetAgentResponse(rsp *http.Response) (*GetAgentResponse, error) @@ -2285,7 +2896,7 @@ func ParseGetAgentResponse(rsp *http.Response) (*GetAgentResponse, error) ParseGetAgentResponse parses an HTTP response from a GetAgentWithResponse call -### func \(GetAgentResponse\) [Status]() +### func \(GetAgentResponse\) [Status]() ```go func (r GetAgentResponse) Status() string @@ -2294,7 +2905,7 @@ func (r GetAgentResponse) Status() string Status returns HTTPResponse.Status -### func \(GetAgentResponse\) [StatusCode]() +### func \(GetAgentResponse\) [StatusCode]() ```go func (r GetAgentResponse) StatusCode() int @@ -2303,7 +2914,7 @@ func (r GetAgentResponse) StatusCode() int StatusCode returns HTTPResponse.StatusCode -## type [GetAuditExportResponse]() +## type [GetAuditExportResponse]() @@ -2319,7 +2930,7 @@ type GetAuditExportResponse struct { ``` -### func [ParseGetAuditExportResponse]() +### func [ParseGetAuditExportResponse]() ```go func ParseGetAuditExportResponse(rsp *http.Response) (*GetAuditExportResponse, error) @@ -2328,7 +2939,7 @@ func ParseGetAuditExportResponse(rsp *http.Response) (*GetAuditExportResponse, e ParseGetAuditExportResponse parses an HTTP response from a GetAuditExportWithResponse call -### func \(GetAuditExportResponse\) [Status]() +### func \(GetAuditExportResponse\) [Status]() ```go func (r GetAuditExportResponse) Status() string @@ -2337,7 +2948,7 @@ func (r GetAuditExportResponse) Status() string Status returns HTTPResponse.Status -### func \(GetAuditExportResponse\) [StatusCode]() +### func \(GetAuditExportResponse\) [StatusCode]() ```go func (r GetAuditExportResponse) StatusCode() int @@ -2346,7 +2957,7 @@ func (r GetAuditExportResponse) StatusCode() int StatusCode returns HTTPResponse.StatusCode -## type [GetAuditLogByIDResponse]() +## type [GetAuditLogByIDResponse]() @@ -2363,7 +2974,7 @@ type GetAuditLogByIDResponse struct { ``` -### func [ParseGetAuditLogByIDResponse]() +### func [ParseGetAuditLogByIDResponse]() ```go func ParseGetAuditLogByIDResponse(rsp *http.Response) (*GetAuditLogByIDResponse, error) @@ -2372,7 +2983,7 @@ func ParseGetAuditLogByIDResponse(rsp *http.Response) (*GetAuditLogByIDResponse, ParseGetAuditLogByIDResponse parses an HTTP response from a GetAuditLogByIDWithResponse call -### func \(GetAuditLogByIDResponse\) [Status]() +### func \(GetAuditLogByIDResponse\) [Status]() ```go func (r GetAuditLogByIDResponse) Status() string @@ -2381,7 +2992,7 @@ func (r GetAuditLogByIDResponse) Status() string Status returns HTTPResponse.Status -### func \(GetAuditLogByIDResponse\) [StatusCode]() +### func \(GetAuditLogByIDResponse\) [StatusCode]() ```go func (r GetAuditLogByIDResponse) StatusCode() int @@ -2390,7 +3001,7 @@ func (r GetAuditLogByIDResponse) StatusCode() int StatusCode returns HTTPResponse.StatusCode -## type [GetAuditLogsParams]() +## type [GetAuditLogsParams]() GetAuditLogsParams defines parameters for GetAuditLogs. @@ -2405,7 +3016,7 @@ type GetAuditLogsParams struct { ``` -## type [GetAuditLogsResponse]() +## type [GetAuditLogsResponse]() @@ -2422,7 +3033,7 @@ type GetAuditLogsResponse struct { ``` -### func [ParseGetAuditLogsResponse]() +### func [ParseGetAuditLogsResponse]() ```go func ParseGetAuditLogsResponse(rsp *http.Response) (*GetAuditLogsResponse, error) @@ -2431,7 +3042,7 @@ func ParseGetAuditLogsResponse(rsp *http.Response) (*GetAuditLogsResponse, error ParseGetAuditLogsResponse parses an HTTP response from a GetAuditLogsWithResponse call -### func \(GetAuditLogsResponse\) [Status]() +### func \(GetAuditLogsResponse\) [Status]() ```go func (r GetAuditLogsResponse) Status() string @@ -2440,7 +3051,7 @@ func (r GetAuditLogsResponse) Status() string Status returns HTTPResponse.Status -### func \(GetAuditLogsResponse\) [StatusCode]() +### func \(GetAuditLogsResponse\) [StatusCode]() ```go func (r GetAuditLogsResponse) StatusCode() int @@ -2448,8 +3059,95 @@ func (r GetAuditLogsResponse) StatusCode() int StatusCode returns HTTPResponse.StatusCode + +## type [GetFileByNameResponse]() + + + +```go +type GetFileByNameResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *FileInfoResponse + JSON401 *ErrorResponse + JSON403 *ErrorResponse + JSON404 *ErrorResponse + JSON500 *ErrorResponse +} +``` + + +### func [ParseGetFileByNameResponse]() + +```go +func ParseGetFileByNameResponse(rsp *http.Response) (*GetFileByNameResponse, error) +``` + +ParseGetFileByNameResponse parses an HTTP response from a GetFileByNameWithResponse call + + +### func \(GetFileByNameResponse\) [Status]() + +```go +func (r GetFileByNameResponse) Status() string +``` + +Status returns HTTPResponse.Status + + +### func \(GetFileByNameResponse\) [StatusCode]() + +```go +func (r GetFileByNameResponse) StatusCode() int +``` + +StatusCode returns HTTPResponse.StatusCode + + +## type [GetFilesResponse]() + + + +```go +type GetFilesResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *FileListResponse + JSON401 *ErrorResponse + JSON403 *ErrorResponse + JSON500 *ErrorResponse +} +``` + + +### func [ParseGetFilesResponse]() + +```go +func ParseGetFilesResponse(rsp *http.Response) (*GetFilesResponse, error) +``` + +ParseGetFilesResponse parses an HTTP response from a GetFilesWithResponse call + + +### func \(GetFilesResponse\) [Status]() + +```go +func (r GetFilesResponse) Status() string +``` + +Status returns HTTPResponse.Status + + +### func \(GetFilesResponse\) [StatusCode]() + +```go +func (r GetFilesResponse) StatusCode() int +``` + +StatusCode returns HTTPResponse.StatusCode + -## type [GetHealthReadyResponse]() +## type [GetHealthReadyResponse]() @@ -2463,7 +3161,7 @@ type GetHealthReadyResponse struct { ``` -### func [ParseGetHealthReadyResponse]() +### func [ParseGetHealthReadyResponse]() ```go func ParseGetHealthReadyResponse(rsp *http.Response) (*GetHealthReadyResponse, error) @@ -2472,7 +3170,7 @@ func ParseGetHealthReadyResponse(rsp *http.Response) (*GetHealthReadyResponse, e ParseGetHealthReadyResponse parses an HTTP response from a GetHealthReadyWithResponse call -### func \(GetHealthReadyResponse\) [Status]() +### func \(GetHealthReadyResponse\) [Status]() ```go func (r GetHealthReadyResponse) Status() string @@ -2481,7 +3179,7 @@ func (r GetHealthReadyResponse) Status() string Status returns HTTPResponse.Status -### func \(GetHealthReadyResponse\) [StatusCode]() +### func \(GetHealthReadyResponse\) [StatusCode]() ```go func (r GetHealthReadyResponse) StatusCode() int @@ -2490,7 +3188,7 @@ func (r GetHealthReadyResponse) StatusCode() int StatusCode returns HTTPResponse.StatusCode -## type [GetHealthResponse]() +## type [GetHealthResponse]() @@ -2503,7 +3201,7 @@ type GetHealthResponse struct { ``` -### func [ParseGetHealthResponse]() +### func [ParseGetHealthResponse]() ```go func ParseGetHealthResponse(rsp *http.Response) (*GetHealthResponse, error) @@ -2512,7 +3210,7 @@ func ParseGetHealthResponse(rsp *http.Response) (*GetHealthResponse, error) ParseGetHealthResponse parses an HTTP response from a GetHealthWithResponse call -### func \(GetHealthResponse\) [Status]() +### func \(GetHealthResponse\) [Status]() ```go func (r GetHealthResponse) Status() string @@ -2521,7 +3219,7 @@ func (r GetHealthResponse) Status() string Status returns HTTPResponse.Status -### func \(GetHealthResponse\) [StatusCode]() +### func \(GetHealthResponse\) [StatusCode]() ```go func (r GetHealthResponse) StatusCode() int @@ -2530,7 +3228,7 @@ func (r GetHealthResponse) StatusCode() int StatusCode returns HTTPResponse.StatusCode -## type [GetHealthStatusResponse]() +## type [GetHealthStatusResponse]() @@ -2546,7 +3244,7 @@ type GetHealthStatusResponse struct { ``` -### func [ParseGetHealthStatusResponse]() +### func [ParseGetHealthStatusResponse]() ```go func ParseGetHealthStatusResponse(rsp *http.Response) (*GetHealthStatusResponse, error) @@ -2555,7 +3253,7 @@ func ParseGetHealthStatusResponse(rsp *http.Response) (*GetHealthStatusResponse, ParseGetHealthStatusResponse parses an HTTP response from a GetHealthStatusWithResponse call -### func \(GetHealthStatusResponse\) [Status]() +### func \(GetHealthStatusResponse\) [Status]() ```go func (r GetHealthStatusResponse) Status() string @@ -2564,7 +3262,7 @@ func (r GetHealthStatusResponse) Status() string Status returns HTTPResponse.Status -### func \(GetHealthStatusResponse\) [StatusCode]() +### func \(GetHealthStatusResponse\) [StatusCode]() ```go func (r GetHealthStatusResponse) StatusCode() int @@ -2573,7 +3271,7 @@ func (r GetHealthStatusResponse) StatusCode() int StatusCode returns HTTPResponse.StatusCode -## type [GetJobByIDResponse]() +## type [GetJobByIDResponse]() @@ -2591,7 +3289,7 @@ type GetJobByIDResponse struct { ``` -### func [ParseGetJobByIDResponse]() +### func [ParseGetJobByIDResponse]() ```go func ParseGetJobByIDResponse(rsp *http.Response) (*GetJobByIDResponse, error) @@ -2600,7 +3298,7 @@ func ParseGetJobByIDResponse(rsp *http.Response) (*GetJobByIDResponse, error) ParseGetJobByIDResponse parses an HTTP response from a GetJobByIDWithResponse call -### func \(GetJobByIDResponse\) [Status]() +### func \(GetJobByIDResponse\) [Status]() ```go func (r GetJobByIDResponse) Status() string @@ -2609,7 +3307,7 @@ func (r GetJobByIDResponse) Status() string Status returns HTTPResponse.Status -### func \(GetJobByIDResponse\) [StatusCode]() +### func \(GetJobByIDResponse\) [StatusCode]() ```go func (r GetJobByIDResponse) StatusCode() int @@ -2618,7 +3316,7 @@ func (r GetJobByIDResponse) StatusCode() int StatusCode returns HTTPResponse.StatusCode -## type [GetJobParams]() +## type [GetJobParams]() GetJobParams defines parameters for GetJob. @@ -2636,7 +3334,7 @@ type GetJobParams struct { ``` -## type [GetJobParamsStatus]() +## type [GetJobParamsStatus]() GetJobParamsStatus defines parameters for GetJob. @@ -2657,7 +3355,7 @@ const ( ``` -## type [GetJobResponse]() +## type [GetJobResponse]() @@ -2674,7 +3372,7 @@ type GetJobResponse struct { ``` -### func [ParseGetJobResponse]() +### func [ParseGetJobResponse]() ```go func ParseGetJobResponse(rsp *http.Response) (*GetJobResponse, error) @@ -2683,7 +3381,7 @@ func ParseGetJobResponse(rsp *http.Response) (*GetJobResponse, error) ParseGetJobResponse parses an HTTP response from a GetJobWithResponse call -### func \(GetJobResponse\) [Status]() +### func \(GetJobResponse\) [Status]() ```go func (r GetJobResponse) Status() string @@ -2692,7 +3390,7 @@ func (r GetJobResponse) Status() string Status returns HTTPResponse.Status -### func \(GetJobResponse\) [StatusCode]() +### func \(GetJobResponse\) [StatusCode]() ```go func (r GetJobResponse) StatusCode() int @@ -2701,7 +3399,7 @@ func (r GetJobResponse) StatusCode() int StatusCode returns HTTPResponse.StatusCode -## type [GetJobStatusResponse]() +## type [GetJobStatusResponse]() @@ -2717,7 +3415,7 @@ type GetJobStatusResponse struct { ``` -### func [ParseGetJobStatusResponse]() +### func [ParseGetJobStatusResponse]() ```go func ParseGetJobStatusResponse(rsp *http.Response) (*GetJobStatusResponse, error) @@ -2726,7 +3424,7 @@ func ParseGetJobStatusResponse(rsp *http.Response) (*GetJobStatusResponse, error ParseGetJobStatusResponse parses an HTTP response from a GetJobStatusWithResponse call -### func \(GetJobStatusResponse\) [Status]() +### func \(GetJobStatusResponse\) [Status]() ```go func (r GetJobStatusResponse) Status() string @@ -2735,7 +3433,7 @@ func (r GetJobStatusResponse) Status() string Status returns HTTPResponse.Status -### func \(GetJobStatusResponse\) [StatusCode]() +### func \(GetJobStatusResponse\) [StatusCode]() ```go func (r GetJobStatusResponse) StatusCode() int @@ -2744,7 +3442,7 @@ func (r GetJobStatusResponse) StatusCode() int StatusCode returns HTTPResponse.StatusCode -## type [GetNodeDiskResponse]() +## type [GetNodeDiskResponse]() @@ -2761,7 +3459,7 @@ type GetNodeDiskResponse struct { ``` -### func [ParseGetNodeDiskResponse]() +### func [ParseGetNodeDiskResponse]() ```go func ParseGetNodeDiskResponse(rsp *http.Response) (*GetNodeDiskResponse, error) @@ -2770,7 +3468,7 @@ func ParseGetNodeDiskResponse(rsp *http.Response) (*GetNodeDiskResponse, error) ParseGetNodeDiskResponse parses an HTTP response from a GetNodeDiskWithResponse call -### func \(GetNodeDiskResponse\) [Status]() +### func \(GetNodeDiskResponse\) [Status]() ```go func (r GetNodeDiskResponse) Status() string @@ -2779,7 +3477,7 @@ func (r GetNodeDiskResponse) Status() string Status returns HTTPResponse.Status -### func \(GetNodeDiskResponse\) [StatusCode]() +### func \(GetNodeDiskResponse\) [StatusCode]() ```go func (r GetNodeDiskResponse) StatusCode() int @@ -2788,7 +3486,7 @@ func (r GetNodeDiskResponse) StatusCode() int StatusCode returns HTTPResponse.StatusCode -## type [GetNodeHostnameResponse]() +## type [GetNodeHostnameResponse]() @@ -2805,7 +3503,7 @@ type GetNodeHostnameResponse struct { ``` -### func [ParseGetNodeHostnameResponse]() +### func [ParseGetNodeHostnameResponse]() ```go func ParseGetNodeHostnameResponse(rsp *http.Response) (*GetNodeHostnameResponse, error) @@ -2814,7 +3512,7 @@ func ParseGetNodeHostnameResponse(rsp *http.Response) (*GetNodeHostnameResponse, ParseGetNodeHostnameResponse parses an HTTP response from a GetNodeHostnameWithResponse call -### func \(GetNodeHostnameResponse\) [Status]() +### func \(GetNodeHostnameResponse\) [Status]() ```go func (r GetNodeHostnameResponse) Status() string @@ -2823,7 +3521,7 @@ func (r GetNodeHostnameResponse) Status() string Status returns HTTPResponse.Status -### func \(GetNodeHostnameResponse\) [StatusCode]() +### func \(GetNodeHostnameResponse\) [StatusCode]() ```go func (r GetNodeHostnameResponse) StatusCode() int @@ -2832,7 +3530,7 @@ func (r GetNodeHostnameResponse) StatusCode() int StatusCode returns HTTPResponse.StatusCode -## type [GetNodeLoadResponse]() +## type [GetNodeLoadResponse]() @@ -2849,7 +3547,7 @@ type GetNodeLoadResponse struct { ``` -### func [ParseGetNodeLoadResponse]() +### func [ParseGetNodeLoadResponse]() ```go func ParseGetNodeLoadResponse(rsp *http.Response) (*GetNodeLoadResponse, error) @@ -2858,7 +3556,7 @@ func ParseGetNodeLoadResponse(rsp *http.Response) (*GetNodeLoadResponse, error) ParseGetNodeLoadResponse parses an HTTP response from a GetNodeLoadWithResponse call -### func \(GetNodeLoadResponse\) [Status]() +### func \(GetNodeLoadResponse\) [Status]() ```go func (r GetNodeLoadResponse) Status() string @@ -2867,7 +3565,7 @@ func (r GetNodeLoadResponse) Status() string Status returns HTTPResponse.Status -### func \(GetNodeLoadResponse\) [StatusCode]() +### func \(GetNodeLoadResponse\) [StatusCode]() ```go func (r GetNodeLoadResponse) StatusCode() int @@ -2876,7 +3574,7 @@ func (r GetNodeLoadResponse) StatusCode() int StatusCode returns HTTPResponse.StatusCode -## type [GetNodeMemoryResponse]() +## type [GetNodeMemoryResponse]() @@ -2893,7 +3591,7 @@ type GetNodeMemoryResponse struct { ``` -### func [ParseGetNodeMemoryResponse]() +### func [ParseGetNodeMemoryResponse]() ```go func ParseGetNodeMemoryResponse(rsp *http.Response) (*GetNodeMemoryResponse, error) @@ -2902,7 +3600,7 @@ func ParseGetNodeMemoryResponse(rsp *http.Response) (*GetNodeMemoryResponse, err ParseGetNodeMemoryResponse parses an HTTP response from a GetNodeMemoryWithResponse call -### func \(GetNodeMemoryResponse\) [Status]() +### func \(GetNodeMemoryResponse\) [Status]() ```go func (r GetNodeMemoryResponse) Status() string @@ -2911,7 +3609,7 @@ func (r GetNodeMemoryResponse) Status() string Status returns HTTPResponse.Status -### func \(GetNodeMemoryResponse\) [StatusCode]() +### func \(GetNodeMemoryResponse\) [StatusCode]() ```go func (r GetNodeMemoryResponse) StatusCode() int @@ -2920,7 +3618,7 @@ func (r GetNodeMemoryResponse) StatusCode() int StatusCode returns HTTPResponse.StatusCode -## type [GetNodeNetworkDNSByInterfaceResponse]() +## type [GetNodeNetworkDNSByInterfaceResponse]() @@ -2937,7 +3635,7 @@ type GetNodeNetworkDNSByInterfaceResponse struct { ``` -### func [ParseGetNodeNetworkDNSByInterfaceResponse]() +### func [ParseGetNodeNetworkDNSByInterfaceResponse]() ```go func ParseGetNodeNetworkDNSByInterfaceResponse(rsp *http.Response) (*GetNodeNetworkDNSByInterfaceResponse, error) @@ -2946,7 +3644,7 @@ func ParseGetNodeNetworkDNSByInterfaceResponse(rsp *http.Response) (*GetNodeNetw ParseGetNodeNetworkDNSByInterfaceResponse parses an HTTP response from a GetNodeNetworkDNSByInterfaceWithResponse call -### func \(GetNodeNetworkDNSByInterfaceResponse\) [Status]() +### func \(GetNodeNetworkDNSByInterfaceResponse\) [Status]() ```go func (r GetNodeNetworkDNSByInterfaceResponse) Status() string @@ -2955,7 +3653,7 @@ func (r GetNodeNetworkDNSByInterfaceResponse) Status() string Status returns HTTPResponse.Status -### func \(GetNodeNetworkDNSByInterfaceResponse\) [StatusCode]() +### func \(GetNodeNetworkDNSByInterfaceResponse\) [StatusCode]() ```go func (r GetNodeNetworkDNSByInterfaceResponse) StatusCode() int @@ -2964,7 +3662,7 @@ func (r GetNodeNetworkDNSByInterfaceResponse) StatusCode() int StatusCode returns HTTPResponse.StatusCode -## type [GetNodeOSResponse]() +## type [GetNodeOSResponse]() @@ -2981,7 +3679,7 @@ type GetNodeOSResponse struct { ``` -### func [ParseGetNodeOSResponse]() +### func [ParseGetNodeOSResponse]() ```go func ParseGetNodeOSResponse(rsp *http.Response) (*GetNodeOSResponse, error) @@ -2990,7 +3688,7 @@ func ParseGetNodeOSResponse(rsp *http.Response) (*GetNodeOSResponse, error) ParseGetNodeOSResponse parses an HTTP response from a GetNodeOSWithResponse call -### func \(GetNodeOSResponse\) [Status]() +### func \(GetNodeOSResponse\) [Status]() ```go func (r GetNodeOSResponse) Status() string @@ -2999,7 +3697,7 @@ func (r GetNodeOSResponse) Status() string Status returns HTTPResponse.Status -### func \(GetNodeOSResponse\) [StatusCode]() +### func \(GetNodeOSResponse\) [StatusCode]() ```go func (r GetNodeOSResponse) StatusCode() int @@ -3008,7 +3706,7 @@ func (r GetNodeOSResponse) StatusCode() int StatusCode returns HTTPResponse.StatusCode -## type [GetNodeStatusResponse]() +## type [GetNodeStatusResponse]() @@ -3025,7 +3723,7 @@ type GetNodeStatusResponse struct { ``` -### func [ParseGetNodeStatusResponse]() +### func [ParseGetNodeStatusResponse]() ```go func ParseGetNodeStatusResponse(rsp *http.Response) (*GetNodeStatusResponse, error) @@ -3034,7 +3732,7 @@ func ParseGetNodeStatusResponse(rsp *http.Response) (*GetNodeStatusResponse, err ParseGetNodeStatusResponse parses an HTTP response from a GetNodeStatusWithResponse call -### func \(GetNodeStatusResponse\) [Status]() +### func \(GetNodeStatusResponse\) [Status]() ```go func (r GetNodeStatusResponse) Status() string @@ -3043,7 +3741,7 @@ func (r GetNodeStatusResponse) Status() string Status returns HTTPResponse.Status -### func \(GetNodeStatusResponse\) [StatusCode]() +### func \(GetNodeStatusResponse\) [StatusCode]() ```go func (r GetNodeStatusResponse) StatusCode() int @@ -3052,7 +3750,7 @@ func (r GetNodeStatusResponse) StatusCode() int StatusCode returns HTTPResponse.StatusCode -## type [GetNodeUptimeResponse]() +## type [GetNodeUptimeResponse]() @@ -3069,7 +3767,7 @@ type GetNodeUptimeResponse struct { ``` -### func [ParseGetNodeUptimeResponse]() +### func [ParseGetNodeUptimeResponse]() ```go func ParseGetNodeUptimeResponse(rsp *http.Response) (*GetNodeUptimeResponse, error) @@ -3078,7 +3776,7 @@ func ParseGetNodeUptimeResponse(rsp *http.Response) (*GetNodeUptimeResponse, err ParseGetNodeUptimeResponse parses an HTTP response from a GetNodeUptimeWithResponse call -### func \(GetNodeUptimeResponse\) [Status]() +### func \(GetNodeUptimeResponse\) [Status]() ```go func (r GetNodeUptimeResponse) Status() string @@ -3087,7 +3785,7 @@ func (r GetNodeUptimeResponse) Status() string Status returns HTTPResponse.Status -### func \(GetNodeUptimeResponse\) [StatusCode]() +### func \(GetNodeUptimeResponse\) [StatusCode]() ```go func (r GetNodeUptimeResponse) StatusCode() int @@ -3096,7 +3794,7 @@ func (r GetNodeUptimeResponse) StatusCode() int StatusCode returns HTTPResponse.StatusCode -## type [GetVersionResponse]() +## type [GetVersionResponse]() @@ -3109,7 +3807,7 @@ type GetVersionResponse struct { ``` -### func [ParseGetVersionResponse]() +### func [ParseGetVersionResponse]() ```go func ParseGetVersionResponse(rsp *http.Response) (*GetVersionResponse, error) @@ -3118,7 +3816,7 @@ func ParseGetVersionResponse(rsp *http.Response) (*GetVersionResponse, error) ParseGetVersionResponse parses an HTTP response from a GetVersionWithResponse call -### func \(GetVersionResponse\) [Status]() +### func \(GetVersionResponse\) [Status]() ```go func (r GetVersionResponse) Status() string @@ -3127,7 +3825,7 @@ func (r GetVersionResponse) Status() string Status returns HTTPResponse.Status -### func \(GetVersionResponse\) [StatusCode]() +### func \(GetVersionResponse\) [StatusCode]() ```go func (r GetVersionResponse) StatusCode() int @@ -3136,7 +3834,7 @@ func (r GetVersionResponse) StatusCode() int StatusCode returns HTTPResponse.StatusCode -## type [HealthResponse]() +## type [HealthResponse]() HealthResponse defines model for HealthResponse. @@ -3148,7 +3846,7 @@ type HealthResponse struct { ``` -## type [Hostname]() +## type [Hostname]() Hostname defines model for Hostname. @@ -3157,7 +3855,7 @@ type Hostname = string ``` -## type [HostnameCollectionResponse]() +## type [HostnameCollectionResponse]() HostnameCollectionResponse defines model for HostnameCollectionResponse. @@ -3170,7 +3868,7 @@ type HostnameCollectionResponse struct { ``` -## type [HostnameResponse]() +## type [HostnameResponse]() HostnameResponse The hostname of the system. @@ -3188,7 +3886,7 @@ type HostnameResponse struct { ``` -## type [HttpRequestDoer]() +## type [HttpRequestDoer]() Doer performs HTTP requests. @@ -3201,7 +3899,7 @@ type HttpRequestDoer interface { ``` -## type [JobDetailResponse]() +## type [JobDetailResponse]() JobDetailResponse defines model for JobDetailResponse. @@ -3268,7 +3966,7 @@ type JobDetailResponse struct { ``` -## type [JobStats]() +## type [JobStats]() JobStats defines model for JobStats. @@ -3295,7 +3993,7 @@ type JobStats struct { ``` -## type [KVBucketInfo]() +## type [KVBucketInfo]() KVBucketInfo defines model for KVBucketInfo. @@ -3313,7 +4011,7 @@ type KVBucketInfo struct { ``` -## type [ListAgentsResponse]() +## type [ListAgentsResponse]() ListAgentsResponse defines model for ListAgentsResponse. @@ -3327,7 +4025,7 @@ type ListAgentsResponse struct { ``` -## type [ListAuditResponse]() +## type [ListAuditResponse]() ListAuditResponse defines model for ListAuditResponse. @@ -3342,7 +4040,7 @@ type ListAuditResponse struct { ``` -## type [ListJobsResponse]() +## type [ListJobsResponse]() ListJobsResponse defines model for ListJobsResponse. @@ -3356,7 +4054,7 @@ type ListJobsResponse struct { ``` -## type [LoadAverageResponse]() +## type [LoadAverageResponse]() LoadAverageResponse The system load averages for 1, 5, and 15 minutes. @@ -3374,7 +4072,7 @@ type LoadAverageResponse struct { ``` -## type [LoadCollectionResponse]() +## type [LoadCollectionResponse]() LoadCollectionResponse defines model for LoadCollectionResponse. @@ -3387,7 +4085,7 @@ type LoadCollectionResponse struct { ``` -## type [LoadResultItem]() +## type [LoadResultItem]() LoadResultItem defines model for LoadResultItem. @@ -3405,7 +4103,7 @@ type LoadResultItem struct { ``` -## type [MemoryCollectionResponse]() +## type [MemoryCollectionResponse]() MemoryCollectionResponse defines model for MemoryCollectionResponse. @@ -3418,7 +4116,7 @@ type MemoryCollectionResponse struct { ``` -## type [MemoryResponse]() +## type [MemoryResponse]() MemoryResponse Memory usage information. @@ -3436,7 +4134,7 @@ type MemoryResponse struct { ``` -## type [MemoryResultItem]() +## type [MemoryResultItem]() MemoryResultItem defines model for MemoryResultItem. @@ -3454,7 +4152,7 @@ type MemoryResultItem struct { ``` -## type [NATSInfo]() +## type [NATSInfo]() NATSInfo defines model for NATSInfo. @@ -3469,7 +4167,7 @@ type NATSInfo struct { ``` -## type [NetworkInterfaceResponse]() +## type [NetworkInterfaceResponse]() NetworkInterfaceResponse defines model for NetworkInterfaceResponse. @@ -3485,7 +4183,7 @@ type NetworkInterfaceResponse struct { ``` -## type [NetworkInterfaceResponseFamily]() +## type [NetworkInterfaceResponseFamily]() NetworkInterfaceResponseFamily IP address family. @@ -3504,7 +4202,7 @@ const ( ``` -## type [NodeCondition]() +## type [NodeCondition]() NodeCondition defines model for NodeCondition. @@ -3518,7 +4216,7 @@ type NodeCondition struct { ``` -## type [NodeConditionType]() +## type [NodeConditionType]() NodeConditionType defines model for NodeCondition.Type. @@ -3537,7 +4235,7 @@ const ( ``` -## type [NodeStatusCollectionResponse]() +## type [NodeStatusCollectionResponse]() NodeStatusCollectionResponse defines model for NodeStatusCollectionResponse. @@ -3550,7 +4248,7 @@ type NodeStatusCollectionResponse struct { ``` -## type [NodeStatusResponse]() +## type [NodeStatusResponse]() NodeStatusResponse defines model for NodeStatusResponse. @@ -3580,7 +4278,7 @@ type NodeStatusResponse struct { ``` -## type [OSInfoCollectionResponse]() +## type [OSInfoCollectionResponse]() OSInfoCollectionResponse defines model for OSInfoCollectionResponse. @@ -3593,7 +4291,7 @@ type OSInfoCollectionResponse struct { ``` -## type [OSInfoResponse]() +## type [OSInfoResponse]() OSInfoResponse Operating system information. @@ -3608,7 +4306,7 @@ type OSInfoResponse struct { ``` -## type [OSInfoResultItem]() +## type [OSInfoResultItem]() OSInfoResultItem defines model for OSInfoResultItem. @@ -3626,7 +4324,7 @@ type OSInfoResultItem struct { ``` -## type [PingCollectionResponse]() +## type [PingCollectionResponse]() PingCollectionResponse defines model for PingCollectionResponse. @@ -3639,7 +4337,7 @@ type PingCollectionResponse struct { ``` -## type [PingResponse]() +## type [PingResponse]() PingResponse defines model for PingResponse. @@ -3671,8 +4369,61 @@ type PingResponse struct { } ``` + +## type [PostFileJSONRequestBody]() + +PostFileJSONRequestBody defines body for PostFile for application/json ContentType. + +```go +type PostFileJSONRequestBody = FileUploadRequest +``` + + +## type [PostFileResponse]() + + + +```go +type PostFileResponse struct { + Body []byte + HTTPResponse *http.Response + JSON201 *FileUploadResponse + JSON400 *ErrorResponse + JSON401 *ErrorResponse + JSON403 *ErrorResponse + JSON500 *ErrorResponse +} +``` + + +### func [ParsePostFileResponse]() + +```go +func ParsePostFileResponse(rsp *http.Response) (*PostFileResponse, error) +``` + +ParsePostFileResponse parses an HTTP response from a PostFileWithResponse call + + +### func \(PostFileResponse\) [Status]() + +```go +func (r PostFileResponse) Status() string +``` + +Status returns HTTPResponse.Status + + +### func \(PostFileResponse\) [StatusCode]() + +```go +func (r PostFileResponse) StatusCode() int +``` + +StatusCode returns HTTPResponse.StatusCode + -## type [PostJobJSONRequestBody]() +## type [PostJobJSONRequestBody]() PostJobJSONRequestBody defines body for PostJob for application/json ContentType. @@ -3681,7 +4432,7 @@ type PostJobJSONRequestBody = CreateJobRequest ``` -## type [PostJobResponse]() +## type [PostJobResponse]() @@ -3698,7 +4449,7 @@ type PostJobResponse struct { ``` -### func [ParsePostJobResponse]() +### func [ParsePostJobResponse]() ```go func ParsePostJobResponse(rsp *http.Response) (*PostJobResponse, error) @@ -3707,7 +4458,7 @@ func ParsePostJobResponse(rsp *http.Response) (*PostJobResponse, error) ParsePostJobResponse parses an HTTP response from a PostJobWithResponse call -### func \(PostJobResponse\) [Status]() +### func \(PostJobResponse\) [Status]() ```go func (r PostJobResponse) Status() string @@ -3716,7 +4467,7 @@ func (r PostJobResponse) Status() string Status returns HTTPResponse.Status -### func \(PostJobResponse\) [StatusCode]() +### func \(PostJobResponse\) [StatusCode]() ```go func (r PostJobResponse) StatusCode() int @@ -3725,7 +4476,7 @@ func (r PostJobResponse) StatusCode() int StatusCode returns HTTPResponse.StatusCode -## type [PostNodeCommandExecJSONRequestBody]() +## type [PostNodeCommandExecJSONRequestBody]() PostNodeCommandExecJSONRequestBody defines body for PostNodeCommandExec for application/json ContentType. @@ -3734,7 +4485,7 @@ type PostNodeCommandExecJSONRequestBody = CommandExecRequest ``` -## type [PostNodeCommandExecResponse]() +## type [PostNodeCommandExecResponse]() @@ -3751,7 +4502,7 @@ type PostNodeCommandExecResponse struct { ``` -### func [ParsePostNodeCommandExecResponse]() +### func [ParsePostNodeCommandExecResponse]() ```go func ParsePostNodeCommandExecResponse(rsp *http.Response) (*PostNodeCommandExecResponse, error) @@ -3760,7 +4511,7 @@ func ParsePostNodeCommandExecResponse(rsp *http.Response) (*PostNodeCommandExecR ParsePostNodeCommandExecResponse parses an HTTP response from a PostNodeCommandExecWithResponse call -### func \(PostNodeCommandExecResponse\) [Status]() +### func \(PostNodeCommandExecResponse\) [Status]() ```go func (r PostNodeCommandExecResponse) Status() string @@ -3769,7 +4520,7 @@ func (r PostNodeCommandExecResponse) Status() string Status returns HTTPResponse.Status -### func \(PostNodeCommandExecResponse\) [StatusCode]() +### func \(PostNodeCommandExecResponse\) [StatusCode]() ```go func (r PostNodeCommandExecResponse) StatusCode() int @@ -3778,7 +4529,7 @@ func (r PostNodeCommandExecResponse) StatusCode() int StatusCode returns HTTPResponse.StatusCode -## type [PostNodeCommandShellJSONRequestBody]() +## type [PostNodeCommandShellJSONRequestBody]() PostNodeCommandShellJSONRequestBody defines body for PostNodeCommandShell for application/json ContentType. @@ -3787,7 +4538,7 @@ type PostNodeCommandShellJSONRequestBody = CommandShellRequest ``` -## type [PostNodeCommandShellResponse]() +## type [PostNodeCommandShellResponse]() @@ -3804,7 +4555,7 @@ type PostNodeCommandShellResponse struct { ``` -### func [ParsePostNodeCommandShellResponse]() +### func [ParsePostNodeCommandShellResponse]() ```go func ParsePostNodeCommandShellResponse(rsp *http.Response) (*PostNodeCommandShellResponse, error) @@ -3813,7 +4564,7 @@ func ParsePostNodeCommandShellResponse(rsp *http.Response) (*PostNodeCommandShel ParsePostNodeCommandShellResponse parses an HTTP response from a PostNodeCommandShellWithResponse call -### func \(PostNodeCommandShellResponse\) [Status]() +### func \(PostNodeCommandShellResponse\) [Status]() ```go func (r PostNodeCommandShellResponse) Status() string @@ -3822,7 +4573,7 @@ func (r PostNodeCommandShellResponse) Status() string Status returns HTTPResponse.Status -### func \(PostNodeCommandShellResponse\) [StatusCode]() +### func \(PostNodeCommandShellResponse\) [StatusCode]() ```go func (r PostNodeCommandShellResponse) StatusCode() int @@ -3830,8 +4581,114 @@ func (r PostNodeCommandShellResponse) StatusCode() int StatusCode returns HTTPResponse.StatusCode + +## type [PostNodeFileDeployJSONRequestBody]() + +PostNodeFileDeployJSONRequestBody defines body for PostNodeFileDeploy for application/json ContentType. + +```go +type PostNodeFileDeployJSONRequestBody = FileDeployRequest +``` + + +## type [PostNodeFileDeployResponse]() + + + +```go +type PostNodeFileDeployResponse struct { + Body []byte + HTTPResponse *http.Response + JSON202 *FileDeployResponse + JSON400 *ErrorResponse + JSON401 *ErrorResponse + JSON403 *ErrorResponse + JSON500 *ErrorResponse +} +``` + + +### func [ParsePostNodeFileDeployResponse]() + +```go +func ParsePostNodeFileDeployResponse(rsp *http.Response) (*PostNodeFileDeployResponse, error) +``` + +ParsePostNodeFileDeployResponse parses an HTTP response from a PostNodeFileDeployWithResponse call + + +### func \(PostNodeFileDeployResponse\) [Status]() + +```go +func (r PostNodeFileDeployResponse) Status() string +``` + +Status returns HTTPResponse.Status + + +### func \(PostNodeFileDeployResponse\) [StatusCode]() + +```go +func (r PostNodeFileDeployResponse) StatusCode() int +``` + +StatusCode returns HTTPResponse.StatusCode + + +## type [PostNodeFileStatusJSONRequestBody]() + +PostNodeFileStatusJSONRequestBody defines body for PostNodeFileStatus for application/json ContentType. + +```go +type PostNodeFileStatusJSONRequestBody = FileStatusRequest +``` + + +## type [PostNodeFileStatusResponse]() + + + +```go +type PostNodeFileStatusResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *FileStatusResponse + JSON400 *ErrorResponse + JSON401 *ErrorResponse + JSON403 *ErrorResponse + JSON500 *ErrorResponse +} +``` + + +### func [ParsePostNodeFileStatusResponse]() + +```go +func ParsePostNodeFileStatusResponse(rsp *http.Response) (*PostNodeFileStatusResponse, error) +``` + +ParsePostNodeFileStatusResponse parses an HTTP response from a PostNodeFileStatusWithResponse call + + +### func \(PostNodeFileStatusResponse\) [Status]() + +```go +func (r PostNodeFileStatusResponse) Status() string +``` + +Status returns HTTPResponse.Status + + +### func \(PostNodeFileStatusResponse\) [StatusCode]() + +```go +func (r PostNodeFileStatusResponse) StatusCode() int +``` + +StatusCode returns HTTPResponse.StatusCode + -## type [PostNodeNetworkPingJSONBody]() +## type [PostNodeNetworkPingJSONBody]() PostNodeNetworkPingJSONBody defines parameters for PostNodeNetworkPing. @@ -3843,7 +4700,7 @@ type PostNodeNetworkPingJSONBody struct { ``` -## type [PostNodeNetworkPingJSONRequestBody]() +## type [PostNodeNetworkPingJSONRequestBody]() PostNodeNetworkPingJSONRequestBody defines body for PostNodeNetworkPing for application/json ContentType. @@ -3852,7 +4709,7 @@ type PostNodeNetworkPingJSONRequestBody PostNodeNetworkPingJSONBody ``` -## type [PostNodeNetworkPingResponse]() +## type [PostNodeNetworkPingResponse]() @@ -3869,7 +4726,7 @@ type PostNodeNetworkPingResponse struct { ``` -### func [ParsePostNodeNetworkPingResponse]() +### func [ParsePostNodeNetworkPingResponse]() ```go func ParsePostNodeNetworkPingResponse(rsp *http.Response) (*PostNodeNetworkPingResponse, error) @@ -3878,7 +4735,7 @@ func ParsePostNodeNetworkPingResponse(rsp *http.Response) (*PostNodeNetworkPingR ParsePostNodeNetworkPingResponse parses an HTTP response from a PostNodeNetworkPingWithResponse call -### func \(PostNodeNetworkPingResponse\) [Status]() +### func \(PostNodeNetworkPingResponse\) [Status]() ```go func (r PostNodeNetworkPingResponse) Status() string @@ -3887,7 +4744,7 @@ func (r PostNodeNetworkPingResponse) Status() string Status returns HTTPResponse.Status -### func \(PostNodeNetworkPingResponse\) [StatusCode]() +### func \(PostNodeNetworkPingResponse\) [StatusCode]() ```go func (r PostNodeNetworkPingResponse) StatusCode() int @@ -3896,7 +4753,7 @@ func (r PostNodeNetworkPingResponse) StatusCode() int StatusCode returns HTTPResponse.StatusCode -## type [PutNodeNetworkDNSJSONRequestBody]() +## type [PutNodeNetworkDNSJSONRequestBody]() PutNodeNetworkDNSJSONRequestBody defines body for PutNodeNetworkDNS for application/json ContentType. @@ -3905,7 +4762,7 @@ type PutNodeNetworkDNSJSONRequestBody = DNSConfigUpdateRequest ``` -## type [PutNodeNetworkDNSResponse]() +## type [PutNodeNetworkDNSResponse]() @@ -3922,7 +4779,7 @@ type PutNodeNetworkDNSResponse struct { ``` -### func [ParsePutNodeNetworkDNSResponse]() +### func [ParsePutNodeNetworkDNSResponse]() ```go func ParsePutNodeNetworkDNSResponse(rsp *http.Response) (*PutNodeNetworkDNSResponse, error) @@ -3931,7 +4788,7 @@ func ParsePutNodeNetworkDNSResponse(rsp *http.Response) (*PutNodeNetworkDNSRespo ParsePutNodeNetworkDNSResponse parses an HTTP response from a PutNodeNetworkDNSWithResponse call -### func \(PutNodeNetworkDNSResponse\) [Status]() +### func \(PutNodeNetworkDNSResponse\) [Status]() ```go func (r PutNodeNetworkDNSResponse) Status() string @@ -3940,7 +4797,7 @@ func (r PutNodeNetworkDNSResponse) Status() string Status returns HTTPResponse.Status -### func \(PutNodeNetworkDNSResponse\) [StatusCode]() +### func \(PutNodeNetworkDNSResponse\) [StatusCode]() ```go func (r PutNodeNetworkDNSResponse) StatusCode() int @@ -3949,7 +4806,7 @@ func (r PutNodeNetworkDNSResponse) StatusCode() int StatusCode returns HTTPResponse.StatusCode -## type [QueueStatsResponse]() +## type [QueueStatsResponse]() QueueStatsResponse defines model for QueueStatsResponse. @@ -3970,7 +4827,7 @@ type QueueStatsResponse struct { ``` -## type [ReadyResponse]() +## type [ReadyResponse]() ReadyResponse defines model for ReadyResponse. @@ -3985,7 +4842,7 @@ type ReadyResponse struct { ``` -## type [RequestEditorFn]() +## type [RequestEditorFn]() RequestEditorFn is the function signature for the RequestEditor callback function @@ -3994,7 +4851,7 @@ type RequestEditorFn func(ctx context.Context, req *http.Request) error ``` -## type [RetryJobByIDJSONRequestBody]() +## type [RetryJobByIDJSONRequestBody]() RetryJobByIDJSONRequestBody defines body for RetryJobByID for application/json ContentType. @@ -4003,7 +4860,7 @@ type RetryJobByIDJSONRequestBody = RetryJobRequest ``` -## type [RetryJobByIDResponse]() +## type [RetryJobByIDResponse]() @@ -4021,7 +4878,7 @@ type RetryJobByIDResponse struct { ``` -### func [ParseRetryJobByIDResponse]() +### func [ParseRetryJobByIDResponse]() ```go func ParseRetryJobByIDResponse(rsp *http.Response) (*RetryJobByIDResponse, error) @@ -4030,7 +4887,7 @@ func ParseRetryJobByIDResponse(rsp *http.Response) (*RetryJobByIDResponse, error ParseRetryJobByIDResponse parses an HTTP response from a RetryJobByIDWithResponse call -### func \(RetryJobByIDResponse\) [Status]() +### func \(RetryJobByIDResponse\) [Status]() ```go func (r RetryJobByIDResponse) Status() string @@ -4039,7 +4896,7 @@ func (r RetryJobByIDResponse) Status() string Status returns HTTPResponse.Status -### func \(RetryJobByIDResponse\) [StatusCode]() +### func \(RetryJobByIDResponse\) [StatusCode]() ```go func (r RetryJobByIDResponse) StatusCode() int @@ -4048,7 +4905,7 @@ func (r RetryJobByIDResponse) StatusCode() int StatusCode returns HTTPResponse.StatusCode -## type [RetryJobRequest]() +## type [RetryJobRequest]() RetryJobRequest defines model for RetryJobRequest. @@ -4060,7 +4917,7 @@ type RetryJobRequest struct { ``` -## type [RouteResponse]() +## type [RouteResponse]() RouteResponse A network routing table entry. @@ -4087,7 +4944,7 @@ type RouteResponse struct { ``` -## type [StatusResponse]() +## type [StatusResponse]() StatusResponse defines model for StatusResponse. @@ -4119,7 +4976,7 @@ type StatusResponse struct { ``` -## type [StreamInfo]() +## type [StreamInfo]() StreamInfo defines model for StreamInfo. @@ -4140,7 +4997,7 @@ type StreamInfo struct { ``` -## type [TimelineEvent]() +## type [TimelineEvent]() TimelineEvent defines model for TimelineEvent. @@ -4155,7 +5012,7 @@ type TimelineEvent struct { ``` -## type [UndrainAgentResponse]() +## type [UndrainAgentResponse]() @@ -4174,7 +5031,7 @@ type UndrainAgentResponse struct { ``` -### func [ParseUndrainAgentResponse]() +### func [ParseUndrainAgentResponse]() ```go func ParseUndrainAgentResponse(rsp *http.Response) (*UndrainAgentResponse, error) @@ -4183,7 +5040,7 @@ func ParseUndrainAgentResponse(rsp *http.Response) (*UndrainAgentResponse, error ParseUndrainAgentResponse parses an HTTP response from a UndrainAgentWithResponse call -### func \(UndrainAgentResponse\) [Status]() +### func \(UndrainAgentResponse\) [Status]() ```go func (r UndrainAgentResponse) Status() string @@ -4192,7 +5049,7 @@ func (r UndrainAgentResponse) Status() string Status returns HTTPResponse.Status -### func \(UndrainAgentResponse\) [StatusCode]() +### func \(UndrainAgentResponse\) [StatusCode]() ```go func (r UndrainAgentResponse) StatusCode() int @@ -4201,7 +5058,7 @@ func (r UndrainAgentResponse) StatusCode() int StatusCode returns HTTPResponse.StatusCode -## type [UptimeCollectionResponse]() +## type [UptimeCollectionResponse]() UptimeCollectionResponse defines model for UptimeCollectionResponse. @@ -4214,7 +5071,7 @@ type UptimeCollectionResponse struct { ``` -## type [UptimeResponse]() +## type [UptimeResponse]() UptimeResponse System uptime information. diff --git a/docs/gen/osapi.md b/docs/gen/osapi.md index 5ca893c..f41f635 100644 --- a/docs/gen/osapi.md +++ b/docs/gen/osapi.md @@ -61,6 +61,19 @@ resp, err := client.Node.Exec(ctx, osapi.ExecRequest{ - [type Disk](<#Disk>) - [type DiskResult](<#DiskResult>) - [type ExecRequest](<#ExecRequest>) +- [type FileDelete](<#FileDelete>) +- [type FileDeployOpts](<#FileDeployOpts>) +- [type FileDeployResult](<#FileDeployResult>) +- [type FileItem](<#FileItem>) +- [type FileList](<#FileList>) +- [type FileMetadata](<#FileMetadata>) +- [type FileService](<#FileService>) + - [func \(s \*FileService\) Delete\(ctx context.Context, name string\) \(\*Response\[FileDelete\], error\)](<#FileService.Delete>) + - [func \(s \*FileService\) Get\(ctx context.Context, name string\) \(\*Response\[FileMetadata\], error\)](<#FileService.Get>) + - [func \(s \*FileService\) List\(ctx context.Context\) \(\*Response\[FileList\], error\)](<#FileService.List>) + - [func \(s \*FileService\) Upload\(ctx context.Context, name string, content \[\]byte\) \(\*Response\[FileUpload\], error\)](<#FileService.Upload>) +- [type FileStatusResult](<#FileStatusResult>) +- [type FileUpload](<#FileUpload>) - [type HealthService](<#HealthService>) - [func \(s \*HealthService\) Liveness\(ctx context.Context\) \(\*Response\[HealthStatus\], error\)](<#HealthService.Liveness>) - [func \(s \*HealthService\) Ready\(ctx context.Context\) \(\*Response\[ReadyStatus\], error\)](<#HealthService.Ready>) @@ -92,6 +105,8 @@ resp, err := client.Node.Exec(ctx, osapi.ExecRequest{ - [type NodeService](<#NodeService>) - [func \(s \*NodeService\) Disk\(ctx context.Context, target string\) \(\*Response\[Collection\[DiskResult\]\], error\)](<#NodeService.Disk>) - [func \(s \*NodeService\) Exec\(ctx context.Context, req ExecRequest\) \(\*Response\[Collection\[CommandResult\]\], error\)](<#NodeService.Exec>) + - [func \(s \*NodeService\) FileDeploy\(ctx context.Context, req FileDeployOpts\) \(\*Response\[FileDeployResult\], error\)](<#NodeService.FileDeploy>) + - [func \(s \*NodeService\) FileStatus\(ctx context.Context, target string, path string\) \(\*Response\[FileStatusResult\], error\)](<#NodeService.FileStatus>) - [func \(s \*NodeService\) GetDNS\(ctx context.Context, target string, interfaceName string\) \(\*Response\[Collection\[DNSConfig\]\], error\)](<#NodeService.GetDNS>) - [func \(s \*NodeService\) Hostname\(ctx context.Context, target string\) \(\*Response\[Collection\[HostnameResult\]\], error\)](<#NodeService.Hostname>) - [func \(s \*NodeService\) Load\(ctx context.Context, target string\) \(\*Response\[Collection\[LoadResult\]\], error\)](<#NodeService.Load>) @@ -386,7 +401,7 @@ func (e *AuthError) Unwrap() error Unwrap returns the underlying APIError. -## type [Client]() +## type [Client]() Client is the top\-level OSAPI SDK client. Use New\(\) to create one. @@ -410,12 +425,15 @@ type Client struct { // Metrics provides Prometheus metrics access. Metrics *MetricsService + + // File provides file management operations (upload, list, get, delete). + File *FileService // contains filtered or unexported fields } ``` -### func [New]() +### func [New]() ```go func New(baseURL string, bearerToken string, opts ...Option) *Client @@ -604,6 +622,178 @@ type ExecRequest struct { } ``` + +## type [FileDelete]() + +FileDelete represents the result of a file deletion. + +```go +type FileDelete struct { + Name string + Deleted bool +} +``` + + +## type [FileDeployOpts]() + +FileDeployOpts contains parameters for file deployment. + +```go +type FileDeployOpts struct { + // ObjectName is the name of the file in the Object Store (required). + ObjectName string + + // Path is the destination path on the target filesystem (required). + Path string + + // ContentType is "raw" or "template" (required). + ContentType string + + // Mode is the file permission mode (e.g., "0644"). Optional. + Mode string + + // Owner is the file owner user. Optional. + Owner string + + // Group is the file owner group. Optional. + Group string + + // Vars are template variables when ContentType is "template". Optional. + Vars map[string]any + + // Target specifies the host: "_any", "_all", hostname, or + // label ("group:web"). + Target string +} +``` + + +## type [FileDeployResult]() + +FileDeployResult represents the result of a file deploy operation. + +```go +type FileDeployResult struct { + JobID string + Hostname string + Changed bool +} +``` + + +## type [FileItem]() + +FileItem represents file metadata in a list. + +```go +type FileItem struct { + Name string + SHA256 string + Size int +} +``` + + +## type [FileList]() + +FileList is a collection of files with total count. + +```go +type FileList struct { + Files []FileItem + Total int +} +``` + + +## type [FileMetadata]() + +FileMetadata represents metadata for a single file. + +```go +type FileMetadata struct { + Name string + SHA256 string + Size int +} +``` + + +## type [FileService]() + +FileService provides file management operations for the Object Store. + +```go +type FileService struct { + // contains filtered or unexported fields +} +``` + + +### func \(\*FileService\) [Delete]() + +```go +func (s *FileService) Delete(ctx context.Context, name string) (*Response[FileDelete], error) +``` + +Delete removes a file from the Object Store. + + +### func \(\*FileService\) [Get]() + +```go +func (s *FileService) Get(ctx context.Context, name string) (*Response[FileMetadata], error) +``` + +Get retrieves metadata for a specific file in the Object Store. + + +### func \(\*FileService\) [List]() + +```go +func (s *FileService) List(ctx context.Context) (*Response[FileList], error) +``` + +List retrieves all files stored in the Object Store. + + +### func \(\*FileService\) [Upload]() + +```go +func (s *FileService) Upload(ctx context.Context, name string, content []byte) (*Response[FileUpload], error) +``` + +Upload uploads a file to the Object Store. + + +## type [FileStatusResult]() + +FileStatusResult represents the result of a file status check. + +```go +type FileStatusResult struct { + JobID string + Hostname string + Path string + Status string + SHA256 string +} +``` + + +## type [FileUpload]() + +FileUpload represents a successfully uploaded file. + +```go +type FileUpload struct { + Name string + SHA256 string + Size int +} +``` + ## type [HealthService]() @@ -948,7 +1138,7 @@ type NodeService struct { ``` -### func \(\*NodeService\) [Disk]() +### func \(\*NodeService\) [Disk]() ```go func (s *NodeService) Disk(ctx context.Context, target string) (*Response[Collection[DiskResult]], error) @@ -957,7 +1147,7 @@ func (s *NodeService) Disk(ctx context.Context, target string) (*Response[Collec Disk retrieves disk usage information from the target host. -### func \(\*NodeService\) [Exec]() +### func \(\*NodeService\) [Exec]() ```go func (s *NodeService) Exec(ctx context.Context, req ExecRequest) (*Response[Collection[CommandResult]], error) @@ -965,8 +1155,26 @@ func (s *NodeService) Exec(ctx context.Context, req ExecRequest) (*Response[Coll Exec executes a command directly without a shell interpreter. + +### func \(\*NodeService\) [FileDeploy]() + +```go +func (s *NodeService) FileDeploy(ctx context.Context, req FileDeployOpts) (*Response[FileDeployResult], error) +``` + +FileDeploy deploys a file from the Object Store to the target host. + + +### func \(\*NodeService\) [FileStatus]() + +```go +func (s *NodeService) FileStatus(ctx context.Context, target string, path string) (*Response[FileStatusResult], error) +``` + +FileStatus checks the deployment status of a file on the target host. + -### func \(\*NodeService\) [GetDNS]() +### func \(\*NodeService\) [GetDNS]() ```go func (s *NodeService) GetDNS(ctx context.Context, target string, interfaceName string) (*Response[Collection[DNSConfig]], error) @@ -975,7 +1183,7 @@ func (s *NodeService) GetDNS(ctx context.Context, target string, interfaceName s GetDNS retrieves DNS configuration for a network interface on the target host. -### func \(\*NodeService\) [Hostname]() +### func \(\*NodeService\) [Hostname]() ```go func (s *NodeService) Hostname(ctx context.Context, target string) (*Response[Collection[HostnameResult]], error) @@ -984,7 +1192,7 @@ func (s *NodeService) Hostname(ctx context.Context, target string) (*Response[Co Hostname retrieves the hostname from the target host. -### func \(\*NodeService\) [Load]() +### func \(\*NodeService\) [Load]() ```go func (s *NodeService) Load(ctx context.Context, target string) (*Response[Collection[LoadResult]], error) @@ -993,7 +1201,7 @@ func (s *NodeService) Load(ctx context.Context, target string) (*Response[Collec Load retrieves load average information from the target host. -### func \(\*NodeService\) [Memory]() +### func \(\*NodeService\) [Memory]() ```go func (s *NodeService) Memory(ctx context.Context, target string) (*Response[Collection[MemoryResult]], error) @@ -1002,7 +1210,7 @@ func (s *NodeService) Memory(ctx context.Context, target string) (*Response[Coll Memory retrieves memory usage information from the target host. -### func \(\*NodeService\) [OS]() +### func \(\*NodeService\) [OS]() ```go func (s *NodeService) OS(ctx context.Context, target string) (*Response[Collection[OSInfoResult]], error) @@ -1011,7 +1219,7 @@ func (s *NodeService) OS(ctx context.Context, target string) (*Response[Collecti OS retrieves operating system information from the target host. -### func \(\*NodeService\) [Ping]() +### func \(\*NodeService\) [Ping]() ```go func (s *NodeService) Ping(ctx context.Context, target string, address string) (*Response[Collection[PingResult]], error) @@ -1020,7 +1228,7 @@ func (s *NodeService) Ping(ctx context.Context, target string, address string) ( Ping sends an ICMP ping to the specified address from the target host. -### func \(\*NodeService\) [Shell]() +### func \(\*NodeService\) [Shell]() ```go func (s *NodeService) Shell(ctx context.Context, req ShellRequest) (*Response[Collection[CommandResult]], error) @@ -1029,7 +1237,7 @@ func (s *NodeService) Shell(ctx context.Context, req ShellRequest) (*Response[Co Shell executes a command through /bin/sh \-c with shell features \(pipes, redirects, variable expansion\). -### func \(\*NodeService\) [Status]() +### func \(\*NodeService\) [Status]() ```go func (s *NodeService) Status(ctx context.Context, target string) (*Response[Collection[NodeStatus]], error) @@ -1038,7 +1246,7 @@ func (s *NodeService) Status(ctx context.Context, target string) (*Response[Coll Status retrieves node status \(OS info, disk, memory, load\) from the target host. -### func \(\*NodeService\) [UpdateDNS]() +### func \(\*NodeService\) [UpdateDNS]() ```go func (s *NodeService) UpdateDNS(ctx context.Context, target string, interfaceName string, servers []string, searchDomains []string) (*Response[Collection[DNSUpdateResult]], error) @@ -1047,7 +1255,7 @@ func (s *NodeService) UpdateDNS(ctx context.Context, target string, interfaceNam UpdateDNS updates DNS configuration for a network interface on the target host. -### func \(\*NodeService\) [Uptime]() +### func \(\*NodeService\) [Uptime]() ```go func (s *NodeService) Uptime(ctx context.Context, target string) (*Response[Collection[UptimeResult]], error) @@ -1118,7 +1326,7 @@ type OSInfoResult struct { ``` -## type [Option]() +## type [Option]() Option configures the Client. @@ -1127,7 +1335,7 @@ type Option func(*Client) ``` -### func [WithHTTPTransport]() +### func [WithHTTPTransport]() ```go func WithHTTPTransport(transport http.RoundTripper) Option @@ -1136,7 +1344,7 @@ func WithHTTPTransport(transport http.RoundTripper) Option WithHTTPTransport sets a custom base HTTP transport. -### func [WithLogger]() +### func [WithLogger]() ```go func WithLogger(logger *slog.Logger) Option @@ -1256,7 +1464,7 @@ func (e *ServerError) Unwrap() error Unwrap returns the underlying APIError. -## type [ShellRequest]() +## type [ShellRequest]() ShellRequest contains parameters for shell command execution. diff --git a/pkg/osapi/file.go b/pkg/osapi/file.go new file mode 100644 index 0000000..6ecff78 --- /dev/null +++ b/pkg/osapi/file.go @@ -0,0 +1,157 @@ +// Copyright (c) 2026 John Dewey + +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to +// deal in the Software without restriction, including without limitation the +// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: + +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. + +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +// DEALINGS IN THE SOFTWARE. + +package osapi + +import ( + "context" + "fmt" + + "github.com/osapi-io/osapi-sdk/pkg/osapi/gen" +) + +// FileService provides file management operations for the Object Store. +type FileService struct { + client *gen.ClientWithResponses +} + +// Upload uploads a file to the Object Store. +func (s *FileService) Upload( + ctx context.Context, + name string, + content []byte, +) (*Response[FileUpload], error) { + body := gen.FileUploadRequest{ + Name: name, + Content: content, + } + + resp, err := s.client.PostFileWithResponse(ctx, body) + if err != nil { + return nil, fmt.Errorf("upload file: %w", err) + } + + if err := checkError( + resp.StatusCode(), + resp.JSON400, + resp.JSON401, + resp.JSON403, + resp.JSON500, + ); err != nil { + return nil, err + } + + if resp.JSON201 == nil { + return nil, &UnexpectedStatusError{APIError{ + StatusCode: resp.StatusCode(), + Message: "nil response body", + }} + } + + return NewResponse(fileUploadFromGen(resp.JSON201), resp.Body), nil +} + +// List retrieves all files stored in the Object Store. +func (s *FileService) List( + ctx context.Context, +) (*Response[FileList], error) { + resp, err := s.client.GetFilesWithResponse(ctx) + if err != nil { + return nil, fmt.Errorf("list files: %w", err) + } + + if err := checkError( + resp.StatusCode(), + resp.JSON401, + resp.JSON403, + resp.JSON500, + ); err != nil { + return nil, err + } + + if resp.JSON200 == nil { + return nil, &UnexpectedStatusError{APIError{ + StatusCode: resp.StatusCode(), + Message: "nil response body", + }} + } + + return NewResponse(fileListFromGen(resp.JSON200), resp.Body), nil +} + +// Get retrieves metadata for a specific file in the Object Store. +func (s *FileService) Get( + ctx context.Context, + name string, +) (*Response[FileMetadata], error) { + resp, err := s.client.GetFileByNameWithResponse(ctx, name) + if err != nil { + return nil, fmt.Errorf("get file %s: %w", name, err) + } + + if err := checkError( + resp.StatusCode(), + resp.JSON401, + resp.JSON403, + resp.JSON404, + resp.JSON500, + ); err != nil { + return nil, err + } + + if resp.JSON200 == nil { + return nil, &UnexpectedStatusError{APIError{ + StatusCode: resp.StatusCode(), + Message: "nil response body", + }} + } + + return NewResponse(fileMetadataFromGen(resp.JSON200), resp.Body), nil +} + +// Delete removes a file from the Object Store. +func (s *FileService) Delete( + ctx context.Context, + name string, +) (*Response[FileDelete], error) { + resp, err := s.client.DeleteFileByNameWithResponse(ctx, name) + if err != nil { + return nil, fmt.Errorf("delete file %s: %w", name, err) + } + + if err := checkError( + resp.StatusCode(), + resp.JSON401, + resp.JSON403, + resp.JSON404, + resp.JSON500, + ); err != nil { + return nil, err + } + + if resp.JSON200 == nil { + return nil, &UnexpectedStatusError{APIError{ + StatusCode: resp.StatusCode(), + Message: "nil response body", + }} + } + + return NewResponse(fileDeleteFromGen(resp.JSON200), resp.Body), nil +} diff --git a/pkg/osapi/file_public_test.go b/pkg/osapi/file_public_test.go new file mode 100644 index 0000000..cd4df55 --- /dev/null +++ b/pkg/osapi/file_public_test.go @@ -0,0 +1,489 @@ +// Copyright (c) 2026 John Dewey + +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to +// deal in the Software without restriction, including without limitation the +// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: + +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. + +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +// DEALINGS IN THE SOFTWARE. + +package osapi_test + +import ( + "context" + "errors" + "log/slog" + "net/http" + "net/http/httptest" + "testing" + + "github.com/stretchr/testify/suite" + + "github.com/osapi-io/osapi-sdk/pkg/osapi" +) + +type FilePublicTestSuite struct { + suite.Suite + + ctx context.Context +} + +func (suite *FilePublicTestSuite) SetupTest() { + suite.ctx = context.Background() +} + +func (suite *FilePublicTestSuite) TestUpload() { + tests := []struct { + name string + handler http.HandlerFunc + serverURL string + validateFunc func(*osapi.Response[osapi.FileUpload], error) + }{ + { + name: "when uploading file returns result", + handler: func(w http.ResponseWriter, _ *http.Request) { + w.Header().Set("Content-Type", "application/json") + w.WriteHeader(http.StatusCreated) + _, _ = w.Write( + []byte(`{"name":"nginx.conf","sha256":"abc123","size":1024}`), + ) + }, + validateFunc: func(resp *osapi.Response[osapi.FileUpload], err error) { + suite.NoError(err) + suite.NotNil(resp) + suite.Equal("nginx.conf", resp.Data.Name) + suite.Equal("abc123", resp.Data.SHA256) + suite.Equal(1024, resp.Data.Size) + }, + }, + { + name: "when server returns 400 returns ValidationError", + handler: func(w http.ResponseWriter, _ *http.Request) { + w.Header().Set("Content-Type", "application/json") + w.WriteHeader(http.StatusBadRequest) + _, _ = w.Write([]byte(`{"error":"name is required"}`)) + }, + validateFunc: func(resp *osapi.Response[osapi.FileUpload], err error) { + suite.Error(err) + suite.Nil(resp) + + var target *osapi.ValidationError + suite.True(errors.As(err, &target)) + suite.Equal(http.StatusBadRequest, target.StatusCode) + }, + }, + { + name: "when server returns 403 returns AuthError", + handler: func(w http.ResponseWriter, _ *http.Request) { + w.Header().Set("Content-Type", "application/json") + w.WriteHeader(http.StatusForbidden) + _, _ = w.Write([]byte(`{"error":"forbidden"}`)) + }, + validateFunc: func(resp *osapi.Response[osapi.FileUpload], err error) { + suite.Error(err) + suite.Nil(resp) + + var target *osapi.AuthError + suite.True(errors.As(err, &target)) + suite.Equal(http.StatusForbidden, target.StatusCode) + }, + }, + { + name: "when client HTTP call fails returns error", + serverURL: "http://127.0.0.1:0", + validateFunc: func(resp *osapi.Response[osapi.FileUpload], err error) { + suite.Error(err) + suite.Nil(resp) + suite.Contains(err.Error(), "upload file") + }, + }, + { + name: "when server returns 201 with no JSON body returns UnexpectedStatusError", + handler: func(w http.ResponseWriter, _ *http.Request) { + w.WriteHeader(http.StatusCreated) + }, + validateFunc: func(resp *osapi.Response[osapi.FileUpload], err error) { + suite.Error(err) + suite.Nil(resp) + + var target *osapi.UnexpectedStatusError + suite.True(errors.As(err, &target)) + suite.Equal(http.StatusCreated, target.StatusCode) + suite.Equal("nil response body", target.Message) + }, + }, + } + + for _, tc := range tests { + suite.Run(tc.name, func() { + var ( + serverURL string + cleanup func() + ) + + if tc.serverURL != "" { + serverURL = tc.serverURL + cleanup = func() {} + } else { + server := httptest.NewServer(tc.handler) + serverURL = server.URL + cleanup = server.Close + } + defer cleanup() + + sut := osapi.New( + serverURL, + "test-token", + osapi.WithLogger(slog.Default()), + ) + + resp, err := sut.File.Upload(suite.ctx, "nginx.conf", []byte("content")) + tc.validateFunc(resp, err) + }) + } +} + +func (suite *FilePublicTestSuite) TestList() { + tests := []struct { + name string + handler http.HandlerFunc + serverURL string + validateFunc func(*osapi.Response[osapi.FileList], error) + }{ + { + name: "when listing files returns results", + handler: func(w http.ResponseWriter, _ *http.Request) { + w.Header().Set("Content-Type", "application/json") + w.WriteHeader(http.StatusOK) + _, _ = w.Write( + []byte( + `{"files":[{"name":"file1.txt","sha256":"aaa","size":100}],"total":1}`, + ), + ) + }, + validateFunc: func(resp *osapi.Response[osapi.FileList], err error) { + suite.NoError(err) + suite.NotNil(resp) + suite.Len(resp.Data.Files, 1) + suite.Equal(1, resp.Data.Total) + suite.Equal("file1.txt", resp.Data.Files[0].Name) + }, + }, + { + name: "when server returns 403 returns AuthError", + handler: func(w http.ResponseWriter, _ *http.Request) { + w.Header().Set("Content-Type", "application/json") + w.WriteHeader(http.StatusForbidden) + _, _ = w.Write([]byte(`{"error":"forbidden"}`)) + }, + validateFunc: func(resp *osapi.Response[osapi.FileList], err error) { + suite.Error(err) + suite.Nil(resp) + + var target *osapi.AuthError + suite.True(errors.As(err, &target)) + suite.Equal(http.StatusForbidden, target.StatusCode) + }, + }, + { + name: "when client HTTP call fails returns error", + serverURL: "http://127.0.0.1:0", + validateFunc: func(resp *osapi.Response[osapi.FileList], err error) { + suite.Error(err) + suite.Nil(resp) + suite.Contains(err.Error(), "list files") + }, + }, + { + name: "when server returns 200 with no JSON body returns UnexpectedStatusError", + handler: func(w http.ResponseWriter, _ *http.Request) { + w.WriteHeader(http.StatusOK) + }, + validateFunc: func(resp *osapi.Response[osapi.FileList], err error) { + suite.Error(err) + suite.Nil(resp) + + var target *osapi.UnexpectedStatusError + suite.True(errors.As(err, &target)) + suite.Equal(http.StatusOK, target.StatusCode) + suite.Equal("nil response body", target.Message) + }, + }, + } + + for _, tc := range tests { + suite.Run(tc.name, func() { + var ( + serverURL string + cleanup func() + ) + + if tc.serverURL != "" { + serverURL = tc.serverURL + cleanup = func() {} + } else { + server := httptest.NewServer(tc.handler) + serverURL = server.URL + cleanup = server.Close + } + defer cleanup() + + sut := osapi.New( + serverURL, + "test-token", + osapi.WithLogger(slog.Default()), + ) + + resp, err := sut.File.List(suite.ctx) + tc.validateFunc(resp, err) + }) + } +} + +func (suite *FilePublicTestSuite) TestGet() { + tests := []struct { + name string + handler http.HandlerFunc + serverURL string + fileName string + validateFunc func(*osapi.Response[osapi.FileMetadata], error) + }{ + { + name: "when getting file returns metadata", + fileName: "nginx.conf", + handler: func(w http.ResponseWriter, _ *http.Request) { + w.Header().Set("Content-Type", "application/json") + w.WriteHeader(http.StatusOK) + _, _ = w.Write( + []byte(`{"name":"nginx.conf","sha256":"def456","size":512}`), + ) + }, + validateFunc: func(resp *osapi.Response[osapi.FileMetadata], err error) { + suite.NoError(err) + suite.NotNil(resp) + suite.Equal("nginx.conf", resp.Data.Name) + suite.Equal("def456", resp.Data.SHA256) + suite.Equal(512, resp.Data.Size) + }, + }, + { + name: "when server returns 404 returns NotFoundError", + fileName: "missing.conf", + handler: func(w http.ResponseWriter, _ *http.Request) { + w.Header().Set("Content-Type", "application/json") + w.WriteHeader(http.StatusNotFound) + _, _ = w.Write([]byte(`{"error":"file not found"}`)) + }, + validateFunc: func(resp *osapi.Response[osapi.FileMetadata], err error) { + suite.Error(err) + suite.Nil(resp) + + var target *osapi.NotFoundError + suite.True(errors.As(err, &target)) + suite.Equal(http.StatusNotFound, target.StatusCode) + }, + }, + { + name: "when server returns 403 returns AuthError", + fileName: "nginx.conf", + handler: func(w http.ResponseWriter, _ *http.Request) { + w.Header().Set("Content-Type", "application/json") + w.WriteHeader(http.StatusForbidden) + _, _ = w.Write([]byte(`{"error":"forbidden"}`)) + }, + validateFunc: func(resp *osapi.Response[osapi.FileMetadata], err error) { + suite.Error(err) + suite.Nil(resp) + + var target *osapi.AuthError + suite.True(errors.As(err, &target)) + suite.Equal(http.StatusForbidden, target.StatusCode) + }, + }, + { + name: "when client HTTP call fails returns error", + fileName: "nginx.conf", + serverURL: "http://127.0.0.1:0", + validateFunc: func(resp *osapi.Response[osapi.FileMetadata], err error) { + suite.Error(err) + suite.Nil(resp) + suite.Contains(err.Error(), "get file nginx.conf") + }, + }, + { + name: "when server returns 200 with no JSON body returns UnexpectedStatusError", + fileName: "nginx.conf", + handler: func(w http.ResponseWriter, _ *http.Request) { + w.WriteHeader(http.StatusOK) + }, + validateFunc: func(resp *osapi.Response[osapi.FileMetadata], err error) { + suite.Error(err) + suite.Nil(resp) + + var target *osapi.UnexpectedStatusError + suite.True(errors.As(err, &target)) + suite.Equal(http.StatusOK, target.StatusCode) + suite.Equal("nil response body", target.Message) + }, + }, + } + + for _, tc := range tests { + suite.Run(tc.name, func() { + var ( + serverURL string + cleanup func() + ) + + if tc.serverURL != "" { + serverURL = tc.serverURL + cleanup = func() {} + } else { + server := httptest.NewServer(tc.handler) + serverURL = server.URL + cleanup = server.Close + } + defer cleanup() + + sut := osapi.New( + serverURL, + "test-token", + osapi.WithLogger(slog.Default()), + ) + + resp, err := sut.File.Get(suite.ctx, tc.fileName) + tc.validateFunc(resp, err) + }) + } +} + +func (suite *FilePublicTestSuite) TestDelete() { + tests := []struct { + name string + handler http.HandlerFunc + serverURL string + fileName string + validateFunc func(*osapi.Response[osapi.FileDelete], error) + }{ + { + name: "when deleting file returns result", + fileName: "old.conf", + handler: func(w http.ResponseWriter, _ *http.Request) { + w.Header().Set("Content-Type", "application/json") + w.WriteHeader(http.StatusOK) + _, _ = w.Write( + []byte(`{"name":"old.conf","deleted":true}`), + ) + }, + validateFunc: func(resp *osapi.Response[osapi.FileDelete], err error) { + suite.NoError(err) + suite.NotNil(resp) + suite.Equal("old.conf", resp.Data.Name) + suite.True(resp.Data.Deleted) + }, + }, + { + name: "when server returns 404 returns NotFoundError", + fileName: "missing.conf", + handler: func(w http.ResponseWriter, _ *http.Request) { + w.Header().Set("Content-Type", "application/json") + w.WriteHeader(http.StatusNotFound) + _, _ = w.Write([]byte(`{"error":"file not found"}`)) + }, + validateFunc: func(resp *osapi.Response[osapi.FileDelete], err error) { + suite.Error(err) + suite.Nil(resp) + + var target *osapi.NotFoundError + suite.True(errors.As(err, &target)) + suite.Equal(http.StatusNotFound, target.StatusCode) + }, + }, + { + name: "when server returns 403 returns AuthError", + fileName: "old.conf", + handler: func(w http.ResponseWriter, _ *http.Request) { + w.Header().Set("Content-Type", "application/json") + w.WriteHeader(http.StatusForbidden) + _, _ = w.Write([]byte(`{"error":"forbidden"}`)) + }, + validateFunc: func(resp *osapi.Response[osapi.FileDelete], err error) { + suite.Error(err) + suite.Nil(resp) + + var target *osapi.AuthError + suite.True(errors.As(err, &target)) + suite.Equal(http.StatusForbidden, target.StatusCode) + }, + }, + { + name: "when client HTTP call fails returns error", + fileName: "old.conf", + serverURL: "http://127.0.0.1:0", + validateFunc: func(resp *osapi.Response[osapi.FileDelete], err error) { + suite.Error(err) + suite.Nil(resp) + suite.Contains(err.Error(), "delete file old.conf") + }, + }, + { + name: "when server returns 200 with no JSON body returns UnexpectedStatusError", + fileName: "old.conf", + handler: func(w http.ResponseWriter, _ *http.Request) { + w.WriteHeader(http.StatusOK) + }, + validateFunc: func(resp *osapi.Response[osapi.FileDelete], err error) { + suite.Error(err) + suite.Nil(resp) + + var target *osapi.UnexpectedStatusError + suite.True(errors.As(err, &target)) + suite.Equal(http.StatusOK, target.StatusCode) + suite.Equal("nil response body", target.Message) + }, + }, + } + + for _, tc := range tests { + suite.Run(tc.name, func() { + var ( + serverURL string + cleanup func() + ) + + if tc.serverURL != "" { + serverURL = tc.serverURL + cleanup = func() {} + } else { + server := httptest.NewServer(tc.handler) + serverURL = server.URL + cleanup = server.Close + } + defer cleanup() + + sut := osapi.New( + serverURL, + "test-token", + osapi.WithLogger(slog.Default()), + ) + + resp, err := sut.File.Delete(suite.ctx, tc.fileName) + tc.validateFunc(resp, err) + }) + } +} + +func TestFilePublicTestSuite(t *testing.T) { + suite.Run(t, new(FilePublicTestSuite)) +} diff --git a/pkg/osapi/file_types.go b/pkg/osapi/file_types.go new file mode 100644 index 0000000..935d166 --- /dev/null +++ b/pkg/osapi/file_types.go @@ -0,0 +1,152 @@ +// Copyright (c) 2026 John Dewey + +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to +// deal in the Software without restriction, including without limitation the +// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: + +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. + +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +// DEALINGS IN THE SOFTWARE. + +package osapi + +import "github.com/osapi-io/osapi-sdk/pkg/osapi/gen" + +// FileUpload represents a successfully uploaded file. +type FileUpload struct { + Name string + SHA256 string + Size int +} + +// FileItem represents file metadata in a list. +type FileItem struct { + Name string + SHA256 string + Size int +} + +// FileList is a collection of files with total count. +type FileList struct { + Files []FileItem + Total int +} + +// FileMetadata represents metadata for a single file. +type FileMetadata struct { + Name string + SHA256 string + Size int +} + +// FileDelete represents the result of a file deletion. +type FileDelete struct { + Name string + Deleted bool +} + +// FileDeployResult represents the result of a file deploy operation. +type FileDeployResult struct { + JobID string + Hostname string + Changed bool +} + +// FileStatusResult represents the result of a file status check. +type FileStatusResult struct { + JobID string + Hostname string + Path string + Status string + SHA256 string +} + +// fileUploadFromGen converts a gen.FileUploadResponse to a FileUpload. +func fileUploadFromGen( + g *gen.FileUploadResponse, +) FileUpload { + return FileUpload{ + Name: g.Name, + SHA256: g.Sha256, + Size: g.Size, + } +} + +// fileListFromGen converts a gen.FileListResponse to a FileList. +func fileListFromGen( + g *gen.FileListResponse, +) FileList { + files := make([]FileItem, 0, len(g.Files)) + for _, f := range g.Files { + files = append(files, FileItem{ + Name: f.Name, + SHA256: f.Sha256, + Size: f.Size, + }) + } + + return FileList{ + Files: files, + Total: g.Total, + } +} + +// fileMetadataFromGen converts a gen.FileInfoResponse to a FileMetadata. +func fileMetadataFromGen( + g *gen.FileInfoResponse, +) FileMetadata { + return FileMetadata{ + Name: g.Name, + SHA256: g.Sha256, + Size: g.Size, + } +} + +// fileDeleteFromGen converts a gen.FileDeleteResponse to a FileDelete. +func fileDeleteFromGen( + g *gen.FileDeleteResponse, +) FileDelete { + return FileDelete{ + Name: g.Name, + Deleted: g.Deleted, + } +} + +// fileDeployResultFromGen converts a gen.FileDeployResponse to a FileDeployResult. +func fileDeployResultFromGen( + g *gen.FileDeployResponse, +) FileDeployResult { + return FileDeployResult{ + JobID: g.JobId, + Hostname: g.Hostname, + Changed: g.Changed, + } +} + +// fileStatusResultFromGen converts a gen.FileStatusResponse to a FileStatusResult. +func fileStatusResultFromGen( + g *gen.FileStatusResponse, +) FileStatusResult { + r := FileStatusResult{ + JobID: g.JobId, + Hostname: g.Hostname, + Path: g.Path, + Status: g.Status, + } + + if g.Sha256 != nil { + r.SHA256 = *g.Sha256 + } + + return r +} diff --git a/pkg/osapi/file_types_test.go b/pkg/osapi/file_types_test.go new file mode 100644 index 0000000..99a924b --- /dev/null +++ b/pkg/osapi/file_types_test.go @@ -0,0 +1,256 @@ +// Copyright (c) 2026 John Dewey + +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to +// deal in the Software without restriction, including without limitation the +// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: + +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. + +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +// DEALINGS IN THE SOFTWARE. + +package osapi + +import ( + "testing" + + "github.com/stretchr/testify/suite" + + "github.com/osapi-io/osapi-sdk/pkg/osapi/gen" +) + +type FileTypesTestSuite struct { + suite.Suite +} + +func (suite *FileTypesTestSuite) TestFileUploadFromGen() { + tests := []struct { + name string + input *gen.FileUploadResponse + validateFunc func(FileUpload) + }{ + { + name: "when all fields populated returns FileUpload", + input: &gen.FileUploadResponse{ + Name: "nginx.conf", + Sha256: "abc123", + Size: 1024, + }, + validateFunc: func(result FileUpload) { + suite.Equal("nginx.conf", result.Name) + suite.Equal("abc123", result.SHA256) + suite.Equal(1024, result.Size) + }, + }, + } + + for _, tc := range tests { + suite.Run(tc.name, func() { + result := fileUploadFromGen(tc.input) + tc.validateFunc(result) + }) + } +} + +func (suite *FileTypesTestSuite) TestFileListFromGen() { + tests := []struct { + name string + input *gen.FileListResponse + validateFunc func(FileList) + }{ + { + name: "when files exist returns FileList with items", + input: &gen.FileListResponse{ + Files: []gen.FileInfo{ + {Name: "file1.txt", Sha256: "aaa", Size: 100}, + {Name: "file2.txt", Sha256: "bbb", Size: 200}, + }, + Total: 2, + }, + validateFunc: func(result FileList) { + suite.Len(result.Files, 2) + suite.Equal(2, result.Total) + suite.Equal("file1.txt", result.Files[0].Name) + suite.Equal("aaa", result.Files[0].SHA256) + suite.Equal(100, result.Files[0].Size) + suite.Equal("file2.txt", result.Files[1].Name) + }, + }, + { + name: "when no files returns empty FileList", + input: &gen.FileListResponse{ + Files: []gen.FileInfo{}, + Total: 0, + }, + validateFunc: func(result FileList) { + suite.Empty(result.Files) + suite.Equal(0, result.Total) + }, + }, + } + + for _, tc := range tests { + suite.Run(tc.name, func() { + result := fileListFromGen(tc.input) + tc.validateFunc(result) + }) + } +} + +func (suite *FileTypesTestSuite) TestFileMetadataFromGen() { + tests := []struct { + name string + input *gen.FileInfoResponse + validateFunc func(FileMetadata) + }{ + { + name: "when all fields populated returns FileMetadata", + input: &gen.FileInfoResponse{ + Name: "config.yaml", + Sha256: "def456", + Size: 512, + }, + validateFunc: func(result FileMetadata) { + suite.Equal("config.yaml", result.Name) + suite.Equal("def456", result.SHA256) + suite.Equal(512, result.Size) + }, + }, + } + + for _, tc := range tests { + suite.Run(tc.name, func() { + result := fileMetadataFromGen(tc.input) + tc.validateFunc(result) + }) + } +} + +func (suite *FileTypesTestSuite) TestFileDeleteFromGen() { + tests := []struct { + name string + input *gen.FileDeleteResponse + validateFunc func(FileDelete) + }{ + { + name: "when deleted returns FileDelete with true", + input: &gen.FileDeleteResponse{ + Name: "old.conf", + Deleted: true, + }, + validateFunc: func(result FileDelete) { + suite.Equal("old.conf", result.Name) + suite.True(result.Deleted) + }, + }, + } + + for _, tc := range tests { + suite.Run(tc.name, func() { + result := fileDeleteFromGen(tc.input) + tc.validateFunc(result) + }) + } +} + +func (suite *FileTypesTestSuite) TestFileDeployResultFromGen() { + tests := []struct { + name string + input *gen.FileDeployResponse + validateFunc func(FileDeployResult) + }{ + { + name: "when all fields populated returns FileDeployResult", + input: &gen.FileDeployResponse{ + JobId: "job-123", + Hostname: "web-01", + Changed: true, + }, + validateFunc: func(result FileDeployResult) { + suite.Equal("job-123", result.JobID) + suite.Equal("web-01", result.Hostname) + suite.True(result.Changed) + }, + }, + { + name: "when not changed returns false", + input: &gen.FileDeployResponse{ + JobId: "job-456", + Hostname: "web-02", + Changed: false, + }, + validateFunc: func(result FileDeployResult) { + suite.False(result.Changed) + }, + }, + } + + for _, tc := range tests { + suite.Run(tc.name, func() { + result := fileDeployResultFromGen(tc.input) + tc.validateFunc(result) + }) + } +} + +func (suite *FileTypesTestSuite) TestFileStatusResultFromGen() { + sha := "abc123" + + tests := []struct { + name string + input *gen.FileStatusResponse + validateFunc func(FileStatusResult) + }{ + { + name: "when all fields populated returns FileStatusResult", + input: &gen.FileStatusResponse{ + JobId: "job-789", + Hostname: "web-03", + Path: "/etc/nginx/nginx.conf", + Status: "in-sync", + Sha256: &sha, + }, + validateFunc: func(result FileStatusResult) { + suite.Equal("job-789", result.JobID) + suite.Equal("web-03", result.Hostname) + suite.Equal("/etc/nginx/nginx.conf", result.Path) + suite.Equal("in-sync", result.Status) + suite.Equal("abc123", result.SHA256) + }, + }, + { + name: "when sha256 is nil returns empty string", + input: &gen.FileStatusResponse{ + JobId: "job-000", + Hostname: "web-04", + Path: "/etc/missing.conf", + Status: "missing", + Sha256: nil, + }, + validateFunc: func(result FileStatusResult) { + suite.Equal("missing", result.Status) + suite.Empty(result.SHA256) + }, + }, + } + + for _, tc := range tests { + suite.Run(tc.name, func() { + result := fileStatusResultFromGen(tc.input) + tc.validateFunc(result) + }) + } +} + +func TestFileTypesTestSuite(t *testing.T) { + suite.Run(t, new(FileTypesTestSuite)) +} diff --git a/pkg/osapi/gen/api.yaml b/pkg/osapi/gen/api.yaml index 8c0b59d..3fe4e38 100644 --- a/pkg/osapi/gen/api.yaml +++ b/pkg/osapi/gen/api.yaml @@ -33,6 +33,9 @@ tags: - name: Node_Management_API_command_operations x-displayName: Node/Command description: Command execution on a target node. + - name: File_Management_API_file_operations + x-displayName: File + description: Object Store file management operations. paths: /agent: servers: [] @@ -1390,6 +1393,273 @@ paths: application/json: schema: $ref: '#/components/schemas/ErrorResponse' + /node/{hostname}/file/deploy: + servers: [] + post: + operationId: PostNodeFileDeploy + summary: Deploy a file from Object Store to the host + tags: + - Node_Management_API_node_operations + security: + - BearerAuth: + - 'file:write' + parameters: + - $ref: '#/components/parameters/Hostname' + requestBody: + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/FileDeployRequest' + responses: + '202': + description: File deploy job accepted. + content: + application/json: + schema: + $ref: '#/components/schemas/FileDeployResponse' + '400': + description: Invalid input. + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse' + '401': + description: Unauthorized. + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse' + '403': + description: Forbidden. + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse' + '500': + description: Internal error. + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse' + /node/{hostname}/file/status: + servers: [] + post: + operationId: PostNodeFileStatus + summary: Check deployment status of a file on the host + tags: + - Node_Management_API_node_operations + security: + - BearerAuth: + - 'file:read' + parameters: + - $ref: '#/components/parameters/Hostname' + requestBody: + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/FileStatusRequest' + responses: + '200': + description: File status. + content: + application/json: + schema: + $ref: '#/components/schemas/FileStatusResponse' + '400': + description: Invalid input. + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse' + '401': + description: Unauthorized. + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse' + '403': + description: Forbidden. + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse' + '500': + description: Internal error. + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse' + /file: + servers: [] + post: + summary: Upload a file + description: Upload a file to the Object Store. + tags: + - File_Management_API_file_operations + operationId: PostFile + security: + - BearerAuth: + - file:write + requestBody: + description: The file to upload. + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/FileUploadRequest' + responses: + '201': + description: File uploaded successfully. + content: + application/json: + schema: + $ref: '#/components/schemas/FileUploadResponse' + '400': + description: Invalid request payload. + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse' + '401': + description: Unauthorized - API key required + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse' + '403': + description: Forbidden - Insufficient permissions + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse' + '500': + description: Error uploading file. + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse' + get: + summary: List stored files + description: List all files stored in the Object Store. + tags: + - File_Management_API_file_operations + operationId: GetFiles + security: + - BearerAuth: + - file:read + responses: + '200': + description: List of stored files. + content: + application/json: + schema: + $ref: '#/components/schemas/FileListResponse' + '401': + description: Unauthorized - API key required + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse' + '403': + description: Forbidden - Insufficient permissions + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse' + '500': + description: Error listing files. + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse' + /file/{name}: + servers: [] + get: + summary: Get file metadata + description: Get metadata for a specific file in the Object Store. + tags: + - File_Management_API_file_operations + operationId: GetFileByName + security: + - BearerAuth: + - file:read + parameters: + - $ref: '#/components/parameters/FileName' + responses: + '200': + description: File metadata. + content: + application/json: + schema: + $ref: '#/components/schemas/FileInfoResponse' + '401': + description: Unauthorized - API key required + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse' + '403': + description: Forbidden - Insufficient permissions + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse' + '404': + description: File not found. + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse' + '500': + description: Error retrieving file metadata. + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse' + delete: + summary: Delete a file + description: Delete a file from the Object Store. + tags: + - File_Management_API_file_operations + operationId: DeleteFileByName + security: + - BearerAuth: + - file:write + parameters: + - $ref: '#/components/parameters/FileName' + responses: + '200': + description: File deleted successfully. + content: + application/json: + schema: + $ref: '#/components/schemas/FileDeleteResponse' + '401': + description: Unauthorized - API key required + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse' + '403': + description: Forbidden - Insufficient permissions + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse' + '404': + description: File not found. + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse' + '500': + description: Error deleting file. + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse' components: securitySchemes: BearerAuth: @@ -2634,6 +2904,198 @@ components: $ref: '#/components/schemas/CommandResultItem' required: - results + FileUploadRequest: + type: object + properties: + name: + type: string + description: The name of the file. + example: nginx.conf + x-oapi-codegen-extra-tags: + validate: required,min=1,max=255 + content: + type: string + format: byte + description: Base64-encoded file content. + example: c2VydmVyIHsgbGlzdGVuIDgwOyB9 + x-oapi-codegen-extra-tags: + validate: required + required: + - name + - content + FileInfo: + type: object + properties: + name: + type: string + description: The name of the file. + example: nginx.conf + sha256: + type: string + description: SHA-256 hash of the file content. + example: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 + size: + type: integer + description: File size in bytes. + example: 1024 + required: + - name + - sha256 + - size + FileUploadResponse: + type: object + properties: + name: + type: string + description: The name of the uploaded file. + example: nginx.conf + sha256: + type: string + description: SHA-256 hash of the file content. + example: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 + size: + type: integer + description: File size in bytes. + example: 1024 + required: + - name + - sha256 + - size + FileListResponse: + type: object + properties: + files: + type: array + items: + $ref: '#/components/schemas/FileInfo' + description: List of stored files. + total: + type: integer + description: Total number of files. + example: 5 + required: + - files + - total + FileInfoResponse: + type: object + properties: + name: + type: string + description: The name of the file. + example: nginx.conf + sha256: + type: string + description: SHA-256 hash of the file content. + example: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 + size: + type: integer + description: File size in bytes. + example: 1024 + required: + - name + - sha256 + - size + FileDeleteResponse: + type: object + properties: + name: + type: string + description: The name of the deleted file. + example: nginx.conf + deleted: + type: boolean + description: Whether the file was deleted. + example: true + required: + - name + - deleted + FileDeployRequest: + type: object + properties: + object_name: + type: string + description: Name of the file in the Object Store. + x-oapi-codegen-extra-tags: + validate: required,min=1,max=255 + path: + type: string + description: Destination path on the target filesystem. + x-oapi-codegen-extra-tags: + validate: required,min=1 + mode: + type: string + description: File permission mode (e.g., "0644"). + owner: + type: string + description: File owner user. + group: + type: string + description: File owner group. + content_type: + type: string + description: Content type — "raw" or "template". + enum: + - raw + - template + x-oapi-codegen-extra-tags: + validate: required,oneof=raw template + vars: + type: object + description: Template variables when content_type is "template". + additionalProperties: true + required: + - object_name + - path + - content_type + FileDeployResponse: + type: object + properties: + job_id: + type: string + description: The ID of the created job. + hostname: + type: string + description: The agent that processed the job. + changed: + type: boolean + description: Whether the file was actually written. + required: + - job_id + - hostname + - changed + FileStatusRequest: + type: object + properties: + path: + type: string + description: Filesystem path to check. + x-oapi-codegen-extra-tags: + validate: required,min=1 + required: + - path + FileStatusResponse: + type: object + properties: + job_id: + type: string + description: The ID of the created job. + hostname: + type: string + description: The agent that processed the job. + path: + type: string + description: The filesystem path. + status: + type: string + description: File state — "in-sync", "drifted", or "missing". + sha256: + type: string + description: Current SHA-256 of the file on disk. + required: + - job_id + - hostname + - path + - status parameters: Hostname: name: hostname @@ -2647,6 +3109,18 @@ components: schema: type: string minLength: 1 + FileName: + name: name + in: path + required: true + description: > + The name of the file in the Object Store. + x-oapi-codegen-extra-tags: + validate: required,min=1,max=255 + schema: + type: string + minLength: 1 + maxLength: 255 x-tagGroups: - name: Agent Management API tags: @@ -2663,6 +3137,9 @@ x-tagGroups: - name: Job Management API tags: - Job_Management_API_job_operations + - name: File Management API + tags: + - File_Management_API_file_operations - name: Node Management API tags: - Node_Management_API_node_operations diff --git a/pkg/osapi/gen/client.gen.go b/pkg/osapi/gen/client.gen.go index 4304888..b9b9b25 100644 --- a/pkg/osapi/gen/client.gen.go +++ b/pkg/osapi/gen/client.gen.go @@ -41,6 +41,12 @@ const ( DNSUpdateResultItemStatusOk DNSUpdateResultItemStatus = "ok" ) +// Defines values for FileDeployRequestContentType. +const ( + Raw FileDeployRequestContentType = "raw" + Template FileDeployRequestContentType = "template" +) + // Defines values for NetworkInterfaceResponseFamily. const ( Dual NetworkInterfaceResponseFamily = "dual" @@ -416,6 +422,132 @@ type ErrorResponse struct { Error *string `json:"error,omitempty"` } +// FileDeleteResponse defines model for FileDeleteResponse. +type FileDeleteResponse struct { + // Deleted Whether the file was deleted. + Deleted bool `json:"deleted"` + + // Name The name of the deleted file. + Name string `json:"name"` +} + +// FileDeployRequest defines model for FileDeployRequest. +type FileDeployRequest struct { + // ContentType Content type — "raw" or "template". + ContentType FileDeployRequestContentType `json:"content_type" validate:"required,oneof=raw template"` + + // Group File owner group. + Group *string `json:"group,omitempty"` + + // Mode File permission mode (e.g., "0644"). + Mode *string `json:"mode,omitempty"` + + // ObjectName Name of the file in the Object Store. + ObjectName string `json:"object_name" validate:"required,min=1,max=255"` + + // Owner File owner user. + Owner *string `json:"owner,omitempty"` + + // Path Destination path on the target filesystem. + Path string `json:"path" validate:"required,min=1"` + + // Vars Template variables when content_type is "template". + Vars *map[string]interface{} `json:"vars,omitempty"` +} + +// FileDeployRequestContentType Content type — "raw" or "template". +type FileDeployRequestContentType string + +// FileDeployResponse defines model for FileDeployResponse. +type FileDeployResponse struct { + // Changed Whether the file was actually written. + Changed bool `json:"changed"` + + // Hostname The agent that processed the job. + Hostname string `json:"hostname"` + + // JobId The ID of the created job. + JobId string `json:"job_id"` +} + +// FileInfo defines model for FileInfo. +type FileInfo struct { + // Name The name of the file. + Name string `json:"name"` + + // Sha256 SHA-256 hash of the file content. + Sha256 string `json:"sha256"` + + // Size File size in bytes. + Size int `json:"size"` +} + +// FileInfoResponse defines model for FileInfoResponse. +type FileInfoResponse struct { + // Name The name of the file. + Name string `json:"name"` + + // Sha256 SHA-256 hash of the file content. + Sha256 string `json:"sha256"` + + // Size File size in bytes. + Size int `json:"size"` +} + +// FileListResponse defines model for FileListResponse. +type FileListResponse struct { + // Files List of stored files. + Files []FileInfo `json:"files"` + + // Total Total number of files. + Total int `json:"total"` +} + +// FileStatusRequest defines model for FileStatusRequest. +type FileStatusRequest struct { + // Path Filesystem path to check. + Path string `json:"path" validate:"required,min=1"` +} + +// FileStatusResponse defines model for FileStatusResponse. +type FileStatusResponse struct { + // Hostname The agent that processed the job. + Hostname string `json:"hostname"` + + // JobId The ID of the created job. + JobId string `json:"job_id"` + + // Path The filesystem path. + Path string `json:"path"` + + // Sha256 Current SHA-256 of the file on disk. + Sha256 *string `json:"sha256,omitempty"` + + // Status File state — "in-sync", "drifted", or "missing". + Status string `json:"status"` +} + +// FileUploadRequest defines model for FileUploadRequest. +type FileUploadRequest struct { + // Content Base64-encoded file content. + Content []byte `json:"content" validate:"required"` + + // Name The name of the file. + Name string `json:"name" validate:"required,min=1,max=255"` +} + +// FileUploadResponse defines model for FileUploadResponse. +type FileUploadResponse struct { + // Name The name of the uploaded file. + Name string `json:"name"` + + // Sha256 SHA-256 hash of the file content. + Sha256 string `json:"sha256"` + + // Size File size in bytes. + Size int `json:"size"` +} + // HealthResponse defines model for HealthResponse. type HealthResponse struct { // Status Health status. @@ -868,6 +1000,9 @@ type UptimeResponse struct { Uptime *string `json:"uptime,omitempty"` } +// FileName defines model for FileName. +type FileName = string + // Hostname defines model for Hostname. type Hostname = string @@ -901,6 +1036,9 @@ type PostNodeNetworkPingJSONBody struct { Address string `json:"address" validate:"required,ip_or_fact"` } +// PostFileJSONRequestBody defines body for PostFile for application/json ContentType. +type PostFileJSONRequestBody = FileUploadRequest + // PostJobJSONRequestBody defines body for PostJob for application/json ContentType. type PostJobJSONRequestBody = CreateJobRequest @@ -913,6 +1051,12 @@ type PostNodeCommandExecJSONRequestBody = CommandExecRequest // PostNodeCommandShellJSONRequestBody defines body for PostNodeCommandShell for application/json ContentType. type PostNodeCommandShellJSONRequestBody = CommandShellRequest +// PostNodeFileDeployJSONRequestBody defines body for PostNodeFileDeploy for application/json ContentType. +type PostNodeFileDeployJSONRequestBody = FileDeployRequest + +// PostNodeFileStatusJSONRequestBody defines body for PostNodeFileStatus for application/json ContentType. +type PostNodeFileStatusJSONRequestBody = FileStatusRequest + // PutNodeNetworkDNSJSONRequestBody defines body for PutNodeNetworkDNS for application/json ContentType. type PutNodeNetworkDNSJSONRequestBody = DNSConfigUpdateRequest @@ -1013,6 +1157,20 @@ type ClientInterface interface { // GetAuditLogByID request GetAuditLogByID(ctx context.Context, id openapi_types.UUID, reqEditors ...RequestEditorFn) (*http.Response, error) + // GetFiles request + GetFiles(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) + + // PostFileWithBody request with any body + PostFileWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + PostFile(ctx context.Context, body PostFileJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // DeleteFileByName request + DeleteFileByName(ctx context.Context, name FileName, reqEditors ...RequestEditorFn) (*http.Response, error) + + // GetFileByName request + GetFileByName(ctx context.Context, name FileName, reqEditors ...RequestEditorFn) (*http.Response, error) + // GetHealth request GetHealth(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) @@ -1060,6 +1218,16 @@ type ClientInterface interface { // GetNodeDisk request GetNodeDisk(ctx context.Context, hostname Hostname, reqEditors ...RequestEditorFn) (*http.Response, error) + // PostNodeFileDeployWithBody request with any body + PostNodeFileDeployWithBody(ctx context.Context, hostname Hostname, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + PostNodeFileDeploy(ctx context.Context, hostname Hostname, body PostNodeFileDeployJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // PostNodeFileStatusWithBody request with any body + PostNodeFileStatusWithBody(ctx context.Context, hostname Hostname, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + PostNodeFileStatus(ctx context.Context, hostname Hostname, body PostNodeFileStatusJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + // GetNodeHostname request GetNodeHostname(ctx context.Context, hostname Hostname, reqEditors ...RequestEditorFn) (*http.Response, error) @@ -1176,6 +1344,66 @@ func (c *Client) GetAuditLogByID(ctx context.Context, id openapi_types.UUID, req return c.Client.Do(req) } +func (c *Client) GetFiles(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewGetFilesRequest(c.Server) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) PostFileWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewPostFileRequestWithBody(c.Server, contentType, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) PostFile(ctx context.Context, body PostFileJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewPostFileRequest(c.Server, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) DeleteFileByName(ctx context.Context, name FileName, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewDeleteFileByNameRequest(c.Server, name) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) GetFileByName(ctx context.Context, name FileName, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewGetFileByNameRequest(c.Server, name) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + func (c *Client) GetHealth(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) { req, err := NewGetHealthRequest(c.Server) if err != nil { @@ -1380,6 +1608,54 @@ func (c *Client) GetNodeDisk(ctx context.Context, hostname Hostname, reqEditors return c.Client.Do(req) } +func (c *Client) PostNodeFileDeployWithBody(ctx context.Context, hostname Hostname, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewPostNodeFileDeployRequestWithBody(c.Server, hostname, contentType, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) PostNodeFileDeploy(ctx context.Context, hostname Hostname, body PostNodeFileDeployJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewPostNodeFileDeployRequest(c.Server, hostname, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) PostNodeFileStatusWithBody(ctx context.Context, hostname Hostname, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewPostNodeFileStatusRequestWithBody(c.Server, hostname, contentType, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) PostNodeFileStatus(ctx context.Context, hostname Hostname, body PostNodeFileStatusJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewPostNodeFileStatusRequest(c.Server, hostname, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + func (c *Client) GetNodeHostname(ctx context.Context, hostname Hostname, reqEditors ...RequestEditorFn) (*http.Response, error) { req, err := NewGetNodeHostnameRequest(c.Server, hostname) if err != nil { @@ -1767,8 +2043,8 @@ func NewGetAuditLogByIDRequest(server string, id openapi_types.UUID) (*http.Requ return req, nil } -// NewGetHealthRequest generates requests for GetHealth -func NewGetHealthRequest(server string) (*http.Request, error) { +// NewGetFilesRequest generates requests for GetFiles +func NewGetFilesRequest(server string) (*http.Request, error) { var err error serverURL, err := url.Parse(server) @@ -1776,7 +2052,7 @@ func NewGetHealthRequest(server string) (*http.Request, error) { return nil, err } - operationPath := fmt.Sprintf("/health") + operationPath := fmt.Sprintf("/file") if operationPath[0] == '/' { operationPath = "." + operationPath } @@ -1794,8 +2070,19 @@ func NewGetHealthRequest(server string) (*http.Request, error) { return req, nil } -// NewGetHealthReadyRequest generates requests for GetHealthReady -func NewGetHealthReadyRequest(server string) (*http.Request, error) { +// NewPostFileRequest calls the generic PostFile builder with application/json body +func NewPostFileRequest(server string, body PostFileJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewPostFileRequestWithBody(server, "application/json", bodyReader) +} + +// NewPostFileRequestWithBody generates requests for PostFile with any type of body +func NewPostFileRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error) { var err error serverURL, err := url.Parse(server) @@ -1803,7 +2090,7 @@ func NewGetHealthReadyRequest(server string) (*http.Request, error) { return nil, err } - operationPath := fmt.Sprintf("/health/ready") + operationPath := fmt.Sprintf("/file") if operationPath[0] == '/' { operationPath = "." + operationPath } @@ -1813,24 +2100,33 @@ func NewGetHealthReadyRequest(server string) (*http.Request, error) { return nil, err } - req, err := http.NewRequest("GET", queryURL.String(), nil) + req, err := http.NewRequest("POST", queryURL.String(), body) if err != nil { return nil, err } + req.Header.Add("Content-Type", contentType) + return req, nil } -// NewGetHealthStatusRequest generates requests for GetHealthStatus -func NewGetHealthStatusRequest(server string) (*http.Request, error) { +// NewDeleteFileByNameRequest generates requests for DeleteFileByName +func NewDeleteFileByNameRequest(server string, name FileName) (*http.Request, error) { var err error + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "name", runtime.ParamLocationPath, name) + if err != nil { + return nil, err + } + serverURL, err := url.Parse(server) if err != nil { return nil, err } - operationPath := fmt.Sprintf("/health/status") + operationPath := fmt.Sprintf("/file/%s", pathParam0) if operationPath[0] == '/' { operationPath = "." + operationPath } @@ -1840,7 +2136,7 @@ func NewGetHealthStatusRequest(server string) (*http.Request, error) { return nil, err } - req, err := http.NewRequest("GET", queryURL.String(), nil) + req, err := http.NewRequest("DELETE", queryURL.String(), nil) if err != nil { return nil, err } @@ -1848,16 +2144,23 @@ func NewGetHealthStatusRequest(server string) (*http.Request, error) { return req, nil } -// NewGetJobRequest generates requests for GetJob -func NewGetJobRequest(server string, params *GetJobParams) (*http.Request, error) { +// NewGetFileByNameRequest generates requests for GetFileByName +func NewGetFileByNameRequest(server string, name FileName) (*http.Request, error) { var err error + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "name", runtime.ParamLocationPath, name) + if err != nil { + return nil, err + } + serverURL, err := url.Parse(server) if err != nil { return nil, err } - operationPath := fmt.Sprintf("/job") + operationPath := fmt.Sprintf("/file/%s", pathParam0) if operationPath[0] == '/' { operationPath = "." + operationPath } @@ -1867,60 +2170,6 @@ func NewGetJobRequest(server string, params *GetJobParams) (*http.Request, error return nil, err } - if params != nil { - queryValues := queryURL.Query() - - if params.Status != nil { - - if queryFrag, err := runtime.StyleParamWithLocation("form", true, "status", runtime.ParamLocationQuery, *params.Status); err != nil { - return nil, err - } else if parsed, err := url.ParseQuery(queryFrag); err != nil { - return nil, err - } else { - for k, v := range parsed { - for _, v2 := range v { - queryValues.Add(k, v2) - } - } - } - - } - - if params.Limit != nil { - - if queryFrag, err := runtime.StyleParamWithLocation("form", true, "limit", runtime.ParamLocationQuery, *params.Limit); err != nil { - return nil, err - } else if parsed, err := url.ParseQuery(queryFrag); err != nil { - return nil, err - } else { - for k, v := range parsed { - for _, v2 := range v { - queryValues.Add(k, v2) - } - } - } - - } - - if params.Offset != nil { - - if queryFrag, err := runtime.StyleParamWithLocation("form", true, "offset", runtime.ParamLocationQuery, *params.Offset); err != nil { - return nil, err - } else if parsed, err := url.ParseQuery(queryFrag); err != nil { - return nil, err - } else { - for k, v := range parsed { - for _, v2 := range v { - queryValues.Add(k, v2) - } - } - } - - } - - queryURL.RawQuery = queryValues.Encode() - } - req, err := http.NewRequest("GET", queryURL.String(), nil) if err != nil { return nil, err @@ -1929,13 +2178,175 @@ func NewGetJobRequest(server string, params *GetJobParams) (*http.Request, error return req, nil } -// NewPostJobRequest calls the generic PostJob builder with application/json body -func NewPostJobRequest(server string, body PostJobJSONRequestBody) (*http.Request, error) { - var bodyReader io.Reader - buf, err := json.Marshal(body) - if err != nil { - return nil, err - } +// NewGetHealthRequest generates requests for GetHealth +func NewGetHealthRequest(server string) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/health") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("GET", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewGetHealthReadyRequest generates requests for GetHealthReady +func NewGetHealthReadyRequest(server string) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/health/ready") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("GET", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewGetHealthStatusRequest generates requests for GetHealthStatus +func NewGetHealthStatusRequest(server string) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/health/status") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("GET", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewGetJobRequest generates requests for GetJob +func NewGetJobRequest(server string, params *GetJobParams) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/job") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + if params != nil { + queryValues := queryURL.Query() + + if params.Status != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "status", runtime.ParamLocationQuery, *params.Status); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + + if params.Limit != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "limit", runtime.ParamLocationQuery, *params.Limit); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + + if params.Offset != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "offset", runtime.ParamLocationQuery, *params.Offset); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + + queryURL.RawQuery = queryValues.Encode() + } + + req, err := http.NewRequest("GET", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewPostJobRequest calls the generic PostJob builder with application/json body +func NewPostJobRequest(server string, body PostJobJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } bodyReader = bytes.NewReader(buf) return NewPostJobRequestWithBody(server, "application/json", bodyReader) } @@ -2273,6 +2684,100 @@ func NewGetNodeDiskRequest(server string, hostname Hostname) (*http.Request, err return req, nil } +// NewPostNodeFileDeployRequest calls the generic PostNodeFileDeploy builder with application/json body +func NewPostNodeFileDeployRequest(server string, hostname Hostname, body PostNodeFileDeployJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewPostNodeFileDeployRequestWithBody(server, hostname, "application/json", bodyReader) +} + +// NewPostNodeFileDeployRequestWithBody generates requests for PostNodeFileDeploy with any type of body +func NewPostNodeFileDeployRequestWithBody(server string, hostname Hostname, contentType string, body io.Reader) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "hostname", runtime.ParamLocationPath, hostname) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/node/%s/file/deploy", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("POST", queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + +// NewPostNodeFileStatusRequest calls the generic PostNodeFileStatus builder with application/json body +func NewPostNodeFileStatusRequest(server string, hostname Hostname, body PostNodeFileStatusJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewPostNodeFileStatusRequestWithBody(server, hostname, "application/json", bodyReader) +} + +// NewPostNodeFileStatusRequestWithBody generates requests for PostNodeFileStatus with any type of body +func NewPostNodeFileStatusRequestWithBody(server string, hostname Hostname, contentType string, body io.Reader) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "hostname", runtime.ParamLocationPath, hostname) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/node/%s/file/status", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("POST", queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + // NewGetNodeHostnameRequest generates requests for GetNodeHostname func NewGetNodeHostnameRequest(server string, hostname Hostname) (*http.Request, error) { var err error @@ -2669,6 +3174,20 @@ type ClientWithResponsesInterface interface { // GetAuditLogByIDWithResponse request GetAuditLogByIDWithResponse(ctx context.Context, id openapi_types.UUID, reqEditors ...RequestEditorFn) (*GetAuditLogByIDResponse, error) + // GetFilesWithResponse request + GetFilesWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*GetFilesResponse, error) + + // PostFileWithBodyWithResponse request with any body + PostFileWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostFileResponse, error) + + PostFileWithResponse(ctx context.Context, body PostFileJSONRequestBody, reqEditors ...RequestEditorFn) (*PostFileResponse, error) + + // DeleteFileByNameWithResponse request + DeleteFileByNameWithResponse(ctx context.Context, name FileName, reqEditors ...RequestEditorFn) (*DeleteFileByNameResponse, error) + + // GetFileByNameWithResponse request + GetFileByNameWithResponse(ctx context.Context, name FileName, reqEditors ...RequestEditorFn) (*GetFileByNameResponse, error) + // GetHealthWithResponse request GetHealthWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*GetHealthResponse, error) @@ -2716,6 +3235,16 @@ type ClientWithResponsesInterface interface { // GetNodeDiskWithResponse request GetNodeDiskWithResponse(ctx context.Context, hostname Hostname, reqEditors ...RequestEditorFn) (*GetNodeDiskResponse, error) + // PostNodeFileDeployWithBodyWithResponse request with any body + PostNodeFileDeployWithBodyWithResponse(ctx context.Context, hostname Hostname, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostNodeFileDeployResponse, error) + + PostNodeFileDeployWithResponse(ctx context.Context, hostname Hostname, body PostNodeFileDeployJSONRequestBody, reqEditors ...RequestEditorFn) (*PostNodeFileDeployResponse, error) + + // PostNodeFileStatusWithBodyWithResponse request with any body + PostNodeFileStatusWithBodyWithResponse(ctx context.Context, hostname Hostname, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostNodeFileStatusResponse, error) + + PostNodeFileStatusWithResponse(ctx context.Context, hostname Hostname, body PostNodeFileStatusJSONRequestBody, reqEditors ...RequestEditorFn) (*PostNodeFileStatusResponse, error) + // GetNodeHostnameWithResponse request GetNodeHostnameWithResponse(ctx context.Context, hostname Hostname, reqEditors ...RequestEditorFn) (*GetNodeHostnameResponse, error) @@ -2932,6 +3461,109 @@ func (r GetAuditLogByIDResponse) StatusCode() int { return 0 } +type GetFilesResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *FileListResponse + JSON401 *ErrorResponse + JSON403 *ErrorResponse + JSON500 *ErrorResponse +} + +// Status returns HTTPResponse.Status +func (r GetFilesResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r GetFilesResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type PostFileResponse struct { + Body []byte + HTTPResponse *http.Response + JSON201 *FileUploadResponse + JSON400 *ErrorResponse + JSON401 *ErrorResponse + JSON403 *ErrorResponse + JSON500 *ErrorResponse +} + +// Status returns HTTPResponse.Status +func (r PostFileResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r PostFileResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type DeleteFileByNameResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *FileDeleteResponse + JSON401 *ErrorResponse + JSON403 *ErrorResponse + JSON404 *ErrorResponse + JSON500 *ErrorResponse +} + +// Status returns HTTPResponse.Status +func (r DeleteFileByNameResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r DeleteFileByNameResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type GetFileByNameResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *FileInfoResponse + JSON401 *ErrorResponse + JSON403 *ErrorResponse + JSON404 *ErrorResponse + JSON500 *ErrorResponse +} + +// Status returns HTTPResponse.Status +func (r GetFileByNameResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r GetFileByNameResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + type GetHealthResponse struct { Body []byte HTTPResponse *http.Response @@ -3263,6 +3895,58 @@ func (r GetNodeDiskResponse) StatusCode() int { return 0 } +type PostNodeFileDeployResponse struct { + Body []byte + HTTPResponse *http.Response + JSON202 *FileDeployResponse + JSON400 *ErrorResponse + JSON401 *ErrorResponse + JSON403 *ErrorResponse + JSON500 *ErrorResponse +} + +// Status returns HTTPResponse.Status +func (r PostNodeFileDeployResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r PostNodeFileDeployResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type PostNodeFileStatusResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *FileStatusResponse + JSON400 *ErrorResponse + JSON401 *ErrorResponse + JSON403 *ErrorResponse + JSON500 *ErrorResponse +} + +// Status returns HTTPResponse.Status +func (r PostNodeFileStatusResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r PostNodeFileStatusResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + type GetNodeHostnameResponse struct { Body []byte HTTPResponse *http.Response @@ -3556,6 +4240,50 @@ func (c *ClientWithResponses) GetAuditLogByIDWithResponse(ctx context.Context, i return ParseGetAuditLogByIDResponse(rsp) } +// GetFilesWithResponse request returning *GetFilesResponse +func (c *ClientWithResponses) GetFilesWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*GetFilesResponse, error) { + rsp, err := c.GetFiles(ctx, reqEditors...) + if err != nil { + return nil, err + } + return ParseGetFilesResponse(rsp) +} + +// PostFileWithBodyWithResponse request with arbitrary body returning *PostFileResponse +func (c *ClientWithResponses) PostFileWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostFileResponse, error) { + rsp, err := c.PostFileWithBody(ctx, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParsePostFileResponse(rsp) +} + +func (c *ClientWithResponses) PostFileWithResponse(ctx context.Context, body PostFileJSONRequestBody, reqEditors ...RequestEditorFn) (*PostFileResponse, error) { + rsp, err := c.PostFile(ctx, body, reqEditors...) + if err != nil { + return nil, err + } + return ParsePostFileResponse(rsp) +} + +// DeleteFileByNameWithResponse request returning *DeleteFileByNameResponse +func (c *ClientWithResponses) DeleteFileByNameWithResponse(ctx context.Context, name FileName, reqEditors ...RequestEditorFn) (*DeleteFileByNameResponse, error) { + rsp, err := c.DeleteFileByName(ctx, name, reqEditors...) + if err != nil { + return nil, err + } + return ParseDeleteFileByNameResponse(rsp) +} + +// GetFileByNameWithResponse request returning *GetFileByNameResponse +func (c *ClientWithResponses) GetFileByNameWithResponse(ctx context.Context, name FileName, reqEditors ...RequestEditorFn) (*GetFileByNameResponse, error) { + rsp, err := c.GetFileByName(ctx, name, reqEditors...) + if err != nil { + return nil, err + } + return ParseGetFileByNameResponse(rsp) +} + // GetHealthWithResponse request returning *GetHealthResponse func (c *ClientWithResponses) GetHealthWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*GetHealthResponse, error) { rsp, err := c.GetHealth(ctx, reqEditors...) @@ -3705,6 +4433,40 @@ func (c *ClientWithResponses) GetNodeDiskWithResponse(ctx context.Context, hostn return ParseGetNodeDiskResponse(rsp) } +// PostNodeFileDeployWithBodyWithResponse request with arbitrary body returning *PostNodeFileDeployResponse +func (c *ClientWithResponses) PostNodeFileDeployWithBodyWithResponse(ctx context.Context, hostname Hostname, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostNodeFileDeployResponse, error) { + rsp, err := c.PostNodeFileDeployWithBody(ctx, hostname, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParsePostNodeFileDeployResponse(rsp) +} + +func (c *ClientWithResponses) PostNodeFileDeployWithResponse(ctx context.Context, hostname Hostname, body PostNodeFileDeployJSONRequestBody, reqEditors ...RequestEditorFn) (*PostNodeFileDeployResponse, error) { + rsp, err := c.PostNodeFileDeploy(ctx, hostname, body, reqEditors...) + if err != nil { + return nil, err + } + return ParsePostNodeFileDeployResponse(rsp) +} + +// PostNodeFileStatusWithBodyWithResponse request with arbitrary body returning *PostNodeFileStatusResponse +func (c *ClientWithResponses) PostNodeFileStatusWithBodyWithResponse(ctx context.Context, hostname Hostname, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostNodeFileStatusResponse, error) { + rsp, err := c.PostNodeFileStatusWithBody(ctx, hostname, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParsePostNodeFileStatusResponse(rsp) +} + +func (c *ClientWithResponses) PostNodeFileStatusWithResponse(ctx context.Context, hostname Hostname, body PostNodeFileStatusJSONRequestBody, reqEditors ...RequestEditorFn) (*PostNodeFileStatusResponse, error) { + rsp, err := c.PostNodeFileStatus(ctx, hostname, body, reqEditors...) + if err != nil { + return nil, err + } + return ParsePostNodeFileStatusResponse(rsp) +} + // GetNodeHostnameWithResponse request returning *GetNodeHostnameResponse func (c *ClientWithResponses) GetNodeHostnameWithResponse(ctx context.Context, hostname Hostname, reqEditors ...RequestEditorFn) (*GetNodeHostnameResponse, error) { rsp, err := c.GetNodeHostname(ctx, hostname, reqEditors...) @@ -3767,62 +4529,282 @@ func (c *ClientWithResponses) PostNodeNetworkPingWithBodyWithResponse(ctx contex return ParsePostNodeNetworkPingResponse(rsp) } -func (c *ClientWithResponses) PostNodeNetworkPingWithResponse(ctx context.Context, hostname Hostname, body PostNodeNetworkPingJSONRequestBody, reqEditors ...RequestEditorFn) (*PostNodeNetworkPingResponse, error) { - rsp, err := c.PostNodeNetworkPing(ctx, hostname, body, reqEditors...) - if err != nil { - return nil, err +func (c *ClientWithResponses) PostNodeNetworkPingWithResponse(ctx context.Context, hostname Hostname, body PostNodeNetworkPingJSONRequestBody, reqEditors ...RequestEditorFn) (*PostNodeNetworkPingResponse, error) { + rsp, err := c.PostNodeNetworkPing(ctx, hostname, body, reqEditors...) + if err != nil { + return nil, err + } + return ParsePostNodeNetworkPingResponse(rsp) +} + +// GetNodeOSWithResponse request returning *GetNodeOSResponse +func (c *ClientWithResponses) GetNodeOSWithResponse(ctx context.Context, hostname Hostname, reqEditors ...RequestEditorFn) (*GetNodeOSResponse, error) { + rsp, err := c.GetNodeOS(ctx, hostname, reqEditors...) + if err != nil { + return nil, err + } + return ParseGetNodeOSResponse(rsp) +} + +// GetNodeUptimeWithResponse request returning *GetNodeUptimeResponse +func (c *ClientWithResponses) GetNodeUptimeWithResponse(ctx context.Context, hostname Hostname, reqEditors ...RequestEditorFn) (*GetNodeUptimeResponse, error) { + rsp, err := c.GetNodeUptime(ctx, hostname, reqEditors...) + if err != nil { + return nil, err + } + return ParseGetNodeUptimeResponse(rsp) +} + +// GetVersionWithResponse request returning *GetVersionResponse +func (c *ClientWithResponses) GetVersionWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*GetVersionResponse, error) { + rsp, err := c.GetVersion(ctx, reqEditors...) + if err != nil { + return nil, err + } + return ParseGetVersionResponse(rsp) +} + +// ParseGetAgentResponse parses an HTTP response from a GetAgentWithResponse call +func ParseGetAgentResponse(rsp *http.Response) (*GetAgentResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &GetAgentResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest ListAgentsResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest ErrorResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest ErrorResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest ErrorResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + } + + return response, nil +} + +// ParseGetAgentDetailsResponse parses an HTTP response from a GetAgentDetailsWithResponse call +func ParseGetAgentDetailsResponse(rsp *http.Response) (*GetAgentDetailsResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &GetAgentDetailsResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest AgentInfo + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest ErrorResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest ErrorResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest ErrorResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest ErrorResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + } + + return response, nil +} + +// ParseDrainAgentResponse parses an HTTP response from a DrainAgentWithResponse call +func ParseDrainAgentResponse(rsp *http.Response) (*DrainAgentResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &DrainAgentResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest struct { + Message string `json:"message"` + } + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest ErrorResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest ErrorResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest ErrorResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 409: + var dest ErrorResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON409 = &dest + } - return ParsePostNodeNetworkPingResponse(rsp) + + return response, nil } -// GetNodeOSWithResponse request returning *GetNodeOSResponse -func (c *ClientWithResponses) GetNodeOSWithResponse(ctx context.Context, hostname Hostname, reqEditors ...RequestEditorFn) (*GetNodeOSResponse, error) { - rsp, err := c.GetNodeOS(ctx, hostname, reqEditors...) +// ParseUndrainAgentResponse parses an HTTP response from a UndrainAgentWithResponse call +func ParseUndrainAgentResponse(rsp *http.Response) (*UndrainAgentResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() if err != nil { return nil, err } - return ParseGetNodeOSResponse(rsp) -} -// GetNodeUptimeWithResponse request returning *GetNodeUptimeResponse -func (c *ClientWithResponses) GetNodeUptimeWithResponse(ctx context.Context, hostname Hostname, reqEditors ...RequestEditorFn) (*GetNodeUptimeResponse, error) { - rsp, err := c.GetNodeUptime(ctx, hostname, reqEditors...) - if err != nil { - return nil, err + response := &UndrainAgentResponse{ + Body: bodyBytes, + HTTPResponse: rsp, } - return ParseGetNodeUptimeResponse(rsp) -} -// GetVersionWithResponse request returning *GetVersionResponse -func (c *ClientWithResponses) GetVersionWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*GetVersionResponse, error) { - rsp, err := c.GetVersion(ctx, reqEditors...) - if err != nil { - return nil, err + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest struct { + Message string `json:"message"` + } + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest ErrorResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest ErrorResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest ErrorResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 409: + var dest ErrorResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON409 = &dest + } - return ParseGetVersionResponse(rsp) + + return response, nil } -// ParseGetAgentResponse parses an HTTP response from a GetAgentWithResponse call -func ParseGetAgentResponse(rsp *http.Response) (*GetAgentResponse, error) { +// ParseGetAuditLogsResponse parses an HTTP response from a GetAuditLogsWithResponse call +func ParseGetAuditLogsResponse(rsp *http.Response) (*GetAuditLogsResponse, error) { bodyBytes, err := io.ReadAll(rsp.Body) defer func() { _ = rsp.Body.Close() }() if err != nil { return nil, err } - response := &GetAgentResponse{ + response := &GetAuditLogsResponse{ Body: bodyBytes, HTTPResponse: rsp, } switch { case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: - var dest ListAgentsResponse + var dest ListAuditResponse if err := json.Unmarshal(bodyBytes, &dest); err != nil { return nil, err } response.JSON200 = &dest + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest ErrorResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: var dest ErrorResponse if err := json.Unmarshal(bodyBytes, &dest); err != nil { @@ -3849,22 +4831,22 @@ func ParseGetAgentResponse(rsp *http.Response) (*GetAgentResponse, error) { return response, nil } -// ParseGetAgentDetailsResponse parses an HTTP response from a GetAgentDetailsWithResponse call -func ParseGetAgentDetailsResponse(rsp *http.Response) (*GetAgentDetailsResponse, error) { +// ParseGetAuditExportResponse parses an HTTP response from a GetAuditExportWithResponse call +func ParseGetAuditExportResponse(rsp *http.Response) (*GetAuditExportResponse, error) { bodyBytes, err := io.ReadAll(rsp.Body) defer func() { _ = rsp.Body.Close() }() if err != nil { return nil, err } - response := &GetAgentDetailsResponse{ + response := &GetAuditExportResponse{ Body: bodyBytes, HTTPResponse: rsp, } switch { case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: - var dest AgentInfo + var dest ListAuditResponse if err := json.Unmarshal(bodyBytes, &dest); err != nil { return nil, err } @@ -3884,13 +4866,6 @@ func ParseGetAgentDetailsResponse(rsp *http.Response) (*GetAgentDetailsResponse, } response.JSON403 = &dest - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: - var dest ErrorResponse - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON404 = &dest - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: var dest ErrorResponse if err := json.Unmarshal(bodyBytes, &dest); err != nil { @@ -3903,24 +4878,22 @@ func ParseGetAgentDetailsResponse(rsp *http.Response) (*GetAgentDetailsResponse, return response, nil } -// ParseDrainAgentResponse parses an HTTP response from a DrainAgentWithResponse call -func ParseDrainAgentResponse(rsp *http.Response) (*DrainAgentResponse, error) { +// ParseGetAuditLogByIDResponse parses an HTTP response from a GetAuditLogByIDWithResponse call +func ParseGetAuditLogByIDResponse(rsp *http.Response) (*GetAuditLogByIDResponse, error) { bodyBytes, err := io.ReadAll(rsp.Body) defer func() { _ = rsp.Body.Close() }() if err != nil { return nil, err } - response := &DrainAgentResponse{ + response := &GetAuditLogByIDResponse{ Body: bodyBytes, HTTPResponse: rsp, } switch { case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: - var dest struct { - Message string `json:"message"` - } + var dest AuditEntryResponse if err := json.Unmarshal(bodyBytes, &dest); err != nil { return nil, err } @@ -3947,36 +4920,34 @@ func ParseDrainAgentResponse(rsp *http.Response) (*DrainAgentResponse, error) { } response.JSON404 = &dest - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 409: + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: var dest ErrorResponse if err := json.Unmarshal(bodyBytes, &dest); err != nil { return nil, err } - response.JSON409 = &dest + response.JSON500 = &dest } return response, nil } -// ParseUndrainAgentResponse parses an HTTP response from a UndrainAgentWithResponse call -func ParseUndrainAgentResponse(rsp *http.Response) (*UndrainAgentResponse, error) { +// ParseGetFilesResponse parses an HTTP response from a GetFilesWithResponse call +func ParseGetFilesResponse(rsp *http.Response) (*GetFilesResponse, error) { bodyBytes, err := io.ReadAll(rsp.Body) defer func() { _ = rsp.Body.Close() }() if err != nil { return nil, err } - response := &UndrainAgentResponse{ + response := &GetFilesResponse{ Body: bodyBytes, HTTPResponse: rsp, } switch { case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: - var dest struct { - Message string `json:"message"` - } + var dest FileListResponse if err := json.Unmarshal(bodyBytes, &dest); err != nil { return nil, err } @@ -3996,45 +4967,38 @@ func ParseUndrainAgentResponse(rsp *http.Response) (*UndrainAgentResponse, error } response.JSON403 = &dest - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: - var dest ErrorResponse - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON404 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 409: + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: var dest ErrorResponse if err := json.Unmarshal(bodyBytes, &dest); err != nil { return nil, err } - response.JSON409 = &dest + response.JSON500 = &dest } return response, nil } -// ParseGetAuditLogsResponse parses an HTTP response from a GetAuditLogsWithResponse call -func ParseGetAuditLogsResponse(rsp *http.Response) (*GetAuditLogsResponse, error) { +// ParsePostFileResponse parses an HTTP response from a PostFileWithResponse call +func ParsePostFileResponse(rsp *http.Response) (*PostFileResponse, error) { bodyBytes, err := io.ReadAll(rsp.Body) defer func() { _ = rsp.Body.Close() }() if err != nil { return nil, err } - response := &GetAuditLogsResponse{ + response := &PostFileResponse{ Body: bodyBytes, HTTPResponse: rsp, } switch { - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: - var dest ListAuditResponse + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 201: + var dest FileUploadResponse if err := json.Unmarshal(bodyBytes, &dest); err != nil { return nil, err } - response.JSON200 = &dest + response.JSON201 = &dest case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: var dest ErrorResponse @@ -4069,22 +5033,22 @@ func ParseGetAuditLogsResponse(rsp *http.Response) (*GetAuditLogsResponse, error return response, nil } -// ParseGetAuditExportResponse parses an HTTP response from a GetAuditExportWithResponse call -func ParseGetAuditExportResponse(rsp *http.Response) (*GetAuditExportResponse, error) { +// ParseDeleteFileByNameResponse parses an HTTP response from a DeleteFileByNameWithResponse call +func ParseDeleteFileByNameResponse(rsp *http.Response) (*DeleteFileByNameResponse, error) { bodyBytes, err := io.ReadAll(rsp.Body) defer func() { _ = rsp.Body.Close() }() if err != nil { return nil, err } - response := &GetAuditExportResponse{ + response := &DeleteFileByNameResponse{ Body: bodyBytes, HTTPResponse: rsp, } switch { case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: - var dest ListAuditResponse + var dest FileDeleteResponse if err := json.Unmarshal(bodyBytes, &dest); err != nil { return nil, err } @@ -4104,6 +5068,13 @@ func ParseGetAuditExportResponse(rsp *http.Response) (*GetAuditExportResponse, e } response.JSON403 = &dest + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest ErrorResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: var dest ErrorResponse if err := json.Unmarshal(bodyBytes, &dest); err != nil { @@ -4116,22 +5087,22 @@ func ParseGetAuditExportResponse(rsp *http.Response) (*GetAuditExportResponse, e return response, nil } -// ParseGetAuditLogByIDResponse parses an HTTP response from a GetAuditLogByIDWithResponse call -func ParseGetAuditLogByIDResponse(rsp *http.Response) (*GetAuditLogByIDResponse, error) { +// ParseGetFileByNameResponse parses an HTTP response from a GetFileByNameWithResponse call +func ParseGetFileByNameResponse(rsp *http.Response) (*GetFileByNameResponse, error) { bodyBytes, err := io.ReadAll(rsp.Body) defer func() { _ = rsp.Body.Close() }() if err != nil { return nil, err } - response := &GetAuditLogByIDResponse{ + response := &GetFileByNameResponse{ Body: bodyBytes, HTTPResponse: rsp, } switch { case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: - var dest AuditEntryResponse + var dest FileInfoResponse if err := json.Unmarshal(bodyBytes, &dest); err != nil { return nil, err } @@ -4823,6 +5794,114 @@ func ParseGetNodeDiskResponse(rsp *http.Response) (*GetNodeDiskResponse, error) return response, nil } +// ParsePostNodeFileDeployResponse parses an HTTP response from a PostNodeFileDeployWithResponse call +func ParsePostNodeFileDeployResponse(rsp *http.Response) (*PostNodeFileDeployResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &PostNodeFileDeployResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 202: + var dest FileDeployResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON202 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest ErrorResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest ErrorResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest ErrorResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest ErrorResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + } + + return response, nil +} + +// ParsePostNodeFileStatusResponse parses an HTTP response from a PostNodeFileStatusWithResponse call +func ParsePostNodeFileStatusResponse(rsp *http.Response) (*PostNodeFileStatusResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &PostNodeFileStatusResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest FileStatusResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest ErrorResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest ErrorResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest ErrorResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest ErrorResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + } + + return response, nil +} + // ParseGetNodeHostnameResponse parses an HTTP response from a GetNodeHostnameWithResponse call func ParseGetNodeHostnameResponse(rsp *http.Response) (*GetNodeHostnameResponse, error) { bodyBytes, err := io.ReadAll(rsp.Body) diff --git a/pkg/osapi/node.go b/pkg/osapi/node.go index dd4515f..ca69453 100644 --- a/pkg/osapi/node.go +++ b/pkg/osapi/node.go @@ -51,6 +51,34 @@ type ExecRequest struct { Target string } +// FileDeployOpts contains parameters for file deployment. +type FileDeployOpts struct { + // ObjectName is the name of the file in the Object Store (required). + ObjectName string + + // Path is the destination path on the target filesystem (required). + Path string + + // ContentType is "raw" or "template" (required). + ContentType string + + // Mode is the file permission mode (e.g., "0644"). Optional. + Mode string + + // Owner is the file owner user. Optional. + Owner string + + // Group is the file owner group. Optional. + Group string + + // Vars are template variables when ContentType is "template". Optional. + Vars map[string]any + + // Target specifies the host: "_any", "_all", hostname, or + // label ("group:web"). + Target string +} + // ShellRequest contains parameters for shell command execution. type ShellRequest struct { // Command is the shell command string passed to /bin/sh -c (required). @@ -407,3 +435,78 @@ func (s *NodeService) Shell( return NewResponse(commandCollectionFromGen(resp.JSON202), resp.Body), nil } + +// FileDeploy deploys a file from the Object Store to the target host. +func (s *NodeService) FileDeploy( + ctx context.Context, + req FileDeployOpts, +) (*Response[FileDeployResult], error) { + body := gen.FileDeployRequest{ + ObjectName: req.ObjectName, + Path: req.Path, + ContentType: gen.FileDeployRequestContentType(req.ContentType), + } + + if req.Mode != "" { + body.Mode = &req.Mode + } + + if req.Owner != "" { + body.Owner = &req.Owner + } + + if req.Group != "" { + body.Group = &req.Group + } + + if len(req.Vars) > 0 { + body.Vars = &req.Vars + } + + resp, err := s.client.PostNodeFileDeployWithResponse(ctx, req.Target, body) + if err != nil { + return nil, fmt.Errorf("file deploy: %w", err) + } + + if err := checkError(resp.StatusCode(), resp.JSON400, resp.JSON401, resp.JSON403, resp.JSON500); err != nil { + return nil, err + } + + if resp.JSON202 == nil { + return nil, &UnexpectedStatusError{APIError{ + StatusCode: resp.StatusCode(), + Message: "nil response body", + }} + } + + return NewResponse(fileDeployResultFromGen(resp.JSON202), resp.Body), nil +} + +// FileStatus checks the deployment status of a file on the target host. +func (s *NodeService) FileStatus( + ctx context.Context, + target string, + path string, +) (*Response[FileStatusResult], error) { + body := gen.FileStatusRequest{ + Path: path, + } + + resp, err := s.client.PostNodeFileStatusWithResponse(ctx, target, body) + if err != nil { + return nil, fmt.Errorf("file status: %w", err) + } + + if err := checkError(resp.StatusCode(), resp.JSON400, resp.JSON401, resp.JSON403, resp.JSON500); err != nil { + return nil, err + } + + if resp.JSON200 == nil { + return nil, &UnexpectedStatusError{APIError{ + StatusCode: resp.StatusCode(), + Message: "nil response body", + }} + } + + return NewResponse(fileStatusResultFromGen(resp.JSON200), resp.Body), nil +} diff --git a/pkg/osapi/node_public_test.go b/pkg/osapi/node_public_test.go index 63e3a30..86b083a 100644 --- a/pkg/osapi/node_public_test.go +++ b/pkg/osapi/node_public_test.go @@ -1394,6 +1394,300 @@ func (suite *NodePublicTestSuite) TestShell() { } } +func (suite *NodePublicTestSuite) TestFileDeploy() { + tests := []struct { + name string + handler http.HandlerFunc + serverURL string + req osapi.FileDeployOpts + validateFunc func(*osapi.Response[osapi.FileDeployResult], error) + }{ + { + name: "when deploying file returns result", + req: osapi.FileDeployOpts{ + ObjectName: "nginx.conf", + Path: "/etc/nginx/nginx.conf", + ContentType: "raw", + Target: "_any", + }, + handler: func(w http.ResponseWriter, _ *http.Request) { + w.Header().Set("Content-Type", "application/json") + w.WriteHeader(http.StatusAccepted) + _, _ = w.Write( + []byte( + `{"job_id":"job-123","hostname":"web-01","changed":true}`, + ), + ) + }, + validateFunc: func(resp *osapi.Response[osapi.FileDeployResult], err error) { + suite.NoError(err) + suite.NotNil(resp) + suite.Equal("job-123", resp.Data.JobID) + suite.Equal("web-01", resp.Data.Hostname) + suite.True(resp.Data.Changed) + }, + }, + { + name: "when all options provided returns results", + req: osapi.FileDeployOpts{ + ObjectName: "app.conf.tmpl", + Path: "/etc/app/app.conf", + ContentType: "template", + Mode: "0644", + Owner: "root", + Group: "root", + Vars: map[string]any{"port": 8080}, + Target: "web-01", + }, + handler: func(w http.ResponseWriter, _ *http.Request) { + w.Header().Set("Content-Type", "application/json") + w.WriteHeader(http.StatusAccepted) + _, _ = w.Write( + []byte( + `{"job_id":"job-456","hostname":"web-01","changed":true}`, + ), + ) + }, + validateFunc: func(resp *osapi.Response[osapi.FileDeployResult], err error) { + suite.NoError(err) + suite.NotNil(resp) + }, + }, + { + name: "when server returns 400 returns ValidationError", + req: osapi.FileDeployOpts{ + Target: "_any", + }, + handler: func(w http.ResponseWriter, _ *http.Request) { + w.Header().Set("Content-Type", "application/json") + w.WriteHeader(http.StatusBadRequest) + _, _ = w.Write([]byte(`{"error":"object_name is required"}`)) + }, + validateFunc: func(resp *osapi.Response[osapi.FileDeployResult], err error) { + suite.Error(err) + suite.Nil(resp) + + var target *osapi.ValidationError + suite.True(errors.As(err, &target)) + suite.Equal(http.StatusBadRequest, target.StatusCode) + }, + }, + { + name: "when server returns 403 returns AuthError", + req: osapi.FileDeployOpts{ + ObjectName: "nginx.conf", + Path: "/etc/nginx/nginx.conf", + ContentType: "raw", + Target: "_any", + }, + handler: func(w http.ResponseWriter, _ *http.Request) { + w.Header().Set("Content-Type", "application/json") + w.WriteHeader(http.StatusForbidden) + _, _ = w.Write([]byte(`{"error":"forbidden"}`)) + }, + validateFunc: func(resp *osapi.Response[osapi.FileDeployResult], err error) { + suite.Error(err) + suite.Nil(resp) + + var target *osapi.AuthError + suite.True(errors.As(err, &target)) + suite.Equal(http.StatusForbidden, target.StatusCode) + }, + }, + { + name: "when client HTTP call fails returns error", + serverURL: "http://127.0.0.1:0", + req: osapi.FileDeployOpts{ + ObjectName: "nginx.conf", + Path: "/etc/nginx/nginx.conf", + ContentType: "raw", + Target: "_any", + }, + validateFunc: func(resp *osapi.Response[osapi.FileDeployResult], err error) { + suite.Error(err) + suite.Nil(resp) + suite.Contains(err.Error(), "file deploy") + }, + }, + { + name: "when server returns 202 with no JSON body returns UnexpectedStatusError", + req: osapi.FileDeployOpts{ + ObjectName: "nginx.conf", + Path: "/etc/nginx/nginx.conf", + ContentType: "raw", + Target: "_any", + }, + handler: func(w http.ResponseWriter, _ *http.Request) { + w.WriteHeader(http.StatusAccepted) + }, + validateFunc: func(resp *osapi.Response[osapi.FileDeployResult], err error) { + suite.Error(err) + suite.Nil(resp) + + var target *osapi.UnexpectedStatusError + suite.True(errors.As(err, &target)) + suite.Equal(http.StatusAccepted, target.StatusCode) + suite.Equal("nil response body", target.Message) + }, + }, + } + + for _, tc := range tests { + suite.Run(tc.name, func() { + var ( + serverURL string + cleanup func() + ) + + if tc.serverURL != "" { + serverURL = tc.serverURL + cleanup = func() {} + } else { + server := httptest.NewServer(tc.handler) + serverURL = server.URL + cleanup = server.Close + } + defer cleanup() + + sut := osapi.New( + serverURL, + "test-token", + osapi.WithLogger(slog.Default()), + ) + + resp, err := sut.Node.FileDeploy(suite.ctx, tc.req) + tc.validateFunc(resp, err) + }) + } +} + +func (suite *NodePublicTestSuite) TestFileStatus() { + tests := []struct { + name string + handler http.HandlerFunc + serverURL string + target string + path string + validateFunc func(*osapi.Response[osapi.FileStatusResult], error) + }{ + { + name: "when checking file status returns result", + target: "_any", + path: "/etc/nginx/nginx.conf", + handler: func(w http.ResponseWriter, _ *http.Request) { + w.Header().Set("Content-Type", "application/json") + w.WriteHeader(http.StatusOK) + _, _ = w.Write( + []byte( + `{"job_id":"job-789","hostname":"web-01","path":"/etc/nginx/nginx.conf","status":"in-sync","sha256":"abc123"}`, + ), + ) + }, + validateFunc: func(resp *osapi.Response[osapi.FileStatusResult], err error) { + suite.NoError(err) + suite.NotNil(resp) + suite.Equal("job-789", resp.Data.JobID) + suite.Equal("web-01", resp.Data.Hostname) + suite.Equal("/etc/nginx/nginx.conf", resp.Data.Path) + suite.Equal("in-sync", resp.Data.Status) + suite.Equal("abc123", resp.Data.SHA256) + }, + }, + { + name: "when server returns 400 returns ValidationError", + target: "_any", + path: "", + handler: func(w http.ResponseWriter, _ *http.Request) { + w.Header().Set("Content-Type", "application/json") + w.WriteHeader(http.StatusBadRequest) + _, _ = w.Write([]byte(`{"error":"path is required"}`)) + }, + validateFunc: func(resp *osapi.Response[osapi.FileStatusResult], err error) { + suite.Error(err) + suite.Nil(resp) + + var target *osapi.ValidationError + suite.True(errors.As(err, &target)) + suite.Equal(http.StatusBadRequest, target.StatusCode) + }, + }, + { + name: "when server returns 403 returns AuthError", + target: "_any", + path: "/etc/nginx/nginx.conf", + handler: func(w http.ResponseWriter, _ *http.Request) { + w.Header().Set("Content-Type", "application/json") + w.WriteHeader(http.StatusForbidden) + _, _ = w.Write([]byte(`{"error":"forbidden"}`)) + }, + validateFunc: func(resp *osapi.Response[osapi.FileStatusResult], err error) { + suite.Error(err) + suite.Nil(resp) + + var target *osapi.AuthError + suite.True(errors.As(err, &target)) + suite.Equal(http.StatusForbidden, target.StatusCode) + }, + }, + { + name: "when client HTTP call fails returns error", + target: "_any", + path: "/etc/nginx/nginx.conf", + serverURL: "http://127.0.0.1:0", + validateFunc: func(resp *osapi.Response[osapi.FileStatusResult], err error) { + suite.Error(err) + suite.Nil(resp) + suite.Contains(err.Error(), "file status") + }, + }, + { + name: "when server returns 200 with no JSON body returns UnexpectedStatusError", + target: "_any", + path: "/etc/nginx/nginx.conf", + handler: func(w http.ResponseWriter, _ *http.Request) { + w.WriteHeader(http.StatusOK) + }, + validateFunc: func(resp *osapi.Response[osapi.FileStatusResult], err error) { + suite.Error(err) + suite.Nil(resp) + + var target *osapi.UnexpectedStatusError + suite.True(errors.As(err, &target)) + suite.Equal(http.StatusOK, target.StatusCode) + suite.Equal("nil response body", target.Message) + }, + }, + } + + for _, tc := range tests { + suite.Run(tc.name, func() { + var ( + serverURL string + cleanup func() + ) + + if tc.serverURL != "" { + serverURL = tc.serverURL + cleanup = func() {} + } else { + server := httptest.NewServer(tc.handler) + serverURL = server.URL + cleanup = server.Close + } + defer cleanup() + + sut := osapi.New( + serverURL, + "test-token", + osapi.WithLogger(slog.Default()), + ) + + resp, err := sut.Node.FileStatus(suite.ctx, tc.target, tc.path) + tc.validateFunc(resp, err) + }) + } +} + func TestNodePublicTestSuite(t *testing.T) { suite.Run(t, new(NodePublicTestSuite)) } diff --git a/pkg/osapi/osapi.go b/pkg/osapi/osapi.go index 63012fa..a8a7d6e 100644 --- a/pkg/osapi/osapi.go +++ b/pkg/osapi/osapi.go @@ -63,6 +63,9 @@ type Client struct { // Metrics provides Prometheus metrics access. Metrics *MetricsService + // File provides file management operations (upload, list, get, delete). + File *FileService + httpClient *gen.ClientWithResponses baseURL string logger *slog.Logger @@ -131,6 +134,7 @@ func New( client: httpClient, baseURL: baseURL, } + c.File = &FileService{client: httpClient} return c } diff --git a/pkg/osapi/osapi_public_test.go b/pkg/osapi/osapi_public_test.go index 188283b..0b34f49 100644 --- a/pkg/osapi/osapi_public_test.go +++ b/pkg/osapi/osapi_public_test.go @@ -69,6 +69,7 @@ func (suite *ClientPublicTestSuite) TestNew() { suite.NotNil(c.Health) suite.NotNil(c.Audit) suite.NotNil(c.Metrics) + suite.NotNil(c.File) }, }, { From 50ae93ab0d841321e9e4b86c4501578544a917bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D7=A0=CF=85=CE=B1=CE=B7=20=D7=A0=CF=85=CE=B1=CE=B7=D1=95?= =?UTF-8?q?=CF=83=CE=B7?= Date: Fri, 6 Mar 2026 12:49:05 -0800 Subject: [PATCH 2/3] docs: add file service and operation documentation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add FileService documentation with Upload, List, Get, Delete methods. Add file deploy/status operation docs for orchestration. Update README services and operations tables. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- CLAUDE.md | 3 +- README.md | 4 ++ docs/orchestration/README.md | 3 + docs/orchestration/file-deploy.md | 66 +++++++++++++++++++ docs/orchestration/file-status.md | 35 +++++++++++ docs/orchestration/file-upload.md | 36 +++++++++++ docs/osapi/README.md | 1 + docs/osapi/file.md | 101 ++++++++++++++++++++++++++++++ docs/osapi/node.md | 27 +++++++- 9 files changed, 274 insertions(+), 2 deletions(-) create mode 100644 docs/orchestration/file-deploy.md create mode 100644 docs/orchestration/file-status.md create mode 100644 docs/orchestration/file-upload.md create mode 100644 docs/osapi/file.md diff --git a/CLAUDE.md b/CLAUDE.md index 046bb2d..07fca85 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -30,9 +30,10 @@ just fetch / just deps / just test / just go::unit / just go::vet / just go::fmt - **`pkg/osapi/`** - Core SDK library - `osapi.go` - Client struct, New() factory, Option funcs - `transport.go` - HTTP transport with Bearer token and OTel tracing - - `node.go` - NodeService (hostname, status, agents) + - `node.go` - NodeService (hostname, status, agents, file deploy/status) - `network.go` - NetworkService (DNS get/update, ping) - `command.go` - CommandService (exec, shell) + - `file.go` - FileService (upload, list, get, delete) - `job.go` - JobService (create, get, list, delete, retry, stats) - `health.go` - HealthService (liveness, readiness, status) - `audit.go` - AuditService (list, get, export) diff --git a/README.md b/README.md index 2dfac95..51d571e 100644 --- a/README.md +++ b/README.md @@ -28,6 +28,7 @@ start. | ------- | ----------------------------------------------------- | ----------------------------- | ------------------------------------ | | Node | Hostname, disk, memory, load, uptime, OS info, status | [docs](docs/osapi/node.md) | [`node.go`](pkg/osapi/node.go) | | Network | DNS get/update, ping | [docs](docs/osapi/node.md) | [`node.go`](pkg/osapi/node.go) | +| File | Upload, list, get, delete, deploy, status | [docs](docs/osapi/file.md) | [`file.go`](pkg/osapi/file.go) | | Command | exec, shell | [docs](docs/osapi/node.md) | [`node.go`](pkg/osapi/node.go) | | Job | Create, get, list, delete, retry, stats | [docs](docs/osapi/job.md) | [`job.go`](pkg/osapi/job.go) | | Agent | List, get (discovery + heartbeat data) | [docs](docs/osapi/agent.md) | [`agent.go`](pkg/osapi/agent.go) | @@ -80,6 +81,9 @@ strategies, and adding new operations. | `node.memory.get` | Get memory stats | Read-only | [docs](docs/orchestration/node-memory.md) | | `node.uptime.get` | Get system uptime | Read-only | [docs](docs/orchestration/node-uptime.md) | | `node.load.get` | Get load averages | Read-only | [docs](docs/orchestration/node-load.md) | +| `file.deploy.execute` | Deploy file to agent | Yes | [docs](docs/orchestration/file-deploy.md) | +| `file.status.get` | Check file status | Read-only | [docs](docs/orchestration/file-status.md) | +| `file.upload` | Upload to Object Store | Yes | [docs](docs/orchestration/file-upload.md) | | `network.dns.get` | Get DNS configuration | Read-only | [docs](docs/orchestration/network-dns-get.md) | | `network.dns.update` | Update DNS servers | Yes | [docs](docs/orchestration/network-dns-update.md) | | `network.ping.do` | Ping a host | Read-only | [docs](docs/orchestration/network-ping.md) | diff --git a/docs/orchestration/README.md b/docs/orchestration/README.md index 412b985..18f4208 100644 --- a/docs/orchestration/README.md +++ b/docs/orchestration/README.md @@ -13,6 +13,9 @@ to an OSAPI job type that agents execute. | --------------------------------------------- | ---------------------- | ---------- | -------- | | [`command.exec.execute`](command-exec.md) | Execute a command | No | Command | | [`command.shell.execute`](command-shell.md) | Execute a shell string | No | Command | +| [`file.deploy.execute`](file-deploy.md) | Deploy file to agent | Yes | File | +| [`file.status.get`](file-status.md) | Check file status | Read-only | File | +| [`file.upload`](file-upload.md) | Upload to Object Store | Yes | File | | [`network.dns.get`](network-dns-get.md) | Get DNS configuration | Read-only | Network | | [`network.dns.update`](network-dns-update.md) | Update DNS servers | Yes | Network | | [`network.ping.do`](network-ping.md) | Ping a host | Read-only | Network | diff --git a/docs/orchestration/file-deploy.md b/docs/orchestration/file-deploy.md new file mode 100644 index 0000000..a78299e --- /dev/null +++ b/docs/orchestration/file-deploy.md @@ -0,0 +1,66 @@ +# file.deploy.execute + +Deploy a file from the Object Store to the target agent's filesystem. Supports +raw content and Go-template rendering with agent facts and custom variables. + +## Usage + +```go +task := plan.Task("deploy-config", &orchestrator.Op{ + Operation: "file.deploy.execute", + Target: "_all", + Params: map[string]any{ + "object_name": "nginx.conf", + "path": "/etc/nginx/nginx.conf", + "content_type": "raw", + "mode": "0644", + "owner": "root", + "group": "root", + }, +}) +``` + +### Template Deployment + +```go +task := plan.Task("deploy-template", &orchestrator.Op{ + Operation: "file.deploy.execute", + Target: "web-01", + Params: map[string]any{ + "object_name": "app.conf.tmpl", + "path": "/etc/app/config.yaml", + "content_type": "template", + "vars": map[string]any{ + "port": 8080, + "debug": false, + }, + }, +}) +``` + +## Parameters + +| Param | Type | Required | Description | +| -------------- | -------------- | -------- | ---------------------------------------- | +| `object_name` | string | Yes | Name of the file in the Object Store | +| `path` | string | Yes | Destination path on the target host | +| `content_type` | string | Yes | `"raw"` or `"template"` | +| `mode` | string | No | File permission mode (e.g., `"0644"`) | +| `owner` | string | No | File owner user | +| `group` | string | No | File owner group | +| `vars` | map[string]any | No | Template variables for `"template"` type | + +## Target + +Accepts any valid target: `_any`, `_all`, a hostname, or a label selector +(`key:value`). + +## Idempotency + +**Idempotent.** Compares the SHA-256 of the Object Store content against the +deployed file. Returns `Changed: true` only if the file was actually written. +Returns `Changed: false` if the hashes match. + +## Permissions + +Requires `file:write` permission. diff --git a/docs/orchestration/file-status.md b/docs/orchestration/file-status.md new file mode 100644 index 0000000..a2e73c2 --- /dev/null +++ b/docs/orchestration/file-status.md @@ -0,0 +1,35 @@ +# file.status.get + +Check the deployment status of a file on the target agent. Reports whether the +file is in-sync, drifted, or missing compared to the expected state. + +## Usage + +```go +task := plan.Task("check-config", &orchestrator.Op{ + Operation: "file.status.get", + Target: "web-01", + Params: map[string]any{ + "path": "/etc/nginx/nginx.conf", + }, +}) +``` + +## Parameters + +| Param | Type | Required | Description | +| ------ | ------ | -------- | ---------------------------- | +| `path` | string | Yes | File path to check on target | + +## Target + +Accepts any valid target: `_any`, `_all`, a hostname, or a label selector +(`key:value`). + +## Idempotency + +**Read-only.** Never modifies state. Always returns `Changed: false`. + +## Permissions + +Requires `file:read` permission. diff --git a/docs/orchestration/file-upload.md b/docs/orchestration/file-upload.md new file mode 100644 index 0000000..c90936b --- /dev/null +++ b/docs/orchestration/file-upload.md @@ -0,0 +1,36 @@ +# file.upload + +Upload file content to the OSAPI Object Store. Returns the object name that can +be referenced in subsequent `file.deploy.execute` operations. + +## Usage + +```go +task := plan.Task("upload-config", &orchestrator.Op{ + Operation: "file.upload", + Params: map[string]any{ + "name": "nginx.conf", + "content": configBytes, + }, +}) +``` + +## Parameters + +| Param | Type | Required | Description | +| --------- | ------ | -------- | ------------------------------- | +| `name` | string | Yes | Object name in the Object Store | +| `content` | []byte | Yes | File content to upload | + +## Target + +Not applicable. Upload is a server-side operation that does not target an agent. + +## Idempotency + +**Idempotent.** Uploading the same content with the same name overwrites the +existing object. + +## Permissions + +Requires `file:write` permission. diff --git a/docs/osapi/README.md b/docs/osapi/README.md index d7e4e1f..5ad6a47 100644 --- a/docs/osapi/README.md +++ b/docs/osapi/README.md @@ -17,6 +17,7 @@ resp, err := client.Node.Hostname(ctx, "_any") | ----------------------- | ---------------------------------- | ------------ | | [`Agent`](agent.md) | Agent discovery and details | `agent.go` | | [`Audit`](audit.md) | Audit log operations | `audit.go` | +| [`File`](file.md) | File management (Object Store) | `file.go` | | [`Health`](health.md) | Health check operations | `health.go` | | [`Job`](job.md) | Async job queue operations | `job.go` | | [`Metrics`](metrics.md) | Prometheus metrics access | `metrics.go` | diff --git a/docs/osapi/file.md b/docs/osapi/file.md new file mode 100644 index 0000000..2cb3058 --- /dev/null +++ b/docs/osapi/file.md @@ -0,0 +1,101 @@ +# FileService + +File management operations for the OSAPI Object Store. Upload, list, inspect, +and delete files that can be deployed to agents via `Node.FileDeploy`. + +## Methods + +### Object Store + +| Method | Description | +| ------------------- | ----------------------------------- | +| `Upload(ctx, n, d)` | Upload file content to Object Store | +| `List(ctx)` | List all stored files | +| `Get(ctx, name)` | Get file metadata by name | +| `Delete(ctx, name)` | Delete a file from Object Store | + +### Node File Operations + +File deploy and status methods live on `NodeService` because they target a +specific host: + +| Method | Description | +| ------------------------------- | ----------------------------------- | +| `FileDeploy(ctx, opts)` | Deploy file to agent with SHA check | +| `FileStatus(ctx, target, path)` | Check deployed file status | + +## FileDeployOpts + +| Field | Type | Required | Description | +| ------------- | -------------- | -------- | ---------------------------------------- | +| `ObjectName` | string | Yes | Name of the file in the Object Store | +| `Path` | string | Yes | Destination path on the target host | +| `ContentType` | string | Yes | `"raw"` or `"template"` | +| `Mode` | string | No | File permission mode (e.g., `"0644"`) | +| `Owner` | string | No | File owner user | +| `Group` | string | No | File owner group | +| `Vars` | map[string]any | No | Template variables for `"template"` type | +| `Target` | string | Yes | Host target (see Targeting below) | + +## Usage + +```go +// Upload a file +resp, err := client.File.Upload(ctx, "nginx.conf", configBytes) + +// List all files +resp, err := client.File.List(ctx) + +// Get file metadata +resp, err := client.File.Get(ctx, "nginx.conf") + +// Delete a file +resp, err := client.File.Delete(ctx, "nginx.conf") + +// Deploy a raw file to a specific host +resp, err := client.Node.FileDeploy(ctx, osapi.FileDeployOpts{ + ObjectName: "nginx.conf", + Path: "/etc/nginx/nginx.conf", + ContentType: "raw", + Mode: "0644", + Owner: "root", + Group: "root", + Target: "web-01", +}) + +// Deploy a template file with variables +resp, err := client.Node.FileDeploy(ctx, osapi.FileDeployOpts{ + ObjectName: "app.conf.tmpl", + Path: "/etc/app/config.yaml", + ContentType: "template", + Vars: map[string]any{ + "port": 8080, + "debug": false, + }, + Target: "_all", +}) + +// Check file status on a host +resp, err := client.Node.FileStatus( + ctx, "web-01", "/etc/nginx/nginx.conf", +) +``` + +## Targeting + +`FileDeploy` and `FileStatus` accept any valid target: `_any`, `_all`, a +hostname, or a label selector (`key:value`). + +Object Store operations (`Upload`, `List`, `Get`, `Delete`) are server-side and +do not use targeting. + +## Idempotency + +`FileDeploy` compares the SHA-256 of the Object Store content against the +deployed file. If the hashes match, the file is not rewritten and the response +reports `Changed: false`. + +## Permissions + +Object Store operations require `file:read` (list, get) or `file:write` (upload, +delete). Deploy requires `file:write`. Status requires `file:read`. diff --git a/docs/osapi/node.md b/docs/osapi/node.md index e6af8a1..66d5d64 100644 --- a/docs/osapi/node.md +++ b/docs/osapi/node.md @@ -33,6 +33,16 @@ all target a specific host. | `Exec(ctx, req)` | Execute a command directly (no shell) | | `Shell(ctx, req)` | Execute via `/bin/sh -c` (pipes, redirects) | +### File + +| Method | Description | +| ------------------------------- | ----------------------------------- | +| `FileDeploy(ctx, opts)` | Deploy file to agent with SHA check | +| `FileStatus(ctx, target, path)` | Check deployed file status | + +See [`FileService`](file.md) for Object Store operations (upload, list, get, +delete) and `FileDeployOpts` details. + ## Usage ```go @@ -61,9 +71,24 @@ resp, err := client.Node.Shell(ctx, osapi.ShellRequest{ Command: "ps aux | grep nginx", Target: "_any", }) + +// Deploy a file +resp, err := client.Node.FileDeploy(ctx, osapi.FileDeployOpts{ + ObjectName: "nginx.conf", + Path: "/etc/nginx/nginx.conf", + ContentType: "raw", + Mode: "0644", + Target: "web-01", +}) + +// Check file status +resp, err := client.Node.FileStatus( + ctx, "web-01", "/etc/nginx/nginx.conf", +) ``` ## Permissions Node info requires `node:read`. Network read requires `network:read`. DNS -updates require `network:write`. Commands require `command:execute`. +updates require `network:write`. Commands require `command:execute`. File deploy +requires `file:write`. File status requires `file:read`. From c08c5ef78b8dec7481707d985beb7ff3aaaa3da2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D7=A0=CF=85=CE=B1=CE=B7=20=D7=A0=CF=85=CE=B1=CE=B7=D1=95?= =?UTF-8?q?=CF=83=CE=B7?= Date: Fri, 6 Mar 2026 12:56:09 -0800 Subject: [PATCH 3/3] feat: add file management and deploy examples MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add SDK client example demonstrating file upload, list, get, deploy, status, and delete. Add orchestration example showing upload → deploy template → verify status DAG workflow. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- README.md | 2 + examples/orchestration/file-deploy/go.mod | 20 ++++ examples/orchestration/file-deploy/go.sum | 39 +++++++ examples/orchestration/file-deploy/main.go | 121 +++++++++++++++++++++ examples/osapi/file/go.mod | 20 ++++ examples/osapi/file/go.sum | 39 +++++++ examples/osapi/file/main.go | 112 +++++++++++++++++++ 7 files changed, 353 insertions(+) create mode 100644 examples/orchestration/file-deploy/go.mod create mode 100644 examples/orchestration/file-deploy/go.sum create mode 100644 examples/orchestration/file-deploy/main.go create mode 100644 examples/osapi/file/go.mod create mode 100644 examples/osapi/file/go.sum create mode 100644 examples/osapi/file/main.go diff --git a/README.md b/README.md index 51d571e..63c4c40 100644 --- a/README.md +++ b/README.md @@ -101,6 +101,7 @@ Each example is a standalone Go program you can read and run. | [agent](examples/osapi/agent/main.go) | Agent discovery, details, and facts | | [audit](examples/osapi/audit/main.go) | Audit log listing, get, and export | | [command](examples/osapi/command/main.go) | Command exec and shell execution | +| [file](examples/osapi/file/main.go) | File upload, deploy, status, and delete | | [health](examples/osapi/health/main.go) | Liveness, readiness, and status checks | | [job](examples/osapi/job/main.go) | Job create, get, list, delete, and retry | | [metrics](examples/osapi/metrics/main.go) | Prometheus metrics retrieval | @@ -114,6 +115,7 @@ Each example is a standalone Go program you can read and run. | [basic](examples/orchestration/basic/main.go) | Simple DAG with dependencies | | [broadcast](examples/orchestration/broadcast/main.go) | Multi-target operations with per-host results | | [error-strategy](examples/orchestration/error-strategy/main.go) | StopAll vs Continue error handling | +| [file-deploy](examples/orchestration/file-deploy/main.go) | Upload, deploy template, verify status | | [guards](examples/orchestration/guards/main.go) | When predicates for conditional execution | | [hooks](examples/orchestration/hooks/main.go) | Lifecycle callbacks for logging and progress | | [only-if-changed](examples/orchestration/only-if-changed/main.go) | Skip tasks when dependencies report no changes | diff --git a/examples/orchestration/file-deploy/go.mod b/examples/orchestration/file-deploy/go.mod new file mode 100644 index 0000000..58a4e81 --- /dev/null +++ b/examples/orchestration/file-deploy/go.mod @@ -0,0 +1,20 @@ +module github.com/osapi-io/osapi-sdk/examples/orchestration/file-deploy + +go 1.25.7 + +replace github.com/osapi-io/osapi-sdk => ../../.. + +require github.com/osapi-io/osapi-sdk v0.0.0-00010101000000-000000000000 + +require ( + github.com/apapsch/go-jsonmerge/v2 v2.0.0 // indirect + github.com/cespare/xxhash/v2 v2.3.0 // indirect + github.com/go-logr/logr v1.4.3 // indirect + github.com/go-logr/stdr v1.2.2 // indirect + github.com/google/uuid v1.6.0 // indirect + github.com/oapi-codegen/runtime v1.2.0 // indirect + go.opentelemetry.io/auto/sdk v1.2.1 // indirect + go.opentelemetry.io/otel v1.41.0 // indirect + go.opentelemetry.io/otel/metric v1.41.0 // indirect + go.opentelemetry.io/otel/trace v1.41.0 // indirect +) diff --git a/examples/orchestration/file-deploy/go.sum b/examples/orchestration/file-deploy/go.sum new file mode 100644 index 0000000..96b22a6 --- /dev/null +++ b/examples/orchestration/file-deploy/go.sum @@ -0,0 +1,39 @@ +github.com/RaveNoX/go-jsoncommentstrip v1.0.0/go.mod h1:78ihd09MekBnJnxpICcwzCMzGrKSKYe4AqU6PDYYpjk= +github.com/apapsch/go-jsonmerge/v2 v2.0.0 h1:axGnT1gRIfimI7gJifB699GoE/oq+F2MU7Dml6nw9rQ= +github.com/apapsch/go-jsonmerge/v2 v2.0.0/go.mod h1:lvDnEdqiQrp0O42VQGgmlKpxL1AP2+08jFMw88y4klk= +github.com/bmatcuk/doublestar v1.1.1/go.mod h1:UD6OnuiIn0yFxxA2le/rnRU1G4RaI4UvFv1sNto9p6w= +github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs= +github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM= +github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= +github.com/go-logr/logr v1.4.3 h1:CjnDlHq8ikf6E492q6eKboGOC0T8CDaOvkHCIg8idEI= +github.com/go-logr/logr v1.4.3/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= +github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= +github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= +github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= +github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= +github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= +github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/juju/gnuflag v0.0.0-20171113085948-2ce1bb71843d/go.mod h1:2PavIy+JPciBPrBUjwbNvtwB6RQlve+hkpll6QSNmOE= +github.com/oapi-codegen/runtime v1.2.0 h1:RvKc1CVS1QeKSNzO97FBQbSMZyQ8s6rZd+LpmzwHMP4= +github.com/oapi-codegen/runtime v1.2.0/go.mod h1:Y7ZhmmlE8ikZOmuHRRndiIm7nf3xcVv+YMweKgG1DT0= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U= +github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/spkg/bom v0.0.0-20160624110644-59b7046e48ad/go.mod h1:qLr4V1qq6nMqFKkMo8ZTx3f+BZEkzsRUY10Xsm2mwU0= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= +github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U= +github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U= +go.opentelemetry.io/auto/sdk v1.2.1 h1:jXsnJ4Lmnqd11kwkBV2LgLoFMZKizbCi5fNZ/ipaZ64= +go.opentelemetry.io/auto/sdk v1.2.1/go.mod h1:KRTj+aOaElaLi+wW1kO/DZRXwkF4C5xPbEe3ZiIhN7Y= +go.opentelemetry.io/otel v1.41.0 h1:YlEwVsGAlCvczDILpUXpIpPSL/VPugt7zHThEMLce1c= +go.opentelemetry.io/otel v1.41.0/go.mod h1:Yt4UwgEKeT05QbLwbyHXEwhnjxNO6D8L5PQP51/46dE= +go.opentelemetry.io/otel/metric v1.41.0 h1:rFnDcs4gRzBcsO9tS8LCpgR0dxg4aaxWlJxCno7JlTQ= +go.opentelemetry.io/otel/metric v1.41.0/go.mod h1:xPvCwd9pU0VN8tPZYzDZV/BMj9CM9vs00GuBjeKhJps= +go.opentelemetry.io/otel/trace v1.41.0 h1:Vbk2co6bhj8L59ZJ6/xFTskY+tGAbOnCtQGVVa9TIN0= +go.opentelemetry.io/otel/trace v1.41.0/go.mod h1:U1NU4ULCoxeDKc09yCWdWe+3QoyweJcISEVa1RBzOis= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/examples/orchestration/file-deploy/main.go b/examples/orchestration/file-deploy/main.go new file mode 100644 index 0000000..9158e2d --- /dev/null +++ b/examples/orchestration/file-deploy/main.go @@ -0,0 +1,121 @@ +// Copyright (c) 2026 John Dewey + +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to +// deal in the Software without restriction, including without limitation the +// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: + +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. + +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +// DEALINGS IN THE SOFTWARE. + +// Package main demonstrates file deployment orchestration: upload a +// template file, deploy to all agents with template rendering, then +// verify status. +// +// DAG: +// +// upload-template +// └── deploy-config +// └── verify-status +// +// Run with: OSAPI_TOKEN="" go run main.go +package main + +import ( + "context" + "fmt" + "log" + "os" + + "github.com/osapi-io/osapi-sdk/pkg/orchestrator" + "github.com/osapi-io/osapi-sdk/pkg/osapi" +) + +func main() { + url := os.Getenv("OSAPI_URL") + if url == "" { + url = "http://localhost:8080" + } + + token := os.Getenv("OSAPI_TOKEN") + if token == "" { + log.Fatal("OSAPI_TOKEN is required") + } + + client := osapi.New(url, token) + + hooks := orchestrator.Hooks{ + BeforeTask: func(task *orchestrator.Task) { + fmt.Printf(" [start] %s\n", task.Name()) + }, + AfterTask: func(_ *orchestrator.Task, result orchestrator.TaskResult) { + fmt.Printf(" [%s] %s changed=%v\n", + result.Status, result.Name, result.Changed) + }, + } + + plan := orchestrator.NewPlan(client, orchestrator.WithHooks(hooks)) + + // Step 1: Upload the template file to Object Store. + upload := plan.TaskFunc( + "upload-template", + func(ctx context.Context, c *osapi.Client) (*orchestrator.Result, error) { + tmpl := []byte(`# Generated for {{ .Hostname }} +listen_address = {{ .Vars.listen_address }} +workers = {{ .Facts.cpu_count }} +`) + resp, err := c.File.Upload(ctx, "app.conf.tmpl", tmpl) + if err != nil { + return nil, fmt.Errorf("upload: %w", err) + } + + fmt.Printf(" uploaded %s (sha256=%s)\n", + resp.Data.Name, resp.Data.SHA256) + + return &orchestrator.Result{Changed: true}, nil + }, + ) + + // Step 2: Deploy the template to all agents. + deploy := plan.Task("deploy-config", &orchestrator.Op{ + Operation: "file.deploy.execute", + Target: "_all", + Params: map[string]any{ + "object_name": "app.conf.tmpl", + "path": "/etc/app/app.conf", + "content_type": "template", + "mode": "0644", + "vars": map[string]any{ + "listen_address": "0.0.0.0:8080", + }, + }, + }) + deploy.DependsOn(upload) + + // Step 3: Verify the deployed file is in-sync. + verify := plan.Task("verify-status", &orchestrator.Op{ + Operation: "file.status.get", + Target: "_all", + Params: map[string]any{ + "path": "/etc/app/app.conf", + }, + }) + verify.DependsOn(deploy) + + report, err := plan.Run(context.Background()) + if err != nil { + log.Fatal(err) + } + + fmt.Printf("\n%s in %s\n", report.Summary(), report.Duration) +} diff --git a/examples/osapi/file/go.mod b/examples/osapi/file/go.mod new file mode 100644 index 0000000..14440f4 --- /dev/null +++ b/examples/osapi/file/go.mod @@ -0,0 +1,20 @@ +module github.com/osapi-io/osapi-sdk/examples/osapi/file + +go 1.25.7 + +replace github.com/osapi-io/osapi-sdk => ../../.. + +require github.com/osapi-io/osapi-sdk v0.0.0-00010101000000-000000000000 + +require ( + github.com/apapsch/go-jsonmerge/v2 v2.0.0 // indirect + github.com/cespare/xxhash/v2 v2.3.0 // indirect + github.com/go-logr/logr v1.4.3 // indirect + github.com/go-logr/stdr v1.2.2 // indirect + github.com/google/uuid v1.6.0 // indirect + github.com/oapi-codegen/runtime v1.2.0 // indirect + go.opentelemetry.io/auto/sdk v1.2.1 // indirect + go.opentelemetry.io/otel v1.41.0 // indirect + go.opentelemetry.io/otel/metric v1.41.0 // indirect + go.opentelemetry.io/otel/trace v1.41.0 // indirect +) diff --git a/examples/osapi/file/go.sum b/examples/osapi/file/go.sum new file mode 100644 index 0000000..96b22a6 --- /dev/null +++ b/examples/osapi/file/go.sum @@ -0,0 +1,39 @@ +github.com/RaveNoX/go-jsoncommentstrip v1.0.0/go.mod h1:78ihd09MekBnJnxpICcwzCMzGrKSKYe4AqU6PDYYpjk= +github.com/apapsch/go-jsonmerge/v2 v2.0.0 h1:axGnT1gRIfimI7gJifB699GoE/oq+F2MU7Dml6nw9rQ= +github.com/apapsch/go-jsonmerge/v2 v2.0.0/go.mod h1:lvDnEdqiQrp0O42VQGgmlKpxL1AP2+08jFMw88y4klk= +github.com/bmatcuk/doublestar v1.1.1/go.mod h1:UD6OnuiIn0yFxxA2le/rnRU1G4RaI4UvFv1sNto9p6w= +github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs= +github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM= +github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= +github.com/go-logr/logr v1.4.3 h1:CjnDlHq8ikf6E492q6eKboGOC0T8CDaOvkHCIg8idEI= +github.com/go-logr/logr v1.4.3/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= +github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= +github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= +github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= +github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= +github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= +github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/juju/gnuflag v0.0.0-20171113085948-2ce1bb71843d/go.mod h1:2PavIy+JPciBPrBUjwbNvtwB6RQlve+hkpll6QSNmOE= +github.com/oapi-codegen/runtime v1.2.0 h1:RvKc1CVS1QeKSNzO97FBQbSMZyQ8s6rZd+LpmzwHMP4= +github.com/oapi-codegen/runtime v1.2.0/go.mod h1:Y7ZhmmlE8ikZOmuHRRndiIm7nf3xcVv+YMweKgG1DT0= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U= +github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/spkg/bom v0.0.0-20160624110644-59b7046e48ad/go.mod h1:qLr4V1qq6nMqFKkMo8ZTx3f+BZEkzsRUY10Xsm2mwU0= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= +github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U= +github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U= +go.opentelemetry.io/auto/sdk v1.2.1 h1:jXsnJ4Lmnqd11kwkBV2LgLoFMZKizbCi5fNZ/ipaZ64= +go.opentelemetry.io/auto/sdk v1.2.1/go.mod h1:KRTj+aOaElaLi+wW1kO/DZRXwkF4C5xPbEe3ZiIhN7Y= +go.opentelemetry.io/otel v1.41.0 h1:YlEwVsGAlCvczDILpUXpIpPSL/VPugt7zHThEMLce1c= +go.opentelemetry.io/otel v1.41.0/go.mod h1:Yt4UwgEKeT05QbLwbyHXEwhnjxNO6D8L5PQP51/46dE= +go.opentelemetry.io/otel/metric v1.41.0 h1:rFnDcs4gRzBcsO9tS8LCpgR0dxg4aaxWlJxCno7JlTQ= +go.opentelemetry.io/otel/metric v1.41.0/go.mod h1:xPvCwd9pU0VN8tPZYzDZV/BMj9CM9vs00GuBjeKhJps= +go.opentelemetry.io/otel/trace v1.41.0 h1:Vbk2co6bhj8L59ZJ6/xFTskY+tGAbOnCtQGVVa9TIN0= +go.opentelemetry.io/otel/trace v1.41.0/go.mod h1:U1NU4ULCoxeDKc09yCWdWe+3QoyweJcISEVa1RBzOis= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/examples/osapi/file/main.go b/examples/osapi/file/main.go new file mode 100644 index 0000000..0eb4342 --- /dev/null +++ b/examples/osapi/file/main.go @@ -0,0 +1,112 @@ +// Copyright (c) 2026 John Dewey + +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to +// deal in the Software without restriction, including without limitation the +// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: + +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. + +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +// DEALINGS IN THE SOFTWARE. + +// Package main demonstrates file management: upload, list, get metadata, +// deploy to an agent, check status, and delete. +// +// Run with: OSAPI_TOKEN="" go run main.go +package main + +import ( + "context" + "fmt" + "log" + "os" + + "github.com/osapi-io/osapi-sdk/pkg/osapi" +) + +func main() { + url := os.Getenv("OSAPI_URL") + if url == "" { + url = "http://localhost:8080" + } + + token := os.Getenv("OSAPI_TOKEN") + if token == "" { + log.Fatal("OSAPI_TOKEN is required") + } + + client := osapi.New(url, token) + ctx := context.Background() + + // Upload a file to the Object Store. + content := []byte("listen_address = 0.0.0.0:8080\nworkers = 4\n") + upload, err := client.File.Upload(ctx, "app.conf", content) + if err != nil { + log.Fatalf("upload: %v", err) + } + + fmt.Printf("Uploaded: name=%s sha256=%s size=%d\n", + upload.Data.Name, upload.Data.SHA256, upload.Data.Size) + + // List all stored files. + list, err := client.File.List(ctx) + if err != nil { + log.Fatalf("list: %v", err) + } + + fmt.Printf("\nStored files (%d):\n", list.Data.Total) + for _, f := range list.Data.Files { + fmt.Printf(" %s size=%d\n", f.Name, f.Size) + } + + // Get metadata for a specific file. + meta, err := client.File.Get(ctx, "app.conf") + if err != nil { + log.Fatalf("get: %v", err) + } + + fmt.Printf("\nMetadata: name=%s sha256=%s size=%d\n", + meta.Data.Name, meta.Data.SHA256, meta.Data.Size) + + // Deploy the file to an agent. + deploy, err := client.Node.FileDeploy(ctx, osapi.FileDeployOpts{ + ObjectName: "app.conf", + Path: "/etc/app/app.conf", + ContentType: "raw", + Mode: "0644", + Target: "_any", + }) + if err != nil { + log.Fatalf("deploy: %v", err) + } + + fmt.Printf("\nDeploy: job=%s host=%s changed=%v\n", + deploy.Data.JobID, deploy.Data.Hostname, deploy.Data.Changed) + + // Check file status on the agent. + status, err := client.Node.FileStatus(ctx, "_any", "/etc/app/app.conf") + if err != nil { + log.Fatalf("status: %v", err) + } + + fmt.Printf("Status: path=%s status=%s\n", + status.Data.Path, status.Data.Status) + + // Clean up — delete the file from the Object Store. + del, err := client.File.Delete(ctx, "app.conf") + if err != nil { + log.Fatalf("delete: %v", err) + } + + fmt.Printf("\nDeleted: name=%s deleted=%v\n", + del.Data.Name, del.Data.Deleted) +}