github.com/keybase/client/go@v0.0.0-20241007131713-f10651d043c8/tlfupgrade/prot.go (about)

     1  package tlfupgrade
     2  
     3  import (
     4  	"errors"
     5  
     6  	"github.com/keybase/client/go/protocol/gregor1"
     7  	"github.com/keybase/client/go/protocol/keybase1"
     8  )
     9  
    10  type GetTLFForUpgradeResType int
    11  
    12  const (
    13  	GetTLFForUpgradeResType_TLFAVAILABLE GetTLFForUpgradeResType = 0
    14  	GetTLFForUpgradeResType_DELAY        GetTLFForUpgradeResType = 1
    15  	GetTLFForUpgradeResType_ERR          GetTLFForUpgradeResType = 2
    16  	GetTLFForUpgradeResType_DISABLED     GetTLFForUpgradeResType = 3
    17  )
    18  
    19  func (o GetTLFForUpgradeResType) DeepCopy() GetTLFForUpgradeResType { return o }
    20  
    21  var GetTLFForUpgradeResTypeMap = map[string]GetTLFForUpgradeResType{
    22  	"TLFAVAILABLE": 0,
    23  	"DELAY":        1,
    24  	"ERR":          2,
    25  	"DISABLED":     3,
    26  }
    27  
    28  var GetTLFForUpgradeResTypeRevMap = map[GetTLFForUpgradeResType]string{
    29  	0: "TLFAVAILABLE",
    30  	1: "DELAY",
    31  	2: "ERR",
    32  	3: "DISABLED",
    33  }
    34  
    35  func (e GetTLFForUpgradeResType) String() string {
    36  	if v, ok := GetTLFForUpgradeResTypeRevMap[e]; ok {
    37  		return v
    38  	}
    39  	return ""
    40  }
    41  
    42  type DelayReason int
    43  
    44  const (
    45  	DelayReason_MISS     DelayReason = 0
    46  	DelayReason_INFLIGHT DelayReason = 1
    47  )
    48  
    49  func (o DelayReason) DeepCopy() DelayReason { return o }
    50  
    51  var DelayReasonMap = map[string]DelayReason{
    52  	"MISS":     0,
    53  	"INFLIGHT": 1,
    54  }
    55  
    56  var DelayReasonRevMap = map[DelayReason]string{
    57  	0: "MISS",
    58  	1: "INFLIGHT",
    59  }
    60  
    61  func (e DelayReason) String() string {
    62  	if v, ok := DelayReasonRevMap[e]; ok {
    63  		return v
    64  	}
    65  	return ""
    66  }
    67  
    68  type GetTLFForUpgradeAvailableRes struct {
    69  	TlfID    keybase1.TLFID `codec:"tlfID" json:"tlfID"`
    70  	TlfName  string         `codec:"tlfName" json:"tlfName"`
    71  	IsPublic bool           `codec:"isPublic" json:"isPublic"`
    72  }
    73  
    74  func (o GetTLFForUpgradeAvailableRes) DeepCopy() GetTLFForUpgradeAvailableRes {
    75  	return GetTLFForUpgradeAvailableRes{
    76  		TlfID:    o.TlfID.DeepCopy(),
    77  		TlfName:  o.TlfName,
    78  		IsPublic: o.IsPublic,
    79  	}
    80  }
    81  
    82  type GetTLFForUpgradeDelayRes struct {
    83  	Delay  gregor1.Time `codec:"delay" json:"delay"`
    84  	Reason DelayReason  `codec:"reason" json:"reason"`
    85  }
    86  
    87  func (o GetTLFForUpgradeDelayRes) DeepCopy() GetTLFForUpgradeDelayRes {
    88  	return GetTLFForUpgradeDelayRes{
    89  		Delay:  o.Delay.DeepCopy(),
    90  		Reason: o.Reason.DeepCopy(),
    91  	}
    92  }
    93  
    94  type GetTLFForUpgradeErrRes struct {
    95  	Error string       `codec:"error" json:"error"`
    96  	Delay gregor1.Time `codec:"delay" json:"delay"`
    97  }
    98  
    99  func (o GetTLFForUpgradeErrRes) DeepCopy() GetTLFForUpgradeErrRes {
   100  	return GetTLFForUpgradeErrRes{
   101  		Error: o.Error,
   102  		Delay: o.Delay.DeepCopy(),
   103  	}
   104  }
   105  
   106  type GetTLFForUpgradeDisabledRes struct {
   107  	Delay gregor1.Time `codec:"delay" json:"delay"`
   108  }
   109  
   110  func (o GetTLFForUpgradeDisabledRes) DeepCopy() GetTLFForUpgradeDisabledRes {
   111  	return GetTLFForUpgradeDisabledRes{
   112  		Delay: o.Delay.DeepCopy(),
   113  	}
   114  }
   115  
   116  type GetTLFForUpgradeRes struct {
   117  	Typ__          GetTLFForUpgradeResType       `codec:"typ" json:"typ"`
   118  	Tlfavailable__ *GetTLFForUpgradeAvailableRes `codec:"tlfavailable,omitempty" json:"tlfavailable,omitempty"`
   119  	Delay__        *GetTLFForUpgradeDelayRes     `codec:"delay,omitempty" json:"delay,omitempty"`
   120  	Err__          *GetTLFForUpgradeErrRes       `codec:"err,omitempty" json:"err,omitempty"`
   121  	Disabled__     *GetTLFForUpgradeDisabledRes  `codec:"disabled,omitempty" json:"disabled,omitempty"`
   122  }
   123  
   124  func (o *GetTLFForUpgradeRes) Typ() (ret GetTLFForUpgradeResType, err error) {
   125  	switch o.Typ__ {
   126  	case GetTLFForUpgradeResType_TLFAVAILABLE:
   127  		if o.Tlfavailable__ == nil {
   128  			err = errors.New("unexpected nil value for Tlfavailable__")
   129  			return ret, err
   130  		}
   131  	case GetTLFForUpgradeResType_DELAY:
   132  		if o.Delay__ == nil {
   133  			err = errors.New("unexpected nil value for Delay__")
   134  			return ret, err
   135  		}
   136  	case GetTLFForUpgradeResType_ERR:
   137  		if o.Err__ == nil {
   138  			err = errors.New("unexpected nil value for Err__")
   139  			return ret, err
   140  		}
   141  	case GetTLFForUpgradeResType_DISABLED:
   142  		if o.Disabled__ == nil {
   143  			err = errors.New("unexpected nil value for Disabled__")
   144  			return ret, err
   145  		}
   146  	}
   147  	return o.Typ__, nil
   148  }
   149  
   150  func (o GetTLFForUpgradeRes) Tlfavailable() (res GetTLFForUpgradeAvailableRes) {
   151  	if o.Typ__ != GetTLFForUpgradeResType_TLFAVAILABLE {
   152  		panic("wrong case accessed")
   153  	}
   154  	if o.Tlfavailable__ == nil {
   155  		return
   156  	}
   157  	return *o.Tlfavailable__
   158  }
   159  
   160  func (o GetTLFForUpgradeRes) Delay() (res GetTLFForUpgradeDelayRes) {
   161  	if o.Typ__ != GetTLFForUpgradeResType_DELAY {
   162  		panic("wrong case accessed")
   163  	}
   164  	if o.Delay__ == nil {
   165  		return
   166  	}
   167  	return *o.Delay__
   168  }
   169  
   170  func (o GetTLFForUpgradeRes) Err() (res GetTLFForUpgradeErrRes) {
   171  	if o.Typ__ != GetTLFForUpgradeResType_ERR {
   172  		panic("wrong case accessed")
   173  	}
   174  	if o.Err__ == nil {
   175  		return
   176  	}
   177  	return *o.Err__
   178  }
   179  
   180  func (o GetTLFForUpgradeRes) Disabled() (res GetTLFForUpgradeDisabledRes) {
   181  	if o.Typ__ != GetTLFForUpgradeResType_DISABLED {
   182  		panic("wrong case accessed")
   183  	}
   184  	if o.Disabled__ == nil {
   185  		return
   186  	}
   187  	return *o.Disabled__
   188  }
   189  
   190  func NewGetTLFForUpgradeResWithTlfavailable(v GetTLFForUpgradeAvailableRes) GetTLFForUpgradeRes {
   191  	return GetTLFForUpgradeRes{
   192  		Typ__:          GetTLFForUpgradeResType_TLFAVAILABLE,
   193  		Tlfavailable__: &v,
   194  	}
   195  }
   196  
   197  func NewGetTLFForUpgradeResWithDelay(v GetTLFForUpgradeDelayRes) GetTLFForUpgradeRes {
   198  	return GetTLFForUpgradeRes{
   199  		Typ__:   GetTLFForUpgradeResType_DELAY,
   200  		Delay__: &v,
   201  	}
   202  }
   203  
   204  func NewGetTLFForUpgradeResWithErr(v GetTLFForUpgradeErrRes) GetTLFForUpgradeRes {
   205  	return GetTLFForUpgradeRes{
   206  		Typ__: GetTLFForUpgradeResType_ERR,
   207  		Err__: &v,
   208  	}
   209  }
   210  
   211  func NewGetTLFForUpgradeResWithDisabled(v GetTLFForUpgradeDisabledRes) GetTLFForUpgradeRes {
   212  	return GetTLFForUpgradeRes{
   213  		Typ__:      GetTLFForUpgradeResType_DISABLED,
   214  		Disabled__: &v,
   215  	}
   216  }
   217  
   218  func (o GetTLFForUpgradeRes) DeepCopy() GetTLFForUpgradeRes {
   219  	return GetTLFForUpgradeRes{
   220  		Typ__: o.Typ__.DeepCopy(),
   221  		Tlfavailable__: (func(x *GetTLFForUpgradeAvailableRes) *GetTLFForUpgradeAvailableRes {
   222  			if x == nil {
   223  				return nil
   224  			}
   225  			tmp := x.DeepCopy()
   226  			return &tmp
   227  		})(o.Tlfavailable__),
   228  		Delay__: (func(x *GetTLFForUpgradeDelayRes) *GetTLFForUpgradeDelayRes {
   229  			if x == nil {
   230  				return nil
   231  			}
   232  			tmp := x.DeepCopy()
   233  			return &tmp
   234  		})(o.Delay__),
   235  		Err__: (func(x *GetTLFForUpgradeErrRes) *GetTLFForUpgradeErrRes {
   236  			if x == nil {
   237  				return nil
   238  			}
   239  			tmp := x.DeepCopy()
   240  			return &tmp
   241  		})(o.Err__),
   242  		Disabled__: (func(x *GetTLFForUpgradeDisabledRes) *GetTLFForUpgradeDisabledRes {
   243  			if x == nil {
   244  				return nil
   245  			}
   246  			tmp := x.DeepCopy()
   247  			return &tmp
   248  		})(o.Disabled__),
   249  	}
   250  }