Skip to content

Commit 6f07a1b

Browse files
updated models_gen (#415)
1 parent 134733c commit 6f07a1b

File tree

6 files changed

+224
-11
lines changed

6 files changed

+224
-11
lines changed

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.40.0
1+
0.41.0

pkg/codefresh/ap_git-sources.go

Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
package codefresh
2+
3+
import (
4+
"context"
5+
"fmt"
6+
7+
platformModel "github.com/codefresh-io/go-sdk/pkg/codefresh/model"
8+
appProxyModel "github.com/codefresh-io/go-sdk/pkg/codefresh/model/app-proxy"
9+
)
10+
11+
type (
12+
IAppProxyGitSourcesAPI interface {
13+
Create(ctx context.Context, appName, appSpecifier, destServer, destNamespace string, isInternal bool) error
14+
Delete(ctx context.Context, appName string) error
15+
Edit(ctx context.Context, appName, appSpecifier string) error
16+
}
17+
18+
appProxyGitSources struct {
19+
codefresh *codefresh
20+
}
21+
22+
graphqlGitSourceListResponse struct {
23+
Data struct {
24+
GitSources platformModel.GitSourceSlice
25+
}
26+
Errors []graphqlError
27+
}
28+
29+
graphqlGitSourceCreateResponse struct {
30+
Errors []graphqlError
31+
}
32+
33+
graphqlGitSourceDeleteResponse struct {
34+
Errors []graphqlError
35+
}
36+
37+
graphqlGitSourceEditResponse struct {
38+
Errors []graphqlError
39+
}
40+
41+
)
42+
43+
func newAppProxyGitSourcesAPI(c *codefresh) IAppProxyGitSourcesAPI {
44+
return &appProxyGitSources{codefresh: c}
45+
}
46+
47+
func (c *appProxyGitSources) Create(ctx context.Context, appName, appSpecifier, destServer, destNamespace string, isInternal bool) error {
48+
jsonData := map[string]interface{}{
49+
"query": `
50+
mutation CreateGitSource($args: CreateGitSourceInput!) {
51+
createGitSource(args: $args)
52+
}
53+
`,
54+
"variables": map[string]interface{}{
55+
"args": appProxyModel.CreateGitSourceInput{
56+
AppName: appName,
57+
AppSpecifier: appSpecifier,
58+
DestServer: destServer,
59+
DestNamespace: destNamespace,
60+
IsInternal: &isInternal,
61+
},
62+
},
63+
}
64+
65+
res := &graphqlGitSourceCreateResponse{}
66+
err := c.codefresh.graphqlAPI(ctx, jsonData, res)
67+
68+
if err != nil {
69+
return fmt.Errorf("failed making a graphql API call to create git source: %w", err)
70+
}
71+
72+
if len(res.Errors) > 0 {
73+
return graphqlErrorResponse{errors: res.Errors}
74+
}
75+
76+
return nil
77+
}
78+
79+
func (c *appProxyGitSources) Delete(ctx context.Context, appName string) error {
80+
jsonData := map[string]interface{}{
81+
"query": `
82+
mutation DeleteApplication($args: DeleteApplicationInput!) {
83+
deleteApplication(args: $args)
84+
}
85+
`,
86+
"variables": map[string]interface{}{
87+
"args": appProxyModel.DeleteApplicationInput{
88+
AppName: appName,
89+
},
90+
},
91+
}
92+
93+
res := &graphqlGitSourceDeleteResponse{}
94+
err := c.codefresh.graphqlAPI(ctx, jsonData, res)
95+
96+
if err != nil {
97+
return fmt.Errorf("failed making a graphql API call to delete git source: %w", err)
98+
}
99+
100+
if len(res.Errors) > 0 {
101+
return graphqlErrorResponse{errors: res.Errors}
102+
}
103+
104+
return nil
105+
}
106+
107+
func (c *appProxyGitSources) Edit(ctx context.Context, appName, appSpecifier string) error {
108+
jsonData := map[string]interface{}{
109+
"query": `
110+
mutation EditGitSource($args: EditGitSourceInput!) {
111+
editGitSource(args: $args)
112+
}
113+
`,
114+
"variables": map[string]interface{}{
115+
"args": appProxyModel.EditGitSourceInput{
116+
AppName: appName,
117+
AppSpecifier: appSpecifier,
118+
},
119+
},
120+
}
121+
122+
res := &graphqlGitSourceEditResponse{}
123+
err := c.codefresh.graphqlAPI(ctx, jsonData, res)
124+
125+
if err != nil {
126+
return fmt.Errorf("failed making a graphql API call to edit git source: %w", err)
127+
}
128+
129+
if len(res.Errors) > 0 {
130+
return graphqlErrorResponse{errors: res.Errors}
131+
}
132+
133+
return nil
134+
}

pkg/codefresh/codefresh.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ type (
4848
AppProxyClusters() IAppProxyClustersAPI
4949
GitIntegrations() IAppProxyGitIntegrationsAPI
5050
VersionInfo() IAppProxyVersionInfoAPI
51+
AppProxyGitSources() IAppProxyGitSourcesAPI
5152
}
5253
)
5354

@@ -161,6 +162,10 @@ func (c *codefresh) VersionInfo() IAppProxyVersionInfoAPI {
161162
return newAppProxyVersionInfoAPI(c)
162163
}
163164

165+
func (c *codefresh) AppProxyGitSources() IAppProxyGitSourcesAPI {
166+
return newAppProxyGitSourcesAPI(c)
167+
}
168+
164169
func (c *codefresh) requestAPI(opt *requestOptions) (*http.Response, error) {
165170
return c.requestAPIWithContext(context.Background(), opt)
166171
}

pkg/codefresh/git-source.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"context"
55
"fmt"
66

7-
"github.com/codefresh-io/go-sdk/pkg/codefresh/model"
7+
model "github.com/codefresh-io/go-sdk/pkg/codefresh/model"
88
)
99

1010
type (

pkg/codefresh/model/app-proxy/models_gen.go

Lines changed: 63 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)