func serviceInstanceGrantTeam(w http.ResponseWriter, r *http.Request, t auth.Token) (err error) {
	instanceName := r.URL.Query().Get(":instance")
	serviceName := r.URL.Query().Get(":service")
	serviceInstance, err := getServiceInstanceOrError(serviceName, instanceName)
	if err != nil {
		return err
	}
	allowed := permission.Check(t, permission.PermServiceInstanceUpdateGrant,
		contextsForServiceInstance(serviceInstance, serviceName)...,
	)
	if !allowed {
		return permission.ErrUnauthorized
	}
	evt, err := event.New(&event.Opts{
		Target:     serviceInstanceTarget(serviceName, instanceName),
		Kind:       permission.PermServiceInstanceUpdateGrant,
		Owner:      t,
		CustomData: event.FormToCustomData(InputFields(r)),
		Allowed: event.Allowed(permission.PermServiceInstanceReadEvents,
			contextsForServiceInstance(serviceInstance, serviceName)...),
	})
	if err != nil {
		return err
	}
	defer func() { evt.Done(err) }()
	teamName := r.URL.Query().Get(":team")
	return serviceInstance.Grant(teamName)
}
func serviceInstanceGrantTeam(w http.ResponseWriter, r *http.Request, t auth.Token) (err error) {
	instanceName := r.URL.Query().Get(":instance")
	serviceName := r.URL.Query().Get(":service")
	serviceInstance, err := getServiceInstanceOrError(serviceName, instanceName)
	if err != nil {
		return err
	}
	allowed := permission.Check(t, permission.PermServiceInstanceUpdateGrant,
		contextsForServiceInstance(serviceInstance, serviceName)...,
	)
	if !allowed {
		return permission.ErrUnauthorized
	}
	evt, err := event.New(&event.Opts{
		Target:     serviceInstanceTarget(serviceName, instanceName),
		Kind:       permission.PermServiceInstanceUpdateGrant,
		Owner:      t,
		CustomData: event.FormToCustomData(InputFields(r)),
		Allowed: event.Allowed(permission.PermServiceInstanceReadEvents,
			contextsForServiceInstance(serviceInstance, serviceName)...),
	})
	if err != nil {
		return err
	}
	defer func() { evt.Done(err) }()
	teamName := r.URL.Query().Get(":team")
	return serviceInstance.Grant(teamName)
}
func serviceInstanceGrantTeam ( w http . ResponseWriter , r * http . Request , t auth . Token ) ( err error ) { instanceName := r . URL . Query ( ) . Get ( " " ) serviceName := r . URL . Query ( ) . Get ( " " ) serviceInstance , err := getServiceInstanceOrError ( serviceName , instanceName ) if err != nil { return err } allowed := permission . Check ( t , permission . PermServiceInstanceUpdateGrant , contextsForServiceInstance ( serviceInstance , serviceName ) ... , ) if ! allowed { return permission . ErrUnauthorized } evt , err := event . New ( & event . Opts { Target : serviceInstanceTarget ( serviceName , instanceName ) , Kind : permission . PermServiceInstanceUpdateGrant , Owner : t , CustomData : event . FormToCustomData ( InputFields ( r ) ) , Allowed : event . Allowed ( permission . PermServiceInstanceReadEvents , contextsForServiceInstance ( serviceInstance , serviceName ) ... ) , } ) if err != nil { return err } defer func ( ) { evt . Done ( err ) } ( ) teamName := r . URL . Query ( ) . Get ( " " ) return serviceInstance . Grant ( teamName ) }
// title: grant access to service instance
// path: /services/{service}/instances/permission/{instance}/{team}
// consume: application/x-www-form-urlencoded
// method: PUT
// responses:
//   200: Access granted
//   401: Unauthorized
//   404: Service instance not found
title : grant access to service instance path : / services / { service } / instances / permission / { instance } / { team } consume : application / x - www - form - urlencoded method : PUT responses : 200 : Access granted 401 : Unauthorized 404 : Service instance not found