Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename api params and other artifacts from service to application #5497

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
16 changes: 8 additions & 8 deletions api/action/client.go
Expand Up @@ -91,20 +91,20 @@ func (c *Client) Cancel(arg params.Actions) (params.ActionResults, error) {
return results, err return results, err
} }


// servicesCharmActions is a batched query for the charm.Actions for a slice // applicationsCharmsActions is a batched query for the charm.Actions for a slice
// of services by Entity. // of services by Entity.
func (c *Client) servicesCharmActions(arg params.Entities) (params.ServicesCharmActionsResults, error) { func (c *Client) applicationsCharmsActions(arg params.Entities) (params.ApplicationsCharmActionsResults, error) {
results := params.ServicesCharmActionsResults{} results := params.ApplicationsCharmActionsResults{}
err := c.facade.FacadeCall("ServicesCharmActions", arg, &results) err := c.facade.FacadeCall("ApplicationsCharmsActions", arg, &results)
return results, err return results, err
} }


// ServiceCharmActions is a single query which uses ServicesCharmActions to // ApplicationCharmActions is a single query which uses ApplicationsCharmsActions to
// get the charm.Actions for a single Service by tag. // get the charm.Actions for a single Service by tag.
func (c *Client) ServiceCharmActions(arg params.Entity) (*charm.Actions, error) { func (c *Client) ApplicationCharmActions(arg params.Entity) (*charm.Actions, error) {
none := &charm.Actions{} none := &charm.Actions{}
tags := params.Entities{Entities: []params.Entity{{Tag: arg.Tag}}} tags := params.Entities{Entities: []params.Entity{{Tag: arg.Tag}}}
results, err := c.servicesCharmActions(tags) results, err := c.applicationsCharmsActions(tags)
if err != nil { if err != nil {
return none, err return none, err
} }
Expand All @@ -116,7 +116,7 @@ func (c *Client) ServiceCharmActions(arg params.Entity) (*charm.Actions, error)
return none, result.Error return none, result.Error
} }
if result.ApplicationTag != arg.Tag { if result.ApplicationTag != arg.Tag {
return none, errors.Errorf("action results received for wrong service %q", result.ApplicationTag) return none, errors.Errorf("action results received for wrong application %q", result.ApplicationTag)
} }
return result.Actions, nil return result.Actions, nil
} }
28 changes: 14 additions & 14 deletions api/action/client_test.go
Expand Up @@ -27,24 +27,24 @@ func (s *actionSuite) TestClient(c *gc.C) {
c.Check(facade.Name(), gc.Equals, "Action") c.Check(facade.Name(), gc.Equals, "Action")
} }


