github.com/hashicorp/hcp-sdk-go@v0.94.0/clients/cloud-log-service/preview/2021-03-30/models/protobuf_null_value.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  	"encoding/json"
    11  
    12  	"github.com/go-openapi/errors"
    13  	"github.com/go-openapi/strfmt"
    14  	"github.com/go-openapi/validate"
    15  )
    16  
    17  // ProtobufNullValue `NullValue` is a singleton enumeration to represent the null value for the
    18  // `Value` type union.
    19  //
    20  //	The JSON representation for `NullValue` is JSON `null`.
    21  //
    22  //	- NULL_VALUE: Null value.
    23  //
    24  // swagger:model protobufNullValue
    25  type ProtobufNullValue string
    26  
    27  func NewProtobufNullValue(value ProtobufNullValue) *ProtobufNullValue {
    28  	return &value
    29  }
    30  
    31  // Pointer returns a pointer to a freshly-allocated ProtobufNullValue.
    32  func (m ProtobufNullValue) Pointer() *ProtobufNullValue {
    33  	return &m
    34  }
    35  
    36  const (
    37  
    38  	// ProtobufNullValueNULLVALUE captures enum value "NULL_VALUE"
    39  	ProtobufNullValueNULLVALUE ProtobufNullValue = "NULL_VALUE"
    40  )
    41  
    42  // for schema
    43  var protobufNullValueEnum []interface{}
    44  
    45  func init() {
    46  	var res []ProtobufNullValue
    47  	if err := json.Unmarshal([]byte(`["NULL_VALUE"]`), &res); err != nil {
    48  		panic(err)
    49  	}
    50  	for _, v := range res {
    51  		protobufNullValueEnum = append(protobufNullValueEnum, v)
    52  	}
    53  }
    54  
    55  func (m ProtobufNullValue) validateProtobufNullValueEnum(path, location string, value ProtobufNullValue) error {
    56  	if err := validate.EnumCase(path, location, value, protobufNullValueEnum, true); err != nil {
    57  		return err
    58  	}
    59  	return nil
    60  }
    61  
    62  // Validate validates this protobuf null value
    63  func (m ProtobufNullValue) Validate(formats strfmt.Registry) error {
    64  	var res []error
    65  
    66  	// value enum
    67  	if err := m.validateProtobufNullValueEnum("", "body", m); err != nil {
    68  		return err
    69  	}
    70  
    71  	if len(res) > 0 {
    72  		return errors.CompositeValidationError(res...)
    73  	}
    74  	return nil
    75  }
    76  
    77  // ContextValidate validates this protobuf null value based on context it is used
    78  func (m ProtobufNullValue) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
    79  	return nil
    80  }