From d591423a489d45c383f8c2b32c4211fe9046a3cf Mon Sep 17 00:00:00 2001 From: Michel Laterman <82832767+michel-laterman@users.noreply.github.com> Date: Wed, 18 Oct 2023 11:10:35 -0700 Subject: [PATCH] Add Elastic-Api-Version and X-Request-Id headers in openapi spec (#3044) Add doc.go files for minimal information on generated client apis (what they are generated from). Add missing headers to all req/resp in the openapi spec for the current implementation in `model/openapi.yml`. Add an `openapi.yml` spec file for the `2023-06-01` based off commit 1d28f4ca4ec62f940771e5eb72b77699d256525f with the missing headers (and version defined in the spec). Correct the directory name for the versioned client. --- ...3-Add-missing-headers-to-openapi-spec.yaml | 32 + internal/pkg/api/api.go | 4 +- internal/pkg/api/apiVersion.go | 1 + internal/pkg/api/openapi.gen.go | 260 ++- model/openapi.yml | 138 +- pkg/api/client.gen.go | 128 +- pkg/api/doc.go | 7 + pkg/api/types.gen.go | 50 +- .../api/client.gen.go | 120 +- pkg/api/versions/2023_06_01/api/doc.go | 10 + pkg/api/versions/2023_06_01/api/openapi.yml | 1427 +++++++++++++++++ .../api/types.gen.go | 57 +- .../e2e/api_version/client_api_2023_06_01.go | 2 +- testing/e2e/api_version/client_api_current.go | 2 +- 14 files changed, 2024 insertions(+), 214 deletions(-) create mode 100644 changelog/fragments/1697650203-Add-missing-headers-to-openapi-spec.yaml create mode 100644 pkg/api/doc.go rename pkg/api/versions/{2022_06_01 => 2023_06_01}/api/client.gen.go (94%) create mode 100644 pkg/api/versions/2023_06_01/api/doc.go create mode 100644 pkg/api/versions/2023_06_01/api/openapi.yml rename pkg/api/versions/{2022_06_01 => 2023_06_01}/api/types.gen.go (94%) diff --git a/changelog/fragments/1697650203-Add-missing-headers-to-openapi-spec.yaml b/changelog/fragments/1697650203-Add-missing-headers-to-openapi-spec.yaml new file mode 100644 index 000000000..65abacada --- /dev/null +++ b/changelog/fragments/1697650203-Add-missing-headers-to-openapi-spec.yaml @@ -0,0 +1,32 @@ +# Kind can be one of: +# - breaking-change: a change to previously-documented behavior +# - deprecation: functionality that is being removed in a later release +# - bug-fix: fixes a problem in a previous version +# - enhancement: extends functionality but does not break or fix existing behavior +# - feature: new functionality +# - known-issue: problems that we are aware of in a given version +# - security: impacts on the security of a product or a user’s deployment. +# - upgrade: important information for someone upgrading from a prior version +# - other: does not fit into any of the other categories +kind: other + +# Change summary; a 80ish characters long description of the change. +summary: Add missing headers to openapi spec + +# Long description; in case the summary is not enough to describe the change +# this field accommodate a description without length limits. +# NOTE: This field will be rendered only for breaking-change and known-issue kinds at the moment. +description: Add missing Elastic-Api-Version and X-Request-Id headers across all req/resp in the openapi spec and generated clients. + +# Affected component; a word indicating the component this changeset affects. +component: + +# PR URL; optional; the PR number that added the changeset. +# If not present is automatically filled by the tooling finding the PR where this changelog fragment has been added. +# NOTE: the tooling supports backports, so it's able to fill the original PR number instead of the backport PR number. +# Please provide it if you are adding a fragment for a different PR. +#pr: https://github.com/owner/repo/1234 + +# Issue URL; optional; the GitHub issue related to this changeset (either closes or is part of). +# If not present is automatically filled by the tooling with the issue linked to the PR number. +#issue: https://github.com/owner/repo/1234 diff --git a/internal/pkg/api/api.go b/internal/pkg/api/api.go index e441b405f..3a8c0c045 100644 --- a/internal/pkg/api/api.go +++ b/internal/pkg/api/api.go @@ -130,7 +130,7 @@ func (a *apiServer) UploadChunk(w http.ResponseWriter, r *http.Request, id strin } } -func (a *apiServer) GetFile(w http.ResponseWriter, r *http.Request, id string) { +func (a *apiServer) GetFile(w http.ResponseWriter, r *http.Request, id string, params GetFileParams) { zlog := hlog.FromRequest(r).With().Logger() if err := a.ft.handleSendFile(zlog, w, r, id); err != nil { cntFileDeliv.IncError(err) @@ -139,7 +139,7 @@ func (a *apiServer) GetFile(w http.ResponseWriter, r *http.Request, id string) { } } -func (a *apiServer) GetPGPKey(w http.ResponseWriter, r *http.Request, major, minor, patch int) { +func (a *apiServer) GetPGPKey(w http.ResponseWriter, r *http.Request, major, minor, patch int, params GetPGPKeyParams) { zlog := hlog.FromRequest(r).With().Logger() if err := a.pt.handlePGPKey(zlog, w, r, major, minor, patch); err != nil { cntGetPGP.IncError(err) diff --git a/internal/pkg/api/apiVersion.go b/internal/pkg/api/apiVersion.go index 4662b8888..e54566b7a 100644 --- a/internal/pkg/api/apiVersion.go +++ b/internal/pkg/api/apiVersion.go @@ -62,6 +62,7 @@ func (a *apiVersion) middleware(next http.Handler) http.Handler { if headerValue != "" { err := a.validateVersionFormat(headerValue) if err != nil { + w.Header().Add(ElasticAPIVersionHeader, a.defaultVersion) ErrorResp(w, r, err) return } diff --git a/internal/pkg/api/openapi.gen.go b/internal/pkg/api/openapi.gen.go index 3737da642..16f0bc025 100644 --- a/internal/pkg/api/openapi.gen.go +++ b/internal/pkg/api/openapi.gen.go @@ -612,6 +612,15 @@ type Throttle = Error // Unavailable Error processing request. type Unavailable = Error +// GetPGPKeyParams defines parameters for GetPGPKey. +type GetPGPKeyParams struct { + // ElasticApiVersion The API version to use, format should be "YYYY-MM-DD" + ElasticApiVersion *ApiVersion `json:"elastic-api-version,omitempty"` + + // XRequestId The request tracking ID for APM. + XRequestId *RequestId `json:"X-Request-Id,omitempty"` +} + // AgentEnrollParams defines parameters for AgentEnroll. type AgentEnrollParams struct { // UserAgent The user-agent header that is sent. @@ -619,8 +628,8 @@ type AgentEnrollParams struct { // The agent version must not be greater than the version of the fleet-server. UserAgent UserAgent `json:"User-Agent"` - // XRequestID The request tracking ID for APM. - XRequestID *RequestId `json:"X-Request-ID,omitempty"` + // XRequestId The request tracking ID for APM. + XRequestId *RequestId `json:"X-Request-Id,omitempty"` // ElasticApiVersion The API version to use, format should be "YYYY-MM-DD" ElasticApiVersion *ApiVersion `json:"elastic-api-version,omitempty"` @@ -628,8 +637,8 @@ type AgentEnrollParams struct { // AgentAcksParams defines parameters for AgentAcks. type AgentAcksParams struct { - // XRequestID The request tracking ID for APM. - XRequestID *RequestId `json:"X-Request-ID,omitempty"` + // XRequestId The request tracking ID for APM. + XRequestId *RequestId `json:"X-Request-Id,omitempty"` // ElasticApiVersion The API version to use, format should be "YYYY-MM-DD" ElasticApiVersion *ApiVersion `json:"elastic-api-version,omitempty"` @@ -647,8 +656,8 @@ type AgentCheckinParams struct { // The agent version must not be greater than the version of the fleet-server. UserAgent UserAgent `json:"User-Agent"` - // XRequestID The request tracking ID for APM. - XRequestID *RequestId `json:"X-Request-ID,omitempty"` + // XRequestId The request tracking ID for APM. + XRequestId *RequestId `json:"X-Request-Id,omitempty"` // ElasticApiVersion The API version to use, format should be "YYYY-MM-DD" ElasticApiVersion *ApiVersion `json:"elastic-api-version,omitempty"` @@ -656,17 +665,26 @@ type AgentCheckinParams struct { // ArtifactParams defines parameters for Artifact. type ArtifactParams struct { - // XRequestID The request tracking ID for APM. - XRequestID *RequestId `json:"X-Request-ID,omitempty"` + // XRequestId The request tracking ID for APM. + XRequestId *RequestId `json:"X-Request-Id,omitempty"` // ElasticApiVersion The API version to use, format should be "YYYY-MM-DD" ElasticApiVersion *ApiVersion `json:"elastic-api-version,omitempty"` } +// GetFileParams defines parameters for GetFile. +type GetFileParams struct { + // ElasticApiVersion The API version to use, format should be "YYYY-MM-DD" + ElasticApiVersion *ApiVersion `json:"elastic-api-version,omitempty"` + + // XRequestId The request tracking ID for APM. + XRequestId *RequestId `json:"X-Request-Id,omitempty"` +} + // UploadBeginParams defines parameters for UploadBegin. type UploadBeginParams struct { - // XRequestID The request tracking ID for APM. - XRequestID *RequestId `json:"X-Request-ID,omitempty"` + // XRequestId The request tracking ID for APM. + XRequestId *RequestId `json:"X-Request-Id,omitempty"` // ElasticApiVersion The API version to use, format should be "YYYY-MM-DD" ElasticApiVersion *ApiVersion `json:"elastic-api-version,omitempty"` @@ -674,8 +692,8 @@ type UploadBeginParams struct { // UploadCompleteParams defines parameters for UploadComplete. type UploadCompleteParams struct { - // XRequestID The request tracking ID for APM. - XRequestID *RequestId `json:"X-Request-ID,omitempty"` + // XRequestId The request tracking ID for APM. + XRequestId *RequestId `json:"X-Request-Id,omitempty"` // ElasticApiVersion The API version to use, format should be "YYYY-MM-DD" ElasticApiVersion *ApiVersion `json:"elastic-api-version,omitempty"` @@ -686,8 +704,8 @@ type UploadChunkParams struct { // XChunkSHA2 the SHA256 hash of the body contents for this request XChunkSHA2 string `json:"X-Chunk-SHA2"` - // XRequestID The request tracking ID for APM. - XRequestID *RequestId `json:"X-Request-ID,omitempty"` + // XRequestId The request tracking ID for APM. + XRequestId *RequestId `json:"X-Request-Id,omitempty"` // ElasticApiVersion The API version to use, format should be "YYYY-MM-DD" ElasticApiVersion *ApiVersion `json:"elastic-api-version,omitempty"` @@ -695,8 +713,8 @@ type UploadChunkParams struct { // StatusParams defines parameters for Status. type StatusParams struct { - // XRequestID The request tracking ID for APM. - XRequestID *RequestId `json:"X-Request-ID,omitempty"` + // XRequestId The request tracking ID for APM. + XRequestId *RequestId `json:"X-Request-Id,omitempty"` // ElasticApiVersion The API version to use, format should be "YYYY-MM-DD" ElasticApiVersion *ApiVersion `json:"elastic-api-version,omitempty"` @@ -1036,7 +1054,7 @@ func (t *UpgradeDetails_Metadata) UnmarshalJSON(b []byte) error { type ServerInterface interface { // retrieve a PGP key from the fleet-server's local storage. // (GET /api/agents/upgrades/{major}.{minor}.{patch}/pgp-public-key) - GetPGPKey(w http.ResponseWriter, r *http.Request, major int, minor int, patch int) + GetPGPKey(w http.ResponseWriter, r *http.Request, major int, minor int, patch int, params GetPGPKeyParams) // (POST /api/fleet/agents/enroll) AgentEnroll(w http.ResponseWriter, r *http.Request, params AgentEnrollParams) @@ -1051,7 +1069,7 @@ type ServerInterface interface { Artifact(w http.ResponseWriter, r *http.Request, id string, sha2 string, params ArtifactParams) // retrieve stored file for integration // (GET /api/fleet/file/{id}) - GetFile(w http.ResponseWriter, r *http.Request, id string) + GetFile(w http.ResponseWriter, r *http.Request, id string, params GetFileParams) // Initiate a file upload process // (POST /api/fleet/uploads) UploadBegin(w http.ResponseWriter, r *http.Request, params UploadBeginParams) @@ -1072,7 +1090,7 @@ type Unimplemented struct{} // retrieve a PGP key from the fleet-server's local storage. // (GET /api/agents/upgrades/{major}.{minor}.{patch}/pgp-public-key) -func (_ Unimplemented) GetPGPKey(w http.ResponseWriter, r *http.Request, major int, minor int, patch int) { +func (_ Unimplemented) GetPGPKey(w http.ResponseWriter, r *http.Request, major int, minor int, patch int, params GetPGPKeyParams) { w.WriteHeader(http.StatusNotImplemented) } @@ -1098,7 +1116,7 @@ func (_ Unimplemented) Artifact(w http.ResponseWriter, r *http.Request, id strin // retrieve stored file for integration // (GET /api/fleet/file/{id}) -func (_ Unimplemented) GetFile(w http.ResponseWriter, r *http.Request, id string) { +func (_ Unimplemented) GetFile(w http.ResponseWriter, r *http.Request, id string, params GetFileParams) { w.WriteHeader(http.StatusNotImplemented) } @@ -1169,8 +1187,51 @@ func (siw *ServerInterfaceWrapper) GetPGPKey(w http.ResponseWriter, r *http.Requ ctx = context.WithValue(ctx, ApiKeyScopes, []string{}) + // Parameter object where we will unmarshal all parameters from the context + var params GetPGPKeyParams + + headers := r.Header + + // ------------- Optional header parameter "elastic-api-version" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("elastic-api-version")]; found { + var ElasticApiVersion ApiVersion + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "elastic-api-version", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "elastic-api-version", runtime.ParamLocationHeader, valueList[0], &ElasticApiVersion) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "elastic-api-version", Err: err}) + return + } + + params.ElasticApiVersion = &ElasticApiVersion + + } + + // ------------- Optional header parameter "X-Request-Id" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("X-Request-Id")]; found { + var XRequestId RequestId + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "X-Request-Id", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "X-Request-Id", runtime.ParamLocationHeader, valueList[0], &XRequestId) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "X-Request-Id", Err: err}) + return + } + + params.XRequestId = &XRequestId + + } + handler := http.Handler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - siw.Handler.GetPGPKey(w, r, major, minor, patch) + siw.Handler.GetPGPKey(w, r, major, minor, patch, params) })) for _, middleware := range siw.HandlerMiddlewares { @@ -1216,22 +1277,22 @@ func (siw *ServerInterfaceWrapper) AgentEnroll(w http.ResponseWriter, r *http.Re return } - // ------------- Optional header parameter "X-Request-ID" ------------- - if valueList, found := headers[http.CanonicalHeaderKey("X-Request-ID")]; found { - var XRequestID RequestId + // ------------- Optional header parameter "X-Request-Id" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("X-Request-Id")]; found { + var XRequestId RequestId n := len(valueList) if n != 1 { - siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "X-Request-ID", Count: n}) + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "X-Request-Id", Count: n}) return } - err = runtime.BindStyledParameterWithLocation("simple", false, "X-Request-ID", runtime.ParamLocationHeader, valueList[0], &XRequestID) + err = runtime.BindStyledParameterWithLocation("simple", false, "X-Request-Id", runtime.ParamLocationHeader, valueList[0], &XRequestId) if err != nil { - siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "X-Request-ID", Err: err}) + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "X-Request-Id", Err: err}) return } - params.XRequestID = &XRequestID + params.XRequestId = &XRequestId } @@ -1287,22 +1348,22 @@ func (siw *ServerInterfaceWrapper) AgentAcks(w http.ResponseWriter, r *http.Requ headers := r.Header - // ------------- Optional header parameter "X-Request-ID" ------------- - if valueList, found := headers[http.CanonicalHeaderKey("X-Request-ID")]; found { - var XRequestID RequestId + // ------------- Optional header parameter "X-Request-Id" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("X-Request-Id")]; found { + var XRequestId RequestId n := len(valueList) if n != 1 { - siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "X-Request-ID", Count: n}) + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "X-Request-Id", Count: n}) return } - err = runtime.BindStyledParameterWithLocation("simple", false, "X-Request-ID", runtime.ParamLocationHeader, valueList[0], &XRequestID) + err = runtime.BindStyledParameterWithLocation("simple", false, "X-Request-Id", runtime.ParamLocationHeader, valueList[0], &XRequestId) if err != nil { - siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "X-Request-ID", Err: err}) + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "X-Request-Id", Err: err}) return } - params.XRequestID = &XRequestID + params.XRequestId = &XRequestId } @@ -1400,22 +1461,22 @@ func (siw *ServerInterfaceWrapper) AgentCheckin(w http.ResponseWriter, r *http.R return } - // ------------- Optional header parameter "X-Request-ID" ------------- - if valueList, found := headers[http.CanonicalHeaderKey("X-Request-ID")]; found { - var XRequestID RequestId + // ------------- Optional header parameter "X-Request-Id" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("X-Request-Id")]; found { + var XRequestId RequestId n := len(valueList) if n != 1 { - siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "X-Request-ID", Count: n}) + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "X-Request-Id", Count: n}) return } - err = runtime.BindStyledParameterWithLocation("simple", false, "X-Request-ID", runtime.ParamLocationHeader, valueList[0], &XRequestID) + err = runtime.BindStyledParameterWithLocation("simple", false, "X-Request-Id", runtime.ParamLocationHeader, valueList[0], &XRequestId) if err != nil { - siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "X-Request-ID", Err: err}) + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "X-Request-Id", Err: err}) return } - params.XRequestID = &XRequestID + params.XRequestId = &XRequestId } @@ -1480,22 +1541,22 @@ func (siw *ServerInterfaceWrapper) Artifact(w http.ResponseWriter, r *http.Reque headers := r.Header - // ------------- Optional header parameter "X-Request-ID" ------------- - if valueList, found := headers[http.CanonicalHeaderKey("X-Request-ID")]; found { - var XRequestID RequestId + // ------------- Optional header parameter "X-Request-Id" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("X-Request-Id")]; found { + var XRequestId RequestId n := len(valueList) if n != 1 { - siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "X-Request-ID", Count: n}) + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "X-Request-Id", Count: n}) return } - err = runtime.BindStyledParameterWithLocation("simple", false, "X-Request-ID", runtime.ParamLocationHeader, valueList[0], &XRequestID) + err = runtime.BindStyledParameterWithLocation("simple", false, "X-Request-Id", runtime.ParamLocationHeader, valueList[0], &XRequestId) if err != nil { - siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "X-Request-ID", Err: err}) + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "X-Request-Id", Err: err}) return } - params.XRequestID = &XRequestID + params.XRequestId = &XRequestId } @@ -1546,8 +1607,51 @@ func (siw *ServerInterfaceWrapper) GetFile(w http.ResponseWriter, r *http.Reques ctx = context.WithValue(ctx, AgentApiKeyScopes, []string{}) + // Parameter object where we will unmarshal all parameters from the context + var params GetFileParams + + headers := r.Header + + // ------------- Optional header parameter "elastic-api-version" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("elastic-api-version")]; found { + var ElasticApiVersion ApiVersion + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "elastic-api-version", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "elastic-api-version", runtime.ParamLocationHeader, valueList[0], &ElasticApiVersion) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "elastic-api-version", Err: err}) + return + } + + params.ElasticApiVersion = &ElasticApiVersion + + } + + // ------------- Optional header parameter "X-Request-Id" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("X-Request-Id")]; found { + var XRequestId RequestId + n := len(valueList) + if n != 1 { + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "X-Request-Id", Count: n}) + return + } + + err = runtime.BindStyledParameterWithLocation("simple", false, "X-Request-Id", runtime.ParamLocationHeader, valueList[0], &XRequestId) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "X-Request-Id", Err: err}) + return + } + + params.XRequestId = &XRequestId + + } + handler := http.Handler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - siw.Handler.GetFile(w, r, id) + siw.Handler.GetFile(w, r, id, params) })) for _, middleware := range siw.HandlerMiddlewares { @@ -1570,22 +1674,22 @@ func (siw *ServerInterfaceWrapper) UploadBegin(w http.ResponseWriter, r *http.Re headers := r.Header - // ------------- Optional header parameter "X-Request-ID" ------------- - if valueList, found := headers[http.CanonicalHeaderKey("X-Request-ID")]; found { - var XRequestID RequestId + // ------------- Optional header parameter "X-Request-Id" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("X-Request-Id")]; found { + var XRequestId RequestId n := len(valueList) if n != 1 { - siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "X-Request-ID", Count: n}) + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "X-Request-Id", Count: n}) return } - err = runtime.BindStyledParameterWithLocation("simple", false, "X-Request-ID", runtime.ParamLocationHeader, valueList[0], &XRequestID) + err = runtime.BindStyledParameterWithLocation("simple", false, "X-Request-Id", runtime.ParamLocationHeader, valueList[0], &XRequestId) if err != nil { - siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "X-Request-ID", Err: err}) + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "X-Request-Id", Err: err}) return } - params.XRequestID = &XRequestID + params.XRequestId = &XRequestId } @@ -1641,22 +1745,22 @@ func (siw *ServerInterfaceWrapper) UploadComplete(w http.ResponseWriter, r *http headers := r.Header - // ------------- Optional header parameter "X-Request-ID" ------------- - if valueList, found := headers[http.CanonicalHeaderKey("X-Request-ID")]; found { - var XRequestID RequestId + // ------------- Optional header parameter "X-Request-Id" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("X-Request-Id")]; found { + var XRequestId RequestId n := len(valueList) if n != 1 { - siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "X-Request-ID", Count: n}) + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "X-Request-Id", Count: n}) return } - err = runtime.BindStyledParameterWithLocation("simple", false, "X-Request-ID", runtime.ParamLocationHeader, valueList[0], &XRequestID) + err = runtime.BindStyledParameterWithLocation("simple", false, "X-Request-Id", runtime.ParamLocationHeader, valueList[0], &XRequestId) if err != nil { - siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "X-Request-ID", Err: err}) + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "X-Request-Id", Err: err}) return } - params.XRequestID = &XRequestID + params.XRequestId = &XRequestId } @@ -1744,22 +1848,22 @@ func (siw *ServerInterfaceWrapper) UploadChunk(w http.ResponseWriter, r *http.Re return } - // ------------- Optional header parameter "X-Request-ID" ------------- - if valueList, found := headers[http.CanonicalHeaderKey("X-Request-ID")]; found { - var XRequestID RequestId + // ------------- Optional header parameter "X-Request-Id" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("X-Request-Id")]; found { + var XRequestId RequestId n := len(valueList) if n != 1 { - siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "X-Request-ID", Count: n}) + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "X-Request-Id", Count: n}) return } - err = runtime.BindStyledParameterWithLocation("simple", false, "X-Request-ID", runtime.ParamLocationHeader, valueList[0], &XRequestID) + err = runtime.BindStyledParameterWithLocation("simple", false, "X-Request-Id", runtime.ParamLocationHeader, valueList[0], &XRequestId) if err != nil { - siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "X-Request-ID", Err: err}) + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "X-Request-Id", Err: err}) return } - params.XRequestID = &XRequestID + params.XRequestId = &XRequestId } @@ -1806,22 +1910,22 @@ func (siw *ServerInterfaceWrapper) Status(w http.ResponseWriter, r *http.Request headers := r.Header - // ------------- Optional header parameter "X-Request-ID" ------------- - if valueList, found := headers[http.CanonicalHeaderKey("X-Request-ID")]; found { - var XRequestID RequestId + // ------------- Optional header parameter "X-Request-Id" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("X-Request-Id")]; found { + var XRequestId RequestId n := len(valueList) if n != 1 { - siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "X-Request-ID", Count: n}) + siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "X-Request-Id", Count: n}) return } - err = runtime.BindStyledParameterWithLocation("simple", false, "X-Request-ID", runtime.ParamLocationHeader, valueList[0], &XRequestID) + err = runtime.BindStyledParameterWithLocation("simple", false, "X-Request-Id", runtime.ParamLocationHeader, valueList[0], &XRequestId) if err != nil { - siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "X-Request-ID", Err: err}) + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "X-Request-Id", Err: err}) return } - params.XRequestID = &XRequestID + params.XRequestId = &XRequestId } diff --git a/model/openapi.yml b/model/openapi.yml index 2138b3edc..e5a7a5280 100644 --- a/model/openapi.yml +++ b/model/openapi.yml @@ -1,7 +1,7 @@ openapi: 3.1.0 info: title: fleet-server API - version: 0.0.1 + version: 0000-00-00 license: name: Elastic License 2.0 url: https://www.elastic.co/licensing/elastic-license @@ -15,6 +15,18 @@ info: If an agent attempts to make request but there are no remaining connections, the attempt will be blocked and the agent will get an error. If an agent tries to send a body that is too large the fleet-server will respond with a 400 status code. components: + headers: + apiVersion: + description: The API version the server is using to respond. + schema: + type: string + examples: + "2023-06-01": + value: 2023-06-01 + requestID: + description: The X-Request-Id header used for tracing requests. + schema: + type: string securitySchemes: apiKey: description: API key security will check that the API key exists and is enabled, but will not check additional permissions @@ -766,7 +778,7 @@ components: - 83810fdc61c44290778c212d7829d0c3f0232e81bd551d3943998a920025d14f parameters: requestId: - name: X-Request-ID + name: X-Request-Id description: The request tracking ID for APM. in: header schema: @@ -777,6 +789,9 @@ components: in: header schema: type: string + examples: + "2023-06-01": + value: 2023-06-01 userAgent: name: User-Agent description: | @@ -804,7 +819,13 @@ components: badRequest: description: | A 400 response for receiving an invalid User-Agent, Elastic-Api-Version header or version number (checkin and enroll endpoints). + In the case where an invalid or unsupported Elastic-Api-Version header is requested, the response will contain the default version number. Or any other undefined error encounted by the fleet-server. May be returned by any endpoint except /api/fleet/status. + headers: + Elastic-Api-Version: + $ref: "#/components/headers/apiVersion" + X-Request-Id: + $ref: "#/components/headers/requestID" content: application/json: schema: @@ -819,6 +840,11 @@ components: internalServerError: description: | A 500 response for encountering not expected bahavior. + headers: + Elastic-Api-Version: + $ref: "#/components/headers/apiVersion" + X-Request-Id: + $ref: "#/components/headers/requestID" content: application/json: schema: @@ -832,6 +858,11 @@ components: error: InternalServerError keyNotEnabled: description: 401 response when the API key is not enabled on any endpoint except /api/fleet/status. Or when there are issues updating an inactive agent on the ack endpoint. + headers: + Elastic-Api-Version: + $ref: "#/components/headers/apiVersion" + X-Request-Id: + $ref: "#/components/headers/requestID" content: application/json: schema: @@ -846,6 +877,11 @@ components: message: ApiKey not enabled agentNotFound: description: 404 response when the agent is not found. May be returned by checkin endpoint. or endpoints that use the agentApiKey auth scheme + headers: + Elastic-Api-Version: + $ref: "#/components/headers/apiVersion" + X-Request-Id: + $ref: "#/components/headers/requestID" content: application/json: schema: @@ -860,6 +896,11 @@ components: message: agent could not be found deadline: description: 408 request timeout. + headers: + Elastic-Api-Version: + $ref: "#/components/headers/apiVersion" + X-Request-Id: + $ref: "#/components/headers/requestID" content: application/json: schema: @@ -873,7 +914,11 @@ components: error: RequestTimeout message: timeout on request throttle: - description: 428 rate limiting request. Only returned by artifacts endpoint. + description: 428 rate limiting request. + headers: + # throttle is checked before api version header is validated + X-Request-Id: + $ref: "#/components/headers/requestID" content: application/json: schema: @@ -891,6 +936,11 @@ components: 503 response when the server is not available for some reason. Such as if a context is cancelled or the connection (to ES) is refused. May be returned by any endpoint. + headers: + Elastic-Api-Version: + $ref: "#/components/headers/apiVersion" + X-Request-Id: + $ref: "#/components/headers/requestID" content: application/json: schema: @@ -923,6 +973,11 @@ paths: responses: "200": description: Healthy fleet-server response. + headers: + Elastic-Api-Version: + $ref: "#/components/headers/apiVersion" + X-Request-Id: + $ref: "#/components/headers/requestID" content: application/json: schema: @@ -946,6 +1001,11 @@ paths: $ref: "#/components/responses/badRequest" "503": description: Unhealthy fleet-server response. + headers: + Elastic-Api-Version: + $ref: "#/components/headers/apiVersion" + X-Request-Id: + $ref: "#/components/headers/requestID" content: text/plain: {} application/json: @@ -1001,6 +1061,11 @@ paths: responses: "200": description: Agent enrolled successfully. + headers: + Elastic-Api-Version: + $ref: "#/components/headers/apiVersion" + X-Request-Id: + $ref: "#/components/headers/requestID" content: application/json: schema: @@ -1035,8 +1100,6 @@ paths: $ref: "#/components/responses/badRequest" "401": $ref: "#/components/responses/keyNotEnabled" - "404": - description: Bad request path, expected id to be enroll. "408": $ref: "#/components/responses/deadline" "500": @@ -1110,7 +1173,10 @@ paths: gzip: description: Response is gzip encoded as the request headers allowed it. value: gzip - + Elastic-Api-Version: + $ref: "#/components/headers/apiVersion" + X-Request-Id: + $ref: "#/components/headers/requestID" content: application/json: schema: @@ -1180,6 +1246,11 @@ paths: responses: "200": description: Agent ack successfully received. + headers: + Elastic-Api-Version: + $ref: "#/components/headers/apiVersion" + X-Request-Id: + $ref: "#/components/headers/requestID" content: application/json: schema: @@ -1229,6 +1300,11 @@ paths: responses: "200": description: The artifact retrieved from ES. + headers: + Elastic-Api-Version: + $ref: "#/components/headers/apiVersion" + X-Request-Id: + $ref: "#/components/headers/requestID" content: "*/*": schema: @@ -1268,6 +1344,11 @@ paths: responses: "200": description: Information about the upload procedure + headers: + Elastic-Api-Version: + $ref: "#/components/headers/apiVersion" + X-Request-Id: + $ref: "#/components/headers/requestID" content: application/json: schema: @@ -1327,6 +1408,11 @@ paths: responses: "200": description: Successful chunk upload + headers: + Elastic-Api-Version: + $ref: "#/components/headers/apiVersion" + X-Request-Id: + $ref: "#/components/headers/requestID" "400": $ref: "#/components/responses/badRequest" "401": @@ -1364,6 +1450,11 @@ paths: responses: "200": description: success response + headers: + Elastic-Api-Version: + $ref: "#/components/headers/apiVersion" + X-Request-Id: + $ref: "#/components/headers/requestID" content: application/json: schema: @@ -1399,6 +1490,8 @@ paths: type: string examples: - ecb30383-6dd1-4b1d-bed0-2386b4e5df51 + - $ref: "#/components/parameters/apiVersion" + - $ref: "#/components/parameters/requestId" responses: "200": description: File Contents. @@ -1409,6 +1502,10 @@ paths: type: string examples: - 0c4a81b85a6b7ff00bde6c32e1e8be33b4b793b3b7b5cb03db93f77f7c9374d1 + Elastic-Api-Version: + $ref: "#/components/headers/apiVersion" + X-Request-Id: + $ref: "#/components/headers/requestID" content: "*/*": schema: @@ -1420,6 +1517,11 @@ paths: $ref: "#/components/responses/keyNotEnabled" "403": description: The requesting entity is not permitted to access the requested file + headers: + Elastic-Api-Version: + $ref: "#/components/headers/apiVersion" + X-Request-Id: + $ref: "#/components/headers/requestID" content: application/json: schema: @@ -1433,6 +1535,11 @@ paths: message: Client is not authorized "404": description: bad path, file not found + headers: + Elastic-Api-Version: + $ref: "#/components/headers/apiVersion" + X-Request-Id: + $ref: "#/components/headers/requestID" "500": $ref: "#/components/responses/internalServerError" "503": @@ -1443,7 +1550,7 @@ paths: summary: retrieve a PGP key from the fleet-server's local storage. description: "Get a PGP key that can be used to verify agent upgrades. Key is stored on (fleet-server's) disk." security: - - apiKey: [] # TODO: verify that we want security on this endpoint. + - apiKey: [] parameters: - name: major in: path @@ -1463,9 +1570,16 @@ paths: required: true schema: type: integer + - $ref: "#/components/parameters/apiVersion" + - $ref: "#/components/parameters/requestId" responses: "200": description: The PGP key bytes. + headers: + Elastic-Api-Version: + $ref: "#/components/headers/apiVersion" + X-Request-Id: + $ref: "#/components/headers/requestID" content: "application/octet-stream": schema: @@ -1477,5 +1591,15 @@ paths: $ref: "#/components/responses/keyNotEnabled" "500": description: The server has an error retrieving or reading the local key. + headers: + Elastic-Api-Version: + $ref: "#/components/headers/apiVersion" + X-Request-Id: + $ref: "#/components/headers/requestID" "501": description: The server will not serve the request without a TLS connection. + headers: + Elastic-Api-Version: + $ref: "#/components/headers/apiVersion" + X-Request-Id: + $ref: "#/components/headers/requestID" diff --git a/pkg/api/client.gen.go b/pkg/api/client.gen.go index 209749271..589180cba 100644 --- a/pkg/api/client.gen.go +++ b/pkg/api/client.gen.go @@ -94,7 +94,7 @@ func WithRequestEditorFn(fn RequestEditorFn) ClientOption { // The interface specification for the client above. type ClientInterface interface { // GetPGPKey request - GetPGPKey(ctx context.Context, major int, minor int, patch int, reqEditors ...RequestEditorFn) (*http.Response, error) + GetPGPKey(ctx context.Context, major int, minor int, patch int, params *GetPGPKeyParams, reqEditors ...RequestEditorFn) (*http.Response, error) // AgentEnrollWithBody request with any body AgentEnrollWithBody(ctx context.Context, params *AgentEnrollParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) @@ -115,7 +115,7 @@ type ClientInterface interface { Artifact(ctx context.Context, id string, sha2 string, params *ArtifactParams, reqEditors ...RequestEditorFn) (*http.Response, error) // GetFile request - GetFile(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*http.Response, error) + GetFile(ctx context.Context, id string, params *GetFileParams, reqEditors ...RequestEditorFn) (*http.Response, error) // UploadBeginWithBody request with any body UploadBeginWithBody(ctx context.Context, params *UploadBeginParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) @@ -134,8 +134,8 @@ type ClientInterface interface { Status(ctx context.Context, params *StatusParams, reqEditors ...RequestEditorFn) (*http.Response, error) } -func (c *Client) GetPGPKey(ctx context.Context, major int, minor int, patch int, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewGetPGPKeyRequest(c.Server, major, minor, patch) +func (c *Client) GetPGPKey(ctx context.Context, major int, minor int, patch int, params *GetPGPKeyParams, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewGetPGPKeyRequest(c.Server, major, minor, patch, params) if err != nil { return nil, err } @@ -230,8 +230,8 @@ func (c *Client) Artifact(ctx context.Context, id string, sha2 string, params *A return c.Client.Do(req) } -func (c *Client) GetFile(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewGetFileRequest(c.Server, id) +func (c *Client) GetFile(ctx context.Context, id string, params *GetFileParams, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewGetFileRequest(c.Server, id, params) if err != nil { return nil, err } @@ -315,7 +315,7 @@ func (c *Client) Status(ctx context.Context, params *StatusParams, reqEditors .. } // NewGetPGPKeyRequest generates requests for GetPGPKey -func NewGetPGPKeyRequest(server string, major int, minor int, patch int) (*http.Request, error) { +func NewGetPGPKeyRequest(server string, major int, minor int, patch int, params *GetPGPKeyParams) (*http.Request, error) { var err error var pathParam0 string @@ -359,6 +359,32 @@ func NewGetPGPKeyRequest(server string, major int, minor int, patch int) (*http. return nil, err } + if params != nil { + + if params.ElasticApiVersion != nil { + var headerParam0 string + + headerParam0, err = runtime.StyleParamWithLocation("simple", false, "elastic-api-version", runtime.ParamLocationHeader, *params.ElasticApiVersion) + if err != nil { + return nil, err + } + + req.Header.Set("elastic-api-version", headerParam0) + } + + if params.XRequestId != nil { + var headerParam1 string + + headerParam1, err = runtime.StyleParamWithLocation("simple", false, "X-Request-Id", runtime.ParamLocationHeader, *params.XRequestId) + if err != nil { + return nil, err + } + + req.Header.Set("X-Request-Id", headerParam1) + } + + } + return req, nil } @@ -410,15 +436,15 @@ func NewAgentEnrollRequestWithBody(server string, params *AgentEnrollParams, con req.Header.Set("User-Agent", headerParam0) - if params.XRequestID != nil { + if params.XRequestId != nil { var headerParam1 string - headerParam1, err = runtime.StyleParamWithLocation("simple", false, "X-Request-ID", runtime.ParamLocationHeader, *params.XRequestID) + headerParam1, err = runtime.StyleParamWithLocation("simple", false, "X-Request-Id", runtime.ParamLocationHeader, *params.XRequestId) if err != nil { return nil, err } - req.Header.Set("X-Request-ID", headerParam1) + req.Header.Set("X-Request-Id", headerParam1) } if params.ElasticApiVersion != nil { @@ -483,15 +509,15 @@ func NewAgentAcksRequestWithBody(server string, id string, params *AgentAcksPara if params != nil { - if params.XRequestID != nil { + if params.XRequestId != nil { var headerParam0 string - headerParam0, err = runtime.StyleParamWithLocation("simple", false, "X-Request-ID", runtime.ParamLocationHeader, *params.XRequestID) + headerParam0, err = runtime.StyleParamWithLocation("simple", false, "X-Request-Id", runtime.ParamLocationHeader, *params.XRequestId) if err != nil { return nil, err } - req.Header.Set("X-Request-ID", headerParam0) + req.Header.Set("X-Request-Id", headerParam0) } if params.ElasticApiVersion != nil { @@ -576,15 +602,15 @@ func NewAgentCheckinRequestWithBody(server string, id string, params *AgentCheck req.Header.Set("User-Agent", headerParam1) - if params.XRequestID != nil { + if params.XRequestId != nil { var headerParam2 string - headerParam2, err = runtime.StyleParamWithLocation("simple", false, "X-Request-ID", runtime.ParamLocationHeader, *params.XRequestID) + headerParam2, err = runtime.StyleParamWithLocation("simple", false, "X-Request-Id", runtime.ParamLocationHeader, *params.XRequestId) if err != nil { return nil, err } - req.Header.Set("X-Request-ID", headerParam2) + req.Header.Set("X-Request-Id", headerParam2) } if params.ElasticApiVersion != nil { @@ -643,15 +669,15 @@ func NewArtifactRequest(server string, id string, sha2 string, params *ArtifactP if params != nil { - if params.XRequestID != nil { + if params.XRequestId != nil { var headerParam0 string - headerParam0, err = runtime.StyleParamWithLocation("simple", false, "X-Request-ID", runtime.ParamLocationHeader, *params.XRequestID) + headerParam0, err = runtime.StyleParamWithLocation("simple", false, "X-Request-Id", runtime.ParamLocationHeader, *params.XRequestId) if err != nil { return nil, err } - req.Header.Set("X-Request-ID", headerParam0) + req.Header.Set("X-Request-Id", headerParam0) } if params.ElasticApiVersion != nil { @@ -671,7 +697,7 @@ func NewArtifactRequest(server string, id string, sha2 string, params *ArtifactP } // NewGetFileRequest generates requests for GetFile -func NewGetFileRequest(server string, id string) (*http.Request, error) { +func NewGetFileRequest(server string, id string, params *GetFileParams) (*http.Request, error) { var err error var pathParam0 string @@ -701,6 +727,32 @@ func NewGetFileRequest(server string, id string) (*http.Request, error) { return nil, err } + if params != nil { + + if params.ElasticApiVersion != nil { + var headerParam0 string + + headerParam0, err = runtime.StyleParamWithLocation("simple", false, "elastic-api-version", runtime.ParamLocationHeader, *params.ElasticApiVersion) + if err != nil { + return nil, err + } + + req.Header.Set("elastic-api-version", headerParam0) + } + + if params.XRequestId != nil { + var headerParam1 string + + headerParam1, err = runtime.StyleParamWithLocation("simple", false, "X-Request-Id", runtime.ParamLocationHeader, *params.XRequestId) + if err != nil { + return nil, err + } + + req.Header.Set("X-Request-Id", headerParam1) + } + + } + return req, nil } @@ -743,15 +795,15 @@ func NewUploadBeginRequestWithBody(server string, params *UploadBeginParams, con if params != nil { - if params.XRequestID != nil { + if params.XRequestId != nil { var headerParam0 string - headerParam0, err = runtime.StyleParamWithLocation("simple", false, "X-Request-ID", runtime.ParamLocationHeader, *params.XRequestID) + headerParam0, err = runtime.StyleParamWithLocation("simple", false, "X-Request-Id", runtime.ParamLocationHeader, *params.XRequestId) if err != nil { return nil, err } - req.Header.Set("X-Request-ID", headerParam0) + req.Header.Set("X-Request-Id", headerParam0) } if params.ElasticApiVersion != nil { @@ -816,15 +868,15 @@ func NewUploadCompleteRequestWithBody(server string, id string, params *UploadCo if params != nil { - if params.XRequestID != nil { + if params.XRequestId != nil { var headerParam0 string - headerParam0, err = runtime.StyleParamWithLocation("simple", false, "X-Request-ID", runtime.ParamLocationHeader, *params.XRequestID) + headerParam0, err = runtime.StyleParamWithLocation("simple", false, "X-Request-Id", runtime.ParamLocationHeader, *params.XRequestId) if err != nil { return nil, err } - req.Header.Set("X-Request-ID", headerParam0) + req.Header.Set("X-Request-Id", headerParam0) } if params.ElasticApiVersion != nil { @@ -894,15 +946,15 @@ func NewUploadChunkRequestWithBody(server string, id string, chunkNum int, param req.Header.Set("X-Chunk-SHA2", headerParam0) - if params.XRequestID != nil { + if params.XRequestId != nil { var headerParam1 string - headerParam1, err = runtime.StyleParamWithLocation("simple", false, "X-Request-ID", runtime.ParamLocationHeader, *params.XRequestID) + headerParam1, err = runtime.StyleParamWithLocation("simple", false, "X-Request-Id", runtime.ParamLocationHeader, *params.XRequestId) if err != nil { return nil, err } - req.Header.Set("X-Request-ID", headerParam1) + req.Header.Set("X-Request-Id", headerParam1) } if params.ElasticApiVersion != nil { @@ -947,15 +999,15 @@ func NewStatusRequest(server string, params *StatusParams) (*http.Request, error if params != nil { - if params.XRequestID != nil { + if params.XRequestId != nil { var headerParam0 string - headerParam0, err = runtime.StyleParamWithLocation("simple", false, "X-Request-ID", runtime.ParamLocationHeader, *params.XRequestID) + headerParam0, err = runtime.StyleParamWithLocation("simple", false, "X-Request-Id", runtime.ParamLocationHeader, *params.XRequestId) if err != nil { return nil, err } - req.Header.Set("X-Request-ID", headerParam0) + req.Header.Set("X-Request-Id", headerParam0) } if params.ElasticApiVersion != nil { @@ -1018,7 +1070,7 @@ func WithBaseURL(baseURL string) ClientOption { // ClientWithResponsesInterface is the interface specification for the client with responses above. type ClientWithResponsesInterface interface { // GetPGPKeyWithResponse request - GetPGPKeyWithResponse(ctx context.Context, major int, minor int, patch int, reqEditors ...RequestEditorFn) (*GetPGPKeyResponse, error) + GetPGPKeyWithResponse(ctx context.Context, major int, minor int, patch int, params *GetPGPKeyParams, reqEditors ...RequestEditorFn) (*GetPGPKeyResponse, error) // AgentEnrollWithBodyWithResponse request with any body AgentEnrollWithBodyWithResponse(ctx context.Context, params *AgentEnrollParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*AgentEnrollResponse, error) @@ -1039,7 +1091,7 @@ type ClientWithResponsesInterface interface { ArtifactWithResponse(ctx context.Context, id string, sha2 string, params *ArtifactParams, reqEditors ...RequestEditorFn) (*ArtifactResponse, error) // GetFileWithResponse request - GetFileWithResponse(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*GetFileResponse, error) + GetFileWithResponse(ctx context.Context, id string, params *GetFileParams, reqEditors ...RequestEditorFn) (*GetFileResponse, error) // UploadBeginWithBodyWithResponse request with any body UploadBeginWithBodyWithResponse(ctx context.Context, params *UploadBeginParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*UploadBeginResponse, error) @@ -1325,8 +1377,8 @@ func (r StatusResponse) StatusCode() int { } // GetPGPKeyWithResponse request returning *GetPGPKeyResponse -func (c *ClientWithResponses) GetPGPKeyWithResponse(ctx context.Context, major int, minor int, patch int, reqEditors ...RequestEditorFn) (*GetPGPKeyResponse, error) { - rsp, err := c.GetPGPKey(ctx, major, minor, patch, reqEditors...) +func (c *ClientWithResponses) GetPGPKeyWithResponse(ctx context.Context, major int, minor int, patch int, params *GetPGPKeyParams, reqEditors ...RequestEditorFn) (*GetPGPKeyResponse, error) { + rsp, err := c.GetPGPKey(ctx, major, minor, patch, params, reqEditors...) if err != nil { return nil, err } @@ -1394,8 +1446,8 @@ func (c *ClientWithResponses) ArtifactWithResponse(ctx context.Context, id strin } // GetFileWithResponse request returning *GetFileResponse -func (c *ClientWithResponses) GetFileWithResponse(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*GetFileResponse, error) { - rsp, err := c.GetFile(ctx, id, reqEditors...) +func (c *ClientWithResponses) GetFileWithResponse(ctx context.Context, id string, params *GetFileParams, reqEditors ...RequestEditorFn) (*GetFileResponse, error) { + rsp, err := c.GetFile(ctx, id, params, reqEditors...) if err != nil { return nil, err } diff --git a/pkg/api/doc.go b/pkg/api/doc.go new file mode 100644 index 000000000..91c9267ce --- /dev/null +++ b/pkg/api/doc.go @@ -0,0 +1,7 @@ +// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one +// or more contributor license agreements. Licensed under the Elastic License; +// you may not use this file except in compliance with the Elastic License. + +// Package api contains the client implementation for the master branch of fleet-server. +// Code is generated from ../model/openapi.yml +package api diff --git a/pkg/api/types.gen.go b/pkg/api/types.gen.go index 1a921419b..9d237c34a 100644 --- a/pkg/api/types.gen.go +++ b/pkg/api/types.gen.go @@ -609,6 +609,15 @@ type Throttle = Error // Unavailable Error processing request. type Unavailable = Error +// GetPGPKeyParams defines parameters for GetPGPKey. +type GetPGPKeyParams struct { + // ElasticApiVersion The API version to use, format should be "YYYY-MM-DD" + ElasticApiVersion *ApiVersion `json:"elastic-api-version,omitempty"` + + // XRequestId The request tracking ID for APM. + XRequestId *RequestId `json:"X-Request-Id,omitempty"` +} + // AgentEnrollParams defines parameters for AgentEnroll. type AgentEnrollParams struct { // UserAgent The user-agent header that is sent. @@ -616,8 +625,8 @@ type AgentEnrollParams struct { // The agent version must not be greater than the version of the fleet-server. UserAgent UserAgent `json:"User-Agent"` - // XRequestID The request tracking ID for APM. - XRequestID *RequestId `json:"X-Request-ID,omitempty"` + // XRequestId The request tracking ID for APM. + XRequestId *RequestId `json:"X-Request-Id,omitempty"` // ElasticApiVersion The API version to use, format should be "YYYY-MM-DD" ElasticApiVersion *ApiVersion `json:"elastic-api-version,omitempty"` @@ -625,8 +634,8 @@ type AgentEnrollParams struct { // AgentAcksParams defines parameters for AgentAcks. type AgentAcksParams struct { - // XRequestID The request tracking ID for APM. - XRequestID *RequestId `json:"X-Request-ID,omitempty"` + // XRequestId The request tracking ID for APM. + XRequestId *RequestId `json:"X-Request-Id,omitempty"` // ElasticApiVersion The API version to use, format should be "YYYY-MM-DD" ElasticApiVersion *ApiVersion `json:"elastic-api-version,omitempty"` @@ -644,8 +653,8 @@ type AgentCheckinParams struct { // The agent version must not be greater than the version of the fleet-server. UserAgent UserAgent `json:"User-Agent"` - // XRequestID The request tracking ID for APM. - XRequestID *RequestId `json:"X-Request-ID,omitempty"` + // XRequestId The request tracking ID for APM. + XRequestId *RequestId `json:"X-Request-Id,omitempty"` // ElasticApiVersion The API version to use, format should be "YYYY-MM-DD" ElasticApiVersion *ApiVersion `json:"elastic-api-version,omitempty"` @@ -653,17 +662,26 @@ type AgentCheckinParams struct { // ArtifactParams defines parameters for Artifact. type ArtifactParams struct { - // XRequestID The request tracking ID for APM. - XRequestID *RequestId `json:"X-Request-ID,omitempty"` + // XRequestId The request tracking ID for APM. + XRequestId *RequestId `json:"X-Request-Id,omitempty"` // ElasticApiVersion The API version to use, format should be "YYYY-MM-DD" ElasticApiVersion *ApiVersion `json:"elastic-api-version,omitempty"` } +// GetFileParams defines parameters for GetFile. +type GetFileParams struct { + // ElasticApiVersion The API version to use, format should be "YYYY-MM-DD" + ElasticApiVersion *ApiVersion `json:"elastic-api-version,omitempty"` + + // XRequestId The request tracking ID for APM. + XRequestId *RequestId `json:"X-Request-Id,omitempty"` +} + // UploadBeginParams defines parameters for UploadBegin. type UploadBeginParams struct { - // XRequestID The request tracking ID for APM. - XRequestID *RequestId `json:"X-Request-ID,omitempty"` + // XRequestId The request tracking ID for APM. + XRequestId *RequestId `json:"X-Request-Id,omitempty"` // ElasticApiVersion The API version to use, format should be "YYYY-MM-DD" ElasticApiVersion *ApiVersion `json:"elastic-api-version,omitempty"` @@ -671,8 +689,8 @@ type UploadBeginParams struct { // UploadCompleteParams defines parameters for UploadComplete. type UploadCompleteParams struct { - // XRequestID The request tracking ID for APM. - XRequestID *RequestId `json:"X-Request-ID,omitempty"` + // XRequestId The request tracking ID for APM. + XRequestId *RequestId `json:"X-Request-Id,omitempty"` // ElasticApiVersion The API version to use, format should be "YYYY-MM-DD" ElasticApiVersion *ApiVersion `json:"elastic-api-version,omitempty"` @@ -683,8 +701,8 @@ type UploadChunkParams struct { // XChunkSHA2 the SHA256 hash of the body contents for this request XChunkSHA2 string `json:"X-Chunk-SHA2"` - // XRequestID The request tracking ID for APM. - XRequestID *RequestId `json:"X-Request-ID,omitempty"` + // XRequestId The request tracking ID for APM. + XRequestId *RequestId `json:"X-Request-Id,omitempty"` // ElasticApiVersion The API version to use, format should be "YYYY-MM-DD" ElasticApiVersion *ApiVersion `json:"elastic-api-version,omitempty"` @@ -692,8 +710,8 @@ type UploadChunkParams struct { // StatusParams defines parameters for Status. type StatusParams struct { - // XRequestID The request tracking ID for APM. - XRequestID *RequestId `json:"X-Request-ID,omitempty"` + // XRequestId The request tracking ID for APM. + XRequestId *RequestId `json:"X-Request-Id,omitempty"` // ElasticApiVersion The API version to use, format should be "YYYY-MM-DD" ElasticApiVersion *ApiVersion `json:"elastic-api-version,omitempty"` diff --git a/pkg/api/versions/2022_06_01/api/client.gen.go b/pkg/api/versions/2023_06_01/api/client.gen.go similarity index 94% rename from pkg/api/versions/2022_06_01/api/client.gen.go rename to pkg/api/versions/2023_06_01/api/client.gen.go index b20d4ccea..942b1bb22 100644 --- a/pkg/api/versions/2022_06_01/api/client.gen.go +++ b/pkg/api/versions/2023_06_01/api/client.gen.go @@ -112,7 +112,7 @@ type ClientInterface interface { Artifact(ctx context.Context, id string, sha2 string, params *ArtifactParams, reqEditors ...RequestEditorFn) (*http.Response, error) // GetFile request - GetFile(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*http.Response, error) + GetFile(ctx context.Context, id string, params *GetFileParams, reqEditors ...RequestEditorFn) (*http.Response, error) // UploadBeginWithBody request with any body UploadBeginWithBody(ctx context.Context, params *UploadBeginParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) @@ -215,8 +215,8 @@ func (c *Client) Artifact(ctx context.Context, id string, sha2 string, params *A return c.Client.Do(req) } -func (c *Client) GetFile(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewGetFileRequest(c.Server, id) +func (c *Client) GetFile(ctx context.Context, id string, params *GetFileParams, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewGetFileRequest(c.Server, id, params) if err != nil { return nil, err } @@ -347,26 +347,26 @@ func NewAgentEnrollRequestWithBody(server string, params *AgentEnrollParams, con req.Header.Set("User-Agent", headerParam0) - if params.XRequestID != nil { + if params.XRequestId != nil { var headerParam1 string - headerParam1, err = runtime.StyleParamWithLocation("simple", false, "X-Request-ID", runtime.ParamLocationHeader, *params.XRequestID) + headerParam1, err = runtime.StyleParamWithLocation("simple", false, "X-Request-Id", runtime.ParamLocationHeader, *params.XRequestId) if err != nil { return nil, err } - req.Header.Set("X-Request-ID", headerParam1) + req.Header.Set("X-Request-Id", headerParam1) } if params.ElasticApiVersion != nil { var headerParam2 string - headerParam2, err = runtime.StyleParamWithLocation("simple", false, "elastic-api-version", runtime.ParamLocationHeader, *params.ElasticApiVersion) + headerParam2, err = runtime.StyleParamWithLocation("simple", false, "Elastic-Api-Version", runtime.ParamLocationHeader, *params.ElasticApiVersion) if err != nil { return nil, err } - req.Header.Set("elastic-api-version", headerParam2) + req.Header.Set("Elastic-Api-Version", headerParam2) } } @@ -420,26 +420,26 @@ func NewAgentAcksRequestWithBody(server string, id string, params *AgentAcksPara if params != nil { - if params.XRequestID != nil { + if params.XRequestId != nil { var headerParam0 string - headerParam0, err = runtime.StyleParamWithLocation("simple", false, "X-Request-ID", runtime.ParamLocationHeader, *params.XRequestID) + headerParam0, err = runtime.StyleParamWithLocation("simple", false, "X-Request-Id", runtime.ParamLocationHeader, *params.XRequestId) if err != nil { return nil, err } - req.Header.Set("X-Request-ID", headerParam0) + req.Header.Set("X-Request-Id", headerParam0) } if params.ElasticApiVersion != nil { var headerParam1 string - headerParam1, err = runtime.StyleParamWithLocation("simple", false, "elastic-api-version", runtime.ParamLocationHeader, *params.ElasticApiVersion) + headerParam1, err = runtime.StyleParamWithLocation("simple", false, "Elastic-Api-Version", runtime.ParamLocationHeader, *params.ElasticApiVersion) if err != nil { return nil, err } - req.Header.Set("elastic-api-version", headerParam1) + req.Header.Set("Elastic-Api-Version", headerParam1) } } @@ -513,26 +513,26 @@ func NewAgentCheckinRequestWithBody(server string, id string, params *AgentCheck req.Header.Set("User-Agent", headerParam1) - if params.XRequestID != nil { + if params.XRequestId != nil { var headerParam2 string - headerParam2, err = runtime.StyleParamWithLocation("simple", false, "X-Request-ID", runtime.ParamLocationHeader, *params.XRequestID) + headerParam2, err = runtime.StyleParamWithLocation("simple", false, "X-Request-Id", runtime.ParamLocationHeader, *params.XRequestId) if err != nil { return nil, err } - req.Header.Set("X-Request-ID", headerParam2) + req.Header.Set("X-Request-Id", headerParam2) } if params.ElasticApiVersion != nil { var headerParam3 string - headerParam3, err = runtime.StyleParamWithLocation("simple", false, "elastic-api-version", runtime.ParamLocationHeader, *params.ElasticApiVersion) + headerParam3, err = runtime.StyleParamWithLocation("simple", false, "Elastic-Api-Version", runtime.ParamLocationHeader, *params.ElasticApiVersion) if err != nil { return nil, err } - req.Header.Set("elastic-api-version", headerParam3) + req.Header.Set("Elastic-Api-Version", headerParam3) } } @@ -580,26 +580,26 @@ func NewArtifactRequest(server string, id string, sha2 string, params *ArtifactP if params != nil { - if params.XRequestID != nil { + if params.XRequestId != nil { var headerParam0 string - headerParam0, err = runtime.StyleParamWithLocation("simple", false, "X-Request-ID", runtime.ParamLocationHeader, *params.XRequestID) + headerParam0, err = runtime.StyleParamWithLocation("simple", false, "X-Request-Id", runtime.ParamLocationHeader, *params.XRequestId) if err != nil { return nil, err } - req.Header.Set("X-Request-ID", headerParam0) + req.Header.Set("X-Request-Id", headerParam0) } if params.ElasticApiVersion != nil { var headerParam1 string - headerParam1, err = runtime.StyleParamWithLocation("simple", false, "elastic-api-version", runtime.ParamLocationHeader, *params.ElasticApiVersion) + headerParam1, err = runtime.StyleParamWithLocation("simple", false, "Elastic-Api-Version", runtime.ParamLocationHeader, *params.ElasticApiVersion) if err != nil { return nil, err } - req.Header.Set("elastic-api-version", headerParam1) + req.Header.Set("Elastic-Api-Version", headerParam1) } } @@ -608,7 +608,7 @@ func NewArtifactRequest(server string, id string, sha2 string, params *ArtifactP } // NewGetFileRequest generates requests for GetFile -func NewGetFileRequest(server string, id string) (*http.Request, error) { +func NewGetFileRequest(server string, id string, params *GetFileParams) (*http.Request, error) { var err error var pathParam0 string @@ -638,6 +638,32 @@ func NewGetFileRequest(server string, id string) (*http.Request, error) { return nil, err } + if params != nil { + + if params.XRequestId != nil { + var headerParam0 string + + headerParam0, err = runtime.StyleParamWithLocation("simple", false, "X-Request-Id", runtime.ParamLocationHeader, *params.XRequestId) + if err != nil { + return nil, err + } + + req.Header.Set("X-Request-Id", headerParam0) + } + + if params.ElasticApiVersion != nil { + var headerParam1 string + + headerParam1, err = runtime.StyleParamWithLocation("simple", false, "Elastic-Api-Version", runtime.ParamLocationHeader, *params.ElasticApiVersion) + if err != nil { + return nil, err + } + + req.Header.Set("Elastic-Api-Version", headerParam1) + } + + } + return req, nil } @@ -680,26 +706,26 @@ func NewUploadBeginRequestWithBody(server string, params *UploadBeginParams, con if params != nil { - if params.XRequestID != nil { + if params.XRequestId != nil { var headerParam0 string - headerParam0, err = runtime.StyleParamWithLocation("simple", false, "X-Request-ID", runtime.ParamLocationHeader, *params.XRequestID) + headerParam0, err = runtime.StyleParamWithLocation("simple", false, "X-Request-Id", runtime.ParamLocationHeader, *params.XRequestId) if err != nil { return nil, err } - req.Header.Set("X-Request-ID", headerParam0) + req.Header.Set("X-Request-Id", headerParam0) } if params.ElasticApiVersion != nil { var headerParam1 string - headerParam1, err = runtime.StyleParamWithLocation("simple", false, "elastic-api-version", runtime.ParamLocationHeader, *params.ElasticApiVersion) + headerParam1, err = runtime.StyleParamWithLocation("simple", false, "Elastic-Api-Version", runtime.ParamLocationHeader, *params.ElasticApiVersion) if err != nil { return nil, err } - req.Header.Set("elastic-api-version", headerParam1) + req.Header.Set("Elastic-Api-Version", headerParam1) } } @@ -753,26 +779,26 @@ func NewUploadCompleteRequestWithBody(server string, id string, params *UploadCo if params != nil { - if params.XRequestID != nil { + if params.XRequestId != nil { var headerParam0 string - headerParam0, err = runtime.StyleParamWithLocation("simple", false, "X-Request-ID", runtime.ParamLocationHeader, *params.XRequestID) + headerParam0, err = runtime.StyleParamWithLocation("simple", false, "X-Request-Id", runtime.ParamLocationHeader, *params.XRequestId) if err != nil { return nil, err } - req.Header.Set("X-Request-ID", headerParam0) + req.Header.Set("X-Request-Id", headerParam0) } if params.ElasticApiVersion != nil { var headerParam1 string - headerParam1, err = runtime.StyleParamWithLocation("simple", false, "elastic-api-version", runtime.ParamLocationHeader, *params.ElasticApiVersion) + headerParam1, err = runtime.StyleParamWithLocation("simple", false, "Elastic-Api-Version", runtime.ParamLocationHeader, *params.ElasticApiVersion) if err != nil { return nil, err } - req.Header.Set("elastic-api-version", headerParam1) + req.Header.Set("Elastic-Api-Version", headerParam1) } } @@ -831,26 +857,26 @@ func NewUploadChunkRequestWithBody(server string, id string, chunkNum int, param req.Header.Set("X-Chunk-SHA2", headerParam0) - if params.XRequestID != nil { + if params.XRequestId != nil { var headerParam1 string - headerParam1, err = runtime.StyleParamWithLocation("simple", false, "X-Request-ID", runtime.ParamLocationHeader, *params.XRequestID) + headerParam1, err = runtime.StyleParamWithLocation("simple", false, "X-Request-Id", runtime.ParamLocationHeader, *params.XRequestId) if err != nil { return nil, err } - req.Header.Set("X-Request-ID", headerParam1) + req.Header.Set("X-Request-Id", headerParam1) } if params.ElasticApiVersion != nil { var headerParam2 string - headerParam2, err = runtime.StyleParamWithLocation("simple", false, "elastic-api-version", runtime.ParamLocationHeader, *params.ElasticApiVersion) + headerParam2, err = runtime.StyleParamWithLocation("simple", false, "Elastic-Api-Version", runtime.ParamLocationHeader, *params.ElasticApiVersion) if err != nil { return nil, err } - req.Header.Set("elastic-api-version", headerParam2) + req.Header.Set("Elastic-Api-Version", headerParam2) } } @@ -884,26 +910,26 @@ func NewStatusRequest(server string, params *StatusParams) (*http.Request, error if params != nil { - if params.XRequestID != nil { + if params.XRequestId != nil { var headerParam0 string - headerParam0, err = runtime.StyleParamWithLocation("simple", false, "X-Request-ID", runtime.ParamLocationHeader, *params.XRequestID) + headerParam0, err = runtime.StyleParamWithLocation("simple", false, "X-Request-Id", runtime.ParamLocationHeader, *params.XRequestId) if err != nil { return nil, err } - req.Header.Set("X-Request-ID", headerParam0) + req.Header.Set("X-Request-Id", headerParam0) } if params.ElasticApiVersion != nil { var headerParam1 string - headerParam1, err = runtime.StyleParamWithLocation("simple", false, "elastic-api-version", runtime.ParamLocationHeader, *params.ElasticApiVersion) + headerParam1, err = runtime.StyleParamWithLocation("simple", false, "Elastic-Api-Version", runtime.ParamLocationHeader, *params.ElasticApiVersion) if err != nil { return nil, err } - req.Header.Set("elastic-api-version", headerParam1) + req.Header.Set("Elastic-Api-Version", headerParam1) } } @@ -973,7 +999,7 @@ type ClientWithResponsesInterface interface { ArtifactWithResponse(ctx context.Context, id string, sha2 string, params *ArtifactParams, reqEditors ...RequestEditorFn) (*ArtifactResponse, error) // GetFileWithResponse request - GetFileWithResponse(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*GetFileResponse, error) + GetFileWithResponse(ctx context.Context, id string, params *GetFileParams, reqEditors ...RequestEditorFn) (*GetFileResponse, error) // UploadBeginWithBodyWithResponse request with any body UploadBeginWithBodyWithResponse(ctx context.Context, params *UploadBeginParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*UploadBeginResponse, error) @@ -1296,8 +1322,8 @@ func (c *ClientWithResponses) ArtifactWithResponse(ctx context.Context, id strin } // GetFileWithResponse request returning *GetFileResponse -func (c *ClientWithResponses) GetFileWithResponse(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*GetFileResponse, error) { - rsp, err := c.GetFile(ctx, id, reqEditors...) +func (c *ClientWithResponses) GetFileWithResponse(ctx context.Context, id string, params *GetFileParams, reqEditors ...RequestEditorFn) (*GetFileResponse, error) { + rsp, err := c.GetFile(ctx, id, params, reqEditors...) if err != nil { return nil, err } diff --git a/pkg/api/versions/2023_06_01/api/doc.go b/pkg/api/versions/2023_06_01/api/doc.go new file mode 100644 index 000000000..817a17428 --- /dev/null +++ b/pkg/api/versions/2023_06_01/api/doc.go @@ -0,0 +1,10 @@ +// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one +// or more contributor license agreements. Licensed under the Elastic License; +// you may not use this file except in compliance with the Elastic License. + +//go:generate oapi-codegen -generate types -package api -o types.gen.go openapi.yml +//go:generate oapi-codegen -generate client -package api -o client.gen.go openapi.yml + +// Package api contains the 2023-06-01 client of the fleet-server API. +// Client code is generated from ./openapi.yml +package api diff --git a/pkg/api/versions/2023_06_01/api/openapi.yml b/pkg/api/versions/2023_06_01/api/openapi.yml new file mode 100644 index 000000000..fe663481f --- /dev/null +++ b/pkg/api/versions/2023_06_01/api/openapi.yml @@ -0,0 +1,1427 @@ +openapi: 3.0.0 +info: + title: fleet-server API + version: 2023-06-01 + license: + name: Elastic License 2.0 + url: https://www.elastic.co/licensing/elastic-license + description: | + The fleet-server API that is used by agents when enrolled with fleet. + + Note that the current implementations in the fleet-server and elastic-agent may have some difference specifically when it comes to some objects. + This is most notable when comparing the `Action` implementations. Fleet-server uses a general template for all actions and the elastic-agent will have more specific representations. + + The implementation of fleet-server by default also includes a connection count limiter, as well as limiters for request body sizes. + If an agent attempts to make request but there are no remaining connections, the attempt will be blocked and the agent will get an error. + If an agent tries to send a body that is too large the fleet-server will respond with a 400 status code. +components: + headers: + apiVersion: + description: The API version the server is using to respond. + schema: + type: string + examples: + "2023-06-01": + value: 2023-06-01 + requestID: + description: The X-Request-Id header used for tracing requests. + schema: + type: string + securitySchemes: + apiKey: + description: API key security will check that the API key exists and is enabled, but will not check additional permissions + type: apiKey + in: header + name: ApiKey + agentApiKey: + description: Agent API key security will check that the API key exists, is enabled, and is assigned to the agent + type: apiKey + in: header + name: ApiKey + schemas: + error: + description: Error processing request. + type: object + required: + - statusCode + - error + properties: + statusCode: + type: integer + description: The HTTP status code of the error. + error: + type: string + description: Error type. + message: + type: string + description: (optional) Error message. + statusResponseVersion: + description: Version information included in the response to an authorized status request. + type: object + properties: + number: + type: string + description: The fleet-server version. + build_hash: + type: string + description: The commit that the fleet-server was built from. + build_time: + type: string + description: The date-time that the fleet-server binary was created. + #format: date-time # not using date-time format at the moment because the currently available objects have plain strings + statusResponse: + x-go-name: StatusAPIResponse + description: Status response information. + type: object + required: + - name + - status + properties: + name: + type: string + description: Service name. + status: + type: string + description: | + A Unit state that fleet-server may report. + Unit state is defined in the elastic-agent-client specification. + enum: + - starting + - configuring + - healthy + - degraded + - failed + - stopping + - stopped + - unknown + version: + $ref: "#/components/schemas/statusResponseVersion" + enrollMetadata: + description: Metadata associated with the agent that is enrolling to fleet. + type: object + required: + - user_provided + - local + - tags + properties: + user_provided: + deprecated: true + description: | + An embedded JSON object that holds user-provided meta-data values. + Defined in fleet-server as a `json.RawMessage`. + fleet-server does not use these values on enrollment of an agent. + + Defined in the elastic-agent as a `map[string]interface{}` with no way to specify any values. + type: string + format: application/json + x-go-type: json.RawMessage + local: + description: | + An embedded JSON object that holds meta-data values. + Defined in fleet-server as a `json.RawMessage`, defined as an object in the elastic-agent. + elastic-agent will populate the object with information from the binary and host/system environment. + If not empty fleet-server will update the value of `local["elastic"]["agent"]["id"]` to the agent ID (assuming the keys exist). + The (possibly updated) value is sent by fleet-server when creating the record for a new agent. + type: string + format: application/json + x-go-type: json.RawMessage + tags: + description: | + User provided tags for the agent. + fleet-server will pass the tags to the agent record on enrollment. + type: array + items: + type: string + enrollRequest: + description: A request to enroll a new agent into fleet. + type: object + required: + - type + - shared_id + - metadata + properties: + type: + description: | + The enrollment type of the agent. + The agent only supports the PERMANENT value. + In the future the enrollment type may be used to indicate agents that use fleet for reporting and monitoring, but do not use policies. + type: string + enum: + - PERMANENT + shared_id: + deprecated: true + type: string + description: | + The shared ID of the agent. + To support pre-existing installs. + + Never implemented. + metadata: + $ref: "#/components/schemas/enrollMetadata" + enrollResponseItem: + description: Response to a successful enrollment of an agent into fleet. + type: object + required: + - id + - active + - policy_id + - type + - enrolled_at + - user_provided_metadata + - local_metadata + - actions + - access_api_key_id + - access_api_key + - status + - tags + properties: + id: + description: The agent ID + type: string + active: + deprecated: true + description: | + If the agent is active in fleet. + Set to true upon enrollment. + + Handling of other values never implemented. + type: boolean + policy_id: + description: The policy ID that the agent is enrolled with. Decoded from the API key used in the request. + type: string + type: + deprecated: true + description: | + The enrollment request type. + + Handling of other values never implemented. + type: string + enrolled_at: + description: The RFC3339 timestamp that the agent was enrolled at. + type: string + #format: date-time + user_provided_metadata: + deprecated: true + description: | + A copy of the user provided metadata from the enrollment request. + + Currently will be empty. + type: string + format: application/json + x-go-type: json.RawMessage + local_metadata: + deprecated: true + description: | + A copy of the (updated) local metadata provided in the enrollment request. + + Never used by agent. + type: string + format: application/json + x-go-type: json.RawMessage + actions: + deprecated: true + description: | + Defined in fleet-server and elastic-agent as `[]interface{}`. + + Never used by agent. + type: array + items: + type: object + access_api_key_id: + description: The id of the ApiKey that fleet-server has generated for the enrolling agent. + type: string + access_api_key: + description: The ApiKey token that fleet-server has generated for the enrolling agent. + type: string + format: password + status: + deprecated: true + description: | + Agent status from fleet-server. + fleet-ui may differ. + + Never used by agent. + type: string + tags: + description: A copy of the tags that were sent with the enrollment request. + type: array + items: + type: string + enrollResponse: + description: The enrollment action response. + type: object + required: + - action + - item + properties: + action: + description: The action result. Will have the value "created". + type: string + item: + $ref: "#/components/schemas/enrollResponseItem" + checkinRequest: + type: object + required: + - status + - message + properties: + status: + description: The agent state, inferred from agent control protocol states. + type: string + enum: + - online + - error + - degraded + - starting + message: + description: State message, may be overridden or use the error message of a failing component. + type: string + ack_token: + description: | + The ack_token form a previous response if the agent has checked in before. + Translated to a sequence number in fleet-server in order to retrieve any new actions for the agent from the last checkin. + type: string + local_metadata: + description: | + An embedded JSON object that holds meta-data values. + Defined in fleet-server as a `json.RawMessage`, defined as an object in the elastic-agent. + elastic-agent will populate the object with information from the binary and host/system environment. + fleet-server will update the agent record if a checkin response contains different data from the record. + type: string + format: application/json + x-go-type: json.RawMessage + components: + description: | + An embedded JSON object that holds component information that the agent is running. + Defined in fleet-server as a `json.RawMessage`, defined as an object in the elastic-agent. + fleet-server will update the components in an agent record if they differ from this object. + type: string + format: application/json + x-go-type: json.RawMessage + poll_timeout: + description: | + An optional timeout value that informs fleet-server of when a client will time out on it's checkin request. + If not specified fleet-server will use the timeout values specified in the config (defaults to 5m polling and a 10m write timeout). + The value, if specified is expected to be a string that is parsable by [time.ParseDuration](https://pkg.go.dev/time#ParseDuration). + If specified fleet-server will set its poll timeout to `max(1m, poll_timeout-2m)` and its write timeout to `max(2m, poll_timout-1m)`. + type: string + format: duration + actionSignature: + description: Optional action signing data. + type: object + x-go-custom-tag: yaml:"signed" # openapi-generator + x-oapi-codegen-extra-tags: # oapi-codegen tags + yaml: "signed" + required: + - data # NOTE: work around to avoid a pointer + - signature # NOTE: work around to avoid a pointer + properties: + data: + description: The base64 encoded, UTF-8 JSON serialized action bytes that are signed. + type: string + format: base64 + x-go-custom-tag: yaml:"data" # openapi-generator + x-oapi-codegen-extra-tags: # oapi-codegen tags + yaml: "data" + json: "data,omitempty" + signature: + description: The base64 encoded signature. + type: string + format: base64 + x-go-custom-tag: yaml:"signature" # openapi-generator + x-oapi-codegen-extra-tags: # oapi-codegen tags + yaml: "signature" + json: "signature,omitempty" + action: + description: | + An action for an elastic-agent. + The actions are defined in generic terms on the fleet-server. + The elastic-agent will have additional details for what is expected when a specific action-type is recieved. + Many attributes in this schema also contain yaml tags so the elastic-agent may serialize them. + The structure of the `data` attribute will vary between action types. + + An additional consideration is Scheduled Actions. Scheduled actions are currently defined as actions that have non-empty values for both the `start_time` and `expiration` attributes. + type: object + required: + - agent_id + - created_at + - data + - id + - type + - input_type + properties: + agent_id: + description: The agent ID. + type: string + created_at: + description: Time when the action was created. + type: string + #format: date-time + start_time: + description: The earliest execution time for the action. Agent will not execute the action before this time. Used for scheduled actions. + type: string + #format: date-time + x-go-custom-tag: yaml:"start_time" # openapi-generator + x-oapi-codegen-extra-tags: # oapi-codegen tags + yaml: "start_time" + expiration: + description: The latest start time for the action. Actions will be dropped by the agent if execution has not started by this time. Used for scheduled actions. + type: string + #format: date-time + x-go-custom-tag: yaml:"expiration" # openapi-generator + x-oapi-codegen-extra-tags: # oapi-codegen tags + yaml: "expiration" + data: + # oapi-codegen type should be: interface{} + description: An embedded action-specific object. + x-go-custom-tag: yaml:"data" + x-oapi-codegen-extra-tags: + yaml: "data" + id: + description: The action ID. + type: string + x-go-custom-tag: yaml:"action_id" # openapi-generator + x-oapi-codegen-extra-tags: # oapi-codegen tags + yaml: "action_id" + traceparent: + description: APM traceparent for the action. + type: string + x-go-custom-tag: yaml:"traceparent" # openapi-generator + x-oapi-codegen-extra-tags: # oapi-codegen tags + yaml: "traceparent" + type: + description: The action type. + type: string + x-go-custom-tag: yaml:"type" # openapi-generator + x-oapi-codegen-extra-tags: # oapi-codegen tags + yaml: "type" + input_type: + description: The input type of the action for actions with type `INPUT_ACTION`. + type: string + x-go-custom-tag: yaml:"input_type" # openapi-generator + x-oapi-codegen-extra-tags: # oapi-codegen tags + yaml: "input_type" + timeout: + description: The timeout value (in seconds) for actions with type `INPUT_ACTION`. + type: integer + format: int64 + x-go-custom-tag: yaml:"timeout" # openapi-generator + x-oapi-codegen-extra-tags: # oapi-codegen tags + yaml: "timeout" + signed: + $ref: "#/components/schemas/actionSignature" + + checkinResponse: + type: object + required: + - action + properties: + ack_token: + description: The acknowlegment token used to indicate action delivery. + type: string + action: + description: The action result. Set to "checkin". + type: string + actions: + description: A list of actions that the agent must execute. + type: array + items: + $ref: "#/components/schemas/action" + event: + description: The ack for a specific action that the elastic-agent has executed. + type: object + required: + - type + - subtype + - agent_id + - action_id + - action_input_type + - policy_id + - stream_id + - timestamp + - message + - started_at + - completed_at + properties: + type: + deprecated: true + description: | + The event type of the ack. + Currently the elastic-agent will only generate ACTION_RESULT events. + + Not used by fleet-server. + Actions that have errored should use the error attribute to communicate an error status. + Additional action status information can be provided in the data attribute. + type: string + enum: + - STATE + - ERROR + - ACTION_RESULT + - ACTION + subtype: + deprecated: true + description: | + The subtype of the ack event. + The elastic-agent will only generate ACKNOWLEDGED events. + + Not used by fleet-server. + Actions that have errored should use the error attribute to communicate an error status. + Additional action status information can be provided in the data attribute. + type: string + enum: + - RUNNING + - STARTING + - IN_PROGRESS + - CONFIG + - FAILED + - STOPPING + - STOPPED + - DATA_DUMP + - ACKNOWLEDGED + - UNKNOWN + agent_id: + description: The ID of the agent that executed the action. + type: string + action_id: + description: The action ID. + type: string + action_input_type: + description: The input_type of the action for input actions. + type: string + policy_id: + deprecated: true + description: Not used by the fleet-server. + type: string + stream_id: + deprecated: true + description: Not used by the fleet-server. + type: string + timestamp: + description: The timestamp of the acknowledgement event. Has the format of "2006-01-02T15:04:05.99999-07:00" + type: string + #format: date-time + message: + description: An acknowlegement message. The elastic-agent inserts the action ID and action type into this message. + type: string + payload: + deprecated: true + description: | + An embedded JSON object that contains additional information for the fleet-server to process. + Defined as a json.RawMessage in both the fleet-server and the elastic-agent. + + Is currently used by UPGRADE actions to signal retries. + If the error attribute is non empty payload is checked for `retry: bool` and `retry_attempt: int`. + If retry is true, fleet-serve will mark the agent as retrying, if it's false the upgrade will be marked as failed. + + Additional action status information can be provided in the data attribute. + type: string + format: application/json + x-go-type: json.RawMessage + started_at: + description: The time at which the action was started. Used only when acknowledging input actions. + type: string + #format: date-time + completed_at: + description: The time at which the action was completed. Used only when acknowledging input actions + type: string + #format: date-time + action_data: + description: The action data for the input action being acknowledged. + type: string + format: application/json + x-go-type: json.RawMessage + action_response: + description: The action response for the input action being acknowledged. + type: string + format: application/json + x-go-type: json.RawMessage + data: + description: | + An embedded JSON object that has the data about the ack. + + Used by REQUEST_DIAGNOSTICS actions. + Contains a `upload_id` attribute used to communicate the successfullly uploaded diagnostics ID. + type: string + format: application/json + x-go-type: json.RawMessage + error: + description: | + An error message. + If this is non-empty an error has occured when executing the action. + For some actions (such as UPGRADE actions) it may result in the action being marked as failed. + type: string + ackRequest: + description: The request an elastic-agent sends to fleet-serve to acknowledge the execution of one or more actions. + type: object + required: + - events + properties: + events: + type: array + items: + $ref: "#/components/schemas/event" + ackResponseItem: + description: The results of processing an acknowledgement event. + type: object + required: + - status + properties: + status: + description: An HTTP status code that indicates if the event was processed successfully or not. + type: integer + message: + description: HTTP status text. + type: string + ackResponse: + description: Response to processing acknowledgement events. + type: object + required: + - action + - items # NOTE: work around as we don't want a pointer here + - errors # NOTE: work around as we don't want a pointer here + properties: + action: + description: The action result. Will have the value "acks". + type: string + errors: + description: A flag to indicate if one or more errors occured when proccessing events. + type: boolean + nullable: false + x-oapi-codegen-extra-tags: + json: "errors,omitempty" + items: + description: The in-order list of results from processing events. + type: array + nullable: false + items: + $ref: "#/components/schemas/ackResponseItem" + x-oapi-codegen-extra-tags: + json: "items,omitempty" + uploadBeginRequest: + title: "Upload Operation Start request body" + type: object + additionalProperties: true + required: + - file + - action_id + - agent_id + - src + properties: + file: + type: object + additionalProperties: true + properties: + Compression: + description: "The algorithm used to compress the file. Valid values: br,gzip,deflate,none" + type: string + example: deflate + hash: + title: Hash + description: Checksums on the file contents + type: object + properties: + sha256: + description: SHA256 of the contents + type: string + example: 04f81394bababa0fb31e6ad2d703c875eb46dc254527e39ff316564c0dc339e2 + name: + description: Name of the file including the extension, without the directory + type: string + example: yankees-stats.zip + mime_type: + description: MIME type of the file + type: string + example: application/zip + size: + description: Size of the file contents, in bytes + type: integer + format: int64 + example: 8276748 + required: + - name + - size + - mime_type + action_id: + description: ID of the action that requested this file + type: string + example: 2f440d31-2ea4-42f8-b0f2-4b6e98e8dc5e + agent_id: + description: Identifier of the agent uploading. Matches the ID usually found in agent.id + type: string + example: 9347e918-5e00-48b0-b302-a09f9258a46d + src: + description: The source integration sending this file + type: string + enum: + - endpoint + - agent + uploadBeginResponse: + x-go-name: UploadBeginAPIResponse + description: Response to initiating a file upload + type: object + required: + - upload_id + - chunk_size + properties: + upload_id: + description: A unique identifier for the ensuing upload operation + type: string + example: fbc8e23c-055d-461e-87f7-b0d1b57f14b4 + chunk_size: + description: The required size (in bytes) that the file must be segmented into for each chunk + type: integer + format: int64 + example: 4194304 + uploadCompleteRequest: + description: Request to verify and finish an uploaded file + type: object + required: + - transithash + properties: + transithash: + description: the transithash (sha256 of the concatenation of each in-order chunk hash) of the entire file contents + type: object + required: + - sha256 + properties: + sha256: + description: SHA256 hash + type: string + example: 83810fdc61c44290778c212d7829d0c3f0232e81bd551d3943998a920025d14f + parameters: + requestId: + name: X-Request-Id + description: The request tracking ID for APM. + in: header + schema: + type: string + apiVersion: + name: Elastic-Api-Version + description: The API version to use, format should be "YYYY-MM-DD" + in: header + schema: + type: string + examples: + "2023-06-01": + value: 2023-06-01 + userAgent: + name: User-Agent + description: | + The user-agent header that is sent. + Must have the format "elastic agent X.Y.Z" where "X.Y.Z" indicates the agent version. + The agent version must not be greater than the version of the fleet-server. + in: header + required: true + schema: + type: string + examples: + valid: + description: A valid User-Agent header from the elastic-agent. + value: elastic agent 8.6.0 + validWithSuffix: + description: A version number may include an optional suffix + value: elastic agent 8.6.0-SNAPSHOT + invalidName: + description: The elastic-agent name is not formatted correctly. + value: elastic-agent 8.6.0 + outdatedVersion: + description: The version string given is too old. + value: elastic agent 7.0.0 + responses: + badRequest: + description: | + A 400 response for receiving an invalid User-Agent, Elastic-Api-Version header or version number (checkin and enroll endpoints). + In the case where an invalid or unsupported Elastic-Api-Version header is requested, the response will contain the default version number. + Or any other undefined error encounted by the fleet-server. May be returned by any endpoint except /api/fleet/status. + headers: + Elastic-Api-Version: + $ref: "#/components/headers/apiVersion" + X-Request-Id: + $ref: "#/components/headers/requestID" + content: + application/json: + schema: + $ref: "#/components/schemas/error" + examples: + badRequest: + description: Generic bad request response. + value: + statusCode: 400 + error: BadRequest + internalServerError: + description: | + A 500 response for encountering not expected bahavior. + headers: + Elastic-Api-Version: + $ref: "#/components/headers/apiVersion" + X-Request-Id: + $ref: "#/components/headers/requestID" + content: + application/json: + schema: + $ref: "#/components/schemas/error" + examples: + internalServerError: + description: Generic internal server error response. + value: + statusCode: 500 + error: InternalServerError + keyNotEnabled: + description: 401 response when the API key is not enabled on any endpoint except /api/fleet/status. Or when there are issues updating an inactive agent on the ack endpoint. + headers: + Elastic-Api-Version: + $ref: "#/components/headers/apiVersion" + X-Request-Id: + $ref: "#/components/headers/requestID" + content: + application/json: + schema: + $ref: "#/components/schemas/error" + examples: + unauthorized: + description: The ApiKey is not enabled + value: + statusCode: 401 + error: Unauthorized + message: ApiKey not enabled + agentNotFound: + description: 404 response when the agent is not found. May be returned by checkin endpoint. or endpoints that use the agentApiKey auth scheme + headers: + Elastic-Api-Version: + $ref: "#/components/headers/apiVersion" + X-Request-Id: + $ref: "#/components/headers/requestID" + content: + application/json: + schema: + $ref: "#/components/schemas/error" + examples: + agentNotFound: + description: The agent is not found. + value: + statusCode: 404 + error: AgentNotFound + message: agent could not be found + deadline: + description: 408 request timeout. + headers: + Elastic-Api-Version: + $ref: "#/components/headers/apiVersion" + X-Request-Id: + $ref: "#/components/headers/requestID" + content: + application/json: + schema: + $ref: "#/components/schemas/error" + examples: + requestTimeout: + description: Deadline exceeded. + value: + statusCode: 408 + error: RequestTimeout + message: timeout on request + throttle: + description: 428 rate limiting request. Only returned by artifacts endpoint. + headers: + # throttle is checked before api version header is validated + X-Request-Id: + $ref: "#/components/headers/requestID" + content: + application/json: + schema: + $ref: "#/components/schemas/error" + examples: + rateLimit: + description: Too many requests - rate limit reached. + value: + statusCode: 428 + error: TooManyRequests + message: too many requests + unavailable: + description: | + 503 response when the server is not available for some reason. + Such as if a context is cancelled or the connection (to ES) is refused. + May be returned by any endpoint. + headers: + Elastic-Api-Version: + $ref: "#/components/headers/apiVersion" + X-Request-Id: + $ref: "#/components/headers/requestID" + content: + application/json: + schema: + $ref: "#/components/schemas/error" + examples: + unavailable: + description: Service unavailable + value: + statusCode: 503 + error: ServiceUnavailable + message: Fleet server unable to communicate with Elasticsearch + +paths: + /api/status: + get: + operationId: status + parameters: + - $ref: "#/components/parameters/requestId" + - $ref: "#/components/parameters/apiVersion" + security: + - {} + - apiKey: [] + description: | + Return the fleet-server status. + The status code will either be 200 if healthy, or 503 if not. + Authentication for this endpoint is optional, if not provided a shorter response body is returned. + responses: + "200": + description: Healthy fleet-server response. + headers: + Elastic-Api-Version: + $ref: "#/components/headers/apiVersion" + X-Request-Id: + $ref: "#/components/headers/requestID" + content: + application/json: + schema: + $ref: "#/components/schemas/statusResponse" + examples: + unauthenticated: + description: The short response for unauthenticated requests. + value: + name: fleet-server + status: healthy + authenticated: + description: The full response for an authenticated request. + value: + name: fleet-server + status: healthy + version: + number: 8.6.0 + build_hash: fd6d862bcbebe841f930e8cdd2fa5107922e66e7 + build_time: 2022-12-01T01:02:03Z + "400": + $ref: "#/components/responses/badRequest" + "503": + description: Unhealthy fleet-server response. + headers: + Elastic-Api-Version: + $ref: "#/components/headers/apiVersion" + X-Request-Id: + $ref: "#/components/headers/requestID" + content: + text/plain: {} + application/json: + schema: + $ref: "#/components/schemas/statusResponse" + examples: + unauthenticated: + description: The short response for unauthenticated requests. + value: + name: fleet-server + status: failed + authenticated: + description: The full response for an authenticated request. + value: + name: fleet-server + status: failed + version: + number: 8.6.0 + build_hash: fd6d862bcbebe841f930e8cdd2fa5107922e66e7 + build_time: 2022-12-01T01:02:03Z + /api/fleet/agents/enroll: + post: + operationId: agentEnroll + parameters: + - $ref: "#/components/parameters/userAgent" + - $ref: "#/components/parameters/requestId" + - $ref: "#/components/parameters/apiVersion" + security: + - apiKey: [] + description: Enroll a new agent to fleet-server. The agent is enrolled in the policy encoded in the apiKey used. + requestBody: + content: + application/json: + schema: + $ref: "#/components/schemas/enrollRequest" + examples: + request: + description: A request to enroll a new agent. + value: + type: PERMANENT + metadata: + local: + elastic: + agent: + id: "" + version: 8.6.0 + snapshot: false + host: + hostname: test + tags: + - us-west + - test + responses: + "200": + description: Agent enrolled successfully. + headers: + Elastic-Api-Version: + $ref: "#/components/headers/apiVersion" + X-Request-Id: + $ref: "#/components/headers/requestID" + content: + application/json: + schema: + $ref: "#/components/schemas/enrollResponse" + examples: + success: + description: Agent enrolled successfully. + value: + action: created + item: + id: agent-test-id + active: true + policy_id: agent-policy-id + type: PERMANENT + enrolled_at: 2022-12-01T01:02:03Z + user_provided_metadata: {} + local_metadata: + elastic: + agent: + id: agent-test-id + version: 8.6.0 + snapshot: false + host: + hostname: test + access_api_key_id: api-key-id + access_api_key: api-key-token + status: online + tags: + - us-west + - test + "400": + $ref: "#/components/responses/badRequest" + "401": + $ref: "#/components/responses/keyNotEnabled" + "408": + $ref: "#/components/responses/deadline" + "500": + $ref: "#/components/responses/internalServerError" + "503": + $ref: "#/components/responses/unavailable" + /api/fleet/agents/{id}/checkin: + post: + operationId: agentCheckin + description: | + The agent checkin endpoint. + Clients will long-poll this endpoint. + A client may inform fleet-server of it's long-poll timeout in the request body. + The fleet-server will return a response if there is a new action for the agent, or if the polling timeout is reached. + The fleet-server may also use some jitter to offset the polling timeout, if specified a random amount of the jitter value may be subtracted from the polling timeout. + The fleet-sever polling timeout is short-circuited in cases of heavy load where setting up the checkin (ensuring the API key is authed etc) takes longer then the timeout value. + Fleet-server sets the poll timeout to 5m by default (with a 10m write timeout), for these values we assume that elastic-agent's request timeout is set to 10m and the cloud-proxy's timeout is longer than 10m. + parameters: + - name: id + in: path + description: The agent ID. + required: true + schema: + type: string + - name: Accept-Encoding + in: header + description: | + If the agent is able to accept encoded responses. + Used to indicate if GZIP compression may be used by the server. + The elastic-agent does not use the accept-encoding header. + schema: + type: string + - $ref: "#/components/parameters/userAgent" + - $ref: "#/components/parameters/requestId" + - $ref: "#/components/parameters/apiVersion" + security: + - agentApiKey: [] + requestBody: + content: + application/json: + schema: + $ref: "#/components/schemas/checkinRequest" + examples: + request: + description: A checkin request from an elastic-agent. + value: + status: online + message: "" + ack_token: previous-token + responses: + "200": + description: Agent checkin successful. May include actions. + headers: + Content-Encoding: + description: Responses may be compressed if the accept encoding indicates it. Currently not used by the agent. + schema: + type: string + examples: + gzip: + description: Response is gzip encoded as the request headers allowed it. + value: gzip + Elastic-Api-Version: + $ref: "#/components/headers/apiVersion" + X-Request-Id: + $ref: "#/components/headers/requestID" + content: + application/json: + schema: + $ref: "#/components/schemas/checkinResponse" + examples: + response: + description: Agent successfully checked in. + value: + action: checkin + ack_token: new-token + actions: + - agent_id: test-agent + created_at: 2022-12-01T01:02:03Z + data: + log_level: debug + id: test-action + type: SETTINGS + "400": + $ref: "#/components/responses/badRequest" + "401": + $ref: "#/components/responses/keyNotEnabled" + "404": + $ref: "#/components/responses/agentNotFound" + "408": + $ref: "#/components/responses/deadline" + "500": + $ref: "#/components/responses/internalServerError" + "503": + $ref: "#/components/responses/unavailable" + /api/fleet/agents/{id}/acks: + post: + operationId: agentAcks + description: | + The endpoint that an agent uses to acknowledge (and inform fleet-server) of events that it has recieved/executed. + A single action may have multiple different events associated with it. + Also an action may not have any acks associated with it. + parameters: + - name: id + in: path + description: The agent ID. + required: true + schema: + type: string + - $ref: "#/components/parameters/requestId" + - $ref: "#/components/parameters/apiVersion" + security: + - agentApiKey: [] + requestBody: + content: + application/json: + schema: + $ref: "#/components/schemas/ackRequest" + examples: + single: + description: Send an ack for a single event. + value: + events: + - type: ACTION_RESULT + subtype: ACKNOWLEDGED + agent_id: test-agent + action_id: test-action + timestamp: 2022-12-01T01:02:03.00004-07:00 + message: Action 'test-action' of type 'TEST' acknowledged. + responses: + "200": + description: Agent ack successfully received. + headers: + Elastic-Api-Version: + $ref: "#/components/headers/apiVersion" + X-Request-Id: + $ref: "#/components/headers/requestID" + content: + application/json: + schema: + $ref: "#/components/schemas/ackResponse" + examples: + single: + description: Successfull ack for a single action. + value: + action: acks + errors: false + items: + - status: 200 + message: ok + "400": + $ref: "#/components/responses/badRequest" + "401": + $ref: "#/components/responses/keyNotEnabled" + "404": + $ref: "#/components/responses/agentNotFound" + "408": + $ref: "#/components/responses/deadline" + "500": + $ref: "#/components/responses/internalServerError" + "503": + $ref: "#/components/responses/unavailable" + /api/fleet/artifacts/{id}/{sha2}: + get: + operationId: artifact + description: The route to retrieve an artifact from Elasticsearch. + parameters: + - name: id + in: path + description: The artifact record ID. + required: true + schema: + type: string + - name: sha2 + in: path + description: The decoded Sha256 associated with the artifact record. + required: true + schema: + type: string + - $ref: "#/components/parameters/requestId" + - $ref: "#/components/parameters/apiVersion" + security: + - agentApiKey: [] + responses: + "200": + description: The artifact retrieved from ES. + headers: + Elastic-Api-Version: + $ref: "#/components/headers/apiVersion" + X-Request-Id: + $ref: "#/components/headers/requestID" + content: + "*/*": + schema: + type: string + format: binary + "400": + $ref: "#/components/responses/badRequest" + "401": + $ref: "#/components/responses/keyNotEnabled" + "404": + $ref: "#/components/responses/agentNotFound" + "408": + $ref: "#/components/responses/deadline" + "428": + $ref: "#/components/responses/throttle" + "500": + $ref: "#/components/responses/internalServerError" + "503": + $ref: "#/components/responses/unavailable" + /api/fleet/uploads: + post: + operationId: uploadBegin + summary: Initiate a file upload process + description: "" + security: + - agentApiKey: [] + parameters: + - $ref: "#/components/parameters/requestId" + - $ref: "#/components/parameters/apiVersion" + requestBody: + required: true + description: Information about the file to be uploaded. Minimum required fields are marked as required. Additional fields may be specified and are allowed. For information about the file itself, ECS.file paths are recommended. For archived files, information about the archive should be placed in `file`. Information about the archive members may be placed in a `contents` array. + content: + application/json: + schema: + $ref: "#/components/schemas/uploadBeginRequest" + responses: + "200": + description: Information about the upload procedure + headers: + Elastic-Api-Version: + $ref: "#/components/headers/apiVersion" + X-Request-Id: + $ref: "#/components/headers/requestID" + content: + application/json: + schema: + $ref: "#/components/schemas/uploadBeginResponse" + "400": + $ref: "#/components/responses/badRequest" + "401": + $ref: "#/components/responses/keyNotEnabled" + "408": + $ref: "#/components/responses/deadline" + "500": + $ref: "#/components/responses/internalServerError" + "503": + $ref: "#/components/responses/unavailable" + /api/fleet/uploads/{id}/{chunkNum}: + put: + operationId: uploadChunk + summary: Upload a section of file data + description: "Upload portions of the intended file in a piecewise fashion. This route is idempotent in that any successive calls will overwrite previous ones for the same URL parameters. Chunks may be uploaded in any order, and may be uploaded in parallel. The body is the raw contents of the file at the given position matching the chunk number. The body must be the exact chunk size returned from the upload initiation response. All chunks must be this size except for the final one, which is naturally the file remainder." + security: + - agentApiKey: [] + parameters: + - name: id + in: path + description: The upload_id as returned in the Upload initiation response + required: true + schema: + type: string + example: ecb30383-6dd1-4b1d-bed0-2386b4e5df51 + - name: chunkNum + in: path + description: the positional index of the chunk within the file. The first chunk is 0, the next 1, etc. + required: true + schema: + type: integer + example: 3 + - name: X-Chunk-SHA2 + in: header + required: true + description: the SHA256 hash of the body contents for this request + schema: + type: string + example: 0c4a81b85a6b7ff00bde6c32e1e8be33b4b793b3b7b5cb03db93f77f7c9374d1 + - $ref: "#/components/parameters/requestId" + - $ref: "#/components/parameters/apiVersion" + requestBody: + description: The chunk contents as bytes + required: true + content: + "*/*": + schema: + type: string + format: binary + responses: + "200": + description: Successful chunk upload + headers: + Elastic-Api-Version: + $ref: "#/components/headers/apiVersion" + X-Request-Id: + $ref: "#/components/headers/requestID" + "400": + $ref: "#/components/responses/badRequest" + "401": + $ref: "#/components/responses/keyNotEnabled" + "408": + $ref: "#/components/responses/deadline" + "500": + $ref: "#/components/responses/internalServerError" + "503": + $ref: "#/components/responses/unavailable" + /api/fleet/uploads/{id}: + post: + operationId: uploadComplete + summary: Complete a file upload process + description: "" + security: + - agentApiKey: [] + requestBody: + required: true + content: + application/json: + schema: + $ref: "#/components/schemas/uploadCompleteRequest" + parameters: + - name: id + in: path + description: The upload_id as returned in the Upload initiation response + required: true + schema: + type: string + example: ecb30383-6dd1-4b1d-bed0-2386b4e5df51 + - $ref: "#/components/parameters/requestId" + - $ref: "#/components/parameters/apiVersion" + responses: + "200": + description: success response + headers: + Elastic-Api-Version: + $ref: "#/components/headers/apiVersion" + X-Request-Id: + $ref: "#/components/headers/requestID" + content: + application/json: + schema: + type: object + properties: + status: + type: string + example: "ok" + "400": + $ref: "#/components/responses/badRequest" + "401": + $ref: "#/components/responses/keyNotEnabled" + "408": + $ref: "#/components/responses/deadline" + "500": + $ref: "#/components/responses/internalServerError" + "503": + $ref: "#/components/responses/unavailable" + /api/fleet/file/{id}: + get: + operationId: getFile + summary: retrieve stored file for integration + description: "Stream out file contents to an agent or integration, provided there is a matching and authorized file stored in elasticsearch." + security: + - agentApiKey: [] + parameters: + - name: id + in: path + description: The file_id as provided to the integration + required: true + schema: + type: string + example: ecb30383-6dd1-4b1d-bed0-2386b4e5df51 + - $ref: "#/components/parameters/requestId" + - $ref: "#/components/parameters/apiVersion" + responses: + "200": + description: File Contents. + headers: + X-File-Sha2: + description: SHA256 digest of the file contents. Only sent when the uploaded file contains a file.hash.sha256 value. + schema: + type: string + example: 0c4a81b85a6b7ff00bde6c32e1e8be33b4b793b3b7b5cb03db93f77f7c9374d1 + Elastic-Api-Version: + $ref: "#/components/headers/apiVersion" + X-Request-Id: + $ref: "#/components/headers/requestID" + content: + "*/*": + schema: + type: string + format: binary + "400": + $ref: "#/components/responses/badRequest" + "401": + $ref: "#/components/responses/keyNotEnabled" + "403": + description: The requesting entity is not permitted to access the requested file + headers: + Elastic-Api-Version: + $ref: "#/components/headers/apiVersion" + X-Request-Id: + $ref: "#/components/headers/requestID" + content: + application/json: + schema: + $ref: "#/components/schemas/error" + examples: + unauthorized: + description: The file is not accessible + value: + statusCode: 403 + error: Forbidden + message: Client is not authorized + "404": + description: bad path, file not found + headers: + Elastic-Api-Version: + $ref: "#/components/headers/apiVersion" + X-Request-Id: + $ref: "#/components/headers/requestID" + "500": + $ref: "#/components/responses/internalServerError" + "503": + $ref: "#/components/responses/unavailable" diff --git a/pkg/api/versions/2022_06_01/api/types.gen.go b/pkg/api/versions/2023_06_01/api/types.gen.go similarity index 94% rename from pkg/api/versions/2022_06_01/api/types.gen.go rename to pkg/api/versions/2023_06_01/api/types.gen.go index 8b0f495ed..e5fbdeaa8 100644 --- a/pkg/api/versions/2022_06_01/api/types.gen.go +++ b/pkg/api/versions/2023_06_01/api/types.gen.go @@ -534,20 +534,20 @@ type AgentEnrollParams struct { // The agent version must not be greater than the version of the fleet-server. UserAgent UserAgent `json:"User-Agent"` - // XRequestID The request tracking ID for APM. - XRequestID *RequestId `json:"X-Request-ID,omitempty"` + // XRequestId The request tracking ID for APM. + XRequestId *RequestId `json:"X-Request-Id,omitempty"` // ElasticApiVersion The API version to use, format should be "YYYY-MM-DD" - ElasticApiVersion *ApiVersion `json:"elastic-api-version,omitempty"` + ElasticApiVersion *ApiVersion `json:"Elastic-Api-Version,omitempty"` } // AgentAcksParams defines parameters for AgentAcks. type AgentAcksParams struct { - // XRequestID The request tracking ID for APM. - XRequestID *RequestId `json:"X-Request-ID,omitempty"` + // XRequestId The request tracking ID for APM. + XRequestId *RequestId `json:"X-Request-Id,omitempty"` // ElasticApiVersion The API version to use, format should be "YYYY-MM-DD" - ElasticApiVersion *ApiVersion `json:"elastic-api-version,omitempty"` + ElasticApiVersion *ApiVersion `json:"Elastic-Api-Version,omitempty"` } // AgentCheckinParams defines parameters for AgentCheckin. @@ -562,38 +562,47 @@ type AgentCheckinParams struct { // The agent version must not be greater than the version of the fleet-server. UserAgent UserAgent `json:"User-Agent"` - // XRequestID The request tracking ID for APM. - XRequestID *RequestId `json:"X-Request-ID,omitempty"` + // XRequestId The request tracking ID for APM. + XRequestId *RequestId `json:"X-Request-Id,omitempty"` // ElasticApiVersion The API version to use, format should be "YYYY-MM-DD" - ElasticApiVersion *ApiVersion `json:"elastic-api-version,omitempty"` + ElasticApiVersion *ApiVersion `json:"Elastic-Api-Version,omitempty"` } // ArtifactParams defines parameters for Artifact. type ArtifactParams struct { - // XRequestID The request tracking ID for APM. - XRequestID *RequestId `json:"X-Request-ID,omitempty"` + // XRequestId The request tracking ID for APM. + XRequestId *RequestId `json:"X-Request-Id,omitempty"` // ElasticApiVersion The API version to use, format should be "YYYY-MM-DD" - ElasticApiVersion *ApiVersion `json:"elastic-api-version,omitempty"` + ElasticApiVersion *ApiVersion `json:"Elastic-Api-Version,omitempty"` +} + +// GetFileParams defines parameters for GetFile. +type GetFileParams struct { + // XRequestId The request tracking ID for APM. + XRequestId *RequestId `json:"X-Request-Id,omitempty"` + + // ElasticApiVersion The API version to use, format should be "YYYY-MM-DD" + ElasticApiVersion *ApiVersion `json:"Elastic-Api-Version,omitempty"` } // UploadBeginParams defines parameters for UploadBegin. type UploadBeginParams struct { - // XRequestID The request tracking ID for APM. - XRequestID *RequestId `json:"X-Request-ID,omitempty"` + // XRequestId The request tracking ID for APM. + XRequestId *RequestId `json:"X-Request-Id,omitempty"` // ElasticApiVersion The API version to use, format should be "YYYY-MM-DD" - ElasticApiVersion *ApiVersion `json:"elastic-api-version,omitempty"` + ElasticApiVersion *ApiVersion `json:"Elastic-Api-Version,omitempty"` } // UploadCompleteParams defines parameters for UploadComplete. type UploadCompleteParams struct { - // XRequestID The request tracking ID for APM. - XRequestID *RequestId `json:"X-Request-ID,omitempty"` + // XRequestId The request tracking ID for APM. + XRequestId *RequestId `json:"X-Request-Id,omitempty"` // ElasticApiVersion The API version to use, format should be "YYYY-MM-DD" - ElasticApiVersion *ApiVersion `json:"elastic-api-version,omitempty"` + ElasticApiVersion *ApiVersion `json:"Elastic-Api-Version,omitempty"` } // UploadChunkParams defines parameters for UploadChunk. @@ -601,20 +610,20 @@ type UploadChunkParams struct { // XChunkSHA2 the SHA256 hash of the body contents for this request XChunkSHA2 string `json:"X-Chunk-SHA2"` - // XRequestID The request tracking ID for APM. - XRequestID *RequestId `json:"X-Request-ID,omitempty"` + // XRequestId The request tracking ID for APM. + XRequestId *RequestId `json:"X-Request-Id,omitempty"` // ElasticApiVersion The API version to use, format should be "YYYY-MM-DD" - ElasticApiVersion *ApiVersion `json:"elastic-api-version,omitempty"` + ElasticApiVersion *ApiVersion `json:"Elastic-Api-Version,omitempty"` } // StatusParams defines parameters for Status. type StatusParams struct { - // XRequestID The request tracking ID for APM. - XRequestID *RequestId `json:"X-Request-ID,omitempty"` + // XRequestId The request tracking ID for APM. + XRequestId *RequestId `json:"X-Request-Id,omitempty"` // ElasticApiVersion The API version to use, format should be "YYYY-MM-DD" - ElasticApiVersion *ApiVersion `json:"elastic-api-version,omitempty"` + ElasticApiVersion *ApiVersion `json:"Elastic-Api-Version,omitempty"` } // AgentEnrollJSONRequestBody defines body for AgentEnroll for application/json ContentType. diff --git a/testing/e2e/api_version/client_api_2023_06_01.go b/testing/e2e/api_version/client_api_2023_06_01.go index 9407427f3..ecaf264f1 100644 --- a/testing/e2e/api_version/client_api_2023_06_01.go +++ b/testing/e2e/api_version/client_api_2023_06_01.go @@ -19,7 +19,7 @@ import ( "time" "github.com/elastic/fleet-server/testing/e2e/scaffold" - "github.com/elastic/fleet-server/v7/pkg/api/versions/2022_06_01/api" + "github.com/elastic/fleet-server/v7/pkg/api/versions/2023_06_01/api" "github.com/elastic/fleet-server/v7/version" ) diff --git a/testing/e2e/api_version/client_api_current.go b/testing/e2e/api_version/client_api_current.go index 409505fa6..f03e10f7a 100644 --- a/testing/e2e/api_version/client_api_current.go +++ b/testing/e2e/api_version/client_api_current.go @@ -249,7 +249,7 @@ func (tester *ClientAPITester) GetPGPKey(ctx context.Context, apiKey string) []b })) tester.Require().NoError(err) - resp, err := client.GetPGPKeyWithResponse(ctx, 1, 2, 3) + resp, err := client.GetPGPKeyWithResponse(ctx, 1, 2, 3, nil) tester.Require().NoError(err) if strings.HasPrefix(tester.endpoint, "https") { tester.Require().Equal(http.StatusOK, resp.StatusCode())