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

     1  // Copyright 2016 Canonical Ltd.
     2  // Licensed under the AGPLv3, see LICENCE file for details.
     3  
     4  package params
     5  
     6  // Cloud holds information about a cloud.
     7  type Cloud struct {
     8  	Type             string        `json:"type"`
     9  	HostCloudRegion  string        `json:"host-cloud-region,omitempty"`
    10  	AuthTypes        []string      `json:"auth-types,omitempty"`
    11  	Endpoint         string        `json:"endpoint,omitempty"`
    12  	IdentityEndpoint string        `json:"identity-endpoint,omitempty"`
    13  	StorageEndpoint  string        `json:"storage-endpoint,omitempty"`
    14  	Regions          []CloudRegion `json:"regions,omitempty"`
    15  	CACertificates   []string      `json:"ca-certificates,omitempty"`
    16  }
    17  
    18  // CloudRegion holds information about a cloud region.
    19  type CloudRegion struct {
    20  	Name             string `json:"name"`
    21  	Endpoint         string `json:"endpoint,omitempty"`
    22  	IdentityEndpoint string `json:"identity-endpoint,omitempty"`
    23  	StorageEndpoint  string `json:"storage-endpoint,omitempty"`
    24  }
    25  
    26  // AddCloudArgs holds a cloud to be added with its name
    27  type AddCloudArgs struct {
    28  	Cloud Cloud  `json:"cloud"`
    29  	Name  string `json:"name"`
    30  }
    31  
    32  // CloudResult contains a cloud definition or an error.
    33  type CloudResult struct {
    34  	Cloud *Cloud `json:"cloud,omitempty"`
    35  	Error *Error `json:"error,omitempty"`
    36  }
    37  
    38  // CloudResults contains a set of CloudResults.
    39  type CloudResults struct {
    40  	Results []CloudResult `json:"results,omitempty"`
    41  }
    42  
    43  // CloudsResult contains a set of Clouds.
    44  type CloudsResult struct {
    45  	// Clouds is a map of clouds, keyed by cloud tag.
    46  	Clouds map[string]Cloud `json:"clouds,omitempty"`
    47  }
    48  
    49  // CloudUserInfo holds information on a user who has access to a
    50  // cloud. Cloud admins can see this information for all users
    51  // who have access, so it should not include sensitive information.
    52  type CloudUserInfo struct {
    53  	UserName    string `json:"user"`
    54  	DisplayName string `json:"display-name"`
    55  	Access      string `json:"access"`
    56  }
    57  
    58  // CloudDetails holds information about a cloud.
    59  type CloudDetails struct {
    60  	Type             string        `json:"type"`
    61  	AuthTypes        []string      `json:"auth-types,omitempty"`
    62  	Endpoint         string        `json:"endpoint,omitempty"`
    63  	IdentityEndpoint string        `json:"identity-endpoint,omitempty"`
    64  	StorageEndpoint  string        `json:"storage-endpoint,omitempty"`
    65  	Regions          []CloudRegion `json:"regions,omitempty"`
    66  }
    67  
    68  // CloudInfo holds information about a cloud and user who can access it.
    69  type CloudInfo struct {
    70  	CloudDetails `json:",inline"`
    71  
    72  	// Users contains information about the users that have access
    73  	// to the cloud. Administrators can see all users that have access;
    74  	// other users can only see their own details.
    75  	Users []CloudUserInfo `json:"users"`
    76  }
    77  
    78  // CloudInfoResult holds the result of a CloudInfo call.
    79  type CloudInfoResult struct {
    80  	Result *CloudInfo `json:"result,omitempty"`
    81  	Error  *Error     `json:"error,omitempty"`
    82  }
    83  
    84  // CloudInfoResults holds the result of a bulk CloudInfo call.
    85  type CloudInfoResults struct {
    86  	Results []CloudInfoResult `json:"results"`
    87  }
    88  
    89  // ListCloudsRequest encapsulates how we request a list of cloud details for a user.
    90  type ListCloudsRequest struct {
    91  	UserTag string `json:"user-tag"`
    92  	All     bool   `json:"all,omitempty"`
    93  }
    94  
    95  // ListCloudInfo holds information about a cloud for a user.
    96  type ListCloudInfo struct {
    97  	CloudDetails `json:",inline"`
    98  
    99  	// Access is the access level for the user.
   100  	Access string `json:"user-access"`
   101  }
   102  
   103  // ListCloudInfoResult holds the result of a ListCloudInfo call.
   104  type ListCloudInfoResult struct {
   105  	Result *ListCloudInfo `json:"result,omitempty"`
   106  	Error  *Error         `json:"error,omitempty"`
   107  }
   108  
   109  // ListCloudInfoResults holds the result of a bulk ListCloudInfo call.
   110  type ListCloudInfoResults struct {
   111  	Results []ListCloudInfoResult `json:"results"`
   112  }
   113  
   114  // ModifyCloudAccessRequest holds the parameters for making grant and revoke cloud calls.
   115  type ModifyCloudAccessRequest struct {
   116  	Changes []ModifyCloudAccess `json:"changes"`
   117  }
   118  
   119  // ModifyCloudAccess defines an operation to modify cloud access.
   120  type ModifyCloudAccess struct {
   121  	UserTag  string      `json:"user-tag"`
   122  	CloudTag string      `json:"cloud-tag"`
   123  	Action   CloudAction `json:"action"`
   124  	Access   string      `json:"access"`
   125  }
   126  
   127  // CloudAction is an action that can be performed on a cloud.
   128  type CloudAction string
   129  
   130  // Actions that can be preformed on a cloud.
   131  const (
   132  	GrantCloudAccess  CloudAction = "grant"
   133  	RevokeCloudAccess CloudAction = "revoke"
   134  )
   135  
   136  // CloudCredential contains a cloud credential
   137  // possibly with secrets redacted.
   138  type CloudCredential struct {
   139  	// AuthType is the authentication type.
   140  	AuthType string `json:"auth-type"`
   141  
   142  	// Attributes contains non-secret credential values.
   143  	Attributes map[string]string `json:"attrs,omitempty"`
   144  
   145  	// Redacted is a list of redacted attributes
   146  	Redacted []string `json:"redacted,omitempty"`
   147  }
   148  
   149  // CloudCredentialResult contains a CloudCredential or an error.
   150  type CloudCredentialResult struct {
   151  	Result *CloudCredential `json:"result,omitempty"`
   152  	Error  *Error           `json:"error,omitempty"`
   153  }
   154  
   155  // CloudCredentialResults contains a set of CloudCredentialResults.
   156  type CloudCredentialResults struct {
   157  	Results []CloudCredentialResult `json:"results,omitempty"`
   158  }
   159  
   160  // UserCloud contains a user/cloud tag pair, typically used for identifying
   161  // a user's credentials for a cloud.
   162  type UserCloud struct {
   163  	UserTag  string `json:"user-tag"`
   164  	CloudTag string `json:"cloud-tag"`
   165  }
   166  
   167  // UserClouds contains a set of UserClouds.
   168  type UserClouds struct {
   169  	UserClouds []UserCloud `json:"user-clouds,omitempty"`
   170  }
   171  
   172  // TaggedCredentials contains a set of tagged cloud credentials.
   173  type TaggedCredentials struct {
   174  	Credentials []TaggedCredential `json:"credentials,omitempty"`
   175  }
   176  
   177  // TaggedCredential contains a cloud credential and its tag.
   178  type TaggedCredential struct {
   179  	Tag        string          `json:"tag"`
   180  	Credential CloudCredential `json:"credential"`
   181  }
   182  
   183  // CloudSpec holds a cloud specification.
   184  type CloudSpec struct {
   185  	Type             string           `json:"type"`
   186  	Name             string           `json:"name"`
   187  	Region           string           `json:"region,omitempty"`
   188  	Endpoint         string           `json:"endpoint,omitempty"`
   189  	IdentityEndpoint string           `json:"identity-endpoint,omitempty"`
   190  	StorageEndpoint  string           `json:"storage-endpoint,omitempty"`
   191  	Credential       *CloudCredential `json:"credential,omitempty"`
   192  	CACertificates   []string         `json:"cacertificates,omitempty"`
   193  }
   194  
   195  // CloudSpecResult contains a CloudSpec or an error.
   196  type CloudSpecResult struct {
   197  	Result *CloudSpec `json:"result,omitempty"`
   198  	Error  *Error     `json:"error,omitempty"`
   199  }
   200  
   201  // CloudSpecResults contains a set of CloudSpecResults.
   202  type CloudSpecResults struct {
   203  	Results []CloudSpecResult `json:"results,omitempty"`
   204  }
   205  
   206  // CloudCredentialArg defines a credential in terms of its cloud and name.
   207  // It is used to request detailed content for the credential stored on the controller.
   208  type CloudCredentialArg struct {
   209  	CloudName      string `json:"cloud-name"`
   210  	CredentialName string `json:"credential-name"`
   211  }
   212  
   213  // IsEmpty returns whether a cloud credential argument is empty.
   214  func (p CloudCredentialArg) IsEmpty() bool {
   215  	return p.CloudName == "" && p.CredentialName == ""
   216  }
   217  
   218  // CloudCredentialArgs defines an input required to make a valid call
   219  // to get credentials content stored on the controller.
   220  type CloudCredentialArgs struct {
   221  	Credentials    []CloudCredentialArg `json:"credentials,omitempty"`
   222  	IncludeSecrets bool                 `json:"include-secrets"`
   223  }
   224  
   225  // CredentialContent contains a cloud credential content.
   226  type CredentialContent struct {
   227  	// Name is the short name of the credential.
   228  	Name string `json:"name"`
   229  
   230  	// Cloud is the cloud name to which this credential belongs.
   231  	Cloud string `json:"cloud"`
   232  
   233  	// AuthType is the authentication type.
   234  	AuthType string `json:"auth-type"`
   235  
   236  	// Attributes contains credential values.
   237  	Attributes map[string]string `json:"attrs,omitempty"`
   238  }
   239  
   240  // ModelAccess contains information about user model access.
   241  type ModelAccess struct {
   242  	Model  string `json:"model,omitempty"`
   243  	Access string `json:"access,omitempty"`
   244  }
   245  
   246  // ControllerCredentialInfo contains everything Juju stores on the controller
   247  // about the credential - its contents as well as what models use it and
   248  // what access currently logged in user, a credential owner, has to these models.
   249  type ControllerCredentialInfo struct {
   250  	// Content has comprehensive credential content.
   251  	Content CredentialContent `json:"content,omitempty"`
   252  
   253  	// Models contains models that are using ths credential.
   254  	Models []ModelAccess `json:"models,omitempty"`
   255  }
   256  
   257  // CredentialContentResult contains comprehensive information about stored credential or an error.
   258  type CredentialContentResult struct {
   259  	Result *ControllerCredentialInfo `json:"result,omitempty"`
   260  	Error  *Error                    `json:"error,omitempty"`
   261  }
   262  
   263  // CredentialContentResults contains a set of CredentialContentResults.
   264  type CredentialContentResults struct {
   265  	Results []CredentialContentResult `json:"results,omitempty"`
   266  }
   267  
   268  // ValidateCredentialArg contains collection of cloud credentials
   269  // identified by their tags to mark as valid or not.
   270  type ValidateCredentialArg struct {
   271  	CredentialTag string `json:"tag"`
   272  	Valid         bool   `json:"valid"`
   273  	Reason        string `json:"reason,omitempty"`
   274  }
   275  
   276  // ValidateCredentialArgs contains a set of ValidateCredentialArg.
   277  type ValidateCredentialArgs struct {
   278  	All []ValidateCredentialArg `json:"credentials,omitempty"`
   279  }
   280  
   281  // UpdateCredentialModelResult contains results for a model credential validation check
   282  // from a cloud credential update.
   283  type UpdateCredentialModelResult struct {
   284  	// ModelUUID contains model's UUID.
   285  	ModelUUID string `json:"uuid"`
   286  
   287  	// ModelName contains model name.
   288  	ModelName string `json:"name"`
   289  
   290  	// Errors contains the errors accumulated while trying to update a credential.
   291  	Errors []ErrorResult `json:"errors,omitempty"`
   292  }
   293  
   294  // UpdateCredentialResult stores the result of updating one cloud credential.
   295  type UpdateCredentialResult struct {
   296  	// CredentialTag holds credential tag.
   297  	CredentialTag string `json:"tag"`
   298  
   299  	// Errors contains an error that may have occurred while trying to update a credential.
   300  	Error *Error `json:"error,omitempty"`
   301  
   302  	// Models contains results of credential check against models that use this cloud credential.
   303  	Models []UpdateCredentialModelResult `json:"models,omitempty"`
   304  }
   305  
   306  // UpdateCredentialResults contains a set of UpdateCredentialResult.
   307  type UpdateCredentialResults struct {
   308  	Results []UpdateCredentialResult `json:"results,omitempty"`
   309  }
   310  
   311  // UpdateCredentialArgs contains a TaggedCredential set and is used in the call to update credentials.
   312  type UpdateCredentialArgs struct {
   313  	// Credentials holds credentials to update.
   314  	Credentials []TaggedCredential `json:"credentials"`
   315  
   316  	// Force indicates whether the update should be forced.
   317  	Force bool `json:"force"`
   318  }
   319  
   320  // InvalidateCredentialArg is used to invalidate a controller credential.
   321  type InvalidateCredentialArg struct {
   322  	// Reason is the description of why we are invalidating credential.
   323  	Reason string `json:"reason,omitempty"`
   324  }
   325  
   326  // RevokeCredentialArg contains data needed to revoke credential.
   327  type RevokeCredentialArg struct {
   328  	// Tag holds credential tag to revoke.
   329  	Tag string `json:"tag"`
   330  
   331  	// Force indicates whether the credential can be revoked forcefully.
   332  	Force bool `json:"force"`
   333  }
   334  
   335  // RevokeCredentialArgs contains credentials to revoke.
   336  type RevokeCredentialArgs struct {
   337  	// Credentials holds credentials to revoke.
   338  	Credentials []RevokeCredentialArg `json:"credentials"`
   339  }