github.com/mhilton/juju-juju@v0.0.0-20150901100907-a94dd2c73455/apiserver/uniter/uniter_v0.go (about) 1 // Copyright 2013 Canonical Ltd. 2 // Licensed under the AGPLv3, see LICENCE file for details. 3 4 // The uniter package implements the API interface used by the uniter 5 // worker. This file contains the API facade version 0. 6 package uniter 7 8 import ( 9 "github.com/juju/names" 10 11 "github.com/juju/juju/apiserver/common" 12 "github.com/juju/juju/apiserver/params" 13 "github.com/juju/juju/state" 14 ) 15 16 func init() { 17 common.RegisterStandardFacade("Uniter", 0, NewUniterAPIV0) 18 } 19 20 // UniterAPIV0 implements the API facade version 0, used by the uniter 21 // worker. 22 type UniterAPIV0 struct { 23 uniterBaseAPI 24 } 25 26 // NewUniterAPIV0 creates a new instance of the Uniter API, version 0. 27 func NewUniterAPIV0(st *state.State, resources *common.Resources, authorizer common.Authorizer) (*UniterAPIV0, error) { 28 baseAPI, err := newUniterBaseAPI(st, resources, authorizer) 29 if err != nil { 30 return nil, err 31 } 32 return &UniterAPIV0{ 33 uniterBaseAPI: *baseAPI, 34 }, nil 35 } 36 37 // GetOwnerTag returns the user tag of the owner of the first given 38 // service tag in args. 39 // 40 // NOTE: This is obsolete and is replaced by ServiceOwner in APIV1, 41 // which should be used instead. This method is not propely handling 42 // multiple tags and does not check for permissions. See also 43 // http://pad.lv/1270795. 44 func (u *UniterAPIV0) GetOwnerTag(args params.Entities) (params.StringResult, error) { 45 var nothing params.StringResult 46 tag, err := names.ParseServiceTag(args.Entities[0].Tag) 47 if err != nil { 48 return nothing, common.ErrPerm 49 } 50 service, err := u.getService(tag) 51 if err != nil { 52 return nothing, err 53 } 54 return params.StringResult{ 55 Result: service.GetOwnerTag(), 56 }, nil 57 }