Mohamed Abukar | 429da19 | 2020-02-26 16:46:34 +0200 | [diff] [blame] | 1 | // Code generated by go-swagger; DO NOT EDIT. |
| 2 | |
| 3 | package models |
| 4 | |
| 5 | // This file was generated by the swagger tool. |
| 6 | // Editing this file might prove futile when you re-run the swagger generate command |
| 7 | |
| 8 | import ( |
| 9 | "strconv" |
| 10 | |
| 11 | strfmt "github.com/go-openapi/strfmt" |
| 12 | |
| 13 | "github.com/go-openapi/errors" |
| 14 | "github.com/go-openapi/swag" |
Mohamed Abukar | b6341a5 | 2020-03-23 08:55:05 +0200 | [diff] [blame] | 15 | "github.com/go-openapi/validate" |
Mohamed Abukar | 429da19 | 2020-02-26 16:46:34 +0200 | [diff] [blame] | 16 | ) |
| 17 | |
| 18 | // SubscriptionResponse subscription response |
| 19 | // swagger:model SubscriptionResponse |
Mohamed Abukar | b6341a5 | 2020-03-23 08:55:05 +0200 | [diff] [blame] | 20 | type SubscriptionResponse struct { |
| 21 | |
| 22 | // subscription Id |
| 23 | // Required: true |
| 24 | SubscriptionID *string `json:"SubscriptionId"` |
| 25 | |
| 26 | // subscription instances |
| 27 | // Required: true |
| 28 | SubscriptionInstances []*SubscriptionInstance `json:"SubscriptionInstances"` |
| 29 | } |
Mohamed Abukar | 429da19 | 2020-02-26 16:46:34 +0200 | [diff] [blame] | 30 | |
| 31 | // Validate validates this subscription response |
Mohamed Abukar | b6341a5 | 2020-03-23 08:55:05 +0200 | [diff] [blame] | 32 | func (m *SubscriptionResponse) Validate(formats strfmt.Registry) error { |
Mohamed Abukar | 429da19 | 2020-02-26 16:46:34 +0200 | [diff] [blame] | 33 | var res []error |
| 34 | |
Mohamed Abukar | b6341a5 | 2020-03-23 08:55:05 +0200 | [diff] [blame] | 35 | if err := m.validateSubscriptionID(formats); err != nil { |
| 36 | res = append(res, err) |
| 37 | } |
| 38 | |
| 39 | if err := m.validateSubscriptionInstances(formats); err != nil { |
| 40 | res = append(res, err) |
| 41 | } |
| 42 | |
| 43 | if len(res) > 0 { |
| 44 | return errors.CompositeValidationError(res...) |
| 45 | } |
| 46 | return nil |
| 47 | } |
| 48 | |
| 49 | func (m *SubscriptionResponse) validateSubscriptionID(formats strfmt.Registry) error { |
| 50 | |
| 51 | if err := validate.Required("SubscriptionId", "body", m.SubscriptionID); err != nil { |
| 52 | return err |
| 53 | } |
| 54 | |
| 55 | return nil |
| 56 | } |
| 57 | |
| 58 | func (m *SubscriptionResponse) validateSubscriptionInstances(formats strfmt.Registry) error { |
| 59 | |
| 60 | if err := validate.Required("SubscriptionInstances", "body", m.SubscriptionInstances); err != nil { |
| 61 | return err |
| 62 | } |
| 63 | |
| 64 | for i := 0; i < len(m.SubscriptionInstances); i++ { |
| 65 | if swag.IsZero(m.SubscriptionInstances[i]) { // not required |
Mohamed Abukar | 429da19 | 2020-02-26 16:46:34 +0200 | [diff] [blame] | 66 | continue |
| 67 | } |
| 68 | |
Mohamed Abukar | b6341a5 | 2020-03-23 08:55:05 +0200 | [diff] [blame] | 69 | if m.SubscriptionInstances[i] != nil { |
| 70 | if err := m.SubscriptionInstances[i].Validate(formats); err != nil { |
Mohamed Abukar | 429da19 | 2020-02-26 16:46:34 +0200 | [diff] [blame] | 71 | if ve, ok := err.(*errors.Validation); ok { |
Mohamed Abukar | b6341a5 | 2020-03-23 08:55:05 +0200 | [diff] [blame] | 72 | return ve.ValidateName("SubscriptionInstances" + "." + strconv.Itoa(i)) |
Mohamed Abukar | 429da19 | 2020-02-26 16:46:34 +0200 | [diff] [blame] | 73 | } |
| 74 | return err |
| 75 | } |
| 76 | } |
| 77 | |
| 78 | } |
| 79 | |
Mohamed Abukar | b6341a5 | 2020-03-23 08:55:05 +0200 | [diff] [blame] | 80 | return nil |
| 81 | } |
| 82 | |
| 83 | // MarshalBinary interface implementation |
| 84 | func (m *SubscriptionResponse) MarshalBinary() ([]byte, error) { |
| 85 | if m == nil { |
| 86 | return nil, nil |
Mohamed Abukar | 429da19 | 2020-02-26 16:46:34 +0200 | [diff] [blame] | 87 | } |
Mohamed Abukar | b6341a5 | 2020-03-23 08:55:05 +0200 | [diff] [blame] | 88 | return swag.WriteJSON(m) |
| 89 | } |
| 90 | |
| 91 | // UnmarshalBinary interface implementation |
| 92 | func (m *SubscriptionResponse) UnmarshalBinary(b []byte) error { |
| 93 | var res SubscriptionResponse |
| 94 | if err := swag.ReadJSON(b, &res); err != nil { |
| 95 | return err |
| 96 | } |
| 97 | *m = res |
Mohamed Abukar | 429da19 | 2020-02-26 16:46:34 +0200 | [diff] [blame] | 98 | return nil |
| 99 | } |