github.com/hashicorp/hcp-sdk-go@v0.94.0/clients/cloud-log-service/preview/2021-03-30/models/cloudiam_service_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  	"github.com/go-openapi/validate"
    15  )
    16  
    17  // CloudiamServicePrincipal ServicePrincipal is the HCP identity for a machine user.
    18  //
    19  // swagger:model cloudiamServicePrincipal
    20  type CloudiamServicePrincipal struct {
    21  
    22  	// created_at is when the service principal was created.
    23  	// Format: date-time
    24  	CreatedAt strfmt.DateTime `json:"created_at,omitempty"`
    25  
    26  	// id is the UUID identifier for this service principal.
    27  	ID string `json:"id,omitempty"`
    28  
    29  	// name is the name for this service principal.
    30  	Name string `json:"name,omitempty"`
    31  
    32  	// organization_id is the UUID identifier of the HCP organization that this
    33  	// service principal belongs to.
    34  	OrganizationID string `json:"organization_id,omitempty"`
    35  
    36  	// project_id is the UUID identifier of the HCP project that this
    37  	// project service principal belongs to.
    38  	ProjectID string `json:"project_id,omitempty"`
    39  
    40  	// resource_name is the resource name for this service principal.
    41  	ResourceName string `json:"resource_name,omitempty"`
    42  }
    43  
    44  // Validate validates this cloudiam service principal
    45  func (m *CloudiamServicePrincipal) Validate(formats strfmt.Registry) error {
    46  	var res []error
    47  
    48  	if err := m.validateCreatedAt(formats); err != nil {
    49  		res = append(res, err)
    50  	}
    51  
    52  	if len(res) > 0 {
    53  		return errors.CompositeValidationError(res...)
    54  	}
    55  	return nil
    56  }
    57  
    58  func (m *CloudiamServicePrincipal) validateCreatedAt(formats strfmt.Registry) error {
    59  	if swag.IsZero(m.CreatedAt) { // not required
    60  		return nil
    61  	}
    62  
    63  	if err := validate.FormatOf("created_at", "body", "date-time", m.CreatedAt.String(), formats); err != nil {
    64  		return err
    65  	}
    66  
    67  	return nil
    68  }
    69  
    70  // ContextValidate validates this cloudiam service principal based on context it is used
    71  func (m *CloudiamServicePrincipal) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
    72  	return nil
    73  }
    74  
    75  // MarshalBinary interface implementation
    76  func (m *CloudiamServicePrincipal) MarshalBinary() ([]byte, error) {
    77  	if m == nil {
    78  		return nil, nil
    79  	}
    80  	return swag.WriteJSON(m)
    81  }
    82  
    83  // UnmarshalBinary interface implementation
    84  func (m *CloudiamServicePrincipal) UnmarshalBinary(b []byte) error {
    85  	var res CloudiamServicePrincipal
    86  	if err := swag.ReadJSON(b, &res); err != nil {
    87  		return err
    88  	}
    89  	*m = res
    90  	return nil
    91  }