blob: d3d1bd6e60eb146086b0dbf3cb88328517f14d75 [file] [log] [blame]
Jiri Simsa67b8a262015-03-24 21:14:07 -07001// Copyright 2015 The Vanadium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style
3// license that can be found in the LICENSE file.
4
Suharsh Sivakumara4ac50a2015-03-13 16:13:50 -07005// This file was auto-generated by the vanadium vdl tool.
Ryan Brownfed691e2014-09-15 13:09:40 -07006// Source: wire.vdl
7
Todd Wang88509682015-04-10 10:28:24 -07008// Package agent defines an interface to keep a private key in memory, and for
9// clients to have access to the private key.
10//
11// Protocol
12//
13// The agent starts processes with the VEYRON_AGENT_FD set to one end of a
14// unix domain socket. To connect to the agent, a client should create
15// a unix domain socket pair. Then send one end of the socket to the agent
16// with 1 byte of data. The agent will then serve the Agent service on
17// the received socket, using SecurityNone.
18//
19// The agent also supports an optional mode where it can manage multiple principals.
20// Typically this is only used by Device Manager. In this mode, VEYRON_AGENT_FD
21// will be 3, and there will be another socket at fd 4.
22// Creating a new principal is similar to connecting to to agent: create a socket
23// pair and send one end on fd 4 with 1 byte of data.
24// Set the data to 1 to request the principal only be stored in memory.
25// The agent will create a new principal and respond with a principal handle on fd 4.
26// To connect using a previously created principal, create a socket pair and send
27// one end with the principal handle as data on fd 4. The agent will not send a
28// response on fd 4.
29// In either, you can use the normal process to connect to an agent over the
30// other end of the pair. Typically you would pass the other end to a child
31// process and set VEYRON_AGENT_FD so it knows to connect.
32//
33// The protocol also has limited support for caching: A client can
34// request notification when any other client modifies the principal so it
35// can flush the cache. See NotifyWhenChanged for details.
36package agent
Ryan Brownfed691e2014-09-15 13:09:40 -070037
38import (
Todd Wangb0d5dce2015-02-05 14:07:55 -080039 // VDL system imports
Ryan Brown81bcb3a2015-02-11 10:58:01 -080040 "io"
Jiri Simsa6ac95222015-02-23 16:11:49 -080041 "v.io/v23"
42 "v.io/v23/context"
Matt Rosencrantz94502cf2015-03-18 09:43:44 -070043 "v.io/v23/rpc"
Ryan Brown6a6768c2015-08-04 11:22:33 -070044 "v.io/v23/vdl"
Ryan Brownfed691e2014-09-15 13:09:40 -070045
Todd Wangb0d5dce2015-02-05 14:07:55 -080046 // VDL user imports
Jiri Simsa6ac95222015-02-23 16:11:49 -080047 "v.io/v23/security"
Ryan Brownfed691e2014-09-15 13:09:40 -070048)
49
Ryan Brown6a6768c2015-08-04 11:22:33 -070050type ConnInfo struct {
51 MinVersion int32
52 MaxVersion int32
53}
54
55func (ConnInfo) __VDLReflect(struct {
56 Name string `vdl:"v.io/x/ref/services/agent.ConnInfo"`
57}) {
58}
59
60type RpcRequest struct {
61 Id uint64
62 Method string
63 NumArgs uint32
64}
65
66func (RpcRequest) __VDLReflect(struct {
67 Name string `vdl:"v.io/x/ref/services/agent.RpcRequest"`
68}) {
69}
70
71type RpcResponse struct {
72 Id uint64
73 Err error
74 NumArgs uint32
75}
76
77func (RpcResponse) __VDLReflect(struct {
78 Name string `vdl:"v.io/x/ref/services/agent.RpcResponse"`
79}) {
80}
81
82type (
83 // RpcMessage represents any single field of the RpcMessage union type.
84 RpcMessage interface {
85 // Index returns the field index.
86 Index() int
87 // Interface returns the field value as an interface.
88 Interface() interface{}
89 // Name returns the field name.
90 Name() string
91 // __VDLReflect describes the RpcMessage union type.
92 __VDLReflect(__RpcMessageReflect)
93 }
94 // RpcMessageReq represents field Req of the RpcMessage union type.
95 RpcMessageReq struct{ Value RpcRequest }
96 // RpcMessageResp represents field Resp of the RpcMessage union type.
97 RpcMessageResp struct{ Value RpcResponse }
98 // __RpcMessageReflect describes the RpcMessage union type.
99 __RpcMessageReflect struct {
100 Name string `vdl:"v.io/x/ref/services/agent.RpcMessage"`
101 Type RpcMessage
102 Union struct {
103 Req RpcMessageReq
104 Resp RpcMessageResp
105 }
106 }
107)
108
109func (x RpcMessageReq) Index() int { return 0 }
110func (x RpcMessageReq) Interface() interface{} { return x.Value }
111func (x RpcMessageReq) Name() string { return "Req" }
112func (x RpcMessageReq) __VDLReflect(__RpcMessageReflect) {}
113
114func (x RpcMessageResp) Index() int { return 1 }
115func (x RpcMessageResp) Interface() interface{} { return x.Value }
116func (x RpcMessageResp) Name() string { return "Resp" }
117func (x RpcMessageResp) __VDLReflect(__RpcMessageReflect) {}
118
119func init() {
120 vdl.Register((*ConnInfo)(nil))
121 vdl.Register((*RpcRequest)(nil))
122 vdl.Register((*RpcResponse)(nil))
123 vdl.Register((*RpcMessage)(nil))
124}
125
Todd Wang702385a2014-11-07 01:54:08 -0800126// AgentClientMethods is the client interface
127// containing Agent methods.
128type AgentClientMethods interface {
Matt Rosencrantz94502cf2015-03-18 09:43:44 -0700129 Bless(ctx *context.T, key []byte, wit security.Blessings, extension string, caveat security.Caveat, additionalCaveats []security.Caveat, opts ...rpc.CallOpt) (security.Blessings, error)
130 BlessSelf(ctx *context.T, name string, caveats []security.Caveat, opts ...rpc.CallOpt) (security.Blessings, error)
131 Sign(ctx *context.T, message []byte, opts ...rpc.CallOpt) (security.Signature, error)
132 MintDischarge(ctx *context.T, forCaveat security.Caveat, caveatOnDischarge security.Caveat, additionalCaveatsOnDischarge []security.Caveat, opts ...rpc.CallOpt) (security.Discharge, error)
133 PublicKey(*context.T, ...rpc.CallOpt) ([]byte, error)
134 BlessingsByName(ctx *context.T, name security.BlessingPattern, opts ...rpc.CallOpt) ([]security.Blessings, error)
135 BlessingsInfo(ctx *context.T, blessings security.Blessings, opts ...rpc.CallOpt) (map[string][]security.Caveat, error)
136 AddToRoots(ctx *context.T, blessing security.Blessings, opts ...rpc.CallOpt) error
137 BlessingStoreSet(ctx *context.T, blessings security.Blessings, forPeers security.BlessingPattern, opts ...rpc.CallOpt) (security.Blessings, error)
138 BlessingStoreForPeer(ctx *context.T, peerBlessings []string, opts ...rpc.CallOpt) (security.Blessings, error)
139 BlessingStoreSetDefault(ctx *context.T, blessings security.Blessings, opts ...rpc.CallOpt) error
140 BlessingStoreDefault(*context.T, ...rpc.CallOpt) (security.Blessings, error)
141 BlessingStorePeerBlessings(*context.T, ...rpc.CallOpt) (map[security.BlessingPattern]security.Blessings, error)
142 BlessingStoreDebugString(*context.T, ...rpc.CallOpt) (string, error)
Suharsh Sivakumard7d4e222015-06-22 11:10:44 -0700143 BlessingStoreCacheDischarge(ctx *context.T, discharge security.Discharge, caveat security.Caveat, impetus security.DischargeImpetus, opts ...rpc.CallOpt) error
144 BlessingStoreClearDischarges(ctx *context.T, discharges []security.Discharge, opts ...rpc.CallOpt) error
145 BlessingStoreDischarge(ctx *context.T, caveat security.Caveat, impetus security.DischargeImpetus, opts ...rpc.CallOpt) (wd security.Discharge, err error)
Matt Rosencrantz94502cf2015-03-18 09:43:44 -0700146 BlessingRootsAdd(ctx *context.T, root []byte, pattern security.BlessingPattern, opts ...rpc.CallOpt) error
147 BlessingRootsRecognized(ctx *context.T, root []byte, blessing string, opts ...rpc.CallOpt) error
Ankur9e5b7722015-04-28 15:00:25 -0700148 BlessingRootsDump(*context.T, ...rpc.CallOpt) (map[security.BlessingPattern][][]byte, error)
Matt Rosencrantz94502cf2015-03-18 09:43:44 -0700149 BlessingRootsDebugString(*context.T, ...rpc.CallOpt) (string, error)
Ryan Brown81bcb3a2015-02-11 10:58:01 -0800150 // Clients using caching should call NotifyWhenChanged upon connecting to
151 // the server. The server will stream back values whenever the client should
152 // flush the cache. The streamed value is arbitrary, simply flush whenever
153 // recieving a new item.
Matt Rosencrantz94502cf2015-03-18 09:43:44 -0700154 NotifyWhenChanged(*context.T, ...rpc.CallOpt) (AgentNotifyWhenChangedClientCall, error)
Ryan Brownfed691e2014-09-15 13:09:40 -0700155}
156
Todd Wang702385a2014-11-07 01:54:08 -0800157// AgentClientStub adds universal methods to AgentClientMethods.
158type AgentClientStub interface {
159 AgentClientMethods
Matt Rosencrantz94502cf2015-03-18 09:43:44 -0700160 rpc.UniversalServiceMethods
Ryan Brownfed691e2014-09-15 13:09:40 -0700161}
162
Todd Wang702385a2014-11-07 01:54:08 -0800163// AgentClient returns a client stub for Agent.
Asim Shankar69fa69f2015-04-01 11:34:32 -0700164func AgentClient(name string) AgentClientStub {
165 return implAgentClientStub{name}
Ryan Brownfed691e2014-09-15 13:09:40 -0700166}
167
Todd Wang702385a2014-11-07 01:54:08 -0800168type implAgentClientStub struct {
Asim Shankar69fa69f2015-04-01 11:34:32 -0700169 name string
Todd Wang702385a2014-11-07 01:54:08 -0800170}
171
Matt Rosencrantz94502cf2015-03-18 09:43:44 -0700172func (c implAgentClientStub) Bless(ctx *context.T, i0 []byte, i1 security.Blessings, i2 string, i3 security.Caveat, i4 []security.Caveat, opts ...rpc.CallOpt) (o0 security.Blessings, err error) {
Suharsh Sivakumardf2672a2015-04-09 19:26:43 -0700173 err = v23.GetClient(ctx).Call(ctx, c.name, "Bless", []interface{}{i0, i1, i2, i3, i4}, []interface{}{&o0}, opts...)
Todd Wang702385a2014-11-07 01:54:08 -0800174 return
175}
176
Matt Rosencrantz94502cf2015-03-18 09:43:44 -0700177func (c implAgentClientStub) BlessSelf(ctx *context.T, i0 string, i1 []security.Caveat, opts ...rpc.CallOpt) (o0 security.Blessings, err error) {
Suharsh Sivakumardf2672a2015-04-09 19:26:43 -0700178 err = v23.GetClient(ctx).Call(ctx, c.name, "BlessSelf", []interface{}{i0, i1}, []interface{}{&o0}, opts...)
Todd Wang702385a2014-11-07 01:54:08 -0800179 return
180}
181
Matt Rosencrantz94502cf2015-03-18 09:43:44 -0700182func (c implAgentClientStub) Sign(ctx *context.T, i0 []byte, opts ...rpc.CallOpt) (o0 security.Signature, err error) {
Suharsh Sivakumardf2672a2015-04-09 19:26:43 -0700183 err = v23.GetClient(ctx).Call(ctx, c.name, "Sign", []interface{}{i0}, []interface{}{&o0}, opts...)
Todd Wang702385a2014-11-07 01:54:08 -0800184 return
185}
186
Matt Rosencrantz94502cf2015-03-18 09:43:44 -0700187func (c implAgentClientStub) MintDischarge(ctx *context.T, i0 security.Caveat, i1 security.Caveat, i2 []security.Caveat, opts ...rpc.CallOpt) (o0 security.Discharge, err error) {
Suharsh Sivakumardf2672a2015-04-09 19:26:43 -0700188 err = v23.GetClient(ctx).Call(ctx, c.name, "MintDischarge", []interface{}{i0, i1, i2}, []interface{}{&o0}, opts...)
Todd Wang702385a2014-11-07 01:54:08 -0800189 return
190}
191
Matt Rosencrantz94502cf2015-03-18 09:43:44 -0700192func (c implAgentClientStub) PublicKey(ctx *context.T, opts ...rpc.CallOpt) (o0 []byte, err error) {
Suharsh Sivakumardf2672a2015-04-09 19:26:43 -0700193 err = v23.GetClient(ctx).Call(ctx, c.name, "PublicKey", nil, []interface{}{&o0}, opts...)
Todd Wang702385a2014-11-07 01:54:08 -0800194 return
195}
196
Matt Rosencrantz94502cf2015-03-18 09:43:44 -0700197func (c implAgentClientStub) BlessingsByName(ctx *context.T, i0 security.BlessingPattern, opts ...rpc.CallOpt) (o0 []security.Blessings, err error) {
Suharsh Sivakumardf2672a2015-04-09 19:26:43 -0700198 err = v23.GetClient(ctx).Call(ctx, c.name, "BlessingsByName", []interface{}{i0}, []interface{}{&o0}, opts...)
gauthamtf8263932014-12-16 10:59:09 -0800199 return
200}
201
Matt Rosencrantz94502cf2015-03-18 09:43:44 -0700202func (c implAgentClientStub) BlessingsInfo(ctx *context.T, i0 security.Blessings, opts ...rpc.CallOpt) (o0 map[string][]security.Caveat, err error) {
Suharsh Sivakumardf2672a2015-04-09 19:26:43 -0700203 err = v23.GetClient(ctx).Call(ctx, c.name, "BlessingsInfo", []interface{}{i0}, []interface{}{&o0}, opts...)
gauthamtf8263932014-12-16 10:59:09 -0800204 return
205}
206
Matt Rosencrantz94502cf2015-03-18 09:43:44 -0700207func (c implAgentClientStub) AddToRoots(ctx *context.T, i0 security.Blessings, opts ...rpc.CallOpt) (err error) {
Suharsh Sivakumardf2672a2015-04-09 19:26:43 -0700208 err = v23.GetClient(ctx).Call(ctx, c.name, "AddToRoots", []interface{}{i0}, nil, opts...)
Todd Wang702385a2014-11-07 01:54:08 -0800209 return
210}
211
Matt Rosencrantz94502cf2015-03-18 09:43:44 -0700212func (c implAgentClientStub) BlessingStoreSet(ctx *context.T, i0 security.Blessings, i1 security.BlessingPattern, opts ...rpc.CallOpt) (o0 security.Blessings, err error) {
Suharsh Sivakumardf2672a2015-04-09 19:26:43 -0700213 err = v23.GetClient(ctx).Call(ctx, c.name, "BlessingStoreSet", []interface{}{i0, i1}, []interface{}{&o0}, opts...)
Todd Wang702385a2014-11-07 01:54:08 -0800214 return
215}
216
Matt Rosencrantz94502cf2015-03-18 09:43:44 -0700217func (c implAgentClientStub) BlessingStoreForPeer(ctx *context.T, i0 []string, opts ...rpc.CallOpt) (o0 security.Blessings, err error) {
Suharsh Sivakumardf2672a2015-04-09 19:26:43 -0700218 err = v23.GetClient(ctx).Call(ctx, c.name, "BlessingStoreForPeer", []interface{}{i0}, []interface{}{&o0}, opts...)
Todd Wang702385a2014-11-07 01:54:08 -0800219 return
220}
221
Matt Rosencrantz94502cf2015-03-18 09:43:44 -0700222func (c implAgentClientStub) BlessingStoreSetDefault(ctx *context.T, i0 security.Blessings, opts ...rpc.CallOpt) (err error) {
Suharsh Sivakumardf2672a2015-04-09 19:26:43 -0700223 err = v23.GetClient(ctx).Call(ctx, c.name, "BlessingStoreSetDefault", []interface{}{i0}, nil, opts...)
Todd Wang702385a2014-11-07 01:54:08 -0800224 return
225}
226
Matt Rosencrantz94502cf2015-03-18 09:43:44 -0700227func (c implAgentClientStub) BlessingStoreDefault(ctx *context.T, opts ...rpc.CallOpt) (o0 security.Blessings, err error) {
Suharsh Sivakumardf2672a2015-04-09 19:26:43 -0700228 err = v23.GetClient(ctx).Call(ctx, c.name, "BlessingStoreDefault", nil, []interface{}{&o0}, opts...)
Todd Wang702385a2014-11-07 01:54:08 -0800229 return
230}
231
Matt Rosencrantz94502cf2015-03-18 09:43:44 -0700232func (c implAgentClientStub) BlessingStorePeerBlessings(ctx *context.T, opts ...rpc.CallOpt) (o0 map[security.BlessingPattern]security.Blessings, err error) {
Suharsh Sivakumardf2672a2015-04-09 19:26:43 -0700233 err = v23.GetClient(ctx).Call(ctx, c.name, "BlessingStorePeerBlessings", nil, []interface{}{&o0}, opts...)
gauthamtf8263932014-12-16 10:59:09 -0800234 return
235}
236
Matt Rosencrantz94502cf2015-03-18 09:43:44 -0700237func (c implAgentClientStub) BlessingStoreDebugString(ctx *context.T, opts ...rpc.CallOpt) (o0 string, err error) {
Suharsh Sivakumardf2672a2015-04-09 19:26:43 -0700238 err = v23.GetClient(ctx).Call(ctx, c.name, "BlessingStoreDebugString", nil, []interface{}{&o0}, opts...)
Todd Wang702385a2014-11-07 01:54:08 -0800239 return
240}
241
Suharsh Sivakumard7d4e222015-06-22 11:10:44 -0700242func (c implAgentClientStub) BlessingStoreCacheDischarge(ctx *context.T, i0 security.Discharge, i1 security.Caveat, i2 security.DischargeImpetus, opts ...rpc.CallOpt) (err error) {
243 err = v23.GetClient(ctx).Call(ctx, c.name, "BlessingStoreCacheDischarge", []interface{}{i0, i1, i2}, nil, opts...)
244 return
245}
246
247func (c implAgentClientStub) BlessingStoreClearDischarges(ctx *context.T, i0 []security.Discharge, opts ...rpc.CallOpt) (err error) {
248 err = v23.GetClient(ctx).Call(ctx, c.name, "BlessingStoreClearDischarges", []interface{}{i0}, nil, opts...)
249 return
250}
251
252func (c implAgentClientStub) BlessingStoreDischarge(ctx *context.T, i0 security.Caveat, i1 security.DischargeImpetus, opts ...rpc.CallOpt) (o0 security.Discharge, err error) {
253 err = v23.GetClient(ctx).Call(ctx, c.name, "BlessingStoreDischarge", []interface{}{i0, i1}, []interface{}{&o0}, opts...)
254 return
255}
256
Matt Rosencrantz94502cf2015-03-18 09:43:44 -0700257func (c implAgentClientStub) BlessingRootsAdd(ctx *context.T, i0 []byte, i1 security.BlessingPattern, opts ...rpc.CallOpt) (err error) {
Suharsh Sivakumardf2672a2015-04-09 19:26:43 -0700258 err = v23.GetClient(ctx).Call(ctx, c.name, "BlessingRootsAdd", []interface{}{i0, i1}, nil, opts...)
Todd Wang702385a2014-11-07 01:54:08 -0800259 return
260}
261
Matt Rosencrantz94502cf2015-03-18 09:43:44 -0700262func (c implAgentClientStub) BlessingRootsRecognized(ctx *context.T, i0 []byte, i1 string, opts ...rpc.CallOpt) (err error) {
Suharsh Sivakumardf2672a2015-04-09 19:26:43 -0700263 err = v23.GetClient(ctx).Call(ctx, c.name, "BlessingRootsRecognized", []interface{}{i0, i1}, nil, opts...)
Todd Wang702385a2014-11-07 01:54:08 -0800264 return
265}
266
Ankur9e5b7722015-04-28 15:00:25 -0700267func (c implAgentClientStub) BlessingRootsDump(ctx *context.T, opts ...rpc.CallOpt) (o0 map[security.BlessingPattern][][]byte, err error) {
268 err = v23.GetClient(ctx).Call(ctx, c.name, "BlessingRootsDump", nil, []interface{}{&o0}, opts...)
269 return
270}
271
Matt Rosencrantz94502cf2015-03-18 09:43:44 -0700272func (c implAgentClientStub) BlessingRootsDebugString(ctx *context.T, opts ...rpc.CallOpt) (o0 string, err error) {
Suharsh Sivakumardf2672a2015-04-09 19:26:43 -0700273 err = v23.GetClient(ctx).Call(ctx, c.name, "BlessingRootsDebugString", nil, []interface{}{&o0}, opts...)
Todd Wang702385a2014-11-07 01:54:08 -0800274 return
275}
276
Matt Rosencrantz94502cf2015-03-18 09:43:44 -0700277func (c implAgentClientStub) NotifyWhenChanged(ctx *context.T, opts ...rpc.CallOpt) (ocall AgentNotifyWhenChangedClientCall, err error) {
278 var call rpc.ClientCall
Asim Shankar69fa69f2015-04-01 11:34:32 -0700279 if call, err = v23.GetClient(ctx).StartCall(ctx, c.name, "NotifyWhenChanged", nil, opts...); err != nil {
Ryan Brown81bcb3a2015-02-11 10:58:01 -0800280 return
281 }
Matt Rosencrantz5c7ed212015-02-27 22:42:35 -0800282 ocall = &implAgentNotifyWhenChangedClientCall{ClientCall: call}
Ryan Brown81bcb3a2015-02-11 10:58:01 -0800283 return
284}
285
286// AgentNotifyWhenChangedClientStream is the client stream for Agent.NotifyWhenChanged.
287type AgentNotifyWhenChangedClientStream interface {
288 // RecvStream returns the receiver side of the Agent.NotifyWhenChanged client stream.
289 RecvStream() interface {
290 // Advance stages an item so that it may be retrieved via Value. Returns
291 // true iff there is an item to retrieve. Advance must be called before
292 // Value is called. May block if an item is not available.
293 Advance() bool
294 // Value returns the item that was staged by Advance. May panic if Advance
295 // returned false or was not called. Never blocks.
296 Value() bool
297 // Err returns any error encountered by Advance. Never blocks.
298 Err() error
299 }
300}
301
Matt Rosencrantz5c7ed212015-02-27 22:42:35 -0800302// AgentNotifyWhenChangedClientCall represents the call returned from Agent.NotifyWhenChanged.
303type AgentNotifyWhenChangedClientCall interface {
Ryan Brown81bcb3a2015-02-11 10:58:01 -0800304 AgentNotifyWhenChangedClientStream
305 // Finish blocks until the server is done, and returns the positional return
306 // values for call.
307 //
308 // Finish returns immediately if the call has been canceled; depending on the
309 // timing the output could either be an error signaling cancelation, or the
310 // valid positional return values from the server.
311 //
312 // Calling Finish is mandatory for releasing stream resources, unless the call
313 // has been canceled or any of the other methods return an error. Finish should
314 // be called at most once.
315 Finish() error
316}
317
Matt Rosencrantz5c7ed212015-02-27 22:42:35 -0800318type implAgentNotifyWhenChangedClientCall struct {
Matt Rosencrantz94502cf2015-03-18 09:43:44 -0700319 rpc.ClientCall
Ryan Brown81bcb3a2015-02-11 10:58:01 -0800320 valRecv bool
321 errRecv error
322}
323
Matt Rosencrantz5c7ed212015-02-27 22:42:35 -0800324func (c *implAgentNotifyWhenChangedClientCall) RecvStream() interface {
Ryan Brown81bcb3a2015-02-11 10:58:01 -0800325 Advance() bool
326 Value() bool
327 Err() error
328} {
Suharsh Sivakumar31f49852015-03-03 16:13:20 -0800329 return implAgentNotifyWhenChangedClientCallRecv{c}
Ryan Brown81bcb3a2015-02-11 10:58:01 -0800330}
331
Suharsh Sivakumar31f49852015-03-03 16:13:20 -0800332type implAgentNotifyWhenChangedClientCallRecv struct {
Matt Rosencrantz5c7ed212015-02-27 22:42:35 -0800333 c *implAgentNotifyWhenChangedClientCall
Ryan Brown81bcb3a2015-02-11 10:58:01 -0800334}
335
Suharsh Sivakumar31f49852015-03-03 16:13:20 -0800336func (c implAgentNotifyWhenChangedClientCallRecv) Advance() bool {
Ryan Brown81bcb3a2015-02-11 10:58:01 -0800337 c.c.errRecv = c.c.Recv(&c.c.valRecv)
338 return c.c.errRecv == nil
339}
Suharsh Sivakumar31f49852015-03-03 16:13:20 -0800340func (c implAgentNotifyWhenChangedClientCallRecv) Value() bool {
Ryan Brown81bcb3a2015-02-11 10:58:01 -0800341 return c.c.valRecv
342}
Suharsh Sivakumar31f49852015-03-03 16:13:20 -0800343func (c implAgentNotifyWhenChangedClientCallRecv) Err() error {
Ryan Brown81bcb3a2015-02-11 10:58:01 -0800344 if c.c.errRecv == io.EOF {
345 return nil
346 }
347 return c.c.errRecv
348}
Matt Rosencrantz5c7ed212015-02-27 22:42:35 -0800349func (c *implAgentNotifyWhenChangedClientCall) Finish() (err error) {
350 err = c.ClientCall.Finish()
Ryan Brown81bcb3a2015-02-11 10:58:01 -0800351 return
352}
353
Todd Wang702385a2014-11-07 01:54:08 -0800354// AgentServerMethods is the interface a server writer
355// implements for Agent.
356type AgentServerMethods interface {
Todd Wang54feabe2015-04-15 23:38:26 -0700357 Bless(ctx *context.T, call rpc.ServerCall, key []byte, wit security.Blessings, extension string, caveat security.Caveat, additionalCaveats []security.Caveat) (security.Blessings, error)
358 BlessSelf(ctx *context.T, call rpc.ServerCall, name string, caveats []security.Caveat) (security.Blessings, error)
359 Sign(ctx *context.T, call rpc.ServerCall, message []byte) (security.Signature, error)
360 MintDischarge(ctx *context.T, call rpc.ServerCall, forCaveat security.Caveat, caveatOnDischarge security.Caveat, additionalCaveatsOnDischarge []security.Caveat) (security.Discharge, error)
361 PublicKey(*context.T, rpc.ServerCall) ([]byte, error)
362 BlessingsByName(ctx *context.T, call rpc.ServerCall, name security.BlessingPattern) ([]security.Blessings, error)
363 BlessingsInfo(ctx *context.T, call rpc.ServerCall, blessings security.Blessings) (map[string][]security.Caveat, error)
364 AddToRoots(ctx *context.T, call rpc.ServerCall, blessing security.Blessings) error
365 BlessingStoreSet(ctx *context.T, call rpc.ServerCall, blessings security.Blessings, forPeers security.BlessingPattern) (security.Blessings, error)
366 BlessingStoreForPeer(ctx *context.T, call rpc.ServerCall, peerBlessings []string) (security.Blessings, error)
367 BlessingStoreSetDefault(ctx *context.T, call rpc.ServerCall, blessings security.Blessings) error
368 BlessingStoreDefault(*context.T, rpc.ServerCall) (security.Blessings, error)
369 BlessingStorePeerBlessings(*context.T, rpc.ServerCall) (map[security.BlessingPattern]security.Blessings, error)
370 BlessingStoreDebugString(*context.T, rpc.ServerCall) (string, error)
Suharsh Sivakumard7d4e222015-06-22 11:10:44 -0700371 BlessingStoreCacheDischarge(ctx *context.T, call rpc.ServerCall, discharge security.Discharge, caveat security.Caveat, impetus security.DischargeImpetus) error
372 BlessingStoreClearDischarges(ctx *context.T, call rpc.ServerCall, discharges []security.Discharge) error
373 BlessingStoreDischarge(ctx *context.T, call rpc.ServerCall, caveat security.Caveat, impetus security.DischargeImpetus) (wd security.Discharge, err error)
Todd Wang54feabe2015-04-15 23:38:26 -0700374 BlessingRootsAdd(ctx *context.T, call rpc.ServerCall, root []byte, pattern security.BlessingPattern) error
375 BlessingRootsRecognized(ctx *context.T, call rpc.ServerCall, root []byte, blessing string) error
Ankur9e5b7722015-04-28 15:00:25 -0700376 BlessingRootsDump(*context.T, rpc.ServerCall) (map[security.BlessingPattern][][]byte, error)
Todd Wang54feabe2015-04-15 23:38:26 -0700377 BlessingRootsDebugString(*context.T, rpc.ServerCall) (string, error)
Ryan Brown81bcb3a2015-02-11 10:58:01 -0800378 // Clients using caching should call NotifyWhenChanged upon connecting to
379 // the server. The server will stream back values whenever the client should
380 // flush the cache. The streamed value is arbitrary, simply flush whenever
381 // recieving a new item.
Todd Wang54feabe2015-04-15 23:38:26 -0700382 NotifyWhenChanged(*context.T, AgentNotifyWhenChangedServerCall) error
Todd Wang702385a2014-11-07 01:54:08 -0800383}
384
385// AgentServerStubMethods is the server interface containing
Matt Rosencrantz94502cf2015-03-18 09:43:44 -0700386// Agent methods, as expected by rpc.Server.
Ryan Brown81bcb3a2015-02-11 10:58:01 -0800387// The only difference between this interface and AgentServerMethods
388// is the streaming methods.
389type AgentServerStubMethods interface {
Todd Wang54feabe2015-04-15 23:38:26 -0700390 Bless(ctx *context.T, call rpc.ServerCall, key []byte, wit security.Blessings, extension string, caveat security.Caveat, additionalCaveats []security.Caveat) (security.Blessings, error)
391 BlessSelf(ctx *context.T, call rpc.ServerCall, name string, caveats []security.Caveat) (security.Blessings, error)
392 Sign(ctx *context.T, call rpc.ServerCall, message []byte) (security.Signature, error)
393 MintDischarge(ctx *context.T, call rpc.ServerCall, forCaveat security.Caveat, caveatOnDischarge security.Caveat, additionalCaveatsOnDischarge []security.Caveat) (security.Discharge, error)
394 PublicKey(*context.T, rpc.ServerCall) ([]byte, error)
395 BlessingsByName(ctx *context.T, call rpc.ServerCall, name security.BlessingPattern) ([]security.Blessings, error)
396 BlessingsInfo(ctx *context.T, call rpc.ServerCall, blessings security.Blessings) (map[string][]security.Caveat, error)
397 AddToRoots(ctx *context.T, call rpc.ServerCall, blessing security.Blessings) error
398 BlessingStoreSet(ctx *context.T, call rpc.ServerCall, blessings security.Blessings, forPeers security.BlessingPattern) (security.Blessings, error)
399 BlessingStoreForPeer(ctx *context.T, call rpc.ServerCall, peerBlessings []string) (security.Blessings, error)
400 BlessingStoreSetDefault(ctx *context.T, call rpc.ServerCall, blessings security.Blessings) error
401 BlessingStoreDefault(*context.T, rpc.ServerCall) (security.Blessings, error)
402 BlessingStorePeerBlessings(*context.T, rpc.ServerCall) (map[security.BlessingPattern]security.Blessings, error)
403 BlessingStoreDebugString(*context.T, rpc.ServerCall) (string, error)
Suharsh Sivakumard7d4e222015-06-22 11:10:44 -0700404 BlessingStoreCacheDischarge(ctx *context.T, call rpc.ServerCall, discharge security.Discharge, caveat security.Caveat, impetus security.DischargeImpetus) error
405 BlessingStoreClearDischarges(ctx *context.T, call rpc.ServerCall, discharges []security.Discharge) error
406 BlessingStoreDischarge(ctx *context.T, call rpc.ServerCall, caveat security.Caveat, impetus security.DischargeImpetus) (wd security.Discharge, err error)
Todd Wang54feabe2015-04-15 23:38:26 -0700407 BlessingRootsAdd(ctx *context.T, call rpc.ServerCall, root []byte, pattern security.BlessingPattern) error
408 BlessingRootsRecognized(ctx *context.T, call rpc.ServerCall, root []byte, blessing string) error
Ankur9e5b7722015-04-28 15:00:25 -0700409 BlessingRootsDump(*context.T, rpc.ServerCall) (map[security.BlessingPattern][][]byte, error)
Todd Wang54feabe2015-04-15 23:38:26 -0700410 BlessingRootsDebugString(*context.T, rpc.ServerCall) (string, error)
Ryan Brown81bcb3a2015-02-11 10:58:01 -0800411 // Clients using caching should call NotifyWhenChanged upon connecting to
412 // the server. The server will stream back values whenever the client should
413 // flush the cache. The streamed value is arbitrary, simply flush whenever
414 // recieving a new item.
Todd Wang54feabe2015-04-15 23:38:26 -0700415 NotifyWhenChanged(*context.T, *AgentNotifyWhenChangedServerCallStub) error
Ryan Brown81bcb3a2015-02-11 10:58:01 -0800416}
Todd Wang702385a2014-11-07 01:54:08 -0800417
418// AgentServerStub adds universal methods to AgentServerStubMethods.
419type AgentServerStub interface {
420 AgentServerStubMethods
Todd Wang5739dda2014-11-16 22:44:02 -0800421 // Describe the Agent interfaces.
Matt Rosencrantz94502cf2015-03-18 09:43:44 -0700422 Describe__() []rpc.InterfaceDesc
Todd Wang702385a2014-11-07 01:54:08 -0800423}
424
425// AgentServer returns a server stub for Agent.
426// It converts an implementation of AgentServerMethods into
Matt Rosencrantz94502cf2015-03-18 09:43:44 -0700427// an object that may be used by rpc.Server.
Todd Wang702385a2014-11-07 01:54:08 -0800428func AgentServer(impl AgentServerMethods) AgentServerStub {
429 stub := implAgentServerStub{
430 impl: impl,
431 }
432 // Initialize GlobState; always check the stub itself first, to handle the
433 // case where the user has the Glob method defined in their VDL source.
Matt Rosencrantz94502cf2015-03-18 09:43:44 -0700434 if gs := rpc.NewGlobState(stub); gs != nil {
Todd Wang702385a2014-11-07 01:54:08 -0800435 stub.gs = gs
Matt Rosencrantz94502cf2015-03-18 09:43:44 -0700436 } else if gs := rpc.NewGlobState(impl); gs != nil {
Todd Wang702385a2014-11-07 01:54:08 -0800437 stub.gs = gs
438 }
Robin Thellend94bc4642014-11-05 18:05:08 -0800439 return stub
Ryan Brownfed691e2014-09-15 13:09:40 -0700440}
441
Todd Wang702385a2014-11-07 01:54:08 -0800442type implAgentServerStub struct {
443 impl AgentServerMethods
Matt Rosencrantz94502cf2015-03-18 09:43:44 -0700444 gs *rpc.GlobState
Ken Ashcrafte027b5c2014-09-16 14:20:20 -0700445}
446
Todd Wang54feabe2015-04-15 23:38:26 -0700447func (s implAgentServerStub) Bless(ctx *context.T, call rpc.ServerCall, i0 []byte, i1 security.Blessings, i2 string, i3 security.Caveat, i4 []security.Caveat) (security.Blessings, error) {
448 return s.impl.Bless(ctx, call, i0, i1, i2, i3, i4)
Ryan Brownfed691e2014-09-15 13:09:40 -0700449}
450
Todd Wang54feabe2015-04-15 23:38:26 -0700451func (s implAgentServerStub) BlessSelf(ctx *context.T, call rpc.ServerCall, i0 string, i1 []security.Caveat) (security.Blessings, error) {
452 return s.impl.BlessSelf(ctx, call, i0, i1)
Suharsh Sivakumar8a7fba42014-10-27 12:40:48 -0700453}
454
Todd Wang54feabe2015-04-15 23:38:26 -0700455func (s implAgentServerStub) Sign(ctx *context.T, call rpc.ServerCall, i0 []byte) (security.Signature, error) {
456 return s.impl.Sign(ctx, call, i0)
Suharsh Sivakumar8a7fba42014-10-27 12:40:48 -0700457}
458
Todd Wang54feabe2015-04-15 23:38:26 -0700459func (s implAgentServerStub) MintDischarge(ctx *context.T, call rpc.ServerCall, i0 security.Caveat, i1 security.Caveat, i2 []security.Caveat) (security.Discharge, error) {
460 return s.impl.MintDischarge(ctx, call, i0, i1, i2)
Ryan Brownfed691e2014-09-15 13:09:40 -0700461}
462
Todd Wang54feabe2015-04-15 23:38:26 -0700463func (s implAgentServerStub) PublicKey(ctx *context.T, call rpc.ServerCall) ([]byte, error) {
464 return s.impl.PublicKey(ctx, call)
Suharsh Sivakumar8a7fba42014-10-27 12:40:48 -0700465}
466
Todd Wang54feabe2015-04-15 23:38:26 -0700467func (s implAgentServerStub) BlessingsByName(ctx *context.T, call rpc.ServerCall, i0 security.BlessingPattern) ([]security.Blessings, error) {
468 return s.impl.BlessingsByName(ctx, call, i0)
gauthamtf8263932014-12-16 10:59:09 -0800469}
470
Todd Wang54feabe2015-04-15 23:38:26 -0700471func (s implAgentServerStub) BlessingsInfo(ctx *context.T, call rpc.ServerCall, i0 security.Blessings) (map[string][]security.Caveat, error) {
472 return s.impl.BlessingsInfo(ctx, call, i0)
gauthamtf8263932014-12-16 10:59:09 -0800473}
474
Todd Wang54feabe2015-04-15 23:38:26 -0700475func (s implAgentServerStub) AddToRoots(ctx *context.T, call rpc.ServerCall, i0 security.Blessings) error {
476 return s.impl.AddToRoots(ctx, call, i0)
Ryan Brownfed691e2014-09-15 13:09:40 -0700477}
478
Todd Wang54feabe2015-04-15 23:38:26 -0700479func (s implAgentServerStub) BlessingStoreSet(ctx *context.T, call rpc.ServerCall, i0 security.Blessings, i1 security.BlessingPattern) (security.Blessings, error) {
480 return s.impl.BlessingStoreSet(ctx, call, i0, i1)
Suharsh Sivakumar8a7fba42014-10-27 12:40:48 -0700481}
482
Todd Wang54feabe2015-04-15 23:38:26 -0700483func (s implAgentServerStub) BlessingStoreForPeer(ctx *context.T, call rpc.ServerCall, i0 []string) (security.Blessings, error) {
484 return s.impl.BlessingStoreForPeer(ctx, call, i0)
Suharsh Sivakumar8a7fba42014-10-27 12:40:48 -0700485}
486
Todd Wang54feabe2015-04-15 23:38:26 -0700487func (s implAgentServerStub) BlessingStoreSetDefault(ctx *context.T, call rpc.ServerCall, i0 security.Blessings) error {
488 return s.impl.BlessingStoreSetDefault(ctx, call, i0)
Suharsh Sivakumar8a7fba42014-10-27 12:40:48 -0700489}
490
Todd Wang54feabe2015-04-15 23:38:26 -0700491func (s implAgentServerStub) BlessingStoreDefault(ctx *context.T, call rpc.ServerCall) (security.Blessings, error) {
492 return s.impl.BlessingStoreDefault(ctx, call)
Suharsh Sivakumar8a7fba42014-10-27 12:40:48 -0700493}
494
Todd Wang54feabe2015-04-15 23:38:26 -0700495func (s implAgentServerStub) BlessingStorePeerBlessings(ctx *context.T, call rpc.ServerCall) (map[security.BlessingPattern]security.Blessings, error) {
496 return s.impl.BlessingStorePeerBlessings(ctx, call)
gauthamtf8263932014-12-16 10:59:09 -0800497}
498
Todd Wang54feabe2015-04-15 23:38:26 -0700499func (s implAgentServerStub) BlessingStoreDebugString(ctx *context.T, call rpc.ServerCall) (string, error) {
500 return s.impl.BlessingStoreDebugString(ctx, call)
Suharsh Sivakumar8a7fba42014-10-27 12:40:48 -0700501}
502
Suharsh Sivakumard7d4e222015-06-22 11:10:44 -0700503func (s implAgentServerStub) BlessingStoreCacheDischarge(ctx *context.T, call rpc.ServerCall, i0 security.Discharge, i1 security.Caveat, i2 security.DischargeImpetus) error {
504 return s.impl.BlessingStoreCacheDischarge(ctx, call, i0, i1, i2)
505}
506
507func (s implAgentServerStub) BlessingStoreClearDischarges(ctx *context.T, call rpc.ServerCall, i0 []security.Discharge) error {
508 return s.impl.BlessingStoreClearDischarges(ctx, call, i0)
509}
510
511func (s implAgentServerStub) BlessingStoreDischarge(ctx *context.T, call rpc.ServerCall, i0 security.Caveat, i1 security.DischargeImpetus) (security.Discharge, error) {
512 return s.impl.BlessingStoreDischarge(ctx, call, i0, i1)
513}
514
Todd Wang54feabe2015-04-15 23:38:26 -0700515func (s implAgentServerStub) BlessingRootsAdd(ctx *context.T, call rpc.ServerCall, i0 []byte, i1 security.BlessingPattern) error {
516 return s.impl.BlessingRootsAdd(ctx, call, i0, i1)
Suharsh Sivakumar8a7fba42014-10-27 12:40:48 -0700517}
518
Todd Wang54feabe2015-04-15 23:38:26 -0700519func (s implAgentServerStub) BlessingRootsRecognized(ctx *context.T, call rpc.ServerCall, i0 []byte, i1 string) error {
520 return s.impl.BlessingRootsRecognized(ctx, call, i0, i1)
Suharsh Sivakumar8a7fba42014-10-27 12:40:48 -0700521}
522
Ankur9e5b7722015-04-28 15:00:25 -0700523func (s implAgentServerStub) BlessingRootsDump(ctx *context.T, call rpc.ServerCall) (map[security.BlessingPattern][][]byte, error) {
524 return s.impl.BlessingRootsDump(ctx, call)
525}
526
Todd Wang54feabe2015-04-15 23:38:26 -0700527func (s implAgentServerStub) BlessingRootsDebugString(ctx *context.T, call rpc.ServerCall) (string, error) {
528 return s.impl.BlessingRootsDebugString(ctx, call)
Suharsh Sivakumar8a7fba42014-10-27 12:40:48 -0700529}
530
Todd Wang54feabe2015-04-15 23:38:26 -0700531func (s implAgentServerStub) NotifyWhenChanged(ctx *context.T, call *AgentNotifyWhenChangedServerCallStub) error {
532 return s.impl.NotifyWhenChanged(ctx, call)
Ryan Brown81bcb3a2015-02-11 10:58:01 -0800533}
534
Matt Rosencrantz94502cf2015-03-18 09:43:44 -0700535func (s implAgentServerStub) Globber() *rpc.GlobState {
Todd Wang702385a2014-11-07 01:54:08 -0800536 return s.gs
Suharsh Sivakumar8a7fba42014-10-27 12:40:48 -0700537}
538
Matt Rosencrantz94502cf2015-03-18 09:43:44 -0700539func (s implAgentServerStub) Describe__() []rpc.InterfaceDesc {
540 return []rpc.InterfaceDesc{AgentDesc}
Todd Wang5739dda2014-11-16 22:44:02 -0800541}
542
543// AgentDesc describes the Agent interface.
Matt Rosencrantz94502cf2015-03-18 09:43:44 -0700544var AgentDesc rpc.InterfaceDesc = descAgent
Todd Wang5739dda2014-11-16 22:44:02 -0800545
546// descAgent hides the desc to keep godoc clean.
Matt Rosencrantz94502cf2015-03-18 09:43:44 -0700547var descAgent = rpc.InterfaceDesc{
Todd Wang5739dda2014-11-16 22:44:02 -0800548 Name: "Agent",
Todd Wang88509682015-04-10 10:28:24 -0700549 PkgPath: "v.io/x/ref/services/agent",
Matt Rosencrantz94502cf2015-03-18 09:43:44 -0700550 Methods: []rpc.MethodDesc{
Todd Wang5739dda2014-11-16 22:44:02 -0800551 {
552 Name: "Bless",
Matt Rosencrantz94502cf2015-03-18 09:43:44 -0700553 InArgs: []rpc.ArgDesc{
Todd Wang5739dda2014-11-16 22:44:02 -0800554 {"key", ``}, // []byte
Asim Shankarb07ec692015-02-27 23:40:44 -0800555 {"wit", ``}, // security.Blessings
Todd Wang5739dda2014-11-16 22:44:02 -0800556 {"extension", ``}, // string
557 {"caveat", ``}, // security.Caveat
558 {"additionalCaveats", ``}, // []security.Caveat
559 },
Matt Rosencrantz94502cf2015-03-18 09:43:44 -0700560 OutArgs: []rpc.ArgDesc{
Asim Shankarb07ec692015-02-27 23:40:44 -0800561 {"", ``}, // security.Blessings
Todd Wang5739dda2014-11-16 22:44:02 -0800562 },
563 },
564 {
565 Name: "BlessSelf",
Matt Rosencrantz94502cf2015-03-18 09:43:44 -0700566 InArgs: []rpc.ArgDesc{
Todd Wang5739dda2014-11-16 22:44:02 -0800567 {"name", ``}, // string
568 {"caveats", ``}, // []security.Caveat
569 },
Matt Rosencrantz94502cf2015-03-18 09:43:44 -0700570 OutArgs: []rpc.ArgDesc{
Asim Shankarb07ec692015-02-27 23:40:44 -0800571 {"", ``}, // security.Blessings
Todd Wang5739dda2014-11-16 22:44:02 -0800572 },
573 },
574 {
575 Name: "Sign",
Matt Rosencrantz94502cf2015-03-18 09:43:44 -0700576 InArgs: []rpc.ArgDesc{
Todd Wang5739dda2014-11-16 22:44:02 -0800577 {"message", ``}, // []byte
578 },
Matt Rosencrantz94502cf2015-03-18 09:43:44 -0700579 OutArgs: []rpc.ArgDesc{
Todd Wang5739dda2014-11-16 22:44:02 -0800580 {"", ``}, // security.Signature
Todd Wang5739dda2014-11-16 22:44:02 -0800581 },
582 },
583 {
584 Name: "MintDischarge",
Matt Rosencrantz94502cf2015-03-18 09:43:44 -0700585 InArgs: []rpc.ArgDesc{
Asim Shankar19da8182015-02-06 01:41:16 -0800586 {"forCaveat", ``}, // security.Caveat
587 {"caveatOnDischarge", ``}, // security.Caveat
588 {"additionalCaveatsOnDischarge", ``}, // []security.Caveat
Todd Wang5739dda2014-11-16 22:44:02 -0800589 },
Matt Rosencrantz94502cf2015-03-18 09:43:44 -0700590 OutArgs: []rpc.ArgDesc{
Asim Shankar08642822015-03-02 21:21:09 -0800591 {"", ``}, // security.Discharge
Todd Wang5739dda2014-11-16 22:44:02 -0800592 },
593 },
594 {
595 Name: "PublicKey",
Matt Rosencrantz94502cf2015-03-18 09:43:44 -0700596 OutArgs: []rpc.ArgDesc{
Todd Wang5739dda2014-11-16 22:44:02 -0800597 {"", ``}, // []byte
Todd Wang5739dda2014-11-16 22:44:02 -0800598 },
599 },
600 {
gauthamtf8263932014-12-16 10:59:09 -0800601 Name: "BlessingsByName",
Matt Rosencrantz94502cf2015-03-18 09:43:44 -0700602 InArgs: []rpc.ArgDesc{
gauthamtf8263932014-12-16 10:59:09 -0800603 {"name", ``}, // security.BlessingPattern
604 },
Matt Rosencrantz94502cf2015-03-18 09:43:44 -0700605 OutArgs: []rpc.ArgDesc{
Asim Shankarb07ec692015-02-27 23:40:44 -0800606 {"", ``}, // []security.Blessings
gauthamtf8263932014-12-16 10:59:09 -0800607 },
608 },
609 {
610 Name: "BlessingsInfo",
Matt Rosencrantz94502cf2015-03-18 09:43:44 -0700611 InArgs: []rpc.ArgDesc{
Asim Shankarb07ec692015-02-27 23:40:44 -0800612 {"blessings", ``}, // security.Blessings
gauthamtf8263932014-12-16 10:59:09 -0800613 },
Matt Rosencrantz94502cf2015-03-18 09:43:44 -0700614 OutArgs: []rpc.ArgDesc{
gauthamt8dc9a182015-01-08 18:03:18 -0800615 {"", ``}, // map[string][]security.Caveat
gauthamtf8263932014-12-16 10:59:09 -0800616 },
617 },
618 {
Todd Wang5739dda2014-11-16 22:44:02 -0800619 Name: "AddToRoots",
Matt Rosencrantz94502cf2015-03-18 09:43:44 -0700620 InArgs: []rpc.ArgDesc{
Asim Shankarb07ec692015-02-27 23:40:44 -0800621 {"blessing", ``}, // security.Blessings
Todd Wang5739dda2014-11-16 22:44:02 -0800622 },
Todd Wang5739dda2014-11-16 22:44:02 -0800623 },
624 {
625 Name: "BlessingStoreSet",
Matt Rosencrantz94502cf2015-03-18 09:43:44 -0700626 InArgs: []rpc.ArgDesc{
Asim Shankarb07ec692015-02-27 23:40:44 -0800627 {"blessings", ``}, // security.Blessings
Todd Wang5739dda2014-11-16 22:44:02 -0800628 {"forPeers", ``}, // security.BlessingPattern
629 },
Matt Rosencrantz94502cf2015-03-18 09:43:44 -0700630 OutArgs: []rpc.ArgDesc{
Asim Shankarb07ec692015-02-27 23:40:44 -0800631 {"", ``}, // security.Blessings
Todd Wang5739dda2014-11-16 22:44:02 -0800632 },
633 },
634 {
635 Name: "BlessingStoreForPeer",
Matt Rosencrantz94502cf2015-03-18 09:43:44 -0700636 InArgs: []rpc.ArgDesc{
Todd Wang5739dda2014-11-16 22:44:02 -0800637 {"peerBlessings", ``}, // []string
638 },
Matt Rosencrantz94502cf2015-03-18 09:43:44 -0700639 OutArgs: []rpc.ArgDesc{
Asim Shankarb07ec692015-02-27 23:40:44 -0800640 {"", ``}, // security.Blessings
Todd Wang5739dda2014-11-16 22:44:02 -0800641 },
642 },
643 {
644 Name: "BlessingStoreSetDefault",
Matt Rosencrantz94502cf2015-03-18 09:43:44 -0700645 InArgs: []rpc.ArgDesc{
Asim Shankarb07ec692015-02-27 23:40:44 -0800646 {"blessings", ``}, // security.Blessings
Todd Wang5739dda2014-11-16 22:44:02 -0800647 },
Todd Wang5739dda2014-11-16 22:44:02 -0800648 },
649 {
650 Name: "BlessingStoreDefault",
Matt Rosencrantz94502cf2015-03-18 09:43:44 -0700651 OutArgs: []rpc.ArgDesc{
Asim Shankarb07ec692015-02-27 23:40:44 -0800652 {"", ``}, // security.Blessings
Todd Wang5739dda2014-11-16 22:44:02 -0800653 },
654 },
655 {
gauthamtf8263932014-12-16 10:59:09 -0800656 Name: "BlessingStorePeerBlessings",
Matt Rosencrantz94502cf2015-03-18 09:43:44 -0700657 OutArgs: []rpc.ArgDesc{
Asim Shankarb07ec692015-02-27 23:40:44 -0800658 {"", ``}, // map[security.BlessingPattern]security.Blessings
gauthamtf8263932014-12-16 10:59:09 -0800659 },
660 },
661 {
Todd Wang5739dda2014-11-16 22:44:02 -0800662 Name: "BlessingStoreDebugString",
Matt Rosencrantz94502cf2015-03-18 09:43:44 -0700663 OutArgs: []rpc.ArgDesc{
Todd Wang5739dda2014-11-16 22:44:02 -0800664 {"", ``}, // string
Todd Wang5739dda2014-11-16 22:44:02 -0800665 },
666 },
667 {
Suharsh Sivakumard7d4e222015-06-22 11:10:44 -0700668 Name: "BlessingStoreCacheDischarge",
669 InArgs: []rpc.ArgDesc{
670 {"discharge", ``}, // security.Discharge
671 {"caveat", ``}, // security.Caveat
672 {"impetus", ``}, // security.DischargeImpetus
673 },
674 },
675 {
676 Name: "BlessingStoreClearDischarges",
677 InArgs: []rpc.ArgDesc{
678 {"discharges", ``}, // []security.Discharge
679 },
680 },
681 {
682 Name: "BlessingStoreDischarge",
683 InArgs: []rpc.ArgDesc{
684 {"caveat", ``}, // security.Caveat
685 {"impetus", ``}, // security.DischargeImpetus
686 },
687 OutArgs: []rpc.ArgDesc{
688 {"wd", ``}, // security.Discharge
689 },
690 },
691 {
Todd Wang5739dda2014-11-16 22:44:02 -0800692 Name: "BlessingRootsAdd",
Matt Rosencrantz94502cf2015-03-18 09:43:44 -0700693 InArgs: []rpc.ArgDesc{
Todd Wang5739dda2014-11-16 22:44:02 -0800694 {"root", ``}, // []byte
695 {"pattern", ``}, // security.BlessingPattern
696 },
Todd Wang5739dda2014-11-16 22:44:02 -0800697 },
698 {
699 Name: "BlessingRootsRecognized",
Matt Rosencrantz94502cf2015-03-18 09:43:44 -0700700 InArgs: []rpc.ArgDesc{
Todd Wang5739dda2014-11-16 22:44:02 -0800701 {"root", ``}, // []byte
702 {"blessing", ``}, // string
703 },
Todd Wang5739dda2014-11-16 22:44:02 -0800704 },
705 {
Ankur9e5b7722015-04-28 15:00:25 -0700706 Name: "BlessingRootsDump",
707 OutArgs: []rpc.ArgDesc{
708 {"", ``}, // map[security.BlessingPattern][][]byte
709 },
710 },
711 {
Todd Wang5739dda2014-11-16 22:44:02 -0800712 Name: "BlessingRootsDebugString",
Matt Rosencrantz94502cf2015-03-18 09:43:44 -0700713 OutArgs: []rpc.ArgDesc{
Todd Wang5739dda2014-11-16 22:44:02 -0800714 {"", ``}, // string
Todd Wang5739dda2014-11-16 22:44:02 -0800715 },
716 },
Ryan Brown81bcb3a2015-02-11 10:58:01 -0800717 {
718 Name: "NotifyWhenChanged",
719 Doc: "// Clients using caching should call NotifyWhenChanged upon connecting to\n// the server. The server will stream back values whenever the client should\n// flush the cache. The streamed value is arbitrary, simply flush whenever\n// recieving a new item.",
Ryan Brown81bcb3a2015-02-11 10:58:01 -0800720 },
Todd Wang5739dda2014-11-16 22:44:02 -0800721 },
Ryan Brownfed691e2014-09-15 13:09:40 -0700722}
Ryan Brown81bcb3a2015-02-11 10:58:01 -0800723
724// AgentNotifyWhenChangedServerStream is the server stream for Agent.NotifyWhenChanged.
725type AgentNotifyWhenChangedServerStream interface {
726 // SendStream returns the send side of the Agent.NotifyWhenChanged server stream.
727 SendStream() interface {
728 // Send places the item onto the output stream. Returns errors encountered
729 // while sending. Blocks if there is no buffer space; will unblock when
730 // buffer space is available.
731 Send(item bool) error
732 }
733}
734
Suharsh Sivakumar31f49852015-03-03 16:13:20 -0800735// AgentNotifyWhenChangedServerCall represents the context passed to Agent.NotifyWhenChanged.
736type AgentNotifyWhenChangedServerCall interface {
Matt Rosencrantz94502cf2015-03-18 09:43:44 -0700737 rpc.ServerCall
Ryan Brown81bcb3a2015-02-11 10:58:01 -0800738 AgentNotifyWhenChangedServerStream
739}
740
Matt Rosencrantz94502cf2015-03-18 09:43:44 -0700741// AgentNotifyWhenChangedServerCallStub is a wrapper that converts rpc.StreamServerCall into
Suharsh Sivakumar31f49852015-03-03 16:13:20 -0800742// a typesafe stub that implements AgentNotifyWhenChangedServerCall.
743type AgentNotifyWhenChangedServerCallStub struct {
Matt Rosencrantz94502cf2015-03-18 09:43:44 -0700744 rpc.StreamServerCall
Ryan Brown81bcb3a2015-02-11 10:58:01 -0800745}
746
Matt Rosencrantz94502cf2015-03-18 09:43:44 -0700747// Init initializes AgentNotifyWhenChangedServerCallStub from rpc.StreamServerCall.
748func (s *AgentNotifyWhenChangedServerCallStub) Init(call rpc.StreamServerCall) {
Matt Rosencrantz1dcd0a92015-02-27 11:05:59 -0800749 s.StreamServerCall = call
Ryan Brown81bcb3a2015-02-11 10:58:01 -0800750}
751
752// SendStream returns the send side of the Agent.NotifyWhenChanged server stream.
Suharsh Sivakumar31f49852015-03-03 16:13:20 -0800753func (s *AgentNotifyWhenChangedServerCallStub) SendStream() interface {
Ryan Brown81bcb3a2015-02-11 10:58:01 -0800754 Send(item bool) error
755} {
Suharsh Sivakumar31f49852015-03-03 16:13:20 -0800756 return implAgentNotifyWhenChangedServerCallSend{s}
Ryan Brown81bcb3a2015-02-11 10:58:01 -0800757}
758
Suharsh Sivakumar31f49852015-03-03 16:13:20 -0800759type implAgentNotifyWhenChangedServerCallSend struct {
760 s *AgentNotifyWhenChangedServerCallStub
Ryan Brown81bcb3a2015-02-11 10:58:01 -0800761}
762
Suharsh Sivakumar31f49852015-03-03 16:13:20 -0800763func (s implAgentNotifyWhenChangedServerCallSend) Send(item bool) error {
Ryan Brown81bcb3a2015-02-11 10:58:01 -0800764 return s.s.Send(item)
765}