Skip to content
This repository was archived by the owner on Jun 3, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .awx/__files/body-api-glzeX.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"description":"AWX REST API","current_version":"/api/v2/","available_versions":{"v2":"/api/v2/"},"oauth2":"/api/o/","custom_logo":"","custom_login_info":"","login_redirect_override":"","swagger":"/api/swagger/"}
32 changes: 32 additions & 0 deletions .awx/mappings/mapping-api-glzeX.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"id" : "14c33444-1535-35fd-a492-2108d7a6e990",
"request" : {
"url" : "/api/",
"method" : "GET"
},
"response" : {
"status" : 200,
"bodyFileName" : "body-api-glzeX.json",
"headers" : {
"X-API-Product-Name" : "AWX",
"Server" : "nginx",
"X-Content-Type-Options" : "nosniff",
"X-API-Query-Time" : "0.003s",
"X-API-Time" : "0.265s",
"Date" : "Fri, 11 Oct 2024 02:05:11 GMT",
"Allow" : "GET, HEAD, OPTIONS",
"Strict-Transport-Security" : "max-age=15768000",
"Access-Control-Expose-Headers" : "X-API-Request-Id",
"X-API-Total-Time" : "0.289s",
"X-API-Query-Count" : "2",
"Set-Cookie" : "csrftoken=Es54ugBVoHkMtDtE5raa0BapN7LHuOhe; Path=/; SameSite=Lax",
"X-API-Request-Id" : "dd4dddd64b7545e8808a4757052edcee",
"Vary" : "Accept, Cookie, Accept-Language, origin",
"X-API-Node" : "awx-1",
"X-API-Product-Version" : "24.6.2.dev128+g825a02c86a",
"Content-Language" : "en",
"Content-Type" : "application/json"
}
},
"uuid" : "14c33444-1535-35fd-a492-2108d7a6e990"
}
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
dist
typescript-fetch-client
node_modules
.env
.idea
awx
awx
generated
2 changes: 1 addition & 1 deletion generate.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
const {execSync} = require('child_process');

execSync(`docker run --rm -v "${process.cwd()}:/local\" openapitools/openapi-generator-cli:v7.8.0 generate -i /local/spec.json -g typescript-fetch -o /local/typescript-fetch-client -p supportsES6=true -p npmName=awx-api-client -p npmVersion=1.0.0`);
execSync(`docker run --rm -v "${process.cwd()}:/local\" openapitools/openapi-generator-cli:v7.9.0 generate -i /local/spec.json -g typescript-fetch -o /local/generated -p supportsES6=true -p npmName=awx-api-client -p npmVersion=1.0.0`);
37 changes: 22 additions & 15 deletions jest-testcontainers-config.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,23 @@
module.exports = {
awx: {
image: 'wiremock/wiremock:3.9.1',
ports: [8080],
resourcesQuota: {
memory: 0.25
},
bindMounts: [{
source: `${__dirname}/.awx`,
target: '/home/wiremock',
mode: 'rw'
}],
command: ['--verbose', '--disable-banner', '--record-mappings',
'--proxy-all', 'https://host.docker.internal:8043' ]
}
}
awx: {
image: "wiremock/wiremock:3.9.1",
ports: [8080],
resourcesQuota: {
memory: 0.25,
},
bindMounts: [
{
source: `${__dirname}/.awx`,
target: "/home/wiremock",
mode: "rw",
},
],
command: [
"--verbose",
"--disable-banner",
"--record-mappings",
"--proxy-all",
"https://host.docker.internal:8043",
],
},
};
20 changes: 11 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,28 +13,30 @@
"repositoryUrl": "https://github.com/eresearchqut/awx-api-client.git"
},
"scripts": {
"awx:clean": "rimraf:awx",
"awx:build": "(git -C awx pull || git clone -b devel https://github.com/ansible/awx.git awx) && (cd awx && make docker-compose-build && make clean/ui ui)",
"awx:start": "(cd awx && make docker-compose)",
"awx:superuser": "docker exec -ti tools_awx_1 awx-manage createsuperuser",
"clean": "rimraf awx && rimraf dist && rimraf generated && rimraf yarn-error.log && rimraf node_modules && rimraf typescript-fetch-client",
"clean": "rimraf dist && rimraf generated && rimraf yarn-error.log && rimraf node_modules",
"regen": "(cd awx && make docker-compose)",
"prebuild": "node ./generate.js",
"build": "(cd ./typescript-fetch-client && yarn install && yarn build)",
"test": "tsc && jest"
"build": "tsc",
"test": "jest"
},
"dependencies": {
"awx-api-client": "./typescript-fetch-client"

},
"devDependencies": {
"@eresearchqut/jest-testcontainers": "^3.4.0",
"@eresearchqut/jest-testcontainers": "^3.6.4",
"@types/jest": "^29.5.12",
"@types/node": "^20.14.10",
"@types/node": "^22.5.1",
"dotenv": "^16.3.1",
"jest": "^29.7.0",
"node-fetch": "^2.6.13",
"node-fetch": "^3.3.2",
"prettier": "^3.3.3",
"rimraf": "^5.0.8",
"ts-jest": "^29.2.2",
"ts-jest": "29.2.5",
"ts-node": "^10.9.2",
"typescript": "^5.5.3"
"typescript": "5.5.4"
}
}
33,666 changes: 33,665 additions & 1 deletion spec.json

Large diffs are not rendered by default.

37 changes: 17 additions & 20 deletions test/ApiApi.test.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,21 @@
import {ApiApi, Configuration, FetchAPI} from 'awx-api-client';

import { configuration } from "./Config";
import {ApiApi} from "../generated/src";

describe("AWX API Test", () => {
const basePath = `http://${global.__TESTCONTAINERS_AWX_IP__}:${global.__TESTCONTAINERS_AWX_PORT_8080__}`;
const configuration = new Configuration({
basePath,
fetchApi: fetch as unknown as FetchAPI
});
const api = new ApiApi(configuration);
test("api list", async () => {
const response = await api.apiList();
expect(response).toEqual({
"description": "AWX REST API",
"current_version": "/api/v2/",
"available_versions": {"v2": "/api/v2/"},
"oauth2": "/api/o/",
"custom_logo": "",
"custom_login_info": "",
"login_redirect_override": "",
"swagger": "/api/swagger/"
})
const api = new ApiApi(configuration);

test("api list", async () => {
const response = await api.apiList();
expect(response).toEqual({
description: "AWX REST API",
current_version: "/api/v2/",
available_versions: { v2: "/api/v2/" },
oauth2: "/api/o/",
custom_logo: "",
custom_login_info: "",
login_redirect_override: "",
swagger: "/api/swagger/",
});
});
});
});
8 changes: 8 additions & 0 deletions test/Config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { Configuration, FetchAPI } from "../generated/src"

export const configuration = new Configuration({
username: "awx",
password: "awx",
basePath: `http://${global.__TESTCONTAINERS_AWX_IP__}:${global.__TESTCONTAINERS_AWX_PORT_8080__}`,
fetchApi: fetch as unknown as FetchAPI,
});
3 changes: 2 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"include": [
"./test/**/*"
"./test/**/*",
"./generated/**/*"
],
"exclude": [
"node_modules",
Expand Down
Loading
Loading