1
1
// Copyright 2014 Canonical Ltd.
2
2
// Licensed under the AGPLv3, see LICENCE file for details.
3
3
4
- // Package service provides access to the service api facade.
5
- // This facade contains api calls that are specific to services .
6
- // As a rule of thumb, if the argument for an api requries a service name
7
- // and affects only that service then the call belongs here.
8
- package service
4
+ // Package application provides access to the application api facade.
5
+ // This facade contains api calls that are specific to applications .
6
+ // As a rule of thumb, if the argument for an api requires an application name
7
+ // and affects only that application then the call belongs here.
8
+ package application
9
9
10
10
import (
11
11
"github.com/juju/errors"
@@ -21,7 +21,7 @@ import (
21
21
"github.com/juju/juju/storage"
22
22
)
23
23
24
- var logger = loggo .GetLogger ("juju.api.service " )
24
+ var logger = loggo .GetLogger ("juju.api.application " )
25
25
26
26
// Client allows access to the service API end point.
27
27
type Client struct {
@@ -30,13 +30,13 @@ type Client struct {
30
30
facade base.FacadeCaller
31
31
}
32
32
33
- // NewClient creates a new client for accessing the service api.
33
+ // NewClient creates a new client for accessing the application api.
34
34
func NewClient (st api.Connection ) * Client {
35
- frontend , backend := base .NewClientFacade (st , "Service " )
35
+ frontend , backend := base .NewClientFacade (st , "Application " )
36
36
return & Client {ClientFacade : frontend , st : st , facade : backend }
37
37
}
38
38
39
- // SetMetricCredentials sets the metric credentials for the service specified.
39
+ // SetMetricCredentials sets the metric credentials for the application specified.
40
40
func (c * Client ) SetMetricCredentials (service string , credentials []byte ) error {
41
41
creds := []params.ApplicationMetricCredential {
42
42
{service , credentials },
@@ -64,15 +64,15 @@ func (c *Client) ModelUUID() string {
64
64
type DeployArgs struct {
65
65
// CharmID identifies the charm to deploy.
66
66
CharmID charmstore.CharmID
67
- // ServiceName is the name to give the service .
68
- ServiceName string
67
+ // ApplicationName is the name to give the application .
68
+ ApplicationName string
69
69
// Series to be used for the machine.
70
70
Series string
71
71
// NumUnits is the number of units to deploy.
72
72
NumUnits int
73
73
// ConfigYAML is a string that overrides the default config.yml.
74
74
ConfigYAML string
75
- // Cons contains constraints on where units of this service may be
75
+ // Cons contains constraints on where units of this application may be
76
76
// placed.
77
77
Cons constraints.Value
78
78
// Placement directives on where the machines for the unit must be
@@ -83,7 +83,7 @@ type DeployArgs struct {
83
83
Storage map [string ]storage.Constraints
84
84
// EndpointBindings
85
85
EndpointBindings map [string ]string
86
- // Collection of resource names for the service , with the value being the
86
+ // Collection of resource names for the application , with the value being the
87
87
// unique ID of a pre-uploaded resources in storage.
88
88
Resources map [string ]string
89
89
}
@@ -94,7 +94,7 @@ type DeployArgs struct {
94
94
func (c * Client ) Deploy (args DeployArgs ) error {
95
95
deployArgs := params.ApplicationsDeploy {
96
96
Applications : []params.ApplicationDeploy {{
97
- ApplicationName : args .ServiceName ,
97
+ ApplicationName : args .ApplicationName ,
98
98
Series : args .Series ,
99
99
CharmUrl : args .CharmID .URL .String (),
100
100
Channel : string (args .CharmID .Channel ),
@@ -134,8 +134,8 @@ func (c *Client) GetCharmURL(serviceName string) (*charm.URL, error) {
134
134
// SetCharmConfig holds the configuration for setting a new revision of a charm
135
135
// on a service.
136
136
type SetCharmConfig struct {
137
- // ServiceName is the name of the service to set the charm on.
138
- ServiceName string
137
+ // ApplicationName is the name of the application to set the charm on.
138
+ ApplicationName string
139
139
// CharmID identifies the charm.
140
140
CharmID charmstore.CharmID
141
141
// ForceSeries forces the use of the charm even if it doesn't match the
@@ -151,7 +151,7 @@ type SetCharmConfig struct {
151
151
// SetCharm sets the charm for a given service.
152
152
func (c * Client ) SetCharm (cfg SetCharmConfig ) error {
153
153
args := params.ApplicationSetCharm {
154
- ApplicationName : cfg .ServiceName ,
154
+ ApplicationName : cfg .ApplicationName ,
155
155
CharmUrl : cfg .CharmID .URL .String (),
156
156
Channel : string (cfg .CharmID .Channel ),
157
157
ForceSeries : cfg .ForceSeries ,
@@ -161,17 +161,17 @@ func (c *Client) SetCharm(cfg SetCharmConfig) error {
161
161
return c .facade .FacadeCall ("SetCharm" , args , nil )
162
162
}
163
163
164
- // Update updates the service attributes, including charm URL,
164
+ // Update updates the application attributes, including charm URL,
165
165
// minimum number of units, settings and constraints.
166
166
func (c * Client ) Update (args params.ApplicationUpdate ) error {
167
167
return c .facade .FacadeCall ("Update" , args , nil )
168
168
}
169
169
170
- // AddUnits adds a given number of units to a service using the specified
170
+ // AddUnits adds a given number of units to an application using the specified
171
171
// placement directives to assign units to machines.
172
- func (c * Client ) AddUnits (service string , numUnits int , placement []* instance.Placement ) ([]string , error ) {
172
+ func (c * Client ) AddUnits (application string , numUnits int , placement []* instance.Placement ) ([]string , error ) {
173
173
args := params.AddApplicationUnits {
174
- ApplicationName : service ,
174
+ ApplicationName : application ,
175
175
NumUnits : numUnits ,
176
176
Placement : placement ,
177
177
}
@@ -180,80 +180,80 @@ func (c *Client) AddUnits(service string, numUnits int, placement []*instance.Pl
180
180
return results .Units , err
181
181
}
182
182
183
- // DestroyUnits decreases the number of units dedicated to a service .
183
+ // DestroyUnits decreases the number of units dedicated to an application .
184
184
func (c * Client ) DestroyUnits (unitNames ... string ) error {
185
185
params := params.DestroyApplicationUnits {unitNames }
186
186
return c .facade .FacadeCall ("DestroyUnits" , params , nil )
187
187
}
188
188
189
- // Destroy destroys a given service .
190
- func (c * Client ) Destroy (service string ) error {
189
+ // Destroy destroys a given application .
190
+ func (c * Client ) Destroy (application string ) error {
191
191
params := params.ApplicationDestroy {
192
- ApplicationName : service ,
192
+ ApplicationName : application ,
193
193
}
194
194
return c .facade .FacadeCall ("Destroy" , params , nil )
195
195
}
196
196
197
- // GetConstraints returns the constraints for the given service .
197
+ // GetConstraints returns the constraints for the given application .
198
198
func (c * Client ) GetConstraints (service string ) (constraints.Value , error ) {
199
199
results := new (params.GetConstraintsResults )
200
200
err := c .facade .FacadeCall ("GetConstraints" , params.GetApplicationConstraints {service }, results )
201
201
return results .Constraints , err
202
202
}
203
203
204
- // SetConstraints specifies the constraints for the given service .
205
- func (c * Client ) SetConstraints (service string , constraints constraints.Value ) error {
204
+ // SetConstraints specifies the constraints for the given application .
205
+ func (c * Client ) SetConstraints (application string , constraints constraints.Value ) error {
206
206
params := params.SetConstraints {
207
- ApplicationName : service ,
207
+ ApplicationName : application ,
208
208
Constraints : constraints ,
209
209
}
210
210
return c .facade .FacadeCall ("SetConstraints" , params , nil )
211
211
}
212
212
213
213
// Expose changes the juju-managed firewall to expose any ports that
214
214
// were also explicitly marked by units as open.
215
- func (c * Client ) Expose (service string ) error {
216
- params := params.ApplicationExpose {ApplicationName : service }
215
+ func (c * Client ) Expose (application string ) error {
216
+ params := params.ApplicationExpose {ApplicationName : application }
217
217
return c .facade .FacadeCall ("Expose" , params , nil )
218
218
}
219
219
220
220
// Unexpose changes the juju-managed firewall to unexpose any ports that
221
221
// were also explicitly marked by units as open.
222
- func (c * Client ) Unexpose (service string ) error {
223
- params := params.ApplicationUnexpose {ApplicationName : service }
222
+ func (c * Client ) Unexpose (application string ) error {
223
+ params := params.ApplicationUnexpose {ApplicationName : application }
224
224
return c .facade .FacadeCall ("Unexpose" , params , nil )
225
225
}
226
226
227
- // Get returns the configuration for the named service .
228
- func (c * Client ) Get (service string ) (* params.ApplicationGetResults , error ) {
227
+ // Get returns the configuration for the named application .
228
+ func (c * Client ) Get (application string ) (* params.ApplicationGetResults , error ) {
229
229
var results params.ApplicationGetResults
230
- params := params.ApplicationGet {ApplicationName : service }
230
+ params := params.ApplicationGet {ApplicationName : application }
231
231
err := c .facade .FacadeCall ("Get" , params , & results )
232
232
return & results , err
233
233
}
234
234
235
- // Set sets configuration options on a service .
236
- func (c * Client ) Set (service string , options map [string ]string ) error {
235
+ // Set sets configuration options on an application .
236
+ func (c * Client ) Set (application string , options map [string ]string ) error {
237
237
p := params.ApplicationSet {
238
- ApplicationName : service ,
238
+ ApplicationName : application ,
239
239
Options : options ,
240
240
}
241
241
return c .facade .FacadeCall ("Set" , p , nil )
242
242
}
243
243
244
- // Unset resets configuration options on a service .
245
- func (c * Client ) Unset (service string , options []string ) error {
244
+ // Unset resets configuration options on an application .
245
+ func (c * Client ) Unset (application string , options []string ) error {
246
246
p := params.ApplicationUnset {
247
- ApplicationName : service ,
247
+ ApplicationName : application ,
248
248
Options : options ,
249
249
}
250
250
return c .facade .FacadeCall ("Unset" , p , nil )
251
251
}
252
252
253
- // CharmRelations returns the service 's charms relation names.
254
- func (c * Client ) CharmRelations (service string ) ([]string , error ) {
253
+ // CharmRelations returns the application 's charms relation names.
254
+ func (c * Client ) CharmRelations (application string ) ([]string , error ) {
255
255
var results params.ApplicationCharmRelationsResults
256
- params := params.ApplicationCharmRelations {ApplicationName : service }
256
+ params := params.ApplicationCharmRelations {ApplicationName : application }
257
257
err := c .facade .FacadeCall ("CharmRelations" , params , & results )
258
258
return results .CharmRelations , err
259
259
}
0 commit comments