...

Source file src/github.com/sigstore/rekor/pkg/generated/models/consistency_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  // ConsistencyProof consistency proof
    35  //
    36  // swagger:model ConsistencyProof
    37  type ConsistencyProof struct {
    38  
    39  	// hashes
    40  	// Required: true
    41  	Hashes []string `json:"hashes"`
    42  
    43  	// The hash value stored at the root of the merkle tree at the time the proof was generated
    44  	// Required: true
    45  	// Pattern: ^[0-9a-fA-F]{64}$
    46  	RootHash *string `json:"rootHash"`
    47  }
    48  
    49  // Validate validates this consistency proof
    50  func (m *ConsistencyProof) Validate(formats strfmt.Registry) error {
    51  	var res []error
    52  
    53  	if err := m.validateHashes(formats); err != nil {
    54  		res = append(res, err)
    55  	}
    56  
    57  	if err := m.validateRootHash(formats); err != nil {
    58  		res = append(res, err)
    59  	}
    60  
    61  	if len(res) > 0 {
    62  		return errors.CompositeValidationError(res...)
    63  	}
    64  	return nil
    65  }
    66  
    67  func (m *ConsistencyProof) validateHashes(formats strfmt.Registry) error {
    68  
    69  	if err := validate.Required("hashes", "body", m.Hashes); err != nil {
    70  		return err
    71  	}
    72  
    73  	for i := 0; i < len(m.Hashes); i++ {
    74  
    75  		if err := validate.Pattern("hashes"+"."+strconv.Itoa(i), "body", m.Hashes[i], `^[0-9a-fA-F]{64}$`); err != nil {
    76  			return err
    77  		}
    78  
    79  	}
    80  
    81  	return nil
    82  }
    83  
    84  func (m *ConsistencyProof) validateRootHash(formats strfmt.Registry) error {
    85  
    86  	if err := validate.Required("rootHash", "body", m.RootHash); err != nil {
    87  		return err
    88  	}
    89  
    90  	if err := validate.Pattern("rootHash", "body", *m.RootHash, `^[0-9a-fA-F]{64}$`); err != nil {
    91  		return err
    92  	}
    93  
    94  	return nil
    95  }
    96  
    97  // ContextValidate validates this consistency proof based on context it is used
    98  func (m *ConsistencyProof) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
    99  	return nil
   100  }
   101  
   102  // MarshalBinary interface implementation
   103  func (m *ConsistencyProof) MarshalBinary() ([]byte, error) {
   104  	if m == nil {
   105  		return nil, nil
   106  	}
   107  	return swag.WriteJSON(m)
   108  }
   109  
   110  // UnmarshalBinary interface implementation
   111  func (m *ConsistencyProof) UnmarshalBinary(b []byte) error {
   112  	var res ConsistencyProof
   113  	if err := swag.ReadJSON(b, &res); err != nil {
   114  		return err
   115  	}
   116  	*m = res
   117  	return nil
   118  }
   119  

View as plain text