blob: 07c29d2fe532ca2f5e27b1af39e04a81eb43d864 [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.
Jiri Simsaddbfebb2014-06-20 15:56:06 -07006// Source: repository.vdl
7
Todd Wang8c4e5cc2015-04-09 11:30:52 -07008// Package repository augments the v.io/v23/services/repository interfaces with
9// implementation-specific configuration methods.
Jiri Simsaddbfebb2014-06-20 15:56:06 -070010package repository
11
12import (
Todd Wangb0d5dce2015-02-05 14:07:55 -080013 // VDL system imports
Jiri Simsa6ac95222015-02-23 16:11:49 -080014 "v.io/v23"
15 "v.io/v23/context"
Matt Rosencrantz94502cf2015-03-18 09:43:44 -070016 "v.io/v23/rpc"
Jiri Simsa6ac95222015-02-23 16:11:49 -080017 "v.io/v23/vdl"
Todd Wangb0d5dce2015-02-05 14:07:55 -080018
19 // VDL user imports
Todd Wang387d8a42015-03-30 17:09:05 -070020 "v.io/v23/security/access"
Todd Wang94c9d0b2015-04-01 14:27:00 -070021 "v.io/v23/services/application"
Todd Wang30192a22015-03-31 13:24:41 -070022 "v.io/v23/services/permissions"
Todd Wang94c9d0b2015-04-01 14:27:00 -070023 "v.io/v23/services/repository"
Robert Kroeger3cd5ed52015-06-23 14:44:47 -070024 "v.io/v23/services/tidyable"
Todd Wang159f6ee2015-04-02 18:57:46 -070025 "v.io/x/ref/services/profile"
Jiri Simsaddbfebb2014-06-20 15:56:06 -070026)
27
Todd Wang702385a2014-11-07 01:54:08 -080028// ApplicationClientMethods is the client interface
29// containing Application methods.
30//
Bogdan Capritaedf6d2b2015-09-02 16:09:03 -070031// Application describes an application repository internally. Besides the
32// public Application interface, it allows adding and removing application
33// envelopes, as well as querying for a list of supported profiles.
Todd Wang702385a2014-11-07 01:54:08 -080034type ApplicationClientMethods interface {
Jiri Simsaddbfebb2014-06-20 15:56:06 -070035 // Application provides access to application envelopes. An
36 // application envelope is identified by an application name and an
Bogdan Capritad9281a32014-07-02 14:40:39 -070037 // application version, which are specified through the object name,
Jiri Simsaddbfebb2014-06-20 15:56:06 -070038 // and a profile name, which is specified using a method argument.
39 //
40 // Example:
41 // /apps/search/v1.Match([]string{"base", "media"})
42 // returns an application envelope that can be used for downloading
43 // and executing the "search" application, version "v1", runnable
44 // on either the "base" or "media" profile.
Todd Wang702385a2014-11-07 01:54:08 -080045 repository.ApplicationClientMethods
Bogdan Caprita661c19a2015-09-04 09:36:58 -070046 // Put adds the given application envelope for the given profile and
Bogdan Capritaedf6d2b2015-09-02 16:09:03 -070047 // application version (required, and specified through the object name
48 // suffix).
49 //
50 // An error is returned if an envelope already exists, unless the
51 // overwrite option is set.
Bogdan Caprita661c19a2015-09-04 09:36:58 -070052 Put(ctx *context.T, Profile string, Envelope application.Envelope, Overwrite bool, opts ...rpc.CallOpt) error
53 // DEPRECATED. Please use Put for new code.
Bogdan Capritaedf6d2b2015-09-02 16:09:03 -070054 PutX(ctx *context.T, Profile string, Envelope application.Envelope, Overwrite bool, opts ...rpc.CallOpt) error
Jiri Simsaddbfebb2014-06-20 15:56:06 -070055 // Remove removes the application envelope for the given profile
Bogdan Capritad9281a32014-07-02 14:40:39 -070056 // name and application version (specified through the object name
Bogdan Capritaedf6d2b2015-09-02 16:09:03 -070057 // suffix).
Jiri Simsaddbfebb2014-06-20 15:56:06 -070058 //
Bogdan Capritaedf6d2b2015-09-02 16:09:03 -070059 // If no version is specified as part of the suffix, the method removes
60 // all versions for the given profile.
61 //
62 // If the profile is the string "*", all profiles are removed for the
63 // given version (or for all versions if the version is not specified).
Matt Rosencrantz94502cf2015-03-18 09:43:44 -070064 Remove(ctx *context.T, Profile string, opts ...rpc.CallOpt) error
Bogdan Capritaedf6d2b2015-09-02 16:09:03 -070065 // Profiles returns the supported profiles for the application version
66 // specified through the object name suffix. If the version is not
67 // specified, Profiles returns the union of profiles across all
68 // versions.
69 Profiles(*context.T, ...rpc.CallOpt) ([]string, error)
Jiri Simsaddbfebb2014-06-20 15:56:06 -070070}
71
Todd Wang702385a2014-11-07 01:54:08 -080072// ApplicationClientStub adds universal methods to ApplicationClientMethods.
73type ApplicationClientStub interface {
74 ApplicationClientMethods
Matt Rosencrantz94502cf2015-03-18 09:43:44 -070075 rpc.UniversalServiceMethods
Jiri Simsaddbfebb2014-06-20 15:56:06 -070076}
77
Todd Wang702385a2014-11-07 01:54:08 -080078// ApplicationClient returns a client stub for Application.
Asim Shankar69fa69f2015-04-01 11:34:32 -070079func ApplicationClient(name string) ApplicationClientStub {
80 return implApplicationClientStub{name, repository.ApplicationClient(name)}
Jiri Simsaddbfebb2014-06-20 15:56:06 -070081}
82
Todd Wang702385a2014-11-07 01:54:08 -080083type implApplicationClientStub struct {
Asim Shankar69fa69f2015-04-01 11:34:32 -070084 name string
Todd Wang702385a2014-11-07 01:54:08 -080085
86 repository.ApplicationClientStub
87}
88
Bogdan Caprita661c19a2015-09-04 09:36:58 -070089func (c implApplicationClientStub) Put(ctx *context.T, i0 string, i1 application.Envelope, i2 bool, opts ...rpc.CallOpt) (err error) {
90 err = v23.GetClient(ctx).Call(ctx, c.name, "Put", []interface{}{i0, i1, i2}, nil, opts...)
Todd Wang702385a2014-11-07 01:54:08 -080091 return
92}
93
Bogdan Capritaedf6d2b2015-09-02 16:09:03 -070094func (c implApplicationClientStub) PutX(ctx *context.T, i0 string, i1 application.Envelope, i2 bool, opts ...rpc.CallOpt) (err error) {
95 err = v23.GetClient(ctx).Call(ctx, c.name, "PutX", []interface{}{i0, i1, i2}, nil, opts...)
96 return
97}
98
Matt Rosencrantz94502cf2015-03-18 09:43:44 -070099func (c implApplicationClientStub) Remove(ctx *context.T, i0 string, opts ...rpc.CallOpt) (err error) {
Suharsh Sivakumardf2672a2015-04-09 19:26:43 -0700100 err = v23.GetClient(ctx).Call(ctx, c.name, "Remove", []interface{}{i0}, nil, opts...)
Todd Wang702385a2014-11-07 01:54:08 -0800101 return
102}
103
Bogdan Capritaedf6d2b2015-09-02 16:09:03 -0700104func (c implApplicationClientStub) Profiles(ctx *context.T, opts ...rpc.CallOpt) (o0 []string, err error) {
105 err = v23.GetClient(ctx).Call(ctx, c.name, "Profiles", nil, []interface{}{&o0}, opts...)
106 return
107}
108
Todd Wang702385a2014-11-07 01:54:08 -0800109// ApplicationServerMethods is the interface a server writer
110// implements for Application.
Jiri Simsaddbfebb2014-06-20 15:56:06 -0700111//
Bogdan Capritaedf6d2b2015-09-02 16:09:03 -0700112// Application describes an application repository internally. Besides the
113// public Application interface, it allows adding and removing application
114// envelopes, as well as querying for a list of supported profiles.
Todd Wang702385a2014-11-07 01:54:08 -0800115type ApplicationServerMethods interface {
116 // Application provides access to application envelopes. An
117 // application envelope is identified by an application name and an
118 // application version, which are specified through the object name,
119 // and a profile name, which is specified using a method argument.
120 //
121 // Example:
122 // /apps/search/v1.Match([]string{"base", "media"})
123 // returns an application envelope that can be used for downloading
124 // and executing the "search" application, version "v1", runnable
125 // on either the "base" or "media" profile.
126 repository.ApplicationServerMethods
Bogdan Caprita661c19a2015-09-04 09:36:58 -0700127 // Put adds the given application envelope for the given profile and
Bogdan Capritaedf6d2b2015-09-02 16:09:03 -0700128 // application version (required, and specified through the object name
129 // suffix).
130 //
131 // An error is returned if an envelope already exists, unless the
132 // overwrite option is set.
Bogdan Caprita661c19a2015-09-04 09:36:58 -0700133 Put(ctx *context.T, call rpc.ServerCall, Profile string, Envelope application.Envelope, Overwrite bool) error
134 // DEPRECATED. Please use Put for new code.
Bogdan Capritaedf6d2b2015-09-02 16:09:03 -0700135 PutX(ctx *context.T, call rpc.ServerCall, Profile string, Envelope application.Envelope, Overwrite bool) error
Todd Wang702385a2014-11-07 01:54:08 -0800136 // Remove removes the application envelope for the given profile
137 // name and application version (specified through the object name
Bogdan Capritaedf6d2b2015-09-02 16:09:03 -0700138 // suffix).
Todd Wang702385a2014-11-07 01:54:08 -0800139 //
Bogdan Capritaedf6d2b2015-09-02 16:09:03 -0700140 // If no version is specified as part of the suffix, the method removes
141 // all versions for the given profile.
142 //
143 // If the profile is the string "*", all profiles are removed for the
144 // given version (or for all versions if the version is not specified).
Todd Wang54feabe2015-04-15 23:38:26 -0700145 Remove(ctx *context.T, call rpc.ServerCall, Profile string) error
Bogdan Capritaedf6d2b2015-09-02 16:09:03 -0700146 // Profiles returns the supported profiles for the application version
147 // specified through the object name suffix. If the version is not
148 // specified, Profiles returns the union of profiles across all
149 // versions.
150 Profiles(*context.T, rpc.ServerCall) ([]string, error)
Todd Wang702385a2014-11-07 01:54:08 -0800151}
152
153// ApplicationServerStubMethods is the server interface containing
Matt Rosencrantz94502cf2015-03-18 09:43:44 -0700154// Application methods, as expected by rpc.Server.
Todd Wang1fe7cdd2014-11-12 12:51:49 -0800155// There is no difference between this interface and ApplicationServerMethods
156// since there are no streaming methods.
157type ApplicationServerStubMethods ApplicationServerMethods
Todd Wang702385a2014-11-07 01:54:08 -0800158
159// ApplicationServerStub adds universal methods to ApplicationServerStubMethods.
160type ApplicationServerStub interface {
161 ApplicationServerStubMethods
Todd Wang5739dda2014-11-16 22:44:02 -0800162 // Describe the Application interfaces.
Matt Rosencrantz94502cf2015-03-18 09:43:44 -0700163 Describe__() []rpc.InterfaceDesc
Todd Wang702385a2014-11-07 01:54:08 -0800164}
165
166// ApplicationServer returns a server stub for Application.
167// It converts an implementation of ApplicationServerMethods into
Matt Rosencrantz94502cf2015-03-18 09:43:44 -0700168// an object that may be used by rpc.Server.
Todd Wang702385a2014-11-07 01:54:08 -0800169func ApplicationServer(impl ApplicationServerMethods) ApplicationServerStub {
170 stub := implApplicationServerStub{
171 impl: impl,
172 ApplicationServerStub: repository.ApplicationServer(impl),
Jiri Simsaddbfebb2014-06-20 15:56:06 -0700173 }
Todd Wang702385a2014-11-07 01:54:08 -0800174 // Initialize GlobState; always check the stub itself first, to handle the
175 // case where the user has the Glob method defined in their VDL source.
Matt Rosencrantz94502cf2015-03-18 09:43:44 -0700176 if gs := rpc.NewGlobState(stub); gs != nil {
Todd Wang702385a2014-11-07 01:54:08 -0800177 stub.gs = gs
Matt Rosencrantz94502cf2015-03-18 09:43:44 -0700178 } else if gs := rpc.NewGlobState(impl); gs != nil {
Todd Wang702385a2014-11-07 01:54:08 -0800179 stub.gs = gs
Robin Thellend94bc4642014-11-05 18:05:08 -0800180 }
Robin Thellend94bc4642014-11-05 18:05:08 -0800181 return stub
Jiri Simsaddbfebb2014-06-20 15:56:06 -0700182}
183
Todd Wang702385a2014-11-07 01:54:08 -0800184type implApplicationServerStub struct {
185 impl ApplicationServerMethods
Todd Wang702385a2014-11-07 01:54:08 -0800186 repository.ApplicationServerStub
Matt Rosencrantz94502cf2015-03-18 09:43:44 -0700187 gs *rpc.GlobState
Matt Rosencrantzbf85d542014-08-22 13:31:14 -0700188}
189
Bogdan Caprita661c19a2015-09-04 09:36:58 -0700190func (s implApplicationServerStub) Put(ctx *context.T, call rpc.ServerCall, i0 string, i1 application.Envelope, i2 bool) error {
191 return s.impl.Put(ctx, call, i0, i1, i2)
Jiri Simsaddbfebb2014-06-20 15:56:06 -0700192}
193
Bogdan Capritaedf6d2b2015-09-02 16:09:03 -0700194func (s implApplicationServerStub) PutX(ctx *context.T, call rpc.ServerCall, i0 string, i1 application.Envelope, i2 bool) error {
195 return s.impl.PutX(ctx, call, i0, i1, i2)
196}
197
Todd Wang54feabe2015-04-15 23:38:26 -0700198func (s implApplicationServerStub) Remove(ctx *context.T, call rpc.ServerCall, i0 string) error {
199 return s.impl.Remove(ctx, call, i0)
Jiri Simsaddbfebb2014-06-20 15:56:06 -0700200}
201
Bogdan Capritaedf6d2b2015-09-02 16:09:03 -0700202func (s implApplicationServerStub) Profiles(ctx *context.T, call rpc.ServerCall) ([]string, error) {
203 return s.impl.Profiles(ctx, call)
204}
205
Matt Rosencrantz94502cf2015-03-18 09:43:44 -0700206func (s implApplicationServerStub) Globber() *rpc.GlobState {
Todd Wang702385a2014-11-07 01:54:08 -0800207 return s.gs
Jiri Simsaddbfebb2014-06-20 15:56:06 -0700208}
209
Matt Rosencrantz94502cf2015-03-18 09:43:44 -0700210func (s implApplicationServerStub) Describe__() []rpc.InterfaceDesc {
Robert Kroeger3cd5ed52015-06-23 14:44:47 -0700211 return []rpc.InterfaceDesc{ApplicationDesc, repository.ApplicationDesc, permissions.ObjectDesc, tidyable.TidyableDesc}
Todd Wang5739dda2014-11-16 22:44:02 -0800212}
213
214// ApplicationDesc describes the Application interface.
Matt Rosencrantz94502cf2015-03-18 09:43:44 -0700215var ApplicationDesc rpc.InterfaceDesc = descApplication
Todd Wang5739dda2014-11-16 22:44:02 -0800216
217// descApplication hides the desc to keep godoc clean.
Matt Rosencrantz94502cf2015-03-18 09:43:44 -0700218var descApplication = rpc.InterfaceDesc{
Todd Wang5739dda2014-11-16 22:44:02 -0800219 Name: "Application",
Todd Wang1ea8f192015-04-03 17:31:51 -0700220 PkgPath: "v.io/x/ref/services/repository",
Bogdan Capritaedf6d2b2015-09-02 16:09:03 -0700221 Doc: "// Application describes an application repository internally. Besides the\n// public Application interface, it allows adding and removing application\n// envelopes, as well as querying for a list of supported profiles.",
Matt Rosencrantz94502cf2015-03-18 09:43:44 -0700222 Embeds: []rpc.EmbedDesc{
Todd Wang94c9d0b2015-04-01 14:27:00 -0700223 {"Application", "v.io/v23/services/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 -0800224 },
Matt Rosencrantz94502cf2015-03-18 09:43:44 -0700225 Methods: []rpc.MethodDesc{
Todd Wang5739dda2014-11-16 22:44:02 -0800226 {
227 Name: "Put",
Bogdan Caprita661c19a2015-09-04 09:36:58 -0700228 Doc: "// Put adds the given application envelope for the given profile and\n// application version (required, and specified through the object name\n// suffix).\n//\n// An error is returned if an envelope already exists, unless the\n// overwrite option is set.",
Matt Rosencrantz94502cf2015-03-18 09:43:44 -0700229 InArgs: []rpc.ArgDesc{
Bogdan Caprita661c19a2015-09-04 09:36:58 -0700230 {"Profile", ``}, // string
231 {"Envelope", ``}, // application.Envelope
232 {"Overwrite", ``}, // bool
Todd Wang5739dda2014-11-16 22:44:02 -0800233 },
Todd Wangb31da592015-02-20 12:50:39 -0800234 Tags: []*vdl.Value{vdl.ValueOf(access.Tag("Write"))},
Todd Wang5739dda2014-11-16 22:44:02 -0800235 },
236 {
Bogdan Capritaedf6d2b2015-09-02 16:09:03 -0700237 Name: "PutX",
Bogdan Caprita661c19a2015-09-04 09:36:58 -0700238 Doc: "// DEPRECATED. Please use Put for new code.",
Bogdan Capritaedf6d2b2015-09-02 16:09:03 -0700239 InArgs: []rpc.ArgDesc{
240 {"Profile", ``}, // string
241 {"Envelope", ``}, // application.Envelope
242 {"Overwrite", ``}, // bool
243 },
244 Tags: []*vdl.Value{vdl.ValueOf(access.Tag("Write"))},
245 },
246 {
Todd Wang5739dda2014-11-16 22:44:02 -0800247 Name: "Remove",
Bogdan Capritaedf6d2b2015-09-02 16:09:03 -0700248 Doc: "// Remove removes the application envelope for the given profile\n// name and application version (specified through the object name\n// suffix).\n//\n// If no version is specified as part of the suffix, the method removes\n// all versions for the given profile.\n//\n// If the profile is the string \"*\", all profiles are removed for the\n// given version (or for all versions if the version is not specified).",
Matt Rosencrantz94502cf2015-03-18 09:43:44 -0700249 InArgs: []rpc.ArgDesc{
Todd Wang5739dda2014-11-16 22:44:02 -0800250 {"Profile", ``}, // string
251 },
Todd Wangb31da592015-02-20 12:50:39 -0800252 Tags: []*vdl.Value{vdl.ValueOf(access.Tag("Write"))},
Todd Wang5739dda2014-11-16 22:44:02 -0800253 },
Bogdan Capritaedf6d2b2015-09-02 16:09:03 -0700254 {
255 Name: "Profiles",
256 Doc: "// Profiles returns the supported profiles for the application version\n// specified through the object name suffix. If the version is not\n// specified, Profiles returns the union of profiles across all\n// versions.",
257 OutArgs: []rpc.ArgDesc{
258 {"", ``}, // []string
259 },
260 Tags: []*vdl.Value{vdl.ValueOf(access.Tag("Read"))},
261 },
Todd Wang5739dda2014-11-16 22:44:02 -0800262 },
Jiri Simsaddbfebb2014-06-20 15:56:06 -0700263}
264
Todd Wang702385a2014-11-07 01:54:08 -0800265// ProfileClientMethods is the client interface
266// containing Profile methods.
267//
Jiri Simsaddbfebb2014-06-20 15:56:06 -0700268// Profile describes a profile internally. Besides the public Profile
269// interface, it allows to add and remove profile specifications.
Todd Wang702385a2014-11-07 01:54:08 -0800270type ProfileClientMethods interface {
Jiri Simsaddbfebb2014-06-20 15:56:06 -0700271 // Profile abstracts a device's ability to run binaries, and hides
272 // specifics such as the operating system, hardware architecture, and
273 // the set of installed libraries. Profiles describe binaries and
274 // devices, and are used to match them.
Todd Wang702385a2014-11-07 01:54:08 -0800275 repository.ProfileClientMethods
Jiri Simsaddbfebb2014-06-20 15:56:06 -0700276 // Specification returns the profile specification for the profile
Bogdan Capritad9281a32014-07-02 14:40:39 -0700277 // identified through the object name suffix.
Matt Rosencrantz94502cf2015-03-18 09:43:44 -0700278 Specification(*context.T, ...rpc.CallOpt) (profile.Specification, error)
Jiri Simsaddbfebb2014-06-20 15:56:06 -0700279 // Put sets the profile specification for the profile identified
Bogdan Capritad9281a32014-07-02 14:40:39 -0700280 // through the object name suffix.
Matt Rosencrantz94502cf2015-03-18 09:43:44 -0700281 Put(ctx *context.T, Specification profile.Specification, opts ...rpc.CallOpt) error
Jiri Simsaddbfebb2014-06-20 15:56:06 -0700282 // Remove removes the profile specification for the profile
Bogdan Capritad9281a32014-07-02 14:40:39 -0700283 // identified through the object name suffix.
Matt Rosencrantz94502cf2015-03-18 09:43:44 -0700284 Remove(*context.T, ...rpc.CallOpt) error
Jiri Simsaddbfebb2014-06-20 15:56:06 -0700285}
286
Todd Wang702385a2014-11-07 01:54:08 -0800287// ProfileClientStub adds universal methods to ProfileClientMethods.
288type ProfileClientStub interface {
289 ProfileClientMethods
Matt Rosencrantz94502cf2015-03-18 09:43:44 -0700290 rpc.UniversalServiceMethods
Jiri Simsaddbfebb2014-06-20 15:56:06 -0700291}
292
Todd Wang702385a2014-11-07 01:54:08 -0800293// ProfileClient returns a client stub for Profile.
Asim Shankar69fa69f2015-04-01 11:34:32 -0700294func ProfileClient(name string) ProfileClientStub {
295 return implProfileClientStub{name, repository.ProfileClient(name)}
Jiri Simsaddbfebb2014-06-20 15:56:06 -0700296}
297
Todd Wang702385a2014-11-07 01:54:08 -0800298type implProfileClientStub struct {
Asim Shankar69fa69f2015-04-01 11:34:32 -0700299 name string
Todd Wang702385a2014-11-07 01:54:08 -0800300
301 repository.ProfileClientStub
302}
303
Matt Rosencrantz94502cf2015-03-18 09:43:44 -0700304func (c implProfileClientStub) Specification(ctx *context.T, opts ...rpc.CallOpt) (o0 profile.Specification, err error) {
Suharsh Sivakumardf2672a2015-04-09 19:26:43 -0700305 err = v23.GetClient(ctx).Call(ctx, c.name, "Specification", nil, []interface{}{&o0}, opts...)
Todd Wang702385a2014-11-07 01:54:08 -0800306 return
307}
308
Matt Rosencrantz94502cf2015-03-18 09:43:44 -0700309func (c implProfileClientStub) Put(ctx *context.T, i0 profile.Specification, opts ...rpc.CallOpt) (err error) {
Suharsh Sivakumardf2672a2015-04-09 19:26:43 -0700310 err = v23.GetClient(ctx).Call(ctx, c.name, "Put", []interface{}{i0}, nil, opts...)
Todd Wang702385a2014-11-07 01:54:08 -0800311 return
312}
313
Matt Rosencrantz94502cf2015-03-18 09:43:44 -0700314func (c implProfileClientStub) Remove(ctx *context.T, opts ...rpc.CallOpt) (err error) {
Suharsh Sivakumardf2672a2015-04-09 19:26:43 -0700315 err = v23.GetClient(ctx).Call(ctx, c.name, "Remove", nil, nil, opts...)
Todd Wang702385a2014-11-07 01:54:08 -0800316 return
317}
318
Todd Wang702385a2014-11-07 01:54:08 -0800319// ProfileServerMethods is the interface a server writer
320// implements for Profile.
Jiri Simsaddbfebb2014-06-20 15:56:06 -0700321//
Todd Wang702385a2014-11-07 01:54:08 -0800322// Profile describes a profile internally. Besides the public Profile
323// interface, it allows to add and remove profile specifications.
324type ProfileServerMethods interface {
325 // Profile abstracts a device's ability to run binaries, and hides
326 // specifics such as the operating system, hardware architecture, and
327 // the set of installed libraries. Profiles describe binaries and
328 // devices, and are used to match them.
329 repository.ProfileServerMethods
330 // Specification returns the profile specification for the profile
331 // identified through the object name suffix.
Todd Wang54feabe2015-04-15 23:38:26 -0700332 Specification(*context.T, rpc.ServerCall) (profile.Specification, error)
Todd Wang702385a2014-11-07 01:54:08 -0800333 // Put sets the profile specification for the profile identified
334 // through the object name suffix.
Todd Wang54feabe2015-04-15 23:38:26 -0700335 Put(ctx *context.T, call rpc.ServerCall, Specification profile.Specification) error
Todd Wang702385a2014-11-07 01:54:08 -0800336 // Remove removes the profile specification for the profile
337 // identified through the object name suffix.
Todd Wang54feabe2015-04-15 23:38:26 -0700338 Remove(*context.T, rpc.ServerCall) error
Todd Wang702385a2014-11-07 01:54:08 -0800339}
340
341// ProfileServerStubMethods is the server interface containing
Matt Rosencrantz94502cf2015-03-18 09:43:44 -0700342// Profile methods, as expected by rpc.Server.
Todd Wang1fe7cdd2014-11-12 12:51:49 -0800343// There is no difference between this interface and ProfileServerMethods
344// since there are no streaming methods.
345type ProfileServerStubMethods ProfileServerMethods
Todd Wang702385a2014-11-07 01:54:08 -0800346
347// ProfileServerStub adds universal methods to ProfileServerStubMethods.
348type ProfileServerStub interface {
349 ProfileServerStubMethods
Todd Wang5739dda2014-11-16 22:44:02 -0800350 // Describe the Profile interfaces.
Matt Rosencrantz94502cf2015-03-18 09:43:44 -0700351 Describe__() []rpc.InterfaceDesc
Todd Wang702385a2014-11-07 01:54:08 -0800352}
353
354// ProfileServer returns a server stub for Profile.
355// It converts an implementation of ProfileServerMethods into
Matt Rosencrantz94502cf2015-03-18 09:43:44 -0700356// an object that may be used by rpc.Server.
Todd Wang702385a2014-11-07 01:54:08 -0800357func ProfileServer(impl ProfileServerMethods) ProfileServerStub {
358 stub := implProfileServerStub{
359 impl: impl,
360 ProfileServerStub: repository.ProfileServer(impl),
Jiri Simsaddbfebb2014-06-20 15:56:06 -0700361 }
Todd Wang702385a2014-11-07 01:54:08 -0800362 // Initialize GlobState; always check the stub itself first, to handle the
363 // case where the user has the Glob method defined in their VDL source.
Matt Rosencrantz94502cf2015-03-18 09:43:44 -0700364 if gs := rpc.NewGlobState(stub); gs != nil {
Todd Wang702385a2014-11-07 01:54:08 -0800365 stub.gs = gs
Matt Rosencrantz94502cf2015-03-18 09:43:44 -0700366 } else if gs := rpc.NewGlobState(impl); gs != nil {
Todd Wang702385a2014-11-07 01:54:08 -0800367 stub.gs = gs
Robin Thellend94bc4642014-11-05 18:05:08 -0800368 }
Robin Thellend94bc4642014-11-05 18:05:08 -0800369 return stub
Jiri Simsaddbfebb2014-06-20 15:56:06 -0700370}
371
Todd Wang702385a2014-11-07 01:54:08 -0800372type implProfileServerStub struct {
373 impl ProfileServerMethods
Todd Wang702385a2014-11-07 01:54:08 -0800374 repository.ProfileServerStub
Matt Rosencrantz94502cf2015-03-18 09:43:44 -0700375 gs *rpc.GlobState
Matt Rosencrantzbf85d542014-08-22 13:31:14 -0700376}
377
Todd Wang54feabe2015-04-15 23:38:26 -0700378func (s implProfileServerStub) Specification(ctx *context.T, call rpc.ServerCall) (profile.Specification, error) {
379 return s.impl.Specification(ctx, call)
Jiri Simsaddbfebb2014-06-20 15:56:06 -0700380}
381
Todd Wang54feabe2015-04-15 23:38:26 -0700382func (s implProfileServerStub) Put(ctx *context.T, call rpc.ServerCall, i0 profile.Specification) error {
383 return s.impl.Put(ctx, call, i0)
Jiri Simsaddbfebb2014-06-20 15:56:06 -0700384}
385
Todd Wang54feabe2015-04-15 23:38:26 -0700386func (s implProfileServerStub) Remove(ctx *context.T, call rpc.ServerCall) error {
387 return s.impl.Remove(ctx, call)
Jiri Simsaddbfebb2014-06-20 15:56:06 -0700388}
389
Matt Rosencrantz94502cf2015-03-18 09:43:44 -0700390func (s implProfileServerStub) Globber() *rpc.GlobState {
Todd Wang702385a2014-11-07 01:54:08 -0800391 return s.gs
Jiri Simsaddbfebb2014-06-20 15:56:06 -0700392}
393
Matt Rosencrantz94502cf2015-03-18 09:43:44 -0700394func (s implProfileServerStub) Describe__() []rpc.InterfaceDesc {
395 return []rpc.InterfaceDesc{ProfileDesc, repository.ProfileDesc}
Todd Wang5739dda2014-11-16 22:44:02 -0800396}
397
398// ProfileDesc describes the Profile interface.
Matt Rosencrantz94502cf2015-03-18 09:43:44 -0700399var ProfileDesc rpc.InterfaceDesc = descProfile
Todd Wang5739dda2014-11-16 22:44:02 -0800400
401// descProfile hides the desc to keep godoc clean.
Matt Rosencrantz94502cf2015-03-18 09:43:44 -0700402var descProfile = rpc.InterfaceDesc{
Todd Wang5739dda2014-11-16 22:44:02 -0800403 Name: "Profile",
Todd Wang1ea8f192015-04-03 17:31:51 -0700404 PkgPath: "v.io/x/ref/services/repository",
Todd Wang5739dda2014-11-16 22:44:02 -0800405 Doc: "// Profile describes a profile internally. Besides the public Profile\n// interface, it allows to add and remove profile specifications.",
Matt Rosencrantz94502cf2015-03-18 09:43:44 -0700406 Embeds: []rpc.EmbedDesc{
Todd Wang94c9d0b2015-04-01 14:27:00 -0700407 {"Profile", "v.io/v23/services/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 -0800408 },
Matt Rosencrantz94502cf2015-03-18 09:43:44 -0700409 Methods: []rpc.MethodDesc{
Todd Wang5739dda2014-11-16 22:44:02 -0800410 {
411 Name: "Specification",
412 Doc: "// Specification returns the profile specification for the profile\n// identified through the object name suffix.",
Matt Rosencrantz94502cf2015-03-18 09:43:44 -0700413 OutArgs: []rpc.ArgDesc{
Todd Wang5739dda2014-11-16 22:44:02 -0800414 {"", ``}, // profile.Specification
Todd Wang5739dda2014-11-16 22:44:02 -0800415 },
Todd Wangb31da592015-02-20 12:50:39 -0800416 Tags: []*vdl.Value{vdl.ValueOf(access.Tag("Read"))},
Todd Wang5739dda2014-11-16 22:44:02 -0800417 },
418 {
419 Name: "Put",
420 Doc: "// Put sets the profile specification for the profile identified\n// through the object name suffix.",
Matt Rosencrantz94502cf2015-03-18 09:43:44 -0700421 InArgs: []rpc.ArgDesc{
Todd Wang5739dda2014-11-16 22:44:02 -0800422 {"Specification", ``}, // profile.Specification
423 },
Todd Wangb31da592015-02-20 12:50:39 -0800424 Tags: []*vdl.Value{vdl.ValueOf(access.Tag("Write"))},
Todd Wang5739dda2014-11-16 22:44:02 -0800425 },
426 {
427 Name: "Remove",
428 Doc: "// Remove removes the profile specification for the profile\n// identified through the object name suffix.",
Todd Wangb31da592015-02-20 12:50:39 -0800429 Tags: []*vdl.Value{vdl.ValueOf(access.Tag("Write"))},
Todd Wang5739dda2014-11-16 22:44:02 -0800430 },
431 },
Jiri Simsaddbfebb2014-06-20 15:56:06 -0700432}