func (s *actionSuite) TestServiceCharmActions(c *gc.C) { func (s *actionSuite) TestApplicationCharmActions(c *gc.C) {
tests := []struct { tests := []struct {
description string description string
patchResults []params.ServiceCharmActionsResult patchResults []params.ApplicationCharmActionsResult
patchErr string patchErr string
expectedErr string expectedErr string
expectedResult *charm.Actions expectedResult *charm.Actions
}{{ }{{
description: "result from wrong service", description: "result from wrong service",
patchResults: []params.ServiceCharmActionsResult{ patchResults: []params.ApplicationCharmActionsResult{
{ {
ApplicationTag: names.NewApplicationTag("bar").String(), ApplicationTag: names.NewApplicationTag("bar").String(),
}, },
}, },
expectedErr: `action results received for wrong service "application-bar"`, expectedErr: `action results received for wrong application "application-bar"`,
}, { }, {
description: "some other error", description: "some other error",
patchResults: []params.ServiceCharmActionsResult{ patchResults: []params.ApplicationCharmActionsResult{
{ {
ApplicationTag: names.NewApplicationTag("foo").String(), ApplicationTag: names.NewApplicationTag("foo").String(),
Error: &params.Error{ Error: &params.Error{
Expand All @@ -55,22 +55,22 @@ func (s *actionSuite) TestServiceCharmActions(c *gc.C) {
expectedErr: `something bad`, expectedErr: `something bad`,
}, { }, {
description: "more than one result", description: "more than one result",
patchResults: []params.ServiceCharmActionsResult{ patchResults: []params.ApplicationCharmActionsResult{
{}, {},
{}, {},
}, },
expectedErr: "2 results, expected 1", expectedErr: "2 results, expected 1",
}, { }, {
description: "no results", description: "no results",
patchResults: []params.ServiceCharmActionsResult{}, patchResults: []params.ApplicationCharmActionsResult{},
expectedErr: "0 results, expected 1", expectedErr: "0 results, expected 1",
}, { }, {
description: "error on facade call", description: "error on facade call",
patchErr: "something went wrong", patchErr: "something went wrong",
expectedErr: "something went wrong", expectedErr: "something went wrong",
}, { }, {
description: "normal result", description: "normal result",
patchResults: []params.ServiceCharmActionsResult{ patchResults: []params.ApplicationCharmActionsResult{
{ {
ApplicationTag: names.NewApplicationTag("foo").String(), ApplicationTag: names.NewApplicationTag("foo").String(),
Actions: &charm.Actions{ Actions: &charm.Actions{
Expand Down Expand Up @@ -101,9 +101,9 @@ func (s *actionSuite) TestServiceCharmActions(c *gc.C) {
// anonymous func to properly trigger defer // anonymous func to properly trigger defer
func() { func() {
c.Logf("test %d: %s", i, t.description) c.Logf("test %d: %s", i, t.description)
cleanup := patchServiceCharmActions(c, s.client, t.patchResults, t.patchErr) cleanup := patchApplicationCharmActions(c, s.client, t.patchResults, t.patchErr)
defer cleanup() defer cleanup()
result, err := s.client.ServiceCharmActions(params.Entity{Tag: names.NewApplicationTag("foo").String()}) result, err := s.client.ApplicationCharmActions(params.Entity{Tag: names.NewApplicationTag("foo").String()})
if t.expectedErr != "" { if t.expectedErr != "" {
c.Check(err, gc.ErrorMatches, t.expectedErr) c.Check(err, gc.ErrorMatches, t.expectedErr)
} else { } else {
Expand All @@ -114,16 +114,16 @@ func (s *actionSuite) TestServiceCharmActions(c *gc.C) {
} }
} }


// replace "ServicesCharmActions" facade call with required results and error // replace sCharmActions" facade call with required results and error
// if desired // if desired
func patchServiceCharmActions(c *gc.C, apiCli *action.Client, patchResults []params.ServiceCharmActionsResult, err string) func() { func patchApplicationCharmActions(c *gc.C, apiCli *action.Client, patchResults []params.ApplicationCharmActionsResult, err string) func() {
return action.PatchClientFacadeCall(apiCli, return action.PatchClientFacadeCall(apiCli,
func(req string, paramsIn interface{}, resp interface{}) error { func(req string, paramsIn interface{}, resp interface{}) error {
c.Assert(req, gc.Equals, "ServicesCharmActions") c.Assert(req, gc.Equals, "ApplicationsCharmsActions")
c.Assert(paramsIn, gc.FitsTypeOf, params.Entities{}) c.Assert(paramsIn, gc.FitsTypeOf, params.Entities{})
p := paramsIn.(params.Entities) p := paramsIn.(params.Entities)
c.Check(p.Entities, gc.HasLen, 1) c.Check(p.Entities, gc.HasLen, 1)
result := resp.(*params.ServicesCharmActionsResults) result := resp.(*params.ApplicationsCharmActionsResults)
result.Results = patchResults result.Results = patchResults
if err != "" { if err != "" {
return errors.New(err) return errors.New(err)
Expand Down
90 changes: 45 additions & 45 deletions api/service/client.go → api/application/client.go
@@ -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"
Expand All @@ -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 {
Expand All @@ -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},
Expand Down Expand Up @@ -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
Expand All @@ -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
} }
Expand All @@ -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),
Expand Down Expand Up @@ -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
Expand All @@ -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,
Expand All @@ -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,
} }
Expand All @@ -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
} }
Expand Down