github.com/hashicorp/hcp-sdk-go@v0.94.0/clients/cloud-log-service/preview/2021-03-30/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  
    93  		if swag.IsZero(m.Location) { // not required
    94  			return nil
    95  		}
    96  
    97  		if err := m.Location.ContextValidate(ctx, formats); err != nil {
    98  			if ve, ok := err.(*errors.Validation); ok {
    99  				return ve.ValidateName("location")
   100  			} else if ce, ok := err.(*errors.CompositeError); ok {
   101  				return ce.ValidateName("location")
   102  			}
   103  			return err
   104  		}
   105  	}
   106  
   107  	return nil
   108  }
   109  
   110  // MarshalBinary interface implementation
   111  func (m *LocationLink) MarshalBinary() ([]byte, error) {
   112  	if m == nil {
   113  		return nil, nil
   114  	}
   115  	return swag.WriteJSON(m)
   116  }
   117  
   118  // UnmarshalBinary interface implementation
   119  func (m *LocationLink) UnmarshalBinary(b []byte) error {
   120  	var res LocationLink
   121  	if err := swag.ReadJSON(b, &res); err != nil {
   122  		return err
   123  	}
   124  	*m = res
   125  	return nil
   126  }