Skip to content

Commit 9779d4c

Browse files
feat: cj endpoints
1 parent df5ff55 commit 9779d4c

95 files changed

Lines changed: 2825 additions & 942 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

handlers/CreateCronjob.go

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package handler
2+
3+
import (
4+
"context"
5+
"fmt"
6+
7+
mcputils "github.com/NodeOps-app/createos-mcp/helpers"
8+
"github.com/mark3labs/mcp-go/mcp"
9+
)
10+
11+
type CreateCronjobParams struct {
12+
ProjectID string `json:"project_id"`
13+
Body map[string]interface{} `json:"body"`
14+
}
15+
16+
func CreateCronjobHandler(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error) {
17+
authInfo, args, err := handleRequest(ctx, request)
18+
if err != nil {
19+
return nil, err
20+
}
21+
22+
params, err := mcputils.ParamsParser[CreateCronjobParams](args)
23+
if err != nil {
24+
return nil, fmt.Errorf("failed to parse parameters: %w", err)
25+
}
26+
27+
return makePostRequest(fmt.Sprintf("/v1/projects/%s/cronjobs", params.ProjectID), params.Body, authInfo)
28+
}

handlers/DeleteCronjob.go

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package handler
2+
3+
import (
4+
"context"
5+
"fmt"
6+
7+
mcputils "github.com/NodeOps-app/createos-mcp/helpers"
8+
"github.com/mark3labs/mcp-go/mcp"
9+
)
10+
11+
type DeleteCronjobParams struct {
12+
ProjectID string `json:"project_id"`
13+
CronjobID string `json:"cronjob_id"`
14+
}
15+
16+
func DeleteCronjobHandler(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error) {
17+
authInfo, args, err := handleRequest(ctx, request)
18+
if err != nil {
19+
return nil, err
20+
}
21+
22+
params, err := mcputils.ParamsParser[DeleteCronjobParams](args)
23+
if err != nil {
24+
return nil, fmt.Errorf("failed to parse parameters: %w", err)
25+
}
26+
27+
return makeDeleteRequest(fmt.Sprintf("/v1/projects/%s/cronjobs/%s", params.ProjectID, params.CronjobID), authInfo)
28+
}

handlers/GetCronjob.go

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package handler
2+
3+
import (
4+
"context"
5+
"fmt"
6+
7+
mcputils "github.com/NodeOps-app/createos-mcp/helpers"
8+
"github.com/mark3labs/mcp-go/mcp"
9+
)
10+
11+
type GetCronjobParams struct {
12+
ProjectID string `json:"project_id"`
13+
CronjobID string `json:"cronjob_id"`
14+
}
15+
16+
func GetCronjobHandler(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error) {
17+
authInfo, args, err := handleRequest(ctx, request)
18+
if err != nil {
19+
return nil, err
20+
}
21+
22+
params, err := mcputils.ParamsParser[GetCronjobParams](args)
23+
if err != nil {
24+
return nil, fmt.Errorf("failed to parse parameters: %w", err)
25+
}
26+
27+
return makeGetRequest(fmt.Sprintf("/v1/projects/%s/cronjobs/%s", params.ProjectID, params.CronjobID), nil, authInfo)
28+
}

handlers/ListCronjobActivities.go

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package handler
2+
3+
import (
4+
"context"
5+
"fmt"
6+
7+
mcputils "github.com/NodeOps-app/createos-mcp/helpers"
8+
"github.com/mark3labs/mcp-go/mcp"
9+
)
10+
11+
type ListCronjobActivitiesParams struct {
12+
ProjectID string `json:"project_id"`
13+
CronjobID string `json:"cronjob_id"`
14+
}
15+
16+
func ListCronjobActivitiesHandler(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error) {
17+
authInfo, args, err := handleRequest(ctx, request)
18+
if err != nil {
19+
return nil, err
20+
}
21+
22+
params, err := mcputils.ParamsParser[ListCronjobActivitiesParams](args)
23+
if err != nil {
24+
return nil, fmt.Errorf("failed to parse parameters: %w", err)
25+
}
26+
27+
return makeGetRequest(fmt.Sprintf("/v1/projects/%s/cronjobs/%s/activities", params.ProjectID, params.CronjobID), nil, authInfo)
28+
}

