github.com/minio/console@v1.4.1/models/remote_bucket.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  // RemoteBucket remote bucket
    36  //
    37  // swagger:model remoteBucket
    38  type RemoteBucket struct {
    39  
    40  	// access key
    41  	// Required: true
    42  	// Min Length: 3
    43  	AccessKey *string `json:"accessKey"`
    44  
    45  	// bandwidth
    46  	Bandwidth int64 `json:"bandwidth,omitempty"`
    47  
    48  	// health check period
    49  	HealthCheckPeriod int64 `json:"healthCheckPeriod,omitempty"`
    50  
    51  	// remote a r n
    52  	// Required: true
    53  	RemoteARN *string `json:"remoteARN"`
    54  
    55  	// secret key
    56  	// Min Length: 8
    57  	SecretKey string `json:"secretKey,omitempty"`
    58  
    59  	// service
    60  	// Enum: [replication]
    61  	Service string `json:"service,omitempty"`
    62  
    63  	// source bucket
    64  	// Required: true
    65  	SourceBucket *string `json:"sourceBucket"`
    66  
    67  	// status
    68  	Status string `json:"status,omitempty"`
    69  
    70  	// sync mode
    71  	SyncMode string `json:"syncMode,omitempty"`
    72  
    73  	// target bucket
    74  	TargetBucket string `json:"targetBucket,omitempty"`
    75  
    76  	// target URL
    77  	TargetURL string `json:"targetURL,omitempty"`
    78  }
    79  
    80  // Validate validates this remote bucket
    81  func (m *RemoteBucket) Validate(formats strfmt.Registry) error {
    82  	var res []error
    83  
    84  	if err := m.validateAccessKey(formats); err != nil {
    85  		res = append(res, err)
    86  	}
    87  
    88  	if err := m.validateRemoteARN(formats); err != nil {
    89  		res = append(res, err)
    90  	}
    91  
    92  	if err := m.validateSecretKey(formats); err != nil {
    93  		res = append(res, err)
    94  	}
    95  
    96  	if err := m.validateService(formats); err != nil {
    97  		res = append(res, err)
    98  	}
    99  
   100  	if err := m.validateSourceBucket(formats); err != nil {
   101  		res = append(res, err)
   102  	}
   103  
   104  	if len(res) > 0 {
   105  		return errors.CompositeValidationError(res...)
   106  	}
   107  	return nil
   108  }
   109  
   110  func (m *RemoteBucket) validateAccessKey(formats strfmt.Registry) error {
   111  
   112  	if err := validate.Required("accessKey", "body", m.AccessKey); err != nil {
   113  		return err
   114  	}
   115  
   116  	if err := validate.MinLength("accessKey", "body", *m.AccessKey, 3); err != nil {
   117  		return err
   118  	}
   119  
   120  	return nil
   121  }
   122  
   123  func (m *RemoteBucket) validateRemoteARN(formats strfmt.Registry) error {
   124  
   125  	if err := validate.Required("remoteARN", "body", m.RemoteARN); err != nil {
   126  		return err
   127  	}
   128  
   129  	return nil
   130  }
   131  
   132  func (m *RemoteBucket) validateSecretKey(formats strfmt.Registry) error {
   133  	if swag.IsZero(m.SecretKey) { // not required
   134  		return nil
   135  	}
   136  
   137  	if err := validate.MinLength("secretKey", "body", m.SecretKey, 8); err != nil {
   138  		return err
   139  	}
   140  
   141  	return nil
   142  }
   143  
   144  var remoteBucketTypeServicePropEnum []interface{}
   145  
   146  func init() {
   147  	var res []string
   148  	if err := json.Unmarshal([]byte(`["replication"]`), &res); err != nil {
   149  		panic(err)
   150  	}
   151  	for _, v := range res {
   152  		remoteBucketTypeServicePropEnum = append(remoteBucketTypeServicePropEnum, v)
   153  	}
   154  }
   155  
   156  const (
   157  
   158  	// RemoteBucketServiceReplication captures enum value "replication"
   159  	RemoteBucketServiceReplication string = "replication"
   160  )
   161  
   162  // prop value enum
   163  func (m *RemoteBucket) validateServiceEnum(path, location string, value string) error {
   164  	if err := validate.EnumCase(path, location, value, remoteBucketTypeServicePropEnum, true); err != nil {
   165  		return err
   166  	}
   167  	return nil
   168  }
   169  
   170  func (m *RemoteBucket) validateService(formats strfmt.Registry) error {
   171  	if swag.IsZero(m.Service) { // not required
   172  		return nil
   173  	}
   174  
   175  	// value enum
   176  	if err := m.validateServiceEnum("service", "body", m.Service); err != nil {
   177  		return err
   178  	}
   179  
   180  	return nil
   181  }
   182  
   183  func (m *RemoteBucket) validateSourceBucket(formats strfmt.Registry) error {
   184  
   185  	if err := validate.Required("sourceBucket", "body", m.SourceBucket); err != nil {
   186  		return err
   187  	}
   188  
   189  	return nil
   190  }
   191  
   192  // ContextValidate validates this remote bucket based on context it is used
   193  func (m *RemoteBucket) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
   194  	return nil
   195  }
   196  
   197  // MarshalBinary interface implementation
   198  func (m *RemoteBucket) MarshalBinary() ([]byte, error) {
   199  	if m == nil {
   200  		return nil, nil
   201  	}
   202  	return swag.WriteJSON(m)
   203  }
   204  
   205  // UnmarshalBinary interface implementation
   206  func (m *RemoteBucket) UnmarshalBinary(b []byte) error {
   207  	var res RemoteBucket
   208  	if err := swag.ReadJSON(b, &res); err != nil {
   209  		return err
   210  	}
   211  	*m = res
   212  	return nil
   213  }