github.com/minio/console@v1.4.1/models/release_metadata.go (about)

     1  // Code generated by go-swagger; DO NOT EDIT.
     2  
     3  // This file is part of MinIO Console Server
     4  // Copyright (c) 2023 MinIO, Inc.
     5  //
     6  // This program is free software: you can redistribute it and/or modify
     7  // it under the terms of the GNU Affero General Public License as published by
     8  // the Free Software Foundation, either version 3 of the License, or
     9  // (at your option) any later version.
    10  //
    11  // This program is distributed in the hope that it will be useful,
    12  // but WITHOUT ANY WARRANTY; without even the implied warranty of
    13  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    14  // GNU Affero General Public License for more details.
    15  //
    16  // You should have received a copy of the GNU Affero General Public License
    17  // along with this program.  If not, see <http://www.gnu.org/licenses/>.
    18  //
    19  
    20  package models
    21  
    22  // This file was generated by the swagger tool.
    23  // Editing this file might prove futile when you re-run the swagger generate command
    24  
    25  import (
    26  	"context"
    27  
    28  	"github.com/go-openapi/errors"
    29  	"github.com/go-openapi/strfmt"
    30  	"github.com/go-openapi/swag"
    31  )
    32  
    33  // ReleaseMetadata release metadata
    34  //
    35  // swagger:model releaseMetadata
    36  type ReleaseMetadata struct {
    37  
    38  	// assets url
    39  	AssetsURL string `json:"assets_url,omitempty"`
    40  
    41  	// author
    42  	Author *ReleaseAuthor `json:"author,omitempty"`
    43  
    44  	// created at
    45  	CreatedAt string `json:"created_at,omitempty"`
    46  
    47  	// draft
    48  	Draft bool `json:"draft,omitempty"`
    49  
    50  	// html url
    51  	HTMLURL string `json:"html_url,omitempty"`
    52  
    53  	// id
    54  	ID int64 `json:"id,omitempty"`
    55  
    56  	// name
    57  	Name string `json:"name,omitempty"`
    58  
    59  	// node id
    60  	NodeID string `json:"node_id,omitempty"`
    61  
    62  	// prerelease
    63  	Prerelease bool `json:"prerelease,omitempty"`
    64  
    65  	// published at
    66  	PublishedAt string `json:"published_at,omitempty"`
    67  
    68  	// tag name
    69  	TagName string `json:"tag_name,omitempty"`
    70  
    71  	// tarball url
    72  	TarballURL string `json:"tarball_url,omitempty"`
    73  
    74  	// target commitish
    75  	TargetCommitish string `json:"target_commitish,omitempty"`
    76  
    77  	// upload url
    78  	UploadURL string `json:"upload_url,omitempty"`
    79  
    80  	// url
    81  	URL string `json:"url,omitempty"`
    82  
    83  	// zipball url
    84  	ZipballURL string `json:"zipball_url,omitempty"`
    85  }
    86  
    87  // Validate validates this release metadata
    88  func (m *ReleaseMetadata) Validate(formats strfmt.Registry) error {
    89  	var res []error
    90  
    91  	if err := m.validateAuthor(formats); err != nil {
    92  		res = append(res, err)
    93  	}
    94  
    95  	if len(res) > 0 {
    96  		return errors.CompositeValidationError(res...)
    97  	}
    98  	return nil
    99  }
   100  
   101  func (m *ReleaseMetadata) validateAuthor(formats strfmt.Registry) error {
   102  	if swag.IsZero(m.Author) { // not required
   103  		return nil
   104  	}
   105  
   106  	if m.Author != nil {
   107  		if err := m.Author.Validate(formats); err != nil {
   108  			if ve, ok := err.(*errors.Validation); ok {
   109  				return ve.ValidateName("author")
   110  			} else if ce, ok := err.(*errors.CompositeError); ok {
   111  				return ce.ValidateName("author")
   112  			}
   113  			return err
   114  		}
   115  	}
   116  
   117  	return nil
   118  }
   119  
   120  // ContextValidate validate this release metadata based on the context it is used
   121  func (m *ReleaseMetadata) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
   122  	var res []error
   123  
   124  	if err := m.contextValidateAuthor(ctx, formats); err != nil {
   125  		res = append(res, err)
   126  	}
   127  
   128  	if len(res) > 0 {
   129  		return errors.CompositeValidationError(res...)
   130  	}
   131  	return nil
   132  }
   133  
   134  func (m *ReleaseMetadata) contextValidateAuthor(ctx context.Context, formats strfmt.Registry) error {
   135  
   136  	if m.Author != nil {
   137  
   138  		if swag.IsZero(m.Author) { // not required
   139  			return nil
   140  		}
   141  
   142  		if err := m.Author.ContextValidate(ctx, formats); err != nil {
   143  			if ve, ok := err.(*errors.Validation); ok {
   144  				return ve.ValidateName("author")
   145  			} else if ce, ok := err.(*errors.CompositeError); ok {
   146  				return ce.ValidateName("author")
   147  			}
   148  			return err
   149  		}
   150  	}
   151  
   152  	return nil
   153  }
   154  
   155  // MarshalBinary interface implementation
   156  func (m *ReleaseMetadata) MarshalBinary() ([]byte, error) {
   157  	if m == nil {
   158  		return nil, nil
   159  	}
   160  	return swag.WriteJSON(m)
   161  }
   162  
   163  // UnmarshalBinary interface implementation
   164  func (m *ReleaseMetadata) UnmarshalBinary(b []byte) error {
   165  	var res ReleaseMetadata
   166  	if err := swag.ReadJSON(b, &res); err != nil {
   167  		return err
   168  	}
   169  	*m = res
   170  	return nil
   171  }