github.com/makyo/juju@v0.0.0-20160425123129-2608902037e9/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  // ModelConfigResults contains the result of client API calls
    13  // to get model config values.
    14  type ModelConfigResults struct {
    15  	Config map[string]interface{}
    16  }
    17  
    18  // ModelSet contains the arguments for ModelSet client API
    19  // call.
    20  type ModelSet struct {
    21  	Config map[string]interface{}
    22  }
    23  
    24  // ModelUnset contains the arguments for ModelUnset client API
    25  // call.
    26  type ModelUnset struct {
    27  	Keys []string
    28  }
    29  
    30  // SetModelAgentVersion contains the arguments for
    31  // SetModelAgentVersion client API call.
    32  type SetModelAgentVersion struct {
    33  	Version version.Number
    34  }
    35  
    36  // ModelInfo holds information about the Juju model.
    37  type ModelInfo struct {
    38  	// The json names for the fields below are as per the older
    39  	// field names for backward compatability. New fields are
    40  	// camel-cased for consistency within this type only.
    41  	Name           string `json:"Name"`
    42  	UUID           string `json:"UUID"`
    43  	ControllerUUID string `json:"ServerUUID"`
    44  	ProviderType   string `json:"ProviderType"`
    45  	DefaultSeries  string `json:"DefaultSeries"`
    46  
    47  	// OwnerTag is the tag of the user that owns the model.
    48  	OwnerTag string `json:"OwnerTag"`
    49  
    50  	// Life is the current lifecycle state of the model.
    51  	Life Life `json:"Life"`
    52  
    53  	// Status is the current status of the model.
    54  	Status EntityStatus `json:"Status"`
    55  
    56  	// Users contains information about the users that have access
    57  	// to the model. Owners and administrators can see all users
    58  	// that have access; other users can only see their own details.
    59  	Users []ModelUserInfo `json:"Users"`
    60  }
    61  
    62  // ModelInfoResult holds the result of a ModelInfo call.
    63  type ModelInfoResult struct {
    64  	Result *ModelInfo `json:"result,omitempty"`
    65  	Error  *Error     `json:"error,omitempty"`
    66  }
    67  
    68  // ModelInfoResult holds the result of a bulk ModelInfo call.
    69  type ModelInfoResults struct {
    70  	Results []ModelInfoResult `json:"results"`
    71  }
    72  
    73  // ModelInfoList holds a list of ModelInfo structures.
    74  type ModelInfoList struct {
    75  	Models []ModelInfo `json:"models,omitempty"`
    76  }
    77  
    78  // ModelInfoListResult holds the result of a call that returns a list
    79  // of ModelInfo structures.
    80  type ModelInfoListResult struct {
    81  	Result *ModelInfoList `json:"result,omitempty"`
    82  	Error  *Error         `json:"error,omitempty"`
    83  }
    84  
    85  // ModelInfoListResults holds the result of a bulk call that returns
    86  // multiple lists of ModelInfo structures.
    87  type ModelInfoListResults struct {
    88  	Results []ModelInfoListResult `json:"results"`
    89  }
    90  
    91  // ModelUserInfo holds information on a user who has access to a
    92  // model. Owners of a model can see this information for all users
    93  // who have access, so it should not include sensitive information.
    94  type ModelUserInfo struct {
    95  	UserName       string                `json:"user"`
    96  	DisplayName    string                `json:"displayname"`
    97  	LastConnection *time.Time            `json:"lastconnection"`
    98  	Access         ModelAccessPermission `json:"access"`
    99  }
   100  
   101  // ModelUserInfoResult holds the result of an ModelUserInfo call.
   102  type ModelUserInfoResult struct {
   103  	Result *ModelUserInfo `json:"result,omitempty"`
   104  	Error  *Error         `json:"error,omitempty"`
   105  }
   106  
   107  // ModelUserInfoResults holds the result of a bulk ModelUserInfo API call.
   108  type ModelUserInfoResults struct {
   109  	Results []ModelUserInfoResult `json:"results"`
   110  }
   111  
   112  // ModifyModelAccessRequest holds the parameters for making grant and revoke model calls.
   113  type ModifyModelAccessRequest struct {
   114  	Changes []ModifyModelAccess `json:"changes"`
   115  }
   116  
   117  type ModifyModelAccess struct {
   118  	UserTag  string                `json:"user-tag"`
   119  	Action   ModelAction           `json:"action"`
   120  	Access   ModelAccessPermission `json:"access"`
   121  	ModelTag string                `json:"model-tag"`
   122  }
   123  
   124  // ModelAction is an action that can be performed on a model.
   125  type ModelAction string
   126  
   127  // Actions that can be preformed on a model.
   128  const (
   129  	GrantModelAccess  ModelAction = "grant"
   130  	RevokeModelAccess ModelAction = "revoke"
   131  )
   132  
   133  // ModelAccessPermission is the type of permission that a user has to access a
   134  // model.
   135  type ModelAccessPermission string
   136  
   137  // Model access permissions that may be set on a user.
   138  const (
   139  	ModelReadAccess  ModelAccessPermission = "read"
   140  	ModelWriteAccess ModelAccessPermission = "write"
   141  )