handlers/ListCronjobs.go

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package handler
2+
3+
import (
4+
"context"
5+
"fmt"
6+
7+
mcputils "github.com/NodeOps-app/createos-mcp/helpers"
8+
"github.com/mark3labs/mcp-go/mcp"
9+
)
10+
11+
type ListCronjobsParams struct {
12+
ProjectID string `json:"project_id"`
13+
}
14+
15+
func ListCronjobsHandler(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error) {
16+
authInfo, args, err := handleRequest(ctx, request)
17+
if err != nil {
18+
return nil, err
19+
}
20+
21+
params, err := mcputils.ParamsParser[ListCronjobsParams](args)
22+
if err != nil {
23+
return nil, fmt.Errorf("failed to parse parameters: %w", err)
24+
}
25+
26+
return makeGetRequest(fmt.Sprintf("/v1/projects/%s/cronjobs", params.ProjectID), nil, authInfo)
27+
}

handlers/SuspendCronjob.go

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package handler
2+
3+
import (
4+
"context"
5+
"fmt"
6+
7+
mcputils "github.com/NodeOps-app/createos-mcp/helpers"
8+
"github.com/mark3labs/mcp-go/mcp"
9+
)
10+
11+
type SuspendCronjobParams struct {
12+
ProjectID string `json:"project_id"`
13+
CronjobID string `json:"cronjob_id"`
14+
}
15+
16+
func SuspendCronjobHandler(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error) {
17+
authInfo, args, err := handleRequest(ctx, request)
18+
if err != nil {
19+
return nil, err
20+
}
21+
22+
params, err := mcputils.ParamsParser[SuspendCronjobParams](args)
23+
if err != nil {
24+
return nil, fmt.Errorf("failed to parse parameters: %w", err)
25+
}
26+
27+
return makePostRequest(fmt.Sprintf("/v1/projects/%s/cronjobs/%s/suspend", params.ProjectID, params.CronjobID), nil, authInfo)
28+
}

handlers/UnsuspendCronjob.go

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package handler
2+
3+
import (
4+
"context"
5+
"fmt"
6+
7+
mcputils "github.com/NodeOps-app/createos-mcp/helpers"
8+
"github.com/mark3labs/mcp-go/mcp"
9+
)
10+
11+
type UnsuspendCronjobParams struct {
12+
ProjectID string `json:"project_id"`
13+
CronjobID string `json:"cronjob_id"`
14+
}
15+
16+
func UnsuspendCronjobHandler(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error) {
17+
authInfo, args, err := handleRequest(ctx, request)
18+
if err != nil {
19+
return nil, err
20+
}
21+
22+
params, err := mcputils.ParamsParser[UnsuspendCronjobParams](args)
23+
if err != nil {
24+
return nil, fmt.Errorf("failed to parse parameters: %w", err)
25+
}
26+
27+
return makePostRequest(fmt.Sprintf("/v1/projects/%s/cronjobs/%s/unsuspend", params.ProjectID, params.CronjobID), nil, authInfo)
28+
}

handlers/UpdateCronjob.go

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package handler
2+
3+
import (
4+
"context"
5+
"fmt"
6+
7+
mcputils "github.com/NodeOps-app/createos-mcp/helpers"
8+
"github.com/mark3labs/mcp-go/mcp"
9+
)
10+
11+
type UpdateCronjobParams struct {
12+
ProjectID string `json:"project_id"`
13+
CronjobID string `json:"cronjob_id"`
14+
Body map[string]interface{} `json:"body"`
15+
}
16+
17+
func UpdateCronjobHandler(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error) {
18+
authInfo, args, err := handleRequest(ctx, request)
19+
if err != nil {
20+
return nil, err
21+
}
22+
23+
params, err := mcputils.ParamsParser[UpdateCronjobParams](args)
24+
if err != nil {
25+
return nil, fmt.Errorf("failed to parse parameters: %w", err)
26+
}
27+
28+
return makePutRequest(fmt.Sprintf("/v1/projects/%s/cronjobs/%s", params.ProjectID, params.CronjobID), params.Body, authInfo)
29+
}

mcptools/AddProjectsToApp.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,10 @@ The template shows a possible response, including its status code and content ty
8080
## Response Structure
8181
8282
- Structure (Type: object):
83-
- **message**: Error message describing what went wrong (Type: string):
84-
- Example: 'invalid uniqueName'
8583
- **success** (Type: boolean):
8684
- Example: 'false'
85+
- **message**: Error message describing what went wrong (Type: string):
86+
- Example: 'invalid uniqueName'
8787
`
8888

8989
// Response Template for the AddProjectsToApp tool (Status: 401, Content-Type: application/json)
@@ -102,10 +102,10 @@ The template shows a possible response, including its status code and content ty
102102
## Response Structure
103103
104104
- Structure (Type: object):
105-
- **message**: Error message describing what went wrong (Type: string):
106-
- Example: 'invalid uniqueName'
107105
- **success** (Type: boolean):
108106
- Example: 'false'
107+
- **message**: Error message describing what went wrong (Type: string):
108+
- Example: 'invalid uniqueName'
109109
`
110110

