github.com/hashicorp/hcp-sdk-go@v0.94.0/clients/cloud-log-service/preview/2021-03-30/models/cloudlog_service20210330_principal.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  // CloudlogService20210330Principal Principal contains information about the person or process who caused a
    17  // control-plane event.
    18  //
    19  // swagger:model cloudlog_service_20210330Principal
    20  type CloudlogService20210330Principal struct {
    21  
    22  	// service has information about the service principal in case one was used
    23  	// to perform the action.
    24  	Service *LogService20210330PrincipalServicePrincipal `json:"service,omitempty"`
    25  
    26  	// type indicates what kind of principal performed the action.
    27  	Type *LogService20210330PrincipalType `json:"type,omitempty"`
    28  
    29  	// user has information about the user in case of user-triggered actions.
    30  	User *LogService20210330PrincipalUserPrincipal `json:"user,omitempty"`
    31  }
    32  
    33  // Validate validates this cloudlog service 20210330 principal
    34  func (m *CloudlogService20210330Principal) Validate(formats strfmt.Registry) error {
    35  	var res []error
    36  
    37  	if err := m.validateService(formats); err != nil {
    38  		res = append(res, err)
    39  	}
    40  
    41  	if err := m.validateType(formats); err != nil {
    42  		res = append(res, err)
    43  	}
    44  
    45  	if err := m.validateUser(formats); err != nil {
    46  		res = append(res, err)
    47  	}
    48  
    49  	if len(res) > 0 {
    50  		return errors.CompositeValidationError(res...)
    51  	}
    52  	return nil
    53  }
    54  
    55  func (m *CloudlogService20210330Principal) validateService(formats strfmt.Registry) error {
    56  	if swag.IsZero(m.Service) { // not required
    57  		return nil
    58  	}
    59  
    60  	if m.Service != nil {
    61  		if err := m.Service.Validate(formats); err != nil {
    62  			if ve, ok := err.(*errors.Validation); ok {
    63  				return ve.ValidateName("service")
    64  			} else if ce, ok := err.(*errors.CompositeError); ok {
    65  				return ce.ValidateName("service")
    66  			}
    67  			return err
    68  		}
    69  	}
    70  
    71  	return nil
    72  }
    73  
    74  func (m *CloudlogService20210330Principal) validateType(formats strfmt.Registry) error {
    75  	if swag.IsZero(m.Type) { // not required
    76  		return nil
    77  	}
    78  
    79  	if m.Type != nil {
    80  		if err := m.Type.Validate(formats); err != nil {
    81  			if ve, ok := err.(*errors.Validation); ok {
    82  				return ve.ValidateName("type")
    83  			} else if ce, ok := err.(*errors.CompositeError); ok {
    84  				return ce.ValidateName("type")
    85  			}
    86  			return err
    87  		}
    88  	}
    89  
    90  	return nil
    91  }
    92  
    93  func (m *CloudlogService20210330Principal) validateUser(formats strfmt.Registry) error {
    94  	if swag.IsZero(m.User) { // not required
    95  		return nil
    96  	}
    97  
    98  	if m.User != nil {
    99  		if err := m.User.Validate(formats); err != nil {
   100  			if ve, ok := err.(*errors.Validation); ok {
   101  				return ve.ValidateName("user")
   102  			} else if ce, ok := err.(*errors.CompositeError); ok {
   103  				return ce.ValidateName("user")
   104  			}
   105  			return err
   106  		}
   107  	}
   108  
   109  	return nil
   110  }
   111  
   112  // ContextValidate validate this cloudlog service 20210330 principal based on the context it is used
   113  func (m *CloudlogService20210330Principal) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
   114  	var res []error
   115  
   116  	if err := m.contextValidateService(ctx, formats); err != nil {
   117  		res = append(res, err)
   118  	}
   119  
   120  	if err := m.contextValidateType(ctx, formats); err != nil {
   121  		res = append(res, err)
   122  	}
   123  
   124  	if err := m.contextValidateUser(ctx, formats); err != nil {
   125  		res = append(res, err)
   126  	}
   127  
   128  	if len(res) > 0 {
   129  		return errors.CompositeValidationError(res...)
   130  	}
   131  	return nil
   132  }
   133  
   134  func (m *CloudlogService20210330Principal) contextValidateService(ctx context.Context, formats strfmt.Registry) error {
   135  
   136  	if m.Service != nil {
   137  
   138  		if swag.IsZero(m.Service) { // not required
   139  			return nil
   140  		}
   141  
   142  		if err := m.Service.ContextValidate(ctx, formats); err != nil {
   143  			if ve, ok := err.(*errors.Validation); ok {
   144  				return ve.ValidateName("service")
   145  			} else if ce, ok := err.(*errors.CompositeError); ok {
   146  				return ce.ValidateName("service")
   147  			}
   148  			return err
   149  		}
   150  	}
   151  
   152  	return nil
   153  }
   154  
   155  func (m *CloudlogService20210330Principal) contextValidateType(ctx context.Context, formats strfmt.Registry) error {
   156  
   157  	if m.Type != nil {
   158  
   159  		if swag.IsZero(m.Type) { // not required
   160  			return nil
   161  		}
   162  
   163  		if err := m.Type.ContextValidate(ctx, formats); err != nil {
   164  			if ve, ok := err.(*errors.Validation); ok {
   165  				return ve.ValidateName("type")
   166  			} else if ce, ok := err.(*errors.CompositeError); ok {
   167  				return ce.ValidateName("type")
   168  			}
   169  			return err
   170  		}
   171  	}
   172  
   173  	return nil
   174  }
   175  
   176  func (m *CloudlogService20210330Principal) contextValidateUser(ctx context.Context, formats strfmt.Registry) error {
   177  
   178  	if m.User != nil {
   179  
   180  		if swag.IsZero(m.User) { // not required
   181  			return nil
   182  		}
   183  
   184  		if err := m.User.ContextValidate(ctx, formats); err != nil {
   185  			if ve, ok := err.(*errors.Validation); ok {
   186  				return ve.ValidateName("user")
   187  			} else if ce, ok := err.(*errors.CompositeError); ok {
   188  				return ce.ValidateName("user")
   189  			}
   190  			return err
   191  		}
   192  	}
   193  
   194  	return nil
   195  }
   196  
   197  // MarshalBinary interface implementation
   198  func (m *CloudlogService20210330Principal) MarshalBinary() ([]byte, error) {
   199  	if m == nil {
   200  		return nil, nil
   201  	}
   202  	return swag.WriteJSON(m)
   203  }
   204  
   205  // UnmarshalBinary interface implementation
   206  func (m *CloudlogService20210330Principal) UnmarshalBinary(b []byte) error {
   207  	var res CloudlogService20210330Principal
   208  	if err := swag.ReadJSON(b, &res); err != nil {
   209  		return err
   210  	}
   211  	*m = res
   212  	return nil
   213  }