Skip to content

Commit

Permalink
Rename api params and other artifacts from service to application
Browse files Browse the repository at this point in the history
  • Loading branch information
wallyworld committed May 31, 2016
1 parent 588a7d0 commit ab54543
Show file tree
Hide file tree
Showing 369 changed files with 4,114 additions and 4,137 deletions.
16 changes: 8 additions & 8 deletions api/action/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,20 +91,20 @@ func (c *Client) Cancel(arg params.Actions) (params.ActionResults, error) {
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.
func (c *Client) servicesCharmActions(arg params.Entities) (params.ServicesCharmActionsResults, error) {
results := params.ServicesCharmActionsResults{}
err := c.facade.FacadeCall("ServicesCharmActions", arg, &results)
func (c *Client) applicationsCharmsActions(arg params.Entities) (params.ApplicationsCharmActionsResults, error) {
results := params.ApplicationsCharmActionsResults{}
err := c.facade.FacadeCall("ApplicationsCharmsActions", arg, &results)
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.
func (c *Client) ServiceCharmActions(arg params.Entity) (*charm.Actions, error) {
func (c *Client) ApplicationCharmActions(arg params.Entity) (*charm.Actions, error) {
none := &charm.Actions{}
tags := params.Entities{Entities: []params.Entity{{Tag: arg.Tag}}}
results, err := c.servicesCharmActions(tags)
results, err := c.applicationsCharmsActions(tags)
if err != nil {
return none, err
}
Expand All @@ -116,7 +116,7 @@ func (c *Client) ServiceCharmActions(arg params.Entity) (*charm.Actions, error)
return none, result.Error
}
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
}
28 changes: 14 additions & 14 deletions api/action/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,24 +27,24 @@ func (s *actionSuite) TestClient(c *gc.C) {
c.Check(facade.Name(), gc.Equals, "Action")
}

func (s *actionSuite) TestServiceCharmActions(c *gc.C) {
func (s *actionSuite) TestApplicationCharmActions(c *gc.C) {
tests := []struct {
description string
patchResults []params.ServiceCharmActionsResult
patchResults []params.ApplicationCharmActionsResult
patchErr string
expectedErr string
expectedResult *charm.Actions
}{{
description: "result from wrong service",
patchResults: []params.ServiceCharmActionsResult{
patchResults: []params.ApplicationCharmActionsResult{
{
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",
patchResults: []params.ServiceCharmActionsResult{
patchResults: []params.ApplicationCharmActionsResult{
{
ApplicationTag: names.NewApplicationTag("foo").String(),
Error: &params.Error{
Expand All @@ -55,22 +55,22 @@ func (s *actionSuite) TestServiceCharmActions(c *gc.C) {
expectedErr: `something bad`,
}, {
description: "more than one result",
patchResults: []params.ServiceCharmActionsResult{
patchResults: []params.ApplicationCharmActionsResult{
{},
{},
},
expectedErr: "2 results, expected 1",
}, {
description: "no results",
patchResults: []params.ServiceCharmActionsResult{},
patchResults: []params.ApplicationCharmActionsResult{},
expectedErr: "0 results, expected 1",
}, {
description: "error on facade call",
patchErr: "something went wrong",
expectedErr: "something went wrong",
}, {
description: "normal result",
patchResults: []params.ServiceCharmActionsResult{
patchResults: []params.ApplicationCharmActionsResult{
{
ApplicationTag: names.NewApplicationTag("foo").String(),
Actions: &charm.Actions{
Expand Down Expand Up @@ -101,9 +101,9 @@ func (s *actionSuite) TestServiceCharmActions(c *gc.C) {
// anonymous func to properly trigger defer
func() {
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()
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 != "" {
c.Check(err, gc.ErrorMatches, t.expectedErr)
} 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
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,
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{})
p := paramsIn.(params.Entities)
c.Check(p.Entities, gc.HasLen, 1)
result := resp.(*params.ServicesCharmActionsResults)
result := resp.(*params.ApplicationsCharmActionsResults)
result.Results = patchResults
if err != "" {
return errors.New(err)
Expand Down
90 changes: 45 additions & 45 deletions api/service/client.go → api/application/client.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// Copyright 2014 Canonical Ltd.
// Licensed under the AGPLv3, see LICENCE file for details.

// Package service provides access to the service api facade.
// This facade contains api calls that are specific to services.
// As a rule of thumb, if the argument for an api requries a service name
// and affects only that service then the call belongs here.
package service
// Package application provides access to the application api facade.
// This facade contains api calls that are specific to applications.
// As a rule of thumb, if the argument for an api requires an application name
// and affects only that application then the call belongs here.
package application

import (
"github.com/juju/errors"
Expand All @@ -21,7 +21,7 @@ import (
"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.
type Client struct {
Expand All @@ -30,13 +30,13 @@ type Client struct {
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 {
frontend, backend := base.NewClientFacade(st, "Service")
frontend, backend := base.NewClientFacade(st, "Application")
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 {
creds := []params.ApplicationMetricCredential{
{service, credentials},
Expand Down Expand Up @@ -64,15 +64,15 @@ func (c *Client) ModelUUID() string {
type DeployArgs struct {
// CharmID identifies the charm to deploy.
CharmID charmstore.CharmID
// ServiceName is the name to give the service.
ServiceName string
// ApplicationName is the name to give the application.
ApplicationName string
// Series to be used for the machine.
Series string
// NumUnits is the number of units to deploy.
NumUnits int
// ConfigYAML is a string that overrides the default config.yml.
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.
Cons constraints.Value
// 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
// EndpointBindings
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.
Resources map[string]string
}
Expand All @@ -94,7 +94,7 @@ type DeployArgs struct {
func (c *Client) Deploy(args DeployArgs) error {
deployArgs := params.ApplicationsDeploy{
Applications: []params.ApplicationDeploy{{
ApplicationName: args.ServiceName,
ApplicationName: args.ApplicationName,
Series: args.Series,
CharmUrl: args.CharmID.URL.String(),
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
// on a service.
type SetCharmConfig struct {
// ServiceName is the name of the service to set the charm on.
ServiceName string
// ApplicationName is the name of the application to set the charm on.
ApplicationName string
// CharmID identifies the charm.
CharmID charmstore.CharmID
// 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.
func (c *Client) SetCharm(cfg SetCharmConfig) error {
args := params.ApplicationSetCharm{
ApplicationName: cfg.ServiceName,
ApplicationName: cfg.ApplicationName,
CharmUrl: cfg.CharmID.URL.String(),
Channel: string(cfg.CharmID.Channel),
ForceSeries: cfg.ForceSeries,
Expand All @@ -161,17 +161,17 @@ func (c *Client) SetCharm(cfg SetCharmConfig) error {
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.
func (c *Client) Update(args params.ApplicationUpdate) error {
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.
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{
ApplicationName: service,
ApplicationName: application,
NumUnits: numUnits,
Placement: placement,
}
Expand All @@ -180,80 +180,80 @@ func (c *Client) AddUnits(service string, numUnits int, placement []*instance.Pl
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 {
params := params.DestroyApplicationUnits{unitNames}
return c.facade.FacadeCall("DestroyUnits", params, nil)
}

// Destroy destroys a given service.
func (c *Client) Destroy(service string) error {
// Destroy destroys a given application.
func (c *Client) Destroy(application string) error {
params := params.ApplicationDestroy{
ApplicationName: service,
ApplicationName: application,
}
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) {
results := new(params.GetConstraintsResults)
err := c.facade.FacadeCall("GetConstraints", params.GetApplicationConstraints{service}, results)
return results.Constraints, err
}

// SetConstraints specifies the constraints for the given service.
func (c *Client) SetConstraints(service string, constraints constraints.Value) error {
// SetConstraints specifies the constraints for the given application.
func (c *Client) SetConstraints(application string, constraints constraints.Value) error {
params := params.SetConstraints{
ApplicationName: service,
ApplicationName: application,
Constraints: constraints,
}
return c.facade.FacadeCall("SetConstraints", params, nil)
}

// Expose changes the juju-managed firewall to expose any ports that
// were also explicitly marked by units as open.
func (c *Client) Expose(service string) error {
params := params.ApplicationExpose{ApplicationName: service}
func (c *Client) Expose(application string) error {
params := params.ApplicationExpose{ApplicationName: application}
return c.facade.FacadeCall("Expose", params, nil)
}

// Unexpose changes the juju-managed firewall to unexpose any ports that
// were also explicitly marked by units as open.
func (c *Client) Unexpose(service string) error {
params := params.ApplicationUnexpose{ApplicationName: service}
func (c *Client) Unexpose(application string) error {
params := params.ApplicationUnexpose{ApplicationName: application}
return c.facade.FacadeCall("Unexpose", params, nil)
}

// Get returns the configuration for the named service.
func (c *Client) Get(service string) (*params.ApplicationGetResults, error) {
// Get returns the configuration for the named application.
func (c *Client) Get(application string) (*params.ApplicationGetResults, error) {
var results params.ApplicationGetResults
params := params.ApplicationGet{ApplicationName: service}
params := params.ApplicationGet{ApplicationName: application}
err := c.facade.FacadeCall("Get", params, &results)
return &results, err
}

// Set sets configuration options on a service.
func (c *Client) Set(service string, options map[string]string) error {
// Set sets configuration options on an application.
func (c *Client) Set(application string, options map[string]string) error {
p := params.ApplicationSet{
ApplicationName: service,
ApplicationName: application,
Options: options,
}
return c.facade.FacadeCall("Set", p, nil)
}

// Unset resets configuration options on a service.
func (c *Client) Unset(service string, options []string) error {
// Unset resets configuration options on an application.
func (c *Client) Unset(application string, options []string) error {
p := params.ApplicationUnset{
ApplicationName: service,
ApplicationName: application,
Options: options,
}
return c.facade.FacadeCall("Unset", p, nil)
}

// CharmRelations returns the service's charms relation names.
func (c *Client) CharmRelations(service string) ([]string, error) {
// CharmRelations returns the application's charms relation names.
func (c *Client) CharmRelations(application string) ([]string, error) {
var results params.ApplicationCharmRelationsResults
params := params.ApplicationCharmRelations{ApplicationName: service}
params := params.ApplicationCharmRelations{ApplicationName: application}
err := c.facade.FacadeCall("CharmRelations", params, &results)
return results.CharmRelations, err
}
Expand Down
Loading

0 comments on commit ab54543

Please sign in to comment.