Skip to content

Commit 46b3573

Browse files
feat: validating limits of account (#481)
1 parent 9b91d2b commit 46b3573

File tree

7 files changed

+3107
-315
lines changed

7 files changed

+3107
-315
lines changed

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
VERSION=v1.4.7
1+
VERSION=v1.4.8
22

33
ifndef GOBIN
44
ifndef GOPATH

pkg/graphql/graphql.go

+5
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ type (
1414
User() UserAPI
1515
Workflow() WorkflowAPI
1616
PromotionTemplate() PromotionTemplateAPI
17+
Payments() PaymentsAPI
1718
}
1819

1920
gqlImpl struct {
@@ -64,3 +65,7 @@ func (v2 *gqlImpl) Workflow() WorkflowAPI {
6465
func (v2 *gqlImpl) PromotionTemplate() PromotionTemplateAPI {
6566
return &promotionTemplate{client: v2.client}
6667
}
68+
69+
func (v2 *gqlImpl) Payments() PaymentsAPI {
70+
return &payments{client: v2.client}
71+
}

pkg/graphql/payments.go

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
package graphql
2+
3+
import (
4+
"context"
5+
"fmt"
6+
platmodel "github.com/codefresh-io/go-sdk/pkg/model/platform"
7+
8+
"github.com/codefresh-io/go-sdk/pkg/client"
9+
)
10+
11+
type (
12+
PaymentsAPI interface {
13+
GetLimitsStatus(ctx context.Context) (*platmodel.LimitsStatus, error)
14+
}
15+
16+
payments struct {
17+
client *client.CfClient
18+
}
19+
)
20+
21+
func (c *payments) GetLimitsStatus(ctx context.Context) (*platmodel.LimitsStatus, error) {
22+
query := `
23+
query LimitsStatus {
24+
limitsStatus {
25+
usage {
26+
clusters
27+
applications
28+
}
29+
limits {
30+
clusters
31+
applications
32+
}
33+
status
34+
}
35+
}`
36+
limitsStatus, err := client.GraphqlAPI[platmodel.LimitsStatus](ctx, c.client, query, nil)
37+
if err != nil {
38+
return nil, fmt.Errorf("failed to get limits status: %w", err)
39+
}
40+
41+
return &limitsStatus, nil
42+
}

0 commit comments

Comments
 (0)