Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 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 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x | const {cx_root} = await import("./cx_root.clas.mjs");
// zcl_abapgit_gitea.clas.abap
class zcl_abapgit_gitea {
static STATIC_SUPER = undefined;
static INTERNAL_TYPE = 'CLAS';
static INTERNAL_NAME = 'ZCL_ABAPGIT_GITEA';
static IMPLEMENTED_INTERFACES = [];
static ATTRIBUTES = {"C_BASE": {"type": () => {return new abap.types.String({qualifiedName: "STRING"});}, "visibility": "I", "is_constant": "X", "is_class": "X"},
"C_USERNAME": {"type": () => {return new abap.types.String({qualifiedName: "STRING"});}, "visibility": "I", "is_constant": "X", "is_class": "X"},
"C_PASSWORD": {"type": () => {return new abap.types.String({qualifiedName: "STRING"});}, "visibility": "I", "is_constant": "X", "is_class": "X"}};
static METHODS = {"CREATE_REPO": {"visibility": "U", "parameters": {"RV_URL": {"type": () => {return new abap.types.String({qualifiedName: "STRING"});}, "is_optional": " ", "parm_kind": "R", "type_name": "StringType"}, "IV_NAME": {"type": () => {return new abap.types.String({qualifiedName: "STRING"});}, "is_optional": " ", "parm_kind": "I", "type_name": "StringType"}}}};
constructor() {
this.me = new abap.types.ABAPObject();
this.me.set(this);
this.INTERNAL_ID = abap.internalIdCounter++;
this.FRIENDS_ACCESS_INSTANCE = {
};
this.c_base = zcl_abapgit_gitea.c_base;
this.c_username = zcl_abapgit_gitea.c_username;
this.c_password = zcl_abapgit_gitea.c_password;
}
async constructor_(INPUT) {
if (super.constructor_) { await super.constructor_(INPUT); }
return this;
}
async create_repo(INPUT) {
return zcl_abapgit_gitea.create_repo(INPUT);
}
static async create_repo(INPUT) {
let rv_url = new abap.types.String({qualifiedName: "STRING"});
let iv_name = INPUT?.iv_name;
if (iv_name?.getQualifiedName === undefined || iv_name.getQualifiedName() !== "STRING") { iv_name = undefined; }
if (iv_name === undefined) { iv_name = new abap.types.String({qualifiedName: "STRING"}).set(INPUT.iv_name); }
let li_agent = new abap.types.ABAPObject({qualifiedName: "ZIF_ABAPGIT_HTTP_AGENT", RTTIName: "\\INTERFACE=ZIF_ABAPGIT_HTTP_AGENT"});
let li_response = new abap.types.ABAPObject({qualifiedName: "ZIF_ABAPGIT_HTTP_RESPONSE", RTTIName: "\\INTERFACE=ZIF_ABAPGIT_HTTP_RESPONSE"});
let lv_json = new abap.types.String({qualifiedName: "STRING"});
let lv_url = new abap.types.String({qualifiedName: "STRING"});
li_agent.set((await abap.Classes['ZCL_ABAPGIT_HTTP_AGENT'].create()));
await (await li_agent.get().zif_abapgit_http_agent$global_headers()).get().set({iv_key: abap.CharacterFactory.get(6, 'Accept'), iv_val: abap.CharacterFactory.get(16, 'application/json')});
await (await li_agent.get().zif_abapgit_http_agent$global_headers()).get().set({iv_key: abap.CharacterFactory.get(12, 'Content-Type'), iv_val: abap.CharacterFactory.get(16, 'application/json')});
lv_url.set(abap.operators.concat(zcl_abapgit_gitea.c_base,abap.CharacterFactory.get(18, '/api/v1/user/repos')));
await abap.Classes['ZCL_ABAPGIT_LOGIN_MANAGER'].set_basic({iv_uri: lv_url, iv_username: zcl_abapgit_gitea.c_username, iv_password: zcl_abapgit_gitea.c_password});
await (await li_agent.get().zif_abapgit_http_agent$global_headers()).get().set({iv_key: abap.CharacterFactory.get(13, 'Authorization'), iv_val: (await abap.Classes['ZCL_ABAPGIT_LOGIN_MANAGER'].get({iv_uri: lv_url}))});
lv_json.set(abap.operators.concat(new abap.types.String().set(`{`),abap.operators.concat(new abap.types.String().set(`\n`),abap.operators.concat(new abap.types.String().set(` "auto_init": true,`),abap.operators.concat(new abap.types.String().set(`\n`),abap.operators.concat(new abap.types.String().set(` "default_branch": "main",`),abap.operators.concat(new abap.types.String().set(`\n`),abap.operators.concat(new abap.types.String().set(` "description": "description",`),abap.operators.concat(new abap.types.String().set(`\n`),abap.operators.concat(new abap.types.String().set(` "license": "MIT",`),abap.operators.concat(new abap.types.String().set(`\n`),abap.operators.concat(new abap.types.String().set(` "name": "`),abap.operators.concat(iv_name,abap.operators.concat(new abap.types.String().set(`",`),abap.operators.concat(new abap.types.String().set(`\n`),abap.operators.concat(new abap.types.String().set(` "private": false,`),abap.operators.concat(new abap.types.String().set(`\n`),abap.operators.concat(new abap.types.String().set(` "trust_model": "default"`),abap.operators.concat(new abap.types.String().set(`\n`),new abap.types.String().set(`}`))))))))))))))))))));
li_response.set((await li_agent.get().zif_abapgit_http_agent$request({iv_url: lv_url, iv_method: abap.CharacterFactory.get(4, 'POST'), iv_payload: lv_json})));
if (abap.compare.ne((await li_response.get().zif_abapgit_http_response$code()), new abap.types.Integer().set(201))) {
await abap.Classes['ZCX_ABAPGIT_EXCEPTION'].raise({iv_text: new abap.types.String().set(`Error creating repository`)});
}
rv_url.set(new abap.types.String().set(`${abap.templateFormatting(zcl_abapgit_gitea.c_base)}/abapgit/${abap.templateFormatting(iv_name)}`));
return rv_url;
}
}
abap.Classes['ZCL_ABAPGIT_GITEA'] = zcl_abapgit_gitea;
zcl_abapgit_gitea.c_base = new abap.types.String({qualifiedName: "STRING"});
zcl_abapgit_gitea.c_base.set('http://localhost:3050');
zcl_abapgit_gitea.c_username = new abap.types.String({qualifiedName: "STRING"});
zcl_abapgit_gitea.c_username.set('abapgit');
zcl_abapgit_gitea.c_password = new abap.types.String({qualifiedName: "STRING"});
zcl_abapgit_gitea.c_password.set('abapgit');
export {zcl_abapgit_gitea}; |