github.com/minio/console@v1.4.1/models/bucket_replication_rule.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  	"encoding/json"
    28  
    29  	"github.com/go-openapi/errors"
    30  	"github.com/go-openapi/strfmt"
    31  	"github.com/go-openapi/swag"
    32  	"github.com/go-openapi/validate"
    33  )
    34  
    35  // BucketReplicationRule bucket replication rule
    36  //
    37  // swagger:model bucketReplicationRule
    38  type BucketReplicationRule struct {
    39  
    40  	// bandwidth
    41  	Bandwidth string `json:"bandwidth,omitempty"`
    42  
    43  	// delete marker replication
    44  	DeleteMarkerReplication bool `json:"delete_marker_replication,omitempty"`
    45  
    46  	// deletes replication
    47  	DeletesReplication bool `json:"deletes_replication,omitempty"`
    48  
    49  	// destination
    50  	Destination *BucketReplicationDestination `json:"destination,omitempty"`
    51  
    52  	// existing objects
    53  	ExistingObjects bool `json:"existingObjects,omitempty"`
    54  
    55  	// health check period
    56  	HealthCheckPeriod int64 `json:"healthCheckPeriod,omitempty"`
    57  
    58  	// id
    59  	ID string `json:"id,omitempty"`
    60  
    61  	// metadata replication
    62  	MetadataReplication bool `json:"metadata_replication,omitempty"`
    63  
    64  	// prefix
    65  	Prefix string `json:"prefix,omitempty"`
    66  
    67  	// priority
    68  	Priority int32 `json:"priority,omitempty"`
    69  
    70  	// status
    71  	// Enum: [Enabled Disabled]
    72  	Status string `json:"status,omitempty"`
    73  
    74  	// storage class
    75  	StorageClass string `json:"storageClass,omitempty"`
    76  
    77  	// sync mode
    78  	// Enum: [async sync]
    79  	SyncMode *string `json:"syncMode,omitempty"`
    80  
    81  	// tags
    82  	Tags string `json:"tags,omitempty"`
    83  }
    84  
    85  // Validate validates this bucket replication rule
    86  func (m *BucketReplicationRule) Validate(formats strfmt.Registry) error {
    87  	var res []error
    88  
    89  	if err := m.validateDestination(formats); err != nil {
    90  		res = append(res, err)
    91  	}
    92  
    93  	if err := m.validateStatus(formats); err != nil {
    94  		res = append(res, err)
    95  	}
    96  
    97  	if err := m.validateSyncMode(formats); err != nil {
    98  		res = append(res, err)
    99  	}
   100  
   101  	if len(res) > 0 {
   102  		return errors.CompositeValidationError(res...)
   103  	}
   104  	return nil
   105  }
   106  
   107  func (m *BucketReplicationRule) validateDestination(formats strfmt.Registry) error {
   108  	if swag.IsZero(m.Destination) { // not required
   109  		return nil
   110  	}
   111  
   112  	if m.Destination != nil {
   113  		if err := m.Destination.Validate(formats); err != nil {
   114  			if ve, ok := err.(*errors.Validation); ok {
   115  				return ve.ValidateName("destination")
   116  			} else if ce, ok := err.(*errors.CompositeError); ok {
   117  				return ce.ValidateName("destination")
   118  			}
   119  			return err
   120  		}
   121  	}
   122  
   123  	return nil
   124  }
   125  
   126  var bucketReplicationRuleTypeStatusPropEnum []interface{}
   127  
   128  func init() {
   129  	var res []string
   130  	if err := json.Unmarshal([]byte(`["Enabled","Disabled"]`), &res); err != nil {
   131  		panic(err)
   132  	}
   133  	for _, v := range res {
   134  		bucketReplicationRuleTypeStatusPropEnum = append(bucketReplicationRuleTypeStatusPropEnum, v)
   135  	}
   136  }
   137  
   138  const (
   139  
   140  	// BucketReplicationRuleStatusEnabled captures enum value "Enabled"
   141  	BucketReplicationRuleStatusEnabled string = "Enabled"
   142  
   143  	// BucketReplicationRuleStatusDisabled captures enum value "Disabled"
   144  	BucketReplicationRuleStatusDisabled string = "Disabled"
   145  )
   146  
   147  // prop value enum
   148  func (m *BucketReplicationRule) validateStatusEnum(path, location string, value string) error {
   149  	if err := validate.EnumCase(path, location, value, bucketReplicationRuleTypeStatusPropEnum, true); err != nil {
   150  		return err
   151  	}
   152  	return nil
   153  }
   154  
   155  func (m *BucketReplicationRule) validateStatus(formats strfmt.Registry) error {
   156  	if swag.IsZero(m.Status) { // not required
   157  		return nil
   158  	}
   159  
   160  	// value enum
   161  	if err := m.validateStatusEnum("status", "body", m.Status); err != nil {
   162  		return err
   163  	}
   164  
   165  	return nil
   166  }
   167  
   168  var bucketReplicationRuleTypeSyncModePropEnum []interface{}
   169  
   170  func init() {
   171  	var res []string
   172  	if err := json.Unmarshal([]byte(`["async","sync"]`), &res); err != nil {
   173  		panic(err)
   174  	}
   175  	for _, v := range res {
   176  		bucketReplicationRuleTypeSyncModePropEnum = append(bucketReplicationRuleTypeSyncModePropEnum, v)
   177  	}
   178  }
   179  
   180  const (
   181  
   182  	// BucketReplicationRuleSyncModeAsync captures enum value "async"
   183  	BucketReplicationRuleSyncModeAsync string = "async"
   184  
   185  	// BucketReplicationRuleSyncModeSync captures enum value "sync"
   186  	BucketReplicationRuleSyncModeSync string = "sync"
   187  )
   188  
   189  // prop value enum
   190  func (m *BucketReplicationRule) validateSyncModeEnum(path, location string, value string) error {
   191  	if err := validate.EnumCase(path, location, value, bucketReplicationRuleTypeSyncModePropEnum, true); err != nil {
   192  		return err
   193  	}
   194  	return nil
   195  }
   196  
   197  func (m *BucketReplicationRule) validateSyncMode(formats strfmt.Registry) error {
   198  	if swag.IsZero(m.SyncMode) { // not required
   199  		return nil
   200  	}
   201  
   202  	// value enum
   203  	if err := m.validateSyncModeEnum("syncMode", "body", *m.SyncMode); err != nil {
   204  		return err
   205  	}
   206  
   207  	return nil
   208  }
   209  
   210  // ContextValidate validate this bucket replication rule based on the context it is used
   211  func (m *BucketReplicationRule) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
   212  	var res []error
   213  
   214  	if err := m.contextValidateDestination(ctx, formats); err != nil {
   215  		res = append(res, err)
   216  	}
   217  
   218  	if len(res) > 0 {
   219  		return errors.CompositeValidationError(res...)
   220  	}
   221  	return nil
   222  }
   223  
   224  func (m *BucketReplicationRule) contextValidateDestination(ctx context.Context, formats strfmt.Registry) error {
   225  
   226  	if m.Destination != nil {
   227  
   228  		if swag.IsZero(m.Destination) { // not required
   229  			return nil
   230  		}
   231  
   232  		if err := m.Destination.ContextValidate(ctx, formats); err != nil {
   233  			if ve, ok := err.(*errors.Validation); ok {
   234  				return ve.ValidateName("destination")
   235  			} else if ce, ok := err.(*errors.CompositeError); ok {
   236  				return ce.ValidateName("destination")
   237  			}
   238  			return err
   239  		}
   240  	}
   241  
   242  	return nil
   243  }
   244  
   245  // MarshalBinary interface implementation
   246  func (m *BucketReplicationRule) MarshalBinary() ([]byte, error) {
   247  	if m == nil {
   248  		return nil, nil
   249  	}
   250  	return swag.WriteJSON(m)
   251  }
   252  
   253  // UnmarshalBinary interface implementation
   254  func (m *BucketReplicationRule) UnmarshalBinary(b []byte) error {
   255  	var res BucketReplicationRule
   256  	if err := swag.ReadJSON(b, &res); err != nil {
   257  		return err
   258  	}
   259  	*m = res
   260  	return nil
   261  }