111111
// Response Template for the AddProjectsToApp tool (Status: 403, Content-Type: application/json)
@@ -124,10 +124,10 @@ The template shows a possible response, including its status code and content ty
124124
## Response Structure
125125
126126
- Structure (Type: object):
127-
- **message**: Error message describing what went wrong (Type: string):
128-
- Example: 'invalid uniqueName'
129127
- **success** (Type: boolean):
130128
- Example: 'false'
129+
- **message**: Error message describing what went wrong (Type: string):
130+
- Example: 'invalid uniqueName'
131131
`
132132

133133
// Response Template for the AddProjectsToApp tool (Status: 404, Content-Type: application/json)
@@ -146,10 +146,10 @@ The template shows a possible response, including its status code and content ty
146146
## Response Structure
147147
148148
- Structure (Type: object):
149-
- **message**: Error message describing what went wrong (Type: string):
150-
- Example: 'invalid uniqueName'
151149
- **success** (Type: boolean):
152150
- Example: 'false'
151+
- **message**: Error message describing what went wrong (Type: string):
152+
- Example: 'invalid uniqueName'
153153
`
154154

155155
// Response Template for the AddProjectsToApp tool (Status: 500, Content-Type: application/json)
@@ -168,10 +168,10 @@ The template shows a possible response, including its status code and content ty
168168
## Response Structure
169169
170170
- Structure (Type: object):
171-
- **message**: Error message describing what went wrong (Type: string):
172-
- Example: 'invalid uniqueName'
173171
- **success** (Type: boolean):
174172
- Example: 'false'
173+
- **message**: Error message describing what went wrong (Type: string):
174+
- Example: 'invalid uniqueName'
175175
`
176176

177177
// NewAddProjectsToAppMCPTool creates the MCP Tool instance for AddProjectsToApp

mcptools/AddServicesToApp.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,10 @@ The template shows a possible response, including its status code and content ty
8080
## Response Structure
8181
8282
- Structure (Type: object):
83-
- **message**: Error message describing what went wrong (Type: string):
84-
- Example: 'invalid uniqueName'
8583
- **success** (Type: boolean):
8684
- Example: 'false'
85+
- **message**: Error message describing what went wrong (Type: string):
86+
- Example: 'invalid uniqueName'
8787
`
8888

8989
// Response Template for the AddServicesToApp tool (Status: 401, Content-Type: application/json)
@@ -102,10 +102,10 @@ The template shows a possible response, including its status code and content ty
102102
## Response Structure
103103
104104
- Structure (Type: object):
105-
- **message**: Error message describing what went wrong (Type: string):
106-
- Example: 'invalid uniqueName'
107105
- **success** (Type: boolean):
108106
- Example: 'false'
107+
- **message**: Error message describing what went wrong (Type: string):
108+
- Example: 'invalid uniqueName'
109109
`
110110

111111
// Response Template for the AddServicesToApp tool (Status: 403, Content-Type: application/json)
@@ -124,10 +124,10 @@ The template shows a possible response, including its status code and content ty
124124
## Response Structure
125125
126126
- Structure (Type: object):
127-
- **message**: Error message describing what went wrong (Type: string):
128-
- Example: 'invalid uniqueName'
129127
- **success** (Type: boolean):
130128
- Example: 'false'
129+
- **message**: Error message describing what went wrong (Type: string):
130+
- Example: 'invalid uniqueName'
131131
`
132132

133133
// Response Template for the AddServicesToApp tool (Status: 404, Content-Type: application/json)
@@ -146,10 +146,10 @@ The template shows a possible response, including its status code and content ty
146146
## Response Structure
147147
148148
- Structure (Type: object):
149-
- **message**: Error message describing what went wrong (Type: string):
150-
- Example: 'invalid uniqueName'
151149
- **success** (Type: boolean):
152150
- Example: 'false'
151+
- **message**: Error message describing what went wrong (Type: string):
152+
- Example: 'invalid uniqueName'
153153
`
154154

155155
// Response Template for the AddServicesToApp tool (Status: 500, Content-Type: application/json)
@@ -168,10 +168,10 @@ The template shows a possible response, including its status code and content ty
168168
## Response Structure
169169
170170
- Structure (Type: object):
171-
- **message**: Error message describing what went wrong (Type: string):
172-
- Example: 'invalid uniqueName'
173171
- **success** (Type: boolean):
174172
- Example: 'false'
173+
- **message**: Error message describing what went wrong (Type: string):
174+
- Example: 'invalid uniqueName'
175175
`
176176

177177
// NewAddServicesToAppMCPTool creates the MCP Tool instance for AddServicesToApp

0 commit comments

Comments
 (0)