This repository has been archived by the owner on Feb 27, 2023. It is now read-only.
/
piece_update_request.go
115 lines (89 loc) · 2.86 KB
/
piece_update_request.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
// Code generated by go-swagger; DO NOT EDIT.
package types
// 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/swag"
"github.com/go-openapi/validate"
)
// PieceUpdateRequest request used to update piece attributes.
// swagger:model PieceUpdateRequest
type PieceUpdateRequest struct {
// the downloader clientID
//
ClientID string `json:"clientID,omitempty"`
// the uploader peerID
//
DstPID string `json:"dstPID,omitempty"`
// pieceStatus indicates whether the peer task successfully download the piece.
//
// Enum: [FAILED SUCCESS INVALID SEMISUC]
PieceStatus string `json:"pieceStatus,omitempty"`
}
// Validate validates this piece update request
func (m *PieceUpdateRequest) Validate(formats strfmt.Registry) error {
var res []error
if err := m.validatePieceStatus(formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
var pieceUpdateRequestTypePieceStatusPropEnum []interface{}
func init() {
var res []string
if err := json.Unmarshal([]byte(`["FAILED","SUCCESS","INVALID","SEMISUC"]`), &res); err != nil {
panic(err)
}
for _, v := range res {
pieceUpdateRequestTypePieceStatusPropEnum = append(pieceUpdateRequestTypePieceStatusPropEnum, v)
}
}
const (
// PieceUpdateRequestPieceStatusFAILED captures enum value "FAILED"
PieceUpdateRequestPieceStatusFAILED string = "FAILED"
// PieceUpdateRequestPieceStatusSUCCESS captures enum value "SUCCESS"
PieceUpdateRequestPieceStatusSUCCESS string = "SUCCESS"
// PieceUpdateRequestPieceStatusINVALID captures enum value "INVALID"
PieceUpdateRequestPieceStatusINVALID string = "INVALID"
// PieceUpdateRequestPieceStatusSEMISUC captures enum value "SEMISUC"
PieceUpdateRequestPieceStatusSEMISUC string = "SEMISUC"
)
// prop value enum
func (m *PieceUpdateRequest) validatePieceStatusEnum(path, location string, value string) error {
if err := validate.Enum(path, location, value, pieceUpdateRequestTypePieceStatusPropEnum); err != nil {
return err
}
return nil
}
func (m *PieceUpdateRequest) validatePieceStatus(formats strfmt.Registry) error {
if swag.IsZero(m.PieceStatus) { // not required
return nil
}
// value enum
if err := m.validatePieceStatusEnum("pieceStatus", "body", m.PieceStatus); err != nil {
return err
}
return nil
}
// MarshalBinary interface implementation
func (m *PieceUpdateRequest) MarshalBinary() ([]byte, error) {
if m == nil {
return nil, nil
}
return swag.WriteJSON(m)
}
// UnmarshalBinary interface implementation
func (m *PieceUpdateRequest) UnmarshalBinary(b []byte) error {
var res PieceUpdateRequest
if err := swag.ReadJSON(b, &res); err != nil {
return err
}
*m = res
return nil
}