-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp_envs.go
More file actions
32 lines (27 loc) · 807 Bytes
/
app_envs.go
File metadata and controls
32 lines (27 loc) · 807 Bytes
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
package api
import (
"context"
"fmt"
"gopkg.in/nullstone-io/go-api-client.v0/response"
"gopkg.in/nullstone-io/go-api-client.v0/types"
"net/http"
)
type AppEnvs struct {
Client *Client
}
func (e AppEnvs) basePath(stackId, appId int64, envName string) string {
return fmt.Sprintf("orgs/%s/stacks/%d/apps/%d/envs/%s", e.Client.Config.OrgName, stackId, appId, envName)
}
func (e AppEnvs) Get(ctx context.Context, stackId, appId int64, envName string) (*types.AppEnv, error) {
res, err := e.Client.Do(ctx, http.MethodGet, e.basePath(stackId, appId, envName), nil, nil, nil)
if err != nil {
return nil, err
}
var appEnv types.AppEnv
if err := response.ReadJson(res, &appEnv); response.IsNotFoundError(err) {
return nil, nil
} else if err != nil {
return nil, err
}
return &appEnv, nil
}