func serviceInstance(w http.ResponseWriter, r *http.Request, t auth.Token) error {
	instanceName := r.URL.Query().Get(":instance")
	serviceName := r.URL.Query().Get(":service")
	svc, err := getService(serviceName)
	if err != nil {
		return err
	}
	serviceInstance, err := getServiceInstanceOrError(serviceName, instanceName)
	if err != nil {
		return err
	}
	allowed := permission.Check(t, permission.PermServiceInstanceRead,
		contextsForServiceInstance(serviceInstance, serviceName)...,
	)
	if !allowed {
		return permission.ErrUnauthorized
	}
	requestID := requestIDHeader(r)
	info, err := serviceInstance.Info(requestID)
	if err != nil {
		return err
	}
	plan, err := service.GetPlanByServiceAndPlanName(svc, serviceInstance.PlanName, requestID)
	if err != nil {
		return err
	}
	sInfo := serviceInstanceInfo{
		Apps:            serviceInstance.Apps,
		Teams:           serviceInstance.Teams,
		TeamOwner:       serviceInstance.TeamOwner,
		Description:     serviceInstance.Description,
		PlanName:        plan.Name,
		PlanDescription: plan.Description,
		CustomInfo:      info,
		Tags:            serviceInstance.Tags,
	}
	w.Header().Set("Content-Type", "application/json")
	return json.NewEncoder(w).Encode(sInfo)
}
func serviceInstance(w http.ResponseWriter, r *http.Request, t auth.Token) error {
	instanceName := r.URL.Query().Get(":instance")
	serviceName := r.URL.Query().Get(":service")
	svc, err := getService(serviceName)
	if err != nil {
		return err
	}
	serviceInstance, err := getServiceInstanceOrError(serviceName, instanceName)
	if err != nil {
		return err
	}
	allowed := permission.Check(t, permission.PermServiceInstanceRead,
		contextsForServiceInstance(serviceInstance, serviceName)...,
	)
	if !allowed {
		return permission.ErrUnauthorized
	}
	requestID := requestIDHeader(r)
	info, err := serviceInstance.Info(requestID)
	if err != nil {
		return err
	}
	plan, err := service.GetPlanByServiceAndPlanName(svc, serviceInstance.PlanName, requestID)
	if err != nil {
		return err
	}
	sInfo := serviceInstanceInfo{
		Apps:            serviceInstance.Apps,
		Teams:           serviceInstance.Teams,
		TeamOwner:       serviceInstance.TeamOwner,
		Description:     serviceInstance.Description,
		PlanName:        plan.Name,
		PlanDescription: plan.Description,
		CustomInfo:      info,
		Tags:            serviceInstance.Tags,
	}
	w.Header().Set("Content-Type", "application/json")
	return json.NewEncoder(w).Encode(sInfo)
}
func serviceInstance ( w http . ResponseWriter , r * http . Request , t auth . Token ) error { instanceName := r . URL . Query ( ) . Get ( " " ) serviceName := r . URL . Query ( ) . Get ( " " ) svc , err := getService ( serviceName ) if err != nil { return err } serviceInstance , err := getServiceInstanceOrError ( serviceName , instanceName ) if err != nil { return err } allowed := permission . Check ( t , permission . PermServiceInstanceRead , contextsForServiceInstance ( serviceInstance , serviceName ) ... , ) if ! allowed { return permission . ErrUnauthorized } requestID := requestIDHeader ( r ) info , err := serviceInstance . Info ( requestID ) if err != nil { return err } plan , err := service . GetPlanByServiceAndPlanName ( svc , serviceInstance . PlanName , requestID ) if err != nil { return err } sInfo := serviceInstanceInfo { Apps : serviceInstance . Apps , Teams : serviceInstance . Teams , TeamOwner : serviceInstance . TeamOwner , Description : serviceInstance . Description , PlanName : plan . Name , PlanDescription : plan . Description , CustomInfo : info , Tags : serviceInstance . Tags , } w . Header ( ) . Set ( " " , " " ) return json . NewEncoder ( w ) . Encode ( sInfo ) }
// title: service instance info
// path: /services/{service}/instances/{instance}
// method: GET
// produce: application/json
// responses:
//   200: OK
//   401: Unauthorized
//   404: Service instance not found
title : service instance info path : / services / { service } / instances / { instance } method : GET produce : application / json responses : 200 : OK 401 : Unauthorized 404 : Service instance not found