github.com/hashicorp/hcp-sdk-go@v0.94.0/clients/cloud-billing/preview/2020-11-05/models/cloudlocation_location.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 // CloudlocationLocation Location represents a target for an operation in HCP. 17 // 18 // swagger:model cloudlocationLocation 19 type CloudlocationLocation struct { 20 21 // organization_id is the id of the organization. 22 OrganizationID string `json:"organization_id,omitempty"` 23 24 // project_id is the projects id. 25 ProjectID string `json:"project_id,omitempty"` 26 27 // region is the region that the resource is located in. It is 28 // optional if the object being referenced is a global object. 29 Region *LocationRegion `json:"region,omitempty"` 30 } 31 32 // Validate validates this cloudlocation location 33 func (m *CloudlocationLocation) Validate(formats strfmt.Registry) error { 34 var res []error 35 36 if err := m.validateRegion(formats); err != nil { 37 res = append(res, err) 38 } 39 40 if len(res) > 0 { 41 return errors.CompositeValidationError(res...) 42 } 43 return nil 44 } 45 46 func (m *CloudlocationLocation) validateRegion(formats strfmt.Registry) error { 47 if swag.IsZero(m.Region) { // not required 48 return nil 49 } 50 51 if m.Region != nil { 52 if err := m.Region.Validate(formats); err != nil { 53 if ve, ok := err.(*errors.Validation); ok { 54 return ve.ValidateName("region") 55 } else if ce, ok := err.(*errors.CompositeError); ok { 56 return ce.ValidateName("region") 57 } 58 return err 59 } 60 } 61 62 return nil 63 } 64 65 // ContextValidate validate this cloudlocation location based on the context it is used 66 func (m *CloudlocationLocation) ContextValidate(ctx context.Context, formats strfmt.Registry) error { 67 var res []error 68 69 if err := m.contextValidateRegion(ctx, formats); err != nil { 70 res = append(res, err) 71 } 72 73 if len(res) > 0 { 74 return errors.CompositeValidationError(res...) 75 } 76 return nil 77 } 78 79 func (m *CloudlocationLocation) contextValidateRegion(ctx context.Context, formats strfmt.Registry) error { 80 81 if m.Region != nil { 82 if err := m.Region.ContextValidate(ctx, formats); err != nil { 83 if ve, ok := err.(*errors.Validation); ok { 84 return ve.ValidateName("region") 85 } else if ce, ok := err.(*errors.CompositeError); ok { 86 return ce.ValidateName("region") 87 } 88 return err 89 } 90 } 91 92 return nil 93 } 94 95 // MarshalBinary interface implementation 96 func (m *CloudlocationLocation) MarshalBinary() ([]byte, error) { 97 if m == nil { 98 return nil, nil 99 } 100 return swag.WriteJSON(m) 101 } 102 103 // UnmarshalBinary interface implementation 104 func (m *CloudlocationLocation) UnmarshalBinary(b []byte) error { 105 var res CloudlocationLocation 106 if err := swag.ReadJSON(b, &res); err != nil { 107 return err 108 } 109 *m = res 110 return nil 111 }