github.com/hashicorp/hcp-sdk-go@v0.94.0/clients/cloud-billing/preview/2020-11-05/models/billing20201105_statement_summary.go (about) 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 "context" 10 11 "github.com/go-openapi/errors" 12 "github.com/go-openapi/strfmt" 13 "github.com/go-openapi/swag" 14 "github.com/go-openapi/validate" 15 ) 16 17 // Billing20201105StatementSummary StatementSummary represents the response type for the ListStatements endpoint 18 // 19 // swagger:model billing_20201105StatementSummary 20 type Billing20201105StatementSummary struct { 21 22 // amount is the dollar amount for the statement 23 Amount string `json:"amount,omitempty"` 24 25 // billing_period_end is the end date for the statement billing period 26 // Format: date-time 27 BillingPeriodEnd strfmt.DateTime `json:"billing_period_end,omitempty"` 28 29 // billing_period_start is the start date for the statement billing period 30 // Format: date-time 31 BillingPeriodStart strfmt.DateTime `json:"billing_period_start,omitempty"` 32 33 // id is the id associated with the statement 34 ID string `json:"id,omitempty"` 35 36 // OnDemandMetadata contains PAYG specific properties. 37 OnDemandMetadata *Billing20201105StatementSummaryOnDemandMetadata `json:"on_demand_metadata,omitempty"` 38 } 39 40 // Validate validates this billing 20201105 statement summary 41 func (m *Billing20201105StatementSummary) Validate(formats strfmt.Registry) error { 42 var res []error 43 44 if err := m.validateBillingPeriodEnd(formats); err != nil { 45 res = append(res, err) 46 } 47 48 if err := m.validateBillingPeriodStart(formats); err != nil { 49 res = append(res, err) 50 } 51 52 if err := m.validateOnDemandMetadata(formats); err != nil { 53 res = append(res, err) 54 } 55 56 if len(res) > 0 { 57 return errors.CompositeValidationError(res...) 58 } 59 return nil 60 } 61 62 func (m *Billing20201105StatementSummary) validateBillingPeriodEnd(formats strfmt.Registry) error { 63 if swag.IsZero(m.BillingPeriodEnd) { // not required 64 return nil 65 } 66 67 if err := validate.FormatOf("billing_period_end", "body", "date-time", m.BillingPeriodEnd.String(), formats); err != nil { 68 return err 69 } 70 71 return nil 72 } 73 74 func (m *Billing20201105StatementSummary) validateBillingPeriodStart(formats strfmt.Registry) error { 75 if swag.IsZero(m.BillingPeriodStart) { // not required 76 return nil 77 } 78 79 if err := validate.FormatOf("billing_period_start", "body", "date-time", m.BillingPeriodStart.String(), formats); err != nil { 80 return err 81 } 82 83 return nil 84 } 85 86 func (m *Billing20201105StatementSummary) validateOnDemandMetadata(formats strfmt.Registry) error { 87 if swag.IsZero(m.OnDemandMetadata) { // not required 88 return nil 89 } 90 91 if m.OnDemandMetadata != nil { 92 if err := m.OnDemandMetadata.Validate(formats); err != nil { 93 if ve, ok := err.(*errors.Validation); ok { 94 return ve.ValidateName("on_demand_metadata") 95 } else if ce, ok := err.(*errors.CompositeError); ok { 96 return ce.ValidateName("on_demand_metadata") 97 } 98 return err 99 } 100 } 101 102 return nil 103 } 104 105 // ContextValidate validate this billing 20201105 statement summary based on the context it is used 106 func (m *Billing20201105StatementSummary) ContextValidate(ctx context.Context, formats strfmt.Registry) error { 107 var res []error 108 109 if err := m.contextValidateOnDemandMetadata(ctx, formats); err != nil { 110 res = append(res, err) 111 } 112 113 if len(res) > 0 { 114 return errors.CompositeValidationError(res...) 115 } 116 return nil 117 } 118 119 func (m *Billing20201105StatementSummary) contextValidateOnDemandMetadata(ctx context.Context, formats strfmt.Registry) error { 120 121 if m.OnDemandMetadata != nil { 122 if err := m.OnDemandMetadata.ContextValidate(ctx, formats); err != nil { 123 if ve, ok := err.(*errors.Validation); ok { 124 return ve.ValidateName("on_demand_metadata") 125 } else if ce, ok := err.(*errors.CompositeError); ok { 126 return ce.ValidateName("on_demand_metadata") 127 } 128 return err 129 } 130 } 131 132 return nil 133 } 134 135 // MarshalBinary interface implementation 136 func (m *Billing20201105StatementSummary) MarshalBinary() ([]byte, error) { 137 if m == nil { 138 return nil, nil 139 } 140 return swag.WriteJSON(m) 141 } 142 143 // UnmarshalBinary interface implementation 144 func (m *Billing20201105StatementSummary) UnmarshalBinary(b []byte) error { 145 var res Billing20201105StatementSummary 146 if err := swag.ReadJSON(b, &res); err != nil { 147 return err 148 } 149 *m = res 150 return nil 151 }