-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathoperation_controller.ex
More file actions
116 lines (103 loc) · 3.2 KB
/
Copy pathoperation_controller.ex
File metadata and controls
116 lines (103 loc) · 3.2 KB
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
# SPDX-FileCopyrightText: SUSE LLC
# SPDX-License-Identifier: Apache-2.0
defmodule WandaWeb.V1.OperationController do
use WandaWeb, :controller
use OpenApiSpex.ControllerSpecs
alias OpenApiSpex.Schema
alias Wanda.Operations
alias WandaWeb.Schemas.V1.{NotFound, UnprocessableEntity}
alias WandaWeb.Schemas.V1.Operation.{
ListOperationsResponse,
OperationResponse
}
require Wanda.Operations.Enums.Status, as: Status
plug OpenApiSpex.Plug.CastAndValidate, json_render_error_v2: true
action_fallback WandaWeb.FallbackController
operation :index,
summary: "List operations.",
description:
"Provides a paginated list of operations performed in the system, allowing for easy tracking and management.",
tags: ["Operations Engine", "MCP"],
"x-ai-tool": %{
name: "operations_list",
display_text: "Operations List"
},
parameters: [
group_id: [
in: :query,
description: "The unique identifier of the group to filter the operations list.",
type: %Schema{
type: :string,
format: :uuid
},
example: "c1a2b3c4-d5e6-7890-abcd-ef1234567890"
],
page: [
in: :query,
description: "Specify the page number to retrieve paginated results for operations.",
type: :integer,
example: 3
],
items_per_page: [
in: :query,
description: "Set the number of items to be returned per page in the paginated results.",
type: :integer,
example: 20
],
status: [
in: :query,
description: "Filter the operations by their status, using one of the allowed values.",
type: %Schema{
type: :string,
enum: Status.values()
}
]
],
responses: [
ok:
{"A successful response containing a paginated list of operations.", "application/json",
ListOperationsResponse},
unprocessable_entity: UnprocessableEntity.response()
]
def index(conn, params) do
operations =
params
|> Operations.list_operations()
|> Enum.map(&Operations.enrich_operation!(&1))
render(conn, operations: operations)
end
operation :show,
summary: "Get an operation by ID.",
description:
"Provides detailed information about a specific operation identified by its UUID.",
tags: ["Operations Engine", "MCP"],
"x-ai-tool": %{
name: "operations_details",
display_text: "Operation Details"
},
parameters: [
id: [
in: :path,
description: "The unique identifier (UUID) of the operation to retrieve details for.",
type: %Schema{
type: :string,
format: :uuid
},
example: "c1a2b3c4-d5e6-7890-abcd-ef1234567890"
]
],
responses: [
ok:
{"A successful response containing details of the requested operation.",
"application/json", OperationResponse},
not_found: NotFound.response(),
unprocessable_entity: UnprocessableEntity.response()
]
def show(conn, %{id: operation_id}) do
operation =
operation_id
|> Operations.get_operation!()
|> Operations.enrich_operation!()
render(conn, operation: operation)
end
end