github.com/keybase/client/go@v0.0.0-20240309051027-028f7c731f8b/protocol/keybase1/audit.go (about)

     1  // Auto-generated to Go types and interfaces using avdl-compiler v1.4.10 (https://github.com/keybase/node-avdl-compiler)
     2  //   Input file: avdl/keybase1/audit.avdl
     3  
     4  package keybase1
     5  
     6  import (
     7  	"fmt"
     8  	"github.com/keybase/go-framed-msgpack-rpc/rpc"
     9  	context "golang.org/x/net/context"
    10  	"time"
    11  )
    12  
    13  type BoxAuditAttemptResult int
    14  
    15  const (
    16  	BoxAuditAttemptResult_FAILURE_RETRYABLE         BoxAuditAttemptResult = 0
    17  	BoxAuditAttemptResult_FAILURE_MALICIOUS_SERVER  BoxAuditAttemptResult = 1
    18  	BoxAuditAttemptResult_OK_VERIFIED               BoxAuditAttemptResult = 2
    19  	BoxAuditAttemptResult_OK_NOT_ATTEMPTED_ROLE     BoxAuditAttemptResult = 3
    20  	BoxAuditAttemptResult_OK_NOT_ATTEMPTED_OPENTEAM BoxAuditAttemptResult = 4
    21  	BoxAuditAttemptResult_OK_NOT_ATTEMPTED_SUBTEAM  BoxAuditAttemptResult = 5
    22  )
    23  
    24  func (o BoxAuditAttemptResult) DeepCopy() BoxAuditAttemptResult { return o }
    25  
    26  var BoxAuditAttemptResultMap = map[string]BoxAuditAttemptResult{
    27  	"FAILURE_RETRYABLE":         0,
    28  	"FAILURE_MALICIOUS_SERVER":  1,
    29  	"OK_VERIFIED":               2,
    30  	"OK_NOT_ATTEMPTED_ROLE":     3,
    31  	"OK_NOT_ATTEMPTED_OPENTEAM": 4,
    32  	"OK_NOT_ATTEMPTED_SUBTEAM":  5,
    33  }
    34  
    35  var BoxAuditAttemptResultRevMap = map[BoxAuditAttemptResult]string{
    36  	0: "FAILURE_RETRYABLE",
    37  	1: "FAILURE_MALICIOUS_SERVER",
    38  	2: "OK_VERIFIED",
    39  	3: "OK_NOT_ATTEMPTED_ROLE",
    40  	4: "OK_NOT_ATTEMPTED_OPENTEAM",
    41  	5: "OK_NOT_ATTEMPTED_SUBTEAM",
    42  }
    43  
    44  func (e BoxAuditAttemptResult) String() string {
    45  	if v, ok := BoxAuditAttemptResultRevMap[e]; ok {
    46  		return v
    47  	}
    48  	return fmt.Sprintf("%v", int(e))
    49  }
    50  
    51  type BoxAuditAttempt struct {
    52  	Ctime      UnixTime              `codec:"ctime" json:"ctime"`
    53  	Error      *string               `codec:"error,omitempty" json:"error,omitempty"`
    54  	Result     BoxAuditAttemptResult `codec:"result" json:"result"`
    55  	Generation *PerTeamKeyGeneration `codec:"generation,omitempty" json:"generation,omitempty"`
    56  	Rotated    bool                  `codec:"rotated" json:"rotated"`
    57  }
    58  
    59  func (o BoxAuditAttempt) DeepCopy() BoxAuditAttempt {
    60  	return BoxAuditAttempt{
    61  		Ctime: o.Ctime.DeepCopy(),
    62  		Error: (func(x *string) *string {
    63  			if x == nil {
    64  				return nil
    65  			}
    66  			tmp := (*x)
    67  			return &tmp
    68  		})(o.Error),
    69  		Result: o.Result.DeepCopy(),
    70  		Generation: (func(x *PerTeamKeyGeneration) *PerTeamKeyGeneration {
    71  			if x == nil {
    72  				return nil
    73  			}
    74  			tmp := (*x).DeepCopy()
    75  			return &tmp
    76  		})(o.Generation),
    77  		Rotated: o.Rotated,
    78  	}
    79  }
    80  
    81  type IsInJailArg struct {
    82  	SessionID int    `codec:"sessionID" json:"sessionID"`
    83  	TeamID    TeamID `codec:"teamID" json:"teamID"`
    84  }
    85  
    86  type BoxAuditTeamArg struct {
    87  	SessionID int    `codec:"sessionID" json:"sessionID"`
    88  	TeamID    TeamID `codec:"teamID" json:"teamID"`
    89  }
    90  
    91  type AttemptBoxAuditArg struct {
    92  	SessionID         int    `codec:"sessionID" json:"sessionID"`
    93  	TeamID            TeamID `codec:"teamID" json:"teamID"`
    94  	RotateBeforeAudit bool   `codec:"rotateBeforeAudit" json:"rotateBeforeAudit"`
    95  }
    96  
    97  type KnownTeamIDsArg struct {
    98  	SessionID int `codec:"sessionID" json:"sessionID"`
    99  }
   100  
   101  type AuditInterface interface {
   102  	IsInJail(context.Context, IsInJailArg) (bool, error)
   103  	BoxAuditTeam(context.Context, BoxAuditTeamArg) (*BoxAuditAttempt, error)
   104  	AttemptBoxAudit(context.Context, AttemptBoxAuditArg) (BoxAuditAttempt, error)
   105  	KnownTeamIDs(context.Context, int) ([]TeamID, error)
   106  }
   107  
   108  func AuditProtocol(i AuditInterface) rpc.Protocol {
   109  	return rpc.Protocol{
   110  		Name: "keybase.1.audit",
   111  		Methods: map[string]rpc.ServeHandlerDescription{
   112  			"isInJail": {
   113  				MakeArg: func() interface{} {
   114  					var ret [1]IsInJailArg
   115  					return &ret
   116  				},
   117  				Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) {
   118  					typedArgs, ok := args.(*[1]IsInJailArg)
   119  					if !ok {
   120  						err = rpc.NewTypeError((*[1]IsInJailArg)(nil), args)
   121  						return
   122  					}
   123  					ret, err = i.IsInJail(ctx, typedArgs[0])
   124  					return
   125  				},
   126  			},
   127  			"boxAuditTeam": {
   128  				MakeArg: func() interface{} {
   129  					var ret [1]BoxAuditTeamArg
   130  					return &ret
   131  				},
   132  				Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) {
   133  					typedArgs, ok := args.(*[1]BoxAuditTeamArg)
   134  					if !ok {
   135  						err = rpc.NewTypeError((*[1]BoxAuditTeamArg)(nil), args)
   136  						return
   137  					}
   138  					ret, err = i.BoxAuditTeam(ctx, typedArgs[0])
   139  					return
   140  				},
   141  			},
   142  			"attemptBoxAudit": {
   143  				MakeArg: func() interface{} {
   144  					var ret [1]AttemptBoxAuditArg
   145  					return &ret
   146  				},
   147  				Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) {
   148  					typedArgs, ok := args.(*[1]AttemptBoxAuditArg)
   149  					if !ok {
   150  						err = rpc.NewTypeError((*[1]AttemptBoxAuditArg)(nil), args)
   151  						return
   152  					}
   153  					ret, err = i.AttemptBoxAudit(ctx, typedArgs[0])
   154  					return
   155  				},
   156  			},
   157  			"knownTeamIDs": {
   158  				MakeArg: func() interface{} {
   159  					var ret [1]KnownTeamIDsArg
   160  					return &ret
   161  				},
   162  				Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) {
   163  					typedArgs, ok := args.(*[1]KnownTeamIDsArg)
   164  					if !ok {
   165  						err = rpc.NewTypeError((*[1]KnownTeamIDsArg)(nil), args)
   166  						return
   167  					}
   168  					ret, err = i.KnownTeamIDs(ctx, typedArgs[0].SessionID)
   169  					return
   170  				},
   171  			},
   172  		},
   173  	}
   174  }
   175  
   176  type AuditClient struct {
   177  	Cli rpc.GenericClient
   178  }
   179  
   180  func (c AuditClient) IsInJail(ctx context.Context, __arg IsInJailArg) (res bool, err error) {
   181  	err = c.Cli.Call(ctx, "keybase.1.audit.isInJail", []interface{}{__arg}, &res, 0*time.Millisecond)
   182  	return
   183  }
   184  
   185  func (c AuditClient) BoxAuditTeam(ctx context.Context, __arg BoxAuditTeamArg) (res *BoxAuditAttempt, err error) {
   186  	err = c.Cli.Call(ctx, "keybase.1.audit.boxAuditTeam", []interface{}{__arg}, &res, 0*time.Millisecond)
   187  	return
   188  }
   189  
   190  func (c AuditClient) AttemptBoxAudit(ctx context.Context, __arg AttemptBoxAuditArg) (res BoxAuditAttempt, err error) {
   191  	err = c.Cli.Call(ctx, "keybase.1.audit.attemptBoxAudit", []interface{}{__arg}, &res, 0*time.Millisecond)
   192  	return
   193  }
   194  
   195  func (c AuditClient) KnownTeamIDs(ctx context.Context, sessionID int) (res []TeamID, err error) {
   196  	__arg := KnownTeamIDsArg{SessionID: sessionID}
   197  	err = c.Cli.Call(ctx, "keybase.1.audit.knownTeamIDs", []interface{}{__arg}, &res, 0*time.Millisecond)
   198  	return
   199  }