Skip to content

Commit 5263b28

Browse files
committed
Added create version command
1 parent 9a646b6 commit 5263b28

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

application/http/http_client.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ const applicationApiPath = "application/api"
1919
type AppHttpClient interface {
2020
GetHttpClient() *jfroghttpclient.JfrogHttpClient
2121
Post(path string, requestBody interface{}) (resp *http.Response, body []byte, err error)
22+
Get(path string) (resp *http.Response, body []byte, err error)
2223
}
2324

2425
type appHttpClient struct {
@@ -93,6 +94,16 @@ func (c *appHttpClient) Post(path string, requestBody interface{}) (resp *http.R
9394
return c.client.SendPost(url, requestContent, c.getJsonHttpClientDetails())
9495
}
9596

97+
func (c *appHttpClient) Get(path string) (resp *http.Response, body []byte, err error) {
98+
url, err := utils.BuildUrl(c.serverDetails.Url, applicationApiPath+path, nil)
99+
if err != nil {
100+
return nil, nil, err
101+
}
102+
103+
response, body, _, err := c.client.SendGet(url, false, c.getJsonHttpClientDetails())
104+
return response, body, err
105+
}
106+
96107
func (c *appHttpClient) toJsonBytes(payload interface{}) ([]byte, error) {
97108
if payload == nil {
98109
return nil, fmt.Errorf("request payload is required")

application/service/system_service.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
package service
22

3+
import (
4+
"fmt"
5+
"github.com/jfrog/jfrog-cli-application/application/http"
6+
)
7+
38
type SystemService interface {
49
Ping(ctx *Context) error
510
}
@@ -12,5 +17,20 @@ func NewSystemService() SystemService {
1217
}
1318

1419
func (ss *systemService) Ping(ctx *Context) error {
20+
httpClient, err := http.NewAppHttpClient(ctx.ServerDetails)
21+
if err != nil {
22+
return err
23+
}
24+
25+
response, body, err := httpClient.Get("/v1/system/ping")
26+
if err != nil {
27+
return err
28+
}
29+
30+
if response.StatusCode != 200 {
31+
return fmt.Errorf("failed to create app version. Status code: %d", response.StatusCode)
32+
}
33+
34+
fmt.Println(string(body))
1535
return nil
1636
}

0 commit comments

Comments
 (0)