github.com/niedbalski/juju@v0.0.0-20190215020005-8ff100488e47/apiserver/facades/controller/crossmodelrelations/state.go (about) 1 // Copyright 2017 Canonical Ltd. 2 // Licensed under the AGPLv3, see LICENCE file for details. 3 4 package crossmodelrelations 5 6 import ( 7 "gopkg.in/juju/names.v2" 8 9 common "github.com/juju/juju/apiserver/common/crossmodel" 10 "github.com/juju/juju/core/crossmodel" 11 "github.com/juju/juju/state" 12 ) 13 14 // RemoteRelationState provides the subset of global state required by the 15 // remote relations facade. 16 type CrossModelRelationsState interface { 17 common.Backend 18 19 // Model returns the model entity. 20 Model() (Model, error) 21 22 // AddOfferConnection creates a new offer connection record, which records details about a 23 // relation made from a remote model to an offer in the local model. 24 AddOfferConnection(state.AddOfferConnectionParams) (OfferConnection, error) 25 26 // OfferConnectionForRelation returns the offer connection details for the given relation key. 27 OfferConnectionForRelation(string) (OfferConnection, error) 28 } 29 30 // TODO - CAAS(ericclaudejones): This should contain state alone, model will be 31 // removed once all relevant methods are moved from state to model. 32 type stateShim struct { 33 common.Backend 34 st *state.State 35 } 36 37 func (st stateShim) ApplicationOfferForUUID(offerUUID string) (*crossmodel.ApplicationOffer, error) { 38 oa := state.NewApplicationOffers(st.st) 39 return oa.ApplicationOfferForUUID(offerUUID) 40 } 41 42 func (st stateShim) AddOfferConnection(arg state.AddOfferConnectionParams) (OfferConnection, error) { 43 return st.st.AddOfferConnection(arg) 44 } 45 46 func (st stateShim) OfferConnectionForRelation(relationKey string) (OfferConnection, error) { 47 return st.st.OfferConnectionForRelation(relationKey) 48 } 49 50 type Model interface { 51 Name() string 52 Owner() names.UserTag 53 } 54 55 func (st stateShim) Model() (Model, error) { 56 return st.st.Model() 57 } 58 59 type OfferConnection interface { 60 OfferUUID() string 61 }