Skip to content

Commit

Permalink
added download_rate to openapi (#3177)
Browse files Browse the repository at this point in the history
* added download_rate to openapi

* fix lint

* fix lint

* added download retry fields

* Update model/openapi.yml

Co-authored-by: Craig MacKenzie <[email protected]>

* Update model/openapi.yml

Co-authored-by: Craig MacKenzie <[email protected]>

* update generated files

---------

Co-authored-by: Craig MacKenzie <[email protected]>
  • Loading branch information
juliaElastic and cmacknz authored Jan 2, 2024
1 parent a244bbe commit 9f4de48
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 5 deletions.
2 changes: 1 addition & 1 deletion NOTICE.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Elastic Beats
Copyright 2014-2023 Elasticsearch BV
Copyright 2014-2024 Elasticsearch BV

This product includes software developed by The Apache Software
Foundation (http://www.apache.org/).
Expand Down
9 changes: 9 additions & 0 deletions internal/pkg/api/openapi.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 9 additions & 4 deletions internal/pkg/api/openapi_spec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// or more contributor license agreements. Licensed under the Elastic License;
// you may not use this file except in compliance with the Elastic License.

//nolint:dupl,goconst // don't care about repitition for tests
//nolint:goconst // don't care about repitition for tests
package api

// Test json encoding/decoding for all req/resp items
Expand Down Expand Up @@ -190,6 +190,7 @@ func Test_UpgradeDetailsMetadata_Downloading(t *testing.T) {
md *UpgradeDetails_Metadata
err error
pct float64
rate float64
}{{
name: "empty object",
md: &UpgradeDetails_Metadata{
Expand All @@ -200,10 +201,11 @@ func Test_UpgradeDetailsMetadata_Downloading(t *testing.T) {
}, {
name: "valid object",
md: &UpgradeDetails_Metadata{
union: json.RawMessage(`{"download_percent":1}`),
union: json.RawMessage(`{"download_percent":1,"download_rate":1000}`),
},
err: nil,
pct: 1,
err: nil,
pct: 1,
rate: 1000,
}, {
name: "invalid object",
md: &UpgradeDetails_Metadata{
Expand Down Expand Up @@ -232,6 +234,9 @@ func Test_UpgradeDetailsMetadata_Downloading(t *testing.T) {
meta, err := tc.md.AsUpgradeMetadataDownloading()
if tc.err == nil {
assert.Equal(t, tc.pct, meta.DownloadPercent)
if meta.DownloadRate != nil {
assert.Equal(t, tc.rate, *meta.DownloadRate)
}
} else {
assert.ErrorAsf(t, err, &tc.err, "error is %v", err)
}
Expand Down
12 changes: 12 additions & 0 deletions model/openapi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,17 @@ components:
description: The artifact download progress as a percentage.
type: number
format: double
download_rate:
description: The artifact download rate as bytes per second.
type: number
format: double
retry_error_msg:
description: The error message that is a result of a retryable upgrade download failure.
type: string
retry_until:
description: The RFC3339 timestamp of the deadline the upgrade download is retried until.
type: string
format: date-time
upgrade_metadata_failed:
description: Upgrade metadata for an upgrade that has failed.
required:
Expand Down Expand Up @@ -1301,6 +1312,7 @@ paths:
state: UPG_DOWNLOADING
metadata:
download_percent: 12.3
download_rate: 1024
responses:
"200":
description: Agent checkin successful. May include actions.
Expand Down
9 changes: 9 additions & 0 deletions pkg/api/types.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 9f4de48

Please sign in to comment.