blob: 2f10e488c1933087cd6440d51f1cc7e6e3045d4c [file] [log] [blame]
Jiri Simsaddbfebb2014-06-20 15:56:06 -07001// This file was auto-generated by the veyron vdl tool.
2// Source: repository.vdl
3
4// Package repository contains implementation of the interface for
5// storing and serving various veyron management objects.
6package repository
7
8import (
Jiri Simsa764efb72014-12-25 20:57:03 -08009 "v.io/core/veyron/services/mgmt/profile"
Jiri Simsaddbfebb2014-06-20 15:56:06 -070010
Jiri Simsa764efb72014-12-25 20:57:03 -080011 "v.io/core/veyron2/services/mgmt/application"
Jiri Simsaddbfebb2014-06-20 15:56:06 -070012
Jiri Simsa764efb72014-12-25 20:57:03 -080013 "v.io/core/veyron2/services/mgmt/repository"
Jiri Simsaddbfebb2014-06-20 15:56:06 -070014
Jiri Simsa764efb72014-12-25 20:57:03 -080015 "v.io/core/veyron2/services/security/access"
Asim Shankar68885192014-11-26 12:48:35 -080016
Todd Wang702385a2014-11-07 01:54:08 -080017 // The non-user imports are prefixed with "__" to prevent collisions.
Jiri Simsa764efb72014-12-25 20:57:03 -080018 __veyron2 "v.io/core/veyron2"
19 __context "v.io/core/veyron2/context"
20 __ipc "v.io/core/veyron2/ipc"
21 __vdlutil "v.io/core/veyron2/vdl/vdlutil"
22 __wiretype "v.io/core/veyron2/wiretype"
Jiri Simsaddbfebb2014-06-20 15:56:06 -070023)
24
Jing Jin896d7762014-11-03 11:18:52 -080025// TODO(toddw): Remove this line once the new signature support is done.
Todd Wang702385a2014-11-07 01:54:08 -080026// It corrects a bug where __wiretype is unused in VDL pacakges where only
Jing Jin896d7762014-11-03 11:18:52 -080027// bootstrap types are used on interfaces.
Todd Wang702385a2014-11-07 01:54:08 -080028const _ = __wiretype.TypeIDInvalid
Shyam Jayaramanc4aed6e2014-07-22 14:25:06 -070029
Todd Wang702385a2014-11-07 01:54:08 -080030// ApplicationClientMethods is the client interface
31// containing Application methods.
32//
Jiri Simsaddbfebb2014-06-20 15:56:06 -070033// Application describes an application repository internally. Besides
34// the public Application interface, it allows to add and remove
35// application envelopes.
Todd Wang702385a2014-11-07 01:54:08 -080036type ApplicationClientMethods interface {
Jiri Simsaddbfebb2014-06-20 15:56:06 -070037 // Application provides access to application envelopes. An
38 // application envelope is identified by an application name and an
Bogdan Capritad9281a32014-07-02 14:40:39 -070039 // application version, which are specified through the object name,
Jiri Simsaddbfebb2014-06-20 15:56:06 -070040 // and a profile name, which is specified using a method argument.
41 //
42 // Example:
43 // /apps/search/v1.Match([]string{"base", "media"})
44 // returns an application envelope that can be used for downloading
45 // and executing the "search" application, version "v1", runnable
46 // on either the "base" or "media" profile.
Todd Wang702385a2014-11-07 01:54:08 -080047 repository.ApplicationClientMethods
Jiri Simsaddbfebb2014-06-20 15:56:06 -070048 // Put adds the given tuple of application version (specified
Bogdan Capritad9281a32014-07-02 14:40:39 -070049 // through the object name suffix) and application envelope to all
Jiri Simsaddbfebb2014-06-20 15:56:06 -070050 // of the given application profiles.
Matt Rosencrantz4f8ac602014-12-29 14:42:48 -080051 Put(ctx *__context.T, Profiles []string, Envelope application.Envelope, opts ...__ipc.CallOpt) error
Jiri Simsaddbfebb2014-06-20 15:56:06 -070052 // Remove removes the application envelope for the given profile
Bogdan Capritad9281a32014-07-02 14:40:39 -070053 // name and application version (specified through the object name
Jiri Simsaddbfebb2014-06-20 15:56:06 -070054 // suffix). If no version is specified as part of the suffix, the
55 // method removes all versions for the given profile.
56 //
57 // TODO(jsimsa): Add support for using "*" to specify all profiles
58 // when Matt implements Globing (or Ken implements querying).
Matt Rosencrantz4f8ac602014-12-29 14:42:48 -080059 Remove(ctx *__context.T, Profile string, opts ...__ipc.CallOpt) error
Jiri Simsaddbfebb2014-06-20 15:56:06 -070060}
61
Todd Wang702385a2014-11-07 01:54:08 -080062// ApplicationClientStub adds universal methods to ApplicationClientMethods.
63type ApplicationClientStub interface {
64 ApplicationClientMethods
65 __ipc.UniversalServiceMethods
Jiri Simsaddbfebb2014-06-20 15:56:06 -070066}
67
Todd Wang702385a2014-11-07 01:54:08 -080068// ApplicationClient returns a client stub for Application.
69func ApplicationClient(name string, opts ...__ipc.BindOpt) ApplicationClientStub {
70 var client __ipc.Client
71 for _, opt := range opts {
72 if clientOpt, ok := opt.(__ipc.Client); ok {
Matt Rosencrantzbf85d542014-08-22 13:31:14 -070073 client = clientOpt
Jiri Simsaddbfebb2014-06-20 15:56:06 -070074 }
Jiri Simsaddbfebb2014-06-20 15:56:06 -070075 }
Todd Wang702385a2014-11-07 01:54:08 -080076 return implApplicationClientStub{name, client, repository.ApplicationClient(name, client)}
Jiri Simsaddbfebb2014-06-20 15:56:06 -070077}
78
Todd Wang702385a2014-11-07 01:54:08 -080079type implApplicationClientStub struct {
80 name string
81 client __ipc.Client
82
83 repository.ApplicationClientStub
84}
85
Matt Rosencrantz4f8ac602014-12-29 14:42:48 -080086func (c implApplicationClientStub) c(ctx *__context.T) __ipc.Client {
Todd Wang702385a2014-11-07 01:54:08 -080087 if c.client != nil {
88 return c.client
89 }
90 return __veyron2.RuntimeFromContext(ctx).Client()
91}
92
Matt Rosencrantz4f8ac602014-12-29 14:42:48 -080093func (c implApplicationClientStub) Put(ctx *__context.T, i0 []string, i1 application.Envelope, opts ...__ipc.CallOpt) (err error) {
Todd Wang702385a2014-11-07 01:54:08 -080094 var call __ipc.Call
95 if call, err = c.c(ctx).StartCall(ctx, c.name, "Put", []interface{}{i0, i1}, opts...); err != nil {
96 return
97 }
98 if ierr := call.Finish(&err); ierr != nil {
99 err = ierr
100 }
101 return
102}
103
Matt Rosencrantz4f8ac602014-12-29 14:42:48 -0800104func (c implApplicationClientStub) Remove(ctx *__context.T, i0 string, opts ...__ipc.CallOpt) (err error) {
Todd Wang702385a2014-11-07 01:54:08 -0800105 var call __ipc.Call
106 if call, err = c.c(ctx).StartCall(ctx, c.name, "Remove", []interface{}{i0}, opts...); err != nil {
107 return
108 }
109 if ierr := call.Finish(&err); ierr != nil {
110 err = ierr
111 }
112 return
113}
114
Matt Rosencrantz4f8ac602014-12-29 14:42:48 -0800115func (c implApplicationClientStub) Signature(ctx *__context.T, opts ...__ipc.CallOpt) (o0 __ipc.ServiceSignature, err error) {
Todd Wang702385a2014-11-07 01:54:08 -0800116 var call __ipc.Call
117 if call, err = c.c(ctx).StartCall(ctx, c.name, "Signature", nil, opts...); err != nil {
118 return
119 }
120 if ierr := call.Finish(&o0, &err); ierr != nil {
121 err = ierr
122 }
123 return
124}
125
Todd Wang702385a2014-11-07 01:54:08 -0800126// ApplicationServerMethods is the interface a server writer
127// implements for Application.
Jiri Simsaddbfebb2014-06-20 15:56:06 -0700128//
Todd Wang702385a2014-11-07 01:54:08 -0800129// Application describes an application repository internally. Besides
130// the public Application interface, it allows to add and remove
131// application envelopes.
132type ApplicationServerMethods interface {
133 // Application provides access to application envelopes. An
134 // application envelope is identified by an application name and an
135 // application version, which are specified through the object name,
136 // and a profile name, which is specified using a method argument.
137 //
138 // Example:
139 // /apps/search/v1.Match([]string{"base", "media"})
140 // returns an application envelope that can be used for downloading
141 // and executing the "search" application, version "v1", runnable
142 // on either the "base" or "media" profile.
143 repository.ApplicationServerMethods
144 // Put adds the given tuple of application version (specified
145 // through the object name suffix) and application envelope to all
146 // of the given application profiles.
147 Put(ctx __ipc.ServerContext, Profiles []string, Envelope application.Envelope) error
148 // Remove removes the application envelope for the given profile
149 // name and application version (specified through the object name
150 // suffix). If no version is specified as part of the suffix, the
151 // method removes all versions for the given profile.
152 //
153 // TODO(jsimsa): Add support for using "*" to specify all profiles
154 // when Matt implements Globing (or Ken implements querying).
155 Remove(ctx __ipc.ServerContext, Profile string) error
156}
157
158// ApplicationServerStubMethods is the server interface containing
Todd Wang1fe7cdd2014-11-12 12:51:49 -0800159// Application methods, as expected by ipc.Server.
160// There is no difference between this interface and ApplicationServerMethods
161// since there are no streaming methods.
162type ApplicationServerStubMethods ApplicationServerMethods
Todd Wang702385a2014-11-07 01:54:08 -0800163
164// ApplicationServerStub adds universal methods to ApplicationServerStubMethods.
165type ApplicationServerStub interface {
166 ApplicationServerStubMethods
Todd Wang5739dda2014-11-16 22:44:02 -0800167 // Describe the Application interfaces.
168 Describe__() []__ipc.InterfaceDesc
169 // Signature will be replaced with Describe__.
Todd Wang1fe7cdd2014-11-12 12:51:49 -0800170 Signature(ctx __ipc.ServerContext) (__ipc.ServiceSignature, error)
Todd Wang702385a2014-11-07 01:54:08 -0800171}
172
173// ApplicationServer returns a server stub for Application.
174// It converts an implementation of ApplicationServerMethods into
175// an object that may be used by ipc.Server.
176func ApplicationServer(impl ApplicationServerMethods) ApplicationServerStub {
177 stub := implApplicationServerStub{
178 impl: impl,
179 ApplicationServerStub: repository.ApplicationServer(impl),
Jiri Simsaddbfebb2014-06-20 15:56:06 -0700180 }
Todd Wang702385a2014-11-07 01:54:08 -0800181 // Initialize GlobState; always check the stub itself first, to handle the
182 // case where the user has the Glob method defined in their VDL source.
183 if gs := __ipc.NewGlobState(stub); gs != nil {
184 stub.gs = gs
185 } else if gs := __ipc.NewGlobState(impl); gs != nil {
186 stub.gs = gs
Robin Thellend94bc4642014-11-05 18:05:08 -0800187 }
Robin Thellend94bc4642014-11-05 18:05:08 -0800188 return stub
Jiri Simsaddbfebb2014-06-20 15:56:06 -0700189}
190
Todd Wang702385a2014-11-07 01:54:08 -0800191type implApplicationServerStub struct {
192 impl ApplicationServerMethods
Todd Wang702385a2014-11-07 01:54:08 -0800193 repository.ApplicationServerStub
Todd Wang1fe7cdd2014-11-12 12:51:49 -0800194 gs *__ipc.GlobState
Matt Rosencrantzbf85d542014-08-22 13:31:14 -0700195}
196
Todd Wang1fe7cdd2014-11-12 12:51:49 -0800197func (s implApplicationServerStub) Put(ctx __ipc.ServerContext, i0 []string, i1 application.Envelope) error {
198 return s.impl.Put(ctx, i0, i1)
Jiri Simsaddbfebb2014-06-20 15:56:06 -0700199}
200
Todd Wang1fe7cdd2014-11-12 12:51:49 -0800201func (s implApplicationServerStub) Remove(ctx __ipc.ServerContext, i0 string) error {
202 return s.impl.Remove(ctx, i0)
Jiri Simsaddbfebb2014-06-20 15:56:06 -0700203}
204
Robin Thellend39ac3232014-12-02 09:50:41 -0800205func (s implApplicationServerStub) Globber() *__ipc.GlobState {
Todd Wang702385a2014-11-07 01:54:08 -0800206 return s.gs
Jiri Simsaddbfebb2014-06-20 15:56:06 -0700207}
208
Todd Wang5739dda2014-11-16 22:44:02 -0800209func (s implApplicationServerStub) Describe__() []__ipc.InterfaceDesc {
210 return []__ipc.InterfaceDesc{ApplicationDesc, repository.ApplicationDesc}
211}
212
213// ApplicationDesc describes the Application interface.
214var ApplicationDesc __ipc.InterfaceDesc = descApplication
215
216// descApplication hides the desc to keep godoc clean.
217var descApplication = __ipc.InterfaceDesc{
218 Name: "Application",
Jiri Simsa764efb72014-12-25 20:57:03 -0800219 PkgPath: "v.io/core/veyron/services/mgmt/repository",
Todd Wang5739dda2014-11-16 22:44:02 -0800220 Doc: "// Application describes an application repository internally. Besides\n// the public Application interface, it allows to add and remove\n// application envelopes.",
221 Embeds: []__ipc.EmbedDesc{
Jiri Simsa764efb72014-12-25 20:57:03 -0800222 {"Application", "v.io/core/veyron2/services/mgmt/repository", "// Application provides access to application envelopes. An\n// application envelope is identified by an application name and an\n// application version, which are specified through the object name,\n// and a profile name, which is specified using a method argument.\n//\n// Example:\n// /apps/search/v1.Match([]string{\"base\", \"media\"})\n// returns an application envelope that can be used for downloading\n// and executing the \"search\" application, version \"v1\", runnable\n// on either the \"base\" or \"media\" profile."},
Todd Wang5739dda2014-11-16 22:44:02 -0800223 },
224 Methods: []__ipc.MethodDesc{
225 {
226 Name: "Put",
227 Doc: "// Put adds the given tuple of application version (specified\n// through the object name suffix) and application envelope to all\n// of the given application profiles.",
228 InArgs: []__ipc.ArgDesc{
229 {"Profiles", ``}, // []string
230 {"Envelope", ``}, // application.Envelope
231 },
232 OutArgs: []__ipc.ArgDesc{
233 {"", ``}, // error
234 },
Asim Shankar68885192014-11-26 12:48:35 -0800235 Tags: []__vdlutil.Any{access.Tag("Write")},
Todd Wang5739dda2014-11-16 22:44:02 -0800236 },
237 {
238 Name: "Remove",
239 Doc: "// Remove removes the application envelope for the given profile\n// name and application version (specified through the object name\n// suffix). If no version is specified as part of the suffix, the\n// method removes all versions for the given profile.\n//\n// TODO(jsimsa): Add support for using \"*\" to specify all profiles\n// when Matt implements Globing (or Ken implements querying).",
240 InArgs: []__ipc.ArgDesc{
241 {"Profile", ``}, // string
242 },
243 OutArgs: []__ipc.ArgDesc{
244 {"", ``}, // error
245 },
Asim Shankar68885192014-11-26 12:48:35 -0800246 Tags: []__vdlutil.Any{access.Tag("Write")},
Todd Wang5739dda2014-11-16 22:44:02 -0800247 },
248 },
Jiri Simsaddbfebb2014-06-20 15:56:06 -0700249}
250
Todd Wang1fe7cdd2014-11-12 12:51:49 -0800251func (s implApplicationServerStub) Signature(ctx __ipc.ServerContext) (__ipc.ServiceSignature, error) {
Todd Wang5739dda2014-11-16 22:44:02 -0800252 // TODO(toddw): Replace with new Describe__ implementation.
Todd Wang702385a2014-11-07 01:54:08 -0800253 result := __ipc.ServiceSignature{Methods: make(map[string]__ipc.MethodSignature)}
254 result.Methods["Put"] = __ipc.MethodSignature{
255 InArgs: []__ipc.MethodArgument{
Jiri Simsaddbfebb2014-06-20 15:56:06 -0700256 {Name: "Profiles", Type: 61},
Robin Thellend64178ed2014-11-20 13:16:22 -0800257 {Name: "Envelope", Type: 66},
Jiri Simsaddbfebb2014-06-20 15:56:06 -0700258 },
Todd Wang702385a2014-11-07 01:54:08 -0800259 OutArgs: []__ipc.MethodArgument{
Robin Thellend64178ed2014-11-20 13:16:22 -0800260 {Name: "", Type: 67},
Jiri Simsaddbfebb2014-06-20 15:56:06 -0700261 },
262 }
Todd Wang702385a2014-11-07 01:54:08 -0800263 result.Methods["Remove"] = __ipc.MethodSignature{
264 InArgs: []__ipc.MethodArgument{
Jiri Simsaddbfebb2014-06-20 15:56:06 -0700265 {Name: "Profile", Type: 3},
266 },
Todd Wang702385a2014-11-07 01:54:08 -0800267 OutArgs: []__ipc.MethodArgument{
Robin Thellend64178ed2014-11-20 13:16:22 -0800268 {Name: "", Type: 67},
Jiri Simsaddbfebb2014-06-20 15:56:06 -0700269 },
270 }
271
Todd Wang702385a2014-11-07 01:54:08 -0800272 result.TypeDefs = []__vdlutil.Any{
Robin Thellend64178ed2014-11-20 13:16:22 -0800273 __wiretype.MapType{Key: 0x3, Elem: 0x3, Name: "", Tags: []string(nil)}, __wiretype.StructType{
Todd Wang702385a2014-11-07 01:54:08 -0800274 []__wiretype.FieldType{
275 __wiretype.FieldType{Type: 0x3, Name: "Title"},
276 __wiretype.FieldType{Type: 0x3d, Name: "Args"},
277 __wiretype.FieldType{Type: 0x3, Name: "Binary"},
278 __wiretype.FieldType{Type: 0x3d, Name: "Env"},
Robin Thellend64178ed2014-11-20 13:16:22 -0800279 __wiretype.FieldType{Type: 0x41, Name: "Packages"},
Jiri Simsaddbfebb2014-06-20 15:56:06 -0700280 },
Jiri Simsa764efb72014-12-25 20:57:03 -0800281 "v.io/core/veyron2/services/mgmt/application.Envelope", []string(nil)},
Todd Wang702385a2014-11-07 01:54:08 -0800282 __wiretype.NamedPrimitiveType{Type: 0x1, Name: "error", Tags: []string(nil)}}
283 var ss __ipc.ServiceSignature
Jiri Simsaddbfebb2014-06-20 15:56:06 -0700284 var firstAdded int
Todd Wang1fe7cdd2014-11-12 12:51:49 -0800285 ss, _ = s.ApplicationServerStub.Signature(ctx)
Jiri Simsaddbfebb2014-06-20 15:56:06 -0700286 firstAdded = len(result.TypeDefs)
287 for k, v := range ss.Methods {
288 for i, _ := range v.InArgs {
Todd Wang702385a2014-11-07 01:54:08 -0800289 if v.InArgs[i].Type >= __wiretype.TypeIDFirst {
290 v.InArgs[i].Type += __wiretype.TypeID(firstAdded)
Jiri Simsaddbfebb2014-06-20 15:56:06 -0700291 }
292 }
293 for i, _ := range v.OutArgs {
Todd Wang702385a2014-11-07 01:54:08 -0800294 if v.OutArgs[i].Type >= __wiretype.TypeIDFirst {
295 v.OutArgs[i].Type += __wiretype.TypeID(firstAdded)
Jiri Simsaddbfebb2014-06-20 15:56:06 -0700296 }
297 }
Todd Wang702385a2014-11-07 01:54:08 -0800298 if v.InStream >= __wiretype.TypeIDFirst {
299 v.InStream += __wiretype.TypeID(firstAdded)
Jiri Simsaddbfebb2014-06-20 15:56:06 -0700300 }
Todd Wang702385a2014-11-07 01:54:08 -0800301 if v.OutStream >= __wiretype.TypeIDFirst {
302 v.OutStream += __wiretype.TypeID(firstAdded)
Jiri Simsaddbfebb2014-06-20 15:56:06 -0700303 }
304 result.Methods[k] = v
305 }
306 //TODO(bprosnitz) combine type definitions from embeded interfaces in a way that doesn't cause duplication.
307 for _, d := range ss.TypeDefs {
308 switch wt := d.(type) {
Todd Wang702385a2014-11-07 01:54:08 -0800309 case __wiretype.SliceType:
310 if wt.Elem >= __wiretype.TypeIDFirst {
311 wt.Elem += __wiretype.TypeID(firstAdded)
Jiri Simsaddbfebb2014-06-20 15:56:06 -0700312 }
313 d = wt
Todd Wang702385a2014-11-07 01:54:08 -0800314 case __wiretype.ArrayType:
315 if wt.Elem >= __wiretype.TypeIDFirst {
316 wt.Elem += __wiretype.TypeID(firstAdded)
Jiri Simsaddbfebb2014-06-20 15:56:06 -0700317 }
318 d = wt
Todd Wang702385a2014-11-07 01:54:08 -0800319 case __wiretype.MapType:
320 if wt.Key >= __wiretype.TypeIDFirst {
321 wt.Key += __wiretype.TypeID(firstAdded)
Jiri Simsaddbfebb2014-06-20 15:56:06 -0700322 }
Todd Wang702385a2014-11-07 01:54:08 -0800323 if wt.Elem >= __wiretype.TypeIDFirst {
324 wt.Elem += __wiretype.TypeID(firstAdded)
Jiri Simsaddbfebb2014-06-20 15:56:06 -0700325 }
326 d = wt
Todd Wang702385a2014-11-07 01:54:08 -0800327 case __wiretype.StructType:
Jiri Simsaddbfebb2014-06-20 15:56:06 -0700328 for i, fld := range wt.Fields {
Todd Wang702385a2014-11-07 01:54:08 -0800329 if fld.Type >= __wiretype.TypeIDFirst {
330 wt.Fields[i].Type += __wiretype.TypeID(firstAdded)
Jiri Simsaddbfebb2014-06-20 15:56:06 -0700331 }
332 }
333 d = wt
334 // NOTE: other types are missing, but we are upgrading anyways.
335 }
336 result.TypeDefs = append(result.TypeDefs, d)
337 }
338
339 return result, nil
340}
341
Todd Wang702385a2014-11-07 01:54:08 -0800342// ProfileClientMethods is the client interface
343// containing Profile methods.
344//
Jiri Simsaddbfebb2014-06-20 15:56:06 -0700345// Profile describes a profile internally. Besides the public Profile
346// interface, it allows to add and remove profile specifications.
Todd Wang702385a2014-11-07 01:54:08 -0800347type ProfileClientMethods interface {
Jiri Simsaddbfebb2014-06-20 15:56:06 -0700348 // Profile abstracts a device's ability to run binaries, and hides
349 // specifics such as the operating system, hardware architecture, and
350 // the set of installed libraries. Profiles describe binaries and
351 // devices, and are used to match them.
Todd Wang702385a2014-11-07 01:54:08 -0800352 repository.ProfileClientMethods
Jiri Simsaddbfebb2014-06-20 15:56:06 -0700353 // Specification returns the profile specification for the profile
Bogdan Capritad9281a32014-07-02 14:40:39 -0700354 // identified through the object name suffix.
Matt Rosencrantz4f8ac602014-12-29 14:42:48 -0800355 Specification(*__context.T, ...__ipc.CallOpt) (profile.Specification, error)
Jiri Simsaddbfebb2014-06-20 15:56:06 -0700356 // Put sets the profile specification for the profile identified
Bogdan Capritad9281a32014-07-02 14:40:39 -0700357 // through the object name suffix.
Matt Rosencrantz4f8ac602014-12-29 14:42:48 -0800358 Put(ctx *__context.T, Specification profile.Specification, opts ...__ipc.CallOpt) error
Jiri Simsaddbfebb2014-06-20 15:56:06 -0700359 // Remove removes the profile specification for the profile
Bogdan Capritad9281a32014-07-02 14:40:39 -0700360 // identified through the object name suffix.
Matt Rosencrantz4f8ac602014-12-29 14:42:48 -0800361 Remove(*__context.T, ...__ipc.CallOpt) error
Jiri Simsaddbfebb2014-06-20 15:56:06 -0700362}
363
Todd Wang702385a2014-11-07 01:54:08 -0800364// ProfileClientStub adds universal methods to ProfileClientMethods.
365type ProfileClientStub interface {
366 ProfileClientMethods
367 __ipc.UniversalServiceMethods
Jiri Simsaddbfebb2014-06-20 15:56:06 -0700368}
369
Todd Wang702385a2014-11-07 01:54:08 -0800370// ProfileClient returns a client stub for Profile.
371func ProfileClient(name string, opts ...__ipc.BindOpt) ProfileClientStub {
372 var client __ipc.Client
373 for _, opt := range opts {
374 if clientOpt, ok := opt.(__ipc.Client); ok {
Matt Rosencrantzbf85d542014-08-22 13:31:14 -0700375 client = clientOpt
Jiri Simsaddbfebb2014-06-20 15:56:06 -0700376 }
Jiri Simsaddbfebb2014-06-20 15:56:06 -0700377 }
Todd Wang702385a2014-11-07 01:54:08 -0800378 return implProfileClientStub{name, client, repository.ProfileClient(name, client)}
Jiri Simsaddbfebb2014-06-20 15:56:06 -0700379}
380
Todd Wang702385a2014-11-07 01:54:08 -0800381type implProfileClientStub struct {
382 name string
383 client __ipc.Client
384
385 repository.ProfileClientStub
386}
387
Matt Rosencrantz4f8ac602014-12-29 14:42:48 -0800388func (c implProfileClientStub) c(ctx *__context.T) __ipc.Client {
Todd Wang702385a2014-11-07 01:54:08 -0800389 if c.client != nil {
390 return c.client
391 }
392 return __veyron2.RuntimeFromContext(ctx).Client()
393}
394
Matt Rosencrantz4f8ac602014-12-29 14:42:48 -0800395func (c implProfileClientStub) Specification(ctx *__context.T, opts ...__ipc.CallOpt) (o0 profile.Specification, err error) {
Todd Wang702385a2014-11-07 01:54:08 -0800396 var call __ipc.Call
397 if call, err = c.c(ctx).StartCall(ctx, c.name, "Specification", nil, opts...); err != nil {
398 return
399 }
400 if ierr := call.Finish(&o0, &err); ierr != nil {
401 err = ierr
402 }
403 return
404}
405
Matt Rosencrantz4f8ac602014-12-29 14:42:48 -0800406func (c implProfileClientStub) Put(ctx *__context.T, i0 profile.Specification, opts ...__ipc.CallOpt) (err error) {
Todd Wang702385a2014-11-07 01:54:08 -0800407 var call __ipc.Call
408 if call, err = c.c(ctx).StartCall(ctx, c.name, "Put", []interface{}{i0}, opts...); err != nil {
409 return
410 }
411 if ierr := call.Finish(&err); ierr != nil {
412 err = ierr
413 }
414 return
415}
416
Matt Rosencrantz4f8ac602014-12-29 14:42:48 -0800417func (c implProfileClientStub) Remove(ctx *__context.T, opts ...__ipc.CallOpt) (err error) {
Todd Wang702385a2014-11-07 01:54:08 -0800418 var call __ipc.Call
419 if call, err = c.c(ctx).StartCall(ctx, c.name, "Remove", nil, opts...); err != nil {
420 return
421 }
422 if ierr := call.Finish(&err); ierr != nil {
423 err = ierr
424 }
425 return
426}
427
Matt Rosencrantz4f8ac602014-12-29 14:42:48 -0800428func (c implProfileClientStub) Signature(ctx *__context.T, opts ...__ipc.CallOpt) (o0 __ipc.ServiceSignature, err error) {
Todd Wang702385a2014-11-07 01:54:08 -0800429 var call __ipc.Call
430 if call, err = c.c(ctx).StartCall(ctx, c.name, "Signature", nil, opts...); err != nil {
431 return
432 }
433 if ierr := call.Finish(&o0, &err); ierr != nil {
434 err = ierr
435 }
436 return
437}
438
Todd Wang702385a2014-11-07 01:54:08 -0800439// ProfileServerMethods is the interface a server writer
440// implements for Profile.
Jiri Simsaddbfebb2014-06-20 15:56:06 -0700441//
Todd Wang702385a2014-11-07 01:54:08 -0800442// Profile describes a profile internally. Besides the public Profile
443// interface, it allows to add and remove profile specifications.
444type ProfileServerMethods interface {
445 // Profile abstracts a device's ability to run binaries, and hides
446 // specifics such as the operating system, hardware architecture, and
447 // the set of installed libraries. Profiles describe binaries and
448 // devices, and are used to match them.
449 repository.ProfileServerMethods
450 // Specification returns the profile specification for the profile
451 // identified through the object name suffix.
452 Specification(__ipc.ServerContext) (profile.Specification, error)
453 // Put sets the profile specification for the profile identified
454 // through the object name suffix.
455 Put(ctx __ipc.ServerContext, Specification profile.Specification) error
456 // Remove removes the profile specification for the profile
457 // identified through the object name suffix.
458 Remove(__ipc.ServerContext) error
459}
460
461// ProfileServerStubMethods is the server interface containing
Todd Wang1fe7cdd2014-11-12 12:51:49 -0800462// Profile methods, as expected by ipc.Server.
463// There is no difference between this interface and ProfileServerMethods
464// since there are no streaming methods.
465type ProfileServerStubMethods ProfileServerMethods
Todd Wang702385a2014-11-07 01:54:08 -0800466
467// ProfileServerStub adds universal methods to ProfileServerStubMethods.
468type ProfileServerStub interface {
469 ProfileServerStubMethods
Todd Wang5739dda2014-11-16 22:44:02 -0800470 // Describe the Profile interfaces.
471 Describe__() []__ipc.InterfaceDesc
472 // Signature will be replaced with Describe__.
Todd Wang1fe7cdd2014-11-12 12:51:49 -0800473 Signature(ctx __ipc.ServerContext) (__ipc.ServiceSignature, error)
Todd Wang702385a2014-11-07 01:54:08 -0800474}
475
476// ProfileServer returns a server stub for Profile.
477// It converts an implementation of ProfileServerMethods into
478// an object that may be used by ipc.Server.
479func ProfileServer(impl ProfileServerMethods) ProfileServerStub {
480 stub := implProfileServerStub{
481 impl: impl,
482 ProfileServerStub: repository.ProfileServer(impl),
Jiri Simsaddbfebb2014-06-20 15:56:06 -0700483 }
Todd Wang702385a2014-11-07 01:54:08 -0800484 // Initialize GlobState; always check the stub itself first, to handle the
485 // case where the user has the Glob method defined in their VDL source.
486 if gs := __ipc.NewGlobState(stub); gs != nil {
487 stub.gs = gs
488 } else if gs := __ipc.NewGlobState(impl); gs != nil {
489 stub.gs = gs
Robin Thellend94bc4642014-11-05 18:05:08 -0800490 }
Robin Thellend94bc4642014-11-05 18:05:08 -0800491 return stub
Jiri Simsaddbfebb2014-06-20 15:56:06 -0700492}
493
Todd Wang702385a2014-11-07 01:54:08 -0800494type implProfileServerStub struct {
495 impl ProfileServerMethods
Todd Wang702385a2014-11-07 01:54:08 -0800496 repository.ProfileServerStub
Todd Wang1fe7cdd2014-11-12 12:51:49 -0800497 gs *__ipc.GlobState
Matt Rosencrantzbf85d542014-08-22 13:31:14 -0700498}
499
Todd Wang1fe7cdd2014-11-12 12:51:49 -0800500func (s implProfileServerStub) Specification(ctx __ipc.ServerContext) (profile.Specification, error) {
501 return s.impl.Specification(ctx)
Jiri Simsaddbfebb2014-06-20 15:56:06 -0700502}
503
Todd Wang1fe7cdd2014-11-12 12:51:49 -0800504func (s implProfileServerStub) Put(ctx __ipc.ServerContext, i0 profile.Specification) error {
505 return s.impl.Put(ctx, i0)
Jiri Simsaddbfebb2014-06-20 15:56:06 -0700506}
507
Todd Wang1fe7cdd2014-11-12 12:51:49 -0800508func (s implProfileServerStub) Remove(ctx __ipc.ServerContext) error {
509 return s.impl.Remove(ctx)
Jiri Simsaddbfebb2014-06-20 15:56:06 -0700510}
511
Robin Thellend39ac3232014-12-02 09:50:41 -0800512func (s implProfileServerStub) Globber() *__ipc.GlobState {
Todd Wang702385a2014-11-07 01:54:08 -0800513 return s.gs
Jiri Simsaddbfebb2014-06-20 15:56:06 -0700514}
515
Todd Wang5739dda2014-11-16 22:44:02 -0800516func (s implProfileServerStub) Describe__() []__ipc.InterfaceDesc {
517 return []__ipc.InterfaceDesc{ProfileDesc, repository.ProfileDesc}
518}
519
520// ProfileDesc describes the Profile interface.
521var ProfileDesc __ipc.InterfaceDesc = descProfile
522
523// descProfile hides the desc to keep godoc clean.
524var descProfile = __ipc.InterfaceDesc{
525 Name: "Profile",
Jiri Simsa764efb72014-12-25 20:57:03 -0800526 PkgPath: "v.io/core/veyron/services/mgmt/repository",
Todd Wang5739dda2014-11-16 22:44:02 -0800527 Doc: "// Profile describes a profile internally. Besides the public Profile\n// interface, it allows to add and remove profile specifications.",
528 Embeds: []__ipc.EmbedDesc{
Jiri Simsa764efb72014-12-25 20:57:03 -0800529 {"Profile", "v.io/core/veyron2/services/mgmt/repository", "// Profile abstracts a device's ability to run binaries, and hides\n// specifics such as the operating system, hardware architecture, and\n// the set of installed libraries. Profiles describe binaries and\n// devices, and are used to match them."},
Todd Wang5739dda2014-11-16 22:44:02 -0800530 },
531 Methods: []__ipc.MethodDesc{
532 {
533 Name: "Specification",
534 Doc: "// Specification returns the profile specification for the profile\n// identified through the object name suffix.",
535 OutArgs: []__ipc.ArgDesc{
536 {"", ``}, // profile.Specification
537 {"", ``}, // error
538 },
Asim Shankar68885192014-11-26 12:48:35 -0800539 Tags: []__vdlutil.Any{access.Tag("Read")},
Todd Wang5739dda2014-11-16 22:44:02 -0800540 },
541 {
542 Name: "Put",
543 Doc: "// Put sets the profile specification for the profile identified\n// through the object name suffix.",
544 InArgs: []__ipc.ArgDesc{
545 {"Specification", ``}, // profile.Specification
546 },
547 OutArgs: []__ipc.ArgDesc{
548 {"", ``}, // error
549 },
Asim Shankar68885192014-11-26 12:48:35 -0800550 Tags: []__vdlutil.Any{access.Tag("Write")},
Todd Wang5739dda2014-11-16 22:44:02 -0800551 },
552 {
553 Name: "Remove",
554 Doc: "// Remove removes the profile specification for the profile\n// identified through the object name suffix.",
555 OutArgs: []__ipc.ArgDesc{
556 {"", ``}, // error
557 },
Asim Shankar68885192014-11-26 12:48:35 -0800558 Tags: []__vdlutil.Any{access.Tag("Write")},
Todd Wang5739dda2014-11-16 22:44:02 -0800559 },
560 },
Jiri Simsaddbfebb2014-06-20 15:56:06 -0700561}
562
Todd Wang1fe7cdd2014-11-12 12:51:49 -0800563func (s implProfileServerStub) Signature(ctx __ipc.ServerContext) (__ipc.ServiceSignature, error) {
Todd Wang5739dda2014-11-16 22:44:02 -0800564 // TODO(toddw): Replace with new Describe__ implementation.
Todd Wang702385a2014-11-07 01:54:08 -0800565 result := __ipc.ServiceSignature{Methods: make(map[string]__ipc.MethodSignature)}
566 result.Methods["Put"] = __ipc.MethodSignature{
567 InArgs: []__ipc.MethodArgument{
Jiri Simsa2f8bc272014-07-16 12:29:15 -0700568 {Name: "Specification", Type: 70},
Jiri Simsaddbfebb2014-06-20 15:56:06 -0700569 },
Todd Wang702385a2014-11-07 01:54:08 -0800570 OutArgs: []__ipc.MethodArgument{
Jiri Simsa2f8bc272014-07-16 12:29:15 -0700571 {Name: "", Type: 71},
Jiri Simsaddbfebb2014-06-20 15:56:06 -0700572 },
573 }
Todd Wang702385a2014-11-07 01:54:08 -0800574 result.Methods["Remove"] = __ipc.MethodSignature{
575 InArgs: []__ipc.MethodArgument{},
576 OutArgs: []__ipc.MethodArgument{
Jiri Simsa2f8bc272014-07-16 12:29:15 -0700577 {Name: "", Type: 71},
Jiri Simsaddbfebb2014-06-20 15:56:06 -0700578 },
579 }
Todd Wang702385a2014-11-07 01:54:08 -0800580 result.Methods["Specification"] = __ipc.MethodSignature{
581 InArgs: []__ipc.MethodArgument{},
582 OutArgs: []__ipc.MethodArgument{
Jiri Simsaddbfebb2014-06-20 15:56:06 -0700583 {Name: "", Type: 70},
Jiri Simsa2f8bc272014-07-16 12:29:15 -0700584 {Name: "", Type: 71},
Jiri Simsaddbfebb2014-06-20 15:56:06 -0700585 },
586 }
587
Todd Wang702385a2014-11-07 01:54:08 -0800588 result.TypeDefs = []__vdlutil.Any{
Jiri Simsa764efb72014-12-25 20:57:03 -0800589 __wiretype.NamedPrimitiveType{Type: 0x3, Name: "v.io/core/veyron2/services/mgmt/build.Architecture", Tags: []string(nil)}, __wiretype.NamedPrimitiveType{Type: 0x3, Name: "v.io/core/veyron2/services/mgmt/build.Format", Tags: []string(nil)}, __wiretype.StructType{
Todd Wang702385a2014-11-07 01:54:08 -0800590 []__wiretype.FieldType{
591 __wiretype.FieldType{Type: 0x3, Name: "Name"},
592 __wiretype.FieldType{Type: 0x3, Name: "MajorVersion"},
593 __wiretype.FieldType{Type: 0x3, Name: "MinorVersion"},
Jiri Simsaddbfebb2014-06-20 15:56:06 -0700594 },
Jiri Simsa764efb72014-12-25 20:57:03 -0800595 "v.io/core/veyron/services/mgmt/profile.Library", []string(nil)},
596 __wiretype.MapType{Key: 0x43, Elem: 0x2, Name: "", Tags: []string(nil)}, __wiretype.NamedPrimitiveType{Type: 0x3, Name: "v.io/core/veyron2/services/mgmt/build.OperatingSystem", Tags: []string(nil)}, __wiretype.StructType{
Todd Wang702385a2014-11-07 01:54:08 -0800597 []__wiretype.FieldType{
598 __wiretype.FieldType{Type: 0x41, Name: "Arch"},
599 __wiretype.FieldType{Type: 0x3, Name: "Description"},
600 __wiretype.FieldType{Type: 0x42, Name: "Format"},
601 __wiretype.FieldType{Type: 0x44, Name: "Libraries"},
602 __wiretype.FieldType{Type: 0x3, Name: "Label"},
603 __wiretype.FieldType{Type: 0x45, Name: "OS"},
Jiri Simsaddbfebb2014-06-20 15:56:06 -0700604 },
Jiri Simsa764efb72014-12-25 20:57:03 -0800605 "v.io/core/veyron/services/mgmt/profile.Specification", []string(nil)},
Todd Wang702385a2014-11-07 01:54:08 -0800606 __wiretype.NamedPrimitiveType{Type: 0x1, Name: "error", Tags: []string(nil)}}
607 var ss __ipc.ServiceSignature
Jiri Simsaddbfebb2014-06-20 15:56:06 -0700608 var firstAdded int
Todd Wang1fe7cdd2014-11-12 12:51:49 -0800609 ss, _ = s.ProfileServerStub.Signature(ctx)
Jiri Simsaddbfebb2014-06-20 15:56:06 -0700610 firstAdded = len(result.TypeDefs)
611 for k, v := range ss.Methods {
612 for i, _ := range v.InArgs {
Todd Wang702385a2014-11-07 01:54:08 -0800613 if v.InArgs[i].Type >= __wiretype.TypeIDFirst {
614 v.InArgs[i].Type += __wiretype.TypeID(firstAdded)
Jiri Simsaddbfebb2014-06-20 15:56:06 -0700615 }
616 }
617 for i, _ := range v.OutArgs {
Todd Wang702385a2014-11-07 01:54:08 -0800618 if v.OutArgs[i].Type >= __wiretype.TypeIDFirst {
619 v.OutArgs[i].Type += __wiretype.TypeID(firstAdded)
Jiri Simsaddbfebb2014-06-20 15:56:06 -0700620 }
621 }
Todd Wang702385a2014-11-07 01:54:08 -0800622 if v.InStream >= __wiretype.TypeIDFirst {
623 v.InStream += __wiretype.TypeID(firstAdded)
Jiri Simsaddbfebb2014-06-20 15:56:06 -0700624 }
Todd Wang702385a2014-11-07 01:54:08 -0800625 if v.OutStream >= __wiretype.TypeIDFirst {
626 v.OutStream += __wiretype.TypeID(firstAdded)
Jiri Simsaddbfebb2014-06-20 15:56:06 -0700627 }
628 result.Methods[k] = v
629 }
630 //TODO(bprosnitz) combine type definitions from embeded interfaces in a way that doesn't cause duplication.
631 for _, d := range ss.TypeDefs {
632 switch wt := d.(type) {
Todd Wang702385a2014-11-07 01:54:08 -0800633 case __wiretype.SliceType:
634 if wt.Elem >= __wiretype.TypeIDFirst {
635 wt.Elem += __wiretype.TypeID(firstAdded)
Jiri Simsaddbfebb2014-06-20 15:56:06 -0700636 }
637 d = wt
Todd Wang702385a2014-11-07 01:54:08 -0800638 case __wiretype.ArrayType:
639 if wt.Elem >= __wiretype.TypeIDFirst {
640 wt.Elem += __wiretype.TypeID(firstAdded)
Jiri Simsaddbfebb2014-06-20 15:56:06 -0700641 }
642 d = wt
Todd Wang702385a2014-11-07 01:54:08 -0800643 case __wiretype.MapType:
644 if wt.Key >= __wiretype.TypeIDFirst {
645 wt.Key += __wiretype.TypeID(firstAdded)
Jiri Simsaddbfebb2014-06-20 15:56:06 -0700646 }
Todd Wang702385a2014-11-07 01:54:08 -0800647 if wt.Elem >= __wiretype.TypeIDFirst {
648 wt.Elem += __wiretype.TypeID(firstAdded)
Jiri Simsaddbfebb2014-06-20 15:56:06 -0700649 }
650 d = wt
Todd Wang702385a2014-11-07 01:54:08 -0800651 case __wiretype.StructType:
Jiri Simsaddbfebb2014-06-20 15:56:06 -0700652 for i, fld := range wt.Fields {
Todd Wang702385a2014-11-07 01:54:08 -0800653 if fld.Type >= __wiretype.TypeIDFirst {
654 wt.Fields[i].Type += __wiretype.TypeID(firstAdded)
Jiri Simsaddbfebb2014-06-20 15:56:06 -0700655 }
656 }
657 d = wt
658 // NOTE: other types are missing, but we are upgrading anyways.
659 }
660 result.TypeDefs = append(result.TypeDefs, d)
661 }
662
663 return result, nil
664}