...

Source file src/github.com/sigstore/rekor/pkg/generated/models/inclusion_proof.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  	"strconv"
    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  // InclusionProof inclusion proof
    35  //
    36  // swagger:model InclusionProof
    37  type InclusionProof struct {
    38  
    39  	// The checkpoint (signed tree head) that the inclusion proof is based on
    40  	// Required: true
    41  	Checkpoint *string `json:"checkpoint"`
    42  
    43  	// A list of hashes required to compute the inclusion proof, sorted in order from leaf to root
    44  	// Required: true
    45  	Hashes []string `json:"hashes"`
    46  
    47  	// The index of the entry in the transparency log
    48  	// Required: true
    49  	// Minimum: 0
    50  	LogIndex *int64 `json:"logIndex"`
    51  
    52  	// The hash value stored at the root of the merkle tree at the time the proof was generated
    53  	// Required: true
    54  	// Pattern: ^[0-9a-fA-F]{64}$
    55  	RootHash *string `json:"rootHash"`
    56  
    57  	// The size of the merkle tree at the time the inclusion proof was generated
    58  	// Required: true
    59  	// Minimum: 1
    60  	TreeSize *int64 `json:"treeSize"`
    61  }
    62  
    63  // Validate validates this inclusion proof
    64  func (m *InclusionProof) Validate(formats strfmt.Registry) error {
    65  	var res []error
    66  
    67  	if err := m.validateCheckpoint(formats); err != nil {
    68  		res = append(res, err)
    69  	}
    70  
    71  	if err := m.validateHashes(formats); err != nil {
    72  		res = append(res, err)
    73  	}
    74  
    75  	if err := m.validateLogIndex(formats); err != nil {
    76  		res = append(res, err)
    77  	}
    78  
    79  	if err := m.validateRootHash(formats); err != nil {
    80  		res = append(res, err)
    81  	}
    82  
    83  	if err := m.validateTreeSize(formats); err != nil {
    84  		res = append(res, err)
    85  	}
    86  
    87  	if len(res) > 0 {
    88  		return errors.CompositeValidationError(res...)
    89  	}
    90  	return nil
    91  }
    92  
    93  func (m *InclusionProof) validateCheckpoint(formats strfmt.Registry) error {
    94  
    95  	if err := validate.Required("checkpoint", "body", m.Checkpoint); err != nil {
    96  		return err
    97  	}
    98  
    99  	return nil
   100  }
   101  
   102  func (m *InclusionProof) validateHashes(formats strfmt.Registry) error {
   103  
   104  	if err := validate.Required("hashes", "body", m.Hashes); err != nil {
   105  		return err
   106  	}
   107  
   108  	for i := 0; i < len(m.Hashes); i++ {
   109  
   110  		if err := validate.Pattern("hashes"+"."+strconv.Itoa(i), "body", m.Hashes[i], `^[0-9a-fA-F]{64}$`); err != nil {
   111  			return err
   112  		}
   113  
   114  	}
   115  
   116  	return nil
   117  }
   118  
   119  func (m *InclusionProof) validateLogIndex(formats strfmt.Registry) error {
   120  
   121  	if err := validate.Required("logIndex", "body", m.LogIndex); err != nil {
   122  		return err
   123  	}
   124  
   125  	if err := validate.MinimumInt("logIndex", "body", *m.LogIndex, 0, false); err != nil {
   126  		return err
   127  	}
   128  
   129  	return nil
   130  }
   131  
   132  func (m *InclusionProof) validateRootHash(formats strfmt.Registry) error {
   133  
   134  	if err := validate.Required("rootHash", "body", m.RootHash); err != nil {
   135  		return err
   136  	}
   137  
   138  	if err := validate.Pattern("rootHash", "body", *m.RootHash, `^[0-9a-fA-F]{64}$`); err != nil {
   139  		return err
   140  	}
   141  
   142  	return nil
   143  }
   144  
   145  func (m *InclusionProof) validateTreeSize(formats strfmt.Registry) error {
   146  
   147  	if err := validate.Required("treeSize", "body", m.TreeSize); err != nil {
   148  		return err
   149  	}
   150  
   151  	if err := validate.MinimumInt("treeSize", "body", *m.TreeSize, 1, false); err != nil {
   152  		return err
   153  	}
   154  
   155  	return nil
   156  }
   157  
   158  // ContextValidate validates this inclusion proof based on context it is used
   159  func (m *InclusionProof) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
   160  	return nil
   161  }
   162  
   163  // MarshalBinary interface implementation
   164  func (m *InclusionProof) MarshalBinary() ([]byte, error) {
   165  	if m == nil {
   166  		return nil, nil
   167  	}
   168  	return swag.WriteJSON(m)
   169  }
   170  
   171  // UnmarshalBinary interface implementation
   172  func (m *InclusionProof) UnmarshalBinary(b []byte) error {
   173  	var res InclusionProof
   174  	if err := swag.ReadJSON(b, &res); err != nil {
   175  		return err
   176  	}
   177  	*m = res
   178  	return nil
   179  }
   180  

View as plain text