github.com/niedbalski/juju@v0.0.0-20190215020005-8ff100488e47/core/crossmodel/interface.go (about) 1 // Copyright 2015 Canonical Ltd. 2 // Licensed under the AGPLv3, see LICENCE file for details. 3 4 package crossmodel 5 6 import ( 7 "gopkg.in/juju/charm.v6" 8 "gopkg.in/macaroon.v2-unstable" 9 10 "github.com/juju/juju/apiserver/params" 11 ) 12 13 // ApplicationOffer holds the details of an application offered 14 // by this model. 15 type ApplicationOffer struct { 16 // OfferUUID is the UUID of the offer. 17 OfferUUID string 18 19 // OfferName is the name of the offer. 20 OfferName string 21 22 // ApplicationName is the name of the application to which the offer pertains. 23 ApplicationName string 24 25 // ApplicationDescription is a description of the application's functionality, 26 // typically copied from the charm metadata. 27 ApplicationDescription string 28 29 // Endpoints is the collection of endpoint names offered (internal->published). 30 // The map allows for advertised endpoint names to be aliased. 31 Endpoints map[string]charm.Relation 32 } 33 34 // AddApplicationOfferArgs contains parameters used to create an application offer. 35 type AddApplicationOfferArgs struct { 36 // OfferName is the name of the offer. 37 OfferName string 38 39 // Owner is the user name who owns the offer. 40 Owner string 41 42 // HasRead are the user names who can see the offer exists. 43 HasRead []string 44 45 // ApplicationName is the name of the application to which the offer pertains. 46 ApplicationName string 47 48 // ApplicationDescription is a description of the application's functionality, 49 // typically copied from the charm metadata. 50 ApplicationDescription string 51 52 // Endpoints is the collection of endpoint names offered (internal->published). 53 // The map allows for advertised endpoint names to be aliased. 54 Endpoints map[string]string 55 56 // Icon is an icon to display when browsing the ApplicationOffers, which by default 57 // comes from the charm. 58 Icon []byte 59 } 60 61 // ConsumeApplicationArgs contains parameters used to consume an offer. 62 type ConsumeApplicationArgs struct { 63 // Offer is the offer to be consumed. 64 Offer params.ApplicationOfferDetails 65 66 // Macaroon is used for authentication. 67 Macaroon *macaroon.Macaroon 68 69 // ControllerInfo contains connection details to the controller 70 // hosting the offer. 71 ControllerInfo *ControllerInfo 72 73 // ApplicationAlias is the name of the alias to use for the application name. 74 ApplicationAlias string 75 } 76 77 // String returns the offered application name. 78 func (s *ApplicationOffer) String() string { 79 return s.ApplicationName 80 } 81 82 // ApplicationOfferFilter is used to query applications offered 83 // by this model. 84 type ApplicationOfferFilter struct { 85 // OwnerName is the owner of the model hosting the offer. 86 OwnerName string 87 88 // ModelName is the name of the model hosting the offer. 89 ModelName string 90 91 // OfferName is the name of the offer. 92 OfferName string 93 94 // ApplicationName is the name of the application to which the offer pertains. 95 ApplicationName string 96 97 // ApplicationDescription is a description of the application's functionality, 98 // typically copied from the charm metadata. 99 ApplicationDescription string 100 101 // Endpoint contains an endpoint filter criteria. 102 Endpoints []EndpointFilterTerm 103 104 // AllowedConsumers are the users allowed to consume the offer. 105 AllowedConsumers []string 106 107 // ConnectedUsers are the users currently related to the offer. 108 ConnectedUsers []string 109 } 110 111 // EndpointFilterTerm represents a remote endpoint filter. 112 type EndpointFilterTerm struct { 113 // Name is an endpoint name. 114 Name string 115 116 // Interface is an endpoint interface. 117 Interface string 118 119 // Role is an endpoint role. 120 Role charm.RelationRole 121 } 122 123 // An ApplicationOffers instance holds application offers from a model. 124 type ApplicationOffers interface { 125 126 // AddOffer adds a new application offer to the directory. 127 AddOffer(offer AddApplicationOfferArgs) (*ApplicationOffer, error) 128 129 // UpdateOffer replaces an existing offer at the same URL. 130 UpdateOffer(offer AddApplicationOfferArgs) (*ApplicationOffer, error) 131 132 // ApplicationOffer returns the named application offer. 133 ApplicationOffer(offerName string) (*ApplicationOffer, error) 134 135 // ApplicationOfferForUUID returns the application offer with the UUID. 136 ApplicationOfferForUUID(offerUUID string) (*ApplicationOffer, error) 137 138 // ListOffers returns the offers satisfying the specified filter. 139 ListOffers(filter ...ApplicationOfferFilter) ([]ApplicationOffer, error) 140 141 // Remove removes the application offer at the specified URL. 142 Remove(offerName string, force bool) error 143 144 // AllApplicationOffers returns all application offers in the model. 145 AllApplicationOffers() (offers []*ApplicationOffer, _ error) 146 } 147 148 // RemoteApplication represents a remote application. 149 type RemoteApplication struct { 150 ApplicationOffer 151 152 // ConnectedUsers are the users that are consuming the application. 153 ConnectedUsers []string 154 }