summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Mazuruk <a.mazuruk@samsung.com>2018-02-27 14:39:00 +0100
committerAlexander Mazuruk <a.mazuruk@samsung.com>2018-07-26 07:32:39 +0200
commit4d17971d343e04fbdbd35ba4516b7c177fae2879 (patch)
tree933f8254c7193c77373e0a4a14aa4f61564a3280
parent4f73896675ad9a5bf59589477cd00b6d6ca6d905 (diff)
downloadweles-4d17971d343e04fbdbd35ba4516b7c177fae2879.tar.gz
weles-4d17971d343e04fbdbd35ba4516b7c177fae2879.tar.bz2
weles-4d17971d343e04fbdbd35ba4516b7c177fae2879.zip
Add new types to weles to enable pagination
Types generated by swagger: - JobFilter containing filters - JobSorter containing information about sorting the data - JobSortBy containing enum of possible sorting keys for jobs - SortOrder containing enum of possible sorting orders Types added manually: - JobPagination containing info how much data should be listed and where should it start. Limit is int32 as Weles is intended to work on both 64 and 32 bit architectures. Due to varying integer size (which is slice limit) on those archs, max slice len is constrained to be 32bit. - ListInfo which holds number of total records fulfilling filter and remaining records that have not yet been sent to the client. Change-Id: I59e441da86856fd2bc57817ce8903ef96f669e97 Signed-off-by: Alexander Mazuruk <a.mazuruk@samsung.com>
-rw-r--r--job_filter.go208
-rw-r--r--job_filter_and_sort.go111
-rw-r--r--job_pagination.go28
-rw-r--r--job_sort_by.go90
-rw-r--r--job_sorter.go108
-rw-r--r--list_info.go25
-rw-r--r--server/embedded_spec.go150
-rw-r--r--sort_order.go83
-rw-r--r--swagger.yml69
9 files changed, 872 insertions, 0 deletions
diff --git a/job_filter.go b/job_filter.go
new file mode 100644
index 0000000..8f63c47
--- /dev/null
+++ b/job_filter.go
@@ -0,0 +1,208 @@
+// Code generated by go-swagger; DO NOT EDIT.
+
+// Copyright (c) 2017-2018 Samsung Electronics Co., Ltd All Rights Reserved
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License
+//
+
+package weles
+
+// This file was generated by the swagger tool.
+// Editing this file might prove futile when you re-run the swagger generate command
+
+import (
+ "strconv"
+
+ strfmt "github.com/go-openapi/strfmt"
+
+ "github.com/go-openapi/errors"
+ "github.com/go-openapi/swag"
+ "github.com/go-openapi/validate"
+)
+
+// JobFilter is used to filter Weles Jobs.
+// swagger:model JobFilter
+type JobFilter struct {
+
+ // created after
+ // Format: date-time
+ CreatedAfter strfmt.DateTime `json:"CreatedAfter,omitempty"`
+
+ // created before
+ // Format: date-time
+ CreatedBefore strfmt.DateTime `json:"CreatedBefore,omitempty"`
+
+ // info
+ Info []string `json:"Info"`
+
+ // job ID
+ JobID []JobID `json:"JobID"`
+
+ // name
+ Name []string `json:"Name"`
+
+ // status
+ Status []JobStatus `json:"Status"`
+
+ // updated after
+ // Format: date-time
+ UpdatedAfter strfmt.DateTime `json:"UpdatedAfter,omitempty"`
+
+ // updated before
+ // Format: date-time
+ UpdatedBefore strfmt.DateTime `json:"UpdatedBefore,omitempty"`
+}
+
+// Validate validates this job filter
+func (m *JobFilter) Validate(formats strfmt.Registry) error {
+ var res []error
+
+ if err := m.validateCreatedAfter(formats); err != nil {
+ res = append(res, err)
+ }
+
+ if err := m.validateCreatedBefore(formats); err != nil {
+ res = append(res, err)
+ }
+
+ if err := m.validateJobID(formats); err != nil {
+ res = append(res, err)
+ }
+
+ if err := m.validateStatus(formats); err != nil {
+ res = append(res, err)
+ }
+
+ if err := m.validateUpdatedAfter(formats); err != nil {
+ res = append(res, err)
+ }
+
+ if err := m.validateUpdatedBefore(formats); err != nil {
+ res = append(res, err)
+ }
+
+ if len(res) > 0 {
+ return errors.CompositeValidationError(res...)
+ }
+ return nil
+}
+
+func (m *JobFilter) validateCreatedAfter(formats strfmt.Registry) error {
+
+ if swag.IsZero(m.CreatedAfter) { // not required
+ return nil
+ }
+
+ if err := validate.FormatOf("CreatedAfter", "body", "date-time", m.CreatedAfter.String(), formats); err != nil {
+ return err
+ }
+
+ return nil
+}
+
+func (m *JobFilter) validateCreatedBefore(formats strfmt.Registry) error {
+
+ if swag.IsZero(m.CreatedBefore) { // not required
+ return nil
+ }
+
+ if err := validate.FormatOf("CreatedBefore", "body", "date-time", m.CreatedBefore.String(), formats); err != nil {
+ return err
+ }
+
+ return nil
+}
+
+func (m *JobFilter) validateJobID(formats strfmt.Registry) error {
+
+ if swag.IsZero(m.JobID) { // not required
+ return nil
+ }
+
+ for i := 0; i < len(m.JobID); i++ {
+
+ if err := m.JobID[i].Validate(formats); err != nil {
+ if ve, ok := err.(*errors.Validation); ok {
+ return ve.ValidateName("JobID" + "." + strconv.Itoa(i))
+ }
+ return err
+ }
+
+ }
+
+ return nil
+}
+
+func (m *JobFilter) validateStatus(formats strfmt.Registry) error {
+
+ if swag.IsZero(m.Status) { // not required
+ return nil
+ }
+
+ for i := 0; i < len(m.Status); i++ {
+
+ if err := m.Status[i].Validate(formats); err != nil {
+ if ve, ok := err.(*errors.Validation); ok {
+ return ve.ValidateName("Status" + "." + strconv.Itoa(i))
+ }
+ return err
+ }
+
+ }
+
+ return nil
+}
+
+func (m *JobFilter) validateUpdatedAfter(formats strfmt.Registry) error {
+
+ if swag.IsZero(m.UpdatedAfter) { // not required
+ return nil
+ }
+
+ if err := validate.FormatOf("UpdatedAfter", "body", "date-time", m.UpdatedAfter.String(), formats); err != nil {
+ return err
+ }
+
+ return nil
+}
+
+func (m *JobFilter) validateUpdatedBefore(formats strfmt.Registry) error {
+
+ if swag.IsZero(m.UpdatedBefore) { // not required
+ return nil
+ }
+
+ if err := validate.FormatOf("UpdatedBefore", "body", "date-time", m.UpdatedBefore.String(), formats); err != nil {
+ return err
+ }
+
+ return nil
+}
+
+// MarshalBinary interface implementation
+func (m *JobFilter) MarshalBinary() ([]byte, error) {
+ if m == nil {
+ return nil, nil
+ }
+ return swag.WriteJSON(m)
+}
+
+// UnmarshalBinary interface implementation
+func (m *JobFilter) UnmarshalBinary(b []byte) error {
+ var res JobFilter
+ if err := swag.ReadJSON(b, &res); err != nil {
+ return err
+ }
+ *m = res
+ return nil
+}
diff --git a/job_filter_and_sort.go b/job_filter_and_sort.go
new file mode 100644
index 0000000..c918289
--- /dev/null
+++ b/job_filter_and_sort.go
@@ -0,0 +1,111 @@
+// Code generated by go-swagger; DO NOT EDIT.
+
+// Copyright (c) 2017-2018 Samsung Electronics Co., Ltd All Rights Reserved
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License
+//
+
+package weles
+
+// This file was generated by the swagger tool.
+// Editing this file might prove futile when you re-run the swagger generate command
+
+import (
+ strfmt "github.com/go-openapi/strfmt"
+
+ "github.com/go-openapi/errors"
+ "github.com/go-openapi/swag"
+)
+
+// JobFilterAndSort Data for filtering and sorting Weles Jobs lists.
+// swagger:model JobFilterAndSort
+type JobFilterAndSort struct {
+
+ // job filter
+ JobFilter *JobFilter `json:"JobFilter,omitempty"`
+
+ // job sorter
+ JobSorter *JobSorter `json:"JobSorter,omitempty"`
+}
+
+// Validate validates this job filter and sort
+func (m *JobFilterAndSort) Validate(formats strfmt.Registry) error {
+ var res []error
+
+ if err := m.validateJobFilter(formats); err != nil {
+ res = append(res, err)
+ }
+
+ if err := m.validateJobSorter(formats); err != nil {
+ res = append(res, err)
+ }
+
+ if len(res) > 0 {
+ return errors.CompositeValidationError(res...)
+ }
+ return nil
+}
+
+func (m *JobFilterAndSort) validateJobFilter(formats strfmt.Registry) error {
+
+ if swag.IsZero(m.JobFilter) { // not required
+ return nil
+ }
+
+ if m.JobFilter != nil {
+ if err := m.JobFilter.Validate(formats); err != nil {
+ if ve, ok := err.(*errors.Validation); ok {
+ return ve.ValidateName("JobFilter")
+ }
+ return err
+ }
+ }
+
+ return nil
+}
+
+func (m *JobFilterAndSort) validateJobSorter(formats strfmt.Registry) error {
+
+ if swag.IsZero(m.JobSorter) { // not required
+ return nil
+ }
+
+ if m.JobSorter != nil {
+ if err := m.JobSorter.Validate(formats); err != nil {
+ if ve, ok := err.(*errors.Validation); ok {
+ return ve.ValidateName("JobSorter")
+ }
+ return err
+ }
+ }
+
+ return nil
+}
+
+// MarshalBinary interface implementation
+func (m *JobFilterAndSort) MarshalBinary() ([]byte, error) {
+ if m == nil {
+ return nil, nil
+ }
+ return swag.WriteJSON(m)
+}
+
+// UnmarshalBinary interface implementation
+func (m *JobFilterAndSort) UnmarshalBinary(b []byte) error {
+ var res JobFilterAndSort
+ if err := swag.ReadJSON(b, &res); err != nil {
+ return err
+ }
+ *m = res
+ return nil
+}
diff --git a/job_pagination.go b/job_pagination.go
new file mode 100644
index 0000000..bf83f84
--- /dev/null
+++ b/job_pagination.go
@@ -0,0 +1,28 @@
+// Copyright (c) 2017-2018 Samsung Electronics Co., Ltd All Rights Reserved
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License
+
+package weles
+
+// JobPagination holds information neccessary to request for a single page of data.
+// When JobID is set, and Forward is false - Controller should return a page of records before the
+// supplied JobID.
+// When JobID is set, and Forward is true - Controller should return page of record after the
+// supplied JobID.
+// In both cases, returned page should not include supplied JobID.
+// Limit denotes the number of records to be returned on the page.
+type JobPagination struct {
+ JobID JobID
+ Forward bool
+ Limit int32
+}
diff --git a/job_sort_by.go b/job_sort_by.go
new file mode 100644
index 0000000..dc3a366
--- /dev/null
+++ b/job_sort_by.go
@@ -0,0 +1,90 @@
+// Code generated by go-swagger; DO NOT EDIT.
+
+// Copyright (c) 2017-2018 Samsung Electronics Co., Ltd All Rights Reserved
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License
+//
+
+package weles
+
+// This file was generated by the swagger tool.
+// Editing this file might prove futile when you re-run the swagger generate command
+
+import (
+ "encoding/json"
+
+ strfmt "github.com/go-openapi/strfmt"
+
+ "github.com/go-openapi/errors"
+ "github.com/go-openapi/validate"
+)
+
+// JobSortBy denotes key for sorting Jobs list. Jobs are sorted by ID (Ascending) by default.
+// You can sort jobs additionaly by
+//
+// * CreatedDate - sorting by date of creation of the weles job.
+//
+// * UpdatedDate - sorting by date of update of the weles job.
+//
+// * JobStatus - sorting by the Job Status. Descending order will sort in the order JobStatuses are listed in the docs (from NEW at the start to CANCELED at the end). Ascending will reverse this order.
+// When sorting is applied, and there are many jobs with the same date/status, they will be sorted by JobID (Ascending)
+//
+// swagger:model JobSortBy
+type JobSortBy string
+
+const (
+
+ // JobSortByCreatedDate captures enum value "CreatedDate"
+ JobSortByCreatedDate JobSortBy = "CreatedDate"
+
+ // JobSortByUpdatedDate captures enum value "UpdatedDate"
+ JobSortByUpdatedDate JobSortBy = "UpdatedDate"
+
+ // JobSortByJobStatus captures enum value "JobStatus"
+ JobSortByJobStatus JobSortBy = "JobStatus"
+)
+
+// for schema
+var jobSortByEnum []interface{}
+
+func init() {
+ var res []JobSortBy
+ if err := json.Unmarshal([]byte(`["CreatedDate","UpdatedDate","JobStatus"]`), &res); err != nil {
+ panic(err)
+ }
+ for _, v := range res {
+ jobSortByEnum = append(jobSortByEnum, v)
+ }
+}
+
+func (m JobSortBy) validateJobSortByEnum(path, location string, value JobSortBy) error {
+ if err := validate.Enum(path, location, value, jobSortByEnum); err != nil {
+ return err
+ }
+ return nil
+}
+
+// Validate validates this job sort by
+func (m JobSortBy) Validate(formats strfmt.Registry) error {
+ var res []error
+
+ // value enum
+ if err := m.validateJobSortByEnum("", "body", m); err != nil {
+ return err
+ }
+
+ if len(res) > 0 {
+ return errors.CompositeValidationError(res...)
+ }
+ return nil
+}
diff --git a/job_sorter.go b/job_sorter.go
new file mode 100644
index 0000000..efcdcdb
--- /dev/null
+++ b/job_sorter.go
@@ -0,0 +1,108 @@
+// Code generated by go-swagger; DO NOT EDIT.
+
+// Copyright (c) 2017-2018 Samsung Electronics Co., Ltd All Rights Reserved
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License
+//
+
+package weles
+
+// This file was generated by the swagger tool.
+// Editing this file might prove futile when you re-run the swagger generate command
+
+import (
+ strfmt "github.com/go-openapi/strfmt"
+
+ "github.com/go-openapi/errors"
+ "github.com/go-openapi/swag"
+)
+
+// JobSorter defines the key for sorting as well as direction of sorting.
+//
+// swagger:model JobSorter
+type JobSorter struct {
+
+ // sort by
+ SortBy JobSortBy `json:"SortBy,omitempty"`
+
+ // sort order
+ SortOrder SortOrder `json:"SortOrder,omitempty"`
+}
+
+// Validate validates this job sorter
+func (m *JobSorter) Validate(formats strfmt.Registry) error {
+ var res []error
+
+ if err := m.validateSortBy(formats); err != nil {
+ res = append(res, err)
+ }
+
+ if err := m.validateSortOrder(formats); err != nil {
+ res = append(res, err)
+ }
+
+ if len(res) > 0 {
+ return errors.CompositeValidationError(res...)
+ }
+ return nil
+}
+
+func (m *JobSorter) validateSortBy(formats strfmt.Registry) error {
+
+ if swag.IsZero(m.SortBy) { // not required
+ return nil
+ }
+
+ if err := m.SortBy.Validate(formats); err != nil {
+ if ve, ok := err.(*errors.Validation); ok {
+ return ve.ValidateName("SortBy")
+ }
+ return err
+ }
+
+ return nil
+}
+
+func (m *JobSorter) validateSortOrder(formats strfmt.Registry) error {
+
+ if swag.IsZero(m.SortOrder) { // not required
+ return nil
+ }
+
+ if err := m.SortOrder.Validate(formats); err != nil {
+ if ve, ok := err.(*errors.Validation); ok {
+ return ve.ValidateName("SortOrder")
+ }
+ return err
+ }
+
+ return nil
+}
+
+// MarshalBinary interface implementation
+func (m *JobSorter) MarshalBinary() ([]byte, error) {
+ if m == nil {
+ return nil, nil
+ }
+ return swag.WriteJSON(m)
+}
+
+// UnmarshalBinary interface implementation
+func (m *JobSorter) UnmarshalBinary(b []byte) error {
+ var res JobSorter
+ if err := swag.ReadJSON(b, &res); err != nil {
+ return err
+ }
+ *m = res
+ return nil
+}
diff --git a/list_info.go b/list_info.go
new file mode 100644
index 0000000..c9800d7
--- /dev/null
+++ b/list_info.go
@@ -0,0 +1,25 @@
+// Copyright (c) 2017-2018 Samsung Electronics Co., Ltd All Rights Reserved
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License
+
+package weles
+
+// ListInfo is a struct holding information to be returned by JobManager and ArtifactManager with
+// lists of data.
+// TotalRecords is returned to the user by API.
+// RemainingRecords is used by API internally to return correct HTTP status codes (206 partial
+// content and 200 ok).
+type ListInfo struct {
+ TotalRecords uint64
+ RemainingRecords uint64
+}
diff --git a/server/embedded_spec.go b/server/embedded_spec.go
index f3c899c..8928ca6 100644
--- a/server/embedded_spec.go
+++ b/server/embedded_spec.go
@@ -258,6 +258,52 @@ func init() {
}
}
},
+ "JobFilter": {
+ "description": "is used to filter Weles Jobs.",
+ "type": "object",
+ "properties": {
+ "CreatedAfter": {
+ "type": "string",
+ "format": "date-time"
+ },
+ "CreatedBefore": {
+ "type": "string",
+ "format": "date-time"
+ },
+ "Info": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "JobID": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/JobID"
+ }
+ },
+ "Name": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "Status": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/JobStatus"
+ }
+ },
+ "UpdatedAfter": {
+ "type": "string",
+ "format": "date-time"
+ },
+ "UpdatedBefore": {
+ "type": "string",
+ "format": "date-time"
+ }
+ }
+ },
"JobID": {
"description": "is a unique identifier for Weles Job.",
"type": "integer",
@@ -295,6 +341,27 @@ func init() {
}
}
},
+ "JobSortBy": {
+ "description": "denotes key for sorting Jobs list. Jobs are sorted by ID (Ascending) by default.\nYou can sort jobs additionaly by\n\n* CreatedDate - sorting by date of creation of the weles job.\n\n* UpdatedDate - sorting by date of update of the weles job.\n\n* JobStatus - sorting by the Job Status. Descending order will sort in the order JobStatuses are listed in the docs (from NEW at the start to CANCELED at the end). Ascending will reverse this order.\nWhen sorting is applied, and there are many jobs with the same date/status, they will be sorted by JobID (Ascending)\n",
+ "type": "string",
+ "enum": [
+ "CreatedDate",
+ "UpdatedDate",
+ "JobStatus"
+ ]
+ },
+ "JobSorter": {
+ "description": "defines the key for sorting as well as direction of sorting.\n",
+ "type": "object",
+ "properties": {
+ "SortBy": {
+ "$ref": "#/definitions/JobSortBy"
+ },
+ "SortOrder": {
+ "$ref": "#/definitions/SortOrder"
+ }
+ }
+ },
"JobStatus": {
"description": "specifies state of the Job.\n\n* NEW - The new Job has been created.\n\n* PARSING - Provided yaml file is being parsed and interpreted.\n\n* DOWNLOADING - Images and/or files required for the test are being downloaded.\n\n* WAITING - Job is waiting for Boruta worker.\n\n* RUNNING - Job is being executed.\n\n* COMPLETED - Job is completed. This is terminal state.\n\n* FAILED - Job execution has failed. This is terminal state.\n\n* CANCELED -Job has been canceled with API call. This is terminal state.\n",
"type": "string",
@@ -308,6 +375,14 @@ func init() {
"FAILED",
"CANCELED"
]
+ },
+ "SortOrder": {
+ "description": "denotes direction of sorting of weles jobs or artifacts.\n\n* Ascending - from oldest to newest.\n\n* Descending - from newest to oldest.\n",
+ "type": "string",
+ "enum": [
+ "Ascending",
+ "Descending"
+ ]
}
},
"responses": {
@@ -597,6 +672,52 @@ func init() {
}
}
},
+ "JobFilter": {
+ "description": "is used to filter Weles Jobs.",
+ "type": "object",
+ "properties": {
+ "CreatedAfter": {
+ "type": "string",
+ "format": "date-time"
+ },
+ "CreatedBefore": {
+ "type": "string",
+ "format": "date-time"
+ },
+ "Info": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "JobID": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/JobID"
+ }
+ },
+ "Name": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "Status": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/JobStatus"
+ }
+ },
+ "UpdatedAfter": {
+ "type": "string",
+ "format": "date-time"
+ },
+ "UpdatedBefore": {
+ "type": "string",
+ "format": "date-time"
+ }
+ }
+ },
"JobID": {
"description": "is a unique identifier for Weles Job.",
"type": "integer",
@@ -634,6 +755,27 @@ func init() {
}
}
},
+ "JobSortBy": {
+ "description": "denotes key for sorting Jobs list. Jobs are sorted by ID (Ascending) by default.\nYou can sort jobs additionaly by\n\n* CreatedDate - sorting by date of creation of the weles job.\n\n* UpdatedDate - sorting by date of update of the weles job.\n\n* JobStatus - sorting by the Job Status. Descending order will sort in the order JobStatuses are listed in the docs (from NEW at the start to CANCELED at the end). Ascending will reverse this order.\nWhen sorting is applied, and there are many jobs with the same date/status, they will be sorted by JobID (Ascending)\n",
+ "type": "string",
+ "enum": [
+ "CreatedDate",
+ "UpdatedDate",
+ "JobStatus"
+ ]
+ },
+ "JobSorter": {
+ "description": "defines the key for sorting as well as direction of sorting.\n",
+ "type": "object",
+ "properties": {
+ "SortBy": {
+ "$ref": "#/definitions/JobSortBy"
+ },
+ "SortOrder": {
+ "$ref": "#/definitions/SortOrder"
+ }
+ }
+ },
"JobStatus": {
"description": "specifies state of the Job.\n\n* NEW - The new Job has been created.\n\n* PARSING - Provided yaml file is being parsed and interpreted.\n\n* DOWNLOADING - Images and/or files required for the test are being downloaded.\n\n* WAITING - Job is waiting for Boruta worker.\n\n* RUNNING - Job is being executed.\n\n* COMPLETED - Job is completed. This is terminal state.\n\n* FAILED - Job execution has failed. This is terminal state.\n\n* CANCELED -Job has been canceled with API call. This is terminal state.\n",
"type": "string",
@@ -647,6 +789,14 @@ func init() {
"FAILED",
"CANCELED"
]
+ },
+ "SortOrder": {
+ "description": "denotes direction of sorting of weles jobs or artifacts.\n\n* Ascending - from oldest to newest.\n\n* Descending - from newest to oldest.\n",
+ "type": "string",
+ "enum": [
+ "Ascending",
+ "Descending"
+ ]
}
},
"responses": {
diff --git a/sort_order.go b/sort_order.go
new file mode 100644
index 0000000..f650ceb
--- /dev/null
+++ b/sort_order.go
@@ -0,0 +1,83 @@
+// Code generated by go-swagger; DO NOT EDIT.
+
+// Copyright (c) 2017-2018 Samsung Electronics Co., Ltd All Rights Reserved
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License
+//
+
+package weles
+
+// This file was generated by the swagger tool.
+// Editing this file might prove futile when you re-run the swagger generate command
+
+import (
+ "encoding/json"
+
+ strfmt "github.com/go-openapi/strfmt"
+
+ "github.com/go-openapi/errors"
+ "github.com/go-openapi/validate"
+)
+
+// SortOrder denotes direction of sorting of weles jobs or artifacts.
+//
+// * Ascending - from oldest to newest.
+//
+// * Descending - from newest to oldest.
+//
+// swagger:model SortOrder
+type SortOrder string
+
+const (
+
+ // SortOrderAscending captures enum value "Ascending"
+ SortOrderAscending SortOrder = "Ascending"
+
+ // SortOrderDescending captures enum value "Descending"
+ SortOrderDescending SortOrder = "Descending"
+)
+
+// for schema
+var sortOrderEnum []interface{}
+
+func init() {
+ var res []SortOrder
+ if err := json.Unmarshal([]byte(`["Ascending","Descending"]`), &res); err != nil {
+ panic(err)
+ }
+ for _, v := range res {
+ sortOrderEnum = append(sortOrderEnum, v)
+ }
+}
+
+func (m SortOrder) validateSortOrderEnum(path, location string, value SortOrder) error {
+ if err := validate.Enum(path, location, value, sortOrderEnum); err != nil {
+ return err
+ }
+ return nil
+}
+
+// Validate validates this sort order
+func (m SortOrder) Validate(formats strfmt.Registry) error {
+ var res []error
+
+ // value enum
+ if err := m.validateSortOrderEnum("", "body", m); err != nil {
+ return err
+ }
+
+ if len(res) > 0 {
+ return errors.CompositeValidationError(res...)
+ }
+ return nil
+}
diff --git a/swagger.yml b/swagger.yml
index f7ceaa0..da1f1da 100644
--- a/swagger.yml
+++ b/swagger.yml
@@ -157,6 +157,75 @@ definitions:
info:
type: string
description: provides additional information about current state, e.g. cause of failure
+ JobFilter:
+ description: is used to filter Weles Jobs.
+ type: object
+ properties:
+ JobID:
+ type: array
+ items:
+ $ref: '#/definitions/JobID'
+ Name:
+ type: array
+ items:
+ type: string
+ CreatedAfter:
+ type: string
+ format: date-time
+ CreatedBefore:
+ type: string
+ format: date-time
+ UpdatedAfter:
+ type: string
+ format: date-time
+ UpdatedBefore:
+ type: string
+ format: date-time
+ Status:
+ type: array
+ items:
+ $ref: '#/definitions/JobStatus'
+ Info:
+ type: array
+ items:
+ type: string
+ JobSortBy:
+ description: |
+ denotes key for sorting Jobs list. Jobs are sorted by ID (Ascending) by default.
+ You can sort jobs additionaly by
+
+ * CreatedDate - sorting by date of creation of the weles job.
+
+ * UpdatedDate - sorting by date of update of the weles job.
+
+ * JobStatus - sorting by the Job Status. Descending order will sort in the order JobStatuses are listed in the docs (from NEW at the start to CANCELED at the end). Ascending will reverse this order.
+ When sorting is applied, and there are many jobs with the same date/status, they will be sorted by JobID (Ascending)
+ type: string
+ enum:
+ - CreatedDate
+ - UpdatedDate
+ - JobStatus
+ SortOrder:
+ description: |
+ denotes direction of sorting of weles jobs or artifacts.
+
+ * Ascending - from oldest to newest.
+
+ * Descending - from newest to oldest.
+
+ type: string
+ enum:
+ - Ascending
+ - Descending
+ JobSorter:
+ description: |
+ defines the key for sorting as well as direction of sorting.
+ type: object
+ properties:
+ SortBy:
+ $ref: '#/definitions/JobSortBy'
+ SortOrder:
+ $ref: '#/definitions/SortOrder'
ArtifactType:
description: |
denotes type and function of an artifact.