github.com/axw/juju@v0.0.0-20161005053422-4bd6544d08d4/apiserver/params/model.go (about)

     1  // Copyright 2015 Canonical Ltd.
     2  // Licensed under the AGPLv3, see LICENCE file for details.
     3  
     4  package params
     5  
     6  import (
     7  	"time"
     8  
     9  	"github.com/juju/version"
    10  )
    11  
    12  // ConfigValue encapsulates a configuration
    13  // value and its source.
    14  type ConfigValue struct {
    15  	Value  interface{} `json:"value"`
    16  	Source string      `json:"source"`
    17  }
    18  
    19  // ModelConfigResults contains the result of client API calls
    20  // to get model config values.
    21  type ModelConfigResults struct {
    22  	Config map[string]ConfigValue `json:"config"`
    23  }
    24  
    25  // HostedModelConfig contains the model config and the cloud spec
    26  // for the model, both things that a client needs to talk directly
    27  // with the provider. This is used to take down mis-behaving models
    28  // aggressively.
    29  type HostedModelConfig struct {
    30  	Name      string                 `json:"name"`
    31  	OwnerTag  string                 `json:"owner"`
    32  	Config    map[string]interface{} `json:"config,omitempty"`
    33  	CloudSpec *CloudSpec             `json:"cloud-spec,omitempty"`
    34  	Error     *Error                 `json:"error,omitempty"`
    35  }
    36  
    37  // HostedModelConfigsResults contains an entry for each hosted model
    38  // in the controller.
    39  type HostedModelConfigsResults struct {
    40  	Models []HostedModelConfig `json:"models"`
    41  }
    42  
    43  // ModelDefaultsResult contains the result of client API calls to get the
    44  // model default values.
    45  type ModelDefaultsResult struct {
    46  	Config map[string]ModelDefaults `json:"config"`
    47  }
    48  
    49  // ModelDefaults holds the settings for a given ModelDefaultsResult config
    50  // attribute.
    51  type ModelDefaults struct {
    52  	Default    interface{}      `json:"default,omitempty"`
    53  	Controller interface{}      `json:"controller,omitempty"`
    54  	Regions    []RegionDefaults `json:"regions,omitempty"`
    55  }
    56  
    57  // RegionDefaults contains the settings for regions in a ModelDefaults.
    58  type RegionDefaults struct {
    59  	RegionName string      `json:"region-name"`
    60  	Value      interface{} `json:"value"`
    61  }
    62  
    63  // ModelSet contains the arguments for ModelSet client API
    64  // call.
    65  type ModelSet struct {
    66  	Config map[string]interface{} `json:"config"`
    67  }
    68  
    69  // ModelUnset contains the arguments for ModelUnset client API
    70  // call.
    71  type ModelUnset struct {
    72  	Keys []string `json:"keys"`
    73  }
    74  
    75  // SetModelDefaults contains the arguments for SetModelDefaults
    76  // client API call.
    77  type SetModelDefaults struct {
    78  	Config []ModelDefaultValues `json:"config"`
    79  }
    80  
    81  // ModelDefaultValues contains the default model values for
    82  // a cloud/region.
    83  type ModelDefaultValues struct {
    84  	CloudTag    string                 `json:"cloud-tag,omitempty"`
    85  	CloudRegion string                 `json:"cloud-region,omitempty"`
    86  	Config      map[string]interface{} `json:"config"`
    87  }
    88  
    89  // ModelUnsetKeys contains the config keys to unset for
    90  // a cloud/region.
    91  type ModelUnsetKeys struct {
    92  	CloudTag    string   `json:"cloud-tag,omitempty"`
    93  	CloudRegion string   `json:"cloud-region,omitempty"`
    94  	Keys        []string `json:"keys"`
    95  }
    96  
    97  // UnsetModelDefaults contains the arguments for UnsetModelDefaults
    98  // client API call.
    99  type UnsetModelDefaults struct {
   100  	Keys []ModelUnsetKeys `json:"keys"`
   101  }
   102  
   103  // SetModelAgentVersion contains the arguments for
   104  // SetModelAgentVersion client API call.
   105  type SetModelAgentVersion struct {
   106  	Version version.Number `json:"version"`
   107  }
   108  
   109  // ModelInfo holds information about the Juju model.
   110  type ModelInfo struct {
   111  	Name               string `json:"name"`
   112  	UUID               string `json:"uuid"`
   113  	ControllerUUID     string `json:"controller-uuid"`
   114  	ProviderType       string `json:"provider-type"`
   115  	DefaultSeries      string `json:"default-series"`
   116  	CloudTag           string `json:"cloud-tag"`
   117  	CloudRegion        string `json:"cloud-region,omitempty"`
   118  	CloudCredentialTag string `json:"cloud-credential-tag,omitempty"`
   119  
   120  	// OwnerTag is the tag of the user that owns the model.
   121  	OwnerTag string `json:"owner-tag"`
   122  
   123  	// Life is the current lifecycle state of the model.
   124  	Life Life `json:"life"`
   125  
   126  	// Status is the current status of the model.
   127  	Status EntityStatus `json:"status"`
   128  
   129  	// Users contains information about the users that have access
   130  	// to the model. Owners and administrators can see all users
   131  	// that have access; other users can only see their own details.
   132  	Users []ModelUserInfo `json:"users"`
   133  
   134  	// Machines contains information about the machines in the model.
   135  	// This information is available to owners and users with write
   136  	// access or greater.
   137  	Machines []ModelMachineInfo `json:"machines"`
   138  }
   139  
   140  // ModelInfoResult holds the result of a ModelInfo call.
   141  type ModelInfoResult struct {
   142  	Result *ModelInfo `json:"result,omitempty"`
   143  	Error  *Error     `json:"error,omitempty"`
   144  }
   145  
   146  // ModelInfoResult holds the result of a bulk ModelInfo call.
   147  type ModelInfoResults struct {
   148  	Results []ModelInfoResult `json:"results"`
   149  }
   150  
   151  // ModelInfoList holds a list of ModelInfo structures.
   152  type ModelInfoList struct {
   153  	Models []ModelInfo `json:"models,omitempty"`
   154  }
   155  
   156  // ModelInfoListResult holds the result of a call that returns a list
   157  // of ModelInfo structures.
   158  type ModelInfoListResult struct {
   159  	Result *ModelInfoList `json:"result,omitempty"`
   160  	Error  *Error         `json:"error,omitempty"`
   161  }
   162  
   163  // ModelInfoListResults holds the result of a bulk call that returns
   164  // multiple lists of ModelInfo structures.
   165  type ModelInfoListResults struct {
   166  	Results []ModelInfoListResult `json:"results"`
   167  }
   168  
   169  // ModelMachineInfo holds information about a machine in a model.
   170  type ModelMachineInfo struct {
   171  	Id         string           `json:"id"`
   172  	Hardware   *MachineHardware `json:"hardware,omitempty"`
   173  	InstanceId string           `json:"instance-id,omitempty"`
   174  	Status     string           `json:"status,omitempty"`
   175  	HasVote    bool             `json:"has-vote,omitempty"`
   176  	WantsVote  bool             `json:"wants-vote,omitempty"`
   177  }
   178  
   179  // MachineHardware holds information about a machine's hardware characteristics.
   180  type MachineHardware struct {
   181  	Arch             *string   `json:"arch,omitempty"`
   182  	Mem              *uint64   `json:"mem,omitempty"`
   183  	RootDisk         *uint64   `json:"root-disk,omitempty"`
   184  	Cores            *uint64   `json:"cores,omitempty"`
   185  	CpuPower         *uint64   `json:"cpu-power,omitempty"`
   186  	Tags             *[]string `json:"tags,omitempty"`
   187  	AvailabilityZone *string   `json:"availability-zone,omitempty"`
   188  }
   189  
   190  // ModelUserInfo holds information on a user who has access to a
   191  // model. Owners of a model can see this information for all users
   192  // who have access, so it should not include sensitive information.
   193  type ModelUserInfo struct {
   194  	UserName       string               `json:"user"`
   195  	DisplayName    string               `json:"display-name"`
   196  	LastConnection *time.Time           `json:"last-connection"`
   197  	Access         UserAccessPermission `json:"access"`
   198  }
   199  
   200  // ModelUserInfoResult holds the result of an ModelUserInfo call.
   201  type ModelUserInfoResult struct {
   202  	Result *ModelUserInfo `json:"result,omitempty"`
   203  	Error  *Error         `json:"error,omitempty"`
   204  }
   205  
   206  // ModelUserInfoResults holds the result of a bulk ModelUserInfo API call.
   207  type ModelUserInfoResults struct {
   208  	Results []ModelUserInfoResult `json:"results"`
   209  }
   210  
   211  // ModifyModelAccessRequest holds the parameters for making grant and revoke model calls.
   212  type ModifyModelAccessRequest struct {
   213  	Changes []ModifyModelAccess `json:"changes"`
   214  }
   215  
   216  type ModifyModelAccess struct {
   217  	UserTag  string               `json:"user-tag"`
   218  	Action   ModelAction          `json:"action"`
   219  	Access   UserAccessPermission `json:"access"`
   220  	ModelTag string               `json:"model-tag"`
   221  }
   222  
   223  // ModelAction is an action that can be performed on a model.
   224  type ModelAction string
   225  
   226  // Actions that can be preformed on a model.
   227  const (
   228  	GrantModelAccess  ModelAction = "grant"
   229  	RevokeModelAccess ModelAction = "revoke"
   230  )
   231  
   232  // UserAccessPermission is the type of permission that a user has to access a
   233  // model.
   234  type UserAccessPermission string
   235  
   236  // Model access permissions that may be set on a user.
   237  const (
   238  	ModelAdminAccess UserAccessPermission = "admin"
   239  	ModelReadAccess  UserAccessPermission = "read"
   240  	ModelWriteAccess UserAccessPermission = "write"
   241  )