github.com/sap/cf-mta-plugin@v2.6.3+incompatible/clients/models/cloud_foundry_resource.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  	strfmt "github.com/go-openapi/strfmt"
    10  
    11  	"github.com/go-openapi/errors"
    12  	"github.com/go-openapi/swag"
    13  )
    14  
    15  // CloudFoundryResource cloud foundry resource
    16  // swagger:model CloudFoundryResource
    17  
    18  type CloudFoundryResource struct {
    19  
    20  	// entity
    21  	Entity *CloudFoundryResourceEntity `json:"entity,omitempty"`
    22  
    23  	// metadata
    24  	Metadata *CloudFoundryResourceMetadata `json:"metadata,omitempty"`
    25  }
    26  
    27  /* polymorph CloudFoundryResource entity false */
    28  
    29  /* polymorph CloudFoundryResource metadata false */
    30  
    31  // Validate validates this cloud foundry resource
    32  func (m *CloudFoundryResource) Validate(formats strfmt.Registry) error {
    33  	var res []error
    34  
    35  	if err := m.validateEntity(formats); err != nil {
    36  		// prop
    37  		res = append(res, err)
    38  	}
    39  
    40  	if err := m.validateMetadata(formats); err != nil {
    41  		// prop
    42  		res = append(res, err)
    43  	}
    44  
    45  	if len(res) > 0 {
    46  		return errors.CompositeValidationError(res...)
    47  	}
    48  	return nil
    49  }
    50  
    51  func (m *CloudFoundryResource) validateEntity(formats strfmt.Registry) error {
    52  
    53  	if swag.IsZero(m.Entity) { // not required
    54  		return nil
    55  	}
    56  
    57  	if m.Entity != nil {
    58  
    59  		if err := m.Entity.Validate(formats); err != nil {
    60  			if ve, ok := err.(*errors.Validation); ok {
    61  				return ve.ValidateName("entity")
    62  			}
    63  			return err
    64  		}
    65  	}
    66  
    67  	return nil
    68  }
    69  
    70  func (m *CloudFoundryResource) validateMetadata(formats strfmt.Registry) error {
    71  
    72  	if swag.IsZero(m.Metadata) { // not required
    73  		return nil
    74  	}
    75  
    76  	if m.Metadata != nil {
    77  
    78  		if err := m.Metadata.Validate(formats); err != nil {
    79  			if ve, ok := err.(*errors.Validation); ok {
    80  				return ve.ValidateName("metadata")
    81  			}
    82  			return err
    83  		}
    84  	}
    85  
    86  	return nil
    87  }
    88  
    89  // MarshalBinary interface implementation
    90  func (m *CloudFoundryResource) MarshalBinary() ([]byte, error) {
    91  	if m == nil {
    92  		return nil, nil
    93  	}
    94  	return swag.WriteJSON(m)
    95  }
    96  
    97  // UnmarshalBinary interface implementation
    98  func (m *CloudFoundryResource) UnmarshalBinary(b []byte) error {
    99  	var res CloudFoundryResource
   100  	if err := swag.ReadJSON(b, &res); err != nil {
   101  		return err
   102  	}
   103  	*m = res
   104  	return nil
   105  }