github.com/loggregator/cli@v6.33.1-0.20180224010324-82334f081791+incompatible/cf/api/appfiles/app_files.go (about) 1 package appfiles 2 3 import ( 4 "fmt" 5 6 "code.cloudfoundry.org/cli/cf/configuration/coreconfig" 7 "code.cloudfoundry.org/cli/cf/net" 8 ) 9 10 //go:generate counterfeiter . Repository 11 12 type Repository interface { 13 ListFiles(appGUID string, instance int, path string) (files string, apiErr error) 14 } 15 16 type CloudControllerAppFilesRepository struct { 17 config coreconfig.Reader 18 gateway net.Gateway 19 } 20 21 func NewCloudControllerAppFilesRepository(config coreconfig.Reader, gateway net.Gateway) (repo CloudControllerAppFilesRepository) { 22 repo.config = config 23 repo.gateway = gateway 24 return 25 } 26 27 func (repo CloudControllerAppFilesRepository) ListFiles(appGUID string, instance int, path string) (files string, apiErr error) { 28 url := fmt.Sprintf("%s/v2/apps/%s/instances/%d/files/%s", repo.config.APIEndpoint(), appGUID, instance, path) 29 request, apiErr := repo.gateway.NewRequest("GET", url, repo.config.AccessToken(), nil) 30 if apiErr != nil { 31 return 32 } 33 34 files, _, apiErr = repo.gateway.PerformRequestForTextResponse(request) 35 return 36 }