github.com/hashicorp/hcp-sdk-go@v0.94.0/clients/cloud-vault-secrets/stable/2023-06-13/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  
    83  		if swag.IsZero(m.Region) { // not required
    84  			return nil
    85  		}
    86  
    87  		if err := m.Region.ContextValidate(ctx, formats); err != nil {
    88  			if ve, ok := err.(*errors.Validation); ok {
    89  				return ve.ValidateName("region")
    90  			} else if ce, ok := err.(*errors.CompositeError); ok {
    91  				return ce.ValidateName("region")
    92  			}
    93  			return err
    94  		}
    95  	}
    96  
    97  	return nil
    98  }
    99  
   100  // MarshalBinary interface implementation
   101  func (m *CloudlocationLocation) MarshalBinary() ([]byte, error) {
   102  	if m == nil {
   103  		return nil, nil
   104  	}
   105  	return swag.WriteJSON(m)
   106  }
   107  
   108  // UnmarshalBinary interface implementation
   109  func (m *CloudlocationLocation) UnmarshalBinary(b []byte) error {
   110  	var res CloudlocationLocation
   111  	if err := swag.ReadJSON(b, &res); err != nil {
   112  		return err
   113  	}
   114  	*m = res
   115  	return nil
   116  }