forked from cloudfoundry/cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app_files.go
33 lines (27 loc) · 925 Bytes
/
app_files.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package api
import (
"fmt"
"github.com/cloudfoundry/cli/cf/configuration"
"github.com/cloudfoundry/cli/cf/net"
)
type AppFilesRepository interface {
ListFiles(appGuid, path string) (files string, apiErr error)
}
type CloudControllerAppFilesRepository struct {
config configuration.Reader
gateway net.Gateway
}
func NewCloudControllerAppFilesRepository(config configuration.Reader, gateway net.Gateway) (repo CloudControllerAppFilesRepository) {
repo.config = config
repo.gateway = gateway
return
}
func (repo CloudControllerAppFilesRepository) ListFiles(appGuid, path string) (files string, apiErr error) {
url := fmt.Sprintf("%s/v2/apps/%s/instances/0/files/%s", repo.config.ApiEndpoint(), appGuid, path)
request, apiErr := repo.gateway.NewRequest("GET", url, repo.config.AccessToken(), nil)
if apiErr != nil {
return
}
files, _, apiErr = repo.gateway.PerformRequestForTextResponse(request)
return
}