github.com/niedbalski/juju@v0.0.0-20190215020005-8ff100488e47/apiserver/params/charms.go (about)

     1  // Copyright 2015 Canonical Ltd.
     2  // Licensed under the AGPLv3, see LICENCE file for details.
     3  
     4  package params
     5  
     6  // ApplicationCharmResults contains a set of ApplicationCharmResults.
     7  type ApplicationCharmResults struct {
     8  	Results []ApplicationCharmResult `json:"results"`
     9  }
    10  
    11  // ApplicationCharmResult contains an ApplicationCharm or an error.
    12  type ApplicationCharmResult struct {
    13  	Result *ApplicationCharm `json:"result,omitempty"`
    14  	Error  *Error            `json:"error,omitempty"`
    15  }
    16  
    17  // ApplicationCharmInfo contains information about an
    18  // application's charm.
    19  type ApplicationCharm struct {
    20  	// URL holds the URL of the charm assigned to the
    21  	// application.
    22  	URL string `json:"url"`
    23  
    24  	// ForceUpgrade indicates whether or not application
    25  	// units should upgrade to the charm even if they
    26  	// are in an error state.
    27  	ForceUpgrade bool `json:"force-upgrade,omitempty"`
    28  
    29  	// SHA256 holds the SHA256 hash of the charm archive.
    30  	SHA256 string `json:"sha256"`
    31  
    32  	// CharmModifiedVersion increases when the charm changes in some way.
    33  	CharmModifiedVersion int `json:"charm-modified-version"`
    34  }
    35  
    36  // CharmsList stores parameters for a charms.List call
    37  type CharmsList struct {
    38  	Names []string `json:"names"`
    39  }
    40  
    41  // CharmsListResult stores result from a charms.List call
    42  type CharmsListResult struct {
    43  	CharmURLs []string `json:"charm-urls"`
    44  }
    45  
    46  // IsMeteredResult stores result from a charms.IsMetered call
    47  type IsMeteredResult struct {
    48  	Metered bool `json:"metered"`
    49  }
    50  
    51  // CharmOption mirrors charm.Option
    52  type CharmOption struct {
    53  	Type        string      `json:"type"`
    54  	Description string      `json:"description,omitempty"`
    55  	Default     interface{} `json:"default,omitempty"`
    56  }
    57  
    58  // CharmRelation mirrors charm.Relation.
    59  type CharmRelation struct {
    60  	Name      string `json:"name"`
    61  	Role      string `json:"role"`
    62  	Interface string `json:"interface"`
    63  	Optional  bool   `json:"optional"`
    64  	Limit     int    `json:"limit"`
    65  	Scope     string `json:"scope"`
    66  }
    67  
    68  // CharmStorage mirrors charm.Storage.
    69  type CharmStorage struct {
    70  	Name        string   `json:"name"`
    71  	Description string   `json:"description"`
    72  	Type        string   `json:"type"`
    73  	Shared      bool     `json:"shared"`
    74  	ReadOnly    bool     `json:"read-only"`
    75  	CountMin    int      `json:"count-min"`
    76  	CountMax    int      `json:"count-max"`
    77  	MinimumSize uint64   `json:"minimum-size"`
    78  	Location    string   `json:"location,omitempty"`
    79  	Properties  []string `json:"properties,omitempty"`
    80  }
    81  
    82  // CharmDevice mirrors charm.Device.
    83  type CharmDevice struct {
    84  	Name        string `bson:"name"`
    85  	Description string `bson:"description"`
    86  	Type        string `bson:"type"`
    87  	CountMin    int64  `bson:"count-min"`
    88  	CountMax    int64  `bson:"count-max"`
    89  }
    90  
    91  // CharmPayloadClass mirrors charm.PayloadClass.
    92  type CharmPayloadClass struct {
    93  	Name string `json:"name"`
    94  	Type string `json:"type"`
    95  }
    96  
    97  // CharmResourceMeta mirrors charm.ResourceMeta.
    98  type CharmResourceMeta struct {
    99  	Name        string `json:"name"`
   100  	Type        string `json:"type"`
   101  	Path        string `json:"path"`
   102  	Description string `json:"description"`
   103  }
   104  
   105  // CharmMeta mirrors charm.Meta.
   106  type CharmMeta struct {
   107  	Name           string                       `json:"name"`
   108  	Summary        string                       `json:"summary"`
   109  	Description    string                       `json:"description"`
   110  	Subordinate    bool                         `json:"subordinate"`
   111  	Provides       map[string]CharmRelation     `json:"provides,omitempty"`
   112  	Requires       map[string]CharmRelation     `json:"requires,omitempty"`
   113  	Peers          map[string]CharmRelation     `json:"peers,omitempty"`
   114  	ExtraBindings  map[string]string            `json:"extra-bindings,omitempty"`
   115  	Categories     []string                     `json:"categories,omitempty"`
   116  	Tags           []string                     `json:"tags,omitempty"`
   117  	Series         []string                     `json:"series,omitempty"`
   118  	Storage        map[string]CharmStorage      `json:"storage,omitempty"`
   119  	Devices        map[string]CharmDevice       `json:"devices,omitempty"`
   120  	PayloadClasses map[string]CharmPayloadClass `json:"payload-classes,omitempty"`
   121  	Resources      map[string]CharmResourceMeta `json:"resources,omitempty"`
   122  	Terms          []string                     `json:"terms,omitempty"`
   123  	MinJujuVersion string                       `json:"min-juju-version,omitempty"`
   124  }
   125  
   126  // CharmInfo holds all the charm data that the client needs.
   127  // To be honest, it probably returns way more than what is actually needed.
   128  type CharmInfo struct {
   129  	Revision   int                    `json:"revision"`
   130  	URL        string                 `json:"url"`
   131  	Config     map[string]CharmOption `json:"config"`
   132  	Meta       *CharmMeta             `json:"meta,omitempty"`
   133  	Actions    *CharmActions          `json:"actions,omitempty"`
   134  	Metrics    *CharmMetrics          `json:"metrics,omitempty"`
   135  	LXDProfile *CharmLXDProfile       `json:"lxd-profile,omitempty"`
   136  }
   137  
   138  // CharmActions mirrors charm.Actions.
   139  type CharmActions struct {
   140  	ActionSpecs map[string]CharmActionSpec `json:"specs,omitempty"`
   141  }
   142  
   143  // CharmActionSpec mirrors charm.ActionSpec.
   144  type CharmActionSpec struct {
   145  	Description string                 `json:"description"`
   146  	Params      map[string]interface{} `json:"params"`
   147  }
   148  
   149  // CharmMetric mirrors charm.Metric.
   150  type CharmMetric struct {
   151  	Type        string `json:"type"`
   152  	Description string `json:"description"`
   153  }
   154  
   155  // CharmPlan mirrors charm.Plan
   156  type CharmPlan struct {
   157  	Required bool `json:"required"`
   158  }
   159  
   160  // CharmMetrics mirrors charm.Metrics.
   161  type CharmMetrics struct {
   162  	Metrics map[string]CharmMetric `json:"metrics"`
   163  	Plan    CharmPlan              `json:"plan"`
   164  }
   165  
   166  // CharmLXDProfile mirrors charm.LXDProfile
   167  type CharmLXDProfile struct {
   168  	Config      map[string]string            `json:"config"`
   169  	Description string                       `json:"description"`
   170  	Devices     map[string]map[string]string `json:"devices"`
   171  }
   172  
   173  // CharmLXDProfileResult returns the result of finding the CharmLXDProfile
   174  type CharmLXDProfileResult struct {
   175  	LXDProfile *CharmLXDProfile `json:"lxd-profile"`
   176  }
   177  
   178  // ContainerLXDProfile contains the charm.LXDProfile information in addition to
   179  // the name of the profile.
   180  type ContainerLXDProfile struct {
   181  	Profile CharmLXDProfile `json:"profile" yaml:"profile"`
   182  	Name    string          `json:"name" yaml:"name"`
   183  }
   184  
   185  // ContainerProfileResult returns the result of finding the CharmLXDProfile and name of
   186  // the lxd profile to be used for 1 unit on the container
   187  type ContainerProfileResult struct {
   188  	Error       *Error                 `json:"error,omitempty"`
   189  	LXDProfiles []*ContainerLXDProfile `json:"lxd-profiles,omitempty"`
   190  }
   191  
   192  // ContainerProfileResults returns the ContainerProfileResult for each unit to be placed
   193  // on the container.
   194  type ContainerProfileResults struct {
   195  	Results []ContainerProfileResult `json:"results"`
   196  }