abapgit-agent 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.abapGitAgent.example +11 -0
- package/API.md +271 -0
- package/CLAUDE.md +445 -0
- package/CLAUDE_MEM.md +88 -0
- package/ERROR_HANDLING.md +30 -0
- package/INSTALL.md +160 -0
- package/README.md +127 -0
- package/abap/CLAUDE.md +492 -0
- package/abap/package.devc.xml +10 -0
- package/abap/zcl_abgagt_agent.clas.abap +769 -0
- package/abap/zcl_abgagt_agent.clas.xml +15 -0
- package/abap/zcl_abgagt_cmd_factory.clas.abap +43 -0
- package/abap/zcl_abgagt_cmd_factory.clas.xml +15 -0
- package/abap/zcl_abgagt_command_inspect.clas.abap +192 -0
- package/abap/zcl_abgagt_command_inspect.clas.testclasses.abap +121 -0
- package/abap/zcl_abgagt_command_inspect.clas.xml +16 -0
- package/abap/zcl_abgagt_command_pull.clas.abap +80 -0
- package/abap/zcl_abgagt_command_pull.clas.testclasses.abap +87 -0
- package/abap/zcl_abgagt_command_pull.clas.xml +16 -0
- package/abap/zcl_abgagt_command_unit.clas.abap +297 -0
- package/abap/zcl_abgagt_command_unit.clas.xml +15 -0
- package/abap/zcl_abgagt_resource_health.clas.abap +25 -0
- package/abap/zcl_abgagt_resource_health.clas.xml +15 -0
- package/abap/zcl_abgagt_resource_inspect.clas.abap +62 -0
- package/abap/zcl_abgagt_resource_inspect.clas.xml +15 -0
- package/abap/zcl_abgagt_resource_pull.clas.abap +71 -0
- package/abap/zcl_abgagt_resource_pull.clas.xml +15 -0
- package/abap/zcl_abgagt_resource_unit.clas.abap +64 -0
- package/abap/zcl_abgagt_resource_unit.clas.xml +15 -0
- package/abap/zcl_abgagt_rest_handler.clas.abap +27 -0
- package/abap/zcl_abgagt_rest_handler.clas.xml +15 -0
- package/abap/zcl_abgagt_util.clas.abap +93 -0
- package/abap/zcl_abgagt_util.clas.testclasses.abap +84 -0
- package/abap/zcl_abgagt_util.clas.xml +16 -0
- package/abap/zif_abgagt_agent.intf.abap +134 -0
- package/abap/zif_abgagt_agent.intf.xml +15 -0
- package/abap/zif_abgagt_cmd_factory.intf.abap +7 -0
- package/abap/zif_abgagt_cmd_factory.intf.xml +15 -0
- package/abap/zif_abgagt_command.intf.abap +21 -0
- package/abap/zif_abgagt_command.intf.xml +15 -0
- package/abap/zif_abgagt_util.intf.abap +28 -0
- package/abap/zif_abgagt_util.intf.xml +15 -0
- package/bin/abapgit-agent +902 -0
- package/img/claude.png +0 -0
- package/package.json +31 -0
- package/scripts/claude-integration.js +351 -0
- package/scripts/test-integration.js +139 -0
- package/src/abap-client.js +314 -0
- package/src/agent.js +119 -0
- package/src/config.js +66 -0
- package/src/index.js +48 -0
- package/src/logger.js +39 -0
- package/src/server.js +116 -0
|
@@ -0,0 +1,297 @@
|
|
|
1
|
+
*"*"use source
|
|
2
|
+
*"*"Local Interface:
|
|
3
|
+
*"**********************************************************************
|
|
4
|
+
" UNIT command implementation - runs AUnit tests directly
|
|
5
|
+
CLASS zcl_abgagt_command_unit DEFINITION PUBLIC FINAL CREATE PUBLIC.
|
|
6
|
+
PUBLIC SECTION.
|
|
7
|
+
INTERFACES zif_abgagt_command.
|
|
8
|
+
|
|
9
|
+
TYPES: BEGIN OF ty_unit_params,
|
|
10
|
+
package TYPE string,
|
|
11
|
+
files TYPE string_table,
|
|
12
|
+
END OF ty_unit_params.
|
|
13
|
+
|
|
14
|
+
" Error structure for failed test methods
|
|
15
|
+
TYPES: BEGIN OF ty_error,
|
|
16
|
+
class_name TYPE string,
|
|
17
|
+
method_name TYPE string,
|
|
18
|
+
error_kind TYPE string,
|
|
19
|
+
error_text TYPE string,
|
|
20
|
+
END OF ty_error.
|
|
21
|
+
|
|
22
|
+
TYPES ty_errors TYPE STANDARD TABLE OF ty_error WITH DEFAULT KEY.
|
|
23
|
+
|
|
24
|
+
TYPES: BEGIN OF ty_unit_result,
|
|
25
|
+
success TYPE abap_bool,
|
|
26
|
+
message TYPE string,
|
|
27
|
+
test_count TYPE i,
|
|
28
|
+
passed_count TYPE i,
|
|
29
|
+
failed_count TYPE i,
|
|
30
|
+
errors TYPE ty_errors,
|
|
31
|
+
END OF ty_unit_result.
|
|
32
|
+
|
|
33
|
+
TYPES: BEGIN OF ty_key,
|
|
34
|
+
obj_name TYPE tadir-obj_name,
|
|
35
|
+
obj_type TYPE tadir-object,
|
|
36
|
+
END OF ty_key.
|
|
37
|
+
|
|
38
|
+
TYPES ty_keys TYPE STANDARD TABLE OF ty_key WITH DEFAULT KEY.
|
|
39
|
+
|
|
40
|
+
METHODS run_aunit_tests
|
|
41
|
+
IMPORTING
|
|
42
|
+
iv_package TYPE devclass OPTIONAL
|
|
43
|
+
it_keys TYPE ty_keys OPTIONAL
|
|
44
|
+
RETURNING
|
|
45
|
+
VALUE(rs_result) TYPE ty_unit_result.
|
|
46
|
+
|
|
47
|
+
PRIVATE SECTION.
|
|
48
|
+
" Methods for extracting errors from nested structure using CL_SUT_AUNIT_RUNNER types
|
|
49
|
+
METHODS get_failed_methods
|
|
50
|
+
IMPORTING
|
|
51
|
+
it_tab_objects TYPE cl_sut_aunit_runner=>typ_tab_objects
|
|
52
|
+
RETURNING
|
|
53
|
+
VALUE(rt_errors) TYPE ty_errors.
|
|
54
|
+
|
|
55
|
+
METHODS extract_errors_from_object
|
|
56
|
+
IMPORTING
|
|
57
|
+
is_object TYPE cl_sut_aunit_runner=>typ_str_object
|
|
58
|
+
RETURNING
|
|
59
|
+
VALUE(rt_errors) TYPE ty_errors.
|
|
60
|
+
|
|
61
|
+
METHODS extract_errors_from_testclass
|
|
62
|
+
IMPORTING
|
|
63
|
+
is_testclass TYPE cl_sut_aunit_runner=>typ_str_testclass
|
|
64
|
+
iv_class_name TYPE seoclass-clsname
|
|
65
|
+
RETURNING
|
|
66
|
+
VALUE(rt_errors) TYPE ty_errors.
|
|
67
|
+
|
|
68
|
+
METHODS extract_error_from_method
|
|
69
|
+
IMPORTING
|
|
70
|
+
is_method TYPE cl_sut_aunit_runner=>typ_str_method
|
|
71
|
+
iv_method_name TYPE saunit_s_method_key-method
|
|
72
|
+
RETURNING
|
|
73
|
+
VALUE(rs_error) TYPE ty_error.
|
|
74
|
+
|
|
75
|
+
ENDCLASS.
|
|
76
|
+
|
|
77
|
+
CLASS zcl_abgagt_command_unit IMPLEMENTATION.
|
|
78
|
+
|
|
79
|
+
METHOD zif_abgagt_command~get_name.
|
|
80
|
+
rv_name = zif_abgagt_command=>gc_unit.
|
|
81
|
+
ENDMETHOD.
|
|
82
|
+
|
|
83
|
+
METHOD zif_abgagt_command~execute.
|
|
84
|
+
DATA: ls_params TYPE ty_unit_params,
|
|
85
|
+
lv_package TYPE devclass,
|
|
86
|
+
lv_file TYPE string,
|
|
87
|
+
lv_obj_type TYPE string,
|
|
88
|
+
lv_obj_name TYPE string,
|
|
89
|
+
lo_util TYPE REF TO zcl_abgagt_util,
|
|
90
|
+
ls_result TYPE ty_unit_result,
|
|
91
|
+
lt_keys TYPE ty_keys,
|
|
92
|
+
ls_key TYPE ty_key.
|
|
93
|
+
|
|
94
|
+
" Parse parameters from is_param
|
|
95
|
+
IF is_param IS SUPPLIED.
|
|
96
|
+
ls_params = CORRESPONDING #( is_param ).
|
|
97
|
+
ENDIF.
|
|
98
|
+
|
|
99
|
+
" Convert package string to devclass
|
|
100
|
+
IF ls_params-package IS NOT INITIAL.
|
|
101
|
+
lv_package = ls_params-package.
|
|
102
|
+
ENDIF.
|
|
103
|
+
|
|
104
|
+
" Parse files to get object keys
|
|
105
|
+
IF ls_params-files IS NOT INITIAL.
|
|
106
|
+
lo_util = zcl_abgagt_util=>get_instance( ).
|
|
107
|
+
LOOP AT ls_params-files INTO lv_file.
|
|
108
|
+
CLEAR: lv_obj_type, lv_obj_name.
|
|
109
|
+
lo_util->zif_abgagt_util~parse_file_to_object(
|
|
110
|
+
EXPORTING iv_file = lv_file
|
|
111
|
+
IMPORTING ev_obj_type = lv_obj_type
|
|
112
|
+
ev_obj_name = lv_obj_name ).
|
|
113
|
+
IF lv_obj_type IS NOT INITIAL AND lv_obj_name IS NOT INITIAL.
|
|
114
|
+
CLEAR ls_key.
|
|
115
|
+
ls_key-obj_type = lv_obj_type.
|
|
116
|
+
ls_key-obj_name = lv_obj_name.
|
|
117
|
+
APPEND ls_key TO lt_keys.
|
|
118
|
+
ENDIF.
|
|
119
|
+
ENDLOOP.
|
|
120
|
+
ENDIF.
|
|
121
|
+
|
|
122
|
+
" Initialize result
|
|
123
|
+
ls_result-success = abap_false.
|
|
124
|
+
ls_result-test_count = 0.
|
|
125
|
+
ls_result-passed_count = 0.
|
|
126
|
+
ls_result-failed_count = 0.
|
|
127
|
+
|
|
128
|
+
IF lt_keys IS INITIAL AND lv_package IS INITIAL.
|
|
129
|
+
ls_result-message = 'No files or package provided'.
|
|
130
|
+
rv_result = /ui2/cl_json=>serialize( data = ls_result ).
|
|
131
|
+
RETURN.
|
|
132
|
+
ENDIF.
|
|
133
|
+
|
|
134
|
+
" Remove duplicates from keys
|
|
135
|
+
IF lt_keys IS NOT INITIAL.
|
|
136
|
+
SORT lt_keys BY obj_type obj_name.
|
|
137
|
+
DELETE ADJACENT DUPLICATES FROM lt_keys COMPARING obj_type obj_name.
|
|
138
|
+
ENDIF.
|
|
139
|
+
|
|
140
|
+
" Run tests and get result directly from str_results
|
|
141
|
+
ls_result = run_aunit_tests(
|
|
142
|
+
iv_package = lv_package
|
|
143
|
+
it_keys = lt_keys ).
|
|
144
|
+
|
|
145
|
+
IF ls_result-test_count = 0 AND ls_result-failed_count = 0.
|
|
146
|
+
ls_result-message = 'No test results returned'.
|
|
147
|
+
rv_result = /ui2/cl_json=>serialize( data = ls_result ).
|
|
148
|
+
RETURN.
|
|
149
|
+
ENDIF.
|
|
150
|
+
|
|
151
|
+
IF ls_result-failed_count = 0.
|
|
152
|
+
ls_result-success = abap_true.
|
|
153
|
+
ls_result-message = |All { ls_result-test_count } tests passed|.
|
|
154
|
+
ELSE.
|
|
155
|
+
ls_result-message = |{ ls_result-failed_count } of { ls_result-test_count } tests failed|.
|
|
156
|
+
ENDIF.
|
|
157
|
+
|
|
158
|
+
rv_result = /ui2/cl_json=>serialize( data = ls_result ).
|
|
159
|
+
ENDMETHOD.
|
|
160
|
+
|
|
161
|
+
METHOD run_aunit_tests.
|
|
162
|
+
DATA: lo_runner TYPE REF TO cl_sut_aunit_runner.
|
|
163
|
+
|
|
164
|
+
" Create runner using S_CREATE
|
|
165
|
+
cl_sut_aunit_runner=>s_create(
|
|
166
|
+
EXPORTING
|
|
167
|
+
p_cov = abap_false
|
|
168
|
+
i_flg_api = abap_true
|
|
169
|
+
RECEIVING
|
|
170
|
+
r_ref_runner = lo_runner ).
|
|
171
|
+
|
|
172
|
+
" Configure runner for OBJECT selection mode
|
|
173
|
+
lo_runner->p_disp = abap_false. " No GUI display
|
|
174
|
+
lo_runner->p_save = abap_true. " Save results
|
|
175
|
+
lo_runner->p_runmd = 'E'. " Execute mode
|
|
176
|
+
|
|
177
|
+
" Set selection type to OBJECT
|
|
178
|
+
lo_runner->p_seltyp = 'OBJECT'.
|
|
179
|
+
lo_runner->p_selcl = abap_true. " Enable class selection mode
|
|
180
|
+
|
|
181
|
+
" Build SO_CLASS range for test class(es)
|
|
182
|
+
DATA lt_so_class TYPE RANGE OF seoaliases-clsname.
|
|
183
|
+
IF it_keys IS NOT INITIAL.
|
|
184
|
+
LOOP AT it_keys ASSIGNING FIELD-SYMBOL(<ls_key>).
|
|
185
|
+
APPEND VALUE #( sign = 'I' option = 'EQ' low = <ls_key>-obj_name ) TO lt_so_class.
|
|
186
|
+
ENDLOOP.
|
|
187
|
+
ENDIF.
|
|
188
|
+
|
|
189
|
+
" Set the class range
|
|
190
|
+
lo_runner->so_class[] = lt_so_class[].
|
|
191
|
+
|
|
192
|
+
" Run tests
|
|
193
|
+
TRY.
|
|
194
|
+
lo_runner->run(
|
|
195
|
+
EXPORTING
|
|
196
|
+
i_flg_select_only = abap_false
|
|
197
|
+
EXCEPTIONS
|
|
198
|
+
OTHERS = 1 ).
|
|
199
|
+
CATCH cx_sut_error.
|
|
200
|
+
RETURN.
|
|
201
|
+
ENDTRY.
|
|
202
|
+
|
|
203
|
+
IF sy-subrc <> 0.
|
|
204
|
+
RETURN.
|
|
205
|
+
ENDIF.
|
|
206
|
+
|
|
207
|
+
" Get results from str_results - use type from CL_SUT_AUNIT_RUNNER
|
|
208
|
+
DATA: ls_str TYPE cl_sut_aunit_runner=>typ_str_results.
|
|
209
|
+
ls_str = lo_runner->str_results.
|
|
210
|
+
|
|
211
|
+
" Fill result directly from str_results counts
|
|
212
|
+
rs_result-test_count = ls_str-cnt_testmethods.
|
|
213
|
+
rs_result-passed_count = ls_str-cnt_ok_methods.
|
|
214
|
+
rs_result-failed_count = ls_str-cnt_error_methods.
|
|
215
|
+
|
|
216
|
+
IF rs_result-failed_count > 0 OR ls_str-pie_abortions > 0.
|
|
217
|
+
rs_result-success = abap_false.
|
|
218
|
+
ELSE.
|
|
219
|
+
rs_result-success = abap_true.
|
|
220
|
+
ENDIF.
|
|
221
|
+
|
|
222
|
+
" Extract failed method details from tab_objects
|
|
223
|
+
rs_result-errors = get_failed_methods( lo_runner->tab_objects ).
|
|
224
|
+
ENDMETHOD.
|
|
225
|
+
|
|
226
|
+
METHOD get_failed_methods.
|
|
227
|
+
" Entry point for extracting failed methods from TAB_OBJECTS
|
|
228
|
+
LOOP AT it_tab_objects ASSIGNING FIELD-SYMBOL(<ls_object>).
|
|
229
|
+
" Extract errors from this object
|
|
230
|
+
DATA(lt_errors) = extract_errors_from_object( <ls_object> ).
|
|
231
|
+
APPEND LINES OF lt_errors TO rt_errors.
|
|
232
|
+
ENDLOOP.
|
|
233
|
+
ENDMETHOD.
|
|
234
|
+
|
|
235
|
+
METHOD extract_errors_from_object.
|
|
236
|
+
" Extract errors from TAB_TESTCLASSES within an object
|
|
237
|
+
LOOP AT is_object-tab_testclasses ASSIGNING FIELD-SYMBOL(<ls_tcl>).
|
|
238
|
+
" Extract errors from this testclass
|
|
239
|
+
DATA(lt_errors) = extract_errors_from_testclass(
|
|
240
|
+
is_testclass = <ls_tcl>
|
|
241
|
+
iv_class_name = is_object-clsname ).
|
|
242
|
+
APPEND LINES OF lt_errors TO rt_errors.
|
|
243
|
+
ENDLOOP.
|
|
244
|
+
ENDMETHOD.
|
|
245
|
+
|
|
246
|
+
METHOD extract_errors_from_testclass.
|
|
247
|
+
" Extract errors from TAB_METHODS within a testclass
|
|
248
|
+
LOOP AT is_testclass-tab_methods ASSIGNING FIELD-SYMBOL(<ls_method>).
|
|
249
|
+
" Extract error from this method
|
|
250
|
+
DATA(ls_error) = extract_error_from_method(
|
|
251
|
+
is_method = <ls_method>
|
|
252
|
+
iv_method_name = <ls_method>-methodname ).
|
|
253
|
+
|
|
254
|
+
" Only add if there's an error
|
|
255
|
+
IF ls_error-error_text IS NOT INITIAL.
|
|
256
|
+
ls_error-class_name = iv_class_name.
|
|
257
|
+
APPEND ls_error TO rt_errors.
|
|
258
|
+
ENDIF.
|
|
259
|
+
ENDLOOP.
|
|
260
|
+
ENDMETHOD.
|
|
261
|
+
|
|
262
|
+
METHOD extract_error_from_method.
|
|
263
|
+
" Extract STR_ERROR from method and build error structure
|
|
264
|
+
" typ_str_error contains typ_str_error_core via INCLUDE as STR_ERROR_CORE
|
|
265
|
+
|
|
266
|
+
" Check if there's an error - only process if error kind is set
|
|
267
|
+
IF is_method-str_error IS INITIAL.
|
|
268
|
+
RETURN.
|
|
269
|
+
ENDIF.
|
|
270
|
+
|
|
271
|
+
" Get error kind (e.g., 'ERROR', 'FAILURE')
|
|
272
|
+
rs_error-error_kind = is_method-str_error-str_error_core-errorkind.
|
|
273
|
+
|
|
274
|
+
" Only process if there's an actual error
|
|
275
|
+
IF rs_error-error_kind IS INITIAL.
|
|
276
|
+
RETURN.
|
|
277
|
+
ENDIF.
|
|
278
|
+
|
|
279
|
+
" Get error text
|
|
280
|
+
rs_error-error_text = is_method-str_error-str_error_core-errortext.
|
|
281
|
+
|
|
282
|
+
" If no error text, try tab_messages
|
|
283
|
+
IF rs_error-error_text IS INITIAL.
|
|
284
|
+
DATA lv_messages TYPE string.
|
|
285
|
+
LOOP AT is_method-str_error-str_error_core-tab_messages ASSIGNING FIELD-SYMBOL(<lv_msg>).
|
|
286
|
+
IF lv_messages IS NOT INITIAL.
|
|
287
|
+
lv_messages = |{ lv_messages }\n|.
|
|
288
|
+
ENDIF.
|
|
289
|
+
lv_messages = |{ lv_messages }{ <lv_msg> }|.
|
|
290
|
+
ENDLOOP.
|
|
291
|
+
rs_error-error_text = lv_messages.
|
|
292
|
+
ENDIF.
|
|
293
|
+
|
|
294
|
+
rs_error-method_name = iv_method_name.
|
|
295
|
+
ENDMETHOD.
|
|
296
|
+
|
|
297
|
+
ENDCLASS.
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
+
<abapGit version="v1.0.0" serializer="LCL_OBJECT_CLAS" serializer_version="v1.0.0">
|
|
3
|
+
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
|
|
4
|
+
<asx:values>
|
|
5
|
+
<VSEOCLASS>
|
|
6
|
+
<CLSNAME>ZCL_ABGAGT_COMMAND_UNIT</CLSNAME>
|
|
7
|
+
<LANGU>E</LANGU>
|
|
8
|
+
<DESCRIPT>Unit Command for ABAP Git Agent</DESCRIPT>
|
|
9
|
+
<EXPOSURE>2</EXPOSURE>
|
|
10
|
+
<STATE>1</STATE>
|
|
11
|
+
<UNICODE>X</UNICODE>
|
|
12
|
+
</VSEOCLASS>
|
|
13
|
+
</asx:values>
|
|
14
|
+
</asx:abap>
|
|
15
|
+
</abapGit>
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
*"*"use source
|
|
2
|
+
*"*"Local Interface:
|
|
3
|
+
*"**********************************************************************
|
|
4
|
+
CLASS zcl_abgagt_resource_health DEFINITION PUBLIC FINAL
|
|
5
|
+
INHERITING FROM cl_rest_resource
|
|
6
|
+
CREATE PUBLIC.
|
|
7
|
+
|
|
8
|
+
PUBLIC SECTION.
|
|
9
|
+
METHODS if_rest_resource~get REDEFINITION.
|
|
10
|
+
|
|
11
|
+
ENDCLASS.
|
|
12
|
+
|
|
13
|
+
CLASS zcl_abgagt_resource_health IMPLEMENTATION.
|
|
14
|
+
|
|
15
|
+
METHOD if_rest_resource~get.
|
|
16
|
+
DATA lv_json TYPE string.
|
|
17
|
+
lv_json = '{"status":"OK","version":"1.0.0"}'.
|
|
18
|
+
|
|
19
|
+
DATA(lo_entity) = mo_response->create_entity( ).
|
|
20
|
+
lo_entity->set_content_type( iv_media_type = if_rest_media_type=>gc_appl_json ).
|
|
21
|
+
lo_entity->set_string_data( lv_json ).
|
|
22
|
+
mo_response->set_status( cl_rest_status_code=>gc_success_ok ).
|
|
23
|
+
ENDMETHOD.
|
|
24
|
+
|
|
25
|
+
ENDCLASS.
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
+
<abapGit version="v1.0.0" serializer="LCL_OBJECT_CLAS" serializer_version="v1.0.0">
|
|
3
|
+
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
|
|
4
|
+
<asx:values>
|
|
5
|
+
<VSEOCLASS>
|
|
6
|
+
<CLSNAME>ZCL_ABGAGT_RESOURCE_HEALTH</CLSNAME>
|
|
7
|
+
<LANGU>E</LANGU>
|
|
8
|
+
<DESCRIPT>ABAP Git Agent - Health Resource</DESCRIPT>
|
|
9
|
+
<EXPOSURE>2</EXPOSURE>
|
|
10
|
+
<STATE>1</STATE>
|
|
11
|
+
<UNICODE>X</UNICODE>
|
|
12
|
+
</VSEOCLASS>
|
|
13
|
+
</asx:values>
|
|
14
|
+
</asx:abap>
|
|
15
|
+
</abapGit>
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
*"*"use source
|
|
2
|
+
*"*"Local Interface:
|
|
3
|
+
*"**********************************************************************
|
|
4
|
+
CLASS zcl_abgagt_resource_inspect DEFINITION PUBLIC FINAL
|
|
5
|
+
INHERITING FROM cl_rest_resource
|
|
6
|
+
CREATE PUBLIC.
|
|
7
|
+
|
|
8
|
+
PUBLIC SECTION.
|
|
9
|
+
METHODS if_rest_resource~post REDEFINITION.
|
|
10
|
+
|
|
11
|
+
ENDCLASS.
|
|
12
|
+
|
|
13
|
+
CLASS zcl_abgagt_resource_inspect IMPLEMENTATION.
|
|
14
|
+
|
|
15
|
+
METHOD if_rest_resource~post.
|
|
16
|
+
DATA lv_json TYPE string.
|
|
17
|
+
lv_json = mo_request->get_entity( )->get_string_data( ).
|
|
18
|
+
|
|
19
|
+
" Parse JSON using /ui2/cl_json
|
|
20
|
+
DATA: BEGIN OF ls_request,
|
|
21
|
+
files TYPE string_table,
|
|
22
|
+
END OF ls_request.
|
|
23
|
+
|
|
24
|
+
/ui2/cl_json=>deserialize(
|
|
25
|
+
EXPORTING
|
|
26
|
+
json = lv_json
|
|
27
|
+
CHANGING
|
|
28
|
+
data = ls_request ).
|
|
29
|
+
|
|
30
|
+
DATA lv_json_resp TYPE string.
|
|
31
|
+
IF ls_request-files IS INITIAL OR lines( ls_request-files ) = 0.
|
|
32
|
+
lv_json_resp = '{"success":"","object_type":"","object_name":"","error_count":1,"errors":[{"line":"1","column":"1","text":"Files list is required"}]}'.
|
|
33
|
+
DATA(lo_entity) = mo_response->create_entity( ).
|
|
34
|
+
lo_entity->set_content_type( iv_media_type = if_rest_media_type=>gc_appl_json ).
|
|
35
|
+
lo_entity->set_string_data( lv_json_resp ).
|
|
36
|
+
mo_response->set_status( cl_rest_status_code=>gc_client_error_bad_request ).
|
|
37
|
+
RETURN.
|
|
38
|
+
ENDIF.
|
|
39
|
+
|
|
40
|
+
" Get command from factory
|
|
41
|
+
DATA(lo_factory) = zcl_abgagt_cmd_factory=>get_instance( ).
|
|
42
|
+
DATA(lo_command) = lo_factory->get_command( zif_abgagt_command=>gc_inspect ).
|
|
43
|
+
|
|
44
|
+
IF lo_command IS NOT BOUND.
|
|
45
|
+
lv_json_resp = '{"success":"","error":"INSPECT command not found"}'.
|
|
46
|
+
lo_entity = mo_response->create_entity( ).
|
|
47
|
+
lo_entity->set_content_type( iv_media_type = if_rest_media_type=>gc_appl_json ).
|
|
48
|
+
lo_entity->set_string_data( lv_json_resp ).
|
|
49
|
+
mo_response->set_status( cl_rest_status_code=>gc_client_error_bad_request ).
|
|
50
|
+
RETURN.
|
|
51
|
+
ENDIF.
|
|
52
|
+
|
|
53
|
+
" Execute command with is_param
|
|
54
|
+
DATA(lv_result) = lo_command->execute( is_param = ls_request ).
|
|
55
|
+
|
|
56
|
+
lo_entity = mo_response->create_entity( ).
|
|
57
|
+
lo_entity->set_content_type( iv_media_type = if_rest_media_type=>gc_appl_json ).
|
|
58
|
+
lo_entity->set_string_data( lv_result ).
|
|
59
|
+
mo_response->set_status( cl_rest_status_code=>gc_success_ok ).
|
|
60
|
+
ENDMETHOD.
|
|
61
|
+
|
|
62
|
+
ENDCLASS.
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
+
<abapGit version="v1.0.0" serializer="LCL_OBJECT_CLAS" serializer_version="v1.0.0">
|
|
3
|
+
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
|
|
4
|
+
<asx:values>
|
|
5
|
+
<VSEOCLASS>
|
|
6
|
+
<CLSNAME>ZCL_ABGAGT_RESOURCE_INSPECT</CLSNAME>
|
|
7
|
+
<LANGU>E</LANGU>
|
|
8
|
+
<DESCRIPT>ABAP Git Agent - Inspect Resource</DESCRIPT>
|
|
9
|
+
<EXPOSURE>2</EXPOSURE>
|
|
10
|
+
<STATE>1</STATE>
|
|
11
|
+
<UNICODE>X</UNICODE>
|
|
12
|
+
</VSEOCLASS>
|
|
13
|
+
</asx:values>
|
|
14
|
+
</asx:abap>
|
|
15
|
+
</abapGit>
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
*"*"use source
|
|
2
|
+
*"*"Local Interface:
|
|
3
|
+
*"**********************************************************************
|
|
4
|
+
CLASS zcl_abgagt_resource_pull DEFINITION PUBLIC FINAL
|
|
5
|
+
INHERITING FROM cl_rest_resource
|
|
6
|
+
CREATE PUBLIC.
|
|
7
|
+
|
|
8
|
+
PUBLIC SECTION.
|
|
9
|
+
METHODS if_rest_resource~post REDEFINITION.
|
|
10
|
+
|
|
11
|
+
ENDCLASS.
|
|
12
|
+
|
|
13
|
+
CLASS zcl_abgagt_resource_pull IMPLEMENTATION.
|
|
14
|
+
|
|
15
|
+
METHOD if_rest_resource~post.
|
|
16
|
+
DATA lv_json TYPE string.
|
|
17
|
+
lv_json = mo_request->get_entity( )->get_string_data( ).
|
|
18
|
+
|
|
19
|
+
" Parse JSON using /ui2/cl_json
|
|
20
|
+
DATA: BEGIN OF ls_request,
|
|
21
|
+
url TYPE string,
|
|
22
|
+
branch TYPE string,
|
|
23
|
+
username TYPE string,
|
|
24
|
+
password TYPE string,
|
|
25
|
+
transport_request TYPE string,
|
|
26
|
+
files TYPE string_table,
|
|
27
|
+
END OF ls_request.
|
|
28
|
+
|
|
29
|
+
/ui2/cl_json=>deserialize(
|
|
30
|
+
EXPORTING
|
|
31
|
+
json = lv_json
|
|
32
|
+
CHANGING
|
|
33
|
+
data = ls_request ).
|
|
34
|
+
|
|
35
|
+
IF ls_request-branch IS INITIAL.
|
|
36
|
+
ls_request-branch = 'main'.
|
|
37
|
+
ENDIF.
|
|
38
|
+
|
|
39
|
+
DATA lv_json_resp TYPE string.
|
|
40
|
+
IF ls_request-url IS INITIAL.
|
|
41
|
+
lv_json_resp = '{"success":"","job_id":"","error":"URL is required"}'.
|
|
42
|
+
DATA(lo_entity) = mo_response->create_entity( ).
|
|
43
|
+
lo_entity->set_content_type( iv_media_type = if_rest_media_type=>gc_appl_json ).
|
|
44
|
+
lo_entity->set_string_data( lv_json_resp ).
|
|
45
|
+
mo_response->set_status( cl_rest_status_code=>gc_client_error_bad_request ).
|
|
46
|
+
RETURN.
|
|
47
|
+
ENDIF.
|
|
48
|
+
|
|
49
|
+
" Get command from factory
|
|
50
|
+
DATA(lo_factory) = zcl_abgagt_cmd_factory=>get_instance( ).
|
|
51
|
+
DATA(lo_command) = lo_factory->get_command( zif_abgagt_command=>gc_pull ).
|
|
52
|
+
|
|
53
|
+
IF lo_command IS NOT BOUND.
|
|
54
|
+
lv_json_resp = '{"success":"","error":"PULL command not found"}'.
|
|
55
|
+
lo_entity = mo_response->create_entity( ).
|
|
56
|
+
lo_entity->set_content_type( iv_media_type = if_rest_media_type=>gc_appl_json ).
|
|
57
|
+
lo_entity->set_string_data( lv_json_resp ).
|
|
58
|
+
mo_response->set_status( cl_rest_status_code=>gc_client_error_bad_request ).
|
|
59
|
+
RETURN.
|
|
60
|
+
ENDIF.
|
|
61
|
+
|
|
62
|
+
" Execute command with is_param
|
|
63
|
+
DATA(lv_result) = lo_command->execute( is_param = ls_request ).
|
|
64
|
+
|
|
65
|
+
lo_entity = mo_response->create_entity( ).
|
|
66
|
+
lo_entity->set_content_type( iv_media_type = if_rest_media_type=>gc_appl_json ).
|
|
67
|
+
lo_entity->set_string_data( lv_result ).
|
|
68
|
+
mo_response->set_status( cl_rest_status_code=>gc_success_ok ).
|
|
69
|
+
ENDMETHOD.
|
|
70
|
+
|
|
71
|
+
ENDCLASS.
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
+
<abapGit version="v1.0.0" serializer="LCL_OBJECT_CLAS" serializer_version="v1.0.0">
|
|
3
|
+
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
|
|
4
|
+
<asx:values>
|
|
5
|
+
<VSEOCLASS>
|
|
6
|
+
<CLSNAME>ZCL_ABGAGT_RESOURCE_PULL</CLSNAME>
|
|
7
|
+
<LANGU>E</LANGU>
|
|
8
|
+
<DESCRIPT>ABAP Git Agent - Pull Resource</DESCRIPT>
|
|
9
|
+
<EXPOSURE>2</EXPOSURE>
|
|
10
|
+
<STATE>1</STATE>
|
|
11
|
+
<UNICODE>X</UNICODE>
|
|
12
|
+
</VSEOCLASS>
|
|
13
|
+
</asx:values>
|
|
14
|
+
</asx:abap>
|
|
15
|
+
</abapGit>
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
*"*"use source
|
|
2
|
+
*"*"Local Interface:
|
|
3
|
+
*"**********************************************************************
|
|
4
|
+
CLASS zcl_abgagt_resource_unit DEFINITION PUBLIC FINAL
|
|
5
|
+
INHERITING FROM cl_rest_resource
|
|
6
|
+
CREATE PUBLIC.
|
|
7
|
+
|
|
8
|
+
PUBLIC SECTION.
|
|
9
|
+
METHODS if_rest_resource~post REDEFINITION.
|
|
10
|
+
|
|
11
|
+
ENDCLASS.
|
|
12
|
+
|
|
13
|
+
CLASS zcl_abgagt_resource_unit IMPLEMENTATION.
|
|
14
|
+
|
|
15
|
+
METHOD if_rest_resource~post.
|
|
16
|
+
DATA lv_json TYPE string.
|
|
17
|
+
lv_json = mo_request->get_entity( )->get_string_data( ).
|
|
18
|
+
|
|
19
|
+
" Parse JSON using /ui2/cl_json
|
|
20
|
+
DATA: BEGIN OF ls_request,
|
|
21
|
+
package TYPE string,
|
|
22
|
+
files TYPE string_table,
|
|
23
|
+
END OF ls_request.
|
|
24
|
+
|
|
25
|
+
/ui2/cl_json=>deserialize(
|
|
26
|
+
EXPORTING
|
|
27
|
+
json = lv_json
|
|
28
|
+
CHANGING
|
|
29
|
+
data = ls_request ).
|
|
30
|
+
|
|
31
|
+
DATA lv_json_resp TYPE string.
|
|
32
|
+
|
|
33
|
+
IF ls_request-package IS INITIAL AND ( ls_request-files IS INITIAL OR lines( ls_request-files ) = 0 ).
|
|
34
|
+
lv_json_resp = '{"success":"","message":"Package or files required"}'.
|
|
35
|
+
DATA(lo_entity) = mo_response->create_entity( ).
|
|
36
|
+
lo_entity->set_content_type( iv_media_type = if_rest_media_type=>gc_appl_json ).
|
|
37
|
+
lo_entity->set_string_data( lv_json_resp ).
|
|
38
|
+
mo_response->set_status( cl_rest_status_code=>gc_client_error_bad_request ).
|
|
39
|
+
RETURN.
|
|
40
|
+
ENDIF.
|
|
41
|
+
|
|
42
|
+
" Get command from factory
|
|
43
|
+
DATA(lo_factory) = zcl_abgagt_cmd_factory=>get_instance( ).
|
|
44
|
+
DATA(lo_command) = lo_factory->get_command( zif_abgagt_command=>gc_unit ).
|
|
45
|
+
|
|
46
|
+
IF lo_command IS NOT BOUND.
|
|
47
|
+
lv_json_resp = '{"success":"","error":"UNIT command not found"}'.
|
|
48
|
+
lo_entity = mo_response->create_entity( ).
|
|
49
|
+
lo_entity->set_content_type( iv_media_type = if_rest_media_type=>gc_appl_json ).
|
|
50
|
+
lo_entity->set_string_data( lv_json_resp ).
|
|
51
|
+
mo_response->set_status( cl_rest_status_code=>gc_client_error_bad_request ).
|
|
52
|
+
RETURN.
|
|
53
|
+
ENDIF.
|
|
54
|
+
|
|
55
|
+
" Execute command with is_param
|
|
56
|
+
DATA(lv_result) = lo_command->execute( is_param = ls_request ).
|
|
57
|
+
|
|
58
|
+
lo_entity = mo_response->create_entity( ).
|
|
59
|
+
lo_entity->set_content_type( iv_media_type = if_rest_media_type=>gc_appl_json ).
|
|
60
|
+
lo_entity->set_string_data( lv_result ).
|
|
61
|
+
mo_response->set_status( cl_rest_status_code=>gc_success_ok ).
|
|
62
|
+
ENDMETHOD.
|
|
63
|
+
|
|
64
|
+
ENDCLASS.
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
+
<abapGit version="v1.0.0" serializer="LCL_OBJECT_CLAS" serializer_version="v1.0.0">
|
|
3
|
+
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
|
|
4
|
+
<asx:values>
|
|
5
|
+
<VSEOCLASS>
|
|
6
|
+
<CLSNAME>ZCL_ABGAGT_RESOURCE_UNIT</CLSNAME>
|
|
7
|
+
<LANGU>E</LANGU>
|
|
8
|
+
<DESCRIPT>ABAP Git Agent - Unit Test Resource</DESCRIPT>
|
|
9
|
+
<EXPOSURE>2</EXPOSURE>
|
|
10
|
+
<STATE>1</STATE>
|
|
11
|
+
<UNICODE>X</UNICODE>
|
|
12
|
+
</VSEOCLASS>
|
|
13
|
+
</asx:values>
|
|
14
|
+
</asx:abap>
|
|
15
|
+
</abapGit>
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
*"*"use source
|
|
2
|
+
*"* Local Interface:
|
|
3
|
+
*"----------------------------------------------------------------------
|
|
4
|
+
CLASS zcl_abgagt_rest_handler DEFINITION PUBLIC INHERITING FROM cl_rest_http_handler CREATE PUBLIC.
|
|
5
|
+
|
|
6
|
+
PUBLIC SECTION.
|
|
7
|
+
METHODS: if_rest_application~get_root_handler REDEFINITION.
|
|
8
|
+
|
|
9
|
+
PRIVATE SECTION.
|
|
10
|
+
|
|
11
|
+
ENDCLASS.
|
|
12
|
+
|
|
13
|
+
CLASS zcl_abgagt_rest_handler IMPLEMENTATION.
|
|
14
|
+
|
|
15
|
+
METHOD if_rest_application~get_root_handler.
|
|
16
|
+
DATA lo_router TYPE REF TO cl_rest_router.
|
|
17
|
+
CREATE OBJECT lo_router.
|
|
18
|
+
|
|
19
|
+
lo_router->attach( iv_template = '/pull' iv_handler_class = 'ZCL_ABGAGT_RESOURCE_PULL' ).
|
|
20
|
+
lo_router->attach( iv_template = '/health' iv_handler_class = 'ZCL_ABGAGT_RESOURCE_HEALTH' ).
|
|
21
|
+
lo_router->attach( iv_template = '/inspect' iv_handler_class = 'ZCL_ABGAGT_RESOURCE_INSPECT' ).
|
|
22
|
+
lo_router->attach( iv_template = '/unit' iv_handler_class = 'ZCL_ABGAGT_RESOURCE_UNIT' ).
|
|
23
|
+
|
|
24
|
+
ro_root_handler = lo_router.
|
|
25
|
+
ENDMETHOD.
|
|
26
|
+
|
|
27
|
+
ENDCLASS.
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
+
<abapGit version="v1.0.0" serializer="LCL_OBJECT_CLAS" serializer_version="v1.0.0">
|
|
3
|
+
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
|
|
4
|
+
<asx:values>
|
|
5
|
+
<VSEOCLASS>
|
|
6
|
+
<CLSNAME>ZCL_ABGAGT_REST_HANDLER</CLSNAME>
|
|
7
|
+
<LANGU>E</LANGU>
|
|
8
|
+
<DESCRIPT>ABAP Git Agent - REST Handler</DESCRIPT>
|
|
9
|
+
<EXPOSURE>2</EXPOSURE>
|
|
10
|
+
<STATE>1</STATE>
|
|
11
|
+
<UNICODE>X</UNICODE>
|
|
12
|
+
</VSEOCLASS>
|
|
13
|
+
</asx:values>
|
|
14
|
+
</asx:abap>
|
|
15
|
+
</abapGit>
|