|
@@ -1,11 +1,11 @@ |
|
// Copyright 2014 Canonical Ltd.
|
|
// Copyright 2014 Canonical Ltd.
|
|
// Licensed under the AGPLv3, see LICENCE file for details.
|
|
// Licensed under the AGPLv3, see LICENCE file for details.
|
|
|
|
|
|
-// Package service provides access to the service api facade.
|
|
+// Package application provides access to the application api facade.
|
|
-// This facade contains api calls that are specific to services.
|
|
+// This facade contains api calls that are specific to applications.
|
|
-// As a rule of thumb, if the argument for an api requries a service name
|
|
+// As a rule of thumb, if the argument for an api requires an application name
|
|
-// and affects only that service then the call belongs here.
|
|
+// and affects only that application then the call belongs here.
|
|
-package service
|
|
+package application
|
|
|
|
|
|
import (
|
|
import (
|
|
"github.com/juju/errors"
|
|
"github.com/juju/errors"
|
|
|
@@ -21,7 +21,7 @@ import ( |
|
"github.com/juju/juju/storage"
|
|
"github.com/juju/juju/storage"
|
|
)
|
|
)
|
|
|
|
|
|
-var logger = loggo.GetLogger("juju.api.service")
|
|
+var logger = loggo.GetLogger("juju.api.application")
|
|
|
|
|
|
// Client allows access to the service API end point.
|
|
// Client allows access to the service API end point.
|
|
type Client struct {
|
|
type Client struct {
|
|
|
@@ -30,13 +30,13 @@ type Client struct { |
|
facade base.FacadeCaller
|
|
facade base.FacadeCaller
|
|
}
|
|
}
|
|
|
|
|
|
-// NewClient creates a new client for accessing the service api.
|
|
+// NewClient creates a new client for accessing the application api.
|
|
func NewClient(st api.Connection) *Client {
|
|
func NewClient(st api.Connection) *Client {
|
|
- frontend, backend := base.NewClientFacade(st, "Service")
|
|
+ frontend, backend := base.NewClientFacade(st, "Application")
|
|
return &Client{ClientFacade: frontend, st: st, facade: backend}
|
|
return &Client{ClientFacade: frontend, st: st, facade: backend}
|
|
}
|
|
}
|
|
|
|
|
|
-// SetMetricCredentials sets the metric credentials for the service specified.
|
|
+// SetMetricCredentials sets the metric credentials for the application specified.
|
|
func (c *Client) SetMetricCredentials(service string, credentials []byte) error {
|
|
func (c *Client) SetMetricCredentials(service string, credentials []byte) error {
|
|
creds := []params.ApplicationMetricCredential{
|
|
creds := []params.ApplicationMetricCredential{
|
|
{service, credentials},
|
|
{service, credentials},
|
|
|
@@ -64,15 +64,15 @@ func (c *Client) ModelUUID() string { |
|
type DeployArgs struct {
|
|
type DeployArgs struct {
|
|
// CharmID identifies the charm to deploy.
|
|
// CharmID identifies the charm to deploy.
|
|
CharmID charmstore.CharmID
|
|
CharmID charmstore.CharmID
|
|
- // ServiceName is the name to give the service.
|
|
+ // ApplicationName is the name to give the application.
|
|
- ServiceName string
|
|
+ ApplicationName string
|
|
// Series to be used for the machine.
|
|
// Series to be used for the machine.
|
|
Series string
|
|
Series string
|
|
// NumUnits is the number of units to deploy.
|
|
// NumUnits is the number of units to deploy.
|
|
NumUnits int
|
|
NumUnits int
|
|
// ConfigYAML is a string that overrides the default config.yml.
|
|
// ConfigYAML is a string that overrides the default config.yml.
|
|
ConfigYAML string
|
|
ConfigYAML string
|
|
- // Cons contains constraints on where units of this service may be
|
|
+ // Cons contains constraints on where units of this application may be
|
|
// placed.
|
|
// placed.
|
|
Cons constraints.Value
|
|
Cons constraints.Value
|
|
// Placement directives on where the machines for the unit must be
|
|
// Placement directives on where the machines for the unit must be
|
|
|
@@ -83,7 +83,7 @@ type DeployArgs struct { |
|
Storage map[string]storage.Constraints
|
|
Storage map[string]storage.Constraints
|
|
// EndpointBindings
|
|
// EndpointBindings
|
|
EndpointBindings map[string]string
|
|
EndpointBindings map[string]string
|
|
- // Collection of resource names for the service, with the value being the
|
|
+ // Collection of resource names for the application, with the value being the
|
|
// unique ID of a pre-uploaded resources in storage.
|
|
// unique ID of a pre-uploaded resources in storage.
|
|
Resources map[string]string
|
|
Resources map[string]string
|
|
}
|
|
}
|
|
|
@@ -94,7 +94,7 @@ type DeployArgs struct { |
|
func (c *Client) Deploy(args DeployArgs) error {
|
|
func (c *Client) Deploy(args DeployArgs) error {
|
|
deployArgs := params.ApplicationsDeploy{
|
|
deployArgs := params.ApplicationsDeploy{
|
|
Applications: []params.ApplicationDeploy{{
|
|
Applications: []params.ApplicationDeploy{{
|
|
- ApplicationName: args.ServiceName,
|
|
+ ApplicationName: args.ApplicationName,
|
|
Series: args.Series,
|
|
Series: args.Series,
|
|
CharmUrl: args.CharmID.URL.String(),
|
|
CharmUrl: args.CharmID.URL.String(),
|
|
Channel: string(args.CharmID.Channel),
|
|
Channel: string(args.CharmID.Channel),
|
|
|
@@ -134,8 +134,8 @@ func (c *Client) GetCharmURL(serviceName string) (*charm.URL, error) { |
|
// SetCharmConfig holds the configuration for setting a new revision of a charm
|
|
// SetCharmConfig holds the configuration for setting a new revision of a charm
|
|
// on a service.
|
|
// on a service.
|
|
type SetCharmConfig struct {
|
|
type SetCharmConfig struct {
|
|
- // ServiceName is the name of the service to set the charm on.
|
|
+ // ApplicationName is the name of the application to set the charm on.
|
|
- ServiceName string
|
|
+ ApplicationName string
|
|
// CharmID identifies the charm.
|
|
// CharmID identifies the charm.
|
|
CharmID charmstore.CharmID
|
|
CharmID charmstore.CharmID
|
|
// ForceSeries forces the use of the charm even if it doesn't match the
|
|
// ForceSeries forces the use of the charm even if it doesn't match the
|
|
|
@@ -151,7 +151,7 @@ type SetCharmConfig struct { |
|
// SetCharm sets the charm for a given service.
|
|
// SetCharm sets the charm for a given service.
|
|
func (c *Client) SetCharm(cfg SetCharmConfig) error {
|
|
func (c *Client) SetCharm(cfg SetCharmConfig) error {
|
|
args := params.ApplicationSetCharm{
|
|
args := params.ApplicationSetCharm{
|
|
- ApplicationName: cfg.ServiceName,
|
|
+ ApplicationName: cfg.ApplicationName,
|
|
CharmUrl: cfg.CharmID.URL.String(),
|
|
CharmUrl: cfg.CharmID.URL.String(),
|
|
Channel: string(cfg.CharmID.Channel),
|
|
Channel: string(cfg.CharmID.Channel),
|
|
ForceSeries: cfg.ForceSeries,
|
|
ForceSeries: cfg.ForceSeries,
|
|
|
@@ -161,17 +161,17 @@ func (c *Client) SetCharm(cfg SetCharmConfig) error { |
|
return c.facade.FacadeCall("SetCharm", args, nil)
|
|
return c.facade.FacadeCall("SetCharm", args, nil)
|
|
}
|
|
}
|
|
|
|
|
|
-// Update updates the service attributes, including charm URL,
|
|
+// Update updates the application attributes, including charm URL,
|
|
// minimum number of units, settings and constraints.
|
|
// minimum number of units, settings and constraints.
|
|
func (c *Client) Update(args params.ApplicationUpdate) error {
|
|
func (c *Client) Update(args params.ApplicationUpdate) error {
|
|
return c.facade.FacadeCall("Update", args, nil)
|
|
return c.facade.FacadeCall("Update", args, nil)
|
|
}
|
|
}
|
|
|
|
|
|
-// AddUnits adds a given number of units to a service using the specified
|
|
+// AddUnits adds a given number of units to an application using the specified
|
|
// placement directives to assign units to machines.
|
|
// placement directives to assign units to machines.
|
|
-func (c *Client) AddUnits(service string, numUnits int, placement []*instance.Placement) ([]string, error) {
|
|
+func (c *Client) AddUnits(application string, numUnits int, placement []*instance.Placement) ([]string, error) {
|
|
args := params.AddApplicationUnits{
|
|
args := params.AddApplicationUnits{
|
|
- ApplicationName: service,
|
|
+ ApplicationName: application,
|
|
NumUnits: numUnits,
|
|
NumUnits: numUnits,
|
|
Placement: placement,
|
|
Placement: placement,
|
|
}
|
|
}
|
|
|
@@ -180,80 +180,80 @@ func (c *Client) AddUnits(service string, numUnits int, placement []*instance.Pl |
|
return results.Units, err
|
|
return results.Units, err
|
|
}
|
|
}
|
|
|
|
|
|
-// DestroyUnits decreases the number of units dedicated to a service.
|
|
+// DestroyUnits decreases the number of units dedicated to an application.
|
|
func (c *Client) DestroyUnits(unitNames ...string) error {
|
|
func (c *Client) DestroyUnits(unitNames ...string) error {
|
|
params := params.DestroyApplicationUnits{unitNames}
|
|
params := params.DestroyApplicationUnits{unitNames}
|
|
return c.facade.FacadeCall("DestroyUnits", params, nil)
|
|
return c.facade.FacadeCall("DestroyUnits", params, nil)
|
|
}
|
|
}
|
|
|
|
|
|
-// Destroy destroys a given service.
|
|
+// Destroy destroys a given application.
|
|
-func (c *Client) Destroy(service string) error {
|
|
+func (c *Client) Destroy(application string) error {
|
|
params := params.ApplicationDestroy{
|
|
params := params.ApplicationDestroy{
|
|
- ApplicationName: service,
|
|
+ ApplicationName: application,
|
|
}
|
|
}
|
|
return c.facade.FacadeCall("Destroy", params, nil)
|
|
return c.facade.FacadeCall("Destroy", params, nil)
|
|
}
|
|
}
|
|
|
|
|
|
-// GetConstraints returns the constraints for the given service.
|
|
+// GetConstraints returns the constraints for the given application.
|
|
func (c *Client) GetConstraints(service string) (constraints.Value, error) {
|
|
func (c *Client) GetConstraints(service string) (constraints.Value, error) {
|
|
results := new(params.GetConstraintsResults)
|
|
results := new(params.GetConstraintsResults)
|
|
err := c.facade.FacadeCall("GetConstraints", params.GetApplicationConstraints{service}, results)
|
|
err := c.facade.FacadeCall("GetConstraints", params.GetApplicationConstraints{service}, results)
|
|
return results.Constraints, err
|
|
return results.Constraints, err
|
|
}
|
|
}
|
|
|
|
|
|
-// SetConstraints specifies the constraints for the given service.
|
|
+// SetConstraints specifies the constraints for the given application.
|
|
-func (c *Client) SetConstraints(service string, constraints constraints.Value) error {
|
|
+func (c *Client) SetConstraints(application string, constraints constraints.Value) error {
|
|
params := params.SetConstraints{
|
|
params := params.SetConstraints{
|
|
- ApplicationName: service,
|
|
+ ApplicationName: application,
|
|
Constraints: constraints,
|
|
Constraints: constraints,
|
|
}
|
|
}
|
|
return c.facade.FacadeCall("SetConstraints", params, nil)
|
|
return c.facade.FacadeCall("SetConstraints", params, nil)
|
|
}
|
|
}
|
|
|
|
|
|
// Expose changes the juju-managed firewall to expose any ports that
|
|
// Expose changes the juju-managed firewall to expose any ports that
|
|
// were also explicitly marked by units as open.
|
|
// were also explicitly marked by units as open.
|
|
-func (c *Client) Expose(service string) error {
|
|
+func (c *Client) Expose(application string) error {
|
|
- params := params.ApplicationExpose{ApplicationName: service}
|
|
+ params := params.ApplicationExpose{ApplicationName: application}
|
|
return c.facade.FacadeCall("Expose", params, nil)
|
|
return c.facade.FacadeCall("Expose", params, nil)
|
|
}
|
|
}
|
|
|
|
|
|
// Unexpose changes the juju-managed firewall to unexpose any ports that
|
|
// Unexpose changes the juju-managed firewall to unexpose any ports that
|
|
// were also explicitly marked by units as open.
|
|
// were also explicitly marked by units as open.
|
|
-func (c *Client) Unexpose(service string) error {
|
|
+func (c *Client) Unexpose(application string) error {
|
|
- params := params.ApplicationUnexpose{ApplicationName: service}
|
|
+ params := params.ApplicationUnexpose{ApplicationName: application}
|
|
return c.facade.FacadeCall("Unexpose", params, nil)
|
|
return c.facade.FacadeCall("Unexpose", params, nil)
|
|
}
|
|
}
|
|
|
|
|
|
-// Get returns the configuration for the named service.
|
|
+// Get returns the configuration for the named application.
|
|
-func (c *Client) Get(service string) (*params.ApplicationGetResults, error) {
|
|
+func (c *Client) Get(application string) (*params.ApplicationGetResults, error) {
|
|
var results params.ApplicationGetResults
|
|
var results params.ApplicationGetResults
|
|
- params := params.ApplicationGet{ApplicationName: service}
|
|
+ params := params.ApplicationGet{ApplicationName: application}
|
|
err := c.facade.FacadeCall("Get", params, &results)
|
|
err := c.facade.FacadeCall("Get", params, &results)
|
|
return &results, err
|
|
return &results, err
|
|
}
|
|
}
|
|
|
|
|
|
-// Set sets configuration options on a service.
|
|
+// Set sets configuration options on an application.
|
|
-func (c *Client) Set(service string, options map[string]string) error {
|
|
+func (c *Client) Set(application string, options map[string]string) error {
|
|
p := params.ApplicationSet{
|
|
p := params.ApplicationSet{
|
|
- ApplicationName: service,
|
|
+ ApplicationName: application,
|
|
Options: options,
|
|
Options: options,
|
|
}
|
|
}
|
|
return c.facade.FacadeCall("Set", p, nil)
|
|
return c.facade.FacadeCall("Set", p, nil)
|
|
}
|
|
}
|
|
|
|
|
|
-// Unset resets configuration options on a service.
|
|
+// Unset resets configuration options on an application.
|
|
-func (c *Client) Unset(service string, options []string) error {
|
|
+func (c *Client) Unset(application string, options []string) error {
|
|
p := params.ApplicationUnset{
|
|
p := params.ApplicationUnset{
|
|
- ApplicationName: service,
|
|
+ ApplicationName: application,
|
|
Options: options,
|
|
Options: options,
|
|
}
|
|
}
|
|
return c.facade.FacadeCall("Unset", p, nil)
|
|
return c.facade.FacadeCall("Unset", p, nil)
|
|
}
|
|
}
|
|
|
|
|
|
-// CharmRelations returns the service's charms relation names.
|
|
+// CharmRelations returns the application's charms relation names.
|
|
-func (c *Client) CharmRelations(service string) ([]string, error) {
|
|
+func (c *Client) CharmRelations(application string) ([]string, error) {
|
|
var results params.ApplicationCharmRelationsResults
|
|
var results params.ApplicationCharmRelationsResults
|
|
- params := params.ApplicationCharmRelations{ApplicationName: service}
|
|
+ params := params.ApplicationCharmRelations{ApplicationName: application}
|
|
err := c.facade.FacadeCall("CharmRelations", params, &results)
|
|
err := c.facade.FacadeCall("CharmRelations", params, &results)
|
|
return results.CharmRelations, err
|
|
return results.CharmRelations, err
|
|
}
|
|
}
|
|
|
|