github.com/hashicorp/hcp-sdk-go@v0.94.0/clients/cloud-billing/preview/2020-11-05/models/location_link.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 ) 15 16 // LocationLink Link is used to uniquely reference any resource within HashiCorp Cloud. 17 // This can be conceptually considered a "foreign key". 18 // 19 // swagger:model locationLink 20 type LocationLink struct { 21 22 // description is a human-friendly description for this link. This is 23 // used primarily for informational purposes such as error messages. 24 Description string `json:"description,omitempty"` 25 26 // id is the identifier for this resource. 27 ID string `json:"id,omitempty"` 28 29 // location is the location where this resource is. 30 Location *CloudlocationLocation `json:"location,omitempty"` 31 32 // type is the unique type of the resource. Each service publishes a 33 // unique set of types. The type value is recommended to be formatted 34 // in "<org>.<type>" such as "hashicorp.hvn". This is to prevent conflicts 35 // in the future, but any string value will work. 36 Type string `json:"type,omitempty"` 37 38 // uuid is the unique UUID for this resource. 39 UUID string `json:"uuid,omitempty"` 40 } 41 42 // Validate validates this location link 43 func (m *LocationLink) Validate(formats strfmt.Registry) error { 44 var res []error 45 46 if err := m.validateLocation(formats); err != nil { 47 res = append(res, err) 48 } 49 50 if len(res) > 0 { 51 return errors.CompositeValidationError(res...) 52 } 53 return nil 54 } 55 56 func (m *LocationLink) validateLocation(formats strfmt.Registry) error { 57 if swag.IsZero(m.Location) { // not required 58 return nil 59 } 60 61 if m.Location != nil { 62 if err := m.Location.Validate(formats); err != nil { 63 if ve, ok := err.(*errors.Validation); ok { 64 return ve.ValidateName("location") 65 } else if ce, ok := err.(*errors.CompositeError); ok { 66 return ce.ValidateName("location") 67 } 68 return err 69 } 70 } 71 72 return nil 73 } 74 75 // ContextValidate validate this location link based on the context it is used 76 func (m *LocationLink) ContextValidate(ctx context.Context, formats strfmt.Registry) error { 77 var res []error 78 79 if err := m.contextValidateLocation(ctx, formats); err != nil { 80 res = append(res, err) 81 } 82 83 if len(res) > 0 { 84 return errors.CompositeValidationError(res...) 85 } 86 return nil 87 } 88 89 func (m *LocationLink) contextValidateLocation(ctx context.Context, formats strfmt.Registry) error { 90 91 if m.Location != nil { 92 if err := m.Location.ContextValidate(ctx, formats); err != nil { 93 if ve, ok := err.(*errors.Validation); ok { 94 return ve.ValidateName("location") 95 } else if ce, ok := err.(*errors.CompositeError); ok { 96 return ce.ValidateName("location") 97 } 98 return err 99 } 100 } 101 102 return nil 103 } 104 105 // MarshalBinary interface implementation 106 func (m *LocationLink) MarshalBinary() ([]byte, error) { 107 if m == nil { 108 return nil, nil 109 } 110 return swag.WriteJSON(m) 111 } 112 113 // UnmarshalBinary interface implementation 114 func (m *LocationLink) UnmarshalBinary(b []byte) error { 115 var res LocationLink 116 if err := swag.ReadJSON(b, &res); err != nil { 117 return err 118 } 119 *m = res 120 return nil 121 }