...

Source file src/github.com/sigstore/rekor/pkg/generated/models/hashedrekord_v001_schema.go

Documentation: github.com/sigstore/rekor/pkg/generated/models

     1  // Code generated by go-swagger; DO NOT EDIT.
     2  
     3  //
     4  // Copyright 2021 The Sigstore Authors.
     5  //
     6  // Licensed under the Apache License, Version 2.0 (the "License");
     7  // you may not use this file except in compliance with the License.
     8  // You may obtain a copy of the License at
     9  //
    10  //     http://www.apache.org/licenses/LICENSE-2.0
    11  //
    12  // Unless required by applicable law or agreed to in writing, software
    13  // distributed under the License is distributed on an "AS IS" BASIS,
    14  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    15  // See the License for the specific language governing permissions and
    16  // limitations under the License.
    17  //
    18  
    19  package models
    20  
    21  // This file was generated by the swagger tool.
    22  // Editing this file might prove futile when you re-run the swagger generate command
    23  
    24  import (
    25  	"context"
    26  	"encoding/json"
    27  
    28  	"github.com/go-openapi/errors"
    29  	"github.com/go-openapi/strfmt"
    30  	"github.com/go-openapi/swag"
    31  	"github.com/go-openapi/validate"
    32  )
    33  
    34  // HashedrekordV001Schema Hashed Rekor v0.0.1 Schema
    35  //
    36  // # Schema for Hashed Rekord object
    37  //
    38  // swagger:model hashedrekordV001Schema
    39  type HashedrekordV001Schema struct {
    40  
    41  	// data
    42  	// Required: true
    43  	Data *HashedrekordV001SchemaData `json:"data"`
    44  
    45  	// signature
    46  	// Required: true
    47  	Signature *HashedrekordV001SchemaSignature `json:"signature"`
    48  }
    49  
    50  // Validate validates this hashedrekord v001 schema
    51  func (m *HashedrekordV001Schema) Validate(formats strfmt.Registry) error {
    52  	var res []error
    53  
    54  	if err := m.validateData(formats); err != nil {
    55  		res = append(res, err)
    56  	}
    57  
    58  	if err := m.validateSignature(formats); err != nil {
    59  		res = append(res, err)
    60  	}
    61  
    62  	if len(res) > 0 {
    63  		return errors.CompositeValidationError(res...)
    64  	}
    65  	return nil
    66  }
    67  
    68  func (m *HashedrekordV001Schema) validateData(formats strfmt.Registry) error {
    69  
    70  	if err := validate.Required("data", "body", m.Data); err != nil {
    71  		return err
    72  	}
    73  
    74  	if m.Data != nil {
    75  		if err := m.Data.Validate(formats); err != nil {
    76  			if ve, ok := err.(*errors.Validation); ok {
    77  				return ve.ValidateName("data")
    78  			} else if ce, ok := err.(*errors.CompositeError); ok {
    79  				return ce.ValidateName("data")
    80  			}
    81  			return err
    82  		}
    83  	}
    84  
    85  	return nil
    86  }
    87  
    88  func (m *HashedrekordV001Schema) validateSignature(formats strfmt.Registry) error {
    89  
    90  	if err := validate.Required("signature", "body", m.Signature); err != nil {
    91  		return err
    92  	}
    93  
    94  	if m.Signature != nil {
    95  		if err := m.Signature.Validate(formats); err != nil {
    96  			if ve, ok := err.(*errors.Validation); ok {
    97  				return ve.ValidateName("signature")
    98  			} else if ce, ok := err.(*errors.CompositeError); ok {
    99  				return ce.ValidateName("signature")
   100  			}
   101  			return err
   102  		}
   103  	}
   104  
   105  	return nil
   106  }
   107  
   108  // ContextValidate validate this hashedrekord v001 schema based on the context it is used
   109  func (m *HashedrekordV001Schema) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
   110  	var res []error
   111  
   112  	if err := m.contextValidateData(ctx, formats); err != nil {
   113  		res = append(res, err)
   114  	}
   115  
   116  	if err := m.contextValidateSignature(ctx, formats); err != nil {
   117  		res = append(res, err)
   118  	}
   119  
   120  	if len(res) > 0 {
   121  		return errors.CompositeValidationError(res...)
   122  	}
   123  	return nil
   124  }
   125  
   126  func (m *HashedrekordV001Schema) contextValidateData(ctx context.Context, formats strfmt.Registry) error {
   127  
   128  	if m.Data != nil {
   129  
   130  		if err := m.Data.ContextValidate(ctx, formats); err != nil {
   131  			if ve, ok := err.(*errors.Validation); ok {
   132  				return ve.ValidateName("data")
   133  			} else if ce, ok := err.(*errors.CompositeError); ok {
   134  				return ce.ValidateName("data")
   135  			}
   136  			return err
   137  		}
   138  	}
   139  
   140  	return nil
   141  }
   142  
   143  func (m *HashedrekordV001Schema) contextValidateSignature(ctx context.Context, formats strfmt.Registry) error {
   144  
   145  	if m.Signature != nil {
   146  
   147  		if err := m.Signature.ContextValidate(ctx, formats); err != nil {
   148  			if ve, ok := err.(*errors.Validation); ok {
   149  				return ve.ValidateName("signature")
   150  			} else if ce, ok := err.(*errors.CompositeError); ok {
   151  				return ce.ValidateName("signature")
   152  			}
   153  			return err
   154  		}
   155  	}
   156  
   157  	return nil
   158  }
   159  
   160  // MarshalBinary interface implementation
   161  func (m *HashedrekordV001Schema) MarshalBinary() ([]byte, error) {
   162  	if m == nil {
   163  		return nil, nil
   164  	}
   165  	return swag.WriteJSON(m)
   166  }
   167  
   168  // UnmarshalBinary interface implementation
   169  func (m *HashedrekordV001Schema) UnmarshalBinary(b []byte) error {
   170  	var res HashedrekordV001Schema
   171  	if err := swag.ReadJSON(b, &res); err != nil {
   172  		return err
   173  	}
   174  	*m = res
   175  	return nil
   176  }
   177  
   178  // HashedrekordV001SchemaData Information about the content associated with the entry
   179  //
   180  // swagger:model HashedrekordV001SchemaData
   181  type HashedrekordV001SchemaData struct {
   182  
   183  	// hash
   184  	Hash *HashedrekordV001SchemaDataHash `json:"hash,omitempty"`
   185  }
   186  
   187  // Validate validates this hashedrekord v001 schema data
   188  func (m *HashedrekordV001SchemaData) Validate(formats strfmt.Registry) error {
   189  	var res []error
   190  
   191  	if err := m.validateHash(formats); err != nil {
   192  		res = append(res, err)
   193  	}
   194  
   195  	if len(res) > 0 {
   196  		return errors.CompositeValidationError(res...)
   197  	}
   198  	return nil
   199  }
   200  
   201  func (m *HashedrekordV001SchemaData) validateHash(formats strfmt.Registry) error {
   202  	if swag.IsZero(m.Hash) { // not required
   203  		return nil
   204  	}
   205  
   206  	if m.Hash != nil {
   207  		if err := m.Hash.Validate(formats); err != nil {
   208  			if ve, ok := err.(*errors.Validation); ok {
   209  				return ve.ValidateName("data" + "." + "hash")
   210  			} else if ce, ok := err.(*errors.CompositeError); ok {
   211  				return ce.ValidateName("data" + "." + "hash")
   212  			}
   213  			return err
   214  		}
   215  	}
   216  
   217  	return nil
   218  }
   219  
   220  // ContextValidate validate this hashedrekord v001 schema data based on the context it is used
   221  func (m *HashedrekordV001SchemaData) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
   222  	var res []error
   223  
   224  	if err := m.contextValidateHash(ctx, formats); err != nil {
   225  		res = append(res, err)
   226  	}
   227  
   228  	if len(res) > 0 {
   229  		return errors.CompositeValidationError(res...)
   230  	}
   231  	return nil
   232  }
   233  
   234  func (m *HashedrekordV001SchemaData) contextValidateHash(ctx context.Context, formats strfmt.Registry) error {
   235  
   236  	if m.Hash != nil {
   237  
   238  		if swag.IsZero(m.Hash) { // not required
   239  			return nil
   240  		}
   241  
   242  		if err := m.Hash.ContextValidate(ctx, formats); err != nil {
   243  			if ve, ok := err.(*errors.Validation); ok {
   244  				return ve.ValidateName("data" + "." + "hash")
   245  			} else if ce, ok := err.(*errors.CompositeError); ok {
   246  				return ce.ValidateName("data" + "." + "hash")
   247  			}
   248  			return err
   249  		}
   250  	}
   251  
   252  	return nil
   253  }
   254  
   255  // MarshalBinary interface implementation
   256  func (m *HashedrekordV001SchemaData) MarshalBinary() ([]byte, error) {
   257  	if m == nil {
   258  		return nil, nil
   259  	}
   260  	return swag.WriteJSON(m)
   261  }
   262  
   263  // UnmarshalBinary interface implementation
   264  func (m *HashedrekordV001SchemaData) UnmarshalBinary(b []byte) error {
   265  	var res HashedrekordV001SchemaData
   266  	if err := swag.ReadJSON(b, &res); err != nil {
   267  		return err
   268  	}
   269  	*m = res
   270  	return nil
   271  }
   272  
   273  // HashedrekordV001SchemaDataHash Specifies the hash algorithm and value for the content
   274  //
   275  // swagger:model HashedrekordV001SchemaDataHash
   276  type HashedrekordV001SchemaDataHash struct {
   277  
   278  	// The hashing function used to compute the hash value
   279  	// Required: true
   280  	// Enum: [sha256 sha384 sha512]
   281  	Algorithm *string `json:"algorithm"`
   282  
   283  	// The hash value for the content, as represented by a lower case hexadecimal string
   284  	// Required: true
   285  	Value *string `json:"value"`
   286  }
   287  
   288  // Validate validates this hashedrekord v001 schema data hash
   289  func (m *HashedrekordV001SchemaDataHash) Validate(formats strfmt.Registry) error {
   290  	var res []error
   291  
   292  	if err := m.validateAlgorithm(formats); err != nil {
   293  		res = append(res, err)
   294  	}
   295  
   296  	if err := m.validateValue(formats); err != nil {
   297  		res = append(res, err)
   298  	}
   299  
   300  	if len(res) > 0 {
   301  		return errors.CompositeValidationError(res...)
   302  	}
   303  	return nil
   304  }
   305  
   306  var hashedrekordV001SchemaDataHashTypeAlgorithmPropEnum []interface{}
   307  
   308  func init() {
   309  	var res []string
   310  	if err := json.Unmarshal([]byte(`["sha256","sha384","sha512"]`), &res); err != nil {
   311  		panic(err)
   312  	}
   313  	for _, v := range res {
   314  		hashedrekordV001SchemaDataHashTypeAlgorithmPropEnum = append(hashedrekordV001SchemaDataHashTypeAlgorithmPropEnum, v)
   315  	}
   316  }
   317  
   318  const (
   319  
   320  	// HashedrekordV001SchemaDataHashAlgorithmSha256 captures enum value "sha256"
   321  	HashedrekordV001SchemaDataHashAlgorithmSha256 string = "sha256"
   322  
   323  	// HashedrekordV001SchemaDataHashAlgorithmSha384 captures enum value "sha384"
   324  	HashedrekordV001SchemaDataHashAlgorithmSha384 string = "sha384"
   325  
   326  	// HashedrekordV001SchemaDataHashAlgorithmSha512 captures enum value "sha512"
   327  	HashedrekordV001SchemaDataHashAlgorithmSha512 string = "sha512"
   328  )
   329  
   330  // prop value enum
   331  func (m *HashedrekordV001SchemaDataHash) validateAlgorithmEnum(path, location string, value string) error {
   332  	if err := validate.EnumCase(path, location, value, hashedrekordV001SchemaDataHashTypeAlgorithmPropEnum, true); err != nil {
   333  		return err
   334  	}
   335  	return nil
   336  }
   337  
   338  func (m *HashedrekordV001SchemaDataHash) validateAlgorithm(formats strfmt.Registry) error {
   339  
   340  	if err := validate.Required("data"+"."+"hash"+"."+"algorithm", "body", m.Algorithm); err != nil {
   341  		return err
   342  	}
   343  
   344  	// value enum
   345  	if err := m.validateAlgorithmEnum("data"+"."+"hash"+"."+"algorithm", "body", *m.Algorithm); err != nil {
   346  		return err
   347  	}
   348  
   349  	return nil
   350  }
   351  
   352  func (m *HashedrekordV001SchemaDataHash) validateValue(formats strfmt.Registry) error {
   353  
   354  	if err := validate.Required("data"+"."+"hash"+"."+"value", "body", m.Value); err != nil {
   355  		return err
   356  	}
   357  
   358  	return nil
   359  }
   360  
   361  // ContextValidate validates this hashedrekord v001 schema data hash based on context it is used
   362  func (m *HashedrekordV001SchemaDataHash) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
   363  	return nil
   364  }
   365  
   366  // MarshalBinary interface implementation
   367  func (m *HashedrekordV001SchemaDataHash) MarshalBinary() ([]byte, error) {
   368  	if m == nil {
   369  		return nil, nil
   370  	}
   371  	return swag.WriteJSON(m)
   372  }
   373  
   374  // UnmarshalBinary interface implementation
   375  func (m *HashedrekordV001SchemaDataHash) UnmarshalBinary(b []byte) error {
   376  	var res HashedrekordV001SchemaDataHash
   377  	if err := swag.ReadJSON(b, &res); err != nil {
   378  		return err
   379  	}
   380  	*m = res
   381  	return nil
   382  }
   383  
   384  // HashedrekordV001SchemaSignature Information about the detached signature associated with the entry
   385  //
   386  // swagger:model HashedrekordV001SchemaSignature
   387  type HashedrekordV001SchemaSignature struct {
   388  
   389  	// Specifies the content of the signature inline within the document
   390  	// Format: byte
   391  	Content strfmt.Base64 `json:"content,omitempty"`
   392  
   393  	// public key
   394  	PublicKey *HashedrekordV001SchemaSignaturePublicKey `json:"publicKey,omitempty"`
   395  }
   396  
   397  // Validate validates this hashedrekord v001 schema signature
   398  func (m *HashedrekordV001SchemaSignature) Validate(formats strfmt.Registry) error {
   399  	var res []error
   400  
   401  	if err := m.validatePublicKey(formats); err != nil {
   402  		res = append(res, err)
   403  	}
   404  
   405  	if len(res) > 0 {
   406  		return errors.CompositeValidationError(res...)
   407  	}
   408  	return nil
   409  }
   410  
   411  func (m *HashedrekordV001SchemaSignature) validatePublicKey(formats strfmt.Registry) error {
   412  	if swag.IsZero(m.PublicKey) { // not required
   413  		return nil
   414  	}
   415  
   416  	if m.PublicKey != nil {
   417  		if err := m.PublicKey.Validate(formats); err != nil {
   418  			if ve, ok := err.(*errors.Validation); ok {
   419  				return ve.ValidateName("signature" + "." + "publicKey")
   420  			} else if ce, ok := err.(*errors.CompositeError); ok {
   421  				return ce.ValidateName("signature" + "." + "publicKey")
   422  			}
   423  			return err
   424  		}
   425  	}
   426  
   427  	return nil
   428  }
   429  
   430  // ContextValidate validate this hashedrekord v001 schema signature based on the context it is used
   431  func (m *HashedrekordV001SchemaSignature) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
   432  	var res []error
   433  
   434  	if err := m.contextValidatePublicKey(ctx, formats); err != nil {
   435  		res = append(res, err)
   436  	}
   437  
   438  	if len(res) > 0 {
   439  		return errors.CompositeValidationError(res...)
   440  	}
   441  	return nil
   442  }
   443  
   444  func (m *HashedrekordV001SchemaSignature) contextValidatePublicKey(ctx context.Context, formats strfmt.Registry) error {
   445  
   446  	if m.PublicKey != nil {
   447  
   448  		if swag.IsZero(m.PublicKey) { // not required
   449  			return nil
   450  		}
   451  
   452  		if err := m.PublicKey.ContextValidate(ctx, formats); err != nil {
   453  			if ve, ok := err.(*errors.Validation); ok {
   454  				return ve.ValidateName("signature" + "." + "publicKey")
   455  			} else if ce, ok := err.(*errors.CompositeError); ok {
   456  				return ce.ValidateName("signature" + "." + "publicKey")
   457  			}
   458  			return err
   459  		}
   460  	}
   461  
   462  	return nil
   463  }
   464  
   465  // MarshalBinary interface implementation
   466  func (m *HashedrekordV001SchemaSignature) MarshalBinary() ([]byte, error) {
   467  	if m == nil {
   468  		return nil, nil
   469  	}
   470  	return swag.WriteJSON(m)
   471  }
   472  
   473  // UnmarshalBinary interface implementation
   474  func (m *HashedrekordV001SchemaSignature) UnmarshalBinary(b []byte) error {
   475  	var res HashedrekordV001SchemaSignature
   476  	if err := swag.ReadJSON(b, &res); err != nil {
   477  		return err
   478  	}
   479  	*m = res
   480  	return nil
   481  }
   482  
   483  // HashedrekordV001SchemaSignaturePublicKey The public key that can verify the signature; this can also be an X509 code signing certificate that contains the raw public key information
   484  //
   485  // swagger:model HashedrekordV001SchemaSignaturePublicKey
   486  type HashedrekordV001SchemaSignaturePublicKey struct {
   487  
   488  	// Specifies the content of the public key or code signing certificate inline within the document
   489  	// Format: byte
   490  	Content strfmt.Base64 `json:"content,omitempty"`
   491  }
   492  
   493  // Validate validates this hashedrekord v001 schema signature public key
   494  func (m *HashedrekordV001SchemaSignaturePublicKey) Validate(formats strfmt.Registry) error {
   495  	return nil
   496  }
   497  
   498  // ContextValidate validates this hashedrekord v001 schema signature public key based on context it is used
   499  func (m *HashedrekordV001SchemaSignaturePublicKey) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
   500  	return nil
   501  }
   502  
   503  // MarshalBinary interface implementation
   504  func (m *HashedrekordV001SchemaSignaturePublicKey) MarshalBinary() ([]byte, error) {
   505  	if m == nil {
   506  		return nil, nil
   507  	}
   508  	return swag.WriteJSON(m)
   509  }
   510  
   511  // UnmarshalBinary interface implementation
   512  func (m *HashedrekordV001SchemaSignaturePublicKey) UnmarshalBinary(b []byte) error {
   513  	var res HashedrekordV001SchemaSignaturePublicKey
   514  	if err := swag.ReadJSON(b, &res); err != nil {
   515  		return err
   516  	}
   517  	*m = res
   518  	return nil
   519  }
   520  

View as plain text