github.com/makyo/juju@v0.0.0-20160425123129-2608902037e9/apiserver/params/params.go (about)

     1  // Copyright 2013 Canonical Ltd.
     2  // Licensed under the AGPLv3, see LICENCE file for details.
     3  
     4  package params
     5  
     6  import (
     7  	"fmt"
     8  	"strings"
     9  	"time"
    10  
    11  	"github.com/juju/errors"
    12  	"github.com/juju/loggo"
    13  	"github.com/juju/replicaset"
    14  	"github.com/juju/utils/proxy"
    15  	"github.com/juju/utils/ssh"
    16  	"github.com/juju/version"
    17  	"gopkg.in/juju/charm.v6-unstable"
    18  	"gopkg.in/macaroon.v1"
    19  
    20  	"github.com/juju/juju/constraints"
    21  	"github.com/juju/juju/instance"
    22  	"github.com/juju/juju/mongo"
    23  	"github.com/juju/juju/network"
    24  	"github.com/juju/juju/state/multiwatcher"
    25  	"github.com/juju/juju/storage"
    26  	"github.com/juju/juju/tools"
    27  )
    28  
    29  // FindTags wraps a slice of strings that are prefixes to use when
    30  // searching for matching tags.
    31  type FindTags struct {
    32  	Prefixes []string `json:"prefixes"`
    33  }
    34  
    35  // FindTagsResults wraps the mapping between the requested prefix and the
    36  // matching tags for each requested prefix.
    37  type FindTagsResults struct {
    38  	Matches map[string][]Entity `json:"matches"`
    39  }
    40  
    41  // Entity identifies a single entity.
    42  type Entity struct {
    43  	Tag string
    44  }
    45  
    46  // Entities identifies multiple entities.
    47  type Entities struct {
    48  	Entities []Entity
    49  }
    50  
    51  // EntityPasswords holds the parameters for making a SetPasswords call.
    52  type EntityPasswords struct {
    53  	Changes []EntityPassword
    54  }
    55  
    56  // EntityPassword specifies a password change for the entity
    57  // with the given tag.
    58  type EntityPassword struct {
    59  	Tag      string
    60  	Password string
    61  }
    62  
    63  // ErrorResults holds the results of calling a bulk operation which
    64  // returns no data, only an error result. The order and
    65  // number of elements matches the operations specified in the request.
    66  type ErrorResults struct {
    67  	// Results contains the error results from each operation.
    68  	Results []ErrorResult
    69  }
    70  
    71  // OneError returns the error from the result
    72  // of a bulk operation on a single value.
    73  func (result ErrorResults) OneError() error {
    74  	if n := len(result.Results); n != 1 {
    75  		return fmt.Errorf("expected 1 result, got %d", n)
    76  	}
    77  	if err := result.Results[0].Error; err != nil {
    78  		return err
    79  	}
    80  	return nil
    81  }
    82  
    83  // Combine returns one error from the result which is an accumulation of the
    84  // errors. If there are no errors in the result, the return value is nil.
    85  // Otherwise the error values are combined with new-line characters.
    86  func (result ErrorResults) Combine() error {
    87  	var errorStrings []string
    88  	for _, r := range result.Results {
    89  		if r.Error != nil {
    90  			errorStrings = append(errorStrings, r.Error.Error())
    91  		}
    92  	}
    93  	if errorStrings != nil {
    94  		return errors.New(strings.Join(errorStrings, "\n"))
    95  	}
    96  	return nil
    97  }
    98  
    99  // ErrorResult holds the error status of a single operation.
   100  type ErrorResult struct {
   101  	Error *Error
   102  }
   103  
   104  // AddRelation holds the parameters for making the AddRelation call.
   105  // The endpoints specified are unordered.
   106  type AddRelation struct {
   107  	Endpoints []string
   108  }
   109  
   110  // AddRelationResults holds the results of a AddRelation call. The Endpoints
   111  // field maps service names to the involved endpoints.
   112  type AddRelationResults struct {
   113  	Endpoints map[string]charm.Relation
   114  }
   115  
   116  // DestroyRelation holds the parameters for making the DestroyRelation call.
   117  // The endpoints specified are unordered.
   118  type DestroyRelation struct {
   119  	Endpoints []string
   120  }
   121  
   122  // AddCharm holds the arguments for making an AddCharm API call.
   123  type AddCharm struct {
   124  	URL     string
   125  	Channel string
   126  }
   127  
   128  // AddCharmWithAuthorization holds the arguments for making an AddCharmWithAuthorization API call.
   129  type AddCharmWithAuthorization struct {
   130  	URL                string
   131  	Channel            string
   132  	CharmStoreMacaroon *macaroon.Macaroon
   133  }
   134  
   135  // AddMachineParams encapsulates the parameters used to create a new machine.
   136  type AddMachineParams struct {
   137  	// The following fields hold attributes that will be given to the
   138  	// new machine when it is created.
   139  	Series      string                    `json:"Series"`
   140  	Constraints constraints.Value         `json:"Constraints"`
   141  	Jobs        []multiwatcher.MachineJob `json:"Jobs"`
   142  
   143  	// Disks describes constraints for disks that must be attached to
   144  	// the machine when it is provisioned.
   145  	Disks []storage.Constraints `json:"Disks"`
   146  
   147  	// If Placement is non-nil, it contains a placement directive
   148  	// that will be used to decide how to instantiate the machine.
   149  	Placement *instance.Placement `json:"Placement"`
   150  
   151  	// If ParentId is non-empty, it specifies the id of the
   152  	// parent machine within which the new machine will
   153  	// be created. In that case, ContainerType must also be
   154  	// set.
   155  	ParentId string `json:"ParentId"`
   156  
   157  	// ContainerType optionally gives the container type of the
   158  	// new machine. If it is non-empty, the new machine
   159  	// will be implemented by a container. If it is specified
   160  	// but ParentId is empty, a new top level machine will
   161  	// be created to hold the container with given series,
   162  	// constraints and jobs.
   163  	ContainerType instance.ContainerType `json:"ContainerType"`
   164  
   165  	// If InstanceId is non-empty, it will be associated with
   166  	// the new machine along with the given nonce,
   167  	// hardware characteristics and addresses.
   168  	// All the following fields will be ignored if ContainerType
   169  	// is set.
   170  	InstanceId              instance.Id                      `json:"InstanceId"`
   171  	Nonce                   string                           `json:"Nonce"`
   172  	HardwareCharacteristics instance.HardwareCharacteristics `json:"HardwareCharacteristics"`
   173  	Addrs                   []Address                        `json:"Addrs"`
   174  }
   175  
   176  // AddMachines holds the parameters for making the AddMachines call.
   177  type AddMachines struct {
   178  	MachineParams []AddMachineParams `json:"MachineParams"`
   179  }
   180  
   181  // AddMachinesResults holds the results of an AddMachines call.
   182  type AddMachinesResults struct {
   183  	Machines []AddMachinesResult `json:"Machines"`
   184  }
   185  
   186  // AddMachinesResult holds the name of a machine added by the
   187  // api.client.AddMachine call for a single machine.
   188  type AddMachinesResult struct {
   189  	Machine string `json:"Machine"`
   190  	Error   *Error `json:"Error"`
   191  }
   192  
   193  // DestroyMachines holds parameters for the DestroyMachines call.
   194  type DestroyMachines struct {
   195  	MachineNames []string
   196  	Force        bool
   197  }
   198  
   199  // ServicesDeploy holds the parameters for deploying one or more services.
   200  type ServicesDeploy struct {
   201  	Services []ServiceDeploy
   202  }
   203  
   204  // ServiceDeploy holds the parameters for making the service Deploy call.
   205  type ServiceDeploy struct {
   206  	ServiceName      string
   207  	Series           string
   208  	CharmUrl         string
   209  	Channel          string
   210  	NumUnits         int
   211  	Config           map[string]string
   212  	ConfigYAML       string // Takes precedence over config if both are present.
   213  	Constraints      constraints.Value
   214  	Placement        []*instance.Placement
   215  	Storage          map[string]storage.Constraints
   216  	EndpointBindings map[string]string
   217  	Resources        map[string]string
   218  }
   219  
   220  // ServiceUpdate holds the parameters for making the service Update call.
   221  type ServiceUpdate struct {
   222  	ServiceName     string
   223  	CharmUrl        string
   224  	ForceCharmUrl   bool
   225  	ForceSeries     bool
   226  	MinUnits        *int
   227  	SettingsStrings map[string]string
   228  	SettingsYAML    string // Takes precedence over SettingsStrings if both are present.
   229  	Constraints     *constraints.Value
   230  }
   231  
   232  // ServiceSetCharm sets the charm for a given service.
   233  type ServiceSetCharm struct {
   234  	// ServiceName is the name of the service to set the charm on.
   235  	ServiceName string `json:"servicename"`
   236  	// CharmUrl is the new url for the charm.
   237  	CharmUrl string `json:"charmurl"`
   238  	// Channel is the charm store channel from which the charm came.
   239  	Channel string `json:"cs-channel"`
   240  	// ForceUnits forces the upgrade on units in an error state.
   241  	ForceUnits bool `json:"forceunits"`
   242  	// ForceSeries forces the use of the charm even if it doesn't match the
   243  	// series of the unit.
   244  	ForceSeries bool `json:"forceseries"`
   245  	// ResourceIDs is a map of resource names to resource IDs to activate during
   246  	// the upgrade.
   247  	ResourceIDs map[string]string `json:"resourceids"`
   248  }
   249  
   250  // ServiceExpose holds the parameters for making the service Expose call.
   251  type ServiceExpose struct {
   252  	ServiceName string
   253  }
   254  
   255  // ServiceSet holds the parameters for a service Set
   256  // command. Options contains the configuration data.
   257  type ServiceSet struct {
   258  	ServiceName string
   259  	Options     map[string]string
   260  }
   261  
   262  // ServiceUnset holds the parameters for a service Unset
   263  // command. Options contains the option attribute names
   264  // to unset.
   265  type ServiceUnset struct {
   266  	ServiceName string
   267  	Options     []string
   268  }
   269  
   270  // ServiceGet holds parameters for making the Get or
   271  // GetCharmURL calls.
   272  type ServiceGet struct {
   273  	ServiceName string
   274  }
   275  
   276  // ServiceGetResults holds results of the service Get call.
   277  type ServiceGetResults struct {
   278  	Service     string
   279  	Charm       string
   280  	Config      map[string]interface{}
   281  	Constraints constraints.Value
   282  }
   283  
   284  // ServiceCharmRelations holds parameters for making the service CharmRelations call.
   285  type ServiceCharmRelations struct {
   286  	ServiceName string
   287  }
   288  
   289  // ServiceCharmRelationsResults holds the results of the service CharmRelations call.
   290  type ServiceCharmRelationsResults struct {
   291  	CharmRelations []string
   292  }
   293  
   294  // ServiceUnexpose holds parameters for the service Unexpose call.
   295  type ServiceUnexpose struct {
   296  	ServiceName string
   297  }
   298  
   299  // ServiceMetricCredential holds parameters for the SetServiceCredentials call.
   300  type ServiceMetricCredential struct {
   301  	ServiceName       string
   302  	MetricCredentials []byte
   303  }
   304  
   305  // ServiceMetricCredentials holds multiple ServiceMetricCredential parameters.
   306  type ServiceMetricCredentials struct {
   307  	Creds []ServiceMetricCredential
   308  }
   309  
   310  // PublicAddress holds parameters for the PublicAddress call.
   311  type PublicAddress struct {
   312  	Target string
   313  }
   314  
   315  // PublicAddressResults holds results of the PublicAddress call.
   316  type PublicAddressResults struct {
   317  	PublicAddress string
   318  }
   319  
   320  // PrivateAddress holds parameters for the PrivateAddress call.
   321  type PrivateAddress struct {
   322  	Target string
   323  }
   324  
   325  // PrivateAddressResults holds results of the PrivateAddress call.
   326  type PrivateAddressResults struct {
   327  	PrivateAddress string
   328  }
   329  
   330  // Resolved holds parameters for the Resolved call.
   331  type Resolved struct {
   332  	UnitName string
   333  	Retry    bool
   334  }
   335  
   336  // ResolvedResults holds results of the Resolved call.
   337  type ResolvedResults struct {
   338  	Service  string
   339  	Charm    string
   340  	Settings map[string]interface{}
   341  }
   342  
   343  // AddServiceUnitsResults holds the names of the units added by the
   344  // AddUnits call.
   345  type AddServiceUnitsResults struct {
   346  	Units []string
   347  }
   348  
   349  // AddServiceUnits holds parameters for the AddUnits call.
   350  type AddServiceUnits struct {
   351  	ServiceName string
   352  	NumUnits    int
   353  	Placement   []*instance.Placement
   354  }
   355  
   356  // DestroyServiceUnits holds parameters for the DestroyUnits call.
   357  type DestroyServiceUnits struct {
   358  	UnitNames []string
   359  }
   360  
   361  // ServiceDestroy holds the parameters for making the service Destroy call.
   362  type ServiceDestroy struct {
   363  	ServiceName string
   364  }
   365  
   366  // Creds holds credentials for identifying an entity.
   367  type Creds struct {
   368  	AuthTag  string
   369  	Password string
   370  	Nonce    string
   371  }
   372  
   373  // LoginRequest holds credentials for identifying an entity to the Login v1
   374  // facade. AuthTag holds the tag of the user to connect as. If it is empty,
   375  // then the provided macaroon slices will be used for authentication (if
   376  // any one is valid, the authentication succeeds). If there are no
   377  // valid macaroons and macaroon authentication is configured,
   378  // the LoginResponse will contain a macaroon that when
   379  // discharged, may allow access.
   380  type LoginRequest struct {
   381  	AuthTag     string           `json:"auth-tag"`
   382  	Credentials string           `json:"credentials"`
   383  	Nonce       string           `json:"nonce"`
   384  	Macaroons   []macaroon.Slice `json:"macaroons"`
   385  }
   386  
   387  // LoginRequestCompat holds credentials for identifying an entity to the Login v1
   388  // or earlier (v0 or even pre-facade).
   389  type LoginRequestCompat struct {
   390  	LoginRequest
   391  	Creds
   392  }
   393  
   394  // GetAnnotationsResults holds annotations associated with an entity.
   395  type GetAnnotationsResults struct {
   396  	Annotations map[string]string
   397  }
   398  
   399  // GetAnnotations stores parameters for making the GetAnnotations call.
   400  type GetAnnotations struct {
   401  	Tag string
   402  }
   403  
   404  // SetAnnotations stores parameters for making the SetAnnotations call.
   405  type SetAnnotations struct {
   406  	Tag   string
   407  	Pairs map[string]string
   408  }
   409  
   410  // GetServiceConstraints stores parameters for making the GetServiceConstraints call.
   411  type GetServiceConstraints struct {
   412  	ServiceName string
   413  }
   414  
   415  // GetConstraintsResults holds results of the GetConstraints call.
   416  type GetConstraintsResults struct {
   417  	Constraints constraints.Value
   418  }
   419  
   420  // SetConstraints stores parameters for making the SetConstraints call.
   421  type SetConstraints struct {
   422  	ServiceName string //optional, if empty, model constraints are set.
   423  	Constraints constraints.Value
   424  }
   425  
   426  // ResolveCharms stores charm references for a ResolveCharms call.
   427  type ResolveCharms struct {
   428  	References []charm.URL
   429  }
   430  
   431  // ResolveCharmResult holds the result of resolving a charm reference to a URL, or any error that occurred.
   432  type ResolveCharmResult struct {
   433  	URL   *charm.URL `json:",omitempty"`
   434  	Error string     `json:",omitempty"`
   435  }
   436  
   437  // ResolveCharmResults holds results of the ResolveCharms call.
   438  type ResolveCharmResults struct {
   439  	URLs []ResolveCharmResult
   440  }
   441  
   442  // AllWatcherId holds the id of an AllWatcher.
   443  type AllWatcherId struct {
   444  	AllWatcherId string
   445  }
   446  
   447  // AllWatcherNextResults holds deltas returned from calling AllWatcher.Next().
   448  type AllWatcherNextResults struct {
   449  	Deltas []multiwatcher.Delta
   450  }
   451  
   452  // ListSSHKeys stores parameters used for a KeyManager.ListKeys call.
   453  type ListSSHKeys struct {
   454  	Entities
   455  	Mode ssh.ListMode
   456  }
   457  
   458  // ModifyUserSSHKeys stores parameters used for a KeyManager.Add|Delete|Import call for a user.
   459  type ModifyUserSSHKeys struct {
   460  	User string
   461  	Keys []string
   462  }
   463  
   464  // StateServingInfo holds information needed by a state
   465  // server.
   466  type StateServingInfo struct {
   467  	APIPort   int
   468  	StatePort int
   469  	// The controller cert and corresponding private key.
   470  	Cert       string
   471  	PrivateKey string
   472  	// The private key for the CA cert so that a new controller
   473  	// cert can be generated when needed.
   474  	CAPrivateKey string
   475  	// this will be passed as the KeyFile argument to MongoDB
   476  	SharedSecret   string
   477  	SystemIdentity string
   478  }
   479  
   480  // IsMasterResult holds the result of an IsMaster API call.
   481  type IsMasterResult struct {
   482  	// Master reports whether the connected agent
   483  	// lives on the same instance as the mongo replica
   484  	// set master.
   485  	Master bool
   486  }
   487  
   488  // ContainerManagerConfigParams contains the parameters for the
   489  // ContainerManagerConfig provisioner API call.
   490  type ContainerManagerConfigParams struct {
   491  	Type instance.ContainerType
   492  }
   493  
   494  // ContainerManagerConfig contains information from the model config
   495  // that is needed for configuring the container manager.
   496  type ContainerManagerConfig struct {
   497  	ManagerConfig map[string]string
   498  }
   499  
   500  // UpdateBehavior contains settings that are duplicated in several
   501  // places. Let's just embed this instead.
   502  type UpdateBehavior struct {
   503  	EnableOSRefreshUpdate bool
   504  	EnableOSUpgrade       bool
   505  }
   506  
   507  // ContainerConfig contains information from the model config that is
   508  // needed for container cloud-init.
   509  type ContainerConfig struct {
   510  	ProviderType            string
   511  	AuthorizedKeys          string
   512  	SSLHostnameVerification bool
   513  	Proxy                   proxy.Settings
   514  	AptProxy                proxy.Settings
   515  	AptMirror               string
   516  	PreferIPv6              bool
   517  	AllowLXCLoopMounts      bool
   518  	*UpdateBehavior
   519  }
   520  
   521  // ProvisioningScriptParams contains the parameters for the
   522  // ProvisioningScript client API call.
   523  type ProvisioningScriptParams struct {
   524  	MachineId string
   525  	Nonce     string
   526  
   527  	// DataDir may be "", in which case the default will be used.
   528  	DataDir string
   529  
   530  	// DisablePackageCommands may be set to disable all
   531  	// package-related commands. It is then the responsibility of the
   532  	// provisioner to ensure that all the packages required by Juju
   533  	// are available.
   534  	DisablePackageCommands bool
   535  }
   536  
   537  // ProvisioningScriptResult contains the result of the
   538  // ProvisioningScript client API call.
   539  type ProvisioningScriptResult struct {
   540  	Script string
   541  }
   542  
   543  // DeployerConnectionValues containers the result of deployer.ConnectionInfo
   544  // API call.
   545  type DeployerConnectionValues struct {
   546  	StateAddresses []string
   547  	APIAddresses   []string
   548  }
   549  
   550  // JobsResult holds the jobs for a machine that are returned by a call to Jobs.
   551  type JobsResult struct {
   552  	Jobs  []multiwatcher.MachineJob `json:"Jobs"`
   553  	Error *Error                    `json:"Error"`
   554  }
   555  
   556  // JobsResults holds the result of a call to Jobs.
   557  type JobsResults struct {
   558  	Results []JobsResult `json:"Results"`
   559  }
   560  
   561  // DistributionGroupResult contains the result of
   562  // the DistributionGroup provisioner API call.
   563  type DistributionGroupResult struct {
   564  	Error  *Error
   565  	Result []instance.Id
   566  }
   567  
   568  // DistributionGroupResults is the bulk form of
   569  // DistributionGroupResult.
   570  type DistributionGroupResults struct {
   571  	Results []DistributionGroupResult
   572  }
   573  
   574  // FacadeVersions describes the available Facades and what versions of each one
   575  // are available
   576  type FacadeVersions struct {
   577  	Name     string
   578  	Versions []int
   579  }
   580  
   581  // LoginResult holds the result of a Login call.
   582  type LoginResult struct {
   583  	Servers        [][]HostPort     `json:"Servers"`
   584  	ModelTag       string           `json:"ModelTag"`
   585  	LastConnection *time.Time       `json:"LastConnection"`
   586  	Facades        []FacadeVersions `json:"Facades"`
   587  }
   588  
   589  // ReauthRequest holds a challenge/response token meaningful to the identity
   590  // provider.
   591  type ReauthRequest struct {
   592  	Prompt string `json:"prompt"`
   593  	Nonce  string `json:"nonce"`
   594  }
   595  
   596  // AuthUserInfo describes a logged-in local user or remote identity.
   597  type AuthUserInfo struct {
   598  	DisplayName    string     `json:"display-name"`
   599  	Identity       string     `json:"identity"`
   600  	LastConnection *time.Time `json:"last-connection,omitempty"`
   601  
   602  	// Credentials contains an optional opaque credential value to be held by
   603  	// the client, if any.
   604  	Credentials *string `json:"credentials,omitempty"`
   605  }
   606  
   607  // LoginResultV1 holds the result of an Admin v1 Login call.
   608  type LoginResultV1 struct {
   609  	// DischargeRequired implies that the login request has failed, and none of
   610  	// the other fields are populated. It contains a macaroon which, when
   611  	// discharged, will grant access on a subsequent call to Login.
   612  	// Note: It is OK to use the Macaroon type here as it is explicitely
   613  	// designed to provide stable serialisation of macaroons.  It's good
   614  	// practice to only use primitives in types that will be serialised,
   615  	// however because of the above it is suitable to use the Macaroon type
   616  	// here.
   617  	DischargeRequired *macaroon.Macaroon `json:"discharge-required,omitempty"`
   618  
   619  	// DischargeRequiredReason holds the reason that the above discharge was
   620  	// required.
   621  	DischargeRequiredReason string `json:"discharge-required-error,omitempty"`
   622  
   623  	// Servers is the list of API server addresses.
   624  	Servers [][]HostPort `json:"servers,omitempty"`
   625  
   626  	// ModelTag is the tag for the model that is being connected to.
   627  	ModelTag string `json:"model-tag,omitempty"`
   628  
   629  	// ControllerTag is the tag for the model that holds the API servers.
   630  	// This is the initial model created when bootstrapping juju.
   631  	ControllerTag string `json:"server-tag,omitempty"`
   632  
   633  	// UserInfo describes the authenticated user, if any.
   634  	UserInfo *AuthUserInfo `json:"user-info,omitempty"`
   635  
   636  	// Facades describes all the available API facade versions to the
   637  	// authenticated client.
   638  	Facades []FacadeVersions `json:"facades,omitempty"`
   639  
   640  	// ServerVersion is the string representation of the server version
   641  	// if the server supports it.
   642  	ServerVersion string `json:"server-version,omitempty"`
   643  }
   644  
   645  // ControllersServersSpec contains arguments for
   646  // the EnableHA client API call.
   647  type ControllersSpec struct {
   648  	ModelTag       string
   649  	NumControllers int               `json:"num-controllers"`
   650  	Constraints    constraints.Value `json:"constraints,omitempty"`
   651  	// Series is the series to associate with new controller machines.
   652  	// If this is empty, then the model's default series is used.
   653  	Series string `json:"series,omitempty"`
   654  	// Placement defines specific machines to become new controller machines.
   655  	Placement []string `json:"placement,omitempty"`
   656  }
   657  
   658  // ControllersServersSpecs contains all the arguments
   659  // for the EnableHA API call.
   660  type ControllersSpecs struct {
   661  	Specs []ControllersSpec
   662  }
   663  
   664  // ControllersChangeResult contains the results
   665  // of a single EnableHA API call or
   666  // an error.
   667  type ControllersChangeResult struct {
   668  	Result ControllersChanges
   669  	Error  *Error
   670  }
   671  
   672  // ControllersChangeResults contains the results
   673  // of the EnableHA API call.
   674  type ControllersChangeResults struct {
   675  	Results []ControllersChangeResult
   676  }
   677  
   678  // ControllersChanges lists the servers
   679  // that have been added, removed or maintained in the
   680  // pool as a result of an enable-ha operation.
   681  type ControllersChanges struct {
   682  	Added      []string `json:"added,omitempty"`
   683  	Maintained []string `json:"maintained,omitempty"`
   684  	Removed    []string `json:"removed,omitempty"`
   685  	Promoted   []string `json:"promoted,omitempty"`
   686  	Demoted    []string `json:"demoted,omitempty"`
   687  	Converted  []string `json:"converted,omitempty"`
   688  }
   689  
   690  // FindToolsParams defines parameters for the FindTools method.
   691  type FindToolsParams struct {
   692  	// Number will be used to match tools versions exactly if non-zero.
   693  	Number version.Number
   694  
   695  	// MajorVersion will be used to match the major version if non-zero.
   696  	MajorVersion int
   697  
   698  	// MinorVersion will be used to match the major version if greater
   699  	// than or equal to zero, and Number is zero.
   700  	MinorVersion int
   701  
   702  	// Arch will be used to match tools by architecture if non-empty.
   703  	Arch string
   704  
   705  	// Series will be used to match tools by series if non-empty.
   706  	Series string
   707  }
   708  
   709  // FindToolsResult holds a list of tools from FindTools and any error.
   710  type FindToolsResult struct {
   711  	List  tools.List
   712  	Error *Error
   713  }
   714  
   715  // ImageFilterParams holds the parameters used to specify images to delete.
   716  type ImageFilterParams struct {
   717  	Images []ImageSpec `json:"images"`
   718  }
   719  
   720  // ImageSpec defines the parameters to select images list or delete.
   721  type ImageSpec struct {
   722  	Kind   string `json:"kind"`
   723  	Arch   string `json:"arch"`
   724  	Series string `json:"series"`
   725  }
   726  
   727  // ListImageResult holds the results of querying images.
   728  type ListImageResult struct {
   729  	Result []ImageMetadata `json:"result"`
   730  }
   731  
   732  // ImageMetadata represents an image in storage.
   733  type ImageMetadata struct {
   734  	Kind    string    `json:"kind"`
   735  	Arch    string    `json:"arch"`
   736  	Series  string    `json:"series"`
   737  	URL     string    `json:"url"`
   738  	Created time.Time `json:"created"`
   739  }
   740  
   741  // RebootActionResults holds a list of RebootActionResult and any error.
   742  type RebootActionResults struct {
   743  	Results []RebootActionResult `json:"results,omitempty"`
   744  }
   745  
   746  // RebootActionResult holds the result of a single call to
   747  // machine.ShouldRebootOrShutdown.
   748  type RebootActionResult struct {
   749  	Result RebootAction `json:"result,omitempty"`
   750  	Error  *Error       `json:"error,omitempty"`
   751  }
   752  
   753  // LogRecord is used to transmit log messages to the logsink API
   754  // endpoint.  Single character field names are used for serialisation
   755  // to keep the size down. These messages are going to be sent a lot.
   756  type LogRecord struct {
   757  	Time     time.Time   `json:"t"`
   758  	Module   string      `json:"m"`
   759  	Location string      `json:"l"`
   760  	Level    loggo.Level `json:"v"`
   761  	Message  string      `json:"x"`
   762  }
   763  
   764  // GetBundleChangesParams holds parameters for making GetBundleChanges calls.
   765  type GetBundleChangesParams struct {
   766  	// BundleDataYAML is the YAML-encoded charm bundle data
   767  	// (see "github.com/juju/charm.BundleData").
   768  	BundleDataYAML string `json:"yaml"`
   769  }
   770  
   771  // GetBundleChangesResults holds results of the GetBundleChanges call.
   772  type GetBundleChangesResults struct {
   773  	// Changes holds the list of changes required to deploy the bundle.
   774  	// It is omitted if the provided bundle YAML has verification errors.
   775  	Changes []*BundleChangesChange `json:"changes,omitempty"`
   776  	// Errors holds possible bundle verification errors.
   777  	Errors []string `json:"errors,omitempty"`
   778  }
   779  
   780  // BundleChangesChange holds a single change required to deploy a bundle.
   781  type BundleChangesChange struct {
   782  	// Id is the unique identifier for this change.
   783  	Id string `json:"id"`
   784  	// Method is the action to be performed to apply this change.
   785  	Method string `json:"method"`
   786  	// Args holds a list of arguments to pass to the method.
   787  	Args []interface{} `json:"args"`
   788  	// Requires holds a list of dependencies for this change. Each dependency
   789  	// is represented by the corresponding change id, and must be applied
   790  	// before this change is applied.
   791  	Requires []string `json:"requires"`
   792  }
   793  
   794  // UpgradeMongoParams holds the arguments required to
   795  // enter upgrade mongo mode.
   796  type UpgradeMongoParams struct {
   797  	Target mongo.Version
   798  }
   799  
   800  // HAMember holds information that identifies one member
   801  // of HA.
   802  type HAMember struct {
   803  	Tag           string
   804  	PublicAddress network.Address
   805  	Series        string
   806  }
   807  
   808  // MongoUpgradeResults holds the results of an attempt
   809  // to enter upgrade mongo mode.
   810  type MongoUpgradeResults struct {
   811  	RsMembers []replicaset.Member
   812  	Master    HAMember
   813  	Members   []HAMember
   814  }
   815  
   816  // ResumeReplicationParams holds the members of a HA that
   817  // must be resumed.
   818  type ResumeReplicationParams struct {
   819  	Members []replicaset.Member
   820  }
   821  
   822  // MeterStatusParam holds meter status information to be set for the specified tag.
   823  type MeterStatusParam struct {
   824  	Tag  string `json:"tag"`
   825  	Code string `json:"code"`
   826  	Info string `json:"info, omitempty"`
   827  }
   828  
   829  // MeterStatusParams holds parameters for making SetMeterStatus calls.
   830  type MeterStatusParams struct {
   831  	Statuses []MeterStatusParam `json:"statues"`
   832  }
   833  
   834  // MacaroonResults contains a set of MacaroonResults.
   835  type MacaroonResults struct {
   836  	Results []MacaroonResult `json:"results"`
   837  }
   838  
   839  // MacaroonResult contains a macaroon or an error.
   840  type MacaroonResult struct {
   841  	Result *macaroon.Macaroon `json:"result,omitempty"`
   842  	Error  *Error             `json:"error,omitempty"`
   843  }