github.com/niedbalski/juju@v0.0.0-20190215020005-8ff100488e47/apiserver/params/resources.go (about) 1 // Copyright 2017 Canonical Ltd. 2 // Licensed under the AGPLv3, see LICENCE file for details. 3 4 package params 5 6 import "time" 7 8 // ListResourcesArgs are the arguments for the ListResources endpoint. 9 type ListResourcesArgs Entities 10 11 // AddPendingResourcesArgs holds the arguments to the AddPendingResources 12 // API endpoint. 13 type AddPendingResourcesArgs struct { 14 Entity 15 AddCharmWithAuthorization 16 17 // Resources is the list of resources to add as pending. 18 Resources []CharmResource `json:"resources"` 19 } 20 21 // AddPendingResourcesResult holds the result of the AddPendingResources 22 // API endpoint. 23 type AddPendingResourcesResult struct { 24 ErrorResult 25 26 // PendingIDs holds the "pending ID" for each of the requested 27 // resources. 28 PendingIDs []string `json:"pending-ids"` 29 } 30 31 // ResourcesResults holds the resources that result 32 // from a bulk API call. 33 type ResourcesResults struct { 34 // Results is the list of resource results. 35 Results []ResourcesResult `json:"results"` 36 } 37 38 // ResourcesResult holds the resources that result from an API call 39 // for a single application. 40 type ResourcesResult struct { 41 ErrorResult 42 43 // Resources is the list of resources for the application. 44 Resources []Resource `json:"resources"` 45 46 // CharmStoreResources is the list of resources associated with the charm in 47 // the charmstore. 48 CharmStoreResources []CharmResource `json:"charm-store-resources"` 49 50 // UnitResources contains a list of the resources for each unit in the 51 // application. 52 UnitResources []UnitResources `json:"unit-resources"` 53 } 54 55 // A UnitResources contains a list of the resources the unit defined by Entity. 56 type UnitResources struct { 57 Entity 58 59 // Resources is a list of resources for the unit. 60 Resources []Resource `json:"resources"` 61 62 // DownloadProgress indicates the number of bytes of a resource file 63 // have been downloaded so far the uniter. Only currently downloading 64 // resources are included. 65 DownloadProgress map[string]int64 `json:"download-progress"` 66 } 67 68 // UploadResult is the response from an upload request. 69 type UploadResult struct { 70 ErrorResult 71 72 // Resource describes the resource that was stored in the model. 73 Resource Resource `json:"resource"` 74 } 75 76 // Resource contains info about a Resource. 77 type Resource struct { 78 CharmResource 79 80 // ID uniquely identifies a resource-application pair within the model. 81 // Note that the model ignores pending resources (those with a 82 // pending ID) except for in a few clearly pending-related places. 83 ID string `json:"id"` 84 85 // PendingID identifies that this resource is pending and 86 // distinguishes it from other pending resources with the same model 87 // ID (and from the active resource). 88 PendingID string `json:"pending-id"` 89 90 // ApplicationID identifies the application for the resource. 91 ApplicationID string `json:"application"` 92 93 // Username is the ID of the user that added the revision 94 // to the model (whether implicitly or explicitly). 95 Username string `json:"username"` 96 97 // Timestamp indicates when the resource was added to the model. 98 Timestamp time.Time `json:"timestamp"` 99 } 100 101 // CharmResource contains the definition for a resource. 102 type CharmResource struct { 103 // Name identifies the resource. 104 Name string `json:"name"` 105 106 // Type is the name of the resource type. 107 Type string `json:"type"` 108 109 // Path is where the resource will be stored. 110 Path string `json:"path"` 111 112 // Description contains user-facing info about the resource. 113 Description string `json:"description,omitempty"` 114 115 // Origin is where the resource will come from. 116 Origin string `json:"origin"` 117 118 // Revision is the revision, if applicable. 119 Revision int `json:"revision"` 120 121 // Fingerprint is the SHA-384 checksum for the resource blob. 122 Fingerprint []byte `json:"fingerprint"` 123 124 // Size is the size of the resource, in bytes. 125 Size int64 `json:"size"` 126 }