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