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