From 3d60652cf198bb80b5c094cc19c1ff614034a67c Mon Sep 17 00:00:00 2001 From: Onur Arslan Date: Sat, 2 Dec 2023 17:18:52 +0100 Subject: [PATCH 01/58] [Functionality] Request Consumer / Producer - request to get the data for consumer and producer data --- pkgs/ui/src/app/client-1/page.tsx | 100 +++++++++++++++++++++--------- 1 file changed, 69 insertions(+), 31 deletions(-) diff --git a/pkgs/ui/src/app/client-1/page.tsx b/pkgs/ui/src/app/client-1/page.tsx index 5abb913..07b79de 100644 --- a/pkgs/ui/src/app/client-1/page.tsx +++ b/pkgs/ui/src/app/client-1/page.tsx @@ -2,39 +2,77 @@ import SummaryDetails from "@/components/summary_card"; import { - Client1SummaryDetails, - Client1ConsumerData, - Client1ConsumerTableConfig, - Client1ProducerTableConfig, - Client1ProducerData, + Client1SummaryDetails, + Client1ConsumerData, + Client1ConsumerTableConfig, + Client1ProducerTableConfig, + Client1ProducerData, } from "@/mock/client_1"; import CustomTable from "@/components/table"; +import {useEffect, useState} from "react"; export default function Client1() { - return ( -
- -
-

Consumer View

- -
-
-

Producer View

- -
-
- ); + const [consumerData, setConsumerData] = useState(null); + const [producerData, setProducerData] = useState(null); + + useEffect(() => { + fetch('http://localhost:2979/api/v1/get_consumers', { + method: 'GET', + // credentials: 'include', + }) + .then(resp => resp.json().then(jsonData => { + console.log(jsonData); + if (jsonData.length > 0) { + setConsumerData(jsonData); + } else { + setConsumerData(Client1ConsumerData); + } + } + )) + .then(data => null) + .catch(err => null) + + fetch('http://localhost:2979/api/v1/get_producers', { + method: 'GET', + // credentials: 'include', + }) + .then(resp => resp.json().then(jsonData => { + console.log(jsonData); + if (jsonData.length > 0) { + setProducerData(jsonData); + } else { + setProducerData(Client1ProducerData); + } + } + )) + .then(data => null) + .catch(err => null) + }, []); + + return ( +
+ +
+

Consumer View

+ +
+
+

Producer View

+ +
+
+ ); } From b89d2df31b115ec381dcace013860eeaf1ae8611 Mon Sep 17 00:00:00 2001 From: Onur Arslan Date: Sat, 2 Dec 2023 17:30:28 +0100 Subject: [PATCH 02/58] [Functionality] Request Consumer / Producer - fixed the hook data --- pkgs/ui/src/app/client-1/page.tsx | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/pkgs/ui/src/app/client-1/page.tsx b/pkgs/ui/src/app/client-1/page.tsx index 07b79de..a676334 100644 --- a/pkgs/ui/src/app/client-1/page.tsx +++ b/pkgs/ui/src/app/client-1/page.tsx @@ -12,8 +12,8 @@ import CustomTable from "@/components/table"; import {useEffect, useState} from "react"; export default function Client1() { - const [consumerData, setConsumerData] = useState(null); - const [producerData, setProducerData] = useState(null); + const [consumerData, setConsumerData] = useState([]); + const [producerData, setProducerData] = useState([]); useEffect(() => { fetch('http://localhost:2979/api/v1/get_consumers', { @@ -29,8 +29,8 @@ export default function Client1() { } } )) - .then(data => null) - .catch(err => null) + .then() + .catch() fetch('http://localhost:2979/api/v1/get_producers', { method: 'GET', @@ -45,8 +45,8 @@ export default function Client1() { } } )) - .then(data => null) - .catch(err => null) + .then() + .catch() }, []); return ( From cd0d3937c466aeb21f31db4cf5798511a3225c72 Mon Sep 17 00:00:00 2001 From: "Arslan, Erdem" Date: Sat, 2 Dec 2023 17:30:39 +0100 Subject: [PATCH 03/58] [Functionality] Request Service Repository - request backend endpoint and fill data if available --- pkgs/ui/src/app/access-point/page.tsx | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/pkgs/ui/src/app/access-point/page.tsx b/pkgs/ui/src/app/access-point/page.tsx index 177073c..25bac10 100644 --- a/pkgs/ui/src/app/access-point/page.tsx +++ b/pkgs/ui/src/app/access-point/page.tsx @@ -9,9 +9,31 @@ import { APServiceRepositoryDummyData, APServiceRepositoryTableConfig, } from "@/mock/access_point"; +import {useEffect, useState} from "react"; export default function AccessPoint() { - return ( + const [repositoryData, setRepositoryData] = useState([]); + + useEffect(() => { + fetch('http://localhost:2979/api/v1/get_repositories', { + method: 'GET', + // credentials: 'include', + }) + .then(resp => resp.json().then(jsonData => { + console.log(jsonData); + if (jsonData.length > 0) { + setRepositoryData(jsonData); + } else { + setRepositoryData(APServiceRepositoryDummyData); + } + } + )) + .then() + .catch() + }, []); + + + return (

Service Repository View

From d95c6ba98148f3bfc0777f4006efc98283225f51 Mon Sep 17 00:00:00 2001 From: "Arslan, Erdem" Date: Sat, 2 Dec 2023 18:48:08 +0100 Subject: [PATCH 04/58] fix formating --- pkgs/ui/src/app/access-point/page.tsx | 42 ++++---- pkgs/ui/src/app/client-1/page.tsx | 134 +++++++++++++------------- 2 files changed, 89 insertions(+), 87 deletions(-) diff --git a/pkgs/ui/src/app/access-point/page.tsx b/pkgs/ui/src/app/access-point/page.tsx index 25bac10..997f915 100644 --- a/pkgs/ui/src/app/access-point/page.tsx +++ b/pkgs/ui/src/app/access-point/page.tsx @@ -9,31 +9,31 @@ import { APServiceRepositoryDummyData, APServiceRepositoryTableConfig, } from "@/mock/access_point"; -import {useEffect, useState} from "react"; +import { useEffect, useState } from "react"; export default function AccessPoint() { - const [repositoryData, setRepositoryData] = useState([]); + const [repositoryData, setRepositoryData] = useState([]); - useEffect(() => { - fetch('http://localhost:2979/api/v1/get_repositories', { - method: 'GET', - // credentials: 'include', - }) - .then(resp => resp.json().then(jsonData => { - console.log(jsonData); - if (jsonData.length > 0) { - setRepositoryData(jsonData); - } else { - setRepositoryData(APServiceRepositoryDummyData); - } - } - )) - .then() - .catch() - }, []); + useEffect(() => { + fetch("http://localhost:2979/api/v1/get_repositories", { + method: "GET", + // credentials: 'include', + }) + .then((resp) => + resp.json().then((jsonData) => { + console.log(jsonData); + if (jsonData.length > 0) { + setRepositoryData(jsonData); + } else { + setRepositoryData(APServiceRepositoryDummyData); + } + }), + ) + .then() + .catch(); + }, []); - - return ( + return (
{ - fetch('http://localhost:2979/api/v1/get_consumers', { - method: 'GET', - // credentials: 'include', - }) - .then(resp => resp.json().then(jsonData => { - console.log(jsonData); - if (jsonData.length > 0) { - setConsumerData(jsonData); - } else { - setConsumerData(Client1ConsumerData); - } - } - )) - .then() - .catch() + useEffect(() => { + fetch("http://localhost:2979/api/v1/get_consumers", { + method: "GET", + // credentials: 'include', + }) + .then((resp) => + resp.json().then((jsonData) => { + console.log(jsonData); + if (jsonData.length > 0) { + setConsumerData(jsonData); + } else { + setConsumerData(Client1ConsumerData); + } + }), + ) + .then() + .catch(); - fetch('http://localhost:2979/api/v1/get_producers', { - method: 'GET', - // credentials: 'include', - }) - .then(resp => resp.json().then(jsonData => { - console.log(jsonData); - if (jsonData.length > 0) { - setProducerData(jsonData); - } else { - setProducerData(Client1ProducerData); - } - } - )) - .then() - .catch() - }, []); + fetch("http://localhost:2979/api/v1/get_producers", { + method: "GET", + // credentials: 'include', + }) + .then((resp) => + resp.json().then((jsonData) => { + console.log(jsonData); + if (jsonData.length > 0) { + setProducerData(jsonData); + } else { + setProducerData(Client1ProducerData); + } + }), + ) + .then() + .catch(); + }, []); - return ( -
- -
-

Consumer View

- -
-
-

Producer View

- -
-
- ); + return ( +
+ +
+

Consumer View

+ +
+
+

Producer View

+ +
+
+ ); } From 2c098f4ba02e38240536ef5eba49fb153e798786 Mon Sep 17 00:00:00 2001 From: Onur Arslan Date: Sat, 2 Dec 2023 21:12:04 +0100 Subject: [PATCH 05/58] [Functionality] Request Consumer / Producer - request consumer, producer data for client-2 - refactored statements --- pkgs/ui/src/app/access-point/page.tsx | 6 +---- pkgs/ui/src/app/client-1/page.tsx | 20 +++++---------- pkgs/ui/src/app/client-2/page.tsx | 36 +++++++++++++++++++++++++-- 3 files changed, 41 insertions(+), 21 deletions(-) diff --git a/pkgs/ui/src/app/access-point/page.tsx b/pkgs/ui/src/app/access-point/page.tsx index 997f915..277d5c0 100644 --- a/pkgs/ui/src/app/access-point/page.tsx +++ b/pkgs/ui/src/app/access-point/page.tsx @@ -22,11 +22,7 @@ export default function AccessPoint() { .then((resp) => resp.json().then((jsonData) => { console.log(jsonData); - if (jsonData.length > 0) { - setRepositoryData(jsonData); - } else { - setRepositoryData(APServiceRepositoryDummyData); - } + jsonData.length > 0 ? setRepositoryData(jsonData) : setRepositoryData(APServiceRepositoryDummyData); }), ) .then() diff --git a/pkgs/ui/src/app/client-1/page.tsx b/pkgs/ui/src/app/client-1/page.tsx index 90437e6..bf47d67 100644 --- a/pkgs/ui/src/app/client-1/page.tsx +++ b/pkgs/ui/src/app/client-1/page.tsx @@ -23,11 +23,7 @@ export default function Client1() { .then((resp) => resp.json().then((jsonData) => { console.log(jsonData); - if (jsonData.length > 0) { - setConsumerData(jsonData); - } else { - setConsumerData(Client1ConsumerData); - } + jsonData.length > 0 ? setConsumerData(jsonData) : setConsumerData(Client1ConsumerData); }), ) .then() @@ -37,15 +33,11 @@ export default function Client1() { method: "GET", // credentials: 'include', }) - .then((resp) => - resp.json().then((jsonData) => { - console.log(jsonData); - if (jsonData.length > 0) { - setProducerData(jsonData); - } else { - setProducerData(Client1ProducerData); - } - }), + .then((resp) => + resp.json().then((jsonData) => { + console.log(jsonData); + jsonData.length > 0 ? setProducerData(jsonData) : setProducerData(Client1ProducerData); + }), ) .then() .catch(); diff --git a/pkgs/ui/src/app/client-2/page.tsx b/pkgs/ui/src/app/client-2/page.tsx index 80be865..b833d89 100644 --- a/pkgs/ui/src/app/client-2/page.tsx +++ b/pkgs/ui/src/app/client-2/page.tsx @@ -9,8 +9,40 @@ import { Client2SummaryDetails, } from "@/mock/client_2"; import CustomTable from "@/components/table"; +import {useEffect, useState} from "react"; export default function Client1() { + const [consumerData, setConsumerData] = useState([]); + const [producerData, setProducerData] = useState([]); + + useEffect(() => { + fetch("http://localhost:2979/api/v1/get_consumers", { + method: "GET", + // credentials: 'include', + }) + .then((resp) => + resp.json().then((jsonData) => { + console.log(jsonData); + jsonData.length > 0 ? setConsumerData(jsonData) : setConsumerData(Client2ConsumerData); + }), + ) + .then() + .catch(); + + fetch("http://localhost:2979/api/v1/get_producers", { + method: "GET", + // credentials: 'include', + }) + .then((resp) => + resp.json().then((jsonData) => { + console.log(jsonData); + jsonData.length > 0 ? setProducerData(jsonData) : setProducerData(Client2ProducerData); + }), + ) + .then() + .catch(); + }, []); + return (

Consumer View

Producer View

From 9b4301d783c2136bf3ba3cf842ac7ab7f22c60c8 Mon Sep 17 00:00:00 2001 From: Onur Arslan Date: Sun, 3 Dec 2023 18:37:45 +0100 Subject: [PATCH 06/58] [Functionality] Request Consumer / Producer - adjusted some header names --- pkgs/ui/src/mock/access_point/index.ts | 32 +++++++++---------- pkgs/ui/src/mock/client_1/index.ts | 44 +++++++++++++------------- pkgs/ui/src/mock/client_2/index.ts | 44 +++++++++++++------------- 3 files changed, 60 insertions(+), 60 deletions(-) diff --git a/pkgs/ui/src/mock/access_point/index.ts b/pkgs/ui/src/mock/access_point/index.ts index 07ae286..1895a9b 100644 --- a/pkgs/ui/src/mock/access_point/index.ts +++ b/pkgs/ui/src/mock/access_point/index.ts @@ -20,25 +20,25 @@ export const APSummaryDetails = [ export const APAttachmentsDummyData = [ { entity_name: "C1", - entity_DID: "did:sov:test:1234", + entity_did: "did:sov:test:1234", network: "Carlo's Home Network", ip_address: "127.0.0.1", }, { entity_name: "C2", - entity_DID: "did:sov:test:4567", + entity_did: "did:sov:test:4567", network: "Steve's Home Network", ip_address: "127.0.0.1", }, { entity_name: "C1-TEST", - entity_DID: "did:sov:test:0001", + entity_did: "did:sov:test:0001", network: "Test Network A", ip_address: "127.0.0.1", }, { entity_name: "C2-TEST", - entity_DID: "did:sov:test:0002", + entity_did: "did:sov:test:0002", network: "Test Network B", ip_address: "127.0.0.1", }, @@ -49,7 +49,7 @@ export const APAttachmentsTableConfig = [ label: "Entity name", }, { - key: "entity_DID", + key: "entity_did", label: "Entity DID", }, { @@ -67,17 +67,17 @@ export const APServiceRepositoryDummyData = [ { service_name: "Carlo's Printing", service_type: "3D Printing", - end_point: "URL", - producer: "C1", - producer_DID: "did:sov:test:1234", + endpoint_url: "URL", + entity: "C1", + entity_did: "did:sov:test:1234", network: "Carlo's Home Network", }, { service_name: "Jeff's Printing", service_type: "3D Printing", - end_point: "URL", - producer: "C2", - producer_DID: "did:sov:test:5678", + endpoint_url: "URL", + entity: "C2", + entity_did: "did:sov:test:5678", network: "Jeff's Home Network", }, ]; @@ -91,16 +91,16 @@ export const APServiceRepositoryTableConfig = [ label: "Service type", }, { - key: "end_point", + key: "endpoint_url", label: "End point", }, { - key: "producer", - label: "Producer", + key: "entity", + label: "Entity", }, { - key: "producer_DID", - label: "Producer DID", + key: "entity_did", + label: "Entity DID", }, { key: "network", diff --git a/pkgs/ui/src/mock/client_1/index.ts b/pkgs/ui/src/mock/client_1/index.ts index 658b51e..2946c9b 100644 --- a/pkgs/ui/src/mock/client_1/index.ts +++ b/pkgs/ui/src/mock/client_1/index.ts @@ -19,33 +19,33 @@ export const Client1ConsumerData = [ { service_name: "Carlo's Printing", service_type: "3D Printing", - end_point: "Consume", - producer: "C2", - producer_did: "did:sov:test:1223", + endpoint_url: "Consume", + entity: "C2", + entity_did: "did:sov:test:1223", network: "Carlo's Home Network", }, { service_name: "Steve's Printing", service_type: "3D Printing", - end_point: "Consume", - producer: "C2", - producer_did: "did:sov:test:1234", + endpoint_url: "Consume", + entity: "C2", + entity_did: "did:sov:test:1234", network: "Steve's Home Network", }, { service_name: "Test A", service_type: "3D Printing", - end_point: "Consume", - producer: "C2", - producer_did: "did:sov:test:4567", + endpoint_url: "Consume", + entity: "C2", + entity_did: "did:sov:test:4567", network: "Test Network A", }, { service_name: "Test B", service_type: "3D Printing", - end_point: "Consume", - producer: "C2", - producer_did: "did:sov:test:0062", + endpoint_url: "Consume", + entity: "C2", + entity_did: "did:sov:test:0062", network: "Test Network B", }, ]; @@ -60,16 +60,16 @@ export const Client1ConsumerTableConfig = [ label: "Service Type", }, { - key: "end_point", + key: "endpoint_url", label: "End Point", }, { - key: "producer", - label: "Producer", + key: "entity", + label: "Entity", }, { - key: "producer_did", - label: "Producer DID", + key: "entity_did", + label: "Entity DID", }, { key: "network", @@ -81,7 +81,7 @@ export const Client1ProducerData = [ { service_name: "Carlo's Printing", service_type: "3D Printing", - end_point: "URL", + endpoint_url: "URL", usage: "C1(3), C3(4)", status: "DRAFT, REGISTERED", action: "Register, Deregister, Delete", @@ -89,7 +89,7 @@ export const Client1ProducerData = [ { service_name: "Steve's Printing", service_type: "3D Printing", - end_point: "URL", + endpoint_url: "URL", usage: "C1(3), C3(4)", status: "REGISTERED", action: "Create", @@ -97,7 +97,7 @@ export const Client1ProducerData = [ { service_name: "Test Printing A", service_type: "3D Printing", - end_point: "URL", + endpoint_url: "URL", usage: "C1(3), C3(4)", status: "DRAFT", action: "Register, Deregister", @@ -105,7 +105,7 @@ export const Client1ProducerData = [ { service_name: "Test Printing B", service_type: "3D Printing", - end_point: "URL", + endpoint_url: "URL", usage: "C1(3), C3(4)", status: "DRAFT, REGISTERED", action: "Delete, Create", @@ -122,7 +122,7 @@ export const Client1ProducerTableConfig = [ label: "Service Type", }, { - key: "end_point", + key: "endpoint_url", label: "End Point", }, { diff --git a/pkgs/ui/src/mock/client_2/index.ts b/pkgs/ui/src/mock/client_2/index.ts index b0105fd..1f40fcd 100644 --- a/pkgs/ui/src/mock/client_2/index.ts +++ b/pkgs/ui/src/mock/client_2/index.ts @@ -19,33 +19,33 @@ export const Client2ConsumerData = [ { service_name: "Carlo's Printing", service_type: "3D Printing", - end_point: "Consume", - producer: "C2", - producer_did: "did:sov:test:1223", + endpoint_url: "Consume", + entity: "C2", + entity_did: "did:sov:test:1223", network: "Carlo's Home Network", }, { service_name: "Steve's Printing", service_type: "3D Printing", - end_point: "Consume", - producer: "C2", - producer_did: "did:sov:test:1234", + endpoint_url: "Consume", + entity: "C2", + entity_did: "did:sov:test:1234", network: "Steve's Home Network", }, { service_name: "Test A", service_type: "3D Printing", - end_point: "Consume", - producer: "C2", - producer_did: "did:sov:test:4567", + endpoint_url: "Consume", + entity: "C2", + entity_did: "did:sov:test:4567", network: "Test Network A", }, { service_name: "Test B", service_type: "3D Printing", - end_point: "Consume", - producer: "C2", - producer_did: "did:sov:test:0062", + endpoint_url: "Consume", + entity: "C2", + entity_did: "did:sov:test:0062", network: "Test Network B", }, ]; @@ -60,16 +60,16 @@ export const Client2ConsumerTableConfig = [ label: "Service Type", }, { - key: "end_point", + key: "endpoint_url", label: "End Point", }, { - key: "producer", - label: "Producer", + key: "entity", + label: "Entity", }, { - key: "producer_did", - label: "Producer DID", + key: "entity_did", + label: "Entity DID", }, { key: "network", @@ -81,7 +81,7 @@ export const Client2ProducerData = [ { service_name: "Carlo's Printing", service_type: "3D Printing", - end_point: "URL", + endpoint_url: "URL", usage: "C1(3), C3(4)", status: "DRAFT, REGISTERED", action: "Register, Deregister, Delete", @@ -89,7 +89,7 @@ export const Client2ProducerData = [ { service_name: "Steve's Printing", service_type: "3D Printing", - end_point: "URL", + endpoint_url: "URL", usage: "C1(3), C3(4)", status: "REGISTERED", action: "Create", @@ -97,7 +97,7 @@ export const Client2ProducerData = [ { service_name: "Test Printing A", service_type: "3D Printing", - end_point: "URL", + endpoint_url: "URL", usage: "C1(3), C3(4)", status: "DRAFT", action: "Register, Deregister", @@ -105,7 +105,7 @@ export const Client2ProducerData = [ { service_name: "Test Printing B", service_type: "3D Printing", - end_point: "URL", + endpoint_url: "URL", usage: "C1(3), C3(4)", status: "DRAFT, REGISTERED", action: "Delete, Create", @@ -122,7 +122,7 @@ export const Client2ProducerTableConfig = [ label: "Service Type", }, { - key: "end_point", + key: "endpoint_url", label: "End Point", }, { From c25ac3025c23e51658d9d1485a9ac427e662af95 Mon Sep 17 00:00:00 2001 From: Onur Arslan Date: Mon, 4 Dec 2023 23:02:54 +0100 Subject: [PATCH 07/58] [Entities] AP Service Repository View Table - adjusted repository data keys --- pkgs/ui/src/mock/access_point/index.ts | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/pkgs/ui/src/mock/access_point/index.ts b/pkgs/ui/src/mock/access_point/index.ts index 1895a9b..8af005c 100644 --- a/pkgs/ui/src/mock/access_point/index.ts +++ b/pkgs/ui/src/mock/access_point/index.ts @@ -94,16 +94,20 @@ export const APServiceRepositoryTableConfig = [ key: "endpoint_url", label: "End point", }, - { - key: "entity", - label: "Entity", - }, + // { + // key: "entity", + // label: "Entity", + // }, { key: "entity_did", label: "Entity DID", }, + // { + // key: "network", + // label: "Network", + // }, { - key: "network", - label: "Network", + key: "status", + label: "Status", }, ]; From 7d4d6f59c290bf67a34c5a2be54ec9d8749dc2ed Mon Sep 17 00:00:00 2001 From: Luis-Hebendanz Date: Sun, 3 Dec 2023 14:22:46 +0100 Subject: [PATCH 08/58] Better README --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index c2c5987..ceaff48 100644 --- a/README.md +++ b/README.md @@ -106,8 +106,8 @@ Let's set up your Git workflow to collaborate effectively: 2. **Git Workflow**: 1. Add your changes to Git using `git add `. - 2. Run `nix fmt` to lint your files. - 3. Commit your changes with a descriptive message: `git commit -a -m "My descriptive commit message"`. + 2. Run `nix fmt` to lint your files. This will format your files and make changes! + 3. Commit your changes and those of nix fmt with a descriptive message: `git commit -a -m "My descriptive commit message"`. 4. Make sure your branch has the latest changes from upstream by executing: ```bash git fetch && git rebase origin/main --autostash From 20e6e551d4194b0d426ee55cc8e0ccbf0744a3bc Mon Sep 17 00:00:00 2001 From: Luis-Hebendanz Date: Sun, 3 Dec 2023 18:38:58 +0100 Subject: [PATCH 09/58] Improved README --- README.md | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index ceaff48..3523700 100644 --- a/README.md +++ b/README.md @@ -26,6 +26,11 @@ Let's get your development environment up and running: curl --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/nix | sh -s -- install ``` +On Windows Subsystem for Linux (WSL) the installer will fail and tell you what to do. Execute the command from the error message and then afterwards execute: +```bash +sudo echo "experimental-features = nix-command flakes" > '/etc/nix/nix.conf' +``` + 2. **Install direnv**: - Download the direnv package from [here](https://direnv.net/docs/installation.html) or run the following command: @@ -95,12 +100,12 @@ Let's set up your Git workflow to collaborate effectively: ```bash tea login add ``` + - Go to https://gitea.gchq.icu/user/settings/applications and create token with all privileges - Fill out the prompt as follows: - URL of Gitea instance: `https://gitea.gchq.icu` - Name of new Login [gitea.gchq.icu]: `gitea.gchq.icu:7171` - - Do you have an access token? No - - Username: YourUsername - - Password: YourPassword + - Do you have an access token? Yes + - Token: ********* - Set Optional settings: No 2. **Git Workflow**: From 80269832e6928cf140cca64f5b58c9eb982030ea Mon Sep 17 00:00:00 2001 From: Luis-Hebendanz Date: Sun, 3 Dec 2023 18:39:19 +0100 Subject: [PATCH 10/58] Improved README --- README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 3523700..85d2b42 100644 --- a/README.md +++ b/README.md @@ -27,6 +27,7 @@ Let's get your development environment up and running: ``` On Windows Subsystem for Linux (WSL) the installer will fail and tell you what to do. Execute the command from the error message and then afterwards execute: + ```bash sudo echo "experimental-features = nix-command flakes" > '/etc/nix/nix.conf' ``` @@ -105,13 +106,13 @@ Let's set up your Git workflow to collaborate effectively: - URL of Gitea instance: `https://gitea.gchq.icu` - Name of new Login [gitea.gchq.icu]: `gitea.gchq.icu:7171` - Do you have an access token? Yes - - Token: ********* + - Token: ****\***** - Set Optional settings: No 2. **Git Workflow**: 1. Add your changes to Git using `git add `. - 2. Run `nix fmt` to lint your files. This will format your files and make changes! + 2. Run `nix fmt` to lint your files. This will format your files and make changes! 3. Commit your changes and those of nix fmt with a descriptive message: `git commit -a -m "My descriptive commit message"`. 4. Make sure your branch has the latest changes from upstream by executing: ```bash From 10d9b995cb304f9097c72914e37dec07c0980dc0 Mon Sep 17 00:00:00 2001 From: Onur Arslan Date: Wed, 6 Dec 2023 19:01:00 +0100 Subject: [PATCH 11/58] [Functionality] Request Consumer / Producer - adjusted some header names --- pkgs/ui/src/mock/client_1/index.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/pkgs/ui/src/mock/client_1/index.ts b/pkgs/ui/src/mock/client_1/index.ts index 2946c9b..9139156 100644 --- a/pkgs/ui/src/mock/client_1/index.ts +++ b/pkgs/ui/src/mock/client_1/index.ts @@ -125,16 +125,16 @@ export const Client1ProducerTableConfig = [ key: "endpoint_url", label: "End Point", }, - { - key: "usage", - label: "Usage", - }, + // { + // key: "usage", + // label: "Usage", + // }, { key: "status", label: "Status", }, - { - key: "action", - label: "Action", - }, + // { + // key: "action", + // label: "Action", + // }, ]; From 647fc33acd7ddbfc5d45ec5596efb3adb826b317 Mon Sep 17 00:00:00 2001 From: Onur Arslan Date: Wed, 6 Dec 2023 19:25:08 +0100 Subject: [PATCH 12/58] [Functionality] Request Home Table - request entities for home view table --- pkgs/ui/src/app/home/page.tsx | 24 +++++++++++++++++++++--- pkgs/ui/src/mock/home/index.ts | 26 +++++++++++++------------- 2 files changed, 34 insertions(+), 16 deletions(-) diff --git a/pkgs/ui/src/app/home/page.tsx b/pkgs/ui/src/app/home/page.tsx index 37e51de..4e14f4f 100644 --- a/pkgs/ui/src/app/home/page.tsx +++ b/pkgs/ui/src/app/home/page.tsx @@ -1,11 +1,29 @@ "use client"; -import { NoDataOverlay } from "@/components/noDataOverlay"; +import {NoDataOverlay} from "@/components/noDataOverlay"; import SummaryDetails from "@/components/summary_card"; import CustomTable from "@/components/table"; -import { HomeDummyData, HomeTableConfig } from "@/mock/home"; +import {HomeDummyData, HomeTableConfig} from "@/mock/home"; +import {useEffect, useState} from "react"; export default function Home() { + const [homeData, setHomeData] = useState([]); + + useEffect(() => { + fetch("http://localhost:2979/api/v1/get_entities", { + method: "GET", + // credentials: 'include', + }) + .then((resp) => + resp.json().then((jsonData) => { + console.log(jsonData); + jsonData.length > 0 ? setHomeData(jsonData) : setHomeData(HomeDummyData); + }), + ) + .then() + .catch(); + }, []); + return (

Home View Table

- +
diff --git a/pkgs/ui/src/mock/home/index.ts b/pkgs/ui/src/mock/home/index.ts index ccff693..b6c2d4f 100644 --- a/pkgs/ui/src/mock/home/index.ts +++ b/pkgs/ui/src/mock/home/index.ts @@ -21,27 +21,27 @@ export const HomeDummyData = [ export const HomeTableConfig = [ { - key: "entity_name", + key: "name", label: "Entity name", }, { - key: "entity_DID", + key: "did", label: "Entity DID", }, + // { + // key: "network", + // label: "Network", + // }, { - key: "network", - label: "Network", - }, - { - key: "ip_address", + key: "ip", label: "IP address", }, + // { + // key: "roles", + // label: "Roles", + // }, { - key: "roles", - label: "Roles", - }, - { - key: "visible", - label: "Visible", + key: "attached", + label: "Attached", }, ]; From 01ce85bb156c5c43d396858b3a8e51b5c9f41362 Mon Sep 17 00:00:00 2001 From: erdemarslan Date: Sat, 9 Dec 2023 18:36:24 +0100 Subject: [PATCH 13/58] fix formatting --- pkgs/ui/src/app/access-point/page.tsx | 4 ++- pkgs/ui/src/app/client-1/page.tsx | 16 ++++++----- pkgs/ui/src/app/client-2/page.tsx | 18 ++++++++----- pkgs/ui/src/app/home/page.tsx | 38 ++++++++++++++------------- 4 files changed, 44 insertions(+), 32 deletions(-) diff --git a/pkgs/ui/src/app/access-point/page.tsx b/pkgs/ui/src/app/access-point/page.tsx index 277d5c0..0ea7a72 100644 --- a/pkgs/ui/src/app/access-point/page.tsx +++ b/pkgs/ui/src/app/access-point/page.tsx @@ -22,7 +22,9 @@ export default function AccessPoint() { .then((resp) => resp.json().then((jsonData) => { console.log(jsonData); - jsonData.length > 0 ? setRepositoryData(jsonData) : setRepositoryData(APServiceRepositoryDummyData); + jsonData.length > 0 + ? setRepositoryData(jsonData) + : setRepositoryData(APServiceRepositoryDummyData); }), ) .then() diff --git a/pkgs/ui/src/app/client-1/page.tsx b/pkgs/ui/src/app/client-1/page.tsx index bf47d67..3eb97c7 100644 --- a/pkgs/ui/src/app/client-1/page.tsx +++ b/pkgs/ui/src/app/client-1/page.tsx @@ -23,7 +23,9 @@ export default function Client1() { .then((resp) => resp.json().then((jsonData) => { console.log(jsonData); - jsonData.length > 0 ? setConsumerData(jsonData) : setConsumerData(Client1ConsumerData); + jsonData.length > 0 + ? setConsumerData(jsonData) + : setConsumerData(Client1ConsumerData); }), ) .then() @@ -33,11 +35,13 @@ export default function Client1() { method: "GET", // credentials: 'include', }) - .then((resp) => - resp.json().then((jsonData) => { - console.log(jsonData); - jsonData.length > 0 ? setProducerData(jsonData) : setProducerData(Client1ProducerData); - }), + .then((resp) => + resp.json().then((jsonData) => { + console.log(jsonData); + jsonData.length > 0 + ? setProducerData(jsonData) + : setProducerData(Client1ProducerData); + }), ) .then() .catch(); diff --git a/pkgs/ui/src/app/client-2/page.tsx b/pkgs/ui/src/app/client-2/page.tsx index b833d89..43da43d 100644 --- a/pkgs/ui/src/app/client-2/page.tsx +++ b/pkgs/ui/src/app/client-2/page.tsx @@ -9,7 +9,7 @@ import { Client2SummaryDetails, } from "@/mock/client_2"; import CustomTable from "@/components/table"; -import {useEffect, useState} from "react"; +import { useEffect, useState } from "react"; export default function Client1() { const [consumerData, setConsumerData] = useState([]); @@ -23,7 +23,9 @@ export default function Client1() { .then((resp) => resp.json().then((jsonData) => { console.log(jsonData); - jsonData.length > 0 ? setConsumerData(jsonData) : setConsumerData(Client2ConsumerData); + jsonData.length > 0 + ? setConsumerData(jsonData) + : setConsumerData(Client2ConsumerData); }), ) .then() @@ -33,11 +35,13 @@ export default function Client1() { method: "GET", // credentials: 'include', }) - .then((resp) => - resp.json().then((jsonData) => { - console.log(jsonData); - jsonData.length > 0 ? setProducerData(jsonData) : setProducerData(Client2ProducerData); - }), + .then((resp) => + resp.json().then((jsonData) => { + console.log(jsonData); + jsonData.length > 0 + ? setProducerData(jsonData) + : setProducerData(Client2ProducerData); + }), ) .then() .catch(); diff --git a/pkgs/ui/src/app/home/page.tsx b/pkgs/ui/src/app/home/page.tsx index 4e14f4f..08e702e 100644 --- a/pkgs/ui/src/app/home/page.tsx +++ b/pkgs/ui/src/app/home/page.tsx @@ -1,28 +1,30 @@ "use client"; -import {NoDataOverlay} from "@/components/noDataOverlay"; +import { NoDataOverlay } from "@/components/noDataOverlay"; import SummaryDetails from "@/components/summary_card"; import CustomTable from "@/components/table"; -import {HomeDummyData, HomeTableConfig} from "@/mock/home"; -import {useEffect, useState} from "react"; +import { HomeDummyData, HomeTableConfig } from "@/mock/home"; +import { useEffect, useState } from "react"; export default function Home() { - const [homeData, setHomeData] = useState([]); + const [homeData, setHomeData] = useState([]); - useEffect(() => { - fetch("http://localhost:2979/api/v1/get_entities", { - method: "GET", - // credentials: 'include', - }) - .then((resp) => - resp.json().then((jsonData) => { - console.log(jsonData); - jsonData.length > 0 ? setHomeData(jsonData) : setHomeData(HomeDummyData); - }), - ) - .then() - .catch(); - }, []); + useEffect(() => { + fetch("http://localhost:2979/api/v1/get_entities", { + method: "GET", + // credentials: 'include', + }) + .then((resp) => + resp.json().then((jsonData) => { + console.log(jsonData); + jsonData.length > 0 + ? setHomeData(jsonData) + : setHomeData(HomeDummyData); + }), + ) + .then() + .catch(); + }, []); return (
From 084288232028355d9d28c7ad372ac46b86c9f848 Mon Sep 17 00:00:00 2001 From: "Arslan, Erdem" Date: Sat, 9 Dec 2023 18:55:19 +0100 Subject: [PATCH 14/58] try creating type RepositoryData to fix pipeline --- pkgs/ui/src/app/access-point/page.tsx | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/pkgs/ui/src/app/access-point/page.tsx b/pkgs/ui/src/app/access-point/page.tsx index 0ea7a72..19196a4 100644 --- a/pkgs/ui/src/app/access-point/page.tsx +++ b/pkgs/ui/src/app/access-point/page.tsx @@ -11,8 +11,15 @@ import { } from "@/mock/access_point"; import { useEffect, useState } from "react"; +interface RepositoryData { + entity_name: string; + entity_did: string; + network: string; + ip_address: string; +} + export default function AccessPoint() { - const [repositoryData, setRepositoryData] = useState([]); + const [repositoryData, setRepositoryData] = useState([]); useEffect(() => { fetch("http://localhost:2979/api/v1/get_repositories", { From a93e6019c5c395d031045482011d45cb3315dad0 Mon Sep 17 00:00:00 2001 From: Luis-Hebendanz Date: Sat, 9 Dec 2023 18:57:20 +0100 Subject: [PATCH 15/58] clan_cli: Added automated database population. Fixed incorrect error handling in backend --- pkgs/clan-cli/clan_cli/webui/__init__.py | 6 ++ pkgs/clan-cli/clan_cli/webui/app.py | 5 +- .../clan-cli/clan_cli/webui/error_handlers.py | 2 +- .../clan_cli/webui/routers/sql_connect.py | 55 +++++++++---------- pkgs/clan-cli/clan_cli/webui/schemas.py | 8 ++- pkgs/clan-cli/clan_cli/webui/server.py | 21 +++++++ pkgs/clan-cli/clan_cli/webui/sql_crud.py | 26 ++++----- pkgs/clan-cli/clan_cli/webui/sql_models.py | 1 + pkgs/clan-cli/tests/test_db_api.py | 32 ++++++++--- 9 files changed, 102 insertions(+), 54 deletions(-) diff --git a/pkgs/clan-cli/clan_cli/webui/__init__.py b/pkgs/clan-cli/clan_cli/webui/__init__.py index de2f5ae..4fc79ad 100644 --- a/pkgs/clan-cli/clan_cli/webui/__init__.py +++ b/pkgs/clan-cli/clan_cli/webui/__init__.py @@ -22,6 +22,12 @@ def register_parser(parser: argparse.ArgumentParser) -> None: parser.add_argument( "--host", type=str, default="localhost", help="Host to listen on" ) + parser.add_argument( + "--no-populate", + action="store_true", + help="Don't populate the database with dummy data", + default=False, + ) parser.add_argument( "--no-open", action="store_true", help="Don't open the browser", default=False ) diff --git a/pkgs/clan-cli/clan_cli/webui/app.py b/pkgs/clan-cli/clan_cli/webui/app.py index b5cb9b1..173cef8 100644 --- a/pkgs/clan-cli/clan_cli/webui/app.py +++ b/pkgs/clan-cli/clan_cli/webui/app.py @@ -35,10 +35,11 @@ def setup_app() -> FastAPI: # bind sql engine # TODO comment aut and add flag to run with pupulated data rm *.sql run pytest with marked then start clan webui # https://docs.pytest.org/en/7.1.x/example/markers.html - sql_models.Base.metadata.drop_all(engine) + # sql_models.Base.metadata.drop_all(engine) + sql_models.Base.metadata.create_all(bind=engine) - app = FastAPI(lifespan=lifespan) + app = FastAPI(lifespan=lifespan, swagger_ui_parameters={"tryItOutEnabled": True}) app.add_middleware( CORSMiddleware, allow_origins=origins, diff --git a/pkgs/clan-cli/clan_cli/webui/error_handlers.py b/pkgs/clan-cli/clan_cli/webui/error_handlers.py index 341bb2e..9948cc5 100644 --- a/pkgs/clan-cli/clan_cli/webui/error_handlers.py +++ b/pkgs/clan-cli/clan_cli/webui/error_handlers.py @@ -25,7 +25,7 @@ def sql_error_handler(request: Request, exc: SQLAlchemyError) -> JSONResponse: def clan_error_handler(request: Request, exc: ClanError) -> JSONResponse: - log.error("ClanError: %s", exc) + log.exception(exc) detail = [ { "loc": [], diff --git a/pkgs/clan-cli/clan_cli/webui/routers/sql_connect.py b/pkgs/clan-cli/clan_cli/webui/routers/sql_connect.py index 9a5c8b1..9fe73f7 100644 --- a/pkgs/clan-cli/clan_cli/webui/routers/sql_connect.py +++ b/pkgs/clan-cli/clan_cli/webui/routers/sql_connect.py @@ -1,3 +1,4 @@ +import logging import time from typing import List, Optional @@ -5,6 +6,7 @@ import httpx from fastapi import APIRouter, BackgroundTasks, Depends from sqlalchemy.orm import Session +from ...errors import ClanError from .. import sql_crud, sql_db, sql_models from ..schemas import ( Consumer, @@ -20,6 +22,8 @@ from ..tags import Tags router = APIRouter() +log = logging.getLogger(__name__) + ######################### # # @@ -141,11 +145,7 @@ def get_repository( @router.post("/api/v1/create_entity", response_model=Entity, tags=[Tags.entities]) def create_entity( entity: EntityCreate, db: Session = Depends(sql_db.get_db) -) -> EntityCreate | str: - # todo checken ob schon da ... - if sql_crud.get_entity_by_did(db, did=entity.did): - print("did already exsists") - return "Error did already exsists in db" +) -> EntityCreate: return sql_crud.create_entity(db, entity) @@ -178,7 +178,7 @@ def get_attached_entities( return entities -@router.post("/api/v1/detach") +@router.post("/api/v1/detach", response_model=Entity, tags=[Tags.entities]) async def detach( background_tasks: BackgroundTasks, entity_did: str = "did:sov:test:1234", @@ -186,13 +186,11 @@ async def detach( limit: int = 100, db: Session = Depends(sql_db.get_db), ) -> dict[str, str]: - background_tasks.add_task( - sql_crud.set_attached_by_entity_did, db, entity_did, False - ) - return {"message": "Detaching in the background"} + entity = sql_crud.set_attached_by_entity_did(db, entity_did, False) + return entity -@router.post("/api/v1/attach") +@router.post("/api/v1/attach", tags=[Tags.entities]) async def attach( background_tasks: BackgroundTasks, entity_did: str = "did:sov:test:1234", @@ -200,27 +198,28 @@ async def attach( limit: int = 100, db: Session = Depends(sql_db.get_db), ) -> dict[str, str]: + if sql_crud.get_entity_by_did(db, entity_did) is None: + raise ClanError(f"Entity with did '{entity_did}' not found") + background_tasks.add_task(attach_entity, db, entity_did) return {"message": "Attaching in the background"} -# TODO def attach_entity(db: Session, entity_did: str) -> None: db_entity = sql_crud.set_attached_by_entity_did(db, entity_did, True) try: - if db_entity is not None: - while db_entity.attached: - # query status endpoint - # https://www.python-httpx.org/ - response = httpx.get(f"http://{db_entity.ip}", timeout=2) - print(response) - # test with: - # while true ; do printf 'HTTP/1.1 200 OK\r\n\r\ncool, thanks' | nc -l -N localhost 5555 ; done - # client test (apt install python3-httpx): - # httpx http://localhost:5555 - # except not reached set false - time.sleep(1) - except Exception as e: - print(e) - if db_entity is not None: - db_entity = sql_crud.set_attached_by_entity_did(db, entity_did, False) + while db_entity.attached: + # query status endpoint + # https://www.python-httpx.org/ + response = httpx.get(f"http://{db_entity.ip}", timeout=2) + print(response) + # test with: + # while true ; do printf 'HTTP/1.1 200 OK\r\n\r\ncool, thanks' | nc -l -N localhost 5555 ; done + # client test (apt install python3-httpx): + # httpx http://localhost:5555 + # except not reached set false + time.sleep(1) + except Exception: + log.warning(f"Entity {entity_did} not reachable. Setting attached to false") + + db_entity = sql_crud.set_attached_by_entity_did(db, entity_did, False) diff --git a/pkgs/clan-cli/clan_cli/webui/schemas.py b/pkgs/clan-cli/clan_cli/webui/schemas.py index 96987f9..ccfb548 100644 --- a/pkgs/clan-cli/clan_cli/webui/schemas.py +++ b/pkgs/clan-cli/clan_cli/webui/schemas.py @@ -27,7 +27,7 @@ class ProducerBase(BaseModel): service_type: str = "3D Printing" endpoint_url: str = "http://127.0.0.1:8000" status: str = "unknown" - other: dict = {"test": "test"} + other: dict = {"action": ["register", "deregister", "delete", "create"]} class ProducerCreate(ProducerBase): @@ -91,7 +91,11 @@ class EntityBase(BaseModel): name: str = "C1" ip: str = "127.0.0.1" attached: bool = False - other: dict = {"test": "test"} + visible: bool = True + other: dict = { + "network": "Carlo's Home Network", + "roles": ["service repository", "service prosumer"], + } class EntityCreate(EntityBase): diff --git a/pkgs/clan-cli/clan_cli/webui/server.py b/pkgs/clan-cli/clan_cli/webui/server.py index 66b0f39..8975166 100644 --- a/pkgs/clan-cli/clan_cli/webui/server.py +++ b/pkgs/clan-cli/clan_cli/webui/server.py @@ -105,6 +105,27 @@ def start_server(args: argparse.Namespace) -> None: if not args.no_open: Thread(target=open_browser, args=(base_url, args.sub_url)).start() + # DELETE all data from the database + from . import sql_models + from .sql_db import engine + + sql_models.Base.metadata.drop_all(engine) + + if args.no_populate is False: + test_dir = Path(__file__).parent.parent.parent / "tests" + + if not test_dir.is_dir(): + raise ClanError(f"Could not find test dir: {test_dir}") + + test_db_api = test_dir / "test_db_api.py" + if not test_db_api.is_file(): + raise ClanError(f"Could not find test db api: {test_db_api}") + + import subprocess + + cmd = ["pytest", "-s", "-n0", str(test_db_api)] + subprocess.run(cmd, check=True) + uvicorn.run( "clan_cli.webui.app:app", host=args.host, diff --git a/pkgs/clan-cli/clan_cli/webui/sql_crud.py b/pkgs/clan-cli/clan_cli/webui/sql_crud.py index d6119c9..fcc8c15 100644 --- a/pkgs/clan-cli/clan_cli/webui/sql_crud.py +++ b/pkgs/clan-cli/clan_cli/webui/sql_crud.py @@ -3,6 +3,7 @@ from typing import List, Optional from sqlalchemy.orm import Session from sqlalchemy.sql.expression import true +from ..errors import ClanError from . import schemas, sql_models ######################### @@ -153,21 +154,18 @@ def get_attached_entities( ) -# set attached -# None if did not found # Returns same entity if setting didnt changed something def set_attached_by_entity_did( db: Session, entity_did: str, value: bool -) -> Optional[sql_models.Entity]: - # ste attached to true +) -> sql_models.Entity: db_entity = get_entity_by_did(db, entity_did) - if db_entity is not None: - # db_entity.attached = Column(True) - setattr(db_entity, "attached", value) - # save changes in db - db.add(db_entity) - db.commit() - db.refresh(db_entity) - return db_entity - else: - return db_entity + if db_entity is None: + raise ClanError(f"Entity with did '{entity_did}' not found") + + setattr(db_entity, "attached", value) + + # save changes in db + db.add(db_entity) + db.commit() + db.refresh(db_entity) + return db_entity diff --git a/pkgs/clan-cli/clan_cli/webui/sql_models.py b/pkgs/clan-cli/clan_cli/webui/sql_models.py index 88231ca..68ab103 100644 --- a/pkgs/clan-cli/clan_cli/webui/sql_models.py +++ b/pkgs/clan-cli/clan_cli/webui/sql_models.py @@ -26,6 +26,7 @@ class Entity(Base): name = Column(String, index=True) ip = Column(String, index=True) attached = Column(Boolean, index=True) + visible = Column(Boolean, index=True) ## Non queryable body ## # In here we deposit: Network, Roles, Visible, etc. diff --git a/pkgs/clan-cli/tests/test_db_api.py b/pkgs/clan-cli/tests/test_db_api.py index 5f6d16e..9e24e4d 100644 --- a/pkgs/clan-cli/tests/test_db_api.py +++ b/pkgs/clan-cli/tests/test_db_api.py @@ -77,7 +77,9 @@ def test_producer(api: TestClient) -> None: "service_type": "3D Printing", "endpoint_url": "http://127.0.0.1:8000", "status": "unknown", - "other": {"test": "test"}, + "other": { + "action": ["register", "deregister", "delete", "create"] + }, "entity_did": default_entity_did, } paramter = "producer" @@ -92,7 +94,9 @@ def test_producer2(api: TestClient) -> None: "service_type": "Fax", "endpoint_url": "http://127.0.0.1:8001", "status": "unknown", - "other": {"faxen": "dicke"}, + "other": { + "action": ["register", "deregister", "delete", "create"] + }, "entity_did": default_entity_did2, } paramter = "producer" @@ -107,7 +111,9 @@ def test_producer3(api: TestClient) -> None: "service_type": "VR-Stream", "endpoint_url": "http://127.0.0.1:8002", "status": "unknown", - "other": {"oculos": "rift"}, + "other": { + "action": ["register", "deregister", "delete", "create"] + }, "entity_did": default_entity_did3, } paramter = "producer" @@ -122,7 +128,9 @@ def test_producer4(api: TestClient) -> None: "service_type": "gallary", "endpoint_url": "http://127.0.0.1:8003", "status": "unknown", - "other": {"nice": "pics"}, + "other": { + "action": ["register", "deregister", "delete", "create"] + }, "entity_did": default_entity_did4, } paramter = "producer" @@ -137,7 +145,9 @@ def test_producer5(api: TestClient) -> None: "service_type": "Game-Shop", "endpoint_url": "http://127.0.0.1:8004", "status": "unknown", - "other": {"war": "games"}, + "other": { + "action": ["register", "deregister", "delete", "create"] + }, "entity_did": default_entity_did5, } paramter = "producer" @@ -263,7 +273,11 @@ def test_entity(api: TestClient) -> None: "name": "C1", "ip": "127.0.0.1", "attached": False, - "other": {"test": "test"}, + "visible": True, + "other": { + "network": "Carlo1's Home Network", + "roles": ["service repository", "service consumer"], + }, } paramter = "entity" # get_request = "entity_did=did%3Asov%3Atest%3A1234" @@ -276,7 +290,11 @@ def test_entity2(api: TestClient) -> None: "name": "C2", "ip": "127.0.0.2", "attached": False, - "other": {"test": "test"}, + "visible": True, + "other": { + "network": "Carlo2's Home Network", + "roles": ["service repository", "service prosumer"], + }, } paramter = "entity" get_request = "entity_did=" + url.quote(default_entity_did2) From 4e0346d0a0e73c7efbf41100c40ca5590c7e7dfb Mon Sep 17 00:00:00 2001 From: Luis-Hebendanz Date: Sat, 9 Dec 2023 18:57:55 +0100 Subject: [PATCH 16/58] nix fmt --- README.md | 2 +- pkgs/clan-cli/tests/test_db_api.py | 20 +++++--------------- 2 files changed, 6 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index 85d2b42..ef9cb23 100644 --- a/README.md +++ b/README.md @@ -106,7 +106,7 @@ Let's set up your Git workflow to collaborate effectively: - URL of Gitea instance: `https://gitea.gchq.icu` - Name of new Login [gitea.gchq.icu]: `gitea.gchq.icu:7171` - Do you have an access token? Yes - - Token: ****\***** + - Token: \***\*\*\*\*** - Set Optional settings: No 2. **Git Workflow**: diff --git a/pkgs/clan-cli/tests/test_db_api.py b/pkgs/clan-cli/tests/test_db_api.py index 9e24e4d..b26a65e 100644 --- a/pkgs/clan-cli/tests/test_db_api.py +++ b/pkgs/clan-cli/tests/test_db_api.py @@ -77,9 +77,7 @@ def test_producer(api: TestClient) -> None: "service_type": "3D Printing", "endpoint_url": "http://127.0.0.1:8000", "status": "unknown", - "other": { - "action": ["register", "deregister", "delete", "create"] - }, + "other": {"action": ["register", "deregister", "delete", "create"]}, "entity_did": default_entity_did, } paramter = "producer" @@ -94,9 +92,7 @@ def test_producer2(api: TestClient) -> None: "service_type": "Fax", "endpoint_url": "http://127.0.0.1:8001", "status": "unknown", - "other": { - "action": ["register", "deregister", "delete", "create"] - }, + "other": {"action": ["register", "deregister", "delete", "create"]}, "entity_did": default_entity_did2, } paramter = "producer" @@ -111,9 +107,7 @@ def test_producer3(api: TestClient) -> None: "service_type": "VR-Stream", "endpoint_url": "http://127.0.0.1:8002", "status": "unknown", - "other": { - "action": ["register", "deregister", "delete", "create"] - }, + "other": {"action": ["register", "deregister", "delete", "create"]}, "entity_did": default_entity_did3, } paramter = "producer" @@ -128,9 +122,7 @@ def test_producer4(api: TestClient) -> None: "service_type": "gallary", "endpoint_url": "http://127.0.0.1:8003", "status": "unknown", - "other": { - "action": ["register", "deregister", "delete", "create"] - }, + "other": {"action": ["register", "deregister", "delete", "create"]}, "entity_did": default_entity_did4, } paramter = "producer" @@ -145,9 +137,7 @@ def test_producer5(api: TestClient) -> None: "service_type": "Game-Shop", "endpoint_url": "http://127.0.0.1:8004", "status": "unknown", - "other": { - "action": ["register", "deregister", "delete", "create"] - }, + "other": {"action": ["register", "deregister", "delete", "create"]}, "entity_did": default_entity_did5, } paramter = "producer" From 129e25e52e834417a6731274d76546f1940b097d Mon Sep 17 00:00:00 2001 From: "Arslan, Erdem" Date: Sat, 9 Dec 2023 18:58:59 +0100 Subject: [PATCH 17/58] fix linting --- pkgs/ui/src/app/access-point/page.tsx | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pkgs/ui/src/app/access-point/page.tsx b/pkgs/ui/src/app/access-point/page.tsx index 19196a4..0e22a84 100644 --- a/pkgs/ui/src/app/access-point/page.tsx +++ b/pkgs/ui/src/app/access-point/page.tsx @@ -12,14 +12,14 @@ import { import { useEffect, useState } from "react"; interface RepositoryData { - entity_name: string; - entity_did: string; - network: string; - ip_address: string; + entity_name: string; + entity_did: string; + network: string; + ip_address: string; } export default function AccessPoint() { - const [repositoryData, setRepositoryData] = useState([]); + const [repositoryData, setRepositoryData] = useState([]); useEffect(() => { fetch("http://localhost:2979/api/v1/get_repositories", { From 0c08cde34c3a5295c178260af09e70cb7824e85d Mon Sep 17 00:00:00 2001 From: Luis-Hebendanz Date: Sat, 9 Dec 2023 19:10:11 +0100 Subject: [PATCH 18/58] Fixed testing issue. Improved README --- README.md | 10 ++++++---- pkgs/clan-cli/clan_cli/webui/__init__.py | 4 ++-- pkgs/clan-cli/clan_cli/webui/server.py | 2 +- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index ef9cb23..5d285c8 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ -# 1Service Aware Network Project Repo +# Service Aware Network Project Repo -Welcome to our website repository! This repo is designed to help you and your team build high-quality websites efficiently. We've carefully chosen the technologies to make development smooth and enjoyable. Here's what you can expect from this template: +Welcome to our website repository! This repo is designed to build high-quality websites efficiently. We've carefully chosen the technologies to make development smooth and enjoyable. **Frontend**: Our frontend is powered by [React NextJS](https://nextjs.org/), a popular and versatile framework for building web applications. @@ -51,6 +51,7 @@ sudo echo "experimental-features = nix-command flakes" > '/etc/nix/nix.conf' 4. **Clone the Repository and Navigate**: - Clone this repository and navigate to it. + - If you are under Windows Subystem For Linux (WSL) please clone the repository to the home folder of your Linux. Do NOT clone it onto your Windows machine! 5. **Allow .envrc**: @@ -72,9 +73,10 @@ sudo echo "experimental-features = nix-command flakes" > '/etc/nix/nix.conf' - To start the backend server, execute: ```bash - clan webui --reload --no-open --log-level debug + clan webui --reload --no-open --log-level debug --populate ``` - The server will automatically restart if any Python files change. + - The `--populate` flag will automatically populate the database with dummy data 8. **Build the Frontend**: @@ -194,8 +196,8 @@ If you need to inspect the Nix sandbox while running tests, follow these steps: 2. Use `cntr` and `psgrep` to attach to the Nix sandbox. This allows you to interactively debug your code while it's paused. For example: ```bash - cntr exec -w your_sandbox_name psgrep -a -x your_python_process_name + cntr attach ``` These debugging and testing methods will help you identify and fix issues in your backend code efficiently, ensuring the reliability and robustness of your application. diff --git a/pkgs/clan-cli/clan_cli/webui/__init__.py b/pkgs/clan-cli/clan_cli/webui/__init__.py index 4fc79ad..1305e78 100644 --- a/pkgs/clan-cli/clan_cli/webui/__init__.py +++ b/pkgs/clan-cli/clan_cli/webui/__init__.py @@ -23,9 +23,9 @@ def register_parser(parser: argparse.ArgumentParser) -> None: "--host", type=str, default="localhost", help="Host to listen on" ) parser.add_argument( - "--no-populate", + "--populate", action="store_true", - help="Don't populate the database with dummy data", + help="Populate the database with dummy data", default=False, ) parser.add_argument( diff --git a/pkgs/clan-cli/clan_cli/webui/server.py b/pkgs/clan-cli/clan_cli/webui/server.py index 8975166..762ccb2 100644 --- a/pkgs/clan-cli/clan_cli/webui/server.py +++ b/pkgs/clan-cli/clan_cli/webui/server.py @@ -111,7 +111,7 @@ def start_server(args: argparse.Namespace) -> None: sql_models.Base.metadata.drop_all(engine) - if args.no_populate is False: + if args.populate: test_dir = Path(__file__).parent.parent.parent / "tests" if not test_dir.is_dir(): From 1cfb5f9fa83a8e0e460081ed17d0f575df20fffe Mon Sep 17 00:00:00 2001 From: "Arslan, Erdem" Date: Sat, 9 Dec 2023 19:11:30 +0100 Subject: [PATCH 19/58] transform data received from endpoint --- pkgs/ui/src/app/access-point/page.tsx | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/pkgs/ui/src/app/access-point/page.tsx b/pkgs/ui/src/app/access-point/page.tsx index 0e22a84..05feee3 100644 --- a/pkgs/ui/src/app/access-point/page.tsx +++ b/pkgs/ui/src/app/access-point/page.tsx @@ -29,8 +29,16 @@ export default function AccessPoint() { .then((resp) => resp.json().then((jsonData) => { console.log(jsonData); + + const transformedData = jsonData.map((item) => ({ + entity_name: item.service_name, + entity_did: item.entity_did, + network: item.network, + ip_address: "", // You might need to set an appropriate default value + })); + jsonData.length > 0 - ? setRepositoryData(jsonData) + ? setRepositoryData(transformedData) : setRepositoryData(APServiceRepositoryDummyData); }), ) From 37d34d4f36b2201b0f01a46ac0de8965fa4ea73d Mon Sep 17 00:00:00 2001 From: Onur Arslan Date: Sat, 9 Dec 2023 19:29:42 +0100 Subject: [PATCH 20/58] fixed the issues for merge --- pkgs/ui/src/app/access-point/page.tsx | 9 +++------ pkgs/ui/src/app/client-1/page.tsx | 10 ++-------- pkgs/ui/src/app/client-2/page.tsx | 10 ++-------- pkgs/ui/src/app/home/page.tsx | 6 ++---- 4 files changed, 9 insertions(+), 26 deletions(-) diff --git a/pkgs/ui/src/app/access-point/page.tsx b/pkgs/ui/src/app/access-point/page.tsx index 05feee3..ba05481 100644 --- a/pkgs/ui/src/app/access-point/page.tsx +++ b/pkgs/ui/src/app/access-point/page.tsx @@ -6,7 +6,6 @@ import { APSummaryDetails, APAttachmentsDummyData, APAttachmentsTableConfig, - APServiceRepositoryDummyData, APServiceRepositoryTableConfig, } from "@/mock/access_point"; import { useEffect, useState } from "react"; @@ -30,16 +29,14 @@ export default function AccessPoint() { resp.json().then((jsonData) => { console.log(jsonData); - const transformedData = jsonData.map((item) => ({ + const transformedData = jsonData.map((item: { service_name: any; entity_did: any; network: any; }) => ({ entity_name: item.service_name, entity_did: item.entity_did, network: item.network, - ip_address: "", // You might need to set an appropriate default value + ip_address: "", })); - jsonData.length > 0 - ? setRepositoryData(transformedData) - : setRepositoryData(APServiceRepositoryDummyData); + setRepositoryData(transformedData); }), ) .then() diff --git a/pkgs/ui/src/app/client-1/page.tsx b/pkgs/ui/src/app/client-1/page.tsx index 3eb97c7..a2f6b0e 100644 --- a/pkgs/ui/src/app/client-1/page.tsx +++ b/pkgs/ui/src/app/client-1/page.tsx @@ -3,10 +3,8 @@ import SummaryDetails from "@/components/summary_card"; import { Client1SummaryDetails, - Client1ConsumerData, Client1ConsumerTableConfig, Client1ProducerTableConfig, - Client1ProducerData, } from "@/mock/client_1"; import CustomTable from "@/components/table"; import { useEffect, useState } from "react"; @@ -23,9 +21,7 @@ export default function Client1() { .then((resp) => resp.json().then((jsonData) => { console.log(jsonData); - jsonData.length > 0 - ? setConsumerData(jsonData) - : setConsumerData(Client1ConsumerData); + setConsumerData(jsonData); }), ) .then() @@ -38,9 +34,7 @@ export default function Client1() { .then((resp) => resp.json().then((jsonData) => { console.log(jsonData); - jsonData.length > 0 - ? setProducerData(jsonData) - : setProducerData(Client1ProducerData); + setProducerData(jsonData); }), ) .then() diff --git a/pkgs/ui/src/app/client-2/page.tsx b/pkgs/ui/src/app/client-2/page.tsx index 43da43d..8b9a8d0 100644 --- a/pkgs/ui/src/app/client-2/page.tsx +++ b/pkgs/ui/src/app/client-2/page.tsx @@ -2,9 +2,7 @@ import SummaryDetails from "@/components/summary_card"; import { - Client2ConsumerData, Client2ConsumerTableConfig, - Client2ProducerData, Client2ProducerTableConfig, Client2SummaryDetails, } from "@/mock/client_2"; @@ -23,9 +21,7 @@ export default function Client1() { .then((resp) => resp.json().then((jsonData) => { console.log(jsonData); - jsonData.length > 0 - ? setConsumerData(jsonData) - : setConsumerData(Client2ConsumerData); + setConsumerData(jsonData); }), ) .then() @@ -38,9 +34,7 @@ export default function Client1() { .then((resp) => resp.json().then((jsonData) => { console.log(jsonData); - jsonData.length > 0 - ? setProducerData(jsonData) - : setProducerData(Client2ProducerData); + setProducerData(jsonData); }), ) .then() diff --git a/pkgs/ui/src/app/home/page.tsx b/pkgs/ui/src/app/home/page.tsx index 08e702e..16b0984 100644 --- a/pkgs/ui/src/app/home/page.tsx +++ b/pkgs/ui/src/app/home/page.tsx @@ -3,7 +3,7 @@ import { NoDataOverlay } from "@/components/noDataOverlay"; import SummaryDetails from "@/components/summary_card"; import CustomTable from "@/components/table"; -import { HomeDummyData, HomeTableConfig } from "@/mock/home"; +import { HomeTableConfig } from "@/mock/home"; import { useEffect, useState } from "react"; export default function Home() { @@ -17,9 +17,7 @@ export default function Home() { .then((resp) => resp.json().then((jsonData) => { console.log(jsonData); - jsonData.length > 0 - ? setHomeData(jsonData) - : setHomeData(HomeDummyData); + setHomeData(jsonData); }), ) .then() From 556b3867876bf4f8e02b76a1f7a4e0aade7328b7 Mon Sep 17 00:00:00 2001 From: "Arslan, Erdem" Date: Sat, 9 Dec 2023 19:39:42 +0100 Subject: [PATCH 21/58] fix formatting --- pkgs/ui/src/app/access-point/page.tsx | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/pkgs/ui/src/app/access-point/page.tsx b/pkgs/ui/src/app/access-point/page.tsx index ba05481..230ee98 100644 --- a/pkgs/ui/src/app/access-point/page.tsx +++ b/pkgs/ui/src/app/access-point/page.tsx @@ -29,12 +29,14 @@ export default function AccessPoint() { resp.json().then((jsonData) => { console.log(jsonData); - const transformedData = jsonData.map((item: { service_name: any; entity_did: any; network: any; }) => ({ - entity_name: item.service_name, - entity_did: item.entity_did, - network: item.network, - ip_address: "", - })); + const transformedData = jsonData.map( + (item: { service_name: any; entity_did: any; network: any }) => ({ + entity_name: item.service_name, + entity_did: item.entity_did, + network: item.network, + ip_address: "", + }), + ); setRepositoryData(transformedData); }), From f296c01abc24a4c4db02e7929fad3d389df17c81 Mon Sep 17 00:00:00 2001 From: ui-asset-bot Date: Sat, 9 Dec 2023 18:45:38 +0000 Subject: [PATCH 22/58] update ui-assets.nix --- pkgs/ui/nix/ui-assets.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/ui/nix/ui-assets.nix b/pkgs/ui/nix/ui-assets.nix index 9e81835..8d7ce17 100644 --- a/pkgs/ui/nix/ui-assets.nix +++ b/pkgs/ui/nix/ui-assets.nix @@ -1,5 +1,5 @@ { fetchzip }: fetchzip { - url = "https://gitea.gchq.icu/api/packages/IoSL/generic/IoSL-service-aware-frontend/16glc9nkcqsalf5jwcwcsv1nx65cqwrqr95n1ghmb365nxi57bb4/assets.tar.gz"; - sha256 = "16glc9nkcqsalf5jwcwcsv1nx65cqwrqr95n1ghmb365nxi57bb4"; + url = "https://gitea.gchq.icu/api/packages/IoSL/generic/IoSL-service-aware-frontend/07dai984ffhflf6i6bs5dg1dybgq6s4vrkwi1fr05sxppg7bz1wq/assets.tar.gz"; + sha256 = "07dai984ffhflf6i6bs5dg1dybgq6s4vrkwi1fr05sxppg7bz1wq"; } From b12201c559baa97c531e52a561779b3f68e99afa Mon Sep 17 00:00:00 2001 From: Luis-Hebendanz Date: Sat, 9 Dec 2023 20:57:05 +0100 Subject: [PATCH 23/58] Added resolution endpoint. Added delete endpoints. Added tests for new endpoints --- .../clan_cli/webui/routers/sql_connect.py | 91 ++++++++++++++++++- pkgs/clan-cli/clan_cli/webui/schemas.py | 26 ++++++ pkgs/clan-cli/clan_cli/webui/sql_crud.py | 75 ++++++++++++++- pkgs/clan-cli/clan_cli/webui/sql_models.py | 3 +- pkgs/clan-cli/clan_cli/webui/tags.py | 5 + pkgs/clan-cli/tests/test_db_api.py | 46 ++++++++++ 6 files changed, 242 insertions(+), 4 deletions(-) diff --git a/pkgs/clan-cli/clan_cli/webui/routers/sql_connect.py b/pkgs/clan-cli/clan_cli/webui/routers/sql_connect.py index 9fe73f7..05da969 100644 --- a/pkgs/clan-cli/clan_cli/webui/routers/sql_connect.py +++ b/pkgs/clan-cli/clan_cli/webui/routers/sql_connect.py @@ -17,6 +17,8 @@ from ..schemas import ( ProducerCreate, Repository, RepositoryCreate, + Resolution, + ResolutionCreate, ) from ..tags import Tags @@ -61,6 +63,15 @@ def get_producer( return producer +@router.delete("/api/v1/delete_producer", tags=[Tags.producers]) +def delete_producer( + entity_did: str = "did:sov:test:1234", + db: Session = Depends(sql_db.get_db), +) -> dict[str, str]: + sql_crud.delete_producer_by_entity_did(db, entity_did) + return {"message": "Producer deleted"} + + ######################### # # # Consumer # @@ -97,6 +108,15 @@ def get_consumer( return consumer +@router.delete("/api/v1/delete_consumer", tags=[Tags.consumers]) +def delete_consumer( + entity_did: str = "did:sov:test:1234", + db: Session = Depends(sql_db.get_db), +) -> dict[str, str]: + sql_crud.delete_consumer_by_entity_did(db, entity_did) + return {"message": "Consumer deleted"} + + ######################### # # # REPOSITORY # @@ -133,10 +153,19 @@ def get_repository( limit: int = 100, db: Session = Depends(sql_db.get_db), ) -> List[sql_models.Repository]: - repository = sql_crud.get_repository_by_did(db, did=entity_did) + repository = sql_crud.get_repository_by_entity_did(db, did=entity_did) return repository +@router.delete("/api/v1/delete_repository", tags=[Tags.repositories]) +def delete_repository( + entity_did: str = "did:sov:test:1234", + db: Session = Depends(sql_db.get_db), +) -> dict[str, str]: + sql_crud.delete_repository_by_entity_did(db, did=entity_did) + return {"message": "Repository deleted"} + + ######################### # # # Entity # @@ -185,7 +214,7 @@ async def detach( skip: int = 0, limit: int = 100, db: Session = Depends(sql_db.get_db), -) -> dict[str, str]: +) -> sql_models.Entity: entity = sql_crud.set_attached_by_entity_did(db, entity_did, False) return entity @@ -223,3 +252,61 @@ def attach_entity(db: Session, entity_did: str) -> None: log.warning(f"Entity {entity_did} not reachable. Setting attached to false") db_entity = sql_crud.set_attached_by_entity_did(db, entity_did, False) + + +@router.delete("/api/v1/delete_entity_recursive", tags=[Tags.entities]) +def delete_entity( + entity_did: str = "did:sov:test:1234", + db: Session = Depends(sql_db.get_db), +) -> dict[str, str]: + sql_crud.delete_entity_by_did_recursive(db, did=entity_did) + return {"message": "Entity deleted and all relations to that entity"} + + +######################### +# # +# Resolution # +# # +######################### +@router.post( + "/api/v1/create_resolution", response_model=Resolution, tags=[Tags.resolutions] +) +def create_resolution( + resolution: ResolutionCreate, + db: Session = Depends(sql_db.get_db), +) -> sql_models.Resolution: + return sql_crud.create_resolution(db, resolution) + + +@router.get( + "/api/v1/get_resolutions", response_model=List[Resolution], tags=[Tags.resolutions] +) +def get_resolutions( + skip: int = 0, limit: int = 100, db: Session = Depends(sql_db.get_db) +) -> List[sql_models.Resolution]: + resolutions = sql_crud.get_resolutions(db, skip=skip, limit=limit) + return resolutions + + +@router.get( + "/api/v1/get_resolution", response_model=List[Resolution], tags=[Tags.resolutions] +) +def get_resolution( + requester_did: str = "did:sov:test:1122", + skip: int = 0, + limit: int = 100, + db: Session = Depends(sql_db.get_db), +) -> List[sql_models.Resolution]: + resolution = sql_crud.get_resolution_by_requester_did( + db, requester_did=requester_did + ) + return resolution + + +@router.delete("/api/v1/delete_resolution", tags=[Tags.resolutions]) +def delete_resolution( + requester_did: str = "did:sov:test:1122", + db: Session = Depends(sql_db.get_db), +) -> dict[str, str]: + sql_crud.delete_resolution_by_requester_did(db, requester_did=requester_did) + return {"message": "Resolution deleted"} diff --git a/pkgs/clan-cli/clan_cli/webui/schemas.py b/pkgs/clan-cli/clan_cli/webui/schemas.py index ccfb548..303e0f7 100644 --- a/pkgs/clan-cli/clan_cli/webui/schemas.py +++ b/pkgs/clan-cli/clan_cli/webui/schemas.py @@ -109,3 +109,29 @@ class Entity(EntityCreate): class Config: orm_mode = True + + +######################### +# # +# Resolution # +# # +######################### + + +class ResolutionBase(BaseModel): + requester_name: str = "C1" + requester_did: str = "did:sov:test:1122" + resolved_did: str = "did:sov:test:1234" + other: dict = {"test": "test"} + + +class ResolutionCreate(ResolutionBase): + pass + + +class Resolution(ResolutionCreate): + timestamp: datetime + id: int + + class Config: + orm_mode = True diff --git a/pkgs/clan-cli/clan_cli/webui/sql_crud.py b/pkgs/clan-cli/clan_cli/webui/sql_crud.py index fcc8c15..cf03c41 100644 --- a/pkgs/clan-cli/clan_cli/webui/sql_crud.py +++ b/pkgs/clan-cli/clan_cli/webui/sql_crud.py @@ -41,6 +41,13 @@ def get_producers_by_entity_did( ) +def delete_producer_by_entity_did(db: Session, entity_did: str) -> None: + db.query(sql_models.Producer).filter( + sql_models.Producer.entity_did == entity_did + ).delete() + db.commit() + + ######################### # # # Consumer # @@ -76,6 +83,13 @@ def get_consumers_by_entity_did( ) +def delete_consumer_by_entity_did(db: Session, entity_did: str) -> None: + db.query(sql_models.Consumer).filter( + sql_models.Consumer.entity_did == entity_did + ).delete() + db.commit() + + ######################### # # # REPOSITORY # @@ -105,7 +119,7 @@ def get_repository_by_uuid(db: Session, uuid: str) -> Optional[sql_models.Reposi ) -def get_repository_by_did( +def get_repository_by_entity_did( db: Session, did: str, skip: int = 0, limit: int = 100 ) -> List[sql_models.Repository]: return ( @@ -117,6 +131,13 @@ def get_repository_by_did( ) +def delete_repository_by_entity_did(db: Session, did: str) -> None: + db.query(sql_models.Repository).filter( + sql_models.Repository.entity_did == did + ).delete() + db.commit() + + ######################### # # # Entity # @@ -169,3 +190,55 @@ def set_attached_by_entity_did( db.commit() db.refresh(db_entity) return db_entity + + +def delete_entity_by_did(db: Session, did: str) -> None: + db.query(sql_models.Entity).filter(sql_models.Entity.did == did).delete() + db.commit() + + +def delete_entity_by_did_recursive(db: Session, did: str) -> None: + delete_producer_by_entity_did(db, did) + delete_consumer_by_entity_did(db, did) + delete_repository_by_entity_did(db, did) + delete_entity_by_did(db, did) + + +######################### +# # +# Resolution # +# # +######################### +def create_resolution( + db: Session, resolution: schemas.ResolutionCreate +) -> sql_models.Resolution: + db_resolution = sql_models.Resolution(**resolution.dict()) + db.add(db_resolution) + db.commit() + db.refresh(db_resolution) + return db_resolution + + +def get_resolutions( + db: Session, skip: int = 0, limit: int = 100 +) -> List[sql_models.Resolution]: + return db.query(sql_models.Resolution).offset(skip).limit(limit).all() + + +def get_resolution_by_requester_did( + db: Session, requester_did: str, skip: int = 0, limit: int = 100 +) -> List[sql_models.Resolution]: + return ( + db.query(sql_models.Resolution) + .filter(sql_models.Resolution.requester_did == requester_did) + .offset(skip) + .limit(limit) + .all() + ) + + +def delete_resolution_by_requester_did(db: Session, requester_did: str) -> None: + db.query(sql_models.Resolution).filter( + sql_models.Resolution.requester_did == requester_did + ).delete() + db.commit() diff --git a/pkgs/clan-cli/clan_cli/webui/sql_models.py b/pkgs/clan-cli/clan_cli/webui/sql_models.py index 68ab103..c606b9f 100644 --- a/pkgs/clan-cli/clan_cli/webui/sql_models.py +++ b/pkgs/clan-cli/clan_cli/webui/sql_models.py @@ -107,4 +107,5 @@ class Resolution(Base): requester_name = Column(String, index=True) requester_did = Column(String, index=True) resolved_did = Column(String, index=True) - timestamp = Column(DateTime, index=True) + other = Column(JSON) + timestamp = Column(DateTime(timezone=True), server_default=func.now()) diff --git a/pkgs/clan-cli/clan_cli/webui/tags.py b/pkgs/clan-cli/clan_cli/webui/tags.py index 78f7968..7f11e48 100644 --- a/pkgs/clan-cli/clan_cli/webui/tags.py +++ b/pkgs/clan-cli/clan_cli/webui/tags.py @@ -7,6 +7,7 @@ class Tags(Enum): consumers = "consumers" entities = "entities" repositories = "repositories" + resolutions = "resolution" def __str__(self) -> str: return self.value @@ -29,4 +30,8 @@ tags_metadata: List[Dict[str, Any]] = [ "name": str(Tags.repositories), "description": "Operations on a repository.", }, + { + "name": str(Tags.resolutions), + "description": "Operations on a resolution.", + }, ] diff --git a/pkgs/clan-cli/tests/test_db_api.py b/pkgs/clan-cli/tests/test_db_api.py index b26a65e..2595a86 100644 --- a/pkgs/clan-cli/tests/test_db_api.py +++ b/pkgs/clan-cli/tests/test_db_api.py @@ -38,8 +38,11 @@ def make_test_post_and_get( headers={"Content-Type": "application/json"}, ) assert response.status_code == 200 + if paramter == "repository": assert_extra_info(["time_created"], request_body, response.json()) + elif paramter == "resolution": + assert_extra_info(["timestamp", "id"], request_body, response.json()) elif paramter == "consumer": assert_extra_info(["id"], request_body, response.json()) elif paramter == "entity": @@ -55,6 +58,8 @@ def make_test_post_and_get( assert response.status_code == 200 if paramter == "repository": assert_extra_info(["time_created"], request_body, response.json()[0]) + elif paramter == "resolution": + assert_extra_info(["timestamp", "id"], request_body, response.json()[0]) elif paramter == "consumer": assert_extra_info(["id"], request_body, response.json()[0]) elif paramter == "entity": @@ -289,3 +294,44 @@ def test_entity2(api: TestClient) -> None: paramter = "entity" get_request = "entity_did=" + url.quote(default_entity_did2) make_test_post_and_get(api, request_body, paramter, get_request) + + +######################### +# # +# Resolution # +# # +######################### +def test_resolution(api: TestClient) -> None: + request_body = { + "requester_did": default_entity_did2, + "requester_name": "C2", + "resolved_did": default_entity_did, + "other": {"test": "test"}, + } + paramter = "resolution" + get_request = "requester_did=" + url.quote(default_entity_did2) + make_test_post_and_get(api, request_body, paramter, get_request) + + +def test_resolution2(api: TestClient) -> None: + request_body = { + "requester_did": default_entity_did3, + "requester_name": "C3", + "resolved_did": default_entity_did, + "other": {"test": "test"}, + } + paramter = "resolution" + get_request = "requester_did=" + url.quote(default_entity_did3) + make_test_post_and_get(api, request_body, paramter, get_request) + + +def test_resolution3(api: TestClient) -> None: + request_body = { + "requester_did": default_entity_did4, + "requester_name": "C4", + "resolved_did": default_entity_did, + "other": {"test": "test"}, + } + paramter = "resolution" + get_request = "requester_did=" + url.quote(default_entity_did4) + make_test_post_and_get(api, request_body, paramter, get_request) From 5262d83da08d5b0468be0bb85fa6e623bd1d5595 Mon Sep 17 00:00:00 2001 From: Onur Arslan Date: Sun, 10 Dec 2023 00:15:34 +0100 Subject: [PATCH 24/58] [Functionality] Request DID Resolution - fetch resolution data - adjustments --- pkgs/ui/src/app/access-point/page.tsx | 12 +---------- pkgs/ui/src/app/client-1/page.tsx | 2 -- pkgs/ui/src/app/client-2/page.tsx | 1 - .../app/distributed-ledger-gateway/page.tsx | 20 +++++++++++++++++-- pkgs/ui/src/app/home/page.tsx | 1 - pkgs/ui/src/mock/dlg/index.ts | 14 ++++++------- 6 files changed, 26 insertions(+), 24 deletions(-) diff --git a/pkgs/ui/src/app/access-point/page.tsx b/pkgs/ui/src/app/access-point/page.tsx index 230ee98..6f07177 100644 --- a/pkgs/ui/src/app/access-point/page.tsx +++ b/pkgs/ui/src/app/access-point/page.tsx @@ -28,17 +28,7 @@ export default function AccessPoint() { .then((resp) => resp.json().then((jsonData) => { console.log(jsonData); - - const transformedData = jsonData.map( - (item: { service_name: any; entity_did: any; network: any }) => ({ - entity_name: item.service_name, - entity_did: item.entity_did, - network: item.network, - ip_address: "", - }), - ); - - setRepositoryData(transformedData); + setRepositoryData(jsonData); }), ) .then() diff --git a/pkgs/ui/src/app/client-1/page.tsx b/pkgs/ui/src/app/client-1/page.tsx index a2f6b0e..763702a 100644 --- a/pkgs/ui/src/app/client-1/page.tsx +++ b/pkgs/ui/src/app/client-1/page.tsx @@ -16,7 +16,6 @@ export default function Client1() { useEffect(() => { fetch("http://localhost:2979/api/v1/get_consumers", { method: "GET", - // credentials: 'include', }) .then((resp) => resp.json().then((jsonData) => { @@ -29,7 +28,6 @@ export default function Client1() { fetch("http://localhost:2979/api/v1/get_producers", { method: "GET", - // credentials: 'include', }) .then((resp) => resp.json().then((jsonData) => { diff --git a/pkgs/ui/src/app/client-2/page.tsx b/pkgs/ui/src/app/client-2/page.tsx index 8b9a8d0..b3a7b75 100644 --- a/pkgs/ui/src/app/client-2/page.tsx +++ b/pkgs/ui/src/app/client-2/page.tsx @@ -16,7 +16,6 @@ export default function Client1() { useEffect(() => { fetch("http://localhost:2979/api/v1/get_consumers", { method: "GET", - // credentials: 'include', }) .then((resp) => resp.json().then((jsonData) => { diff --git a/pkgs/ui/src/app/distributed-ledger-gateway/page.tsx b/pkgs/ui/src/app/distributed-ledger-gateway/page.tsx index cc1c15e..41e83fa 100644 --- a/pkgs/ui/src/app/distributed-ledger-gateway/page.tsx +++ b/pkgs/ui/src/app/distributed-ledger-gateway/page.tsx @@ -1,14 +1,30 @@ "use client"; import { - DLGResolutionDummyData, DLGResolutionTableConfig, DLGSummaryDetails, } from "@/mock/dlg"; import CustomTable from "@/components/table"; import SummaryDetails from "@/components/summary_card"; +import {useEffect, useState} from "react"; export default function DLG() { + const [resolutionData, setResolutionData] = useState([]); + + useEffect(() => { + fetch("http://localhost:2979/api/v1/get_resolutions", { + method: "GET", + }) + .then((resp) => + resp.json().then((jsonData) => { + console.log(jsonData); + setResolutionData(jsonData); + }), + ) + .then() + .catch(); + }, []); + return (

DID Resolution View

diff --git a/pkgs/ui/src/app/home/page.tsx b/pkgs/ui/src/app/home/page.tsx index 16b0984..d6c3566 100644 --- a/pkgs/ui/src/app/home/page.tsx +++ b/pkgs/ui/src/app/home/page.tsx @@ -12,7 +12,6 @@ export default function Home() { useEffect(() => { fetch("http://localhost:2979/api/v1/get_entities", { method: "GET", - // credentials: 'include', }) .then((resp) => resp.json().then((jsonData) => { diff --git a/pkgs/ui/src/mock/dlg/index.ts b/pkgs/ui/src/mock/dlg/index.ts index 0163634..2e33f79 100644 --- a/pkgs/ui/src/mock/dlg/index.ts +++ b/pkgs/ui/src/mock/dlg/index.ts @@ -16,14 +16,14 @@ export const DLGSummaryDetails = [ export const DLGResolutionDummyData = [ { requester_name: "C1", - requester_DID: "did:sov:test:1234", - DID_resolved: "did:sov:test:1234", + requester_did: "did:sov:test:1234", + resolved_did: "did:sov:test:1234", timestamp: "2023.11.01 17:05:45", }, { requester_name: "C2", - requester_DID: "did:sov:test:5678", - DID_resolved: "did:sov:test:5678", + requester_did: "did:sov:test:5678", + resolved_did: "did:sov:test:5678", timestamp: "2023.12.01 15:05:50", }, ]; @@ -34,12 +34,12 @@ export const DLGResolutionTableConfig = [ label: "Requester name", }, { - key: "requester_DID", + key: "requester_did", label: "Requester DID", }, { - key: "DID_resolved", - label: "DID resolved", + key: "resolved_did", + label: "Resolved DID", }, { key: "timestamp", From 61261d7ac3c61c27558ec53ae07c5f88ef7510d4 Mon Sep 17 00:00:00 2001 From: Onur Arslan Date: Sun, 10 Dec 2023 00:30:30 +0100 Subject: [PATCH 25/58] [Functionality] Request DID Resolution - fixes --- pkgs/ui/src/app/access-point/page.tsx | 1 - pkgs/ui/src/app/distributed-ledger-gateway/page.tsx | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/pkgs/ui/src/app/access-point/page.tsx b/pkgs/ui/src/app/access-point/page.tsx index 6f07177..6a18acf 100644 --- a/pkgs/ui/src/app/access-point/page.tsx +++ b/pkgs/ui/src/app/access-point/page.tsx @@ -23,7 +23,6 @@ export default function AccessPoint() { useEffect(() => { fetch("http://localhost:2979/api/v1/get_repositories", { method: "GET", - // credentials: 'include', }) .then((resp) => resp.json().then((jsonData) => { diff --git a/pkgs/ui/src/app/distributed-ledger-gateway/page.tsx b/pkgs/ui/src/app/distributed-ledger-gateway/page.tsx index 41e83fa..731737a 100644 --- a/pkgs/ui/src/app/distributed-ledger-gateway/page.tsx +++ b/pkgs/ui/src/app/distributed-ledger-gateway/page.tsx @@ -6,7 +6,7 @@ import { } from "@/mock/dlg"; import CustomTable from "@/components/table"; import SummaryDetails from "@/components/summary_card"; -import {useEffect, useState} from "react"; +import { useEffect, useState } from "react"; export default function DLG() { const [resolutionData, setResolutionData] = useState([]); From 88578fe0077711fd59c1d728b212b5d9f5a23d37 Mon Sep 17 00:00:00 2001 From: "Arslan, Erdem" Date: Sun, 10 Dec 2023 00:45:52 +0100 Subject: [PATCH 26/58] fix formatting --- pkgs/clan-cli/bin/clan | 0 pkgs/clan-cli/bin/clan-config | 0 pkgs/clan-cli/bin/gen-openapi | 0 pkgs/node-packages/generate.sh | 0 pkgs/ui/nix/update-ui-assets.sh | 0 pkgs/ui/src/app/distributed-ledger-gateway/page.tsx | 5 +---- 6 files changed, 1 insertion(+), 4 deletions(-) mode change 100755 => 100644 pkgs/clan-cli/bin/clan mode change 100755 => 100644 pkgs/clan-cli/bin/clan-config mode change 100755 => 100644 pkgs/clan-cli/bin/gen-openapi mode change 100755 => 100644 pkgs/node-packages/generate.sh mode change 100755 => 100644 pkgs/ui/nix/update-ui-assets.sh diff --git a/pkgs/clan-cli/bin/clan b/pkgs/clan-cli/bin/clan old mode 100755 new mode 100644 diff --git a/pkgs/clan-cli/bin/clan-config b/pkgs/clan-cli/bin/clan-config old mode 100755 new mode 100644 diff --git a/pkgs/clan-cli/bin/gen-openapi b/pkgs/clan-cli/bin/gen-openapi old mode 100755 new mode 100644 diff --git a/pkgs/node-packages/generate.sh b/pkgs/node-packages/generate.sh old mode 100755 new mode 100644 diff --git a/pkgs/ui/nix/update-ui-assets.sh b/pkgs/ui/nix/update-ui-assets.sh old mode 100755 new mode 100644 diff --git a/pkgs/ui/src/app/distributed-ledger-gateway/page.tsx b/pkgs/ui/src/app/distributed-ledger-gateway/page.tsx index 731737a..73312b2 100644 --- a/pkgs/ui/src/app/distributed-ledger-gateway/page.tsx +++ b/pkgs/ui/src/app/distributed-ledger-gateway/page.tsx @@ -1,9 +1,6 @@ "use client"; -import { - DLGResolutionTableConfig, - DLGSummaryDetails, -} from "@/mock/dlg"; +import { DLGResolutionTableConfig, DLGSummaryDetails } from "@/mock/dlg"; import CustomTable from "@/components/table"; import SummaryDetails from "@/components/summary_card"; import { useEffect, useState } from "react"; From 5c0696b1bf959e5ebd1a800f9e4fa228c1989f6d Mon Sep 17 00:00:00 2001 From: Luis-Hebendanz Date: Sun, 10 Dec 2023 18:16:59 +0100 Subject: [PATCH 27/58] Fixing asset pipeline --- .gitea/workflows/ui_assets.yaml | 2 +- pkgs/ui/nix/update-ui-assets.sh | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.gitea/workflows/ui_assets.yaml b/.gitea/workflows/ui_assets.yaml index 3c7f527..d4e1088 100644 --- a/.gitea/workflows/ui_assets.yaml +++ b/.gitea/workflows/ui_assets.yaml @@ -25,7 +25,7 @@ jobs: || echo "$MODIFIED_FILES" | grep -q ".gitea/workflows/ui_assets.yaml"; then echo "UI files have changed" - ./pkgs/ui/nix/update-ui-assets.sh + bash ./pkgs/ui/nix/update-ui-assets.sh # git push if we have a diff diff --git a/pkgs/ui/nix/update-ui-assets.sh b/pkgs/ui/nix/update-ui-assets.sh index 0bfc6b1..d3ab7d9 100644 --- a/pkgs/ui/nix/update-ui-assets.sh +++ b/pkgs/ui/nix/update-ui-assets.sh @@ -1,3 +1,5 @@ +#!/usr/bin/env bash + # shellcheck shell=bash set -xeuo pipefail From 85d62aac8997068c8545cbcf10084b8731a1aa86 Mon Sep 17 00:00:00 2001 From: ui-asset-bot Date: Sun, 10 Dec 2023 17:30:51 +0000 Subject: [PATCH 28/58] update ui-assets.nix --- pkgs/ui/nix/ui-assets.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/ui/nix/ui-assets.nix b/pkgs/ui/nix/ui-assets.nix index 8d7ce17..848c912 100644 --- a/pkgs/ui/nix/ui-assets.nix +++ b/pkgs/ui/nix/ui-assets.nix @@ -1,5 +1,5 @@ { fetchzip }: fetchzip { - url = "https://gitea.gchq.icu/api/packages/IoSL/generic/IoSL-service-aware-frontend/07dai984ffhflf6i6bs5dg1dybgq6s4vrkwi1fr05sxppg7bz1wq/assets.tar.gz"; - sha256 = "07dai984ffhflf6i6bs5dg1dybgq6s4vrkwi1fr05sxppg7bz1wq"; + url = "https://gitea.gchq.icu/api/packages/IoSL/generic/IoSL-service-aware-frontend/042x4cdb35zzwjx3fc7v0qxil1fbam5xrgg42v816yih9kl5dqrz/assets.tar.gz"; + sha256 = "042x4cdb35zzwjx3fc7v0qxil1fbam5xrgg42v816yih9kl5dqrz"; } From 8ee14f1a7bf903a28b93fd07141f54c3d1bd771d Mon Sep 17 00:00:00 2001 From: sara-pervana Date: Tue, 12 Dec 2023 23:00:37 +0100 Subject: [PATCH 29/58] Before Milestone Meeting Final Changes (#40) some final fixes before the demo Co-authored-by: Luis-Hebendanz Reviewed-on: https://gitea.gchq.icu/IoSL/service-aware-frontend/pulls/40 Co-authored-by: sara-pervana Co-committed-by: sara-pervana --- pkgs/clan-cli/tests/test_db_api.py | 4 +- pkgs/ui/src/app/access-point/page.tsx | 69 ++++--- pkgs/ui/src/app/client-1/page.tsx | 176 ++++++++++++++---- pkgs/ui/src/app/client-2/page.tsx | 176 ++++++++++++++---- .../app/distributed-ledger-gateway/page.tsx | 35 ++-- pkgs/ui/src/app/home/page.tsx | 44 +++-- .../ui/src/components/hooks/useAppContext.tsx | 29 ++- pkgs/ui/src/components/hooks/useFetch.tsx | 33 ++++ .../src/components/hooks/useGetEntityById.tsx | 19 ++ pkgs/ui/src/components/summary_card/index.tsx | 10 +- pkgs/ui/src/components/table/index.tsx | 7 +- pkgs/ui/src/config/access_point/index.tsx | 80 ++++++++ pkgs/ui/src/config/client_1/index.tsx | 77 ++++++++ pkgs/ui/src/config/client_2/index.tsx | 77 ++++++++ pkgs/ui/src/{mock => config}/dlg/index.ts | 3 + pkgs/ui/src/config/home/index.ts | 35 ++++ pkgs/ui/src/constants/index.ts | 9 + pkgs/ui/src/mock/access_point/index.ts | 113 ----------- pkgs/ui/src/mock/client_1/index.ts | 140 -------------- pkgs/ui/src/mock/client_2/index.ts | 140 -------------- pkgs/ui/src/mock/home/index.ts | 47 ----- pkgs/ui/src/types/index.ts | 5 +- pkgs/ui/src/utils/helpers.ts | 12 ++ 23 files changed, 759 insertions(+), 581 deletions(-) create mode 100644 pkgs/ui/src/components/hooks/useFetch.tsx create mode 100644 pkgs/ui/src/components/hooks/useGetEntityById.tsx create mode 100644 pkgs/ui/src/config/access_point/index.tsx create mode 100644 pkgs/ui/src/config/client_1/index.tsx create mode 100644 pkgs/ui/src/config/client_2/index.tsx rename pkgs/ui/src/{mock => config}/dlg/index.ts (88%) create mode 100644 pkgs/ui/src/config/home/index.ts create mode 100644 pkgs/ui/src/constants/index.ts delete mode 100644 pkgs/ui/src/mock/access_point/index.ts delete mode 100644 pkgs/ui/src/mock/client_1/index.ts delete mode 100644 pkgs/ui/src/mock/client_2/index.ts delete mode 100644 pkgs/ui/src/mock/home/index.ts create mode 100644 pkgs/ui/src/utils/helpers.ts diff --git a/pkgs/clan-cli/tests/test_db_api.py b/pkgs/clan-cli/tests/test_db_api.py index 2595a86..cf393bf 100644 --- a/pkgs/clan-cli/tests/test_db_api.py +++ b/pkgs/clan-cli/tests/test_db_api.py @@ -266,7 +266,7 @@ def test_entity(api: TestClient) -> None: request_body = { "did": default_entity_did, "name": "C1", - "ip": "127.0.0.1", + "ip": "127.0.0.1:5555", "attached": False, "visible": True, "other": { @@ -283,7 +283,7 @@ def test_entity2(api: TestClient) -> None: request_body = { "did": default_entity_did2, "name": "C2", - "ip": "127.0.0.2", + "ip": "127.0.0.1:5555", "attached": False, "visible": True, "other": { diff --git a/pkgs/ui/src/app/access-point/page.tsx b/pkgs/ui/src/app/access-point/page.tsx index 6a18acf..91bd903 100644 --- a/pkgs/ui/src/app/access-point/page.tsx +++ b/pkgs/ui/src/app/access-point/page.tsx @@ -1,56 +1,77 @@ "use client"; +import { mutate } from "swr"; +import { useGetAttachedEntities } from "@/api/entities/entities"; +import { useGetRepositories } from "@/api/repositories/repositories"; import SummaryDetails from "@/components/summary_card"; import CustomTable from "@/components/table"; import { APSummaryDetails, - APAttachmentsDummyData, APAttachmentsTableConfig, APServiceRepositoryTableConfig, -} from "@/mock/access_point"; -import { useEffect, useState } from "react"; - -interface RepositoryData { - entity_name: string; - entity_did: string; - network: string; - ip_address: string; -} +} from "@/config/access_point"; +import { useEffect } from "react"; export default function AccessPoint() { - const [repositoryData, setRepositoryData] = useState([]); + const { + data: APAttachementData, + isLoading: loadingAttachements, + swrKey: attachedEntitiesKeyFunc, + } = useGetAttachedEntities(); + const { + data: APRepositories, + isLoading: laodingRepositories, + swrKey: repositoriesKeyFunc, + } = useGetRepositories(); + + const onRefresh = () => { + const attachedEntitiesKey = + typeof attachedEntitiesKeyFunc === "function" + ? attachedEntitiesKeyFunc() + : attachedEntitiesKeyFunc; + const repositoriesKey = + typeof repositoriesKeyFunc === "function" + ? repositoriesKeyFunc() + : repositoriesKeyFunc; + + if (attachedEntitiesKey) { + mutate(attachedEntitiesKey); + } + if (repositoriesKey) { + mutate(repositoriesKey); + } + }; useEffect(() => { - fetch("http://localhost:2979/api/v1/get_repositories", { - method: "GET", - }) - .then((resp) => - resp.json().then((jsonData) => { - console.log(jsonData); - setRepositoryData(jsonData); - }), - ) - .then() - .catch(); + const interval = setInterval(() => { + onRefresh(); + }, 1000); + + return () => clearInterval(interval); + // eslint-disable-next-line react-hooks/exhaustive-deps }, []); return (

Attachment View

Service Repository View

diff --git a/pkgs/ui/src/app/client-1/page.tsx b/pkgs/ui/src/app/client-1/page.tsx index 763702a..c0343de 100644 --- a/pkgs/ui/src/app/client-1/page.tsx +++ b/pkgs/ui/src/app/client-1/page.tsx @@ -1,68 +1,168 @@ "use client"; - -import SummaryDetails from "@/components/summary_card"; +import { useEffect, useRef, useState } from "react"; import { - Client1SummaryDetails, Client1ConsumerTableConfig, Client1ProducerTableConfig, -} from "@/mock/client_1"; +} from "@/config/client_1"; import CustomTable from "@/components/table"; -import { useEffect, useState } from "react"; +import useGetEntityByName from "@/components/hooks/useGetEntityById"; +import { + Alert, + Button, + Card, + CardContent, + CardHeader, + Skeleton, + Snackbar, + Typography, +} from "@mui/material"; +import CopyToClipboard from "@/components/copy_to_clipboard"; +import { mutate } from "swr"; +import { useGetEntity } from "@/api/entities/entities"; +import { BASE_URL } from "@/constants"; +import axios from "axios"; export default function Client1() { - const [consumerData, setConsumerData] = useState([]); - const [producerData, setProducerData] = useState([]); + const { entity } = useGetEntityByName("C1"); + const { + data: client1, + isLoading, + swrKey: entityKeyFunc, + } = useGetEntity({ entity_did: entity?.did }); + const cardContentRef = useRef(null); + const [isAttached, setIsAttached] = useState(entity?.attached || false); + const [snackbarOpen, setSnackbarOpen] = useState(false); + const [snackbarMessage, setSnackbarMessage] = useState(""); + + const closeSnackBar = () => { + setSnackbarMessage(""); + setSnackbarOpen(false); + }; + + const onAttachEntity = async () => { + try { + const response = await axios.post(`${BASE_URL}/attach`, { + entity_did: entity?.did, + }); + setSnackbarMessage(response.data.message); + setSnackbarOpen(true); + } catch (error) { + console.error(error); + } finally { + setIsAttached(true); + } + }; + + const onDetachEntity = async () => { + try { + const response = await axios.post(`${BASE_URL}/detach`, { + entity_did: entity?.did, + }); + console.log(response); + setSnackbarMessage("Entity detached successfully."); + setSnackbarOpen(true); + } catch (error) { + console.error(error); + } finally { + setIsAttached(false); + } + }; + + const onRefresh = () => { + const entityKey = + typeof entityKeyFunc === "function" ? entityKeyFunc() : entityKeyFunc; + if (entityKey) mutate(entityKey); + }; useEffect(() => { - fetch("http://localhost:2979/api/v1/get_consumers", { - method: "GET", - }) - .then((resp) => - resp.json().then((jsonData) => { - console.log(jsonData); - setConsumerData(jsonData); - }), - ) - .then() - .catch(); + const interval = setInterval(() => { + onRefresh(); + }, 1000); - fetch("http://localhost:2979/api/v1/get_producers", { - method: "GET", - }) - .then((resp) => - resp.json().then((jsonData) => { - console.log(jsonData); - setProducerData(jsonData); - }), - ) - .then() - .catch(); + return () => clearInterval(interval); + // eslint-disable-next-line react-hooks/exhaustive-deps }, []); + if (isLoading) return ; + return (
- + > +

Client 1

+
+ {isAttached === false ? ( + + ) : ( + + )} + + +
+
+ + + } + /> + + + DID: {client1?.data?.did} + + + IP: {client1?.data?.ip} + + + Network: {client1?.data?.other?.network} + + +

Consumer View

Producer View

+ + + {snackbarMessage} + +
); } diff --git a/pkgs/ui/src/app/client-2/page.tsx b/pkgs/ui/src/app/client-2/page.tsx index b3a7b75..31526a5 100644 --- a/pkgs/ui/src/app/client-2/page.tsx +++ b/pkgs/ui/src/app/client-2/page.tsx @@ -1,69 +1,165 @@ "use client"; - -import SummaryDetails from "@/components/summary_card"; +import { useEffect, useRef, useState } from "react"; import { Client2ConsumerTableConfig, Client2ProducerTableConfig, - Client2SummaryDetails, -} from "@/mock/client_2"; +} from "@/config/client_2"; import CustomTable from "@/components/table"; -import { useEffect, useState } from "react"; +import useGetEntityByName from "@/components/hooks/useGetEntityById"; +import { + Button, + Card, + CardContent, + CardHeader, + Skeleton, + Typography, + Snackbar, + Alert, +} from "@mui/material"; +import CopyToClipboard from "@/components/copy_to_clipboard"; +import { useGetEntity } from "@/api/entities/entities"; +import { mutate } from "swr"; +import axios from "axios"; +import { BASE_URL } from "@/constants"; -export default function Client1() { - const [consumerData, setConsumerData] = useState([]); - const [producerData, setProducerData] = useState([]); +export default function Client2() { + const { entity } = useGetEntityByName("C2"); + const { + data: client2, + isLoading, + swrKey: entityKeyFunc, + } = useGetEntity({ entity_did: entity?.did }); + const cardContentRef = useRef(null); + const [isAttached, setIsAttached] = useState(entity?.attached); + const [snackbarOpen, setSnackbarOpen] = useState(false); + const [snackbarMessage, setSnackbarMessage] = useState(""); + + const closeSnackBar = () => { + setSnackbarMessage(""); + setSnackbarOpen(false); + }; + + const onAttachEntity = async () => { + try { + const response = await axios.post(`${BASE_URL}/attach`, { + entity_did: entity?.did, + }); + alert(response.data.message); + } catch (error) { + console.error(error); + } finally { + setIsAttached(true); + } + }; + + const onDetachEntity = async () => { + try { + const response = await axios.post(`${BASE_URL}/detach`, { + entity_did: entity?.did, + }); + console.log("detach", response); + alert("Entity Detached Successfully."); + } catch (error) { + console.error(error); + } finally { + setIsAttached(false); + } + }; + + const onRefresh = () => { + const entityKey = + typeof entityKeyFunc === "function" ? entityKeyFunc() : entityKeyFunc; + if (entityKey) mutate(entityKey); + }; useEffect(() => { - fetch("http://localhost:2979/api/v1/get_consumers", { - method: "GET", - }) - .then((resp) => - resp.json().then((jsonData) => { - console.log(jsonData); - setConsumerData(jsonData); - }), - ) - .then() - .catch(); + const interval = setInterval(() => { + onRefresh(); + }, 1000); - fetch("http://localhost:2979/api/v1/get_producers", { - method: "GET", - // credentials: 'include', - }) - .then((resp) => - resp.json().then((jsonData) => { - console.log(jsonData); - setProducerData(jsonData); - }), - ) - .then() - .catch(); + return () => clearInterval(interval); + // eslint-disable-next-line react-hooks/exhaustive-deps }, []); + if (isLoading) return ; + return (
- + > +

Client 2

+
+ {isAttached === false ? ( + + ) : ( + + )} + +
+
+ + + } + /> + + + DID: {client2?.data?.did} + + + IP: {client2?.data?.ip} + + + Network: {client2?.data?.other?.network} + + +

Consumer View

Producer View

+ + + {snackbarMessage} + +
); } diff --git a/pkgs/ui/src/app/distributed-ledger-gateway/page.tsx b/pkgs/ui/src/app/distributed-ledger-gateway/page.tsx index 73312b2..9698c9f 100644 --- a/pkgs/ui/src/app/distributed-ledger-gateway/page.tsx +++ b/pkgs/ui/src/app/distributed-ledger-gateway/page.tsx @@ -1,31 +1,37 @@ "use client"; -import { DLGResolutionTableConfig, DLGSummaryDetails } from "@/mock/dlg"; +import { DLGResolutionTableConfig, DLGSummaryDetails } from "@/config/dlg"; import CustomTable from "@/components/table"; import SummaryDetails from "@/components/summary_card"; -import { useEffect, useState } from "react"; +import useFetch from "@/components/hooks/useFetch"; +import { useEffect } from "react"; export default function DLG() { - const [resolutionData, setResolutionData] = useState([]); + const { + data: resolutionData, + loading: loadingResolutions, + fetch, + } = useFetch("/get_resolutions"); + + const onRefresh = () => { + fetch(); + }; useEffect(() => { - fetch("http://localhost:2979/api/v1/get_resolutions", { - method: "GET", - }) - .then((resp) => - resp.json().then((jsonData) => { - console.log(jsonData); - setResolutionData(jsonData); - }), - ) - .then() - .catch(); + const interval = setInterval(() => { + onRefresh(); + }, 5000); + + return () => clearInterval(interval); + // eslint-disable-next-line react-hooks/exhaustive-deps }, []); return (

DID Resolution View

diff --git a/pkgs/ui/src/app/home/page.tsx b/pkgs/ui/src/app/home/page.tsx index d6c3566..d405ccf 100644 --- a/pkgs/ui/src/app/home/page.tsx +++ b/pkgs/ui/src/app/home/page.tsx @@ -1,39 +1,51 @@ "use client"; +import { useAppState } from "@/components/hooks/useAppContext"; import { NoDataOverlay } from "@/components/noDataOverlay"; import SummaryDetails from "@/components/summary_card"; import CustomTable from "@/components/table"; -import { HomeTableConfig } from "@/mock/home"; -import { useEffect, useState } from "react"; +import { HomeTableConfig } from "@/config/home"; +import { useEffect } from "react"; +import { mutate } from "swr"; export default function Home() { - const [homeData, setHomeData] = useState([]); + const { data } = useAppState(); + + const entitiesKeyFunc = data.entitiesKeyFunc; + + const onRefresh = () => { + const entityKey = + typeof entitiesKeyFunc === "function" + ? entitiesKeyFunc() + : entitiesKeyFunc; + if (entitiesKeyFunc) mutate(entityKey); + }; useEffect(() => { - fetch("http://localhost:2979/api/v1/get_entities", { - method: "GET", - }) - .then((resp) => - resp.json().then((jsonData) => { - console.log(jsonData); - setHomeData(jsonData); - }), - ) - .then() - .catch(); + const interval = setInterval(() => { + onRefresh(); + }, 500); + + return () => clearInterval(interval); + // eslint-disable-next-line react-hooks/exhaustive-deps }, []); return (

Home View Table

- +
diff --git a/pkgs/ui/src/components/hooks/useAppContext.tsx b/pkgs/ui/src/components/hooks/useAppContext.tsx index a749aaf..d8e9c31 100644 --- a/pkgs/ui/src/components/hooks/useAppContext.tsx +++ b/pkgs/ui/src/components/hooks/useAppContext.tsx @@ -1,3 +1,5 @@ +import { useGetEntities } from "@/api/entities/entities"; +import { Entity } from "@/api/model"; import { AxiosError } from "axios"; import React, { createContext, @@ -5,6 +7,7 @@ import React, { ReactNode, SetStateAction, useState, + useEffect, } from "react"; type AppContextType = { @@ -18,7 +21,11 @@ type AppContextType = { export const AppContext = createContext({} as AppContextType); -type AppState = NonNullable; +type AppState = { + allEntities: Entity[] | undefined; + loadingEntities: boolean; + entitiesKeyFunc: any; +}; interface AppContextProviderProps { children: ReactNode; @@ -26,10 +33,28 @@ interface AppContextProviderProps { export const WithAppState = (props: AppContextProviderProps) => { const { children } = props; + const { data: entityData, swrKey: entitiesKeyFunc } = useGetEntities(); + const isLoading = false; const error = undefined; - const [data, setAppState] = useState({}); + const [data, setAppState] = useState({ + allEntities: [], + loadingEntities: true, + entitiesKeyFunc, + }); + + useEffect(() => { + if (entityData) { + setAppState((prevState) => ({ + ...prevState, + allEntities: entityData.data, + entitiesKeyFunc, + loadingEntities: false, + })); + } + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [entityData]); return ( { + const [data, setData] = useState([]); + const [loading, setLoading] = useState(true); + const [error, setError] = useState(null); + + const fetch = () => { + setLoading(true); + axios + .get(BASE_URL + url) + .then((response) => { + setData(response.data); + }) + .catch((error) => { + setError(error); + }) + .finally(() => { + setLoading(false); + }); + }; + + useEffect(() => { + fetch(); + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [url]); + + return { data, loading, error, fetch }; +}; + +export default useFetch; diff --git a/pkgs/ui/src/components/hooks/useGetEntityById.tsx b/pkgs/ui/src/components/hooks/useGetEntityById.tsx new file mode 100644 index 0000000..7736d44 --- /dev/null +++ b/pkgs/ui/src/components/hooks/useGetEntityById.tsx @@ -0,0 +1,19 @@ +import { useContext } from "react"; +import { AppContext } from "./useAppContext"; + +const useGetEntityByName = (nameOrDid: string) => { + const { data } = useContext(AppContext); + const allEntities = data.allEntities; + + if (!allEntities) { + return { entity: undefined, isLoading: true }; + } + + const entity = allEntities.find( + (entity) => entity.name === nameOrDid || entity.did === nameOrDid, + ); + + return { entity, isLoading: false }; +}; + +export default useGetEntityByName; diff --git a/pkgs/ui/src/components/summary_card/index.tsx b/pkgs/ui/src/components/summary_card/index.tsx index a9c979a..0a6c016 100644 --- a/pkgs/ui/src/components/summary_card/index.tsx +++ b/pkgs/ui/src/components/summary_card/index.tsx @@ -14,6 +14,8 @@ const SummaryDetails = ({ entity, hasRefreshButton, hasAttachDetach, + fake, + onRefresh, }: ISummaryDetails) => { const cardContentRef = useRef(null); const hasDetails = entity.details && entity.details.length > 0; @@ -34,13 +36,17 @@ const SummaryDetails = ({ Attach / Detach )} - {hasRefreshButton && } + {hasRefreshButton && ( + + )}
{hasDetails && ( } /> diff --git a/pkgs/ui/src/components/table/index.tsx b/pkgs/ui/src/components/table/index.tsx index 36714df..25af334 100644 --- a/pkgs/ui/src/components/table/index.tsx +++ b/pkgs/ui/src/components/table/index.tsx @@ -9,9 +9,12 @@ import Paper from "@mui/material/Paper"; import { NoDataOverlay } from "@/components/noDataOverlay"; import { StyledTableCell, StyledTableRow } from "./style"; import { ICustomTable, CustomTableConfiguration } from "@/types"; -import { Checkbox } from "@mui/material"; +import { Checkbox, Skeleton } from "@mui/material"; + +const CustomTable = ({ configuration, data, loading }: ICustomTable) => { + if (loading) + return ; -const CustomTable = ({ configuration, data }: ICustomTable) => { // display empty icon in case there is no data if (!data || data.length === 0) return ; diff --git a/pkgs/ui/src/config/access_point/index.tsx b/pkgs/ui/src/config/access_point/index.tsx new file mode 100644 index 0000000..2d8575a --- /dev/null +++ b/pkgs/ui/src/config/access_point/index.tsx @@ -0,0 +1,80 @@ +// AP - Summary + +export const APSummaryDetails = [ + { + label: "DID", + value: "did:sov:test:1274", + }, + { + label: "IP", + value: "127.0.0.2", + }, + { + label: "Network", + value: "Carlo's Home Network", + }, +]; + +export const APAttachmentsTableConfig = [ + { + key: "name", + label: "Entity name", + }, + { + key: "did", + label: "Entity DID", + }, + { + key: "other", + label: "Network", + render: (value: any) => { + let renderedValue = ""; + if (typeof value === "object") renderedValue = value?.network; + return renderedValue; + }, + }, + { + key: "ip", + label: "IP address", + }, +]; + +export const APServiceRepositoryTableConfig = [ + { + key: "service_name", + label: "Service name", + }, + { + key: "service_type", + label: "Service type", + }, + { + key: "endpoint_url", + label: "End point", + }, + { + key: "entity_did", + label: "Entity DID", + }, + { + key: "status", + label: "Status", + }, + { + key: "other", + label: "Type", + render: (value: any) => { + let renderedValue: any = ""; + if (typeof value === "object") { + const label = Object.keys(value)[0]; + const info = value[label]; + renderedValue = ( + + {label} {info} + + ); + } + return renderedValue; + }, + }, +]; diff --git a/pkgs/ui/src/config/client_1/index.tsx b/pkgs/ui/src/config/client_1/index.tsx new file mode 100644 index 0000000..ca3a025 --- /dev/null +++ b/pkgs/ui/src/config/client_1/index.tsx @@ -0,0 +1,77 @@ +import { Button } from "@mui/material"; + +export const Client1ConsumerTableConfig = [ + { + key: "service_name", + label: "Service name", + }, + { + key: "service_type", + label: "Service Type", + }, + { + key: "endpoint_url", + label: "End Point", + render: () => { + return ( + + ); + }, + }, + // { + // key: "entity", + // label: "Entity", + // }, + { + key: "entity_did", + label: "Entity DID", + }, + // { + // key: "network", + // label: "Network", + // }, +]; + +export const Client1ProducerTableConfig = [ + { + key: "service_name", + label: "Service name", + }, + { + key: "service_type", + label: "Service Type", + }, + { + key: "endpoint_url", + label: "End Point", + }, + { + key: "entity_did", + label: "Entity DID", + }, + { + key: "status", + label: "Status", + }, + { + key: "other", + label: "Action", + render: (value: any) => { + let renderedValue: any = ""; + if (typeof value === "object") + renderedValue = ( + <> + {value.action.map((actionType: string) => ( + <> + {actionType} +
+ + ))} + + ); + return renderedValue; + }, + }, +]; diff --git a/pkgs/ui/src/config/client_2/index.tsx b/pkgs/ui/src/config/client_2/index.tsx new file mode 100644 index 0000000..982b2ad --- /dev/null +++ b/pkgs/ui/src/config/client_2/index.tsx @@ -0,0 +1,77 @@ +import { Button } from "@mui/material"; + +export const Client2ConsumerTableConfig = [ + { + key: "service_name", + label: "Service name", + }, + { + key: "service_type", + label: "Service Type", + }, + { + key: "endpoint_url", + label: "End Point", + render: () => { + return ( + + ); + }, + }, + // { + // key: "entity", + // label: "Entity", + // }, + { + key: "entity_did", + label: "Entity DID", + }, + // { + // key: "network", + // label: "Network", + // }, +]; + +export const Client2ProducerTableConfig = [ + { + key: "service_name", + label: "Service name", + }, + { + key: "service_type", + label: "Service Type", + }, + { + key: "endpoint_url", + label: "End Point", + }, + { + key: "entity_did", + label: "Entity DID", + }, + { + key: "status", + label: "Status", + }, + { + key: "other", + label: "Action", + render: (value: any) => { + let renderedValue: any = ""; + if (typeof value === "object") + renderedValue = ( + <> + {value.action.map((actionType: string) => ( + <> + {actionType} +
+ + ))} + + ); + return renderedValue; + }, + }, +]; diff --git a/pkgs/ui/src/mock/dlg/index.ts b/pkgs/ui/src/config/dlg/index.ts similarity index 88% rename from pkgs/ui/src/mock/dlg/index.ts rename to pkgs/ui/src/config/dlg/index.ts index 2e33f79..0cc3109 100644 --- a/pkgs/ui/src/mock/dlg/index.ts +++ b/pkgs/ui/src/config/dlg/index.ts @@ -1,5 +1,7 @@ // DLG Summary Details +import { formatDateTime } from "@/utils/helpers"; + export const DLGSummaryDetails = [ { label: "DID", @@ -44,5 +46,6 @@ export const DLGResolutionTableConfig = [ { key: "timestamp", label: "Timestamp", + render: (value: string) => formatDateTime(value), }, ]; diff --git a/pkgs/ui/src/config/home/index.ts b/pkgs/ui/src/config/home/index.ts new file mode 100644 index 0000000..7f72fe5 --- /dev/null +++ b/pkgs/ui/src/config/home/index.ts @@ -0,0 +1,35 @@ +export const HomeTableConfig = [ + { + key: "name", + label: "Entity name", + }, + { + key: "did", + label: "Entity DID", + }, + { + key: "other", + label: "Network", + render: (value: any) => { + const renderedValue = typeof value === "object" ? value?.network : "-"; + return renderedValue; + }, + }, + { + key: "ip", + label: "IP address", + }, + { + key: "other", + label: "Roles", + render: (value: any) => { + const renderedValue = + typeof value === "object" ? value?.roles?.join(", ") : "-"; + return renderedValue; + }, + }, + { + key: "attached", + label: "Attached", + }, +]; diff --git a/pkgs/ui/src/constants/index.ts b/pkgs/ui/src/constants/index.ts new file mode 100644 index 0000000..449ac7f --- /dev/null +++ b/pkgs/ui/src/constants/index.ts @@ -0,0 +1,9 @@ +const BASE_URL = "http://localhost:2979/api/v1"; + +// Home View +const HOME_VIEW_TABLE = "/get_entities"; + +// Access Point +const SERVICE_REPOSITORY_URL = "/get_repositories"; + +export { BASE_URL, HOME_VIEW_TABLE, SERVICE_REPOSITORY_URL }; diff --git a/pkgs/ui/src/mock/access_point/index.ts b/pkgs/ui/src/mock/access_point/index.ts deleted file mode 100644 index 8af005c..0000000 --- a/pkgs/ui/src/mock/access_point/index.ts +++ /dev/null @@ -1,113 +0,0 @@ -// AP - Summary - -export const APSummaryDetails = [ - { - label: "DID", - value: "did:sov:test:1274", - }, - { - label: "IP", - value: "127.0.0.2", - }, - { - label: "Network", - value: "Carlo's Home Network", - }, -]; - -// AP - Attachements - -export const APAttachmentsDummyData = [ - { - entity_name: "C1", - entity_did: "did:sov:test:1234", - network: "Carlo's Home Network", - ip_address: "127.0.0.1", - }, - { - entity_name: "C2", - entity_did: "did:sov:test:4567", - network: "Steve's Home Network", - ip_address: "127.0.0.1", - }, - { - entity_name: "C1-TEST", - entity_did: "did:sov:test:0001", - network: "Test Network A", - ip_address: "127.0.0.1", - }, - { - entity_name: "C2-TEST", - entity_did: "did:sov:test:0002", - network: "Test Network B", - ip_address: "127.0.0.1", - }, -]; -export const APAttachmentsTableConfig = [ - { - key: "entity_name", - label: "Entity name", - }, - { - key: "entity_did", - label: "Entity DID", - }, - { - key: "network", - label: "Network", - }, - { - key: "ip_address", - label: "IP address", - }, -]; - -// AP - Service Repository -export const APServiceRepositoryDummyData = [ - { - service_name: "Carlo's Printing", - service_type: "3D Printing", - endpoint_url: "URL", - entity: "C1", - entity_did: "did:sov:test:1234", - network: "Carlo's Home Network", - }, - { - service_name: "Jeff's Printing", - service_type: "3D Printing", - endpoint_url: "URL", - entity: "C2", - entity_did: "did:sov:test:5678", - network: "Jeff's Home Network", - }, -]; -export const APServiceRepositoryTableConfig = [ - { - key: "service_name", - label: "Service name", - }, - { - key: "service_type", - label: "Service type", - }, - { - key: "endpoint_url", - label: "End point", - }, - // { - // key: "entity", - // label: "Entity", - // }, - { - key: "entity_did", - label: "Entity DID", - }, - // { - // key: "network", - // label: "Network", - // }, - { - key: "status", - label: "Status", - }, -]; diff --git a/pkgs/ui/src/mock/client_1/index.ts b/pkgs/ui/src/mock/client_1/index.ts deleted file mode 100644 index 9139156..0000000 --- a/pkgs/ui/src/mock/client_1/index.ts +++ /dev/null @@ -1,140 +0,0 @@ -// Client1 - Summary - -export const Client1SummaryDetails = [ - { - label: "DID", - value: "did:sov:test:1234", - }, - { - label: "IP", - value: "127.0.0.1", - }, - { - label: "Network", - value: "Carlo's Home Network", - }, -]; - -export const Client1ConsumerData = [ - { - service_name: "Carlo's Printing", - service_type: "3D Printing", - endpoint_url: "Consume", - entity: "C2", - entity_did: "did:sov:test:1223", - network: "Carlo's Home Network", - }, - { - service_name: "Steve's Printing", - service_type: "3D Printing", - endpoint_url: "Consume", - entity: "C2", - entity_did: "did:sov:test:1234", - network: "Steve's Home Network", - }, - { - service_name: "Test A", - service_type: "3D Printing", - endpoint_url: "Consume", - entity: "C2", - entity_did: "did:sov:test:4567", - network: "Test Network A", - }, - { - service_name: "Test B", - service_type: "3D Printing", - endpoint_url: "Consume", - entity: "C2", - entity_did: "did:sov:test:0062", - network: "Test Network B", - }, -]; - -export const Client1ConsumerTableConfig = [ - { - key: "service_name", - label: "Service name", - }, - { - key: "service_type", - label: "Service Type", - }, - { - key: "endpoint_url", - label: "End Point", - }, - { - key: "entity", - label: "Entity", - }, - { - key: "entity_did", - label: "Entity DID", - }, - { - key: "network", - label: "Network", - }, -]; - -export const Client1ProducerData = [ - { - service_name: "Carlo's Printing", - service_type: "3D Printing", - endpoint_url: "URL", - usage: "C1(3), C3(4)", - status: "DRAFT, REGISTERED", - action: "Register, Deregister, Delete", - }, - { - service_name: "Steve's Printing", - service_type: "3D Printing", - endpoint_url: "URL", - usage: "C1(3), C3(4)", - status: "REGISTERED", - action: "Create", - }, - { - service_name: "Test Printing A", - service_type: "3D Printing", - endpoint_url: "URL", - usage: "C1(3), C3(4)", - status: "DRAFT", - action: "Register, Deregister", - }, - { - service_name: "Test Printing B", - service_type: "3D Printing", - endpoint_url: "URL", - usage: "C1(3), C3(4)", - status: "DRAFT, REGISTERED", - action: "Delete, Create", - }, -]; - -export const Client1ProducerTableConfig = [ - { - key: "service_name", - label: "Service name", - }, - { - key: "service_type", - label: "Service Type", - }, - { - key: "endpoint_url", - label: "End Point", - }, - // { - // key: "usage", - // label: "Usage", - // }, - { - key: "status", - label: "Status", - }, - // { - // key: "action", - // label: "Action", - // }, -]; diff --git a/pkgs/ui/src/mock/client_2/index.ts b/pkgs/ui/src/mock/client_2/index.ts deleted file mode 100644 index 1f40fcd..0000000 --- a/pkgs/ui/src/mock/client_2/index.ts +++ /dev/null @@ -1,140 +0,0 @@ -// Client2 - Summary - -export const Client2SummaryDetails = [ - { - label: "DID", - value: "did:sov:test:1234", - }, - { - label: "IP", - value: "127.0.0.2", - }, - { - label: "Network", - value: "Carlo's Home Network", - }, -]; - -export const Client2ConsumerData = [ - { - service_name: "Carlo's Printing", - service_type: "3D Printing", - endpoint_url: "Consume", - entity: "C2", - entity_did: "did:sov:test:1223", - network: "Carlo's Home Network", - }, - { - service_name: "Steve's Printing", - service_type: "3D Printing", - endpoint_url: "Consume", - entity: "C2", - entity_did: "did:sov:test:1234", - network: "Steve's Home Network", - }, - { - service_name: "Test A", - service_type: "3D Printing", - endpoint_url: "Consume", - entity: "C2", - entity_did: "did:sov:test:4567", - network: "Test Network A", - }, - { - service_name: "Test B", - service_type: "3D Printing", - endpoint_url: "Consume", - entity: "C2", - entity_did: "did:sov:test:0062", - network: "Test Network B", - }, -]; - -export const Client2ConsumerTableConfig = [ - { - key: "service_name", - label: "Service name", - }, - { - key: "service_type", - label: "Service Type", - }, - { - key: "endpoint_url", - label: "End Point", - }, - { - key: "entity", - label: "Entity", - }, - { - key: "entity_did", - label: "Entity DID", - }, - { - key: "network", - label: "Network", - }, -]; - -export const Client2ProducerData = [ - { - service_name: "Carlo's Printing", - service_type: "3D Printing", - endpoint_url: "URL", - usage: "C1(3), C3(4)", - status: "DRAFT, REGISTERED", - action: "Register, Deregister, Delete", - }, - { - service_name: "Steve's Printing", - service_type: "3D Printing", - endpoint_url: "URL", - usage: "C1(3), C3(4)", - status: "REGISTERED", - action: "Create", - }, - { - service_name: "Test Printing A", - service_type: "3D Printing", - endpoint_url: "URL", - usage: "C1(3), C3(4)", - status: "DRAFT", - action: "Register, Deregister", - }, - { - service_name: "Test Printing B", - service_type: "3D Printing", - endpoint_url: "URL", - usage: "C1(3), C3(4)", - status: "DRAFT, REGISTERED", - action: "Delete, Create", - }, -]; - -export const Client2ProducerTableConfig = [ - { - key: "service_name", - label: "Service name", - }, - { - key: "service_type", - label: "Service Type", - }, - { - key: "endpoint_url", - label: "End Point", - }, - { - key: "usage", - label: "Usage", - }, - { - key: "status", - label: "Status", - }, - { - key: "action", - label: "Action", - }, -]; diff --git a/pkgs/ui/src/mock/home/index.ts b/pkgs/ui/src/mock/home/index.ts deleted file mode 100644 index b6c2d4f..0000000 --- a/pkgs/ui/src/mock/home/index.ts +++ /dev/null @@ -1,47 +0,0 @@ -// HOME - Table Data - -export const HomeDummyData = [ - { - entity_name: "C1", - entity_DID: "did:sov:test:1234", - network: "Carlo's Home Network", - ip_address: "127.0.0.1", - roles: "service repository, service consumer, DLG", - visible: true, - }, - { - entity_name: "C2", - entity_DID: "did:sov:test:4567", - network: "Steve's Home Network", - ip_address: "127.0.0.1", - roles: "service repository, service consumer, DLG", - visible: false, - }, -]; - -export const HomeTableConfig = [ - { - key: "name", - label: "Entity name", - }, - { - key: "did", - label: "Entity DID", - }, - // { - // key: "network", - // label: "Network", - // }, - { - key: "ip", - label: "IP address", - }, - // { - // key: "roles", - // label: "Roles", - // }, - { - key: "attached", - label: "Attached", - }, -]; diff --git a/pkgs/ui/src/types/index.ts b/pkgs/ui/src/types/index.ts index 264feb4..fc40cbd 100644 --- a/pkgs/ui/src/types/index.ts +++ b/pkgs/ui/src/types/index.ts @@ -7,6 +7,7 @@ export interface CustomTableConfiguration { export interface ICustomTable { configuration: CustomTableConfiguration[]; data: any; + loading?: boolean; } export interface EntityDetails { @@ -20,7 +21,9 @@ export interface Entity { } export interface ISummaryDetails { - entity: Entity; + entity: any; + fake?: boolean; hasRefreshButton?: boolean; hasAttachDetach?: boolean; + onRefresh?: () => void; } diff --git a/pkgs/ui/src/utils/helpers.ts b/pkgs/ui/src/utils/helpers.ts new file mode 100644 index 0000000..8d6e3b2 --- /dev/null +++ b/pkgs/ui/src/utils/helpers.ts @@ -0,0 +1,12 @@ +export const formatDateTime = (date: string) => { + const _date = new Date(date); + return _date.toLocaleDateString("en-US", { + year: "numeric", + month: "long", + day: "numeric", + hour: "2-digit", + minute: "2-digit", + second: "2-digit", + hour12: true, + }); +}; From 824edac9e9b1521247bfa6c8e81174d14fa41e5e Mon Sep 17 00:00:00 2001 From: ui-asset-bot Date: Tue, 12 Dec 2023 22:03:01 +0000 Subject: [PATCH 30/58] update ui-assets.nix --- pkgs/ui/nix/ui-assets.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/ui/nix/ui-assets.nix b/pkgs/ui/nix/ui-assets.nix index 848c912..af775c8 100644 --- a/pkgs/ui/nix/ui-assets.nix +++ b/pkgs/ui/nix/ui-assets.nix @@ -1,5 +1,5 @@ { fetchzip }: fetchzip { - url = "https://gitea.gchq.icu/api/packages/IoSL/generic/IoSL-service-aware-frontend/042x4cdb35zzwjx3fc7v0qxil1fbam5xrgg42v816yih9kl5dqrz/assets.tar.gz"; - sha256 = "042x4cdb35zzwjx3fc7v0qxil1fbam5xrgg42v816yih9kl5dqrz"; + url = "https://gitea.gchq.icu/api/packages/IoSL/generic/IoSL-service-aware-frontend/15d2rn12jhrwry2ipvjhn62dgl7vvdrkc1zkp02xfvaz8ijf18s8/assets.tar.gz"; + sha256 = "15d2rn12jhrwry2ipvjhn62dgl7vvdrkc1zkp02xfvaz8ijf18s8"; } From 5fad1e678f96e247d12133a13eb9c06a584ec545 Mon Sep 17 00:00:00 2001 From: Luis-Hebendanz Date: Thu, 4 Jan 2024 22:40:10 +0100 Subject: [PATCH 31/58] Rename producer to service and consumer to client --- .../clan_cli/webui/routers/sql_connect.py | 94 +++++++++---------- pkgs/clan-cli/clan_cli/webui/schemas.py | 22 ++--- pkgs/clan-cli/clan_cli/webui/sql_crud.py | 72 +++++++------- pkgs/clan-cli/clan_cli/webui/sql_models.py | 38 ++++---- pkgs/clan-cli/clan_cli/webui/tags.py | 12 +-- pkgs/clan-cli/emulate_entity.sh | 3 + pkgs/clan-cli/tests/test_db_api.py | 46 ++++----- pkgs/ui/README.md | 1 + pkgs/ui/nix/ui-assets.nix | 2 +- 9 files changed, 140 insertions(+), 150 deletions(-) create mode 100755 pkgs/clan-cli/emulate_entity.sh diff --git a/pkgs/clan-cli/clan_cli/webui/routers/sql_connect.py b/pkgs/clan-cli/clan_cli/webui/routers/sql_connect.py index 05da969..df4cdda 100644 --- a/pkgs/clan-cli/clan_cli/webui/routers/sql_connect.py +++ b/pkgs/clan-cli/clan_cli/webui/routers/sql_connect.py @@ -9,16 +9,16 @@ from sqlalchemy.orm import Session from ...errors import ClanError from .. import sql_crud, sql_db, sql_models from ..schemas import ( - Consumer, - ConsumerCreate, + Client, + ClientCreate, Entity, EntityCreate, - Producer, - ProducerCreate, Repository, RepositoryCreate, Resolution, ResolutionCreate, + Service, + ServiceCreate, ) from ..tags import Tags @@ -29,92 +29,82 @@ log = logging.getLogger(__name__) ######################### # # -# Producer # +# Service # # # ######################### -@router.post("/api/v1/create_producer", response_model=Producer, tags=[Tags.producers]) -def create_producer( - producer: ProducerCreate, db: Session = Depends(sql_db.get_db) -) -> Producer: +@router.post("/api/v1/create_service", response_model=Service, tags=[Tags.services]) +def create_service( + service: ServiceCreate, db: Session = Depends(sql_db.get_db) +) -> Service: # todo checken ob schon da ... - return sql_crud.create_producer(db=db, producer=producer) + return sql_crud.create_service(db=db, service=service) -@router.get( - "/api/v1/get_producers", response_model=List[Producer], tags=[Tags.producers] -) -def get_producers( +@router.get("/api/v1/get_services", response_model=List[Service], tags=[Tags.services]) +def get_services( skip: int = 0, limit: int = 100, db: Session = Depends(sql_db.get_db) -) -> List[sql_models.Producer]: - producers = sql_crud.get_producers(db, skip=skip, limit=limit) - return producers +) -> List[sql_models.Service]: + services = sql_crud.get_services(db, skip=skip, limit=limit) + return services -@router.get( - "/api/v1/get_producer", response_model=List[Producer], tags=[Tags.producers] -) -def get_producer( +@router.get("/api/v1/get_service", response_model=List[Service], tags=[Tags.services]) +def get_service( entity_did: str = "did:sov:test:1234", skip: int = 0, limit: int = 100, db: Session = Depends(sql_db.get_db), -) -> List[sql_models.Producer]: - producer = sql_crud.get_producers_by_entity_did(db, entity_did=entity_did) - return producer +) -> List[sql_models.Service]: + service = sql_crud.get_services_by_entity_did(db, entity_did=entity_did) + return service -@router.delete("/api/v1/delete_producer", tags=[Tags.producers]) -def delete_producer( +@router.delete("/api/v1/delete_service", tags=[Tags.services]) +def delete_service( entity_did: str = "did:sov:test:1234", db: Session = Depends(sql_db.get_db), ) -> dict[str, str]: - sql_crud.delete_producer_by_entity_did(db, entity_did) - return {"message": "Producer deleted"} + sql_crud.delete_service_by_entity_did(db, entity_did) + return {"message": "service deleted"} ######################### # # -# Consumer # +# Client # # # ######################### -@router.post("/api/v1/create_consumer", response_model=Consumer, tags=[Tags.consumers]) -def create_consumer( - consumer: ConsumerCreate, db: Session = Depends(sql_db.get_db) -) -> Consumer: +@router.post("/api/v1/create_client", response_model=Client, tags=[Tags.clients]) +def create_client(client: ClientCreate, db: Session = Depends(sql_db.get_db)) -> Client: # todo checken ob schon da ... - return sql_crud.create_consumer(db=db, consumer=consumer) + return sql_crud.create_client(db=db, client=client) -@router.get( - "/api/v1/get_consumers", response_model=List[Consumer], tags=[Tags.consumers] -) -def get_consumers( +@router.get("/api/v1/get_clients", response_model=List[Client], tags=[Tags.clients]) +def get_clients( skip: int = 0, limit: int = 100, db: Session = Depends(sql_db.get_db) -) -> List[sql_models.Consumer]: - consumers = sql_crud.get_consumers(db, skip=skip, limit=limit) - return consumers +) -> List[sql_models.Client]: + clients = sql_crud.get_clients(db, skip=skip, limit=limit) + return clients -@router.get( - "/api/v1/get_consumer", response_model=List[Consumer], tags=[Tags.consumers] -) -def get_consumer( +@router.get("/api/v1/get_client", response_model=List[Client], tags=[Tags.clients]) +def get_client( entity_did: str = "did:sov:test:1234", skip: int = 0, limit: int = 100, db: Session = Depends(sql_db.get_db), -) -> List[sql_models.Consumer]: - consumer = sql_crud.get_consumers_by_entity_did(db, entity_did=entity_did) - return consumer +) -> List[sql_models.Client]: + client = sql_crud.get_client_by_entity_did(db, entity_did=entity_did) + return client -@router.delete("/api/v1/delete_consumer", tags=[Tags.consumers]) -def delete_consumer( +@router.delete("/api/v1/delete_client", tags=[Tags.clients]) +def delete_client( entity_did: str = "did:sov:test:1234", db: Session = Depends(sql_db.get_db), ) -> dict[str, str]: - sql_crud.delete_consumer_by_entity_did(db, entity_did) - return {"message": "Consumer deleted"} + sql_crud.delete_client_by_entity_did(db, entity_did) + return {"message": "client deleted"} ######################### diff --git a/pkgs/clan-cli/clan_cli/webui/schemas.py b/pkgs/clan-cli/clan_cli/webui/schemas.py index 303e0f7..edf02b2 100644 --- a/pkgs/clan-cli/clan_cli/webui/schemas.py +++ b/pkgs/clan-cli/clan_cli/webui/schemas.py @@ -18,10 +18,10 @@ class Machine(BaseModel): ######################### # # -# Producer # +# Service # # # ######################### -class ProducerBase(BaseModel): +class ServiceBase(BaseModel): uuid: str = "8e285c0c-4e40-430a-a477-26b3b81e30df" service_name: str = "Carlo's Printing" service_type: str = "3D Printing" @@ -30,11 +30,11 @@ class ProducerBase(BaseModel): other: dict = {"action": ["register", "deregister", "delete", "create"]} -class ProducerCreate(ProducerBase): +class ServiceCreate(ServiceBase): entity_did: str = "did:sov:test:1234" -class Producer(ProducerCreate): +class Service(ServiceCreate): class Config: orm_mode = True @@ -44,17 +44,17 @@ class Producer(ProducerCreate): # Consumer # # # ######################### -class ConsumerBase(BaseModel): +class ClientBase(BaseModel): entity_did: str = "did:sov:test:1234" - producer_uuid: str = "8e285c0c-4e40-430a-a477-26b3b81e30df" + service_uuid: str = "8e285c0c-4e40-430a-a477-26b3b81e30df" other: dict = {"test": "test"} -class ConsumerCreate(ConsumerBase): +class ClientCreate(ClientBase): pass -class Consumer(ConsumerCreate): +class Client(ClientCreate): id: int class Config: @@ -66,7 +66,7 @@ class Consumer(ConsumerCreate): # REPOSITORY # # # ######################### -class RepositoryBase(ProducerBase): +class RepositoryBase(ServiceBase): pass @@ -103,8 +103,8 @@ class EntityCreate(EntityBase): class Entity(EntityCreate): - producers: List[Producer] = [] - consumers: List[Consumer] = [] + services: List[Service] = [] + clients: List[Client] = [] repository: List[Repository] = [] class Config: diff --git a/pkgs/clan-cli/clan_cli/webui/sql_crud.py b/pkgs/clan-cli/clan_cli/webui/sql_crud.py index cf03c41..93b6141 100644 --- a/pkgs/clan-cli/clan_cli/webui/sql_crud.py +++ b/pkgs/clan-cli/clan_cli/webui/sql_crud.py @@ -8,84 +8,80 @@ from . import schemas, sql_models ######################### # # -# Producer # +# service # # # ######################### -def create_producer( - db: Session, producer: schemas.ProducerCreate -) -> sql_models.Producer: - db_producer = sql_models.Producer(**producer.dict()) - db.add(db_producer) +def create_service(db: Session, service: schemas.ServiceCreate) -> sql_models.Service: + db_service = sql_models.Service(**service.dict()) + db.add(db_service) db.commit() - db.refresh(db_producer) - return db_producer + db.refresh(db_service) + return db_service -def get_producers( +def get_services( db: Session, skip: int = 0, limit: int = 100 -) -> List[sql_models.Producer]: - return db.query(sql_models.Producer).offset(skip).limit(limit).all() +) -> List[sql_models.Service]: + return db.query(sql_models.Service).offset(skip).limit(limit).all() -def get_producers_by_entity_did( +def get_services_by_entity_did( db: Session, entity_did: str, skip: int = 0, limit: int = 100 -) -> List[sql_models.Producer]: +) -> List[sql_models.Service]: return ( - db.query(sql_models.Producer) - .filter(sql_models.Producer.entity_did == entity_did) + db.query(sql_models.Service) + .filter(sql_models.Service.entity_did == entity_did) .offset(skip) .limit(limit) .all() ) -def delete_producer_by_entity_did(db: Session, entity_did: str) -> None: - db.query(sql_models.Producer).filter( - sql_models.Producer.entity_did == entity_did +def delete_service_by_entity_did(db: Session, entity_did: str) -> None: + db.query(sql_models.Service).filter( + sql_models.Service.entity_did == entity_did ).delete() db.commit() ######################### # # -# Consumer # +# client # # # ######################### -def create_consumer( - db: Session, consumer: schemas.ConsumerCreate -) -> sql_models.Consumer: - db_consumer = sql_models.Consumer(**consumer.dict()) - db.add(db_consumer) +def create_client(db: Session, client: schemas.ClientCreate) -> sql_models.Client: + db_client = sql_models.Client(**client.dict()) + db.add(db_client) db.commit() - db.refresh(db_consumer) - return db_consumer + db.refresh(db_client) + return db_client -def get_consumers( +def get_clients( db: Session, skip: int = 0, limit: int = 100 -) -> List[sql_models.Consumer]: - return db.query(sql_models.Consumer).offset(skip).limit(limit).all() +) -> List[sql_models.Client]: + return db.query(sql_models.Client).offset(skip).limit(limit).all() -def get_consumers_by_entity_did( +def get_client_by_entity_did( db: Session, entity_did: str, skip: int = 0, limit: int = 100 -) -> List[sql_models.Consumer]: +) -> List[sql_models.Client]: return ( - db.query(sql_models.Consumer) - .filter(sql_models.Consumer.entity_did == entity_did) + db.query(sql_models.Client) + .filter(sql_models.Client.entity_did == entity_did) .offset(skip) .limit(limit) .all() ) -def delete_consumer_by_entity_did(db: Session, entity_did: str) -> None: - db.query(sql_models.Consumer).filter( - sql_models.Consumer.entity_did == entity_did +def delete_client_by_entity_did(db: Session, entity_did: str) -> None: + db.query(sql_models.Client).filter( + sql_models.Client.entity_did == entity_did ).delete() db.commit() @@ -198,8 +194,8 @@ def delete_entity_by_did(db: Session, did: str) -> None: def delete_entity_by_did_recursive(db: Session, did: str) -> None: - delete_producer_by_entity_did(db, did) - delete_consumer_by_entity_did(db, did) + delete_service_by_entity_did(db, did) + delete_client_by_entity_did(db, did) delete_repository_by_entity_did(db, did) delete_entity_by_did(db, did) diff --git a/pkgs/clan-cli/clan_cli/webui/sql_models.py b/pkgs/clan-cli/clan_cli/webui/sql_models.py index c606b9f..2523451 100644 --- a/pkgs/clan-cli/clan_cli/webui/sql_models.py +++ b/pkgs/clan-cli/clan_cli/webui/sql_models.py @@ -33,13 +33,13 @@ class Entity(Base): other = Column(JSON) ## Relations ## - producers = relationship("Producer", back_populates="entity") - consumers = relationship("Consumer", back_populates="entity") + services = relationship("Service", back_populates="entity") + clients = relationship("Client", back_populates="entity") repository = relationship("Repository", back_populates="entity") # TODO maby refactor to repositories -class ProducerAbstract(Base): +class ServiceAbstract(Base): __abstract__ = True # Queryable body @@ -54,22 +54,22 @@ class ProducerAbstract(Base): other = Column(JSON) -class Producer(ProducerAbstract): - __tablename__ = "producers" +class Service(ServiceAbstract): + __tablename__ = "services" - # Usage is the consumers column + # Usage is the clients column ## Relations ## - # One entity can have many producers - entity = relationship("Entity", back_populates="producers") + # One entity can have many services + entity = relationship("Entity", back_populates="services") entity_did = Column(String, ForeignKey("entities.did")) - # One producer has many consumers - consumers = relationship("Consumer", back_populates="producer") + # One service has many clients + clients = relationship("Client", back_populates="service") -class Consumer(Base): - __tablename__ = "consumers" +class Client(Base): + __tablename__ = "clients" ## Queryable body ## id = Column(Integer, primary_key=True, index=True) @@ -78,18 +78,18 @@ class Consumer(Base): other = Column(JSON) ## Relations ## - # one entity can have many consumers - entity = relationship("Entity", back_populates="consumers") + # one entity can have many clients + entity = relationship("Entity", back_populates="clients") entity_did = Column(String, ForeignKey("entities.did")) - # one consumer has one producer - producer = relationship("Producer", back_populates="consumers") - producer_uuid = Column(String, ForeignKey("producers.uuid")) + # one client has one service + service = relationship("Service", back_populates="clients") + service_uuid = Column(String, ForeignKey("services.uuid")) - __table_args__ = (UniqueConstraint("producer_uuid", "entity_did"),) + __table_args__ = (UniqueConstraint("service_uuid", "entity_did"),) -class Repository(ProducerAbstract): +class Repository(ServiceAbstract): __tablename__ = "repositories" time_created = Column(DateTime(timezone=True), server_default=func.now()) diff --git a/pkgs/clan-cli/clan_cli/webui/tags.py b/pkgs/clan-cli/clan_cli/webui/tags.py index 7f11e48..034beb7 100644 --- a/pkgs/clan-cli/clan_cli/webui/tags.py +++ b/pkgs/clan-cli/clan_cli/webui/tags.py @@ -3,8 +3,8 @@ from typing import Any, Dict, List class Tags(Enum): - producers = "producers" - consumers = "consumers" + services = "services" + clients = "clients" entities = "entities" repositories = "repositories" resolutions = "resolution" @@ -15,12 +15,12 @@ class Tags(Enum): tags_metadata: List[Dict[str, Any]] = [ { - "name": str(Tags.producers), - "description": "Operations on a producer.", + "name": str(Tags.services), + "description": "Operations on a service.", }, { - "name": str(Tags.consumers), - "description": "Operations on a consumer.", + "name": str(Tags.clients), + "description": "Operations on a client.", }, { "name": str(Tags.entities), diff --git a/pkgs/clan-cli/emulate_entity.sh b/pkgs/clan-cli/emulate_entity.sh new file mode 100755 index 0000000..da91b78 --- /dev/null +++ b/pkgs/clan-cli/emulate_entity.sh @@ -0,0 +1,3 @@ +#!/usr/bin/env bash + +while true ; do printf 'HTTP/1.1 200 OK\r\n\r\ncool, thanks' | nc -l -N 127.0.0.1 5555 ; done diff --git a/pkgs/clan-cli/tests/test_db_api.py b/pkgs/clan-cli/tests/test_db_api.py index cf393bf..b1693ca 100644 --- a/pkgs/clan-cli/tests/test_db_api.py +++ b/pkgs/clan-cli/tests/test_db_api.py @@ -43,11 +43,11 @@ def make_test_post_and_get( assert_extra_info(["time_created"], request_body, response.json()) elif paramter == "resolution": assert_extra_info(["timestamp", "id"], request_body, response.json()) - elif paramter == "consumer": + elif paramter == "client": assert_extra_info(["id"], request_body, response.json()) elif paramter == "entity": assert_extra_info( - ["consumers", "producers", "repository"], request_body, response.json() + ["clients", "services", "repository"], request_body, response.json() ) else: assert response.json() == request_body @@ -60,11 +60,11 @@ def make_test_post_and_get( assert_extra_info(["time_created"], request_body, response.json()[0]) elif paramter == "resolution": assert_extra_info(["timestamp", "id"], request_body, response.json()[0]) - elif paramter == "consumer": + elif paramter == "client": assert_extra_info(["id"], request_body, response.json()[0]) elif paramter == "entity": assert_extra_info( - ["consumers", "producers", "repository"], request_body, response.json() + ["clients", "services", "repository"], request_body, response.json() ) else: assert response.json() == [request_body] @@ -72,10 +72,10 @@ def make_test_post_and_get( ######################### # # -# Producer # +# service # # # ######################### -def test_producer(api: TestClient) -> None: +def test_service(api: TestClient) -> None: request_body = { "uuid": "8e285c0c-4e40-430a-a477-26b3b81e30df", "service_name": "Carlo'''s Printing", @@ -85,12 +85,12 @@ def test_producer(api: TestClient) -> None: "other": {"action": ["register", "deregister", "delete", "create"]}, "entity_did": default_entity_did, } - paramter = "producer" + paramter = "service" # get_request = "entity_did=did%3Asov%3Atest%3A1234" make_test_post_and_get(api, request_body, paramter) -def test_producer2(api: TestClient) -> None: +def test_service2(api: TestClient) -> None: request_body = { "uuid": "8e285c0c-4e40-430a-a477-26b3b81e30d1", "service_name": "Luis'''s Fax", @@ -100,12 +100,12 @@ def test_producer2(api: TestClient) -> None: "other": {"action": ["register", "deregister", "delete", "create"]}, "entity_did": default_entity_did2, } - paramter = "producer" + paramter = "service" get_request = "entity_did=" + url.quote(default_entity_did2) make_test_post_and_get(api, request_body, paramter, get_request) -def test_producer3(api: TestClient) -> None: +def test_service3(api: TestClient) -> None: request_body = { "uuid": "8e285c0c-4e40-430a-a477-26b3b81e30d2", "service_name": "Erdem'''s VR-Stream", @@ -115,12 +115,12 @@ def test_producer3(api: TestClient) -> None: "other": {"action": ["register", "deregister", "delete", "create"]}, "entity_did": default_entity_did3, } - paramter = "producer" + paramter = "service" get_request = "entity_did=" + url.quote(default_entity_did3) make_test_post_and_get(api, request_body, paramter, get_request) -def test_producer4(api: TestClient) -> None: +def test_service4(api: TestClient) -> None: request_body = { "uuid": "8e285c0c-4e40-430a-a477-26b3b81e30d3", "service_name": "Onur'''s gallary", @@ -130,12 +130,12 @@ def test_producer4(api: TestClient) -> None: "other": {"action": ["register", "deregister", "delete", "create"]}, "entity_did": default_entity_did4, } - paramter = "producer" + paramter = "service" get_request = "entity_did=" + url.quote(default_entity_did4) make_test_post_and_get(api, request_body, paramter, get_request) -def test_producer5(api: TestClient) -> None: +def test_service5(api: TestClient) -> None: request_body = { "uuid": "8e285c0c-4e40-430a-a477-26b3b81e30d4", "service_name": "Sara'''s Game-Shop", @@ -145,34 +145,34 @@ def test_producer5(api: TestClient) -> None: "other": {"action": ["register", "deregister", "delete", "create"]}, "entity_did": default_entity_did5, } - paramter = "producer" + paramter = "service" get_request = "entity_did=" + url.quote(default_entity_did5) make_test_post_and_get(api, request_body, paramter, get_request) ######################### # # -# Consumer # +# client # # # ######################### -def test_consumer(api: TestClient) -> None: +def test_client(api: TestClient) -> None: request_body = { "entity_did": default_entity_did, - "producer_uuid": "8e285c0c-4e40-430a-a477-26b3b81e30df", + "service_uuid": "8e285c0c-4e40-430a-a477-26b3b81e30df", "other": {"test": "test"}, } - paramter = "consumer" + paramter = "client" # get_request = "entity_did=did%3Asov%3Atest%3A1234" make_test_post_and_get(api, request_body, paramter) -def test_consumer2(api: TestClient) -> None: +def test_client2(api: TestClient) -> None: request_body = { "entity_did": default_entity_did2, - "producer_uuid": "8e285c0c-4e40-430a-a477-26b3b81e30d4", + "service_uuid": "8e285c0c-4e40-430a-a477-26b3b81e30d4", "other": {"war": "games"}, } - paramter = "consumer" + paramter = "client" get_request = "entity_did=" + url.quote(default_entity_did2) make_test_post_and_get(api, request_body, paramter, get_request) @@ -271,7 +271,7 @@ def test_entity(api: TestClient) -> None: "visible": True, "other": { "network": "Carlo1's Home Network", - "roles": ["service repository", "service consumer"], + "roles": ["service repository", "service client"], }, } paramter = "entity" diff --git a/pkgs/ui/README.md b/pkgs/ui/README.md index ee3cff7..4a81fd9 100644 --- a/pkgs/ui/README.md +++ b/pkgs/ui/README.md @@ -25,3 +25,4 @@ Than run this command: ``` GITEA_TOKEN= nix run .#update-ui-assets ``` +. diff --git a/pkgs/ui/nix/ui-assets.nix b/pkgs/ui/nix/ui-assets.nix index af775c8..196aeee 100644 --- a/pkgs/ui/nix/ui-assets.nix +++ b/pkgs/ui/nix/ui-assets.nix @@ -1,5 +1,5 @@ { fetchzip }: fetchzip { url = "https://gitea.gchq.icu/api/packages/IoSL/generic/IoSL-service-aware-frontend/15d2rn12jhrwry2ipvjhn62dgl7vvdrkc1zkp02xfvaz8ijf18s8/assets.tar.gz"; - sha256 = "15d2rn12jhrwry2ipvjhn62dgl7vvdrkc1zkp02xfvaz8ijf18s8"; + sha256 = "sha256-SKPgZERfbdcFuPMHNnPb+9DXhLFQ7huFzzxDKYLNopU="; } From 68b7171852d17892bafd791e6903352d8a2bff56 Mon Sep 17 00:00:00 2001 From: Luis-Hebendanz Date: Thu, 4 Jan 2024 23:27:35 +0100 Subject: [PATCH 32/58] Refactored api calls to REST. Clients endpoint is now services without self. repository view is the same as get all services. --- .../clan_cli/webui/routers/sql_connect.py | 175 ++++++------------ pkgs/clan-cli/clan_cli/webui/schemas.py | 50 +---- pkgs/clan-cli/clan_cli/webui/sql_crud.py | 130 +------------ pkgs/clan-cli/clan_cli/webui/sql_models.py | 55 ------ 4 files changed, 59 insertions(+), 351 deletions(-) diff --git a/pkgs/clan-cli/clan_cli/webui/routers/sql_connect.py b/pkgs/clan-cli/clan_cli/webui/routers/sql_connect.py index df4cdda..6ca62b8 100644 --- a/pkgs/clan-cli/clan_cli/webui/routers/sql_connect.py +++ b/pkgs/clan-cli/clan_cli/webui/routers/sql_connect.py @@ -1,5 +1,6 @@ import logging import time +from datetime import datetime from typing import List, Optional import httpx @@ -9,14 +10,9 @@ from sqlalchemy.orm import Session from ...errors import ClanError from .. import sql_crud, sql_db, sql_models from ..schemas import ( - Client, - ClientCreate, Entity, EntityCreate, - Repository, - RepositoryCreate, Resolution, - ResolutionCreate, Service, ServiceCreate, ) @@ -32,7 +28,7 @@ log = logging.getLogger(__name__) # Service # # # ######################### -@router.post("/api/v1/create_service", response_model=Service, tags=[Tags.services]) +@router.post("/api/v1/service", response_model=Service, tags=[Tags.services]) def create_service( service: ServiceCreate, db: Session = Depends(sql_db.get_db) ) -> Service: @@ -40,16 +36,18 @@ def create_service( return sql_crud.create_service(db=db, service=service) -@router.get("/api/v1/get_services", response_model=List[Service], tags=[Tags.services]) -def get_services( +@router.get("/api/v1/services", response_model=List[Service], tags=[Tags.services]) +def get_all_services( skip: int = 0, limit: int = 100, db: Session = Depends(sql_db.get_db) ) -> List[sql_models.Service]: services = sql_crud.get_services(db, skip=skip, limit=limit) return services -@router.get("/api/v1/get_service", response_model=List[Service], tags=[Tags.services]) -def get_service( +@router.get( + "/api/v1/{entity_did}/service", response_model=List[Service], tags=[Tags.services] +) +def get_service_by_did( entity_did: str = "did:sov:test:1234", skip: int = 0, limit: int = 100, @@ -59,7 +57,7 @@ def get_service( return service -@router.delete("/api/v1/delete_service", tags=[Tags.services]) +@router.delete("/api/v1/{entity_did}/service", tags=[Tags.services]) def delete_service( entity_did: str = "did:sov:test:1234", db: Session = Depends(sql_db.get_db), @@ -73,38 +71,19 @@ def delete_service( # Client # # # ######################### -@router.post("/api/v1/create_client", response_model=Client, tags=[Tags.clients]) -def create_client(client: ClientCreate, db: Session = Depends(sql_db.get_db)) -> Client: - # todo checken ob schon da ... - return sql_crud.create_client(db=db, client=client) - - -@router.get("/api/v1/get_clients", response_model=List[Client], tags=[Tags.clients]) -def get_clients( - skip: int = 0, limit: int = 100, db: Session = Depends(sql_db.get_db) -) -> List[sql_models.Client]: - clients = sql_crud.get_clients(db, skip=skip, limit=limit) - return clients - - -@router.get("/api/v1/get_client", response_model=List[Client], tags=[Tags.clients]) -def get_client( +@router.get( + "/api/v1/{entity_did}/clients", response_model=List[Service], tags=[Tags.clients] +) +def get_all_clients( entity_did: str = "did:sov:test:1234", skip: int = 0, limit: int = 100, db: Session = Depends(sql_db.get_db), -) -> List[sql_models.Client]: - client = sql_crud.get_client_by_entity_did(db, entity_did=entity_did) - return client - - -@router.delete("/api/v1/delete_client", tags=[Tags.clients]) -def delete_client( - entity_did: str = "did:sov:test:1234", - db: Session = Depends(sql_db.get_db), -) -> dict[str, str]: - sql_crud.delete_client_by_entity_did(db, entity_did) - return {"message": "client deleted"} +) -> List[sql_models.Service]: + clients = sql_crud.get_services_without_entity_id( + db, entity_did, skip=skip, limit=limit + ) + return clients ######################### @@ -112,72 +91,44 @@ def delete_client( # REPOSITORY # # # ######################### -@router.post( - "/api/v1/create_repository", response_model=Repository, tags=[Tags.repositories] -) -def create_repository( - repository: RepositoryCreate, db: Session = Depends(sql_db.get_db) -) -> sql_models.Repository: - # todo checken ob schon da ... - return sql_crud.create_repository(db=db, repository=repository) @router.get( - "/api/v1/get_repositories", - response_model=List[Repository], + "/api/v1/repositories", + response_model=List[Service], tags=[Tags.repositories], ) -def get_repositories( +def get_all_repositories( skip: int = 0, limit: int = 100, db: Session = Depends(sql_db.get_db) -) -> List[sql_models.Repository]: - repositories = sql_crud.get_repositories(db, skip=skip, limit=limit) +) -> List[sql_models.Service]: + repositories = sql_crud.get_services(db, skip=skip, limit=limit) return repositories -@router.get( - "/api/v1/get_repository", response_model=List[Repository], tags=[Tags.repositories] -) -def get_repository( - entity_did: str = "did:sov:test:1234", - skip: int = 0, - limit: int = 100, - db: Session = Depends(sql_db.get_db), -) -> List[sql_models.Repository]: - repository = sql_crud.get_repository_by_entity_did(db, did=entity_did) - return repository - - -@router.delete("/api/v1/delete_repository", tags=[Tags.repositories]) -def delete_repository( - entity_did: str = "did:sov:test:1234", - db: Session = Depends(sql_db.get_db), -) -> dict[str, str]: - sql_crud.delete_repository_by_entity_did(db, did=entity_did) - return {"message": "Repository deleted"} - - ######################### # # # Entity # # # ######################### -@router.post("/api/v1/create_entity", response_model=Entity, tags=[Tags.entities]) +@router.post("/api/v1/entity", response_model=Entity, tags=[Tags.entities]) def create_entity( entity: EntityCreate, db: Session = Depends(sql_db.get_db) ) -> EntityCreate: return sql_crud.create_entity(db, entity) -@router.get("/api/v1/get_entities", response_model=List[Entity], tags=[Tags.entities]) -def get_entities( +@router.get("/api/v1/entities", response_model=List[Entity], tags=[Tags.entities]) +def get_all_entities( skip: int = 0, limit: int = 100, db: Session = Depends(sql_db.get_db) ) -> List[sql_models.Entity]: entities = sql_crud.get_entities(db, skip=skip, limit=limit) return entities -@router.get("/api/v1/get_entity", response_model=Optional[Entity], tags=[Tags.entities]) -def get_entity( +@router.get( + "/api/v1/{entity_did}/entity", response_model=Optional[Entity], tags=[Tags.entities] +) +def get_entity_by_did( entity_did: str = "did:sov:test:1234", db: Session = Depends(sql_db.get_db), ) -> Optional[sql_models.Entity]: @@ -186,7 +137,7 @@ def get_entity( @router.get( - "/api/v1/get_attached_entities", + "/api/v1/attached_entities", response_model=List[Entity], tags=[Tags.entities], ) @@ -197,8 +148,8 @@ def get_attached_entities( return entities -@router.post("/api/v1/detach", response_model=Entity, tags=[Tags.entities]) -async def detach( +@router.post("/api/v1/{entity_did}/detach", response_model=Entity, tags=[Tags.entities]) +async def detach_entity( background_tasks: BackgroundTasks, entity_did: str = "did:sov:test:1234", skip: int = 0, @@ -209,8 +160,8 @@ async def detach( return entity -@router.post("/api/v1/attach", tags=[Tags.entities]) -async def attach( +@router.post("/api/v1/{entity_did}/attach", tags=[Tags.entities]) +async def attach_entity( background_tasks: BackgroundTasks, entity_did: str = "did:sov:test:1234", skip: int = 0, @@ -220,11 +171,11 @@ async def attach( if sql_crud.get_entity_by_did(db, entity_did) is None: raise ClanError(f"Entity with did '{entity_did}' not found") - background_tasks.add_task(attach_entity, db, entity_did) + background_tasks.add_task(attach_entity_loc, db, entity_did) return {"message": "Attaching in the background"} -def attach_entity(db: Session, entity_did: str) -> None: +def attach_entity_loc(db: Session, entity_did: str) -> None: db_entity = sql_crud.set_attached_by_entity_did(db, entity_did, True) try: while db_entity.attached: @@ -244,7 +195,7 @@ def attach_entity(db: Session, entity_did: str) -> None: db_entity = sql_crud.set_attached_by_entity_did(db, entity_did, False) -@router.delete("/api/v1/delete_entity_recursive", tags=[Tags.entities]) +@router.delete("/api/v1/{entity_did}/entity", tags=[Tags.entities]) def delete_entity( entity_did: str = "did:sov:test:1234", db: Session = Depends(sql_db.get_db), @@ -258,45 +209,23 @@ def delete_entity( # Resolution # # # ######################### -@router.post( - "/api/v1/create_resolution", response_model=Resolution, tags=[Tags.resolutions] -) -def create_resolution( - resolution: ResolutionCreate, - db: Session = Depends(sql_db.get_db), -) -> sql_models.Resolution: - return sql_crud.create_resolution(db, resolution) @router.get( - "/api/v1/get_resolutions", response_model=List[Resolution], tags=[Tags.resolutions] + "/api/v1/resolutions", response_model=List[Resolution], tags=[Tags.resolutions] ) -def get_resolutions( +def get_all_resolutions( skip: int = 0, limit: int = 100, db: Session = Depends(sql_db.get_db) -) -> List[sql_models.Resolution]: - resolutions = sql_crud.get_resolutions(db, skip=skip, limit=limit) - return resolutions +) -> List[Resolution]: + # TODO: Get resolutions from DLG entity - -@router.get( - "/api/v1/get_resolution", response_model=List[Resolution], tags=[Tags.resolutions] -) -def get_resolution( - requester_did: str = "did:sov:test:1122", - skip: int = 0, - limit: int = 100, - db: Session = Depends(sql_db.get_db), -) -> List[sql_models.Resolution]: - resolution = sql_crud.get_resolution_by_requester_did( - db, requester_did=requester_did - ) - return resolution - - -@router.delete("/api/v1/delete_resolution", tags=[Tags.resolutions]) -def delete_resolution( - requester_did: str = "did:sov:test:1122", - db: Session = Depends(sql_db.get_db), -) -> dict[str, str]: - sql_crud.delete_resolution_by_requester_did(db, requester_did=requester_did) - return {"message": "Resolution deleted"} + return [ + Resolution( + requester_name="C1", + requester_did="did:sov:test:1122", + resolved_did="did:sov:test:1234", + other={"test": "test"}, + timestamp=datetime.now(), + id=1, + ) + ] diff --git a/pkgs/clan-cli/clan_cli/webui/schemas.py b/pkgs/clan-cli/clan_cli/webui/schemas.py index edf02b2..eee4451 100644 --- a/pkgs/clan-cli/clan_cli/webui/schemas.py +++ b/pkgs/clan-cli/clan_cli/webui/schemas.py @@ -1,6 +1,5 @@ from datetime import datetime from enum import Enum -from typing import List from pydantic import BaseModel @@ -39,48 +38,6 @@ class Service(ServiceCreate): orm_mode = True -######################### -# # -# Consumer # -# # -######################### -class ClientBase(BaseModel): - entity_did: str = "did:sov:test:1234" - service_uuid: str = "8e285c0c-4e40-430a-a477-26b3b81e30df" - other: dict = {"test": "test"} - - -class ClientCreate(ClientBase): - pass - - -class Client(ClientCreate): - id: int - - class Config: - orm_mode = True - - -######################### -# # -# REPOSITORY # -# # -######################### -class RepositoryBase(ServiceBase): - pass - - -class RepositoryCreate(RepositoryBase): - entity_did: str = "did:sov:test:1234" - - -class Repository(RepositoryCreate): - time_created: datetime - - class Config: - orm_mode = True - - ######################### # # # Entity # @@ -90,7 +47,6 @@ class EntityBase(BaseModel): did: str = "did:sov:test:1234" name: str = "C1" ip: str = "127.0.0.1" - attached: bool = False visible: bool = True other: dict = { "network": "Carlo's Home Network", @@ -103,9 +59,7 @@ class EntityCreate(EntityBase): class Entity(EntityCreate): - services: List[Service] = [] - clients: List[Client] = [] - repository: List[Repository] = [] + attached: bool class Config: orm_mode = True @@ -116,8 +70,6 @@ class Entity(EntityCreate): # Resolution # # # ######################### - - class ResolutionBase(BaseModel): requester_name: str = "C1" requester_did: str = "did:sov:test:1122" diff --git a/pkgs/clan-cli/clan_cli/webui/sql_crud.py b/pkgs/clan-cli/clan_cli/webui/sql_crud.py index 93b6141..f10f582 100644 --- a/pkgs/clan-cli/clan_cli/webui/sql_crud.py +++ b/pkgs/clan-cli/clan_cli/webui/sql_crud.py @@ -8,7 +8,7 @@ from . import schemas, sql_models ######################### # # -# service # +# service # # # ######################### @@ -46,101 +46,25 @@ def delete_service_by_entity_did(db: Session, entity_did: str) -> None: db.commit() -######################### -# # -# client # -# # -######################### - - -def create_client(db: Session, client: schemas.ClientCreate) -> sql_models.Client: - db_client = sql_models.Client(**client.dict()) - db.add(db_client) - db.commit() - db.refresh(db_client) - return db_client - - -def get_clients( - db: Session, skip: int = 0, limit: int = 100 -) -> List[sql_models.Client]: - return db.query(sql_models.Client).offset(skip).limit(limit).all() - - -def get_client_by_entity_did( +def get_services_without_entity_id( db: Session, entity_did: str, skip: int = 0, limit: int = 100 -) -> List[sql_models.Client]: +) -> List[sql_models.Service]: return ( - db.query(sql_models.Client) - .filter(sql_models.Client.entity_did == entity_did) + db.query(sql_models.Service) + .filter(sql_models.Service.entity_did != entity_did) .offset(skip) .limit(limit) .all() ) -def delete_client_by_entity_did(db: Session, entity_did: str) -> None: - db.query(sql_models.Client).filter( - sql_models.Client.entity_did == entity_did - ).delete() - db.commit() - - -######################### -# # -# REPOSITORY # -# # -######################### -def create_repository( - db: Session, repository: schemas.RepositoryCreate -) -> sql_models.Repository: - db_repository = sql_models.Repository(**repository.dict()) - db.add(db_repository) - db.commit() - db.refresh(db_repository) - return db_repository - - -def get_repositories( - db: Session, skip: int = 0, limit: int = 100 -) -> List[sql_models.Repository]: - return db.query(sql_models.Repository).offset(skip).limit(limit).all() - - -def get_repository_by_uuid(db: Session, uuid: str) -> Optional[sql_models.Repository]: - return ( - db.query(sql_models.Repository) - .filter(sql_models.Repository.uuid == uuid) - .first() - ) - - -def get_repository_by_entity_did( - db: Session, did: str, skip: int = 0, limit: int = 100 -) -> List[sql_models.Repository]: - return ( - db.query(sql_models.Repository) - .filter(sql_models.Repository.entity_did == did) - .offset(skip) - .limit(limit) - .all() - ) - - -def delete_repository_by_entity_did(db: Session, did: str) -> None: - db.query(sql_models.Repository).filter( - sql_models.Repository.entity_did == did - ).delete() - db.commit() - - ######################### # # # Entity # # # ######################### def create_entity(db: Session, entity: schemas.EntityCreate) -> sql_models.Entity: - db_entity = sql_models.Entity(**entity.dict()) + db_entity = sql_models.Entity(**entity.dict(), attached=False) db.add(db_entity) db.commit() db.refresh(db_entity) @@ -195,46 +119,4 @@ def delete_entity_by_did(db: Session, did: str) -> None: def delete_entity_by_did_recursive(db: Session, did: str) -> None: delete_service_by_entity_did(db, did) - delete_client_by_entity_did(db, did) - delete_repository_by_entity_did(db, did) delete_entity_by_did(db, did) - - -######################### -# # -# Resolution # -# # -######################### -def create_resolution( - db: Session, resolution: schemas.ResolutionCreate -) -> sql_models.Resolution: - db_resolution = sql_models.Resolution(**resolution.dict()) - db.add(db_resolution) - db.commit() - db.refresh(db_resolution) - return db_resolution - - -def get_resolutions( - db: Session, skip: int = 0, limit: int = 100 -) -> List[sql_models.Resolution]: - return db.query(sql_models.Resolution).offset(skip).limit(limit).all() - - -def get_resolution_by_requester_did( - db: Session, requester_did: str, skip: int = 0, limit: int = 100 -) -> List[sql_models.Resolution]: - return ( - db.query(sql_models.Resolution) - .filter(sql_models.Resolution.requester_did == requester_did) - .offset(skip) - .limit(limit) - .all() - ) - - -def delete_resolution_by_requester_did(db: Session, requester_did: str) -> None: - db.query(sql_models.Resolution).filter( - sql_models.Resolution.requester_did == requester_did - ).delete() - db.commit() diff --git a/pkgs/clan-cli/clan_cli/webui/sql_models.py b/pkgs/clan-cli/clan_cli/webui/sql_models.py index 2523451..f8341f0 100644 --- a/pkgs/clan-cli/clan_cli/webui/sql_models.py +++ b/pkgs/clan-cli/clan_cli/webui/sql_models.py @@ -2,15 +2,11 @@ from sqlalchemy import ( JSON, Boolean, Column, - DateTime, ForeignKey, - Integer, String, Text, - UniqueConstraint, ) from sqlalchemy.orm import relationship -from sqlalchemy.sql import func from .sql_db import Base @@ -34,9 +30,6 @@ class Entity(Base): ## Relations ## services = relationship("Service", back_populates="entity") - clients = relationship("Client", back_populates="entity") - repository = relationship("Repository", back_populates="entity") - # TODO maby refactor to repositories class ServiceAbstract(Base): @@ -57,55 +50,7 @@ class ServiceAbstract(Base): class Service(ServiceAbstract): __tablename__ = "services" - # Usage is the clients column - ## Relations ## # One entity can have many services entity = relationship("Entity", back_populates="services") entity_did = Column(String, ForeignKey("entities.did")) - - # One service has many clients - clients = relationship("Client", back_populates="service") - - -class Client(Base): - __tablename__ = "clients" - - ## Queryable body ## - id = Column(Integer, primary_key=True, index=True) - - ## Non queryable body ## - other = Column(JSON) - - ## Relations ## - # one entity can have many clients - entity = relationship("Entity", back_populates="clients") - entity_did = Column(String, ForeignKey("entities.did")) - - # one client has one service - service = relationship("Service", back_populates="clients") - service_uuid = Column(String, ForeignKey("services.uuid")) - - __table_args__ = (UniqueConstraint("service_uuid", "entity_did"),) - - -class Repository(ServiceAbstract): - __tablename__ = "repositories" - - time_created = Column(DateTime(timezone=True), server_default=func.now()) - - # one repository has one entity - entity = relationship("Entity", back_populates="repository") - entity_did = Column(Integer, ForeignKey("entities.did")) - - -# TODO: Ask how this works exactly -class Resolution(Base): - __tablename__ = "resolutions" - - id = Column(Integer, primary_key=True) - requester_name = Column(String, index=True) - requester_did = Column(String, index=True) - resolved_did = Column(String, index=True) - other = Column(JSON) - timestamp = Column(DateTime(timezone=True), server_default=func.now()) From 633055010b71fa97fd906762c0d064c163972288 Mon Sep 17 00:00:00 2001 From: Luis-Hebendanz Date: Fri, 5 Jan 2024 13:18:46 +0100 Subject: [PATCH 33/58] Generate python client for tests --- pkgs/clan-cli/bin/gen-openapi | 1 + pkgs/clan-cli/bin/gen-python-client | 64 + pkgs/clan-cli/shell.nix | 3 +- .../clan-cli/tests/openapi_client/__init__.py | 48 + .../tests/openapi_client/api/__init__.py | 10 + .../tests/openapi_client/api/clients_api.py | 200 +++ .../tests/openapi_client/api/default_api.py | 437 +++++++ .../tests/openapi_client/api/entities_api.py | 1074 +++++++++++++++++ .../openapi_client/api/repositories_api.py | 192 +++ .../openapi_client/api/resolution_api.py | 192 +++ .../tests/openapi_client/api/services_api.py | 633 ++++++++++ .../tests/openapi_client/api_client.py | 758 ++++++++++++ .../tests/openapi_client/api_response.py | 25 + .../tests/openapi_client/configuration.py | 434 +++++++ .../tests/openapi_client/exceptions.py | 166 +++ .../tests/openapi_client/models/__init__.py | 26 + .../tests/openapi_client/models/entity.py | 81 ++ .../openapi_client/models/entity_create.py | 79 ++ .../models/http_validation_error.py | 79 ++ .../tests/openapi_client/models/machine.py | 74 ++ .../tests/openapi_client/models/resolution.py | 81 ++ .../tests/openapi_client/models/service.py | 83 ++ .../openapi_client/models/service_create.py | 83 ++ .../tests/openapi_client/models/status.py | 41 + .../openapi_client/models/validation_error.py | 83 ++ .../models/validation_error_loc_inner.py | 138 +++ pkgs/clan-cli/tests/openapi_client/py.typed | 0 pkgs/clan-cli/tests/openapi_client/rest.py | 303 +++++ pkgs/clan-cli/tests/test_db_api.py | 327 +---- 29 files changed, 5389 insertions(+), 326 deletions(-) mode change 100644 => 100755 pkgs/clan-cli/bin/gen-openapi create mode 100755 pkgs/clan-cli/bin/gen-python-client create mode 100644 pkgs/clan-cli/tests/openapi_client/__init__.py create mode 100644 pkgs/clan-cli/tests/openapi_client/api/__init__.py create mode 100644 pkgs/clan-cli/tests/openapi_client/api/clients_api.py create mode 100644 pkgs/clan-cli/tests/openapi_client/api/default_api.py create mode 100644 pkgs/clan-cli/tests/openapi_client/api/entities_api.py create mode 100644 pkgs/clan-cli/tests/openapi_client/api/repositories_api.py create mode 100644 pkgs/clan-cli/tests/openapi_client/api/resolution_api.py create mode 100644 pkgs/clan-cli/tests/openapi_client/api/services_api.py create mode 100644 pkgs/clan-cli/tests/openapi_client/api_client.py create mode 100644 pkgs/clan-cli/tests/openapi_client/api_response.py create mode 100644 pkgs/clan-cli/tests/openapi_client/configuration.py create mode 100644 pkgs/clan-cli/tests/openapi_client/exceptions.py create mode 100644 pkgs/clan-cli/tests/openapi_client/models/__init__.py create mode 100644 pkgs/clan-cli/tests/openapi_client/models/entity.py create mode 100644 pkgs/clan-cli/tests/openapi_client/models/entity_create.py create mode 100644 pkgs/clan-cli/tests/openapi_client/models/http_validation_error.py create mode 100644 pkgs/clan-cli/tests/openapi_client/models/machine.py create mode 100644 pkgs/clan-cli/tests/openapi_client/models/resolution.py create mode 100644 pkgs/clan-cli/tests/openapi_client/models/service.py create mode 100644 pkgs/clan-cli/tests/openapi_client/models/service_create.py create mode 100644 pkgs/clan-cli/tests/openapi_client/models/status.py create mode 100644 pkgs/clan-cli/tests/openapi_client/models/validation_error.py create mode 100644 pkgs/clan-cli/tests/openapi_client/models/validation_error_loc_inner.py create mode 100644 pkgs/clan-cli/tests/openapi_client/py.typed create mode 100644 pkgs/clan-cli/tests/openapi_client/rest.py diff --git a/pkgs/clan-cli/bin/gen-openapi b/pkgs/clan-cli/bin/gen-openapi old mode 100644 new mode 100755 index 76b5a2e..b4de47d --- a/pkgs/clan-cli/bin/gen-openapi +++ b/pkgs/clan-cli/bin/gen-openapi @@ -1,4 +1,5 @@ #!/usr/bin/env python + import argparse import json import sys diff --git a/pkgs/clan-cli/bin/gen-python-client b/pkgs/clan-cli/bin/gen-python-client new file mode 100755 index 0000000..bfc881d --- /dev/null +++ b/pkgs/clan-cli/bin/gen-python-client @@ -0,0 +1,64 @@ +#!/usr/bin/env python + +import argparse +import json +import sys +from pathlib import Path +import tempfile +from uvicorn.importer import import_from_string +import subprocess +import shutil + +def main() -> None: + parser = argparse.ArgumentParser(prog="gen-openapi") + parser.add_argument( + "--app", help='App import string. Eg. "clan_cli.webui.app:app"', default="clan_cli.webui.app:app" + ) + parser.add_argument("--app-dir", help="Directory containing the app", default=".") + parser.add_argument( + "--out", help="Output file ending in .json", default="tests", type=Path + ) + args = parser.parse_args() + + if args.app_dir is not None: + print(f"adding {args.app_dir} to sys.path") + sys.path.insert(0, args.app_dir) + + print(f"importing app from {args.app}") + app = import_from_string(args.app) + openapi = app.openapi() + version = openapi.get("openapi", "unknown version") + + print(f"writing openapi spec v{version}") + with tempfile.TemporaryDirectory() as tmpdirname: + + tmp_dir = Path(tmpdirname) + openapi_p = tmp_dir / "openapi.json" + openapi_p.write_text(json.dumps(openapi, indent=2)) + + gen_code = tmp_dir / "gen_code" + + print(f"generating python client to {args.out}") + if not args.out.is_dir(): + raise Exception(f"{args.out} is not a directory") + args.out.mkdir(parents=True, exist_ok=True) + + cmd = [ + "openapi-generator-cli", + "generate", + "-g", + "python", + "-o", + f"{gen_code}", + "-i", + f"{openapi_p}", + ] + subprocess.run(cmd, check=True, text=True) + + dest_client: Path = args.out / "openapi_client" + shutil.rmtree(dest_client, ignore_errors=True) + shutil.copytree(gen_code / "openapi_client", dest_client) + + +if __name__ == "__main__": + main() diff --git a/pkgs/clan-cli/shell.nix b/pkgs/clan-cli/shell.nix index ac5ee0a..43c7aa8 100644 --- a/pkgs/clan-cli/shell.nix +++ b/pkgs/clan-cli/shell.nix @@ -1,4 +1,4 @@ -{ nix-unit, clan-cli, ui-assets, system, mkShell, writeScriptBin, openssh, ruff, python3 }: +{ nix-unit, clan-cli, openapi-generator-cli, ui-assets, system, mkShell, writeScriptBin, openssh, ruff, python3 }: let checkScript = writeScriptBin "check" '' nix build .#checks.${system}.{treefmt,clan-pytest} -L "$@" @@ -19,6 +19,7 @@ mkShell { openssh ruff clan-cli.checkPython + openapi-generator-cli ]; shellHook = '' diff --git a/pkgs/clan-cli/tests/openapi_client/__init__.py b/pkgs/clan-cli/tests/openapi_client/__init__.py new file mode 100644 index 0000000..f46dd78 --- /dev/null +++ b/pkgs/clan-cli/tests/openapi_client/__init__.py @@ -0,0 +1,48 @@ +# coding: utf-8 + +# flake8: noqa + +""" + FastAPI + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: 0.1.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +__version__ = "1.0.0" + +# import apis into sdk package +from openapi_client.api.clients_api import ClientsApi +from openapi_client.api.default_api import DefaultApi +from openapi_client.api.entities_api import EntitiesApi +from openapi_client.api.repositories_api import RepositoriesApi +from openapi_client.api.resolution_api import ResolutionApi +from openapi_client.api.services_api import ServicesApi + +# import ApiClient +from openapi_client.api_response import ApiResponse +from openapi_client.api_client import ApiClient +from openapi_client.configuration import Configuration +from openapi_client.exceptions import OpenApiException +from openapi_client.exceptions import ApiTypeError +from openapi_client.exceptions import ApiValueError +from openapi_client.exceptions import ApiKeyError +from openapi_client.exceptions import ApiAttributeError +from openapi_client.exceptions import ApiException + +# import models into sdk package +from openapi_client.models.entity import Entity +from openapi_client.models.entity_create import EntityCreate +from openapi_client.models.http_validation_error import HTTPValidationError +from openapi_client.models.machine import Machine +from openapi_client.models.resolution import Resolution +from openapi_client.models.service import Service +from openapi_client.models.service_create import ServiceCreate +from openapi_client.models.status import Status +from openapi_client.models.validation_error import ValidationError +from openapi_client.models.validation_error_loc_inner import ValidationErrorLocInner diff --git a/pkgs/clan-cli/tests/openapi_client/api/__init__.py b/pkgs/clan-cli/tests/openapi_client/api/__init__.py new file mode 100644 index 0000000..234e1be --- /dev/null +++ b/pkgs/clan-cli/tests/openapi_client/api/__init__.py @@ -0,0 +1,10 @@ +# flake8: noqa + +# import apis into api package +from openapi_client.api.clients_api import ClientsApi +from openapi_client.api.default_api import DefaultApi +from openapi_client.api.entities_api import EntitiesApi +from openapi_client.api.repositories_api import RepositoriesApi +from openapi_client.api.resolution_api import ResolutionApi +from openapi_client.api.services_api import ServicesApi + diff --git a/pkgs/clan-cli/tests/openapi_client/api/clients_api.py b/pkgs/clan-cli/tests/openapi_client/api/clients_api.py new file mode 100644 index 0000000..52c267e --- /dev/null +++ b/pkgs/clan-cli/tests/openapi_client/api/clients_api.py @@ -0,0 +1,200 @@ +# coding: utf-8 + +""" + FastAPI + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: 0.1.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import re # noqa: F401 +import io +import warnings + +from pydantic import validate_arguments, ValidationError + +from pydantic import StrictInt, StrictStr + +from typing import List, Optional + +from openapi_client.models.service import Service + +from openapi_client.api_client import ApiClient +from openapi_client.api_response import ApiResponse +from openapi_client.exceptions import ( # noqa: F401 + ApiTypeError, + ApiValueError +) + + +class ClientsApi: + """NOTE: This class is auto generated by OpenAPI Generator + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + def __init__(self, api_client=None) -> None: + if api_client is None: + api_client = ApiClient.get_default() + self.api_client = api_client + + @validate_arguments + def get_all_clients(self, entity_did : StrictStr, skip : Optional[StrictInt] = None, limit : Optional[StrictInt] = None, **kwargs) -> List[Service]: # noqa: E501 + """Get All Clients # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.get_all_clients(entity_did, skip, limit, async_req=True) + >>> result = thread.get() + + :param entity_did: (required) + :type entity_did: str + :param skip: + :type skip: int + :param limit: + :type limit: int + :param async_req: Whether to execute the request asynchronously. + :type async_req: bool, optional + :param _request_timeout: timeout setting for this request. + If one number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :return: Returns the result object. + If the method is called asynchronously, + returns the request thread. + :rtype: List[Service] + """ + kwargs['_return_http_data_only'] = True + if '_preload_content' in kwargs: + message = "Error! Please call the get_all_clients_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data" # noqa: E501 + raise ValueError(message) + return self.get_all_clients_with_http_info(entity_did, skip, limit, **kwargs) # noqa: E501 + + @validate_arguments + def get_all_clients_with_http_info(self, entity_did : StrictStr, skip : Optional[StrictInt] = None, limit : Optional[StrictInt] = None, **kwargs) -> ApiResponse: # noqa: E501 + """Get All Clients # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.get_all_clients_with_http_info(entity_did, skip, limit, async_req=True) + >>> result = thread.get() + + :param entity_did: (required) + :type entity_did: str + :param skip: + :type skip: int + :param limit: + :type limit: int + :param async_req: Whether to execute the request asynchronously. + :type async_req: bool, optional + :param _preload_content: if False, the ApiResponse.data will + be set to none and raw_data will store the + HTTP response body without reading/decoding. + Default is True. + :type _preload_content: bool, optional + :param _return_http_data_only: response data instead of ApiResponse + object with status code, headers, etc + :type _return_http_data_only: bool, optional + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the authentication + in the spec for a single request. + :type _request_auth: dict, optional + :type _content_type: string, optional: force content-type for the request + :return: Returns the result object. + If the method is called asynchronously, + returns the request thread. + :rtype: tuple(List[Service], status_code(int), headers(HTTPHeaderDict)) + """ + + _params = locals() + + _all_params = [ + 'entity_did', + 'skip', + 'limit' + ] + _all_params.extend( + [ + 'async_req', + '_return_http_data_only', + '_preload_content', + '_request_timeout', + '_request_auth', + '_content_type', + '_headers' + ] + ) + + # validate the arguments + for _key, _val in _params['kwargs'].items(): + if _key not in _all_params: + raise ApiTypeError( + "Got an unexpected keyword argument '%s'" + " to method get_all_clients" % _key + ) + _params[_key] = _val + del _params['kwargs'] + + _collection_formats = {} + + # process the path parameters + _path_params = {} + if _params['entity_did']: + _path_params['entity_did'] = _params['entity_did'] + + + # process the query parameters + _query_params = [] + if _params.get('skip') is not None: # noqa: E501 + _query_params.append(('skip', _params['skip'])) + + if _params.get('limit') is not None: # noqa: E501 + _query_params.append(('limit', _params['limit'])) + + # process the header parameters + _header_params = dict(_params.get('_headers', {})) + # process the form parameters + _form_params = [] + _files = {} + # process the body parameter + _body_params = None + # set the HTTP header `Accept` + _header_params['Accept'] = self.api_client.select_header_accept( + ['application/json']) # noqa: E501 + + # authentication setting + _auth_settings = [] # noqa: E501 + + _response_types_map = { + '200': "List[Service]", + '422': "HTTPValidationError", + } + + return self.api_client.call_api( + '/api/v1/{entity_did}/clients', 'GET', + _path_params, + _query_params, + _header_params, + body=_body_params, + post_params=_form_params, + files=_files, + response_types_map=_response_types_map, + auth_settings=_auth_settings, + async_req=_params.get('async_req'), + _return_http_data_only=_params.get('_return_http_data_only'), # noqa: E501 + _preload_content=_params.get('_preload_content', True), + _request_timeout=_params.get('_request_timeout'), + collection_formats=_collection_formats, + _request_auth=_params.get('_request_auth')) diff --git a/pkgs/clan-cli/tests/openapi_client/api/default_api.py b/pkgs/clan-cli/tests/openapi_client/api/default_api.py new file mode 100644 index 0000000..b64e1d4 --- /dev/null +++ b/pkgs/clan-cli/tests/openapi_client/api/default_api.py @@ -0,0 +1,437 @@ +# coding: utf-8 + +""" + FastAPI + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: 0.1.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import re # noqa: F401 +import io +import warnings + +from pydantic import validate_arguments, ValidationError + +from pydantic import StrictStr + +from openapi_client.models.machine import Machine + +from openapi_client.api_client import ApiClient +from openapi_client.api_response import ApiResponse +from openapi_client.exceptions import ( # noqa: F401 + ApiTypeError, + ApiValueError +) + + +class DefaultApi: + """NOTE: This class is auto generated by OpenAPI Generator + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + def __init__(self, api_client=None) -> None: + if api_client is None: + api_client = ApiClient.get_default() + self.api_client = api_client + + @validate_arguments + def get(self, **kwargs) -> None: # noqa: E501 + """Get # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.get(async_req=True) + >>> result = thread.get() + + :param async_req: Whether to execute the request asynchronously. + :type async_req: bool, optional + :param _request_timeout: timeout setting for this request. + If one number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :return: Returns the result object. + If the method is called asynchronously, + returns the request thread. + :rtype: None + """ + kwargs['_return_http_data_only'] = True + if '_preload_content' in kwargs: + message = "Error! Please call the get_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data" # noqa: E501 + raise ValueError(message) + return self.get_with_http_info(**kwargs) # noqa: E501 + + @validate_arguments + def get_with_http_info(self, **kwargs) -> ApiResponse: # noqa: E501 + """Get # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.get_with_http_info(async_req=True) + >>> result = thread.get() + + :param async_req: Whether to execute the request asynchronously. + :type async_req: bool, optional + :param _preload_content: if False, the ApiResponse.data will + be set to none and raw_data will store the + HTTP response body without reading/decoding. + Default is True. + :type _preload_content: bool, optional + :param _return_http_data_only: response data instead of ApiResponse + object with status code, headers, etc + :type _return_http_data_only: bool, optional + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the authentication + in the spec for a single request. + :type _request_auth: dict, optional + :type _content_type: string, optional: force content-type for the request + :return: Returns the result object. + If the method is called asynchronously, + returns the request thread. + :rtype: None + """ + + _params = locals() + + _all_params = [ + ] + _all_params.extend( + [ + 'async_req', + '_return_http_data_only', + '_preload_content', + '_request_timeout', + '_request_auth', + '_content_type', + '_headers' + ] + ) + + # validate the arguments + for _key, _val in _params['kwargs'].items(): + if _key not in _all_params: + raise ApiTypeError( + "Got an unexpected keyword argument '%s'" + " to method get" % _key + ) + _params[_key] = _val + del _params['kwargs'] + + _collection_formats = {} + + # process the path parameters + _path_params = {} + + # process the query parameters + _query_params = [] + # process the header parameters + _header_params = dict(_params.get('_headers', {})) + # process the form parameters + _form_params = [] + _files = {} + # process the body parameter + _body_params = None + # set the HTTP header `Accept` + _header_params['Accept'] = self.api_client.select_header_accept( + ['application/json']) # noqa: E501 + + # authentication setting + _auth_settings = [] # noqa: E501 + + _response_types_map = {} + + return self.api_client.call_api( + '/ws2_example', 'GET', + _path_params, + _query_params, + _header_params, + body=_body_params, + post_params=_form_params, + files=_files, + response_types_map=_response_types_map, + auth_settings=_auth_settings, + async_req=_params.get('async_req'), + _return_http_data_only=_params.get('_return_http_data_only'), # noqa: E501 + _preload_content=_params.get('_preload_content', True), + _request_timeout=_params.get('_request_timeout'), + collection_formats=_collection_formats, + _request_auth=_params.get('_request_auth')) + + @validate_arguments + def health(self, **kwargs) -> Machine: # noqa: E501 + """Health # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.health(async_req=True) + >>> result = thread.get() + + :param async_req: Whether to execute the request asynchronously. + :type async_req: bool, optional + :param _request_timeout: timeout setting for this request. + If one number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :return: Returns the result object. + If the method is called asynchronously, + returns the request thread. + :rtype: Machine + """ + kwargs['_return_http_data_only'] = True + if '_preload_content' in kwargs: + message = "Error! Please call the health_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data" # noqa: E501 + raise ValueError(message) + return self.health_with_http_info(**kwargs) # noqa: E501 + + @validate_arguments + def health_with_http_info(self, **kwargs) -> ApiResponse: # noqa: E501 + """Health # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.health_with_http_info(async_req=True) + >>> result = thread.get() + + :param async_req: Whether to execute the request asynchronously. + :type async_req: bool, optional + :param _preload_content: if False, the ApiResponse.data will + be set to none and raw_data will store the + HTTP response body without reading/decoding. + Default is True. + :type _preload_content: bool, optional + :param _return_http_data_only: response data instead of ApiResponse + object with status code, headers, etc + :type _return_http_data_only: bool, optional + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the authentication + in the spec for a single request. + :type _request_auth: dict, optional + :type _content_type: string, optional: force content-type for the request + :return: Returns the result object. + If the method is called asynchronously, + returns the request thread. + :rtype: tuple(Machine, status_code(int), headers(HTTPHeaderDict)) + """ + + _params = locals() + + _all_params = [ + ] + _all_params.extend( + [ + 'async_req', + '_return_http_data_only', + '_preload_content', + '_request_timeout', + '_request_auth', + '_content_type', + '_headers' + ] + ) + + # validate the arguments + for _key, _val in _params['kwargs'].items(): + if _key not in _all_params: + raise ApiTypeError( + "Got an unexpected keyword argument '%s'" + " to method health" % _key + ) + _params[_key] = _val + del _params['kwargs'] + + _collection_formats = {} + + # process the path parameters + _path_params = {} + + # process the query parameters + _query_params = [] + # process the header parameters + _header_params = dict(_params.get('_headers', {})) + # process the form parameters + _form_params = [] + _files = {} + # process the body parameter + _body_params = None + # set the HTTP header `Accept` + _header_params['Accept'] = self.api_client.select_header_accept( + ['application/json']) # noqa: E501 + + # authentication setting + _auth_settings = [] # noqa: E501 + + _response_types_map = { + '200': "Machine", + } + + return self.api_client.call_api( + '/health', 'GET', + _path_params, + _query_params, + _header_params, + body=_body_params, + post_params=_form_params, + files=_files, + response_types_map=_response_types_map, + auth_settings=_auth_settings, + async_req=_params.get('async_req'), + _return_http_data_only=_params.get('_return_http_data_only'), # noqa: E501 + _preload_content=_params.get('_preload_content', True), + _request_timeout=_params.get('_request_timeout'), + collection_formats=_collection_formats, + _request_auth=_params.get('_request_auth')) + + @validate_arguments + def root(self, path_name : StrictStr, **kwargs) -> None: # noqa: E501 + """Root # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.root(path_name, async_req=True) + >>> result = thread.get() + + :param path_name: (required) + :type path_name: str + :param async_req: Whether to execute the request asynchronously. + :type async_req: bool, optional + :param _request_timeout: timeout setting for this request. + If one number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :return: Returns the result object. + If the method is called asynchronously, + returns the request thread. + :rtype: None + """ + kwargs['_return_http_data_only'] = True + if '_preload_content' in kwargs: + message = "Error! Please call the root_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data" # noqa: E501 + raise ValueError(message) + return self.root_with_http_info(path_name, **kwargs) # noqa: E501 + + @validate_arguments + def root_with_http_info(self, path_name : StrictStr, **kwargs) -> ApiResponse: # noqa: E501 + """Root # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.root_with_http_info(path_name, async_req=True) + >>> result = thread.get() + + :param path_name: (required) + :type path_name: str + :param async_req: Whether to execute the request asynchronously. + :type async_req: bool, optional + :param _preload_content: if False, the ApiResponse.data will + be set to none and raw_data will store the + HTTP response body without reading/decoding. + Default is True. + :type _preload_content: bool, optional + :param _return_http_data_only: response data instead of ApiResponse + object with status code, headers, etc + :type _return_http_data_only: bool, optional + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the authentication + in the spec for a single request. + :type _request_auth: dict, optional + :type _content_type: string, optional: force content-type for the request + :return: Returns the result object. + If the method is called asynchronously, + returns the request thread. + :rtype: None + """ + + _params = locals() + + _all_params = [ + 'path_name' + ] + _all_params.extend( + [ + 'async_req', + '_return_http_data_only', + '_preload_content', + '_request_timeout', + '_request_auth', + '_content_type', + '_headers' + ] + ) + + # validate the arguments + for _key, _val in _params['kwargs'].items(): + if _key not in _all_params: + raise ApiTypeError( + "Got an unexpected keyword argument '%s'" + " to method root" % _key + ) + _params[_key] = _val + del _params['kwargs'] + + _collection_formats = {} + + # process the path parameters + _path_params = {} + if _params['path_name']: + _path_params['path_name'] = _params['path_name'] + + + # process the query parameters + _query_params = [] + # process the header parameters + _header_params = dict(_params.get('_headers', {})) + # process the form parameters + _form_params = [] + _files = {} + # process the body parameter + _body_params = None + # set the HTTP header `Accept` + _header_params['Accept'] = self.api_client.select_header_accept( + ['application/json']) # noqa: E501 + + # authentication setting + _auth_settings = [] # noqa: E501 + + _response_types_map = {} + + return self.api_client.call_api( + '/{path_name}', 'GET', + _path_params, + _query_params, + _header_params, + body=_body_params, + post_params=_form_params, + files=_files, + response_types_map=_response_types_map, + auth_settings=_auth_settings, + async_req=_params.get('async_req'), + _return_http_data_only=_params.get('_return_http_data_only'), # noqa: E501 + _preload_content=_params.get('_preload_content', True), + _request_timeout=_params.get('_request_timeout'), + collection_formats=_collection_formats, + _request_auth=_params.get('_request_auth')) diff --git a/pkgs/clan-cli/tests/openapi_client/api/entities_api.py b/pkgs/clan-cli/tests/openapi_client/api/entities_api.py new file mode 100644 index 0000000..3827b74 --- /dev/null +++ b/pkgs/clan-cli/tests/openapi_client/api/entities_api.py @@ -0,0 +1,1074 @@ +# coding: utf-8 + +""" + FastAPI + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: 0.1.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import re # noqa: F401 +import io +import warnings + +from pydantic import validate_arguments, ValidationError + +from pydantic import StrictInt, StrictStr + +from typing import Any, List, Optional + +from openapi_client.models.entity import Entity +from openapi_client.models.entity_create import EntityCreate + +from openapi_client.api_client import ApiClient +from openapi_client.api_response import ApiResponse +from openapi_client.exceptions import ( # noqa: F401 + ApiTypeError, + ApiValueError +) + + +class EntitiesApi: + """NOTE: This class is auto generated by OpenAPI Generator + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + def __init__(self, api_client=None) -> None: + if api_client is None: + api_client = ApiClient.get_default() + self.api_client = api_client + + @validate_arguments + def attach_entity(self, entity_did : StrictStr, skip : Optional[StrictInt] = None, limit : Optional[StrictInt] = None, **kwargs) -> Dict[str, str]: # noqa: E501 + """Attach Entity # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.attach_entity(entity_did, skip, limit, async_req=True) + >>> result = thread.get() + + :param entity_did: (required) + :type entity_did: str + :param skip: + :type skip: int + :param limit: + :type limit: int + :param async_req: Whether to execute the request asynchronously. + :type async_req: bool, optional + :param _request_timeout: timeout setting for this request. + If one number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :return: Returns the result object. + If the method is called asynchronously, + returns the request thread. + :rtype: Dict[str, str] + """ + kwargs['_return_http_data_only'] = True + if '_preload_content' in kwargs: + message = "Error! Please call the attach_entity_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data" # noqa: E501 + raise ValueError(message) + return self.attach_entity_with_http_info(entity_did, skip, limit, **kwargs) # noqa: E501 + + @validate_arguments + def attach_entity_with_http_info(self, entity_did : StrictStr, skip : Optional[StrictInt] = None, limit : Optional[StrictInt] = None, **kwargs) -> ApiResponse: # noqa: E501 + """Attach Entity # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.attach_entity_with_http_info(entity_did, skip, limit, async_req=True) + >>> result = thread.get() + + :param entity_did: (required) + :type entity_did: str + :param skip: + :type skip: int + :param limit: + :type limit: int + :param async_req: Whether to execute the request asynchronously. + :type async_req: bool, optional + :param _preload_content: if False, the ApiResponse.data will + be set to none and raw_data will store the + HTTP response body without reading/decoding. + Default is True. + :type _preload_content: bool, optional + :param _return_http_data_only: response data instead of ApiResponse + object with status code, headers, etc + :type _return_http_data_only: bool, optional + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the authentication + in the spec for a single request. + :type _request_auth: dict, optional + :type _content_type: string, optional: force content-type for the request + :return: Returns the result object. + If the method is called asynchronously, + returns the request thread. + :rtype: tuple(Dict[str, str], status_code(int), headers(HTTPHeaderDict)) + """ + + _params = locals() + + _all_params = [ + 'entity_did', + 'skip', + 'limit' + ] + _all_params.extend( + [ + 'async_req', + '_return_http_data_only', + '_preload_content', + '_request_timeout', + '_request_auth', + '_content_type', + '_headers' + ] + ) + + # validate the arguments + for _key, _val in _params['kwargs'].items(): + if _key not in _all_params: + raise ApiTypeError( + "Got an unexpected keyword argument '%s'" + " to method attach_entity" % _key + ) + _params[_key] = _val + del _params['kwargs'] + + _collection_formats = {} + + # process the path parameters + _path_params = {} + if _params['entity_did']: + _path_params['entity_did'] = _params['entity_did'] + + + # process the query parameters + _query_params = [] + if _params.get('skip') is not None: # noqa: E501 + _query_params.append(('skip', _params['skip'])) + + if _params.get('limit') is not None: # noqa: E501 + _query_params.append(('limit', _params['limit'])) + + # process the header parameters + _header_params = dict(_params.get('_headers', {})) + # process the form parameters + _form_params = [] + _files = {} + # process the body parameter + _body_params = None + # set the HTTP header `Accept` + _header_params['Accept'] = self.api_client.select_header_accept( + ['application/json']) # noqa: E501 + + # authentication setting + _auth_settings = [] # noqa: E501 + + _response_types_map = { + '200': "Dict[str, str]", + '422': "HTTPValidationError", + } + + return self.api_client.call_api( + '/api/v1/{entity_did}/attach', 'POST', + _path_params, + _query_params, + _header_params, + body=_body_params, + post_params=_form_params, + files=_files, + response_types_map=_response_types_map, + auth_settings=_auth_settings, + async_req=_params.get('async_req'), + _return_http_data_only=_params.get('_return_http_data_only'), # noqa: E501 + _preload_content=_params.get('_preload_content', True), + _request_timeout=_params.get('_request_timeout'), + collection_formats=_collection_formats, + _request_auth=_params.get('_request_auth')) + + @validate_arguments + def create_entity(self, entity_create : EntityCreate, **kwargs) -> Entity: # noqa: E501 + """Create Entity # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.create_entity(entity_create, async_req=True) + >>> result = thread.get() + + :param entity_create: (required) + :type entity_create: EntityCreate + :param async_req: Whether to execute the request asynchronously. + :type async_req: bool, optional + :param _request_timeout: timeout setting for this request. + If one number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :return: Returns the result object. + If the method is called asynchronously, + returns the request thread. + :rtype: Entity + """ + kwargs['_return_http_data_only'] = True + if '_preload_content' in kwargs: + message = "Error! Please call the create_entity_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data" # noqa: E501 + raise ValueError(message) + return self.create_entity_with_http_info(entity_create, **kwargs) # noqa: E501 + + @validate_arguments + def create_entity_with_http_info(self, entity_create : EntityCreate, **kwargs) -> ApiResponse: # noqa: E501 + """Create Entity # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.create_entity_with_http_info(entity_create, async_req=True) + >>> result = thread.get() + + :param entity_create: (required) + :type entity_create: EntityCreate + :param async_req: Whether to execute the request asynchronously. + :type async_req: bool, optional + :param _preload_content: if False, the ApiResponse.data will + be set to none and raw_data will store the + HTTP response body without reading/decoding. + Default is True. + :type _preload_content: bool, optional + :param _return_http_data_only: response data instead of ApiResponse + object with status code, headers, etc + :type _return_http_data_only: bool, optional + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the authentication + in the spec for a single request. + :type _request_auth: dict, optional + :type _content_type: string, optional: force content-type for the request + :return: Returns the result object. + If the method is called asynchronously, + returns the request thread. + :rtype: tuple(Entity, status_code(int), headers(HTTPHeaderDict)) + """ + + _params = locals() + + _all_params = [ + 'entity_create' + ] + _all_params.extend( + [ + 'async_req', + '_return_http_data_only', + '_preload_content', + '_request_timeout', + '_request_auth', + '_content_type', + '_headers' + ] + ) + + # validate the arguments + for _key, _val in _params['kwargs'].items(): + if _key not in _all_params: + raise ApiTypeError( + "Got an unexpected keyword argument '%s'" + " to method create_entity" % _key + ) + _params[_key] = _val + del _params['kwargs'] + + _collection_formats = {} + + # process the path parameters + _path_params = {} + + # process the query parameters + _query_params = [] + # process the header parameters + _header_params = dict(_params.get('_headers', {})) + # process the form parameters + _form_params = [] + _files = {} + # process the body parameter + _body_params = None + if _params['entity_create'] is not None: + _body_params = _params['entity_create'] + + # set the HTTP header `Accept` + _header_params['Accept'] = self.api_client.select_header_accept( + ['application/json']) # noqa: E501 + + # set the HTTP header `Content-Type` + _content_types_list = _params.get('_content_type', + self.api_client.select_header_content_type( + ['application/json'])) + if _content_types_list: + _header_params['Content-Type'] = _content_types_list + + # authentication setting + _auth_settings = [] # noqa: E501 + + _response_types_map = { + '200': "Entity", + '422': "HTTPValidationError", + } + + return self.api_client.call_api( + '/api/v1/entity', 'POST', + _path_params, + _query_params, + _header_params, + body=_body_params, + post_params=_form_params, + files=_files, + response_types_map=_response_types_map, + auth_settings=_auth_settings, + async_req=_params.get('async_req'), + _return_http_data_only=_params.get('_return_http_data_only'), # noqa: E501 + _preload_content=_params.get('_preload_content', True), + _request_timeout=_params.get('_request_timeout'), + collection_formats=_collection_formats, + _request_auth=_params.get('_request_auth')) + + @validate_arguments + def delete_entity(self, entity_did : StrictStr, **kwargs) -> Dict[str, str]: # noqa: E501 + """Delete Entity # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.delete_entity(entity_did, async_req=True) + >>> result = thread.get() + + :param entity_did: (required) + :type entity_did: str + :param async_req: Whether to execute the request asynchronously. + :type async_req: bool, optional + :param _request_timeout: timeout setting for this request. + If one number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :return: Returns the result object. + If the method is called asynchronously, + returns the request thread. + :rtype: Dict[str, str] + """ + kwargs['_return_http_data_only'] = True + if '_preload_content' in kwargs: + message = "Error! Please call the delete_entity_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data" # noqa: E501 + raise ValueError(message) + return self.delete_entity_with_http_info(entity_did, **kwargs) # noqa: E501 + + @validate_arguments + def delete_entity_with_http_info(self, entity_did : StrictStr, **kwargs) -> ApiResponse: # noqa: E501 + """Delete Entity # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.delete_entity_with_http_info(entity_did, async_req=True) + >>> result = thread.get() + + :param entity_did: (required) + :type entity_did: str + :param async_req: Whether to execute the request asynchronously. + :type async_req: bool, optional + :param _preload_content: if False, the ApiResponse.data will + be set to none and raw_data will store the + HTTP response body without reading/decoding. + Default is True. + :type _preload_content: bool, optional + :param _return_http_data_only: response data instead of ApiResponse + object with status code, headers, etc + :type _return_http_data_only: bool, optional + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the authentication + in the spec for a single request. + :type _request_auth: dict, optional + :type _content_type: string, optional: force content-type for the request + :return: Returns the result object. + If the method is called asynchronously, + returns the request thread. + :rtype: tuple(Dict[str, str], status_code(int), headers(HTTPHeaderDict)) + """ + + _params = locals() + + _all_params = [ + 'entity_did' + ] + _all_params.extend( + [ + 'async_req', + '_return_http_data_only', + '_preload_content', + '_request_timeout', + '_request_auth', + '_content_type', + '_headers' + ] + ) + + # validate the arguments + for _key, _val in _params['kwargs'].items(): + if _key not in _all_params: + raise ApiTypeError( + "Got an unexpected keyword argument '%s'" + " to method delete_entity" % _key + ) + _params[_key] = _val + del _params['kwargs'] + + _collection_formats = {} + + # process the path parameters + _path_params = {} + if _params['entity_did']: + _path_params['entity_did'] = _params['entity_did'] + + + # process the query parameters + _query_params = [] + # process the header parameters + _header_params = dict(_params.get('_headers', {})) + # process the form parameters + _form_params = [] + _files = {} + # process the body parameter + _body_params = None + # set the HTTP header `Accept` + _header_params['Accept'] = self.api_client.select_header_accept( + ['application/json']) # noqa: E501 + + # authentication setting + _auth_settings = [] # noqa: E501 + + _response_types_map = { + '200': "Dict[str, str]", + '422': "HTTPValidationError", + } + + return self.api_client.call_api( + '/api/v1/{entity_did}/entity', 'DELETE', + _path_params, + _query_params, + _header_params, + body=_body_params, + post_params=_form_params, + files=_files, + response_types_map=_response_types_map, + auth_settings=_auth_settings, + async_req=_params.get('async_req'), + _return_http_data_only=_params.get('_return_http_data_only'), # noqa: E501 + _preload_content=_params.get('_preload_content', True), + _request_timeout=_params.get('_request_timeout'), + collection_formats=_collection_formats, + _request_auth=_params.get('_request_auth')) + + @validate_arguments + def detach_entity(self, entity_did : StrictStr, skip : Optional[StrictInt] = None, limit : Optional[StrictInt] = None, **kwargs) -> Entity: # noqa: E501 + """Detach Entity # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.detach_entity(entity_did, skip, limit, async_req=True) + >>> result = thread.get() + + :param entity_did: (required) + :type entity_did: str + :param skip: + :type skip: int + :param limit: + :type limit: int + :param async_req: Whether to execute the request asynchronously. + :type async_req: bool, optional + :param _request_timeout: timeout setting for this request. + If one number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :return: Returns the result object. + If the method is called asynchronously, + returns the request thread. + :rtype: Entity + """ + kwargs['_return_http_data_only'] = True + if '_preload_content' in kwargs: + message = "Error! Please call the detach_entity_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data" # noqa: E501 + raise ValueError(message) + return self.detach_entity_with_http_info(entity_did, skip, limit, **kwargs) # noqa: E501 + + @validate_arguments + def detach_entity_with_http_info(self, entity_did : StrictStr, skip : Optional[StrictInt] = None, limit : Optional[StrictInt] = None, **kwargs) -> ApiResponse: # noqa: E501 + """Detach Entity # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.detach_entity_with_http_info(entity_did, skip, limit, async_req=True) + >>> result = thread.get() + + :param entity_did: (required) + :type entity_did: str + :param skip: + :type skip: int + :param limit: + :type limit: int + :param async_req: Whether to execute the request asynchronously. + :type async_req: bool, optional + :param _preload_content: if False, the ApiResponse.data will + be set to none and raw_data will store the + HTTP response body without reading/decoding. + Default is True. + :type _preload_content: bool, optional + :param _return_http_data_only: response data instead of ApiResponse + object with status code, headers, etc + :type _return_http_data_only: bool, optional + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the authentication + in the spec for a single request. + :type _request_auth: dict, optional + :type _content_type: string, optional: force content-type for the request + :return: Returns the result object. + If the method is called asynchronously, + returns the request thread. + :rtype: tuple(Entity, status_code(int), headers(HTTPHeaderDict)) + """ + + _params = locals() + + _all_params = [ + 'entity_did', + 'skip', + 'limit' + ] + _all_params.extend( + [ + 'async_req', + '_return_http_data_only', + '_preload_content', + '_request_timeout', + '_request_auth', + '_content_type', + '_headers' + ] + ) + + # validate the arguments + for _key, _val in _params['kwargs'].items(): + if _key not in _all_params: + raise ApiTypeError( + "Got an unexpected keyword argument '%s'" + " to method detach_entity" % _key + ) + _params[_key] = _val + del _params['kwargs'] + + _collection_formats = {} + + # process the path parameters + _path_params = {} + if _params['entity_did']: + _path_params['entity_did'] = _params['entity_did'] + + + # process the query parameters + _query_params = [] + if _params.get('skip') is not None: # noqa: E501 + _query_params.append(('skip', _params['skip'])) + + if _params.get('limit') is not None: # noqa: E501 + _query_params.append(('limit', _params['limit'])) + + # process the header parameters + _header_params = dict(_params.get('_headers', {})) + # process the form parameters + _form_params = [] + _files = {} + # process the body parameter + _body_params = None + # set the HTTP header `Accept` + _header_params['Accept'] = self.api_client.select_header_accept( + ['application/json']) # noqa: E501 + + # authentication setting + _auth_settings = [] # noqa: E501 + + _response_types_map = { + '200': "Entity", + '422': "HTTPValidationError", + } + + return self.api_client.call_api( + '/api/v1/{entity_did}/detach', 'POST', + _path_params, + _query_params, + _header_params, + body=_body_params, + post_params=_form_params, + files=_files, + response_types_map=_response_types_map, + auth_settings=_auth_settings, + async_req=_params.get('async_req'), + _return_http_data_only=_params.get('_return_http_data_only'), # noqa: E501 + _preload_content=_params.get('_preload_content', True), + _request_timeout=_params.get('_request_timeout'), + collection_formats=_collection_formats, + _request_auth=_params.get('_request_auth')) + + @validate_arguments + def get_all_entities(self, skip : Optional[StrictInt] = None, limit : Optional[StrictInt] = None, **kwargs) -> List[Entity]: # noqa: E501 + """Get All Entities # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.get_all_entities(skip, limit, async_req=True) + >>> result = thread.get() + + :param skip: + :type skip: int + :param limit: + :type limit: int + :param async_req: Whether to execute the request asynchronously. + :type async_req: bool, optional + :param _request_timeout: timeout setting for this request. + If one number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :return: Returns the result object. + If the method is called asynchronously, + returns the request thread. + :rtype: List[Entity] + """ + kwargs['_return_http_data_only'] = True + if '_preload_content' in kwargs: + message = "Error! Please call the get_all_entities_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data" # noqa: E501 + raise ValueError(message) + return self.get_all_entities_with_http_info(skip, limit, **kwargs) # noqa: E501 + + @validate_arguments + def get_all_entities_with_http_info(self, skip : Optional[StrictInt] = None, limit : Optional[StrictInt] = None, **kwargs) -> ApiResponse: # noqa: E501 + """Get All Entities # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.get_all_entities_with_http_info(skip, limit, async_req=True) + >>> result = thread.get() + + :param skip: + :type skip: int + :param limit: + :type limit: int + :param async_req: Whether to execute the request asynchronously. + :type async_req: bool, optional + :param _preload_content: if False, the ApiResponse.data will + be set to none and raw_data will store the + HTTP response body without reading/decoding. + Default is True. + :type _preload_content: bool, optional + :param _return_http_data_only: response data instead of ApiResponse + object with status code, headers, etc + :type _return_http_data_only: bool, optional + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the authentication + in the spec for a single request. + :type _request_auth: dict, optional + :type _content_type: string, optional: force content-type for the request + :return: Returns the result object. + If the method is called asynchronously, + returns the request thread. + :rtype: tuple(List[Entity], status_code(int), headers(HTTPHeaderDict)) + """ + + _params = locals() + + _all_params = [ + 'skip', + 'limit' + ] + _all_params.extend( + [ + 'async_req', + '_return_http_data_only', + '_preload_content', + '_request_timeout', + '_request_auth', + '_content_type', + '_headers' + ] + ) + + # validate the arguments + for _key, _val in _params['kwargs'].items(): + if _key not in _all_params: + raise ApiTypeError( + "Got an unexpected keyword argument '%s'" + " to method get_all_entities" % _key + ) + _params[_key] = _val + del _params['kwargs'] + + _collection_formats = {} + + # process the path parameters + _path_params = {} + + # process the query parameters + _query_params = [] + if _params.get('skip') is not None: # noqa: E501 + _query_params.append(('skip', _params['skip'])) + + if _params.get('limit') is not None: # noqa: E501 + _query_params.append(('limit', _params['limit'])) + + # process the header parameters + _header_params = dict(_params.get('_headers', {})) + # process the form parameters + _form_params = [] + _files = {} + # process the body parameter + _body_params = None + # set the HTTP header `Accept` + _header_params['Accept'] = self.api_client.select_header_accept( + ['application/json']) # noqa: E501 + + # authentication setting + _auth_settings = [] # noqa: E501 + + _response_types_map = { + '200': "List[Entity]", + '422': "HTTPValidationError", + } + + return self.api_client.call_api( + '/api/v1/entities', 'GET', + _path_params, + _query_params, + _header_params, + body=_body_params, + post_params=_form_params, + files=_files, + response_types_map=_response_types_map, + auth_settings=_auth_settings, + async_req=_params.get('async_req'), + _return_http_data_only=_params.get('_return_http_data_only'), # noqa: E501 + _preload_content=_params.get('_preload_content', True), + _request_timeout=_params.get('_request_timeout'), + collection_formats=_collection_formats, + _request_auth=_params.get('_request_auth')) + + @validate_arguments + def get_attached_entities(self, skip : Optional[StrictInt] = None, limit : Optional[StrictInt] = None, **kwargs) -> List[Entity]: # noqa: E501 + """Get Attached Entities # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.get_attached_entities(skip, limit, async_req=True) + >>> result = thread.get() + + :param skip: + :type skip: int + :param limit: + :type limit: int + :param async_req: Whether to execute the request asynchronously. + :type async_req: bool, optional + :param _request_timeout: timeout setting for this request. + If one number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :return: Returns the result object. + If the method is called asynchronously, + returns the request thread. + :rtype: List[Entity] + """ + kwargs['_return_http_data_only'] = True + if '_preload_content' in kwargs: + message = "Error! Please call the get_attached_entities_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data" # noqa: E501 + raise ValueError(message) + return self.get_attached_entities_with_http_info(skip, limit, **kwargs) # noqa: E501 + + @validate_arguments + def get_attached_entities_with_http_info(self, skip : Optional[StrictInt] = None, limit : Optional[StrictInt] = None, **kwargs) -> ApiResponse: # noqa: E501 + """Get Attached Entities # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.get_attached_entities_with_http_info(skip, limit, async_req=True) + >>> result = thread.get() + + :param skip: + :type skip: int + :param limit: + :type limit: int + :param async_req: Whether to execute the request asynchronously. + :type async_req: bool, optional + :param _preload_content: if False, the ApiResponse.data will + be set to none and raw_data will store the + HTTP response body without reading/decoding. + Default is True. + :type _preload_content: bool, optional + :param _return_http_data_only: response data instead of ApiResponse + object with status code, headers, etc + :type _return_http_data_only: bool, optional + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the authentication + in the spec for a single request. + :type _request_auth: dict, optional + :type _content_type: string, optional: force content-type for the request + :return: Returns the result object. + If the method is called asynchronously, + returns the request thread. + :rtype: tuple(List[Entity], status_code(int), headers(HTTPHeaderDict)) + """ + + _params = locals() + + _all_params = [ + 'skip', + 'limit' + ] + _all_params.extend( + [ + 'async_req', + '_return_http_data_only', + '_preload_content', + '_request_timeout', + '_request_auth', + '_content_type', + '_headers' + ] + ) + + # validate the arguments + for _key, _val in _params['kwargs'].items(): + if _key not in _all_params: + raise ApiTypeError( + "Got an unexpected keyword argument '%s'" + " to method get_attached_entities" % _key + ) + _params[_key] = _val + del _params['kwargs'] + + _collection_formats = {} + + # process the path parameters + _path_params = {} + + # process the query parameters + _query_params = [] + if _params.get('skip') is not None: # noqa: E501 + _query_params.append(('skip', _params['skip'])) + + if _params.get('limit') is not None: # noqa: E501 + _query_params.append(('limit', _params['limit'])) + + # process the header parameters + _header_params = dict(_params.get('_headers', {})) + # process the form parameters + _form_params = [] + _files = {} + # process the body parameter + _body_params = None + # set the HTTP header `Accept` + _header_params['Accept'] = self.api_client.select_header_accept( + ['application/json']) # noqa: E501 + + # authentication setting + _auth_settings = [] # noqa: E501 + + _response_types_map = { + '200': "List[Entity]", + '422': "HTTPValidationError", + } + + return self.api_client.call_api( + '/api/v1/attached_entities', 'GET', + _path_params, + _query_params, + _header_params, + body=_body_params, + post_params=_form_params, + files=_files, + response_types_map=_response_types_map, + auth_settings=_auth_settings, + async_req=_params.get('async_req'), + _return_http_data_only=_params.get('_return_http_data_only'), # noqa: E501 + _preload_content=_params.get('_preload_content', True), + _request_timeout=_params.get('_request_timeout'), + collection_formats=_collection_formats, + _request_auth=_params.get('_request_auth')) + + @validate_arguments + def get_entity_by_did(self, entity_did : StrictStr, **kwargs) -> Entity: # noqa: E501 + """Get Entity By Did # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.get_entity_by_did(entity_did, async_req=True) + >>> result = thread.get() + + :param entity_did: (required) + :type entity_did: str + :param async_req: Whether to execute the request asynchronously. + :type async_req: bool, optional + :param _request_timeout: timeout setting for this request. + If one number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :return: Returns the result object. + If the method is called asynchronously, + returns the request thread. + :rtype: Entity + """ + kwargs['_return_http_data_only'] = True + if '_preload_content' in kwargs: + message = "Error! Please call the get_entity_by_did_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data" # noqa: E501 + raise ValueError(message) + return self.get_entity_by_did_with_http_info(entity_did, **kwargs) # noqa: E501 + + @validate_arguments + def get_entity_by_did_with_http_info(self, entity_did : StrictStr, **kwargs) -> ApiResponse: # noqa: E501 + """Get Entity By Did # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.get_entity_by_did_with_http_info(entity_did, async_req=True) + >>> result = thread.get() + + :param entity_did: (required) + :type entity_did: str + :param async_req: Whether to execute the request asynchronously. + :type async_req: bool, optional + :param _preload_content: if False, the ApiResponse.data will + be set to none and raw_data will store the + HTTP response body without reading/decoding. + Default is True. + :type _preload_content: bool, optional + :param _return_http_data_only: response data instead of ApiResponse + object with status code, headers, etc + :type _return_http_data_only: bool, optional + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the authentication + in the spec for a single request. + :type _request_auth: dict, optional + :type _content_type: string, optional: force content-type for the request + :return: Returns the result object. + If the method is called asynchronously, + returns the request thread. + :rtype: tuple(Entity, status_code(int), headers(HTTPHeaderDict)) + """ + + _params = locals() + + _all_params = [ + 'entity_did' + ] + _all_params.extend( + [ + 'async_req', + '_return_http_data_only', + '_preload_content', + '_request_timeout', + '_request_auth', + '_content_type', + '_headers' + ] + ) + + # validate the arguments + for _key, _val in _params['kwargs'].items(): + if _key not in _all_params: + raise ApiTypeError( + "Got an unexpected keyword argument '%s'" + " to method get_entity_by_did" % _key + ) + _params[_key] = _val + del _params['kwargs'] + + _collection_formats = {} + + # process the path parameters + _path_params = {} + if _params['entity_did']: + _path_params['entity_did'] = _params['entity_did'] + + + # process the query parameters + _query_params = [] + # process the header parameters + _header_params = dict(_params.get('_headers', {})) + # process the form parameters + _form_params = [] + _files = {} + # process the body parameter + _body_params = None + # set the HTTP header `Accept` + _header_params['Accept'] = self.api_client.select_header_accept( + ['application/json']) # noqa: E501 + + # authentication setting + _auth_settings = [] # noqa: E501 + + _response_types_map = { + '200': "Entity", + '422': "HTTPValidationError", + } + + return self.api_client.call_api( + '/api/v1/{entity_did}/entity', 'GET', + _path_params, + _query_params, + _header_params, + body=_body_params, + post_params=_form_params, + files=_files, + response_types_map=_response_types_map, + auth_settings=_auth_settings, + async_req=_params.get('async_req'), + _return_http_data_only=_params.get('_return_http_data_only'), # noqa: E501 + _preload_content=_params.get('_preload_content', True), + _request_timeout=_params.get('_request_timeout'), + collection_formats=_collection_formats, + _request_auth=_params.get('_request_auth')) diff --git a/pkgs/clan-cli/tests/openapi_client/api/repositories_api.py b/pkgs/clan-cli/tests/openapi_client/api/repositories_api.py new file mode 100644 index 0000000..bedb1e3 --- /dev/null +++ b/pkgs/clan-cli/tests/openapi_client/api/repositories_api.py @@ -0,0 +1,192 @@ +# coding: utf-8 + +""" + FastAPI + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: 0.1.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import re # noqa: F401 +import io +import warnings + +from pydantic import validate_arguments, ValidationError + +from pydantic import StrictInt + +from typing import List, Optional + +from openapi_client.models.service import Service + +from openapi_client.api_client import ApiClient +from openapi_client.api_response import ApiResponse +from openapi_client.exceptions import ( # noqa: F401 + ApiTypeError, + ApiValueError +) + + +class RepositoriesApi: + """NOTE: This class is auto generated by OpenAPI Generator + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + def __init__(self, api_client=None) -> None: + if api_client is None: + api_client = ApiClient.get_default() + self.api_client = api_client + + @validate_arguments + def get_all_repositories(self, skip : Optional[StrictInt] = None, limit : Optional[StrictInt] = None, **kwargs) -> List[Service]: # noqa: E501 + """Get All Repositories # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.get_all_repositories(skip, limit, async_req=True) + >>> result = thread.get() + + :param skip: + :type skip: int + :param limit: + :type limit: int + :param async_req: Whether to execute the request asynchronously. + :type async_req: bool, optional + :param _request_timeout: timeout setting for this request. + If one number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :return: Returns the result object. + If the method is called asynchronously, + returns the request thread. + :rtype: List[Service] + """ + kwargs['_return_http_data_only'] = True + if '_preload_content' in kwargs: + message = "Error! Please call the get_all_repositories_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data" # noqa: E501 + raise ValueError(message) + return self.get_all_repositories_with_http_info(skip, limit, **kwargs) # noqa: E501 + + @validate_arguments + def get_all_repositories_with_http_info(self, skip : Optional[StrictInt] = None, limit : Optional[StrictInt] = None, **kwargs) -> ApiResponse: # noqa: E501 + """Get All Repositories # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.get_all_repositories_with_http_info(skip, limit, async_req=True) + >>> result = thread.get() + + :param skip: + :type skip: int + :param limit: + :type limit: int + :param async_req: Whether to execute the request asynchronously. + :type async_req: bool, optional + :param _preload_content: if False, the ApiResponse.data will + be set to none and raw_data will store the + HTTP response body without reading/decoding. + Default is True. + :type _preload_content: bool, optional + :param _return_http_data_only: response data instead of ApiResponse + object with status code, headers, etc + :type _return_http_data_only: bool, optional + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the authentication + in the spec for a single request. + :type _request_auth: dict, optional + :type _content_type: string, optional: force content-type for the request + :return: Returns the result object. + If the method is called asynchronously, + returns the request thread. + :rtype: tuple(List[Service], status_code(int), headers(HTTPHeaderDict)) + """ + + _params = locals() + + _all_params = [ + 'skip', + 'limit' + ] + _all_params.extend( + [ + 'async_req', + '_return_http_data_only', + '_preload_content', + '_request_timeout', + '_request_auth', + '_content_type', + '_headers' + ] + ) + + # validate the arguments + for _key, _val in _params['kwargs'].items(): + if _key not in _all_params: + raise ApiTypeError( + "Got an unexpected keyword argument '%s'" + " to method get_all_repositories" % _key + ) + _params[_key] = _val + del _params['kwargs'] + + _collection_formats = {} + + # process the path parameters + _path_params = {} + + # process the query parameters + _query_params = [] + if _params.get('skip') is not None: # noqa: E501 + _query_params.append(('skip', _params['skip'])) + + if _params.get('limit') is not None: # noqa: E501 + _query_params.append(('limit', _params['limit'])) + + # process the header parameters + _header_params = dict(_params.get('_headers', {})) + # process the form parameters + _form_params = [] + _files = {} + # process the body parameter + _body_params = None + # set the HTTP header `Accept` + _header_params['Accept'] = self.api_client.select_header_accept( + ['application/json']) # noqa: E501 + + # authentication setting + _auth_settings = [] # noqa: E501 + + _response_types_map = { + '200': "List[Service]", + '422': "HTTPValidationError", + } + + return self.api_client.call_api( + '/api/v1/repositories', 'GET', + _path_params, + _query_params, + _header_params, + body=_body_params, + post_params=_form_params, + files=_files, + response_types_map=_response_types_map, + auth_settings=_auth_settings, + async_req=_params.get('async_req'), + _return_http_data_only=_params.get('_return_http_data_only'), # noqa: E501 + _preload_content=_params.get('_preload_content', True), + _request_timeout=_params.get('_request_timeout'), + collection_formats=_collection_formats, + _request_auth=_params.get('_request_auth')) diff --git a/pkgs/clan-cli/tests/openapi_client/api/resolution_api.py b/pkgs/clan-cli/tests/openapi_client/api/resolution_api.py new file mode 100644 index 0000000..e054beb --- /dev/null +++ b/pkgs/clan-cli/tests/openapi_client/api/resolution_api.py @@ -0,0 +1,192 @@ +# coding: utf-8 + +""" + FastAPI + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: 0.1.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import re # noqa: F401 +import io +import warnings + +from pydantic import validate_arguments, ValidationError + +from pydantic import StrictInt + +from typing import List, Optional + +from openapi_client.models.resolution import Resolution + +from openapi_client.api_client import ApiClient +from openapi_client.api_response import ApiResponse +from openapi_client.exceptions import ( # noqa: F401 + ApiTypeError, + ApiValueError +) + + +class ResolutionApi: + """NOTE: This class is auto generated by OpenAPI Generator + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + def __init__(self, api_client=None) -> None: + if api_client is None: + api_client = ApiClient.get_default() + self.api_client = api_client + + @validate_arguments + def get_all_resolutions(self, skip : Optional[StrictInt] = None, limit : Optional[StrictInt] = None, **kwargs) -> List[Resolution]: # noqa: E501 + """Get All Resolutions # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.get_all_resolutions(skip, limit, async_req=True) + >>> result = thread.get() + + :param skip: + :type skip: int + :param limit: + :type limit: int + :param async_req: Whether to execute the request asynchronously. + :type async_req: bool, optional + :param _request_timeout: timeout setting for this request. + If one number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :return: Returns the result object. + If the method is called asynchronously, + returns the request thread. + :rtype: List[Resolution] + """ + kwargs['_return_http_data_only'] = True + if '_preload_content' in kwargs: + message = "Error! Please call the get_all_resolutions_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data" # noqa: E501 + raise ValueError(message) + return self.get_all_resolutions_with_http_info(skip, limit, **kwargs) # noqa: E501 + + @validate_arguments + def get_all_resolutions_with_http_info(self, skip : Optional[StrictInt] = None, limit : Optional[StrictInt] = None, **kwargs) -> ApiResponse: # noqa: E501 + """Get All Resolutions # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.get_all_resolutions_with_http_info(skip, limit, async_req=True) + >>> result = thread.get() + + :param skip: + :type skip: int + :param limit: + :type limit: int + :param async_req: Whether to execute the request asynchronously. + :type async_req: bool, optional + :param _preload_content: if False, the ApiResponse.data will + be set to none and raw_data will store the + HTTP response body without reading/decoding. + Default is True. + :type _preload_content: bool, optional + :param _return_http_data_only: response data instead of ApiResponse + object with status code, headers, etc + :type _return_http_data_only: bool, optional + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the authentication + in the spec for a single request. + :type _request_auth: dict, optional + :type _content_type: string, optional: force content-type for the request + :return: Returns the result object. + If the method is called asynchronously, + returns the request thread. + :rtype: tuple(List[Resolution], status_code(int), headers(HTTPHeaderDict)) + """ + + _params = locals() + + _all_params = [ + 'skip', + 'limit' + ] + _all_params.extend( + [ + 'async_req', + '_return_http_data_only', + '_preload_content', + '_request_timeout', + '_request_auth', + '_content_type', + '_headers' + ] + ) + + # validate the arguments + for _key, _val in _params['kwargs'].items(): + if _key not in _all_params: + raise ApiTypeError( + "Got an unexpected keyword argument '%s'" + " to method get_all_resolutions" % _key + ) + _params[_key] = _val + del _params['kwargs'] + + _collection_formats = {} + + # process the path parameters + _path_params = {} + + # process the query parameters + _query_params = [] + if _params.get('skip') is not None: # noqa: E501 + _query_params.append(('skip', _params['skip'])) + + if _params.get('limit') is not None: # noqa: E501 + _query_params.append(('limit', _params['limit'])) + + # process the header parameters + _header_params = dict(_params.get('_headers', {})) + # process the form parameters + _form_params = [] + _files = {} + # process the body parameter + _body_params = None + # set the HTTP header `Accept` + _header_params['Accept'] = self.api_client.select_header_accept( + ['application/json']) # noqa: E501 + + # authentication setting + _auth_settings = [] # noqa: E501 + + _response_types_map = { + '200': "List[Resolution]", + '422': "HTTPValidationError", + } + + return self.api_client.call_api( + '/api/v1/resolutions', 'GET', + _path_params, + _query_params, + _header_params, + body=_body_params, + post_params=_form_params, + files=_files, + response_types_map=_response_types_map, + auth_settings=_auth_settings, + async_req=_params.get('async_req'), + _return_http_data_only=_params.get('_return_http_data_only'), # noqa: E501 + _preload_content=_params.get('_preload_content', True), + _request_timeout=_params.get('_request_timeout'), + collection_formats=_collection_formats, + _request_auth=_params.get('_request_auth')) diff --git a/pkgs/clan-cli/tests/openapi_client/api/services_api.py b/pkgs/clan-cli/tests/openapi_client/api/services_api.py new file mode 100644 index 0000000..d7de01f --- /dev/null +++ b/pkgs/clan-cli/tests/openapi_client/api/services_api.py @@ -0,0 +1,633 @@ +# coding: utf-8 + +""" + FastAPI + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: 0.1.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import re # noqa: F401 +import io +import warnings + +from pydantic import validate_arguments, ValidationError + +from pydantic import StrictInt, StrictStr + +from typing import Any, List, Optional + +from openapi_client.models.service import Service +from openapi_client.models.service_create import ServiceCreate + +from openapi_client.api_client import ApiClient +from openapi_client.api_response import ApiResponse +from openapi_client.exceptions import ( # noqa: F401 + ApiTypeError, + ApiValueError +) + + +class ServicesApi: + """NOTE: This class is auto generated by OpenAPI Generator + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + def __init__(self, api_client=None) -> None: + if api_client is None: + api_client = ApiClient.get_default() + self.api_client = api_client + + @validate_arguments + def create_service(self, service_create : ServiceCreate, **kwargs) -> Service: # noqa: E501 + """Create Service # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.create_service(service_create, async_req=True) + >>> result = thread.get() + + :param service_create: (required) + :type service_create: ServiceCreate + :param async_req: Whether to execute the request asynchronously. + :type async_req: bool, optional + :param _request_timeout: timeout setting for this request. + If one number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :return: Returns the result object. + If the method is called asynchronously, + returns the request thread. + :rtype: Service + """ + kwargs['_return_http_data_only'] = True + if '_preload_content' in kwargs: + message = "Error! Please call the create_service_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data" # noqa: E501 + raise ValueError(message) + return self.create_service_with_http_info(service_create, **kwargs) # noqa: E501 + + @validate_arguments + def create_service_with_http_info(self, service_create : ServiceCreate, **kwargs) -> ApiResponse: # noqa: E501 + """Create Service # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.create_service_with_http_info(service_create, async_req=True) + >>> result = thread.get() + + :param service_create: (required) + :type service_create: ServiceCreate + :param async_req: Whether to execute the request asynchronously. + :type async_req: bool, optional + :param _preload_content: if False, the ApiResponse.data will + be set to none and raw_data will store the + HTTP response body without reading/decoding. + Default is True. + :type _preload_content: bool, optional + :param _return_http_data_only: response data instead of ApiResponse + object with status code, headers, etc + :type _return_http_data_only: bool, optional + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the authentication + in the spec for a single request. + :type _request_auth: dict, optional + :type _content_type: string, optional: force content-type for the request + :return: Returns the result object. + If the method is called asynchronously, + returns the request thread. + :rtype: tuple(Service, status_code(int), headers(HTTPHeaderDict)) + """ + + _params = locals() + + _all_params = [ + 'service_create' + ] + _all_params.extend( + [ + 'async_req', + '_return_http_data_only', + '_preload_content', + '_request_timeout', + '_request_auth', + '_content_type', + '_headers' + ] + ) + + # validate the arguments + for _key, _val in _params['kwargs'].items(): + if _key not in _all_params: + raise ApiTypeError( + "Got an unexpected keyword argument '%s'" + " to method create_service" % _key + ) + _params[_key] = _val + del _params['kwargs'] + + _collection_formats = {} + + # process the path parameters + _path_params = {} + + # process the query parameters + _query_params = [] + # process the header parameters + _header_params = dict(_params.get('_headers', {})) + # process the form parameters + _form_params = [] + _files = {} + # process the body parameter + _body_params = None + if _params['service_create'] is not None: + _body_params = _params['service_create'] + + # set the HTTP header `Accept` + _header_params['Accept'] = self.api_client.select_header_accept( + ['application/json']) # noqa: E501 + + # set the HTTP header `Content-Type` + _content_types_list = _params.get('_content_type', + self.api_client.select_header_content_type( + ['application/json'])) + if _content_types_list: + _header_params['Content-Type'] = _content_types_list + + # authentication setting + _auth_settings = [] # noqa: E501 + + _response_types_map = { + '200': "Service", + '422': "HTTPValidationError", + } + + return self.api_client.call_api( + '/api/v1/service', 'POST', + _path_params, + _query_params, + _header_params, + body=_body_params, + post_params=_form_params, + files=_files, + response_types_map=_response_types_map, + auth_settings=_auth_settings, + async_req=_params.get('async_req'), + _return_http_data_only=_params.get('_return_http_data_only'), # noqa: E501 + _preload_content=_params.get('_preload_content', True), + _request_timeout=_params.get('_request_timeout'), + collection_formats=_collection_formats, + _request_auth=_params.get('_request_auth')) + + @validate_arguments + def delete_service(self, entity_did : StrictStr, **kwargs) -> Dict[str, str]: # noqa: E501 + """Delete Service # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.delete_service(entity_did, async_req=True) + >>> result = thread.get() + + :param entity_did: (required) + :type entity_did: str + :param async_req: Whether to execute the request asynchronously. + :type async_req: bool, optional + :param _request_timeout: timeout setting for this request. + If one number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :return: Returns the result object. + If the method is called asynchronously, + returns the request thread. + :rtype: Dict[str, str] + """ + kwargs['_return_http_data_only'] = True + if '_preload_content' in kwargs: + message = "Error! Please call the delete_service_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data" # noqa: E501 + raise ValueError(message) + return self.delete_service_with_http_info(entity_did, **kwargs) # noqa: E501 + + @validate_arguments + def delete_service_with_http_info(self, entity_did : StrictStr, **kwargs) -> ApiResponse: # noqa: E501 + """Delete Service # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.delete_service_with_http_info(entity_did, async_req=True) + >>> result = thread.get() + + :param entity_did: (required) + :type entity_did: str + :param async_req: Whether to execute the request asynchronously. + :type async_req: bool, optional + :param _preload_content: if False, the ApiResponse.data will + be set to none and raw_data will store the + HTTP response body without reading/decoding. + Default is True. + :type _preload_content: bool, optional + :param _return_http_data_only: response data instead of ApiResponse + object with status code, headers, etc + :type _return_http_data_only: bool, optional + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the authentication + in the spec for a single request. + :type _request_auth: dict, optional + :type _content_type: string, optional: force content-type for the request + :return: Returns the result object. + If the method is called asynchronously, + returns the request thread. + :rtype: tuple(Dict[str, str], status_code(int), headers(HTTPHeaderDict)) + """ + + _params = locals() + + _all_params = [ + 'entity_did' + ] + _all_params.extend( + [ + 'async_req', + '_return_http_data_only', + '_preload_content', + '_request_timeout', + '_request_auth', + '_content_type', + '_headers' + ] + ) + + # validate the arguments + for _key, _val in _params['kwargs'].items(): + if _key not in _all_params: + raise ApiTypeError( + "Got an unexpected keyword argument '%s'" + " to method delete_service" % _key + ) + _params[_key] = _val + del _params['kwargs'] + + _collection_formats = {} + + # process the path parameters + _path_params = {} + if _params['entity_did']: + _path_params['entity_did'] = _params['entity_did'] + + + # process the query parameters + _query_params = [] + # process the header parameters + _header_params = dict(_params.get('_headers', {})) + # process the form parameters + _form_params = [] + _files = {} + # process the body parameter + _body_params = None + # set the HTTP header `Accept` + _header_params['Accept'] = self.api_client.select_header_accept( + ['application/json']) # noqa: E501 + + # authentication setting + _auth_settings = [] # noqa: E501 + + _response_types_map = { + '200': "Dict[str, str]", + '422': "HTTPValidationError", + } + + return self.api_client.call_api( + '/api/v1/{entity_did}/service', 'DELETE', + _path_params, + _query_params, + _header_params, + body=_body_params, + post_params=_form_params, + files=_files, + response_types_map=_response_types_map, + auth_settings=_auth_settings, + async_req=_params.get('async_req'), + _return_http_data_only=_params.get('_return_http_data_only'), # noqa: E501 + _preload_content=_params.get('_preload_content', True), + _request_timeout=_params.get('_request_timeout'), + collection_formats=_collection_formats, + _request_auth=_params.get('_request_auth')) + + @validate_arguments + def get_all_services(self, skip : Optional[StrictInt] = None, limit : Optional[StrictInt] = None, **kwargs) -> List[Service]: # noqa: E501 + """Get All Services # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.get_all_services(skip, limit, async_req=True) + >>> result = thread.get() + + :param skip: + :type skip: int + :param limit: + :type limit: int + :param async_req: Whether to execute the request asynchronously. + :type async_req: bool, optional + :param _request_timeout: timeout setting for this request. + If one number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :return: Returns the result object. + If the method is called asynchronously, + returns the request thread. + :rtype: List[Service] + """ + kwargs['_return_http_data_only'] = True + if '_preload_content' in kwargs: + message = "Error! Please call the get_all_services_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data" # noqa: E501 + raise ValueError(message) + return self.get_all_services_with_http_info(skip, limit, **kwargs) # noqa: E501 + + @validate_arguments + def get_all_services_with_http_info(self, skip : Optional[StrictInt] = None, limit : Optional[StrictInt] = None, **kwargs) -> ApiResponse: # noqa: E501 + """Get All Services # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.get_all_services_with_http_info(skip, limit, async_req=True) + >>> result = thread.get() + + :param skip: + :type skip: int + :param limit: + :type limit: int + :param async_req: Whether to execute the request asynchronously. + :type async_req: bool, optional + :param _preload_content: if False, the ApiResponse.data will + be set to none and raw_data will store the + HTTP response body without reading/decoding. + Default is True. + :type _preload_content: bool, optional + :param _return_http_data_only: response data instead of ApiResponse + object with status code, headers, etc + :type _return_http_data_only: bool, optional + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the authentication + in the spec for a single request. + :type _request_auth: dict, optional + :type _content_type: string, optional: force content-type for the request + :return: Returns the result object. + If the method is called asynchronously, + returns the request thread. + :rtype: tuple(List[Service], status_code(int), headers(HTTPHeaderDict)) + """ + + _params = locals() + + _all_params = [ + 'skip', + 'limit' + ] + _all_params.extend( + [ + 'async_req', + '_return_http_data_only', + '_preload_content', + '_request_timeout', + '_request_auth', + '_content_type', + '_headers' + ] + ) + + # validate the arguments + for _key, _val in _params['kwargs'].items(): + if _key not in _all_params: + raise ApiTypeError( + "Got an unexpected keyword argument '%s'" + " to method get_all_services" % _key + ) + _params[_key] = _val + del _params['kwargs'] + + _collection_formats = {} + + # process the path parameters + _path_params = {} + + # process the query parameters + _query_params = [] + if _params.get('skip') is not None: # noqa: E501 + _query_params.append(('skip', _params['skip'])) + + if _params.get('limit') is not None: # noqa: E501 + _query_params.append(('limit', _params['limit'])) + + # process the header parameters + _header_params = dict(_params.get('_headers', {})) + # process the form parameters + _form_params = [] + _files = {} + # process the body parameter + _body_params = None + # set the HTTP header `Accept` + _header_params['Accept'] = self.api_client.select_header_accept( + ['application/json']) # noqa: E501 + + # authentication setting + _auth_settings = [] # noqa: E501 + + _response_types_map = { + '200': "List[Service]", + '422': "HTTPValidationError", + } + + return self.api_client.call_api( + '/api/v1/services', 'GET', + _path_params, + _query_params, + _header_params, + body=_body_params, + post_params=_form_params, + files=_files, + response_types_map=_response_types_map, + auth_settings=_auth_settings, + async_req=_params.get('async_req'), + _return_http_data_only=_params.get('_return_http_data_only'), # noqa: E501 + _preload_content=_params.get('_preload_content', True), + _request_timeout=_params.get('_request_timeout'), + collection_formats=_collection_formats, + _request_auth=_params.get('_request_auth')) + + @validate_arguments + def get_service_by_did(self, entity_did : StrictStr, skip : Optional[StrictInt] = None, limit : Optional[StrictInt] = None, **kwargs) -> List[Service]: # noqa: E501 + """Get Service By Did # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.get_service_by_did(entity_did, skip, limit, async_req=True) + >>> result = thread.get() + + :param entity_did: (required) + :type entity_did: str + :param skip: + :type skip: int + :param limit: + :type limit: int + :param async_req: Whether to execute the request asynchronously. + :type async_req: bool, optional + :param _request_timeout: timeout setting for this request. + If one number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :return: Returns the result object. + If the method is called asynchronously, + returns the request thread. + :rtype: List[Service] + """ + kwargs['_return_http_data_only'] = True + if '_preload_content' in kwargs: + message = "Error! Please call the get_service_by_did_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data" # noqa: E501 + raise ValueError(message) + return self.get_service_by_did_with_http_info(entity_did, skip, limit, **kwargs) # noqa: E501 + + @validate_arguments + def get_service_by_did_with_http_info(self, entity_did : StrictStr, skip : Optional[StrictInt] = None, limit : Optional[StrictInt] = None, **kwargs) -> ApiResponse: # noqa: E501 + """Get Service By Did # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.get_service_by_did_with_http_info(entity_did, skip, limit, async_req=True) + >>> result = thread.get() + + :param entity_did: (required) + :type entity_did: str + :param skip: + :type skip: int + :param limit: + :type limit: int + :param async_req: Whether to execute the request asynchronously. + :type async_req: bool, optional + :param _preload_content: if False, the ApiResponse.data will + be set to none and raw_data will store the + HTTP response body without reading/decoding. + Default is True. + :type _preload_content: bool, optional + :param _return_http_data_only: response data instead of ApiResponse + object with status code, headers, etc + :type _return_http_data_only: bool, optional + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the authentication + in the spec for a single request. + :type _request_auth: dict, optional + :type _content_type: string, optional: force content-type for the request + :return: Returns the result object. + If the method is called asynchronously, + returns the request thread. + :rtype: tuple(List[Service], status_code(int), headers(HTTPHeaderDict)) + """ + + _params = locals() + + _all_params = [ + 'entity_did', + 'skip', + 'limit' + ] + _all_params.extend( + [ + 'async_req', + '_return_http_data_only', + '_preload_content', + '_request_timeout', + '_request_auth', + '_content_type', + '_headers' + ] + ) + + # validate the arguments + for _key, _val in _params['kwargs'].items(): + if _key not in _all_params: + raise ApiTypeError( + "Got an unexpected keyword argument '%s'" + " to method get_service_by_did" % _key + ) + _params[_key] = _val + del _params['kwargs'] + + _collection_formats = {} + + # process the path parameters + _path_params = {} + if _params['entity_did']: + _path_params['entity_did'] = _params['entity_did'] + + + # process the query parameters + _query_params = [] + if _params.get('skip') is not None: # noqa: E501 + _query_params.append(('skip', _params['skip'])) + + if _params.get('limit') is not None: # noqa: E501 + _query_params.append(('limit', _params['limit'])) + + # process the header parameters + _header_params = dict(_params.get('_headers', {})) + # process the form parameters + _form_params = [] + _files = {} + # process the body parameter + _body_params = None + # set the HTTP header `Accept` + _header_params['Accept'] = self.api_client.select_header_accept( + ['application/json']) # noqa: E501 + + # authentication setting + _auth_settings = [] # noqa: E501 + + _response_types_map = { + '200': "List[Service]", + '422': "HTTPValidationError", + } + + return self.api_client.call_api( + '/api/v1/{entity_did}/service', 'GET', + _path_params, + _query_params, + _header_params, + body=_body_params, + post_params=_form_params, + files=_files, + response_types_map=_response_types_map, + auth_settings=_auth_settings, + async_req=_params.get('async_req'), + _return_http_data_only=_params.get('_return_http_data_only'), # noqa: E501 + _preload_content=_params.get('_preload_content', True), + _request_timeout=_params.get('_request_timeout'), + collection_formats=_collection_formats, + _request_auth=_params.get('_request_auth')) diff --git a/pkgs/clan-cli/tests/openapi_client/api_client.py b/pkgs/clan-cli/tests/openapi_client/api_client.py new file mode 100644 index 0000000..245408e --- /dev/null +++ b/pkgs/clan-cli/tests/openapi_client/api_client.py @@ -0,0 +1,758 @@ +# coding: utf-8 + +""" + FastAPI + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: 0.1.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import atexit +import datetime +from dateutil.parser import parse +import json +import mimetypes +from multiprocessing.pool import ThreadPool +import os +import re +import tempfile + +from urllib.parse import quote + +from openapi_client.configuration import Configuration +from openapi_client.api_response import ApiResponse +import openapi_client.models +from openapi_client import rest +from openapi_client.exceptions import ApiValueError, ApiException + + +class ApiClient: + """Generic API client for OpenAPI client library builds. + + OpenAPI generic API client. This client handles the client- + server communication, and is invariant across implementations. Specifics of + the methods and models for each application are generated from the OpenAPI + templates. + + :param configuration: .Configuration object for this client + :param header_name: a header to pass when making calls to the API. + :param header_value: a header value to pass when making calls to + the API. + :param cookie: a cookie to include in the header when making calls + to the API + :param pool_threads: The number of threads to use for async requests + to the API. More threads means more concurrent API requests. + """ + + PRIMITIVE_TYPES = (float, bool, bytes, str, int) + NATIVE_TYPES_MAPPING = { + 'int': int, + 'long': int, # TODO remove as only py3 is supported? + 'float': float, + 'str': str, + 'bool': bool, + 'date': datetime.date, + 'datetime': datetime.datetime, + 'object': object, + } + _pool = None + + def __init__(self, configuration=None, header_name=None, header_value=None, + cookie=None, pool_threads=1) -> None: + # use default configuration if none is provided + if configuration is None: + configuration = Configuration.get_default() + self.configuration = configuration + self.pool_threads = pool_threads + + self.rest_client = rest.RESTClientObject(configuration) + self.default_headers = {} + if header_name is not None: + self.default_headers[header_name] = header_value + self.cookie = cookie + # Set default User-Agent. + self.user_agent = 'OpenAPI-Generator/1.0.0/python' + self.client_side_validation = configuration.client_side_validation + + def __enter__(self): + return self + + def __exit__(self, exc_type, exc_value, traceback): + self.close() + + def close(self): + if self._pool: + self._pool.close() + self._pool.join() + self._pool = None + if hasattr(atexit, 'unregister'): + atexit.unregister(self.close) + + @property + def pool(self): + """Create thread pool on first request + avoids instantiating unused threadpool for blocking clients. + """ + if self._pool is None: + atexit.register(self.close) + self._pool = ThreadPool(self.pool_threads) + return self._pool + + @property + def user_agent(self): + """User agent for this API client""" + return self.default_headers['User-Agent'] + + @user_agent.setter + def user_agent(self, value): + self.default_headers['User-Agent'] = value + + def set_default_header(self, header_name, header_value): + self.default_headers[header_name] = header_value + + + _default = None + + @classmethod + def get_default(cls): + """Return new instance of ApiClient. + + This method returns newly created, based on default constructor, + object of ApiClient class or returns a copy of default + ApiClient. + + :return: The ApiClient object. + """ + if cls._default is None: + cls._default = ApiClient() + return cls._default + + @classmethod + def set_default(cls, default): + """Set default instance of ApiClient. + + It stores default ApiClient. + + :param default: object of ApiClient. + """ + cls._default = default + + def __call_api( + self, resource_path, method, path_params=None, + query_params=None, header_params=None, body=None, post_params=None, + files=None, response_types_map=None, auth_settings=None, + _return_http_data_only=None, collection_formats=None, + _preload_content=True, _request_timeout=None, _host=None, + _request_auth=None): + + config = self.configuration + + # header parameters + header_params = header_params or {} + header_params.update(self.default_headers) + if self.cookie: + header_params['Cookie'] = self.cookie + if header_params: + header_params = self.sanitize_for_serialization(header_params) + header_params = dict(self.parameters_to_tuples(header_params, + collection_formats)) + + # path parameters + if path_params: + path_params = self.sanitize_for_serialization(path_params) + path_params = self.parameters_to_tuples(path_params, + collection_formats) + for k, v in path_params: + # specified safe chars, encode everything + resource_path = resource_path.replace( + '{%s}' % k, + quote(str(v), safe=config.safe_chars_for_path_param) + ) + + # post parameters + if post_params or files: + post_params = post_params if post_params else [] + post_params = self.sanitize_for_serialization(post_params) + post_params = self.parameters_to_tuples(post_params, + collection_formats) + post_params.extend(self.files_parameters(files)) + + # auth setting + self.update_params_for_auth( + header_params, query_params, auth_settings, + resource_path, method, body, + request_auth=_request_auth) + + # body + if body: + body = self.sanitize_for_serialization(body) + + # request url + if _host is None: + url = self.configuration.host + resource_path + else: + # use server/host defined in path or operation instead + url = _host + resource_path + + # query parameters + if query_params: + query_params = self.sanitize_for_serialization(query_params) + url_query = self.parameters_to_url_query(query_params, + collection_formats) + url += "?" + url_query + + try: + # perform request and return response + response_data = self.request( + method, url, + query_params=query_params, + headers=header_params, + post_params=post_params, body=body, + _preload_content=_preload_content, + _request_timeout=_request_timeout) + except ApiException as e: + if e.body: + e.body = e.body.decode('utf-8') + raise e + + self.last_response = response_data + + return_data = None # assuming derialization is not needed + # data needs deserialization or returns HTTP data (deserialized) only + if _preload_content or _return_http_data_only: + response_type = response_types_map.get(str(response_data.status), None) + if not response_type and isinstance(response_data.status, int) and 100 <= response_data.status <= 599: + # if not found, look for '1XX', '2XX', etc. + response_type = response_types_map.get(str(response_data.status)[0] + "XX", None) + + if response_type == "bytearray": + response_data.data = response_data.data + else: + match = None + content_type = response_data.getheader('content-type') + if content_type is not None: + match = re.search(r"charset=([a-zA-Z\-\d]+)[\s;]?", content_type) + encoding = match.group(1) if match else "utf-8" + response_data.data = response_data.data.decode(encoding) + + # deserialize response data + if response_type == "bytearray": + return_data = response_data.data + elif response_type: + return_data = self.deserialize(response_data, response_type) + else: + return_data = None + + if _return_http_data_only: + return return_data + else: + return ApiResponse(status_code = response_data.status, + data = return_data, + headers = response_data.getheaders(), + raw_data = response_data.data) + + def sanitize_for_serialization(self, obj): + """Builds a JSON POST object. + + If obj is None, return None. + If obj is str, int, long, float, bool, return directly. + If obj is datetime.datetime, datetime.date + convert to string in iso8601 format. + If obj is list, sanitize each element in the list. + If obj is dict, return the dict. + If obj is OpenAPI model, return the properties dict. + + :param obj: The data to serialize. + :return: The serialized form of data. + """ + if obj is None: + return None + elif isinstance(obj, self.PRIMITIVE_TYPES): + return obj + elif isinstance(obj, list): + return [self.sanitize_for_serialization(sub_obj) + for sub_obj in obj] + elif isinstance(obj, tuple): + return tuple(self.sanitize_for_serialization(sub_obj) + for sub_obj in obj) + elif isinstance(obj, (datetime.datetime, datetime.date)): + return obj.isoformat() + + if isinstance(obj, dict): + obj_dict = obj + else: + # Convert model obj to dict except + # attributes `openapi_types`, `attribute_map` + # and attributes which value is not None. + # Convert attribute name to json key in + # model definition for request. + obj_dict = obj.to_dict() + + return {key: self.sanitize_for_serialization(val) + for key, val in obj_dict.items()} + + def deserialize(self, response, response_type): + """Deserializes response into an object. + + :param response: RESTResponse object to be deserialized. + :param response_type: class literal for + deserialized object, or string of class name. + + :return: deserialized object. + """ + # handle file downloading + # save response body into a tmp file and return the instance + if response_type == "file": + return self.__deserialize_file(response) + + # fetch data from response object + try: + data = json.loads(response.data) + except ValueError: + data = response.data + + return self.__deserialize(data, response_type) + + def __deserialize(self, data, klass): + """Deserializes dict, list, str into an object. + + :param data: dict, list or str. + :param klass: class literal, or string of class name. + + :return: object. + """ + if data is None: + return None + + if isinstance(klass, str): + if klass.startswith('List['): + sub_kls = re.match(r'List\[(.*)]', klass).group(1) + return [self.__deserialize(sub_data, sub_kls) + for sub_data in data] + + if klass.startswith('Dict['): + sub_kls = re.match(r'Dict\[([^,]*), (.*)]', klass).group(2) + return {k: self.__deserialize(v, sub_kls) + for k, v in data.items()} + + # convert str to class + if klass in self.NATIVE_TYPES_MAPPING: + klass = self.NATIVE_TYPES_MAPPING[klass] + else: + klass = getattr(openapi_client.models, klass) + + if klass in self.PRIMITIVE_TYPES: + return self.__deserialize_primitive(data, klass) + elif klass == object: + return self.__deserialize_object(data) + elif klass == datetime.date: + return self.__deserialize_date(data) + elif klass == datetime.datetime: + return self.__deserialize_datetime(data) + else: + return self.__deserialize_model(data, klass) + + def call_api(self, resource_path, method, + path_params=None, query_params=None, header_params=None, + body=None, post_params=None, files=None, + response_types_map=None, auth_settings=None, + async_req=None, _return_http_data_only=None, + collection_formats=None, _preload_content=True, + _request_timeout=None, _host=None, _request_auth=None): + """Makes the HTTP request (synchronous) and returns deserialized data. + + To make an async_req request, set the async_req parameter. + + :param resource_path: Path to method endpoint. + :param method: Method to call. + :param path_params: Path parameters in the url. + :param query_params: Query parameters in the url. + :param header_params: Header parameters to be + placed in the request header. + :param body: Request body. + :param post_params dict: Request post form parameters, + for `application/x-www-form-urlencoded`, `multipart/form-data`. + :param auth_settings list: Auth Settings names for the request. + :param response: Response data type. + :param files dict: key -> filename, value -> filepath, + for `multipart/form-data`. + :param async_req bool: execute request asynchronously + :param _return_http_data_only: response data instead of ApiResponse + object with status code, headers, etc + :param _preload_content: if False, the ApiResponse.data will + be set to none and raw_data will store the + HTTP response body without reading/decoding. + Default is True. + :param collection_formats: dict of collection formats for path, query, + header, and post parameters. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the authentication + in the spec for a single request. + :type _request_token: dict, optional + :return: + If async_req parameter is True, + the request will be called asynchronously. + The method will return the request thread. + If parameter async_req is False or missing, + then the method will return the response directly. + """ + if not async_req: + return self.__call_api(resource_path, method, + path_params, query_params, header_params, + body, post_params, files, + response_types_map, auth_settings, + _return_http_data_only, collection_formats, + _preload_content, _request_timeout, _host, + _request_auth) + + return self.pool.apply_async(self.__call_api, (resource_path, + method, path_params, + query_params, + header_params, body, + post_params, files, + response_types_map, + auth_settings, + _return_http_data_only, + collection_formats, + _preload_content, + _request_timeout, + _host, _request_auth)) + + def request(self, method, url, query_params=None, headers=None, + post_params=None, body=None, _preload_content=True, + _request_timeout=None): + """Makes the HTTP request using RESTClient.""" + if method == "GET": + return self.rest_client.get_request(url, + query_params=query_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + headers=headers) + elif method == "HEAD": + return self.rest_client.head_request(url, + query_params=query_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + headers=headers) + elif method == "OPTIONS": + return self.rest_client.options_request(url, + query_params=query_params, + headers=headers, + _preload_content=_preload_content, + _request_timeout=_request_timeout) + elif method == "POST": + return self.rest_client.post_request(url, + query_params=query_params, + headers=headers, + post_params=post_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + body=body) + elif method == "PUT": + return self.rest_client.put_request(url, + query_params=query_params, + headers=headers, + post_params=post_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + body=body) + elif method == "PATCH": + return self.rest_client.patch_request(url, + query_params=query_params, + headers=headers, + post_params=post_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + body=body) + elif method == "DELETE": + return self.rest_client.delete_request(url, + query_params=query_params, + headers=headers, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + body=body) + else: + raise ApiValueError( + "http method must be `GET`, `HEAD`, `OPTIONS`," + " `POST`, `PATCH`, `PUT` or `DELETE`." + ) + + def parameters_to_tuples(self, params, collection_formats): + """Get parameters as list of tuples, formatting collections. + + :param params: Parameters as dict or list of two-tuples + :param dict collection_formats: Parameter collection formats + :return: Parameters as list of tuples, collections formatted + """ + new_params = [] + if collection_formats is None: + collection_formats = {} + for k, v in params.items() if isinstance(params, dict) else params: # noqa: E501 + if k in collection_formats: + collection_format = collection_formats[k] + if collection_format == 'multi': + new_params.extend((k, value) for value in v) + else: + if collection_format == 'ssv': + delimiter = ' ' + elif collection_format == 'tsv': + delimiter = '\t' + elif collection_format == 'pipes': + delimiter = '|' + else: # csv is the default + delimiter = ',' + new_params.append( + (k, delimiter.join(str(value) for value in v))) + else: + new_params.append((k, v)) + return new_params + + def parameters_to_url_query(self, params, collection_formats): + """Get parameters as list of tuples, formatting collections. + + :param params: Parameters as dict or list of two-tuples + :param dict collection_formats: Parameter collection formats + :return: URL query string (e.g. a=Hello%20World&b=123) + """ + new_params = [] + if collection_formats is None: + collection_formats = {} + for k, v in params.items() if isinstance(params, dict) else params: # noqa: E501 + if isinstance(v, (int, float)): + v = str(v) + if isinstance(v, bool): + v = str(v).lower() + if isinstance(v, dict): + v = json.dumps(v) + + if k in collection_formats: + collection_format = collection_formats[k] + if collection_format == 'multi': + new_params.extend((k, value) for value in v) + else: + if collection_format == 'ssv': + delimiter = ' ' + elif collection_format == 'tsv': + delimiter = '\t' + elif collection_format == 'pipes': + delimiter = '|' + else: # csv is the default + delimiter = ',' + new_params.append( + (k, delimiter.join(quote(str(value)) for value in v))) + else: + new_params.append((k, quote(str(v)))) + + return "&".join(["=".join(item) for item in new_params]) + + def files_parameters(self, files=None): + """Builds form parameters. + + :param files: File parameters. + :return: Form parameters with files. + """ + params = [] + + if files: + for k, v in files.items(): + if not v: + continue + file_names = v if type(v) is list else [v] + for n in file_names: + with open(n, 'rb') as f: + filename = os.path.basename(f.name) + filedata = f.read() + mimetype = (mimetypes.guess_type(filename)[0] or + 'application/octet-stream') + params.append( + tuple([k, tuple([filename, filedata, mimetype])])) + + return params + + def select_header_accept(self, accepts): + """Returns `Accept` based on an array of accepts provided. + + :param accepts: List of headers. + :return: Accept (e.g. application/json). + """ + if not accepts: + return + + for accept in accepts: + if re.search('json', accept, re.IGNORECASE): + return accept + + return accepts[0] + + def select_header_content_type(self, content_types): + """Returns `Content-Type` based on an array of content_types provided. + + :param content_types: List of content-types. + :return: Content-Type (e.g. application/json). + """ + if not content_types: + return None + + for content_type in content_types: + if re.search('json', content_type, re.IGNORECASE): + return content_type + + return content_types[0] + + def update_params_for_auth(self, headers, queries, auth_settings, + resource_path, method, body, + request_auth=None): + """Updates header and query params based on authentication setting. + + :param headers: Header parameters dict to be updated. + :param queries: Query parameters tuple list to be updated. + :param auth_settings: Authentication setting identifiers list. + :resource_path: A string representation of the HTTP request resource path. + :method: A string representation of the HTTP request method. + :body: A object representing the body of the HTTP request. + The object type is the return value of sanitize_for_serialization(). + :param request_auth: if set, the provided settings will + override the token in the configuration. + """ + if not auth_settings: + return + + if request_auth: + self._apply_auth_params(headers, queries, + resource_path, method, body, + request_auth) + return + + for auth in auth_settings: + auth_setting = self.configuration.auth_settings().get(auth) + if auth_setting: + self._apply_auth_params(headers, queries, + resource_path, method, body, + auth_setting) + + def _apply_auth_params(self, headers, queries, + resource_path, method, body, + auth_setting): + """Updates the request parameters based on a single auth_setting + + :param headers: Header parameters dict to be updated. + :param queries: Query parameters tuple list to be updated. + :resource_path: A string representation of the HTTP request resource path. + :method: A string representation of the HTTP request method. + :body: A object representing the body of the HTTP request. + The object type is the return value of sanitize_for_serialization(). + :param auth_setting: auth settings for the endpoint + """ + if auth_setting['in'] == 'cookie': + headers['Cookie'] = auth_setting['value'] + elif auth_setting['in'] == 'header': + if auth_setting['type'] != 'http-signature': + headers[auth_setting['key']] = auth_setting['value'] + elif auth_setting['in'] == 'query': + queries.append((auth_setting['key'], auth_setting['value'])) + else: + raise ApiValueError( + 'Authentication token must be in `query` or `header`' + ) + + def __deserialize_file(self, response): + """Deserializes body to file + + Saves response body into a file in a temporary folder, + using the filename from the `Content-Disposition` header if provided. + + :param response: RESTResponse. + :return: file path. + """ + fd, path = tempfile.mkstemp(dir=self.configuration.temp_folder_path) + os.close(fd) + os.remove(path) + + content_disposition = response.getheader("Content-Disposition") + if content_disposition: + filename = re.search(r'filename=[\'"]?([^\'"\s]+)[\'"]?', + content_disposition).group(1) + path = os.path.join(os.path.dirname(path), filename) + + with open(path, "wb") as f: + f.write(response.data) + + return path + + def __deserialize_primitive(self, data, klass): + """Deserializes string to primitive type. + + :param data: str. + :param klass: class literal. + + :return: int, long, float, str, bool. + """ + try: + return klass(data) + except UnicodeEncodeError: + return str(data) + except TypeError: + return data + + def __deserialize_object(self, value): + """Return an original value. + + :return: object. + """ + return value + + def __deserialize_date(self, string): + """Deserializes string to date. + + :param string: str. + :return: date. + """ + try: + return parse(string).date() + except ImportError: + return string + except ValueError: + raise rest.ApiException( + status=0, + reason="Failed to parse `{0}` as date object".format(string) + ) + + def __deserialize_datetime(self, string): + """Deserializes string to datetime. + + The string should be in iso8601 datetime format. + + :param string: str. + :return: datetime. + """ + try: + return parse(string) + except ImportError: + return string + except ValueError: + raise rest.ApiException( + status=0, + reason=( + "Failed to parse `{0}` as datetime object" + .format(string) + ) + ) + + def __deserialize_model(self, data, klass): + """Deserializes list or dict to model. + + :param data: dict, list. + :param klass: class literal. + :return: model object. + """ + + return klass.from_dict(data) diff --git a/pkgs/clan-cli/tests/openapi_client/api_response.py b/pkgs/clan-cli/tests/openapi_client/api_response.py new file mode 100644 index 0000000..a0b62b9 --- /dev/null +++ b/pkgs/clan-cli/tests/openapi_client/api_response.py @@ -0,0 +1,25 @@ +"""API response object.""" + +from __future__ import annotations +from typing import Any, Dict, Optional +from pydantic import Field, StrictInt, StrictStr + +class ApiResponse: + """ + API response object + """ + + status_code: Optional[StrictInt] = Field(None, description="HTTP status code") + headers: Optional[Dict[StrictStr, StrictStr]] = Field(None, description="HTTP headers") + data: Optional[Any] = Field(None, description="Deserialized data given the data type") + raw_data: Optional[Any] = Field(None, description="Raw data (HTTP response body)") + + def __init__(self, + status_code=None, + headers=None, + data=None, + raw_data=None) -> None: + self.status_code = status_code + self.headers = headers + self.data = data + self.raw_data = raw_data diff --git a/pkgs/clan-cli/tests/openapi_client/configuration.py b/pkgs/clan-cli/tests/openapi_client/configuration.py new file mode 100644 index 0000000..6576427 --- /dev/null +++ b/pkgs/clan-cli/tests/openapi_client/configuration.py @@ -0,0 +1,434 @@ +# coding: utf-8 + +""" + FastAPI + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: 0.1.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import copy +import logging +import multiprocessing +import sys +import urllib3 + +import http.client as httplib + +JSON_SCHEMA_VALIDATION_KEYWORDS = { + 'multipleOf', 'maximum', 'exclusiveMaximum', + 'minimum', 'exclusiveMinimum', 'maxLength', + 'minLength', 'pattern', 'maxItems', 'minItems' +} + +class Configuration: + """This class contains various settings of the API client. + + :param host: Base url. + :param api_key: Dict to store API key(s). + Each entry in the dict specifies an API key. + The dict key is the name of the security scheme in the OAS specification. + The dict value is the API key secret. + :param api_key_prefix: Dict to store API prefix (e.g. Bearer). + The dict key is the name of the security scheme in the OAS specification. + The dict value is an API key prefix when generating the auth data. + :param username: Username for HTTP basic authentication. + :param password: Password for HTTP basic authentication. + :param access_token: Access token. + :param server_index: Index to servers configuration. + :param server_variables: Mapping with string values to replace variables in + templated server configuration. The validation of enums is performed for + variables with defined enum values before. + :param server_operation_index: Mapping from operation ID to an index to server + configuration. + :param server_operation_variables: Mapping from operation ID to a mapping with + string values to replace variables in templated server configuration. + The validation of enums is performed for variables with defined enum + values before. + :param ssl_ca_cert: str - the path to a file of concatenated CA certificates + in PEM format. + + """ + + _default = None + + def __init__(self, host=None, + api_key=None, api_key_prefix=None, + username=None, password=None, + access_token=None, + server_index=None, server_variables=None, + server_operation_index=None, server_operation_variables=None, + ssl_ca_cert=None, + ) -> None: + """Constructor + """ + self._base_path = "http://localhost" if host is None else host + """Default Base url + """ + self.server_index = 0 if server_index is None and host is None else server_index + self.server_operation_index = server_operation_index or {} + """Default server index + """ + self.server_variables = server_variables or {} + self.server_operation_variables = server_operation_variables or {} + """Default server variables + """ + self.temp_folder_path = None + """Temp file folder for downloading files + """ + # Authentication Settings + self.api_key = {} + if api_key: + self.api_key = api_key + """dict to store API key(s) + """ + self.api_key_prefix = {} + if api_key_prefix: + self.api_key_prefix = api_key_prefix + """dict to store API prefix (e.g. Bearer) + """ + self.refresh_api_key_hook = None + """function hook to refresh API key if expired + """ + self.username = username + """Username for HTTP basic authentication + """ + self.password = password + """Password for HTTP basic authentication + """ + self.access_token = access_token + """Access token + """ + self.logger = {} + """Logging Settings + """ + self.logger["package_logger"] = logging.getLogger("openapi_client") + self.logger["urllib3_logger"] = logging.getLogger("urllib3") + self.logger_format = '%(asctime)s %(levelname)s %(message)s' + """Log format + """ + self.logger_stream_handler = None + """Log stream handler + """ + self.logger_file_handler = None + """Log file handler + """ + self.logger_file = None + """Debug file location + """ + self.debug = False + """Debug switch + """ + + self.verify_ssl = True + """SSL/TLS verification + Set this to false to skip verifying SSL certificate when calling API + from https server. + """ + self.ssl_ca_cert = ssl_ca_cert + """Set this to customize the certificate file to verify the peer. + """ + self.cert_file = None + """client certificate file + """ + self.key_file = None + """client key file + """ + self.assert_hostname = None + """Set this to True/False to enable/disable SSL hostname verification. + """ + self.tls_server_name = None + """SSL/TLS Server Name Indication (SNI) + Set this to the SNI value expected by the server. + """ + + self.connection_pool_maxsize = multiprocessing.cpu_count() * 5 + """urllib3 connection pool's maximum number of connections saved + per pool. urllib3 uses 1 connection as default value, but this is + not the best value when you are making a lot of possibly parallel + requests to the same host, which is often the case here. + cpu_count * 5 is used as default value to increase performance. + """ + + self.proxy = None + """Proxy URL + """ + self.proxy_headers = None + """Proxy headers + """ + self.safe_chars_for_path_param = '' + """Safe chars for path_param + """ + self.retries = None + """Adding retries to override urllib3 default value 3 + """ + # Enable client side validation + self.client_side_validation = True + + self.socket_options = None + """Options to pass down to the underlying urllib3 socket + """ + + self.datetime_format = "%Y-%m-%dT%H:%M:%S.%f%z" + """datetime format + """ + + self.date_format = "%Y-%m-%d" + """date format + """ + + def __deepcopy__(self, memo): + cls = self.__class__ + result = cls.__new__(cls) + memo[id(self)] = result + for k, v in self.__dict__.items(): + if k not in ('logger', 'logger_file_handler'): + setattr(result, k, copy.deepcopy(v, memo)) + # shallow copy of loggers + result.logger = copy.copy(self.logger) + # use setters to configure loggers + result.logger_file = self.logger_file + result.debug = self.debug + return result + + def __setattr__(self, name, value): + object.__setattr__(self, name, value) + + @classmethod + def set_default(cls, default): + """Set default instance of configuration. + + It stores default configuration, which can be + returned by get_default_copy method. + + :param default: object of Configuration + """ + cls._default = default + + @classmethod + def get_default_copy(cls): + """Deprecated. Please use `get_default` instead. + + Deprecated. Please use `get_default` instead. + + :return: The configuration object. + """ + return cls.get_default() + + @classmethod + def get_default(cls): + """Return the default configuration. + + This method returns newly created, based on default constructor, + object of Configuration class or returns a copy of default + configuration. + + :return: The configuration object. + """ + if cls._default is None: + cls._default = Configuration() + return cls._default + + @property + def logger_file(self): + """The logger file. + + If the logger_file is None, then add stream handler and remove file + handler. Otherwise, add file handler and remove stream handler. + + :param value: The logger_file path. + :type: str + """ + return self.__logger_file + + @logger_file.setter + def logger_file(self, value): + """The logger file. + + If the logger_file is None, then add stream handler and remove file + handler. Otherwise, add file handler and remove stream handler. + + :param value: The logger_file path. + :type: str + """ + self.__logger_file = value + if self.__logger_file: + # If set logging file, + # then add file handler and remove stream handler. + self.logger_file_handler = logging.FileHandler(self.__logger_file) + self.logger_file_handler.setFormatter(self.logger_formatter) + for _, logger in self.logger.items(): + logger.addHandler(self.logger_file_handler) + + @property + def debug(self): + """Debug status + + :param value: The debug status, True or False. + :type: bool + """ + return self.__debug + + @debug.setter + def debug(self, value): + """Debug status + + :param value: The debug status, True or False. + :type: bool + """ + self.__debug = value + if self.__debug: + # if debug status is True, turn on debug logging + for _, logger in self.logger.items(): + logger.setLevel(logging.DEBUG) + # turn on httplib debug + httplib.HTTPConnection.debuglevel = 1 + else: + # if debug status is False, turn off debug logging, + # setting log level to default `logging.WARNING` + for _, logger in self.logger.items(): + logger.setLevel(logging.WARNING) + # turn off httplib debug + httplib.HTTPConnection.debuglevel = 0 + + @property + def logger_format(self): + """The logger format. + + The logger_formatter will be updated when sets logger_format. + + :param value: The format string. + :type: str + """ + return self.__logger_format + + @logger_format.setter + def logger_format(self, value): + """The logger format. + + The logger_formatter will be updated when sets logger_format. + + :param value: The format string. + :type: str + """ + self.__logger_format = value + self.logger_formatter = logging.Formatter(self.__logger_format) + + def get_api_key_with_prefix(self, identifier, alias=None): + """Gets API key (with prefix if set). + + :param identifier: The identifier of apiKey. + :param alias: The alternative identifier of apiKey. + :return: The token for api key authentication. + """ + if self.refresh_api_key_hook is not None: + self.refresh_api_key_hook(self) + key = self.api_key.get(identifier, self.api_key.get(alias) if alias is not None else None) + if key: + prefix = self.api_key_prefix.get(identifier) + if prefix: + return "%s %s" % (prefix, key) + else: + return key + + def get_basic_auth_token(self): + """Gets HTTP basic authentication header (string). + + :return: The token for basic HTTP authentication. + """ + username = "" + if self.username is not None: + username = self.username + password = "" + if self.password is not None: + password = self.password + return urllib3.util.make_headers( + basic_auth=username + ':' + password + ).get('authorization') + + def auth_settings(self): + """Gets Auth Settings dict for api client. + + :return: The Auth Settings information dict. + """ + auth = {} + return auth + + def to_debug_report(self): + """Gets the essential information for debugging. + + :return: The report for debugging. + """ + return "Python SDK Debug Report:\n"\ + "OS: {env}\n"\ + "Python Version: {pyversion}\n"\ + "Version of the API: 0.1.0\n"\ + "SDK Package Version: 1.0.0".\ + format(env=sys.platform, pyversion=sys.version) + + def get_host_settings(self): + """Gets an array of host settings + + :return: An array of host settings + """ + return [ + { + 'url': "", + 'description': "No description provided", + } + ] + + def get_host_from_settings(self, index, variables=None, servers=None): + """Gets host URL based on the index and variables + :param index: array index of the host settings + :param variables: hash of variable and the corresponding value + :param servers: an array of host settings or None + :return: URL based on host settings + """ + if index is None: + return self._base_path + + variables = {} if variables is None else variables + servers = self.get_host_settings() if servers is None else servers + + try: + server = servers[index] + except IndexError: + raise ValueError( + "Invalid index {0} when selecting the host settings. " + "Must be less than {1}".format(index, len(servers))) + + url = server['url'] + + # go through variables and replace placeholders + for variable_name, variable in server.get('variables', {}).items(): + used_value = variables.get( + variable_name, variable['default_value']) + + if 'enum_values' in variable \ + and used_value not in variable['enum_values']: + raise ValueError( + "The variable `{0}` in the host URL has invalid value " + "{1}. Must be {2}.".format( + variable_name, variables[variable_name], + variable['enum_values'])) + + url = url.replace("{" + variable_name + "}", used_value) + + return url + + @property + def host(self): + """Return generated host.""" + return self.get_host_from_settings(self.server_index, variables=self.server_variables) + + @host.setter + def host(self, value): + """Fix base path.""" + self._base_path = value + self.server_index = None diff --git a/pkgs/clan-cli/tests/openapi_client/exceptions.py b/pkgs/clan-cli/tests/openapi_client/exceptions.py new file mode 100644 index 0000000..a952fe2 --- /dev/null +++ b/pkgs/clan-cli/tests/openapi_client/exceptions.py @@ -0,0 +1,166 @@ +# coding: utf-8 + +""" + FastAPI + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: 0.1.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +class OpenApiException(Exception): + """The base exception class for all OpenAPIExceptions""" + + +class ApiTypeError(OpenApiException, TypeError): + def __init__(self, msg, path_to_item=None, valid_classes=None, + key_type=None) -> None: + """ Raises an exception for TypeErrors + + Args: + msg (str): the exception message + + Keyword Args: + path_to_item (list): a list of keys an indices to get to the + current_item + None if unset + valid_classes (tuple): the primitive classes that current item + should be an instance of + None if unset + key_type (bool): False if our value is a value in a dict + True if it is a key in a dict + False if our item is an item in a list + None if unset + """ + self.path_to_item = path_to_item + self.valid_classes = valid_classes + self.key_type = key_type + full_msg = msg + if path_to_item: + full_msg = "{0} at {1}".format(msg, render_path(path_to_item)) + super(ApiTypeError, self).__init__(full_msg) + + +class ApiValueError(OpenApiException, ValueError): + def __init__(self, msg, path_to_item=None) -> None: + """ + Args: + msg (str): the exception message + + Keyword Args: + path_to_item (list) the path to the exception in the + received_data dict. None if unset + """ + + self.path_to_item = path_to_item + full_msg = msg + if path_to_item: + full_msg = "{0} at {1}".format(msg, render_path(path_to_item)) + super(ApiValueError, self).__init__(full_msg) + + +class ApiAttributeError(OpenApiException, AttributeError): + def __init__(self, msg, path_to_item=None) -> None: + """ + Raised when an attribute reference or assignment fails. + + Args: + msg (str): the exception message + + Keyword Args: + path_to_item (None/list) the path to the exception in the + received_data dict + """ + self.path_to_item = path_to_item + full_msg = msg + if path_to_item: + full_msg = "{0} at {1}".format(msg, render_path(path_to_item)) + super(ApiAttributeError, self).__init__(full_msg) + + +class ApiKeyError(OpenApiException, KeyError): + def __init__(self, msg, path_to_item=None) -> None: + """ + Args: + msg (str): the exception message + + Keyword Args: + path_to_item (None/list) the path to the exception in the + received_data dict + """ + self.path_to_item = path_to_item + full_msg = msg + if path_to_item: + full_msg = "{0} at {1}".format(msg, render_path(path_to_item)) + super(ApiKeyError, self).__init__(full_msg) + + +class ApiException(OpenApiException): + + def __init__(self, status=None, reason=None, http_resp=None) -> None: + if http_resp: + self.status = http_resp.status + self.reason = http_resp.reason + self.body = http_resp.data + self.headers = http_resp.getheaders() + else: + self.status = status + self.reason = reason + self.body = None + self.headers = None + + def __str__(self): + """Custom error messages for exception""" + error_message = "({0})\n"\ + "Reason: {1}\n".format(self.status, self.reason) + if self.headers: + error_message += "HTTP response headers: {0}\n".format( + self.headers) + + if self.body: + error_message += "HTTP response body: {0}\n".format(self.body) + + return error_message + +class BadRequestException(ApiException): + + def __init__(self, status=None, reason=None, http_resp=None) -> None: + super(BadRequestException, self).__init__(status, reason, http_resp) + +class NotFoundException(ApiException): + + def __init__(self, status=None, reason=None, http_resp=None) -> None: + super(NotFoundException, self).__init__(status, reason, http_resp) + + +class UnauthorizedException(ApiException): + + def __init__(self, status=None, reason=None, http_resp=None) -> None: + super(UnauthorizedException, self).__init__(status, reason, http_resp) + + +class ForbiddenException(ApiException): + + def __init__(self, status=None, reason=None, http_resp=None) -> None: + super(ForbiddenException, self).__init__(status, reason, http_resp) + + +class ServiceException(ApiException): + + def __init__(self, status=None, reason=None, http_resp=None) -> None: + super(ServiceException, self).__init__(status, reason, http_resp) + + +def render_path(path_to_item): + """Returns a string representation of a path""" + result = "" + for pth in path_to_item: + if isinstance(pth, int): + result += "[{0}]".format(pth) + else: + result += "['{0}']".format(pth) + return result diff --git a/pkgs/clan-cli/tests/openapi_client/models/__init__.py b/pkgs/clan-cli/tests/openapi_client/models/__init__.py new file mode 100644 index 0000000..4955602 --- /dev/null +++ b/pkgs/clan-cli/tests/openapi_client/models/__init__.py @@ -0,0 +1,26 @@ +# coding: utf-8 + +# flake8: noqa +""" + FastAPI + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: 0.1.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +# import models into model package +from openapi_client.models.entity import Entity +from openapi_client.models.entity_create import EntityCreate +from openapi_client.models.http_validation_error import HTTPValidationError +from openapi_client.models.machine import Machine +from openapi_client.models.resolution import Resolution +from openapi_client.models.service import Service +from openapi_client.models.service_create import ServiceCreate +from openapi_client.models.status import Status +from openapi_client.models.validation_error import ValidationError +from openapi_client.models.validation_error_loc_inner import ValidationErrorLocInner diff --git a/pkgs/clan-cli/tests/openapi_client/models/entity.py b/pkgs/clan-cli/tests/openapi_client/models/entity.py new file mode 100644 index 0000000..888c1ae --- /dev/null +++ b/pkgs/clan-cli/tests/openapi_client/models/entity.py @@ -0,0 +1,81 @@ +# coding: utf-8 + +""" + FastAPI + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: 0.1.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + + +from typing import Any, Dict, Optional +from pydantic import BaseModel, Field, StrictBool, StrictStr + +class Entity(BaseModel): + """ + Entity + """ + did: Optional[StrictStr] = 'did:sov:test:1234' + name: Optional[StrictStr] = 'C1' + ip: Optional[StrictStr] = '127.0.0.1' + visible: Optional[StrictBool] = True + other: Optional[Dict[str, Any]] = None + attached: StrictBool = Field(...) + __properties = ["did", "name", "ip", "visible", "other", "attached"] + + class Config: + """Pydantic configuration""" + allow_population_by_field_name = True + validate_assignment = True + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.dict(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Entity: + """Create an instance of Entity from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self): + """Returns the dictionary representation of the model using alias""" + _dict = self.dict(by_alias=True, + exclude={ + }, + exclude_none=True) + return _dict + + @classmethod + def from_dict(cls, obj: dict) -> Entity: + """Create an instance of Entity from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return Entity.parse_obj(obj) + + _obj = Entity.parse_obj({ + "did": obj.get("did") if obj.get("did") is not None else 'did:sov:test:1234', + "name": obj.get("name") if obj.get("name") is not None else 'C1', + "ip": obj.get("ip") if obj.get("ip") is not None else '127.0.0.1', + "visible": obj.get("visible") if obj.get("visible") is not None else True, + "other": obj.get("other"), + "attached": obj.get("attached") + }) + return _obj + + diff --git a/pkgs/clan-cli/tests/openapi_client/models/entity_create.py b/pkgs/clan-cli/tests/openapi_client/models/entity_create.py new file mode 100644 index 0000000..0204840 --- /dev/null +++ b/pkgs/clan-cli/tests/openapi_client/models/entity_create.py @@ -0,0 +1,79 @@ +# coding: utf-8 + +""" + FastAPI + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: 0.1.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + + +from typing import Any, Dict, Optional +from pydantic import BaseModel, StrictBool, StrictStr + +class EntityCreate(BaseModel): + """ + EntityCreate + """ + did: Optional[StrictStr] = 'did:sov:test:1234' + name: Optional[StrictStr] = 'C1' + ip: Optional[StrictStr] = '127.0.0.1' + visible: Optional[StrictBool] = True + other: Optional[Dict[str, Any]] = None + __properties = ["did", "name", "ip", "visible", "other"] + + class Config: + """Pydantic configuration""" + allow_population_by_field_name = True + validate_assignment = True + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.dict(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> EntityCreate: + """Create an instance of EntityCreate from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self): + """Returns the dictionary representation of the model using alias""" + _dict = self.dict(by_alias=True, + exclude={ + }, + exclude_none=True) + return _dict + + @classmethod + def from_dict(cls, obj: dict) -> EntityCreate: + """Create an instance of EntityCreate from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return EntityCreate.parse_obj(obj) + + _obj = EntityCreate.parse_obj({ + "did": obj.get("did") if obj.get("did") is not None else 'did:sov:test:1234', + "name": obj.get("name") if obj.get("name") is not None else 'C1', + "ip": obj.get("ip") if obj.get("ip") is not None else '127.0.0.1', + "visible": obj.get("visible") if obj.get("visible") is not None else True, + "other": obj.get("other") + }) + return _obj + + diff --git a/pkgs/clan-cli/tests/openapi_client/models/http_validation_error.py b/pkgs/clan-cli/tests/openapi_client/models/http_validation_error.py new file mode 100644 index 0000000..640927e --- /dev/null +++ b/pkgs/clan-cli/tests/openapi_client/models/http_validation_error.py @@ -0,0 +1,79 @@ +# coding: utf-8 + +""" + FastAPI + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: 0.1.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + + +from typing import List, Optional +from pydantic import BaseModel, conlist +from openapi_client.models.validation_error import ValidationError + +class HTTPValidationError(BaseModel): + """ + HTTPValidationError + """ + detail: Optional[conlist(ValidationError)] = None + __properties = ["detail"] + + class Config: + """Pydantic configuration""" + allow_population_by_field_name = True + validate_assignment = True + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.dict(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> HTTPValidationError: + """Create an instance of HTTPValidationError from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self): + """Returns the dictionary representation of the model using alias""" + _dict = self.dict(by_alias=True, + exclude={ + }, + exclude_none=True) + # override the default output from pydantic by calling `to_dict()` of each item in detail (list) + _items = [] + if self.detail: + for _item in self.detail: + if _item: + _items.append(_item.to_dict()) + _dict['detail'] = _items + return _dict + + @classmethod + def from_dict(cls, obj: dict) -> HTTPValidationError: + """Create an instance of HTTPValidationError from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return HTTPValidationError.parse_obj(obj) + + _obj = HTTPValidationError.parse_obj({ + "detail": [ValidationError.from_dict(_item) for _item in obj.get("detail")] if obj.get("detail") is not None else None + }) + return _obj + + diff --git a/pkgs/clan-cli/tests/openapi_client/models/machine.py b/pkgs/clan-cli/tests/openapi_client/models/machine.py new file mode 100644 index 0000000..e8e4c18 --- /dev/null +++ b/pkgs/clan-cli/tests/openapi_client/models/machine.py @@ -0,0 +1,74 @@ +# coding: utf-8 + +""" + FastAPI + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: 0.1.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + + + +from pydantic import BaseModel, Field, StrictStr +from openapi_client.models.status import Status + +class Machine(BaseModel): + """ + Machine + """ + name: StrictStr = Field(...) + status: Status = Field(...) + __properties = ["name", "status"] + + class Config: + """Pydantic configuration""" + allow_population_by_field_name = True + validate_assignment = True + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.dict(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Machine: + """Create an instance of Machine from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self): + """Returns the dictionary representation of the model using alias""" + _dict = self.dict(by_alias=True, + exclude={ + }, + exclude_none=True) + return _dict + + @classmethod + def from_dict(cls, obj: dict) -> Machine: + """Create an instance of Machine from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return Machine.parse_obj(obj) + + _obj = Machine.parse_obj({ + "name": obj.get("name"), + "status": obj.get("status") + }) + return _obj + + diff --git a/pkgs/clan-cli/tests/openapi_client/models/resolution.py b/pkgs/clan-cli/tests/openapi_client/models/resolution.py new file mode 100644 index 0000000..4e97999 --- /dev/null +++ b/pkgs/clan-cli/tests/openapi_client/models/resolution.py @@ -0,0 +1,81 @@ +# coding: utf-8 + +""" + FastAPI + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: 0.1.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from datetime import datetime +from typing import Any, Dict, Optional +from pydantic import BaseModel, Field, StrictInt, StrictStr + +class Resolution(BaseModel): + """ + Resolution + """ + requester_name: Optional[StrictStr] = 'C1' + requester_did: Optional[StrictStr] = 'did:sov:test:1122' + resolved_did: Optional[StrictStr] = 'did:sov:test:1234' + other: Optional[Dict[str, Any]] = None + timestamp: datetime = Field(...) + id: StrictInt = Field(...) + __properties = ["requester_name", "requester_did", "resolved_did", "other", "timestamp", "id"] + + class Config: + """Pydantic configuration""" + allow_population_by_field_name = True + validate_assignment = True + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.dict(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Resolution: + """Create an instance of Resolution from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self): + """Returns the dictionary representation of the model using alias""" + _dict = self.dict(by_alias=True, + exclude={ + }, + exclude_none=True) + return _dict + + @classmethod + def from_dict(cls, obj: dict) -> Resolution: + """Create an instance of Resolution from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return Resolution.parse_obj(obj) + + _obj = Resolution.parse_obj({ + "requester_name": obj.get("requester_name") if obj.get("requester_name") is not None else 'C1', + "requester_did": obj.get("requester_did") if obj.get("requester_did") is not None else 'did:sov:test:1122', + "resolved_did": obj.get("resolved_did") if obj.get("resolved_did") is not None else 'did:sov:test:1234', + "other": obj.get("other"), + "timestamp": obj.get("timestamp"), + "id": obj.get("id") + }) + return _obj + + diff --git a/pkgs/clan-cli/tests/openapi_client/models/service.py b/pkgs/clan-cli/tests/openapi_client/models/service.py new file mode 100644 index 0000000..3128a41 --- /dev/null +++ b/pkgs/clan-cli/tests/openapi_client/models/service.py @@ -0,0 +1,83 @@ +# coding: utf-8 + +""" + FastAPI + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: 0.1.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + + +from typing import Any, Dict, Optional +from pydantic import BaseModel, StrictStr + +class Service(BaseModel): + """ + Service + """ + uuid: Optional[StrictStr] = '8e285c0c-4e40-430a-a477-26b3b81e30df' + service_name: Optional[StrictStr] = 'Carlo's Printing' + service_type: Optional[StrictStr] = '3D Printing' + endpoint_url: Optional[StrictStr] = 'http://127.0.0.1:8000' + status: Optional[StrictStr] = 'unknown' + other: Optional[Dict[str, Any]] = None + entity_did: Optional[StrictStr] = 'did:sov:test:1234' + __properties = ["uuid", "service_name", "service_type", "endpoint_url", "status", "other", "entity_did"] + + class Config: + """Pydantic configuration""" + allow_population_by_field_name = True + validate_assignment = True + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.dict(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Service: + """Create an instance of Service from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self): + """Returns the dictionary representation of the model using alias""" + _dict = self.dict(by_alias=True, + exclude={ + }, + exclude_none=True) + return _dict + + @classmethod + def from_dict(cls, obj: dict) -> Service: + """Create an instance of Service from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return Service.parse_obj(obj) + + _obj = Service.parse_obj({ + "uuid": obj.get("uuid") if obj.get("uuid") is not None else '8e285c0c-4e40-430a-a477-26b3b81e30df', + "service_name": obj.get("service_name") if obj.get("service_name") is not None else 'Carlo's Printing', + "service_type": obj.get("service_type") if obj.get("service_type") is not None else '3D Printing', + "endpoint_url": obj.get("endpoint_url") if obj.get("endpoint_url") is not None else 'http://127.0.0.1:8000', + "status": obj.get("status") if obj.get("status") is not None else 'unknown', + "other": obj.get("other"), + "entity_did": obj.get("entity_did") if obj.get("entity_did") is not None else 'did:sov:test:1234' + }) + return _obj + + diff --git a/pkgs/clan-cli/tests/openapi_client/models/service_create.py b/pkgs/clan-cli/tests/openapi_client/models/service_create.py new file mode 100644 index 0000000..d6efb93 --- /dev/null +++ b/pkgs/clan-cli/tests/openapi_client/models/service_create.py @@ -0,0 +1,83 @@ +# coding: utf-8 + +""" + FastAPI + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: 0.1.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + + +from typing import Any, Dict, Optional +from pydantic import BaseModel, StrictStr + +class ServiceCreate(BaseModel): + """ + ServiceCreate + """ + uuid: Optional[StrictStr] = '8e285c0c-4e40-430a-a477-26b3b81e30df' + service_name: Optional[StrictStr] = 'Carlo's Printing' + service_type: Optional[StrictStr] = '3D Printing' + endpoint_url: Optional[StrictStr] = 'http://127.0.0.1:8000' + status: Optional[StrictStr] = 'unknown' + other: Optional[Dict[str, Any]] = None + entity_did: Optional[StrictStr] = 'did:sov:test:1234' + __properties = ["uuid", "service_name", "service_type", "endpoint_url", "status", "other", "entity_did"] + + class Config: + """Pydantic configuration""" + allow_population_by_field_name = True + validate_assignment = True + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.dict(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> ServiceCreate: + """Create an instance of ServiceCreate from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self): + """Returns the dictionary representation of the model using alias""" + _dict = self.dict(by_alias=True, + exclude={ + }, + exclude_none=True) + return _dict + + @classmethod + def from_dict(cls, obj: dict) -> ServiceCreate: + """Create an instance of ServiceCreate from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return ServiceCreate.parse_obj(obj) + + _obj = ServiceCreate.parse_obj({ + "uuid": obj.get("uuid") if obj.get("uuid") is not None else '8e285c0c-4e40-430a-a477-26b3b81e30df', + "service_name": obj.get("service_name") if obj.get("service_name") is not None else 'Carlo's Printing', + "service_type": obj.get("service_type") if obj.get("service_type") is not None else '3D Printing', + "endpoint_url": obj.get("endpoint_url") if obj.get("endpoint_url") is not None else 'http://127.0.0.1:8000', + "status": obj.get("status") if obj.get("status") is not None else 'unknown', + "other": obj.get("other"), + "entity_did": obj.get("entity_did") if obj.get("entity_did") is not None else 'did:sov:test:1234' + }) + return _obj + + diff --git a/pkgs/clan-cli/tests/openapi_client/models/status.py b/pkgs/clan-cli/tests/openapi_client/models/status.py new file mode 100644 index 0000000..2b0f741 --- /dev/null +++ b/pkgs/clan-cli/tests/openapi_client/models/status.py @@ -0,0 +1,41 @@ +# coding: utf-8 + +""" + FastAPI + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: 0.1.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import json +import pprint +import re # noqa: F401 +from aenum import Enum, no_arg + + + + + +class Status(str, Enum): + """ + An enumeration. + """ + + """ + allowed enum values + """ + ONLINE = 'online' + OFFLINE = 'offline' + UNKNOWN = 'unknown' + + @classmethod + def from_json(cls, json_str: str) -> Status: + """Create an instance of Status from a JSON string""" + return Status(json.loads(json_str)) + + diff --git a/pkgs/clan-cli/tests/openapi_client/models/validation_error.py b/pkgs/clan-cli/tests/openapi_client/models/validation_error.py new file mode 100644 index 0000000..466a764 --- /dev/null +++ b/pkgs/clan-cli/tests/openapi_client/models/validation_error.py @@ -0,0 +1,83 @@ +# coding: utf-8 + +""" + FastAPI + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: 0.1.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + + +from typing import List +from pydantic import BaseModel, Field, StrictStr, conlist +from openapi_client.models.validation_error_loc_inner import ValidationErrorLocInner + +class ValidationError(BaseModel): + """ + ValidationError + """ + loc: conlist(ValidationErrorLocInner) = Field(...) + msg: StrictStr = Field(...) + type: StrictStr = Field(...) + __properties = ["loc", "msg", "type"] + + class Config: + """Pydantic configuration""" + allow_population_by_field_name = True + validate_assignment = True + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.dict(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> ValidationError: + """Create an instance of ValidationError from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self): + """Returns the dictionary representation of the model using alias""" + _dict = self.dict(by_alias=True, + exclude={ + }, + exclude_none=True) + # override the default output from pydantic by calling `to_dict()` of each item in loc (list) + _items = [] + if self.loc: + for _item in self.loc: + if _item: + _items.append(_item.to_dict()) + _dict['loc'] = _items + return _dict + + @classmethod + def from_dict(cls, obj: dict) -> ValidationError: + """Create an instance of ValidationError from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return ValidationError.parse_obj(obj) + + _obj = ValidationError.parse_obj({ + "loc": [ValidationErrorLocInner.from_dict(_item) for _item in obj.get("loc")] if obj.get("loc") is not None else None, + "msg": obj.get("msg"), + "type": obj.get("type") + }) + return _obj + + diff --git a/pkgs/clan-cli/tests/openapi_client/models/validation_error_loc_inner.py b/pkgs/clan-cli/tests/openapi_client/models/validation_error_loc_inner.py new file mode 100644 index 0000000..fbfce3b --- /dev/null +++ b/pkgs/clan-cli/tests/openapi_client/models/validation_error_loc_inner.py @@ -0,0 +1,138 @@ +# coding: utf-8 + +""" + FastAPI + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: 0.1.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +from inspect import getfullargspec +import json +import pprint +import re # noqa: F401 + +from typing import Optional +from pydantic import BaseModel, Field, StrictInt, StrictStr, ValidationError, validator +from typing import Union, Any, List, TYPE_CHECKING +from pydantic import StrictStr, Field + +VALIDATIONERRORLOCINNER_ANY_OF_SCHEMAS = ["int", "str"] + +class ValidationErrorLocInner(BaseModel): + """ + ValidationErrorLocInner + """ + + # data type: str + anyof_schema_1_validator: Optional[StrictStr] = None + # data type: int + anyof_schema_2_validator: Optional[StrictInt] = None + if TYPE_CHECKING: + actual_instance: Union[int, str] + else: + actual_instance: Any + any_of_schemas: List[str] = Field(VALIDATIONERRORLOCINNER_ANY_OF_SCHEMAS, const=True) + + class Config: + validate_assignment = True + + def __init__(self, *args, **kwargs) -> None: + if args: + if len(args) > 1: + raise ValueError("If a position argument is used, only 1 is allowed to set `actual_instance`") + if kwargs: + raise ValueError("If a position argument is used, keyword arguments cannot be used.") + super().__init__(actual_instance=args[0]) + else: + super().__init__(**kwargs) + + @validator('actual_instance') + def actual_instance_must_validate_anyof(cls, v): + instance = ValidationErrorLocInner.construct() + error_messages = [] + # validate data type: str + try: + instance.anyof_schema_1_validator = v + return v + except (ValidationError, ValueError) as e: + error_messages.append(str(e)) + # validate data type: int + try: + instance.anyof_schema_2_validator = v + return v + except (ValidationError, ValueError) as e: + error_messages.append(str(e)) + if error_messages: + # no match + raise ValueError("No match found when setting the actual_instance in ValidationErrorLocInner with anyOf schemas: int, str. Details: " + ", ".join(error_messages)) + else: + return v + + @classmethod + def from_dict(cls, obj: dict) -> ValidationErrorLocInner: + return cls.from_json(json.dumps(obj)) + + @classmethod + def from_json(cls, json_str: str) -> ValidationErrorLocInner: + """Returns the object represented by the json string""" + instance = ValidationErrorLocInner.construct() + error_messages = [] + # deserialize data into str + try: + # validation + instance.anyof_schema_1_validator = json.loads(json_str) + # assign value to actual_instance + instance.actual_instance = instance.anyof_schema_1_validator + return instance + except (ValidationError, ValueError) as e: + error_messages.append(str(e)) + # deserialize data into int + try: + # validation + instance.anyof_schema_2_validator = json.loads(json_str) + # assign value to actual_instance + instance.actual_instance = instance.anyof_schema_2_validator + return instance + except (ValidationError, ValueError) as e: + error_messages.append(str(e)) + + if error_messages: + # no match + raise ValueError("No match found when deserializing the JSON string into ValidationErrorLocInner with anyOf schemas: int, str. Details: " + ", ".join(error_messages)) + else: + return instance + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + if self.actual_instance is None: + return "null" + + to_json = getattr(self.actual_instance, "to_json", None) + if callable(to_json): + return self.actual_instance.to_json() + else: + return json.dumps(self.actual_instance) + + def to_dict(self) -> dict: + """Returns the dict representation of the actual instance""" + if self.actual_instance is None: + return "null" + + to_json = getattr(self.actual_instance, "to_json", None) + if callable(to_json): + return self.actual_instance.to_dict() + else: + return json.dumps(self.actual_instance) + + def to_str(self) -> str: + """Returns the string representation of the actual instance""" + return pprint.pformat(self.dict()) + + diff --git a/pkgs/clan-cli/tests/openapi_client/py.typed b/pkgs/clan-cli/tests/openapi_client/py.typed new file mode 100644 index 0000000..e69de29 diff --git a/pkgs/clan-cli/tests/openapi_client/rest.py b/pkgs/clan-cli/tests/openapi_client/rest.py new file mode 100644 index 0000000..3e5c074 --- /dev/null +++ b/pkgs/clan-cli/tests/openapi_client/rest.py @@ -0,0 +1,303 @@ +# coding: utf-8 + +""" + FastAPI + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: 0.1.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import io +import json +import logging +import re +import ssl + +from urllib.parse import urlencode, quote_plus +import urllib3 + +from openapi_client.exceptions import ApiException, UnauthorizedException, ForbiddenException, NotFoundException, ServiceException, ApiValueError, BadRequestException + + +logger = logging.getLogger(__name__) + + +class RESTResponse(io.IOBase): + + def __init__(self, resp) -> None: + self.urllib3_response = resp + self.status = resp.status + self.reason = resp.reason + self.data = resp.data + + def getheaders(self): + """Returns a dictionary of the response headers.""" + return self.urllib3_response.headers + + def getheader(self, name, default=None): + """Returns a given response header.""" + return self.urllib3_response.headers.get(name, default) + + +class RESTClientObject: + + def __init__(self, configuration, pools_size=4, maxsize=None) -> None: + # urllib3.PoolManager will pass all kw parameters to connectionpool + # https://github.com/shazow/urllib3/blob/f9409436f83aeb79fbaf090181cd81b784f1b8ce/urllib3/poolmanager.py#L75 # noqa: E501 + # https://github.com/shazow/urllib3/blob/f9409436f83aeb79fbaf090181cd81b784f1b8ce/urllib3/connectionpool.py#L680 # noqa: E501 + # maxsize is the number of requests to host that are allowed in parallel # noqa: E501 + # Custom SSL certificates and client certificates: http://urllib3.readthedocs.io/en/latest/advanced-usage.html # noqa: E501 + + # cert_reqs + if configuration.verify_ssl: + cert_reqs = ssl.CERT_REQUIRED + else: + cert_reqs = ssl.CERT_NONE + + addition_pool_args = {} + if configuration.assert_hostname is not None: + addition_pool_args['assert_hostname'] = configuration.assert_hostname # noqa: E501 + + if configuration.retries is not None: + addition_pool_args['retries'] = configuration.retries + + if configuration.tls_server_name: + addition_pool_args['server_hostname'] = configuration.tls_server_name + + + if configuration.socket_options is not None: + addition_pool_args['socket_options'] = configuration.socket_options + + if maxsize is None: + if configuration.connection_pool_maxsize is not None: + maxsize = configuration.connection_pool_maxsize + else: + maxsize = 4 + + # https pool manager + if configuration.proxy: + self.pool_manager = urllib3.ProxyManager( + num_pools=pools_size, + maxsize=maxsize, + cert_reqs=cert_reqs, + ca_certs=configuration.ssl_ca_cert, + cert_file=configuration.cert_file, + key_file=configuration.key_file, + proxy_url=configuration.proxy, + proxy_headers=configuration.proxy_headers, + **addition_pool_args + ) + else: + self.pool_manager = urllib3.PoolManager( + num_pools=pools_size, + maxsize=maxsize, + cert_reqs=cert_reqs, + ca_certs=configuration.ssl_ca_cert, + cert_file=configuration.cert_file, + key_file=configuration.key_file, + **addition_pool_args + ) + + def request(self, method, url, query_params=None, headers=None, + body=None, post_params=None, _preload_content=True, + _request_timeout=None): + """Perform requests. + + :param method: http request method + :param url: http request url + :param query_params: query parameters in the url + :param headers: http request headers + :param body: request json body, for `application/json` + :param post_params: request post parameters, + `application/x-www-form-urlencoded` + and `multipart/form-data` + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + """ + method = method.upper() + assert method in ['GET', 'HEAD', 'DELETE', 'POST', 'PUT', + 'PATCH', 'OPTIONS'] + + if post_params and body: + raise ApiValueError( + "body parameter cannot be used with post_params parameter." + ) + + post_params = post_params or {} + headers = headers or {} + # url already contains the URL query string + # so reset query_params to empty dict + query_params = {} + + timeout = None + if _request_timeout: + if isinstance(_request_timeout, (int,float)): # noqa: E501,F821 + timeout = urllib3.Timeout(total=_request_timeout) + elif (isinstance(_request_timeout, tuple) and + len(_request_timeout) == 2): + timeout = urllib3.Timeout( + connect=_request_timeout[0], read=_request_timeout[1]) + + try: + # For `POST`, `PUT`, `PATCH`, `OPTIONS`, `DELETE` + if method in ['POST', 'PUT', 'PATCH', 'OPTIONS', 'DELETE']: + + # no content type provided or payload is json + if not headers.get('Content-Type') or re.search('json', headers['Content-Type'], re.IGNORECASE): + request_body = None + if body is not None: + request_body = json.dumps(body) + r = self.pool_manager.request( + method, url, + body=request_body, + preload_content=_preload_content, + timeout=timeout, + headers=headers) + elif headers['Content-Type'] == 'application/x-www-form-urlencoded': # noqa: E501 + r = self.pool_manager.request( + method, url, + fields=post_params, + encode_multipart=False, + preload_content=_preload_content, + timeout=timeout, + headers=headers) + elif headers['Content-Type'] == 'multipart/form-data': + # must del headers['Content-Type'], or the correct + # Content-Type which generated by urllib3 will be + # overwritten. + del headers['Content-Type'] + r = self.pool_manager.request( + method, url, + fields=post_params, + encode_multipart=True, + preload_content=_preload_content, + timeout=timeout, + headers=headers) + # Pass a `string` parameter directly in the body to support + # other content types than Json when `body` argument is + # provided in serialized form + elif isinstance(body, str) or isinstance(body, bytes): + request_body = body + r = self.pool_manager.request( + method, url, + body=request_body, + preload_content=_preload_content, + timeout=timeout, + headers=headers) + else: + # Cannot generate the request from given parameters + msg = """Cannot prepare a request message for provided + arguments. Please check that your arguments match + declared content type.""" + raise ApiException(status=0, reason=msg) + # For `GET`, `HEAD` + else: + r = self.pool_manager.request(method, url, + fields={}, + preload_content=_preload_content, + timeout=timeout, + headers=headers) + except urllib3.exceptions.SSLError as e: + msg = "{0}\n{1}".format(type(e).__name__, str(e)) + raise ApiException(status=0, reason=msg) + + if _preload_content: + r = RESTResponse(r) + + # log response body + logger.debug("response body: %s", r.data) + + if not 200 <= r.status <= 299: + if r.status == 400: + raise BadRequestException(http_resp=r) + + if r.status == 401: + raise UnauthorizedException(http_resp=r) + + if r.status == 403: + raise ForbiddenException(http_resp=r) + + if r.status == 404: + raise NotFoundException(http_resp=r) + + if 500 <= r.status <= 599: + raise ServiceException(http_resp=r) + + raise ApiException(http_resp=r) + + return r + + def get_request(self, url, headers=None, query_params=None, _preload_content=True, + _request_timeout=None): + return self.request("GET", url, + headers=headers, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + query_params=query_params) + + def head_request(self, url, headers=None, query_params=None, _preload_content=True, + _request_timeout=None): + return self.request("HEAD", url, + headers=headers, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + query_params=query_params) + + def options_request(self, url, headers=None, query_params=None, post_params=None, + body=None, _preload_content=True, _request_timeout=None): + return self.request("OPTIONS", url, + headers=headers, + query_params=query_params, + post_params=post_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + body=body) + + def delete_request(self, url, headers=None, query_params=None, body=None, + _preload_content=True, _request_timeout=None): + return self.request("DELETE", url, + headers=headers, + query_params=query_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + body=body) + + def post_request(self, url, headers=None, query_params=None, post_params=None, + body=None, _preload_content=True, _request_timeout=None): + return self.request("POST", url, + headers=headers, + query_params=query_params, + post_params=post_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + body=body) + + def put_request(self, url, headers=None, query_params=None, post_params=None, + body=None, _preload_content=True, _request_timeout=None): + return self.request("PUT", url, + headers=headers, + query_params=query_params, + post_params=post_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + body=body) + + def patch_request(self, url, headers=None, query_params=None, post_params=None, + body=None, _preload_content=True, _request_timeout=None): + return self.request("PATCH", url, + headers=headers, + query_params=query_params, + post_params=post_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + body=body) diff --git a/pkgs/clan-cli/tests/test_db_api.py b/pkgs/clan-cli/tests/test_db_api.py index b1693ca..0fb3383 100644 --- a/pkgs/clan-cli/tests/test_db_api.py +++ b/pkgs/clan-cli/tests/test_db_api.py @@ -2,6 +2,8 @@ import urllib.parse as url from typing import Any from api import TestClient +from openapi_client.api.entities_api import EntitiesApi + default_entity_did_url = "entity_did=did%3Asov%3Atest%3A1234" default_entity_did = "did:sov:test:1234" @@ -10,328 +12,3 @@ default_entity_did3 = "did:sov:test:1236" default_entity_did4 = "did:sov:test:1237" default_entity_did5 = "did:sov:test:1238" - -def assert_extra_info( - infos: list[str], - request_body: dict[str, Any], - response: dict[str, str], -) -> None: - # print(type()) - for info in infos: - assert info in response.keys() - # TODO maybe check the content of the extra info ... - response.pop(info) - assert response == request_body - - -def make_test_post_and_get( - api: TestClient, - request_body: dict[str, Any], - paramter: str, - get_request: str = default_entity_did_url, - apiversion: str = "v1", -) -> None: - # test post - response = api.post( - f"/api/{apiversion}/create_{paramter}", - json=request_body, - headers={"Content-Type": "application/json"}, - ) - assert response.status_code == 200 - - if paramter == "repository": - assert_extra_info(["time_created"], request_body, response.json()) - elif paramter == "resolution": - assert_extra_info(["timestamp", "id"], request_body, response.json()) - elif paramter == "client": - assert_extra_info(["id"], request_body, response.json()) - elif paramter == "entity": - assert_extra_info( - ["clients", "services", "repository"], request_body, response.json() - ) - else: - assert response.json() == request_body - # test get - response = api.get( - f"api/{apiversion}/get_{paramter}?{get_request}&skip=0&limit=100" - ) - assert response.status_code == 200 - if paramter == "repository": - assert_extra_info(["time_created"], request_body, response.json()[0]) - elif paramter == "resolution": - assert_extra_info(["timestamp", "id"], request_body, response.json()[0]) - elif paramter == "client": - assert_extra_info(["id"], request_body, response.json()[0]) - elif paramter == "entity": - assert_extra_info( - ["clients", "services", "repository"], request_body, response.json() - ) - else: - assert response.json() == [request_body] - - -######################### -# # -# service # -# # -######################### -def test_service(api: TestClient) -> None: - request_body = { - "uuid": "8e285c0c-4e40-430a-a477-26b3b81e30df", - "service_name": "Carlo'''s Printing", - "service_type": "3D Printing", - "endpoint_url": "http://127.0.0.1:8000", - "status": "unknown", - "other": {"action": ["register", "deregister", "delete", "create"]}, - "entity_did": default_entity_did, - } - paramter = "service" - # get_request = "entity_did=did%3Asov%3Atest%3A1234" - make_test_post_and_get(api, request_body, paramter) - - -def test_service2(api: TestClient) -> None: - request_body = { - "uuid": "8e285c0c-4e40-430a-a477-26b3b81e30d1", - "service_name": "Luis'''s Fax", - "service_type": "Fax", - "endpoint_url": "http://127.0.0.1:8001", - "status": "unknown", - "other": {"action": ["register", "deregister", "delete", "create"]}, - "entity_did": default_entity_did2, - } - paramter = "service" - get_request = "entity_did=" + url.quote(default_entity_did2) - make_test_post_and_get(api, request_body, paramter, get_request) - - -def test_service3(api: TestClient) -> None: - request_body = { - "uuid": "8e285c0c-4e40-430a-a477-26b3b81e30d2", - "service_name": "Erdem'''s VR-Stream", - "service_type": "VR-Stream", - "endpoint_url": "http://127.0.0.1:8002", - "status": "unknown", - "other": {"action": ["register", "deregister", "delete", "create"]}, - "entity_did": default_entity_did3, - } - paramter = "service" - get_request = "entity_did=" + url.quote(default_entity_did3) - make_test_post_and_get(api, request_body, paramter, get_request) - - -def test_service4(api: TestClient) -> None: - request_body = { - "uuid": "8e285c0c-4e40-430a-a477-26b3b81e30d3", - "service_name": "Onur'''s gallary", - "service_type": "gallary", - "endpoint_url": "http://127.0.0.1:8003", - "status": "unknown", - "other": {"action": ["register", "deregister", "delete", "create"]}, - "entity_did": default_entity_did4, - } - paramter = "service" - get_request = "entity_did=" + url.quote(default_entity_did4) - make_test_post_and_get(api, request_body, paramter, get_request) - - -def test_service5(api: TestClient) -> None: - request_body = { - "uuid": "8e285c0c-4e40-430a-a477-26b3b81e30d4", - "service_name": "Sara'''s Game-Shop", - "service_type": "Game-Shop", - "endpoint_url": "http://127.0.0.1:8004", - "status": "unknown", - "other": {"action": ["register", "deregister", "delete", "create"]}, - "entity_did": default_entity_did5, - } - paramter = "service" - get_request = "entity_did=" + url.quote(default_entity_did5) - make_test_post_and_get(api, request_body, paramter, get_request) - - -######################### -# # -# client # -# # -######################### -def test_client(api: TestClient) -> None: - request_body = { - "entity_did": default_entity_did, - "service_uuid": "8e285c0c-4e40-430a-a477-26b3b81e30df", - "other": {"test": "test"}, - } - paramter = "client" - # get_request = "entity_did=did%3Asov%3Atest%3A1234" - make_test_post_and_get(api, request_body, paramter) - - -def test_client2(api: TestClient) -> None: - request_body = { - "entity_did": default_entity_did2, - "service_uuid": "8e285c0c-4e40-430a-a477-26b3b81e30d4", - "other": {"war": "games"}, - } - paramter = "client" - get_request = "entity_did=" + url.quote(default_entity_did2) - make_test_post_and_get(api, request_body, paramter, get_request) - - -######################### -# # -# REPOSITORY # -# # -######################### -def test_repository(api: TestClient) -> None: - request_body = { - "uuid": "8e285c0c-4e40-430a-a477-26b3b81e30df", - "service_name": "Carlo'''s Printing", - "service_type": "3D Printing", - "endpoint_url": "http://127.0.0.1:8000", - "status": "unknown", - "other": {"test": "test"}, - "entity_did": default_entity_did, - } - paramter = "repository" - # get_request = "entity_did=did%3Asov%3Atest%3A1234" - make_test_post_and_get(api, request_body, paramter) - - -def test_repository2(api: TestClient) -> None: - request_body = { - "uuid": "8e285c0c-4e40-430a-a477-26b3b81e30d1", - "service_name": "Luis'''s Fax", - "service_type": "Fax", - "endpoint_url": "http://127.0.0.1:8001", - "status": "unknown", - "other": {"faxen": "dicke"}, - "entity_did": default_entity_did2, - } - paramter = "repository" - get_request = "entity_did=" + url.quote(default_entity_did2) - make_test_post_and_get(api, request_body, paramter, get_request) - - -def test_repository3(api: TestClient) -> None: - request_body = { - "uuid": "8e285c0c-4e40-430a-a477-26b3b81e30d2", - "service_name": "Erdem'''s VR-Stream", - "service_type": "VR-Stream", - "endpoint_url": "http://127.0.0.1:8002", - "status": "unknown", - "other": {"oculos": "rift"}, - "entity_did": default_entity_did3, - } - paramter = "repository" - get_request = "entity_did=" + url.quote(default_entity_did3) - make_test_post_and_get(api, request_body, paramter, get_request) - - -def test_repository4(api: TestClient) -> None: - request_body = { - "uuid": "8e285c0c-4e40-430a-a477-26b3b81e30d3", - "service_name": "Onur'''s gallary", - "service_type": "gallary", - "endpoint_url": "http://127.0.0.1:8003", - "status": "unknown", - "other": {"nice": "pics"}, - "entity_did": default_entity_did4, - } - paramter = "repository" - get_request = "entity_did=" + url.quote(default_entity_did4) - make_test_post_and_get(api, request_body, paramter, get_request) - - -def test_repository5(api: TestClient) -> None: - request_body = { - "uuid": "8e285c0c-4e40-430a-a477-26b3b81e30d4", - "service_name": "Sara'''s Game-Shop", - "service_type": "Game-Shop", - "endpoint_url": "http://127.0.0.2:8004", - "status": "unknown", - "other": {"war": "games"}, - "entity_did": default_entity_did5, - } - paramter = "repository" - get_request = "entity_did=" + url.quote(default_entity_did5) - make_test_post_and_get(api, request_body, paramter, get_request) - - -######################### -# # -# Entity # -# # -######################### -def test_entity(api: TestClient) -> None: - request_body = { - "did": default_entity_did, - "name": "C1", - "ip": "127.0.0.1:5555", - "attached": False, - "visible": True, - "other": { - "network": "Carlo1's Home Network", - "roles": ["service repository", "service client"], - }, - } - paramter = "entity" - # get_request = "entity_did=did%3Asov%3Atest%3A1234" - make_test_post_and_get(api, request_body, paramter) - - -def test_entity2(api: TestClient) -> None: - request_body = { - "did": default_entity_did2, - "name": "C2", - "ip": "127.0.0.1:5555", - "attached": False, - "visible": True, - "other": { - "network": "Carlo2's Home Network", - "roles": ["service repository", "service prosumer"], - }, - } - paramter = "entity" - get_request = "entity_did=" + url.quote(default_entity_did2) - make_test_post_and_get(api, request_body, paramter, get_request) - - -######################### -# # -# Resolution # -# # -######################### -def test_resolution(api: TestClient) -> None: - request_body = { - "requester_did": default_entity_did2, - "requester_name": "C2", - "resolved_did": default_entity_did, - "other": {"test": "test"}, - } - paramter = "resolution" - get_request = "requester_did=" + url.quote(default_entity_did2) - make_test_post_and_get(api, request_body, paramter, get_request) - - -def test_resolution2(api: TestClient) -> None: - request_body = { - "requester_did": default_entity_did3, - "requester_name": "C3", - "resolved_did": default_entity_did, - "other": {"test": "test"}, - } - paramter = "resolution" - get_request = "requester_did=" + url.quote(default_entity_did3) - make_test_post_and_get(api, request_body, paramter, get_request) - - -def test_resolution3(api: TestClient) -> None: - request_body = { - "requester_did": default_entity_did4, - "requester_name": "C4", - "resolved_did": default_entity_did, - "other": {"test": "test"}, - } - paramter = "resolution" - get_request = "requester_did=" + url.quote(default_entity_did4) - make_test_post_and_get(api, request_body, paramter, get_request) From 0c9a8349a6293c626714bab42583f8e8c8da13b2 Mon Sep 17 00:00:00 2001 From: Luis-Hebendanz Date: Fri, 5 Jan 2024 13:44:42 +0100 Subject: [PATCH 34/58] Added exclude **/tests/openapi_client/** to nix fmt --- formatter.nix | 2 ++ pkgs/clan-cli/clan_cli/webui/schemas.py | 4 ++-- pkgs/clan-cli/pyproject.toml | 7 +++++-- pkgs/clan-cli/tests/openapi_client/models/service.py | 4 ++-- .../tests/openapi_client/models/service_create.py | 4 ++-- pkgs/clan-cli/tests/test_db_api.py | 8 -------- pkgs/ui/README.md | 1 + 7 files changed, 14 insertions(+), 16 deletions(-) diff --git a/formatter.nix b/formatter.nix index ee1c751..5d7a76b 100644 --- a/formatter.nix +++ b/formatter.nix @@ -25,6 +25,7 @@ "pkgs/clan-cli".extraPythonPackages = self'.packages.clan-cli.pytestDependencies; }; + treefmt.settings.formatter.nix = { command = "sh"; options = [ @@ -51,6 +52,7 @@ "--" # this argument is ignored by bash ]; includes = [ "*.py" ]; + excludes = [ "**/tests/openapi_client/**" ]; }; }; } diff --git a/pkgs/clan-cli/clan_cli/webui/schemas.py b/pkgs/clan-cli/clan_cli/webui/schemas.py index eee4451..b98b9b7 100644 --- a/pkgs/clan-cli/clan_cli/webui/schemas.py +++ b/pkgs/clan-cli/clan_cli/webui/schemas.py @@ -22,7 +22,7 @@ class Machine(BaseModel): ######################### class ServiceBase(BaseModel): uuid: str = "8e285c0c-4e40-430a-a477-26b3b81e30df" - service_name: str = "Carlo's Printing" + service_name: str = "Carlos Printing" service_type: str = "3D Printing" endpoint_url: str = "http://127.0.0.1:8000" status: str = "unknown" @@ -49,7 +49,7 @@ class EntityBase(BaseModel): ip: str = "127.0.0.1" visible: bool = True other: dict = { - "network": "Carlo's Home Network", + "network": "Carlos Home Network", "roles": ["service repository", "service prosumer"], } diff --git a/pkgs/clan-cli/pyproject.toml b/pkgs/clan-cli/pyproject.toml index 3f48ba3..de8f11a 100644 --- a/pkgs/clan-cli/pyproject.toml +++ b/pkgs/clan-cli/pyproject.toml @@ -31,7 +31,10 @@ warn_redundant_casts = true disallow_untyped_calls = true disallow_untyped_defs = true no_implicit_optional = true -exclude = "clan_cli.nixpkgs" +exclude = [ + "clan_cli.nixpkgs", + "tests/openapi_client", +] [[tool.mypy.overrides]] module = "argcomplete.*" @@ -60,9 +63,9 @@ ignore_missing_imports = true [tool.ruff] line-length = 88 - select = [ "E", "F", "I", "N"] ignore = [ "E501" ] +exclude = ["tests/openapi_client"] [tool.black] line-length = 88 diff --git a/pkgs/clan-cli/tests/openapi_client/models/service.py b/pkgs/clan-cli/tests/openapi_client/models/service.py index 3128a41..14cc136 100644 --- a/pkgs/clan-cli/tests/openapi_client/models/service.py +++ b/pkgs/clan-cli/tests/openapi_client/models/service.py @@ -26,7 +26,7 @@ class Service(BaseModel): Service """ uuid: Optional[StrictStr] = '8e285c0c-4e40-430a-a477-26b3b81e30df' - service_name: Optional[StrictStr] = 'Carlo's Printing' + service_name: Optional[StrictStr] = 'Carlos Printing' service_type: Optional[StrictStr] = '3D Printing' endpoint_url: Optional[StrictStr] = 'http://127.0.0.1:8000' status: Optional[StrictStr] = 'unknown' @@ -71,7 +71,7 @@ class Service(BaseModel): _obj = Service.parse_obj({ "uuid": obj.get("uuid") if obj.get("uuid") is not None else '8e285c0c-4e40-430a-a477-26b3b81e30df', - "service_name": obj.get("service_name") if obj.get("service_name") is not None else 'Carlo's Printing', + "service_name": obj.get("service_name") if obj.get("service_name") is not None else 'Carlos Printing', "service_type": obj.get("service_type") if obj.get("service_type") is not None else '3D Printing', "endpoint_url": obj.get("endpoint_url") if obj.get("endpoint_url") is not None else 'http://127.0.0.1:8000', "status": obj.get("status") if obj.get("status") is not None else 'unknown', diff --git a/pkgs/clan-cli/tests/openapi_client/models/service_create.py b/pkgs/clan-cli/tests/openapi_client/models/service_create.py index d6efb93..3d6b732 100644 --- a/pkgs/clan-cli/tests/openapi_client/models/service_create.py +++ b/pkgs/clan-cli/tests/openapi_client/models/service_create.py @@ -26,7 +26,7 @@ class ServiceCreate(BaseModel): ServiceCreate """ uuid: Optional[StrictStr] = '8e285c0c-4e40-430a-a477-26b3b81e30df' - service_name: Optional[StrictStr] = 'Carlo's Printing' + service_name: Optional[StrictStr] = 'Carlos Printing' service_type: Optional[StrictStr] = '3D Printing' endpoint_url: Optional[StrictStr] = 'http://127.0.0.1:8000' status: Optional[StrictStr] = 'unknown' @@ -71,7 +71,7 @@ class ServiceCreate(BaseModel): _obj = ServiceCreate.parse_obj({ "uuid": obj.get("uuid") if obj.get("uuid") is not None else '8e285c0c-4e40-430a-a477-26b3b81e30df', - "service_name": obj.get("service_name") if obj.get("service_name") is not None else 'Carlo's Printing', + "service_name": obj.get("service_name") if obj.get("service_name") is not None else 'Carlos Printing', "service_type": obj.get("service_type") if obj.get("service_type") is not None else '3D Printing', "endpoint_url": obj.get("endpoint_url") if obj.get("endpoint_url") is not None else 'http://127.0.0.1:8000', "status": obj.get("status") if obj.get("status") is not None else 'unknown', diff --git a/pkgs/clan-cli/tests/test_db_api.py b/pkgs/clan-cli/tests/test_db_api.py index 0fb3383..99f9624 100644 --- a/pkgs/clan-cli/tests/test_db_api.py +++ b/pkgs/clan-cli/tests/test_db_api.py @@ -1,14 +1,6 @@ -import urllib.parse as url -from typing import Any - -from api import TestClient -from openapi_client.api.entities_api import EntitiesApi - - default_entity_did_url = "entity_did=did%3Asov%3Atest%3A1234" default_entity_did = "did:sov:test:1234" default_entity_did2 = "did:sov:test:1235" default_entity_did3 = "did:sov:test:1236" default_entity_did4 = "did:sov:test:1237" default_entity_did5 = "did:sov:test:1238" - diff --git a/pkgs/ui/README.md b/pkgs/ui/README.md index 4a81fd9..ed8aeb6 100644 --- a/pkgs/ui/README.md +++ b/pkgs/ui/README.md @@ -25,4 +25,5 @@ Than run this command: ``` GITEA_TOKEN= nix run .#update-ui-assets ``` + . From aa664dfce1c60a8bd4d57d1d11f7df9467342f9f Mon Sep 17 00:00:00 2001 From: Luis-Hebendanz Date: Fri, 5 Jan 2024 16:50:27 +0100 Subject: [PATCH 35/58] Added working python generator in tests --- pkgs/clan-cli/bin/gen-python-client | 34 +- .../clan_cli/webui/routers/sql_connect.py | 24 +- pkgs/clan-cli/default.nix | 9 +- pkgs/clan-cli/flake-module.nix | 1 - pkgs/clan-cli/pyproject.toml | 1 + pkgs/clan-cli/tests/api.py | 53 +- .../tests/openapi_client/api/entities_api.py | 2 +- .../tests/openapi_client/api/services_api.py | 2 +- .../tests/openapi_client/docs/ClientsApi.md | 77 +++ .../tests/openapi_client/docs/DefaultApi.md | 193 +++++++ .../tests/openapi_client/docs/EntitiesApi.md | 486 ++++++++++++++++++ .../tests/openapi_client/docs/Entity.md | 32 ++ .../tests/openapi_client/docs/EntityCreate.md | 31 ++ .../docs/HTTPValidationError.md | 27 + .../tests/openapi_client/docs/Machine.md | 28 + .../openapi_client/docs/RepositoriesApi.md | 75 +++ .../tests/openapi_client/docs/Resolution.md | 32 ++ .../openapi_client/docs/ResolutionApi.md | 75 +++ .../tests/openapi_client/docs/Service.md | 33 ++ .../openapi_client/docs/ServiceCreate.md | 33 ++ .../tests/openapi_client/docs/ServicesApi.md | 280 ++++++++++ .../tests/openapi_client/docs/Status.md | 10 + .../openapi_client/docs/ValidationError.md | 29 ++ .../docs/ValidationErrorLocInner.md | 26 + .../{py.typed => test/__init__.py} | 0 .../openapi_client/test/test_clients_api.py | 38 ++ .../openapi_client/test/test_default_api.py | 52 ++ .../openapi_client/test/test_entities_api.py | 80 +++ .../tests/openapi_client/test/test_entity.py | 58 +++ .../openapi_client/test/test_entity_create.py | 56 ++ .../test/test_http_validation_error.py | 59 +++ .../tests/openapi_client/test/test_machine.py | 55 ++ .../test/test_repositories_api.py | 38 ++ .../openapi_client/test/test_resolution.py | 59 +++ .../test/test_resolution_api.py | 38 ++ .../tests/openapi_client/test/test_service.py | 58 +++ .../test/test_service_create.py | 58 +++ .../openapi_client/test/test_services_api.py | 59 +++ .../tests/openapi_client/test/test_status.py | 34 ++ .../test/test_validation_error.py | 61 +++ .../test/test_validation_error_loc_inner.py | 51 ++ pkgs/clan-cli/tests/test_db_api.py | 10 + 42 files changed, 2436 insertions(+), 21 deletions(-) create mode 100644 pkgs/clan-cli/tests/openapi_client/docs/ClientsApi.md create mode 100644 pkgs/clan-cli/tests/openapi_client/docs/DefaultApi.md create mode 100644 pkgs/clan-cli/tests/openapi_client/docs/EntitiesApi.md create mode 100644 pkgs/clan-cli/tests/openapi_client/docs/Entity.md create mode 100644 pkgs/clan-cli/tests/openapi_client/docs/EntityCreate.md create mode 100644 pkgs/clan-cli/tests/openapi_client/docs/HTTPValidationError.md create mode 100644 pkgs/clan-cli/tests/openapi_client/docs/Machine.md create mode 100644 pkgs/clan-cli/tests/openapi_client/docs/RepositoriesApi.md create mode 100644 pkgs/clan-cli/tests/openapi_client/docs/Resolution.md create mode 100644 pkgs/clan-cli/tests/openapi_client/docs/ResolutionApi.md create mode 100644 pkgs/clan-cli/tests/openapi_client/docs/Service.md create mode 100644 pkgs/clan-cli/tests/openapi_client/docs/ServiceCreate.md create mode 100644 pkgs/clan-cli/tests/openapi_client/docs/ServicesApi.md create mode 100644 pkgs/clan-cli/tests/openapi_client/docs/Status.md create mode 100644 pkgs/clan-cli/tests/openapi_client/docs/ValidationError.md create mode 100644 pkgs/clan-cli/tests/openapi_client/docs/ValidationErrorLocInner.md rename pkgs/clan-cli/tests/openapi_client/{py.typed => test/__init__.py} (100%) create mode 100644 pkgs/clan-cli/tests/openapi_client/test/test_clients_api.py create mode 100644 pkgs/clan-cli/tests/openapi_client/test/test_default_api.py create mode 100644 pkgs/clan-cli/tests/openapi_client/test/test_entities_api.py create mode 100644 pkgs/clan-cli/tests/openapi_client/test/test_entity.py create mode 100644 pkgs/clan-cli/tests/openapi_client/test/test_entity_create.py create mode 100644 pkgs/clan-cli/tests/openapi_client/test/test_http_validation_error.py create mode 100644 pkgs/clan-cli/tests/openapi_client/test/test_machine.py create mode 100644 pkgs/clan-cli/tests/openapi_client/test/test_repositories_api.py create mode 100644 pkgs/clan-cli/tests/openapi_client/test/test_resolution.py create mode 100644 pkgs/clan-cli/tests/openapi_client/test/test_resolution_api.py create mode 100644 pkgs/clan-cli/tests/openapi_client/test/test_service.py create mode 100644 pkgs/clan-cli/tests/openapi_client/test/test_service_create.py create mode 100644 pkgs/clan-cli/tests/openapi_client/test/test_services_api.py create mode 100644 pkgs/clan-cli/tests/openapi_client/test/test_status.py create mode 100644 pkgs/clan-cli/tests/openapi_client/test/test_validation_error.py create mode 100644 pkgs/clan-cli/tests/openapi_client/test/test_validation_error_loc_inner.py diff --git a/pkgs/clan-cli/bin/gen-python-client b/pkgs/clan-cli/bin/gen-python-client index bfc881d..5e027f5 100755 --- a/pkgs/clan-cli/bin/gen-python-client +++ b/pkgs/clan-cli/bin/gen-python-client @@ -9,6 +9,24 @@ from uvicorn.importer import import_from_string import subprocess import shutil +import os +import re + +def replace_line_in_file(file_path: Path, pattern: str, replacement: str) -> None: + with open(file_path, 'r') as file: + content = file.read() + updated_content = re.sub(pattern, replacement, content) + with open(file_path, 'w') as file: + file.write(updated_content) + +def replace_in_directory(*, directory_path: Path, pattern: str, replacement: str) -> None: + for root, dirs, files in os.walk(directory_path): + for file in files: + file_path = Path(os.path.join(root, file)) + replace_line_in_file(file_path, pattern, replacement) + + + def main() -> None: parser = argparse.ArgumentParser(prog="gen-openapi") parser.add_argument( @@ -52,12 +70,22 @@ def main() -> None: f"{gen_code}", "-i", f"{openapi_p}", + "--additional-properties=generateSourceCodeOnly=true" ] subprocess.run(cmd, check=True, text=True) - dest_client: Path = args.out / "openapi_client" - shutil.rmtree(dest_client, ignore_errors=True) - shutil.copytree(gen_code / "openapi_client", dest_client) + + src_client: Path = gen_code / "openapi_client" + pattern = r"from typing import Any, List, Optional" + replacement = "from typing import Any, List, Optional, Dict" + replace_in_directory(directory_path=src_client, pattern=pattern, replacement=replacement) + + dst_client: Path = args.out / "openapi_client" + breakpoint() + shutil.rmtree(dst_client, ignore_errors=True) + shutil.copytree(src_client, dst_client) + + if __name__ == "__main__": diff --git a/pkgs/clan-cli/clan_cli/webui/routers/sql_connect.py b/pkgs/clan-cli/clan_cli/webui/routers/sql_connect.py index 6ca62b8..e4b1ea6 100644 --- a/pkgs/clan-cli/clan_cli/webui/routers/sql_connect.py +++ b/pkgs/clan-cli/clan_cli/webui/routers/sql_connect.py @@ -29,7 +29,7 @@ log = logging.getLogger(__name__) # # ######################### @router.post("/api/v1/service", response_model=Service, tags=[Tags.services]) -def create_service( +async def create_service( service: ServiceCreate, db: Session = Depends(sql_db.get_db) ) -> Service: # todo checken ob schon da ... @@ -37,7 +37,7 @@ def create_service( @router.get("/api/v1/services", response_model=List[Service], tags=[Tags.services]) -def get_all_services( +async def get_all_services( skip: int = 0, limit: int = 100, db: Session = Depends(sql_db.get_db) ) -> List[sql_models.Service]: services = sql_crud.get_services(db, skip=skip, limit=limit) @@ -47,7 +47,7 @@ def get_all_services( @router.get( "/api/v1/{entity_did}/service", response_model=List[Service], tags=[Tags.services] ) -def get_service_by_did( +async def get_service_by_did( entity_did: str = "did:sov:test:1234", skip: int = 0, limit: int = 100, @@ -58,7 +58,7 @@ def get_service_by_did( @router.delete("/api/v1/{entity_did}/service", tags=[Tags.services]) -def delete_service( +async def delete_service( entity_did: str = "did:sov:test:1234", db: Session = Depends(sql_db.get_db), ) -> dict[str, str]: @@ -74,7 +74,7 @@ def delete_service( @router.get( "/api/v1/{entity_did}/clients", response_model=List[Service], tags=[Tags.clients] ) -def get_all_clients( +async def get_all_clients( entity_did: str = "did:sov:test:1234", skip: int = 0, limit: int = 100, @@ -98,7 +98,7 @@ def get_all_clients( response_model=List[Service], tags=[Tags.repositories], ) -def get_all_repositories( +async def get_all_repositories( skip: int = 0, limit: int = 100, db: Session = Depends(sql_db.get_db) ) -> List[sql_models.Service]: repositories = sql_crud.get_services(db, skip=skip, limit=limit) @@ -111,14 +111,14 @@ def get_all_repositories( # # ######################### @router.post("/api/v1/entity", response_model=Entity, tags=[Tags.entities]) -def create_entity( +async def create_entity( entity: EntityCreate, db: Session = Depends(sql_db.get_db) ) -> EntityCreate: return sql_crud.create_entity(db, entity) @router.get("/api/v1/entities", response_model=List[Entity], tags=[Tags.entities]) -def get_all_entities( +async def get_all_entities( skip: int = 0, limit: int = 100, db: Session = Depends(sql_db.get_db) ) -> List[sql_models.Entity]: entities = sql_crud.get_entities(db, skip=skip, limit=limit) @@ -128,7 +128,7 @@ def get_all_entities( @router.get( "/api/v1/{entity_did}/entity", response_model=Optional[Entity], tags=[Tags.entities] ) -def get_entity_by_did( +async def get_entity_by_did( entity_did: str = "did:sov:test:1234", db: Session = Depends(sql_db.get_db), ) -> Optional[sql_models.Entity]: @@ -141,7 +141,7 @@ def get_entity_by_did( response_model=List[Entity], tags=[Tags.entities], ) -def get_attached_entities( +async def get_attached_entities( skip: int = 0, limit: int = 100, db: Session = Depends(sql_db.get_db) ) -> List[sql_models.Entity]: entities = sql_crud.get_attached_entities(db, skip=skip, limit=limit) @@ -196,7 +196,7 @@ def attach_entity_loc(db: Session, entity_did: str) -> None: @router.delete("/api/v1/{entity_did}/entity", tags=[Tags.entities]) -def delete_entity( +async def delete_entity( entity_did: str = "did:sov:test:1234", db: Session = Depends(sql_db.get_db), ) -> dict[str, str]: @@ -214,7 +214,7 @@ def delete_entity( @router.get( "/api/v1/resolutions", response_model=List[Resolution], tags=[Tags.resolutions] ) -def get_all_resolutions( +async def get_all_resolutions( skip: int = 0, limit: int = 100, db: Session = Depends(sql_db.get_db) ) -> List[Resolution]: # TODO: Get resolutions from DLG entity diff --git a/pkgs/clan-cli/default.nix b/pkgs/clan-cli/default.nix index 42347b6..6d3cd26 100644 --- a/pkgs/clan-cli/default.nix +++ b/pkgs/clan-cli/default.nix @@ -36,8 +36,10 @@ , mypy , sqlalchemy , websockets -, deal , broadcaster +, aenum +, dateutil +, urllib3 }: let @@ -48,7 +50,6 @@ let sqlalchemy websockets broadcaster - deal ]; pytestDependencies = runtimeDependencies ++ dependencies ++ [ @@ -63,6 +64,10 @@ let git gnupg stdenv.cc + # openapi client deps + dateutil + aenum + urllib3 ]; # Optional dependencies for clan cli, we re-expose them here to make sure they all build. diff --git a/pkgs/clan-cli/flake-module.nix b/pkgs/clan-cli/flake-module.nix index 5e3719c..e854320 100644 --- a/pkgs/clan-cli/flake-module.nix +++ b/pkgs/clan-cli/flake-module.nix @@ -8,7 +8,6 @@ clan-cli = pkgs.python3.pkgs.callPackage ./default.nix { inherit (self'.packages) ui-assets; inherit (inputs) nixpkgs; - inherit (inputs.nixpkgs-for-iosl.legacyPackages.${system}.python3Packages) deal; inherit (inputs.nixpkgs-for-iosl.legacyPackages.${system}.python3Packages) broadcaster; }; inherit (self'.packages.clan-cli) clan-openapi; diff --git a/pkgs/clan-cli/pyproject.toml b/pkgs/clan-cli/pyproject.toml index de8f11a..0149e3a 100644 --- a/pkgs/clan-cli/pyproject.toml +++ b/pkgs/clan-cli/pyproject.toml @@ -34,6 +34,7 @@ no_implicit_optional = true exclude = [ "clan_cli.nixpkgs", "tests/openapi_client", + "openapi_client", ] [[tool.mypy.overrides]] diff --git a/pkgs/clan-cli/tests/api.py b/pkgs/clan-cli/tests/api.py index 7dc1ed8..c95c1f9 100644 --- a/pkgs/clan-cli/tests/api.py +++ b/pkgs/clan-cli/tests/api.py @@ -1,9 +1,60 @@ +import sys +import time +import urllib.request +from multiprocessing import Process +from typing import Generator +from urllib.error import URLError + import pytest +import uvicorn from fastapi.testclient import TestClient +from openapi_client import ApiClient, Configuration from clan_cli.webui.app import app @pytest.fixture(scope="session") -def api() -> TestClient: +def test_client() -> TestClient: return TestClient(app) + + +def get_health(*, url: str, max_retries: int = 20, delay: float = 0.2) -> str | None: + for attempt in range(max_retries): + try: + with urllib.request.urlopen(url) as response: + return response.read() + except URLError as e: + print(f"Attempt {attempt + 1} failed: {e.reason}", file=sys.stderr) + time.sleep(delay) + return None + + +# Pytest fixture to run the server in a separate process +@pytest.fixture(scope="session") +def server_url() -> Generator[str, None, None]: + port = 8000 + host = "127.0.0.1" + proc = Process( + target=uvicorn.run, + args=(app,), + kwargs={"host": host, "port": port, "log_level": "info"}, + daemon=True, + ) + proc.start() + + url = f"http://{host}:{port}" + res = get_health(url=url + "/health") + if res is None: + raise Exception(f"Couldn't reach {url} after starting server") + + yield url + proc.terminate() + + +@pytest.fixture(scope="session") +def api_client(server_url: str) -> Generator[ApiClient, None, None]: + configuration = Configuration(host=server_url) + + # Enter a context with an instance of the API client + with ApiClient(configuration) as api_client: + yield api_client diff --git a/pkgs/clan-cli/tests/openapi_client/api/entities_api.py b/pkgs/clan-cli/tests/openapi_client/api/entities_api.py index 3827b74..e12e7ac 100644 --- a/pkgs/clan-cli/tests/openapi_client/api/entities_api.py +++ b/pkgs/clan-cli/tests/openapi_client/api/entities_api.py @@ -20,7 +20,7 @@ from pydantic import validate_arguments, ValidationError from pydantic import StrictInt, StrictStr -from typing import Any, List, Optional +from typing import Any, List, Optional, Dict from openapi_client.models.entity import Entity from openapi_client.models.entity_create import EntityCreate diff --git a/pkgs/clan-cli/tests/openapi_client/api/services_api.py b/pkgs/clan-cli/tests/openapi_client/api/services_api.py index d7de01f..7e13ea0 100644 --- a/pkgs/clan-cli/tests/openapi_client/api/services_api.py +++ b/pkgs/clan-cli/tests/openapi_client/api/services_api.py @@ -20,7 +20,7 @@ from pydantic import validate_arguments, ValidationError from pydantic import StrictInt, StrictStr -from typing import Any, List, Optional +from typing import Any, List, Optional, Dict from openapi_client.models.service import Service from openapi_client.models.service_create import ServiceCreate diff --git a/pkgs/clan-cli/tests/openapi_client/docs/ClientsApi.md b/pkgs/clan-cli/tests/openapi_client/docs/ClientsApi.md new file mode 100644 index 0000000..a466552 --- /dev/null +++ b/pkgs/clan-cli/tests/openapi_client/docs/ClientsApi.md @@ -0,0 +1,77 @@ +# openapi_client.ClientsApi + +All URIs are relative to _http://localhost_ + +| Method | HTTP request | Description | +| ---------------------------------------------------- | ------------------------------------ | --------------- | +| [**get_all_clients**](ClientsApi.md#get_all_clients) | **GET** /api/v1/{entity_did}/clients | Get All Clients | + +# **get_all_clients** + +> List[Service] get_all_clients(entity_did, skip=skip, limit=limit) + +Get All Clients + +### Example + +```python +import time +import os +import openapi_client +from openapi_client.models.service import Service +from openapi_client.rest import ApiException +from pprint import pprint + +# Defining the host is optional and defaults to http://localhost +# See configuration.py for a list of all supported configuration parameters. +configuration = openapi_client.Configuration( + host = "http://localhost" +) + + +# Enter a context with an instance of the API client +with openapi_client.ApiClient(configuration) as api_client: + # Create an instance of the API class + api_instance = openapi_client.ClientsApi(api_client) + entity_did = 'entity_did_example' # str | + skip = 0 # int | (optional) (default to 0) + limit = 100 # int | (optional) (default to 100) + + try: + # Get All Clients + api_response = api_instance.get_all_clients(entity_did, skip=skip, limit=limit) + print("The response of ClientsApi->get_all_clients:\n") + pprint(api_response) + except Exception as e: + print("Exception when calling ClientsApi->get_all_clients: %s\n" % e) +``` + +### Parameters + +| Name | Type | Description | Notes | +| -------------- | ------- | ----------- | --------------------------- | +| **entity_did** | **str** | | +| **skip** | **int** | | [optional] [default to 0] | +| **limit** | **int** | | [optional] [default to 100] | + +### Return type + +[**List[Service]**](Service.md) + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +### HTTP response details + +| Status code | Description | Response headers | +| ----------- | ------------------- | ---------------- | +| **200** | Successful Response | - | +| **422** | Validation Error | - | + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) diff --git a/pkgs/clan-cli/tests/openapi_client/docs/DefaultApi.md b/pkgs/clan-cli/tests/openapi_client/docs/DefaultApi.md new file mode 100644 index 0000000..aef64f7 --- /dev/null +++ b/pkgs/clan-cli/tests/openapi_client/docs/DefaultApi.md @@ -0,0 +1,193 @@ +# openapi_client.DefaultApi + +All URIs are relative to _http://localhost_ + +| Method | HTTP request | Description | +| ---------------------------------- | -------------------- | ----------- | +| [**get**](DefaultApi.md#get) | **GET** /ws2_example | Get | +| [**health**](DefaultApi.md#health) | **GET** /health | Health | +| [**root**](DefaultApi.md#root) | **GET** /{path_name} | Root | + +# **get** + +> get() + +Get + +### Example + +```python +import time +import os +import openapi_client +from openapi_client.rest import ApiException +from pprint import pprint + +# Defining the host is optional and defaults to http://localhost +# See configuration.py for a list of all supported configuration parameters. +configuration = openapi_client.Configuration( + host = "http://localhost" +) + + +# Enter a context with an instance of the API client +with openapi_client.ApiClient(configuration) as api_client: + # Create an instance of the API class + api_instance = openapi_client.DefaultApi(api_client) + + try: + # Get + api_instance.get() + except Exception as e: + print("Exception when calling DefaultApi->get: %s\n" % e) +``` + +### Parameters + +This endpoint does not need any parameter. + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +### HTTP response details + +| Status code | Description | Response headers | +| ----------- | ------------------- | ---------------- | +| **200** | Successful Response | - | + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **health** + +> Machine health() + +Health + +### Example + +```python +import time +import os +import openapi_client +from openapi_client.models.machine import Machine +from openapi_client.rest import ApiException +from pprint import pprint + +# Defining the host is optional and defaults to http://localhost +# See configuration.py for a list of all supported configuration parameters. +configuration = openapi_client.Configuration( + host = "http://localhost" +) + + +# Enter a context with an instance of the API client +with openapi_client.ApiClient(configuration) as api_client: + # Create an instance of the API class + api_instance = openapi_client.DefaultApi(api_client) + + try: + # Health + api_response = api_instance.health() + print("The response of DefaultApi->health:\n") + pprint(api_response) + except Exception as e: + print("Exception when calling DefaultApi->health: %s\n" % e) +``` + +### Parameters + +This endpoint does not need any parameter. + +### Return type + +[**Machine**](Machine.md) + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +### HTTP response details + +| Status code | Description | Response headers | +| ----------- | ------------------- | ---------------- | +| **200** | Successful Response | - | + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **root** + +> root(path_name) + +Root + +### Example + +```python +import time +import os +import openapi_client +from openapi_client.rest import ApiException +from pprint import pprint + +# Defining the host is optional and defaults to http://localhost +# See configuration.py for a list of all supported configuration parameters. +configuration = openapi_client.Configuration( + host = "http://localhost" +) + + +# Enter a context with an instance of the API client +with openapi_client.ApiClient(configuration) as api_client: + # Create an instance of the API class + api_instance = openapi_client.DefaultApi(api_client) + path_name = 'path_name_example' # str | + + try: + # Root + api_instance.root(path_name) + except Exception as e: + print("Exception when calling DefaultApi->root: %s\n" % e) +``` + +### Parameters + +| Name | Type | Description | Notes | +| ------------- | ------- | ----------- | ----- | +| **path_name** | **str** | | + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +### HTTP response details + +| Status code | Description | Response headers | +| ----------- | ------------------- | ---------------- | +| **200** | Successful Response | - | +| **422** | Validation Error | - | + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) diff --git a/pkgs/clan-cli/tests/openapi_client/docs/EntitiesApi.md b/pkgs/clan-cli/tests/openapi_client/docs/EntitiesApi.md new file mode 100644 index 0000000..518cce7 --- /dev/null +++ b/pkgs/clan-cli/tests/openapi_client/docs/EntitiesApi.md @@ -0,0 +1,486 @@ +# openapi_client.EntitiesApi + +All URIs are relative to _http://localhost_ + +| Method | HTTP request | Description | +| ----------------------------------------------------------------- | -------------------------------------- | --------------------- | +| [**attach_entity**](EntitiesApi.md#attach_entity) | **POST** /api/v1/{entity_did}/attach | Attach Entity | +| [**create_entity**](EntitiesApi.md#create_entity) | **POST** /api/v1/entity | Create Entity | +| [**delete_entity**](EntitiesApi.md#delete_entity) | **DELETE** /api/v1/{entity_did}/entity | Delete Entity | +| [**detach_entity**](EntitiesApi.md#detach_entity) | **POST** /api/v1/{entity_did}/detach | Detach Entity | +| [**get_all_entities**](EntitiesApi.md#get_all_entities) | **GET** /api/v1/entities | Get All Entities | +| [**get_attached_entities**](EntitiesApi.md#get_attached_entities) | **GET** /api/v1/attached_entities | Get Attached Entities | +| [**get_entity_by_did**](EntitiesApi.md#get_entity_by_did) | **GET** /api/v1/{entity_did}/entity | Get Entity By Did | + +# **attach_entity** + +> Dict[str, str] attach_entity(entity_did, skip=skip, limit=limit) + +Attach Entity + +### Example + +```python +import time +import os +import openapi_client +from openapi_client.rest import ApiException +from pprint import pprint + +# Defining the host is optional and defaults to http://localhost +# See configuration.py for a list of all supported configuration parameters. +configuration = openapi_client.Configuration( + host = "http://localhost" +) + + +# Enter a context with an instance of the API client +with openapi_client.ApiClient(configuration) as api_client: + # Create an instance of the API class + api_instance = openapi_client.EntitiesApi(api_client) + entity_did = 'entity_did_example' # str | + skip = 0 # int | (optional) (default to 0) + limit = 100 # int | (optional) (default to 100) + + try: + # Attach Entity + api_response = api_instance.attach_entity(entity_did, skip=skip, limit=limit) + print("The response of EntitiesApi->attach_entity:\n") + pprint(api_response) + except Exception as e: + print("Exception when calling EntitiesApi->attach_entity: %s\n" % e) +``` + +### Parameters + +| Name | Type | Description | Notes | +| -------------- | ------- | ----------- | --------------------------- | +| **entity_did** | **str** | | +| **skip** | **int** | | [optional] [default to 0] | +| **limit** | **int** | | [optional] [default to 100] | + +### Return type + +**Dict[str, str]** + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +### HTTP response details + +| Status code | Description | Response headers | +| ----------- | ------------------- | ---------------- | +| **200** | Successful Response | - | +| **422** | Validation Error | - | + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **create_entity** + +> Entity create_entity(entity_create) + +Create Entity + +### Example + +```python +import time +import os +import openapi_client +from openapi_client.models.entity import Entity +from openapi_client.models.entity_create import EntityCreate +from openapi_client.rest import ApiException +from pprint import pprint + +# Defining the host is optional and defaults to http://localhost +# See configuration.py for a list of all supported configuration parameters. +configuration = openapi_client.Configuration( + host = "http://localhost" +) + + +# Enter a context with an instance of the API client +with openapi_client.ApiClient(configuration) as api_client: + # Create an instance of the API class + api_instance = openapi_client.EntitiesApi(api_client) + entity_create = openapi_client.EntityCreate() # EntityCreate | + + try: + # Create Entity + api_response = api_instance.create_entity(entity_create) + print("The response of EntitiesApi->create_entity:\n") + pprint(api_response) + except Exception as e: + print("Exception when calling EntitiesApi->create_entity: %s\n" % e) +``` + +### Parameters + +| Name | Type | Description | Notes | +| ----------------- | ----------------------------------- | ----------- | ----- | +| **entity_create** | [**EntityCreate**](EntityCreate.md) | | + +### Return type + +[**Entity**](Entity.md) + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: application/json + +### HTTP response details + +| Status code | Description | Response headers | +| ----------- | ------------------- | ---------------- | +| **200** | Successful Response | - | +| **422** | Validation Error | - | + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **delete_entity** + +> Dict[str, str] delete_entity(entity_did) + +Delete Entity + +### Example + +```python +import time +import os +import openapi_client +from openapi_client.rest import ApiException +from pprint import pprint + +# Defining the host is optional and defaults to http://localhost +# See configuration.py for a list of all supported configuration parameters. +configuration = openapi_client.Configuration( + host = "http://localhost" +) + + +# Enter a context with an instance of the API client +with openapi_client.ApiClient(configuration) as api_client: + # Create an instance of the API class + api_instance = openapi_client.EntitiesApi(api_client) + entity_did = 'entity_did_example' # str | + + try: + # Delete Entity + api_response = api_instance.delete_entity(entity_did) + print("The response of EntitiesApi->delete_entity:\n") + pprint(api_response) + except Exception as e: + print("Exception when calling EntitiesApi->delete_entity: %s\n" % e) +``` + +### Parameters + +| Name | Type | Description | Notes | +| -------------- | ------- | ----------- | ----- | +| **entity_did** | **str** | | + +### Return type + +**Dict[str, str]** + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +### HTTP response details + +| Status code | Description | Response headers | +| ----------- | ------------------- | ---------------- | +| **200** | Successful Response | - | +| **422** | Validation Error | - | + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **detach_entity** + +> Entity detach_entity(entity_did, skip=skip, limit=limit) + +Detach Entity + +### Example + +```python +import time +import os +import openapi_client +from openapi_client.models.entity import Entity +from openapi_client.rest import ApiException +from pprint import pprint + +# Defining the host is optional and defaults to http://localhost +# See configuration.py for a list of all supported configuration parameters. +configuration = openapi_client.Configuration( + host = "http://localhost" +) + + +# Enter a context with an instance of the API client +with openapi_client.ApiClient(configuration) as api_client: + # Create an instance of the API class + api_instance = openapi_client.EntitiesApi(api_client) + entity_did = 'entity_did_example' # str | + skip = 0 # int | (optional) (default to 0) + limit = 100 # int | (optional) (default to 100) + + try: + # Detach Entity + api_response = api_instance.detach_entity(entity_did, skip=skip, limit=limit) + print("The response of EntitiesApi->detach_entity:\n") + pprint(api_response) + except Exception as e: + print("Exception when calling EntitiesApi->detach_entity: %s\n" % e) +``` + +### Parameters + +| Name | Type | Description | Notes | +| -------------- | ------- | ----------- | --------------------------- | +| **entity_did** | **str** | | +| **skip** | **int** | | [optional] [default to 0] | +| **limit** | **int** | | [optional] [default to 100] | + +### Return type + +[**Entity**](Entity.md) + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +### HTTP response details + +| Status code | Description | Response headers | +| ----------- | ------------------- | ---------------- | +| **200** | Successful Response | - | +| **422** | Validation Error | - | + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **get_all_entities** + +> List[Entity] get_all_entities(skip=skip, limit=limit) + +Get All Entities + +### Example + +```python +import time +import os +import openapi_client +from openapi_client.models.entity import Entity +from openapi_client.rest import ApiException +from pprint import pprint + +# Defining the host is optional and defaults to http://localhost +# See configuration.py for a list of all supported configuration parameters. +configuration = openapi_client.Configuration( + host = "http://localhost" +) + + +# Enter a context with an instance of the API client +with openapi_client.ApiClient(configuration) as api_client: + # Create an instance of the API class + api_instance = openapi_client.EntitiesApi(api_client) + skip = 0 # int | (optional) (default to 0) + limit = 100 # int | (optional) (default to 100) + + try: + # Get All Entities + api_response = api_instance.get_all_entities(skip=skip, limit=limit) + print("The response of EntitiesApi->get_all_entities:\n") + pprint(api_response) + except Exception as e: + print("Exception when calling EntitiesApi->get_all_entities: %s\n" % e) +``` + +### Parameters + +| Name | Type | Description | Notes | +| --------- | ------- | ----------- | --------------------------- | +| **skip** | **int** | | [optional] [default to 0] | +| **limit** | **int** | | [optional] [default to 100] | + +### Return type + +[**List[Entity]**](Entity.md) + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +### HTTP response details + +| Status code | Description | Response headers | +| ----------- | ------------------- | ---------------- | +| **200** | Successful Response | - | +| **422** | Validation Error | - | + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **get_attached_entities** + +> List[Entity] get_attached_entities(skip=skip, limit=limit) + +Get Attached Entities + +### Example + +```python +import time +import os +import openapi_client +from openapi_client.models.entity import Entity +from openapi_client.rest import ApiException +from pprint import pprint + +# Defining the host is optional and defaults to http://localhost +# See configuration.py for a list of all supported configuration parameters. +configuration = openapi_client.Configuration( + host = "http://localhost" +) + + +# Enter a context with an instance of the API client +with openapi_client.ApiClient(configuration) as api_client: + # Create an instance of the API class + api_instance = openapi_client.EntitiesApi(api_client) + skip = 0 # int | (optional) (default to 0) + limit = 100 # int | (optional) (default to 100) + + try: + # Get Attached Entities + api_response = api_instance.get_attached_entities(skip=skip, limit=limit) + print("The response of EntitiesApi->get_attached_entities:\n") + pprint(api_response) + except Exception as e: + print("Exception when calling EntitiesApi->get_attached_entities: %s\n" % e) +``` + +### Parameters + +| Name | Type | Description | Notes | +| --------- | ------- | ----------- | --------------------------- | +| **skip** | **int** | | [optional] [default to 0] | +| **limit** | **int** | | [optional] [default to 100] | + +### Return type + +[**List[Entity]**](Entity.md) + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +### HTTP response details + +| Status code | Description | Response headers | +| ----------- | ------------------- | ---------------- | +| **200** | Successful Response | - | +| **422** | Validation Error | - | + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **get_entity_by_did** + +> Entity get_entity_by_did(entity_did) + +Get Entity By Did + +### Example + +```python +import time +import os +import openapi_client +from openapi_client.models.entity import Entity +from openapi_client.rest import ApiException +from pprint import pprint + +# Defining the host is optional and defaults to http://localhost +# See configuration.py for a list of all supported configuration parameters. +configuration = openapi_client.Configuration( + host = "http://localhost" +) + + +# Enter a context with an instance of the API client +with openapi_client.ApiClient(configuration) as api_client: + # Create an instance of the API class + api_instance = openapi_client.EntitiesApi(api_client) + entity_did = 'entity_did_example' # str | + + try: + # Get Entity By Did + api_response = api_instance.get_entity_by_did(entity_did) + print("The response of EntitiesApi->get_entity_by_did:\n") + pprint(api_response) + except Exception as e: + print("Exception when calling EntitiesApi->get_entity_by_did: %s\n" % e) +``` + +### Parameters + +| Name | Type | Description | Notes | +| -------------- | ------- | ----------- | ----- | +| **entity_did** | **str** | | + +### Return type + +[**Entity**](Entity.md) + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +### HTTP response details + +| Status code | Description | Response headers | +| ----------- | ------------------- | ---------------- | +| **200** | Successful Response | - | +| **422** | Validation Error | - | + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) diff --git a/pkgs/clan-cli/tests/openapi_client/docs/Entity.md b/pkgs/clan-cli/tests/openapi_client/docs/Entity.md new file mode 100644 index 0000000..75d6e99 --- /dev/null +++ b/pkgs/clan-cli/tests/openapi_client/docs/Entity.md @@ -0,0 +1,32 @@ +# Entity + +## Properties + +| Name | Type | Description | Notes | +| ------------ | ---------- | ----------- | ------------------------------------------- | +| **did** | **str** | | [optional] [default to 'did:sov:test:1234'] | +| **name** | **str** | | [optional] [default to 'C1'] | +| **ip** | **str** | | [optional] [default to '127.0.0.1'] | +| **visible** | **bool** | | [optional] [default to True] | +| **other** | **object** | | [optional] | +| **attached** | **bool** | | + +## Example + +```python +from openapi_client.models.entity import Entity + +# TODO update the JSON string below +json = "{}" +# create an instance of Entity from a JSON string +entity_instance = Entity.from_json(json) +# print the JSON string representation of the object +print Entity.to_json() + +# convert the object into a dict +entity_dict = entity_instance.to_dict() +# create an instance of Entity from a dict +entity_form_dict = entity.from_dict(entity_dict) +``` + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/pkgs/clan-cli/tests/openapi_client/docs/EntityCreate.md b/pkgs/clan-cli/tests/openapi_client/docs/EntityCreate.md new file mode 100644 index 0000000..ab0f28a --- /dev/null +++ b/pkgs/clan-cli/tests/openapi_client/docs/EntityCreate.md @@ -0,0 +1,31 @@ +# EntityCreate + +## Properties + +| Name | Type | Description | Notes | +| ----------- | ---------- | ----------- | ------------------------------------------- | +| **did** | **str** | | [optional] [default to 'did:sov:test:1234'] | +| **name** | **str** | | [optional] [default to 'C1'] | +| **ip** | **str** | | [optional] [default to '127.0.0.1'] | +| **visible** | **bool** | | [optional] [default to True] | +| **other** | **object** | | [optional] | + +## Example + +```python +from openapi_client.models.entity_create import EntityCreate + +# TODO update the JSON string below +json = "{}" +# create an instance of EntityCreate from a JSON string +entity_create_instance = EntityCreate.from_json(json) +# print the JSON string representation of the object +print EntityCreate.to_json() + +# convert the object into a dict +entity_create_dict = entity_create_instance.to_dict() +# create an instance of EntityCreate from a dict +entity_create_form_dict = entity_create.from_dict(entity_create_dict) +``` + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/pkgs/clan-cli/tests/openapi_client/docs/HTTPValidationError.md b/pkgs/clan-cli/tests/openapi_client/docs/HTTPValidationError.md new file mode 100644 index 0000000..d4902e7 --- /dev/null +++ b/pkgs/clan-cli/tests/openapi_client/docs/HTTPValidationError.md @@ -0,0 +1,27 @@ +# HTTPValidationError + +## Properties + +| Name | Type | Description | Notes | +| ---------- | ----------------------------------------------- | ----------- | ---------- | +| **detail** | [**List[ValidationError]**](ValidationError.md) | | [optional] | + +## Example + +```python +from openapi_client.models.http_validation_error import HTTPValidationError + +# TODO update the JSON string below +json = "{}" +# create an instance of HTTPValidationError from a JSON string +http_validation_error_instance = HTTPValidationError.from_json(json) +# print the JSON string representation of the object +print HTTPValidationError.to_json() + +# convert the object into a dict +http_validation_error_dict = http_validation_error_instance.to_dict() +# create an instance of HTTPValidationError from a dict +http_validation_error_form_dict = http_validation_error.from_dict(http_validation_error_dict) +``` + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/pkgs/clan-cli/tests/openapi_client/docs/Machine.md b/pkgs/clan-cli/tests/openapi_client/docs/Machine.md new file mode 100644 index 0000000..062fd51 --- /dev/null +++ b/pkgs/clan-cli/tests/openapi_client/docs/Machine.md @@ -0,0 +1,28 @@ +# Machine + +## Properties + +| Name | Type | Description | Notes | +| ---------- | ----------------------- | ----------- | ----- | +| **name** | **str** | | +| **status** | [**Status**](Status.md) | | + +## Example + +```python +from openapi_client.models.machine import Machine + +# TODO update the JSON string below +json = "{}" +# create an instance of Machine from a JSON string +machine_instance = Machine.from_json(json) +# print the JSON string representation of the object +print Machine.to_json() + +# convert the object into a dict +machine_dict = machine_instance.to_dict() +# create an instance of Machine from a dict +machine_form_dict = machine.from_dict(machine_dict) +``` + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/pkgs/clan-cli/tests/openapi_client/docs/RepositoriesApi.md b/pkgs/clan-cli/tests/openapi_client/docs/RepositoriesApi.md new file mode 100644 index 0000000..ff735f0 --- /dev/null +++ b/pkgs/clan-cli/tests/openapi_client/docs/RepositoriesApi.md @@ -0,0 +1,75 @@ +# openapi_client.RepositoriesApi + +All URIs are relative to _http://localhost_ + +| Method | HTTP request | Description | +| ------------------------------------------------------------------- | ---------------------------- | -------------------- | +| [**get_all_repositories**](RepositoriesApi.md#get_all_repositories) | **GET** /api/v1/repositories | Get All Repositories | + +# **get_all_repositories** + +> List[Service] get_all_repositories(skip=skip, limit=limit) + +Get All Repositories + +### Example + +```python +import time +import os +import openapi_client +from openapi_client.models.service import Service +from openapi_client.rest import ApiException +from pprint import pprint + +# Defining the host is optional and defaults to http://localhost +# See configuration.py for a list of all supported configuration parameters. +configuration = openapi_client.Configuration( + host = "http://localhost" +) + + +# Enter a context with an instance of the API client +with openapi_client.ApiClient(configuration) as api_client: + # Create an instance of the API class + api_instance = openapi_client.RepositoriesApi(api_client) + skip = 0 # int | (optional) (default to 0) + limit = 100 # int | (optional) (default to 100) + + try: + # Get All Repositories + api_response = api_instance.get_all_repositories(skip=skip, limit=limit) + print("The response of RepositoriesApi->get_all_repositories:\n") + pprint(api_response) + except Exception as e: + print("Exception when calling RepositoriesApi->get_all_repositories: %s\n" % e) +``` + +### Parameters + +| Name | Type | Description | Notes | +| --------- | ------- | ----------- | --------------------------- | +| **skip** | **int** | | [optional] [default to 0] | +| **limit** | **int** | | [optional] [default to 100] | + +### Return type + +[**List[Service]**](Service.md) + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +### HTTP response details + +| Status code | Description | Response headers | +| ----------- | ------------------- | ---------------- | +| **200** | Successful Response | - | +| **422** | Validation Error | - | + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) diff --git a/pkgs/clan-cli/tests/openapi_client/docs/Resolution.md b/pkgs/clan-cli/tests/openapi_client/docs/Resolution.md new file mode 100644 index 0000000..11bfaee --- /dev/null +++ b/pkgs/clan-cli/tests/openapi_client/docs/Resolution.md @@ -0,0 +1,32 @@ +# Resolution + +## Properties + +| Name | Type | Description | Notes | +| ------------------ | ------------ | ----------- | ------------------------------------------- | +| **requester_name** | **str** | | [optional] [default to 'C1'] | +| **requester_did** | **str** | | [optional] [default to 'did:sov:test:1122'] | +| **resolved_did** | **str** | | [optional] [default to 'did:sov:test:1234'] | +| **other** | **object** | | [optional] | +| **timestamp** | **datetime** | | +| **id** | **int** | | + +## Example + +```python +from openapi_client.models.resolution import Resolution + +# TODO update the JSON string below +json = "{}" +# create an instance of Resolution from a JSON string +resolution_instance = Resolution.from_json(json) +# print the JSON string representation of the object +print Resolution.to_json() + +# convert the object into a dict +resolution_dict = resolution_instance.to_dict() +# create an instance of Resolution from a dict +resolution_form_dict = resolution.from_dict(resolution_dict) +``` + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/pkgs/clan-cli/tests/openapi_client/docs/ResolutionApi.md b/pkgs/clan-cli/tests/openapi_client/docs/ResolutionApi.md new file mode 100644 index 0000000..24da5fb --- /dev/null +++ b/pkgs/clan-cli/tests/openapi_client/docs/ResolutionApi.md @@ -0,0 +1,75 @@ +# openapi_client.ResolutionApi + +All URIs are relative to _http://localhost_ + +| Method | HTTP request | Description | +| --------------------------------------------------------------- | --------------------------- | ------------------- | +| [**get_all_resolutions**](ResolutionApi.md#get_all_resolutions) | **GET** /api/v1/resolutions | Get All Resolutions | + +# **get_all_resolutions** + +> List[Resolution] get_all_resolutions(skip=skip, limit=limit) + +Get All Resolutions + +### Example + +```python +import time +import os +import openapi_client +from openapi_client.models.resolution import Resolution +from openapi_client.rest import ApiException +from pprint import pprint + +# Defining the host is optional and defaults to http://localhost +# See configuration.py for a list of all supported configuration parameters. +configuration = openapi_client.Configuration( + host = "http://localhost" +) + + +# Enter a context with an instance of the API client +with openapi_client.ApiClient(configuration) as api_client: + # Create an instance of the API class + api_instance = openapi_client.ResolutionApi(api_client) + skip = 0 # int | (optional) (default to 0) + limit = 100 # int | (optional) (default to 100) + + try: + # Get All Resolutions + api_response = api_instance.get_all_resolutions(skip=skip, limit=limit) + print("The response of ResolutionApi->get_all_resolutions:\n") + pprint(api_response) + except Exception as e: + print("Exception when calling ResolutionApi->get_all_resolutions: %s\n" % e) +``` + +### Parameters + +| Name | Type | Description | Notes | +| --------- | ------- | ----------- | --------------------------- | +| **skip** | **int** | | [optional] [default to 0] | +| **limit** | **int** | | [optional] [default to 100] | + +### Return type + +[**List[Resolution]**](Resolution.md) + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +### HTTP response details + +| Status code | Description | Response headers | +| ----------- | ------------------- | ---------------- | +| **200** | Successful Response | - | +| **422** | Validation Error | - | + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) diff --git a/pkgs/clan-cli/tests/openapi_client/docs/Service.md b/pkgs/clan-cli/tests/openapi_client/docs/Service.md new file mode 100644 index 0000000..dea7f6d --- /dev/null +++ b/pkgs/clan-cli/tests/openapi_client/docs/Service.md @@ -0,0 +1,33 @@ +# Service + +## Properties + +| Name | Type | Description | Notes | +| ---------------- | ---------- | ----------- | -------------------------------------------------------------- | +| **uuid** | **str** | | [optional] [default to '8e285c0c-4e40-430a-a477-26b3b81e30df'] | +| **service_name** | **str** | | [optional] [default to 'Carlos Printing'] | +| **service_type** | **str** | | [optional] [default to '3D Printing'] | +| **endpoint_url** | **str** | | [optional] [default to 'http://127.0.0.1:8000'] | +| **status** | **str** | | [optional] [default to 'unknown'] | +| **other** | **object** | | [optional] | +| **entity_did** | **str** | | [optional] [default to 'did:sov:test:1234'] | + +## Example + +```python +from openapi_client.models.service import Service + +# TODO update the JSON string below +json = "{}" +# create an instance of Service from a JSON string +service_instance = Service.from_json(json) +# print the JSON string representation of the object +print Service.to_json() + +# convert the object into a dict +service_dict = service_instance.to_dict() +# create an instance of Service from a dict +service_form_dict = service.from_dict(service_dict) +``` + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/pkgs/clan-cli/tests/openapi_client/docs/ServiceCreate.md b/pkgs/clan-cli/tests/openapi_client/docs/ServiceCreate.md new file mode 100644 index 0000000..891a492 --- /dev/null +++ b/pkgs/clan-cli/tests/openapi_client/docs/ServiceCreate.md @@ -0,0 +1,33 @@ +# ServiceCreate + +## Properties + +| Name | Type | Description | Notes | +| ---------------- | ---------- | ----------- | -------------------------------------------------------------- | +| **uuid** | **str** | | [optional] [default to '8e285c0c-4e40-430a-a477-26b3b81e30df'] | +| **service_name** | **str** | | [optional] [default to 'Carlos Printing'] | +| **service_type** | **str** | | [optional] [default to '3D Printing'] | +| **endpoint_url** | **str** | | [optional] [default to 'http://127.0.0.1:8000'] | +| **status** | **str** | | [optional] [default to 'unknown'] | +| **other** | **object** | | [optional] | +| **entity_did** | **str** | | [optional] [default to 'did:sov:test:1234'] | + +## Example + +```python +from openapi_client.models.service_create import ServiceCreate + +# TODO update the JSON string below +json = "{}" +# create an instance of ServiceCreate from a JSON string +service_create_instance = ServiceCreate.from_json(json) +# print the JSON string representation of the object +print ServiceCreate.to_json() + +# convert the object into a dict +service_create_dict = service_create_instance.to_dict() +# create an instance of ServiceCreate from a dict +service_create_form_dict = service_create.from_dict(service_create_dict) +``` + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/pkgs/clan-cli/tests/openapi_client/docs/ServicesApi.md b/pkgs/clan-cli/tests/openapi_client/docs/ServicesApi.md new file mode 100644 index 0000000..048e944 --- /dev/null +++ b/pkgs/clan-cli/tests/openapi_client/docs/ServicesApi.md @@ -0,0 +1,280 @@ +# openapi_client.ServicesApi + +All URIs are relative to _http://localhost_ + +| Method | HTTP request | Description | +| ----------------------------------------------------------- | --------------------------------------- | ------------------ | +| [**create_service**](ServicesApi.md#create_service) | **POST** /api/v1/service | Create Service | +| [**delete_service**](ServicesApi.md#delete_service) | **DELETE** /api/v1/{entity_did}/service | Delete Service | +| [**get_all_services**](ServicesApi.md#get_all_services) | **GET** /api/v1/services | Get All Services | +| [**get_service_by_did**](ServicesApi.md#get_service_by_did) | **GET** /api/v1/{entity_did}/service | Get Service By Did | + +# **create_service** + +> Service create_service(service_create) + +Create Service + +### Example + +```python +import time +import os +import openapi_client +from openapi_client.models.service import Service +from openapi_client.models.service_create import ServiceCreate +from openapi_client.rest import ApiException +from pprint import pprint + +# Defining the host is optional and defaults to http://localhost +# See configuration.py for a list of all supported configuration parameters. +configuration = openapi_client.Configuration( + host = "http://localhost" +) + + +# Enter a context with an instance of the API client +with openapi_client.ApiClient(configuration) as api_client: + # Create an instance of the API class + api_instance = openapi_client.ServicesApi(api_client) + service_create = openapi_client.ServiceCreate() # ServiceCreate | + + try: + # Create Service + api_response = api_instance.create_service(service_create) + print("The response of ServicesApi->create_service:\n") + pprint(api_response) + except Exception as e: + print("Exception when calling ServicesApi->create_service: %s\n" % e) +``` + +### Parameters + +| Name | Type | Description | Notes | +| ------------------ | ------------------------------------- | ----------- | ----- | +| **service_create** | [**ServiceCreate**](ServiceCreate.md) | | + +### Return type + +[**Service**](Service.md) + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: application/json + +### HTTP response details + +| Status code | Description | Response headers | +| ----------- | ------------------- | ---------------- | +| **200** | Successful Response | - | +| **422** | Validation Error | - | + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **delete_service** + +> Dict[str, str] delete_service(entity_did) + +Delete Service + +### Example + +```python +import time +import os +import openapi_client +from openapi_client.rest import ApiException +from pprint import pprint + +# Defining the host is optional and defaults to http://localhost +# See configuration.py for a list of all supported configuration parameters. +configuration = openapi_client.Configuration( + host = "http://localhost" +) + + +# Enter a context with an instance of the API client +with openapi_client.ApiClient(configuration) as api_client: + # Create an instance of the API class + api_instance = openapi_client.ServicesApi(api_client) + entity_did = 'entity_did_example' # str | + + try: + # Delete Service + api_response = api_instance.delete_service(entity_did) + print("The response of ServicesApi->delete_service:\n") + pprint(api_response) + except Exception as e: + print("Exception when calling ServicesApi->delete_service: %s\n" % e) +``` + +### Parameters + +| Name | Type | Description | Notes | +| -------------- | ------- | ----------- | ----- | +| **entity_did** | **str** | | + +### Return type + +**Dict[str, str]** + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +### HTTP response details + +| Status code | Description | Response headers | +| ----------- | ------------------- | ---------------- | +| **200** | Successful Response | - | +| **422** | Validation Error | - | + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **get_all_services** + +> List[Service] get_all_services(skip=skip, limit=limit) + +Get All Services + +### Example + +```python +import time +import os +import openapi_client +from openapi_client.models.service import Service +from openapi_client.rest import ApiException +from pprint import pprint + +# Defining the host is optional and defaults to http://localhost +# See configuration.py for a list of all supported configuration parameters. +configuration = openapi_client.Configuration( + host = "http://localhost" +) + + +# Enter a context with an instance of the API client +with openapi_client.ApiClient(configuration) as api_client: + # Create an instance of the API class + api_instance = openapi_client.ServicesApi(api_client) + skip = 0 # int | (optional) (default to 0) + limit = 100 # int | (optional) (default to 100) + + try: + # Get All Services + api_response = api_instance.get_all_services(skip=skip, limit=limit) + print("The response of ServicesApi->get_all_services:\n") + pprint(api_response) + except Exception as e: + print("Exception when calling ServicesApi->get_all_services: %s\n" % e) +``` + +### Parameters + +| Name | Type | Description | Notes | +| --------- | ------- | ----------- | --------------------------- | +| **skip** | **int** | | [optional] [default to 0] | +| **limit** | **int** | | [optional] [default to 100] | + +### Return type + +[**List[Service]**](Service.md) + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +### HTTP response details + +| Status code | Description | Response headers | +| ----------- | ------------------- | ---------------- | +| **200** | Successful Response | - | +| **422** | Validation Error | - | + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **get_service_by_did** + +> List[Service] get_service_by_did(entity_did, skip=skip, limit=limit) + +Get Service By Did + +### Example + +```python +import time +import os +import openapi_client +from openapi_client.models.service import Service +from openapi_client.rest import ApiException +from pprint import pprint + +# Defining the host is optional and defaults to http://localhost +# See configuration.py for a list of all supported configuration parameters. +configuration = openapi_client.Configuration( + host = "http://localhost" +) + + +# Enter a context with an instance of the API client +with openapi_client.ApiClient(configuration) as api_client: + # Create an instance of the API class + api_instance = openapi_client.ServicesApi(api_client) + entity_did = 'entity_did_example' # str | + skip = 0 # int | (optional) (default to 0) + limit = 100 # int | (optional) (default to 100) + + try: + # Get Service By Did + api_response = api_instance.get_service_by_did(entity_did, skip=skip, limit=limit) + print("The response of ServicesApi->get_service_by_did:\n") + pprint(api_response) + except Exception as e: + print("Exception when calling ServicesApi->get_service_by_did: %s\n" % e) +``` + +### Parameters + +| Name | Type | Description | Notes | +| -------------- | ------- | ----------- | --------------------------- | +| **entity_did** | **str** | | +| **skip** | **int** | | [optional] [default to 0] | +| **limit** | **int** | | [optional] [default to 100] | + +### Return type + +[**List[Service]**](Service.md) + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +### HTTP response details + +| Status code | Description | Response headers | +| ----------- | ------------------- | ---------------- | +| **200** | Successful Response | - | +| **422** | Validation Error | - | + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) diff --git a/pkgs/clan-cli/tests/openapi_client/docs/Status.md b/pkgs/clan-cli/tests/openapi_client/docs/Status.md new file mode 100644 index 0000000..10bd223 --- /dev/null +++ b/pkgs/clan-cli/tests/openapi_client/docs/Status.md @@ -0,0 +1,10 @@ +# Status + +An enumeration. + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/pkgs/clan-cli/tests/openapi_client/docs/ValidationError.md b/pkgs/clan-cli/tests/openapi_client/docs/ValidationError.md new file mode 100644 index 0000000..b57b565 --- /dev/null +++ b/pkgs/clan-cli/tests/openapi_client/docs/ValidationError.md @@ -0,0 +1,29 @@ +# ValidationError + +## Properties + +| Name | Type | Description | Notes | +| -------- | --------------------------------------------------------------- | ----------- | ----- | +| **loc** | [**List[ValidationErrorLocInner]**](ValidationErrorLocInner.md) | | +| **msg** | **str** | | +| **type** | **str** | | + +## Example + +```python +from openapi_client.models.validation_error import ValidationError + +# TODO update the JSON string below +json = "{}" +# create an instance of ValidationError from a JSON string +validation_error_instance = ValidationError.from_json(json) +# print the JSON string representation of the object +print ValidationError.to_json() + +# convert the object into a dict +validation_error_dict = validation_error_instance.to_dict() +# create an instance of ValidationError from a dict +validation_error_form_dict = validation_error.from_dict(validation_error_dict) +``` + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/pkgs/clan-cli/tests/openapi_client/docs/ValidationErrorLocInner.md b/pkgs/clan-cli/tests/openapi_client/docs/ValidationErrorLocInner.md new file mode 100644 index 0000000..04e49df --- /dev/null +++ b/pkgs/clan-cli/tests/openapi_client/docs/ValidationErrorLocInner.md @@ -0,0 +1,26 @@ +# ValidationErrorLocInner + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | + +## Example + +```python +from openapi_client.models.validation_error_loc_inner import ValidationErrorLocInner + +# TODO update the JSON string below +json = "{}" +# create an instance of ValidationErrorLocInner from a JSON string +validation_error_loc_inner_instance = ValidationErrorLocInner.from_json(json) +# print the JSON string representation of the object +print ValidationErrorLocInner.to_json() + +# convert the object into a dict +validation_error_loc_inner_dict = validation_error_loc_inner_instance.to_dict() +# create an instance of ValidationErrorLocInner from a dict +validation_error_loc_inner_form_dict = validation_error_loc_inner.from_dict(validation_error_loc_inner_dict) +``` + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/pkgs/clan-cli/tests/openapi_client/py.typed b/pkgs/clan-cli/tests/openapi_client/test/__init__.py similarity index 100% rename from pkgs/clan-cli/tests/openapi_client/py.typed rename to pkgs/clan-cli/tests/openapi_client/test/__init__.py diff --git a/pkgs/clan-cli/tests/openapi_client/test/test_clients_api.py b/pkgs/clan-cli/tests/openapi_client/test/test_clients_api.py new file mode 100644 index 0000000..6170b17 --- /dev/null +++ b/pkgs/clan-cli/tests/openapi_client/test/test_clients_api.py @@ -0,0 +1,38 @@ +# coding: utf-8 + +""" + FastAPI + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: 0.1.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import unittest + +from openapi_client.api.clients_api import ClientsApi # noqa: E501 + + +class TestClientsApi(unittest.TestCase): + """ClientsApi unit test stubs""" + + def setUp(self) -> None: + self.api = ClientsApi() # noqa: E501 + + def tearDown(self) -> None: + pass + + def test_get_all_clients(self) -> None: + """Test case for get_all_clients + + Get All Clients # noqa: E501 + """ + pass + + +if __name__ == '__main__': + unittest.main() diff --git a/pkgs/clan-cli/tests/openapi_client/test/test_default_api.py b/pkgs/clan-cli/tests/openapi_client/test/test_default_api.py new file mode 100644 index 0000000..c8d82a9 --- /dev/null +++ b/pkgs/clan-cli/tests/openapi_client/test/test_default_api.py @@ -0,0 +1,52 @@ +# coding: utf-8 + +""" + FastAPI + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: 0.1.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import unittest + +from openapi_client.api.default_api import DefaultApi # noqa: E501 + + +class TestDefaultApi(unittest.TestCase): + """DefaultApi unit test stubs""" + + def setUp(self) -> None: + self.api = DefaultApi() # noqa: E501 + + def tearDown(self) -> None: + pass + + def test_get(self) -> None: + """Test case for get + + Get # noqa: E501 + """ + pass + + def test_health(self) -> None: + """Test case for health + + Health # noqa: E501 + """ + pass + + def test_root(self) -> None: + """Test case for root + + Root # noqa: E501 + """ + pass + + +if __name__ == '__main__': + unittest.main() diff --git a/pkgs/clan-cli/tests/openapi_client/test/test_entities_api.py b/pkgs/clan-cli/tests/openapi_client/test/test_entities_api.py new file mode 100644 index 0000000..75c7fb4 --- /dev/null +++ b/pkgs/clan-cli/tests/openapi_client/test/test_entities_api.py @@ -0,0 +1,80 @@ +# coding: utf-8 + +""" + FastAPI + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: 0.1.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import unittest + +from openapi_client.api.entities_api import EntitiesApi # noqa: E501 + + +class TestEntitiesApi(unittest.TestCase): + """EntitiesApi unit test stubs""" + + def setUp(self) -> None: + self.api = EntitiesApi() # noqa: E501 + + def tearDown(self) -> None: + pass + + def test_attach_entity(self) -> None: + """Test case for attach_entity + + Attach Entity # noqa: E501 + """ + pass + + def test_create_entity(self) -> None: + """Test case for create_entity + + Create Entity # noqa: E501 + """ + pass + + def test_delete_entity(self) -> None: + """Test case for delete_entity + + Delete Entity # noqa: E501 + """ + pass + + def test_detach_entity(self) -> None: + """Test case for detach_entity + + Detach Entity # noqa: E501 + """ + pass + + def test_get_all_entities(self) -> None: + """Test case for get_all_entities + + Get All Entities # noqa: E501 + """ + pass + + def test_get_attached_entities(self) -> None: + """Test case for get_attached_entities + + Get Attached Entities # noqa: E501 + """ + pass + + def test_get_entity_by_did(self) -> None: + """Test case for get_entity_by_did + + Get Entity By Did # noqa: E501 + """ + pass + + +if __name__ == '__main__': + unittest.main() diff --git a/pkgs/clan-cli/tests/openapi_client/test/test_entity.py b/pkgs/clan-cli/tests/openapi_client/test/test_entity.py new file mode 100644 index 0000000..8f87b61 --- /dev/null +++ b/pkgs/clan-cli/tests/openapi_client/test/test_entity.py @@ -0,0 +1,58 @@ +# coding: utf-8 + +""" + FastAPI + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: 0.1.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import unittest +import datetime + +from openapi_client.models.entity import Entity # noqa: E501 + +class TestEntity(unittest.TestCase): + """Entity unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional) -> Entity: + """Test Entity + include_option is a boolean, when False only required + params are included, when True both required and + optional params are included """ + # uncomment below to create an instance of `Entity` + """ + model = Entity() # noqa: E501 + if include_optional: + return Entity( + did = 'did:sov:test:1234', + name = 'C1', + ip = '127.0.0.1', + visible = True, + other = openapi_client.models.other.Other(), + attached = True + ) + else: + return Entity( + attached = True, + ) + """ + + def testEntity(self): + """Test Entity""" + # inst_req_only = self.make_instance(include_optional=False) + # inst_req_and_optional = self.make_instance(include_optional=True) + +if __name__ == '__main__': + unittest.main() diff --git a/pkgs/clan-cli/tests/openapi_client/test/test_entity_create.py b/pkgs/clan-cli/tests/openapi_client/test/test_entity_create.py new file mode 100644 index 0000000..457eee1 --- /dev/null +++ b/pkgs/clan-cli/tests/openapi_client/test/test_entity_create.py @@ -0,0 +1,56 @@ +# coding: utf-8 + +""" + FastAPI + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: 0.1.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import unittest +import datetime + +from openapi_client.models.entity_create import EntityCreate # noqa: E501 + +class TestEntityCreate(unittest.TestCase): + """EntityCreate unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional) -> EntityCreate: + """Test EntityCreate + include_option is a boolean, when False only required + params are included, when True both required and + optional params are included """ + # uncomment below to create an instance of `EntityCreate` + """ + model = EntityCreate() # noqa: E501 + if include_optional: + return EntityCreate( + did = 'did:sov:test:1234', + name = 'C1', + ip = '127.0.0.1', + visible = True, + other = openapi_client.models.other.Other() + ) + else: + return EntityCreate( + ) + """ + + def testEntityCreate(self): + """Test EntityCreate""" + # inst_req_only = self.make_instance(include_optional=False) + # inst_req_and_optional = self.make_instance(include_optional=True) + +if __name__ == '__main__': + unittest.main() diff --git a/pkgs/clan-cli/tests/openapi_client/test/test_http_validation_error.py b/pkgs/clan-cli/tests/openapi_client/test/test_http_validation_error.py new file mode 100644 index 0000000..9c2d93d --- /dev/null +++ b/pkgs/clan-cli/tests/openapi_client/test/test_http_validation_error.py @@ -0,0 +1,59 @@ +# coding: utf-8 + +""" + FastAPI + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: 0.1.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import unittest +import datetime + +from openapi_client.models.http_validation_error import HTTPValidationError # noqa: E501 + +class TestHTTPValidationError(unittest.TestCase): + """HTTPValidationError unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional) -> HTTPValidationError: + """Test HTTPValidationError + include_option is a boolean, when False only required + params are included, when True both required and + optional params are included """ + # uncomment below to create an instance of `HTTPValidationError` + """ + model = HTTPValidationError() # noqa: E501 + if include_optional: + return HTTPValidationError( + detail = [ + openapi_client.models.validation_error.ValidationError( + loc = [ + null + ], + msg = '', + type = '', ) + ] + ) + else: + return HTTPValidationError( + ) + """ + + def testHTTPValidationError(self): + """Test HTTPValidationError""" + # inst_req_only = self.make_instance(include_optional=False) + # inst_req_and_optional = self.make_instance(include_optional=True) + +if __name__ == '__main__': + unittest.main() diff --git a/pkgs/clan-cli/tests/openapi_client/test/test_machine.py b/pkgs/clan-cli/tests/openapi_client/test/test_machine.py new file mode 100644 index 0000000..1138964 --- /dev/null +++ b/pkgs/clan-cli/tests/openapi_client/test/test_machine.py @@ -0,0 +1,55 @@ +# coding: utf-8 + +""" + FastAPI + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: 0.1.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import unittest +import datetime + +from openapi_client.models.machine import Machine # noqa: E501 + +class TestMachine(unittest.TestCase): + """Machine unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional) -> Machine: + """Test Machine + include_option is a boolean, when False only required + params are included, when True both required and + optional params are included """ + # uncomment below to create an instance of `Machine` + """ + model = Machine() # noqa: E501 + if include_optional: + return Machine( + name = '', + status = 'online' + ) + else: + return Machine( + name = '', + status = 'online', + ) + """ + + def testMachine(self): + """Test Machine""" + # inst_req_only = self.make_instance(include_optional=False) + # inst_req_and_optional = self.make_instance(include_optional=True) + +if __name__ == '__main__': + unittest.main() diff --git a/pkgs/clan-cli/tests/openapi_client/test/test_repositories_api.py b/pkgs/clan-cli/tests/openapi_client/test/test_repositories_api.py new file mode 100644 index 0000000..ac87716 --- /dev/null +++ b/pkgs/clan-cli/tests/openapi_client/test/test_repositories_api.py @@ -0,0 +1,38 @@ +# coding: utf-8 + +""" + FastAPI + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: 0.1.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import unittest + +from openapi_client.api.repositories_api import RepositoriesApi # noqa: E501 + + +class TestRepositoriesApi(unittest.TestCase): + """RepositoriesApi unit test stubs""" + + def setUp(self) -> None: + self.api = RepositoriesApi() # noqa: E501 + + def tearDown(self) -> None: + pass + + def test_get_all_repositories(self) -> None: + """Test case for get_all_repositories + + Get All Repositories # noqa: E501 + """ + pass + + +if __name__ == '__main__': + unittest.main() diff --git a/pkgs/clan-cli/tests/openapi_client/test/test_resolution.py b/pkgs/clan-cli/tests/openapi_client/test/test_resolution.py new file mode 100644 index 0000000..62e85bf --- /dev/null +++ b/pkgs/clan-cli/tests/openapi_client/test/test_resolution.py @@ -0,0 +1,59 @@ +# coding: utf-8 + +""" + FastAPI + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: 0.1.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import unittest +import datetime + +from openapi_client.models.resolution import Resolution # noqa: E501 + +class TestResolution(unittest.TestCase): + """Resolution unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional) -> Resolution: + """Test Resolution + include_option is a boolean, when False only required + params are included, when True both required and + optional params are included """ + # uncomment below to create an instance of `Resolution` + """ + model = Resolution() # noqa: E501 + if include_optional: + return Resolution( + requester_name = 'C1', + requester_did = 'did:sov:test:1122', + resolved_did = 'did:sov:test:1234', + other = openapi_client.models.other.Other(), + timestamp = datetime.datetime.strptime('2013-10-20 19:20:30.00', '%Y-%m-%d %H:%M:%S.%f'), + id = 56 + ) + else: + return Resolution( + timestamp = datetime.datetime.strptime('2013-10-20 19:20:30.00', '%Y-%m-%d %H:%M:%S.%f'), + id = 56, + ) + """ + + def testResolution(self): + """Test Resolution""" + # inst_req_only = self.make_instance(include_optional=False) + # inst_req_and_optional = self.make_instance(include_optional=True) + +if __name__ == '__main__': + unittest.main() diff --git a/pkgs/clan-cli/tests/openapi_client/test/test_resolution_api.py b/pkgs/clan-cli/tests/openapi_client/test/test_resolution_api.py new file mode 100644 index 0000000..7f26f22 --- /dev/null +++ b/pkgs/clan-cli/tests/openapi_client/test/test_resolution_api.py @@ -0,0 +1,38 @@ +# coding: utf-8 + +""" + FastAPI + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: 0.1.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import unittest + +from openapi_client.api.resolution_api import ResolutionApi # noqa: E501 + + +class TestResolutionApi(unittest.TestCase): + """ResolutionApi unit test stubs""" + + def setUp(self) -> None: + self.api = ResolutionApi() # noqa: E501 + + def tearDown(self) -> None: + pass + + def test_get_all_resolutions(self) -> None: + """Test case for get_all_resolutions + + Get All Resolutions # noqa: E501 + """ + pass + + +if __name__ == '__main__': + unittest.main() diff --git a/pkgs/clan-cli/tests/openapi_client/test/test_service.py b/pkgs/clan-cli/tests/openapi_client/test/test_service.py new file mode 100644 index 0000000..75e01ff --- /dev/null +++ b/pkgs/clan-cli/tests/openapi_client/test/test_service.py @@ -0,0 +1,58 @@ +# coding: utf-8 + +""" + FastAPI + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: 0.1.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import unittest +import datetime + +from openapi_client.models.service import Service # noqa: E501 + +class TestService(unittest.TestCase): + """Service unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional) -> Service: + """Test Service + include_option is a boolean, when False only required + params are included, when True both required and + optional params are included """ + # uncomment below to create an instance of `Service` + """ + model = Service() # noqa: E501 + if include_optional: + return Service( + uuid = '8e285c0c-4e40-430a-a477-26b3b81e30df', + service_name = 'Carlos Printing', + service_type = '3D Printing', + endpoint_url = 'http://127.0.0.1:8000', + status = 'unknown', + other = openapi_client.models.other.Other(), + entity_did = 'did:sov:test:1234' + ) + else: + return Service( + ) + """ + + def testService(self): + """Test Service""" + # inst_req_only = self.make_instance(include_optional=False) + # inst_req_and_optional = self.make_instance(include_optional=True) + +if __name__ == '__main__': + unittest.main() diff --git a/pkgs/clan-cli/tests/openapi_client/test/test_service_create.py b/pkgs/clan-cli/tests/openapi_client/test/test_service_create.py new file mode 100644 index 0000000..23adb04 --- /dev/null +++ b/pkgs/clan-cli/tests/openapi_client/test/test_service_create.py @@ -0,0 +1,58 @@ +# coding: utf-8 + +""" + FastAPI + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: 0.1.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import unittest +import datetime + +from openapi_client.models.service_create import ServiceCreate # noqa: E501 + +class TestServiceCreate(unittest.TestCase): + """ServiceCreate unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional) -> ServiceCreate: + """Test ServiceCreate + include_option is a boolean, when False only required + params are included, when True both required and + optional params are included """ + # uncomment below to create an instance of `ServiceCreate` + """ + model = ServiceCreate() # noqa: E501 + if include_optional: + return ServiceCreate( + uuid = '8e285c0c-4e40-430a-a477-26b3b81e30df', + service_name = 'Carlos Printing', + service_type = '3D Printing', + endpoint_url = 'http://127.0.0.1:8000', + status = 'unknown', + other = openapi_client.models.other.Other(), + entity_did = 'did:sov:test:1234' + ) + else: + return ServiceCreate( + ) + """ + + def testServiceCreate(self): + """Test ServiceCreate""" + # inst_req_only = self.make_instance(include_optional=False) + # inst_req_and_optional = self.make_instance(include_optional=True) + +if __name__ == '__main__': + unittest.main() diff --git a/pkgs/clan-cli/tests/openapi_client/test/test_services_api.py b/pkgs/clan-cli/tests/openapi_client/test/test_services_api.py new file mode 100644 index 0000000..e92a4d7 --- /dev/null +++ b/pkgs/clan-cli/tests/openapi_client/test/test_services_api.py @@ -0,0 +1,59 @@ +# coding: utf-8 + +""" + FastAPI + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: 0.1.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import unittest + +from openapi_client.api.services_api import ServicesApi # noqa: E501 + + +class TestServicesApi(unittest.TestCase): + """ServicesApi unit test stubs""" + + def setUp(self) -> None: + self.api = ServicesApi() # noqa: E501 + + def tearDown(self) -> None: + pass + + def test_create_service(self) -> None: + """Test case for create_service + + Create Service # noqa: E501 + """ + pass + + def test_delete_service(self) -> None: + """Test case for delete_service + + Delete Service # noqa: E501 + """ + pass + + def test_get_all_services(self) -> None: + """Test case for get_all_services + + Get All Services # noqa: E501 + """ + pass + + def test_get_service_by_did(self) -> None: + """Test case for get_service_by_did + + Get Service By Did # noqa: E501 + """ + pass + + +if __name__ == '__main__': + unittest.main() diff --git a/pkgs/clan-cli/tests/openapi_client/test/test_status.py b/pkgs/clan-cli/tests/openapi_client/test/test_status.py new file mode 100644 index 0000000..8a69573 --- /dev/null +++ b/pkgs/clan-cli/tests/openapi_client/test/test_status.py @@ -0,0 +1,34 @@ +# coding: utf-8 + +""" + FastAPI + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: 0.1.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import unittest +import datetime + +from openapi_client.models.status import Status # noqa: E501 + +class TestStatus(unittest.TestCase): + """Status unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def testStatus(self): + """Test Status""" + # inst = Status() + +if __name__ == '__main__': + unittest.main() diff --git a/pkgs/clan-cli/tests/openapi_client/test/test_validation_error.py b/pkgs/clan-cli/tests/openapi_client/test/test_validation_error.py new file mode 100644 index 0000000..3636285 --- /dev/null +++ b/pkgs/clan-cli/tests/openapi_client/test/test_validation_error.py @@ -0,0 +1,61 @@ +# coding: utf-8 + +""" + FastAPI + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: 0.1.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import unittest +import datetime + +from openapi_client.models.validation_error import ValidationError # noqa: E501 + +class TestValidationError(unittest.TestCase): + """ValidationError unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional) -> ValidationError: + """Test ValidationError + include_option is a boolean, when False only required + params are included, when True both required and + optional params are included """ + # uncomment below to create an instance of `ValidationError` + """ + model = ValidationError() # noqa: E501 + if include_optional: + return ValidationError( + loc = [ + null + ], + msg = '', + type = '' + ) + else: + return ValidationError( + loc = [ + null + ], + msg = '', + type = '', + ) + """ + + def testValidationError(self): + """Test ValidationError""" + # inst_req_only = self.make_instance(include_optional=False) + # inst_req_and_optional = self.make_instance(include_optional=True) + +if __name__ == '__main__': + unittest.main() diff --git a/pkgs/clan-cli/tests/openapi_client/test/test_validation_error_loc_inner.py b/pkgs/clan-cli/tests/openapi_client/test/test_validation_error_loc_inner.py new file mode 100644 index 0000000..545e84d --- /dev/null +++ b/pkgs/clan-cli/tests/openapi_client/test/test_validation_error_loc_inner.py @@ -0,0 +1,51 @@ +# coding: utf-8 + +""" + FastAPI + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: 0.1.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import unittest +import datetime + +from openapi_client.models.validation_error_loc_inner import ValidationErrorLocInner # noqa: E501 + +class TestValidationErrorLocInner(unittest.TestCase): + """ValidationErrorLocInner unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional) -> ValidationErrorLocInner: + """Test ValidationErrorLocInner + include_option is a boolean, when False only required + params are included, when True both required and + optional params are included """ + # uncomment below to create an instance of `ValidationErrorLocInner` + """ + model = ValidationErrorLocInner() # noqa: E501 + if include_optional: + return ValidationErrorLocInner( + ) + else: + return ValidationErrorLocInner( + ) + """ + + def testValidationErrorLocInner(self): + """Test ValidationErrorLocInner""" + # inst_req_only = self.make_instance(include_optional=False) + # inst_req_and_optional = self.make_instance(include_optional=True) + +if __name__ == '__main__': + unittest.main() diff --git a/pkgs/clan-cli/tests/test_db_api.py b/pkgs/clan-cli/tests/test_db_api.py index 99f9624..53dedce 100644 --- a/pkgs/clan-cli/tests/test_db_api.py +++ b/pkgs/clan-cli/tests/test_db_api.py @@ -1,6 +1,16 @@ +from openapi_client import ApiClient +from openapi_client.api import default_api +from openapi_client.models import Machine, Status + default_entity_did_url = "entity_did=did%3Asov%3Atest%3A1234" default_entity_did = "did:sov:test:1234" default_entity_did2 = "did:sov:test:1235" default_entity_did3 = "did:sov:test:1236" default_entity_did4 = "did:sov:test:1237" default_entity_did5 = "did:sov:test:1238" + + +def test_health(api_client: ApiClient) -> None: + default = default_api.DefaultApi(api_client=api_client) + res: Machine = default.health() + assert res.status == Status.ONLINE From bd30682092e20ad2b32b6f7cc9ec73ff63ca1860 Mon Sep 17 00:00:00 2001 From: Luis-Hebendanz Date: Sun, 7 Jan 2024 13:35:22 +0100 Subject: [PATCH 36/58] Stash changes --- pkgs/clan-cli/bin/gen-python-client | 1 - pkgs/clan-cli/clan_cli/webui/app.py | 6 +- .../routers/{sql_connect.py => endpoints.py} | 51 +++--- pkgs/clan-cli/clan_cli/webui/schemas.py | 90 ++++++---- pkgs/clan-cli/clan_cli/webui/sql_crud.py | 4 + pkgs/clan-cli/clan_cli/webui/sql_models.py | 2 +- .../tests/openapi_client/api/clients_api.py | 18 +- .../tests/openapi_client/api/entities_api.py | 139 +++++++++++++++ .../tests/openapi_client/docs/ClientsApi.md | 20 +-- .../tests/openapi_client/docs/EntitiesApi.md | 67 +++++++ .../tests/openapi_client/docs/Entity.md | 14 +- .../tests/openapi_client/docs/EntityCreate.md | 14 +- .../tests/openapi_client/docs/Resolution.md | 12 +- .../tests/openapi_client/docs/Service.md | 19 +- .../openapi_client/docs/ServiceCreate.md | 18 +- .../tests/openapi_client/models/entity.py | 20 +-- .../openapi_client/models/entity_create.py | 22 +-- .../tests/openapi_client/models/resolution.py | 16 +- .../tests/openapi_client/models/service.py | 38 ++-- .../openapi_client/models/service_create.py | 30 ++-- .../openapi_client/test/test_clients_api.py | 6 +- .../openapi_client/test/test_entities_api.py | 7 + .../tests/openapi_client/test/test_entity.py | 7 +- .../openapi_client/test/test_entity_create.py | 7 +- .../openapi_client/test/test_resolution.py | 6 +- .../tests/openapi_client/test/test_service.py | 25 ++- .../test/test_service_create.py | 9 +- pkgs/clan-cli/tests/test_db_api.py | 83 ++++++++- pkgs/ui/shell.nix | 6 +- pkgs/ui/src/app/access-point/page.tsx | 4 +- pkgs/ui/src/app/client-1/page.tsx | 168 ------------------ .../[client_name]}/page.tsx | 151 +++++++++------- .../ui/src/components/hooks/useAppContext.tsx | 4 +- pkgs/ui/src/components/sidebar/index.tsx | 4 +- pkgs/ui/src/components/table/index.tsx | 10 +- pkgs/ui/src/config/client_1/index.tsx | 4 +- pkgs/ui/src/config/home/index.ts | 4 +- pkgs/ui/src/types/index.ts | 1 + 38 files changed, 661 insertions(+), 446 deletions(-) rename pkgs/clan-cli/clan_cli/webui/routers/{sql_connect.py => endpoints.py} (88%) delete mode 100644 pkgs/ui/src/app/client-1/page.tsx rename pkgs/ui/src/app/{client-2 => client/[client_name]}/page.tsx (60%) diff --git a/pkgs/clan-cli/bin/gen-python-client b/pkgs/clan-cli/bin/gen-python-client index 5e027f5..3c83d1b 100755 --- a/pkgs/clan-cli/bin/gen-python-client +++ b/pkgs/clan-cli/bin/gen-python-client @@ -81,7 +81,6 @@ def main() -> None: replace_in_directory(directory_path=src_client, pattern=pattern, replacement=replacement) dst_client: Path = args.out / "openapi_client" - breakpoint() shutil.rmtree(dst_client, ignore_errors=True) shutil.copytree(src_client, dst_client) diff --git a/pkgs/clan-cli/clan_cli/webui/app.py b/pkgs/clan-cli/clan_cli/webui/app.py index 173cef8..d34d25d 100644 --- a/pkgs/clan-cli/clan_cli/webui/app.py +++ b/pkgs/clan-cli/clan_cli/webui/app.py @@ -13,12 +13,14 @@ from ..errors import ClanError from . import sql_models from .assets import asset_path from .error_handlers import clan_error_handler, sql_error_handler -from .routers import health, root, socket_manager2, sql_connect # sql router hinzufügen +from .routers import endpoints, health, root, socket_manager2 # sql router hinzufügen from .sql_db import engine from .tags import tags_metadata origins = [ "http://localhost:3000", + "http://127.0.0.1:3000", + "http://0.0.0.0:3000", ] # Logging setup log = logging.getLogger(__name__) @@ -50,7 +52,7 @@ def setup_app() -> FastAPI: app.include_router(health.router) # sql methodes - app.include_router(sql_connect.router) + app.include_router(endpoints.router) app.include_router(socket_manager2.router) diff --git a/pkgs/clan-cli/clan_cli/webui/routers/sql_connect.py b/pkgs/clan-cli/clan_cli/webui/routers/endpoints.py similarity index 88% rename from pkgs/clan-cli/clan_cli/webui/routers/sql_connect.py rename to pkgs/clan-cli/clan_cli/webui/routers/endpoints.py index e4b1ea6..4aec32b 100644 --- a/pkgs/clan-cli/clan_cli/webui/routers/sql_connect.py +++ b/pkgs/clan-cli/clan_cli/webui/routers/endpoints.py @@ -15,6 +15,7 @@ from ..schemas import ( Resolution, Service, ServiceCreate, + ServicesByName, ) from ..tags import Tags @@ -57,6 +58,24 @@ async def get_service_by_did( return service +@router.get( + "/api/v1/services_by_entity_name", + response_model=ServicesByName, + tags=[Tags.services], +) +async def get_services_by_name( + entity_name: str, + skip: int = 0, + limit: int = 100, + db: Session = Depends(sql_db.get_db), +) -> ServicesByName: + entity = sql_crud.get_entity_by_name(db, name=entity_name) + if entity is None: + raise ClanError(f"Entity with name '{entity_name}' not found") + services = sql_crud.get_services_by_entity_did(db, entity_did=str(entity.did)) + return ServicesByName(entity=entity, services=services) # type: ignore + + @router.delete("/api/v1/{entity_did}/service", tags=[Tags.services]) async def delete_service( entity_did: str = "did:sov:test:1234", @@ -66,33 +85,11 @@ async def delete_service( return {"message": "service deleted"} -######################### -# # -# Client # -# # -######################### -@router.get( - "/api/v1/{entity_did}/clients", response_model=List[Service], tags=[Tags.clients] -) -async def get_all_clients( - entity_did: str = "did:sov:test:1234", - skip: int = 0, - limit: int = 100, - db: Session = Depends(sql_db.get_db), -) -> List[sql_models.Service]: - clients = sql_crud.get_services_without_entity_id( - db, entity_did, skip=skip, limit=limit - ) - return clients - - ######################### # # # REPOSITORY # # # ######################### - - @router.get( "/api/v1/repositories", response_model=List[Service], @@ -117,6 +114,16 @@ async def create_entity( return sql_crud.create_entity(db, entity) +@router.get( + "/api/v1/entity_by_name", response_model=Optional[Entity], tags=[Tags.entities] +) +async def get_entity_by_name( + entity_name: str, db: Session = Depends(sql_db.get_db) +) -> Optional[sql_models.Entity]: + entity = sql_crud.get_entity_by_name(db, name=entity_name) + return entity + + @router.get("/api/v1/entities", response_model=List[Entity], tags=[Tags.entities]) async def get_all_entities( skip: int = 0, limit: int = 100, db: Session = Depends(sql_db.get_db) diff --git a/pkgs/clan-cli/clan_cli/webui/schemas.py b/pkgs/clan-cli/clan_cli/webui/schemas.py index b98b9b7..bdb1a2e 100644 --- a/pkgs/clan-cli/clan_cli/webui/schemas.py +++ b/pkgs/clan-cli/clan_cli/webui/schemas.py @@ -1,7 +1,8 @@ from datetime import datetime from enum import Enum +from typing import List -from pydantic import BaseModel +from pydantic import BaseModel, Field class Status(Enum): @@ -15,43 +16,23 @@ class Machine(BaseModel): status: Status -######################### -# # -# Service # -# # -######################### -class ServiceBase(BaseModel): - uuid: str = "8e285c0c-4e40-430a-a477-26b3b81e30df" - service_name: str = "Carlos Printing" - service_type: str = "3D Printing" - endpoint_url: str = "http://127.0.0.1:8000" - status: str = "unknown" - other: dict = {"action": ["register", "deregister", "delete", "create"]} - - -class ServiceCreate(ServiceBase): - entity_did: str = "did:sov:test:1234" - - -class Service(ServiceCreate): - class Config: - orm_mode = True - - ######################### # # # Entity # # # ######################### class EntityBase(BaseModel): - did: str = "did:sov:test:1234" - name: str = "C1" - ip: str = "127.0.0.1" - visible: bool = True - other: dict = { - "network": "Carlos Home Network", - "roles": ["service repository", "service prosumer"], - } + did: str = Field(..., example="did:sov:test:1234") + name: str = Field(..., example="C1") + ip: str = Field(..., example="127.0.0.1") + visible: bool = Field(..., example=True) + other: dict = Field( + ..., + example={ + "network": "Carlos Home Network", + "roles": ["service repository", "service prosumer"], + }, + ) class EntityCreate(EntityBase): @@ -59,7 +40,42 @@ class EntityCreate(EntityBase): class Entity(EntityCreate): - attached: bool + attached: bool = Field(...) + + class Config: + orm_mode = True + + +######################### +# # +# Service # +# # +######################### +class ServiceBase(BaseModel): + uuid: str = Field(..., example="8e285c0c-4e40-430a-a477-26b3b81e30df") + service_name: str = Field(..., example="Carlos Printing") + service_type: str = Field(..., example="3D Printing") + endpoint_url: str = Field(..., example="http://127.0.0.1:8000") + status: str = Field(..., example="unknown") + other: dict = Field( + ..., example={"action": ["register", "deregister", "delete", "create"]} + ) + + +class ServiceCreate(ServiceBase): + entity_did: str = Field(..., example="did:sov:test:1234") + + +class Service(ServiceCreate): + entity: Entity + + class Config: + orm_mode = True + + +class ServicesByName(BaseModel): + entity: Entity + services: List[Service] class Config: orm_mode = True @@ -71,10 +87,10 @@ class Entity(EntityCreate): # # ######################### class ResolutionBase(BaseModel): - requester_name: str = "C1" - requester_did: str = "did:sov:test:1122" - resolved_did: str = "did:sov:test:1234" - other: dict = {"test": "test"} + requester_name: str = Field(..., example="C1") + requester_did: str = Field(..., example="did:sov:test:1122") + resolved_did: str = Field(..., example="did:sov:test:1234") + other: dict = Field(..., example={"test": "test"}) class ResolutionCreate(ResolutionBase): diff --git a/pkgs/clan-cli/clan_cli/webui/sql_crud.py b/pkgs/clan-cli/clan_cli/webui/sql_crud.py index f10f582..f18bc4e 100644 --- a/pkgs/clan-cli/clan_cli/webui/sql_crud.py +++ b/pkgs/clan-cli/clan_cli/webui/sql_crud.py @@ -81,6 +81,10 @@ def get_entity_by_did(db: Session, did: str) -> Optional[sql_models.Entity]: return db.query(sql_models.Entity).filter(sql_models.Entity.did == did).first() +def get_entity_by_name(db: Session, name: str) -> Optional[sql_models.Entity]: + return db.query(sql_models.Entity).filter(sql_models.Entity.name == name).first() + + # get attached def get_attached_entities( db: Session, skip: int = 0, limit: int = 100 diff --git a/pkgs/clan-cli/clan_cli/webui/sql_models.py b/pkgs/clan-cli/clan_cli/webui/sql_models.py index f8341f0..b0358ce 100644 --- a/pkgs/clan-cli/clan_cli/webui/sql_models.py +++ b/pkgs/clan-cli/clan_cli/webui/sql_models.py @@ -19,7 +19,7 @@ class Entity(Base): ## Queryable body ## did = Column(String, primary_key=True, index=True) - name = Column(String, index=True) + name = Column(String, index=True, unique=True) ip = Column(String, index=True) attached = Column(Boolean, index=True) visible = Column(Boolean, index=True) diff --git a/pkgs/clan-cli/tests/openapi_client/api/clients_api.py b/pkgs/clan-cli/tests/openapi_client/api/clients_api.py index 52c267e..431c420 100644 --- a/pkgs/clan-cli/tests/openapi_client/api/clients_api.py +++ b/pkgs/clan-cli/tests/openapi_client/api/clients_api.py @@ -45,13 +45,13 @@ class ClientsApi: self.api_client = api_client @validate_arguments - def get_all_clients(self, entity_did : StrictStr, skip : Optional[StrictInt] = None, limit : Optional[StrictInt] = None, **kwargs) -> List[Service]: # noqa: E501 - """Get All Clients # noqa: E501 + def get_clients_by_did(self, entity_did : StrictStr, skip : Optional[StrictInt] = None, limit : Optional[StrictInt] = None, **kwargs) -> List[Service]: # noqa: E501 + """Get Clients By Did # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.get_all_clients(entity_did, skip, limit, async_req=True) + >>> thread = api.get_clients_by_did(entity_did, skip, limit, async_req=True) >>> result = thread.get() :param entity_did: (required) @@ -73,18 +73,18 @@ class ClientsApi: """ kwargs['_return_http_data_only'] = True if '_preload_content' in kwargs: - message = "Error! Please call the get_all_clients_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data" # noqa: E501 + message = "Error! Please call the get_clients_by_did_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data" # noqa: E501 raise ValueError(message) - return self.get_all_clients_with_http_info(entity_did, skip, limit, **kwargs) # noqa: E501 + return self.get_clients_by_did_with_http_info(entity_did, skip, limit, **kwargs) # noqa: E501 @validate_arguments - def get_all_clients_with_http_info(self, entity_did : StrictStr, skip : Optional[StrictInt] = None, limit : Optional[StrictInt] = None, **kwargs) -> ApiResponse: # noqa: E501 - """Get All Clients # noqa: E501 + def get_clients_by_did_with_http_info(self, entity_did : StrictStr, skip : Optional[StrictInt] = None, limit : Optional[StrictInt] = None, **kwargs) -> ApiResponse: # noqa: E501 + """Get Clients By Did # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.get_all_clients_with_http_info(entity_did, skip, limit, async_req=True) + >>> thread = api.get_clients_by_did_with_http_info(entity_did, skip, limit, async_req=True) >>> result = thread.get() :param entity_did: (required) @@ -142,7 +142,7 @@ class ClientsApi: if _key not in _all_params: raise ApiTypeError( "Got an unexpected keyword argument '%s'" - " to method get_all_clients" % _key + " to method get_clients_by_did" % _key ) _params[_key] = _val del _params['kwargs'] diff --git a/pkgs/clan-cli/tests/openapi_client/api/entities_api.py b/pkgs/clan-cli/tests/openapi_client/api/entities_api.py index e12e7ac..51f4345 100644 --- a/pkgs/clan-cli/tests/openapi_client/api/entities_api.py +++ b/pkgs/clan-cli/tests/openapi_client/api/entities_api.py @@ -1072,3 +1072,142 @@ class EntitiesApi: _request_timeout=_params.get('_request_timeout'), collection_formats=_collection_formats, _request_auth=_params.get('_request_auth')) + + @validate_arguments + def get_entity_by_name(self, entity_name : StrictStr, **kwargs) -> Entity: # noqa: E501 + """Get Entity By Name # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.get_entity_by_name(entity_name, async_req=True) + >>> result = thread.get() + + :param entity_name: (required) + :type entity_name: str + :param async_req: Whether to execute the request asynchronously. + :type async_req: bool, optional + :param _request_timeout: timeout setting for this request. + If one number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :return: Returns the result object. + If the method is called asynchronously, + returns the request thread. + :rtype: Entity + """ + kwargs['_return_http_data_only'] = True + if '_preload_content' in kwargs: + message = "Error! Please call the get_entity_by_name_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data" # noqa: E501 + raise ValueError(message) + return self.get_entity_by_name_with_http_info(entity_name, **kwargs) # noqa: E501 + + @validate_arguments + def get_entity_by_name_with_http_info(self, entity_name : StrictStr, **kwargs) -> ApiResponse: # noqa: E501 + """Get Entity By Name # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.get_entity_by_name_with_http_info(entity_name, async_req=True) + >>> result = thread.get() + + :param entity_name: (required) + :type entity_name: str + :param async_req: Whether to execute the request asynchronously. + :type async_req: bool, optional + :param _preload_content: if False, the ApiResponse.data will + be set to none and raw_data will store the + HTTP response body without reading/decoding. + Default is True. + :type _preload_content: bool, optional + :param _return_http_data_only: response data instead of ApiResponse + object with status code, headers, etc + :type _return_http_data_only: bool, optional + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the authentication + in the spec for a single request. + :type _request_auth: dict, optional + :type _content_type: string, optional: force content-type for the request + :return: Returns the result object. + If the method is called asynchronously, + returns the request thread. + :rtype: tuple(Entity, status_code(int), headers(HTTPHeaderDict)) + """ + + _params = locals() + + _all_params = [ + 'entity_name' + ] + _all_params.extend( + [ + 'async_req', + '_return_http_data_only', + '_preload_content', + '_request_timeout', + '_request_auth', + '_content_type', + '_headers' + ] + ) + + # validate the arguments + for _key, _val in _params['kwargs'].items(): + if _key not in _all_params: + raise ApiTypeError( + "Got an unexpected keyword argument '%s'" + " to method get_entity_by_name" % _key + ) + _params[_key] = _val + del _params['kwargs'] + + _collection_formats = {} + + # process the path parameters + _path_params = {} + + # process the query parameters + _query_params = [] + if _params.get('entity_name') is not None: # noqa: E501 + _query_params.append(('entity_name', _params['entity_name'])) + + # process the header parameters + _header_params = dict(_params.get('_headers', {})) + # process the form parameters + _form_params = [] + _files = {} + # process the body parameter + _body_params = None + # set the HTTP header `Accept` + _header_params['Accept'] = self.api_client.select_header_accept( + ['application/json']) # noqa: E501 + + # authentication setting + _auth_settings = [] # noqa: E501 + + _response_types_map = { + '200': "Entity", + '422': "HTTPValidationError", + } + + return self.api_client.call_api( + '/api/v1/entity_by_name', 'GET', + _path_params, + _query_params, + _header_params, + body=_body_params, + post_params=_form_params, + files=_files, + response_types_map=_response_types_map, + auth_settings=_auth_settings, + async_req=_params.get('async_req'), + _return_http_data_only=_params.get('_return_http_data_only'), # noqa: E501 + _preload_content=_params.get('_preload_content', True), + _request_timeout=_params.get('_request_timeout'), + collection_formats=_collection_formats, + _request_auth=_params.get('_request_auth')) diff --git a/pkgs/clan-cli/tests/openapi_client/docs/ClientsApi.md b/pkgs/clan-cli/tests/openapi_client/docs/ClientsApi.md index a466552..e232dcd 100644 --- a/pkgs/clan-cli/tests/openapi_client/docs/ClientsApi.md +++ b/pkgs/clan-cli/tests/openapi_client/docs/ClientsApi.md @@ -2,15 +2,15 @@ All URIs are relative to _http://localhost_ -| Method | HTTP request | Description | -| ---------------------------------------------------- | ------------------------------------ | --------------- | -| [**get_all_clients**](ClientsApi.md#get_all_clients) | **GET** /api/v1/{entity_did}/clients | Get All Clients | +| Method | HTTP request | Description | +| ---------------------------------------------------------- | ------------------------------------ | ------------------ | +| [**get_clients_by_did**](ClientsApi.md#get_clients_by_did) | **GET** /api/v1/{entity_did}/clients | Get Clients By Did | -# **get_all_clients** +# **get_clients_by_did** -> List[Service] get_all_clients(entity_did, skip=skip, limit=limit) +> List[Service] get_clients_by_did(entity_did, skip=skip, limit=limit) -Get All Clients +Get Clients By Did ### Example @@ -38,12 +38,12 @@ with openapi_client.ApiClient(configuration) as api_client: limit = 100 # int | (optional) (default to 100) try: - # Get All Clients - api_response = api_instance.get_all_clients(entity_did, skip=skip, limit=limit) - print("The response of ClientsApi->get_all_clients:\n") + # Get Clients By Did + api_response = api_instance.get_clients_by_did(entity_did, skip=skip, limit=limit) + print("The response of ClientsApi->get_clients_by_did:\n") pprint(api_response) except Exception as e: - print("Exception when calling ClientsApi->get_all_clients: %s\n" % e) + print("Exception when calling ClientsApi->get_clients_by_did: %s\n" % e) ``` ### Parameters diff --git a/pkgs/clan-cli/tests/openapi_client/docs/EntitiesApi.md b/pkgs/clan-cli/tests/openapi_client/docs/EntitiesApi.md index 518cce7..86785f9 100644 --- a/pkgs/clan-cli/tests/openapi_client/docs/EntitiesApi.md +++ b/pkgs/clan-cli/tests/openapi_client/docs/EntitiesApi.md @@ -11,6 +11,7 @@ All URIs are relative to _http://localhost_ | [**get_all_entities**](EntitiesApi.md#get_all_entities) | **GET** /api/v1/entities | Get All Entities | | [**get_attached_entities**](EntitiesApi.md#get_attached_entities) | **GET** /api/v1/attached_entities | Get Attached Entities | | [**get_entity_by_did**](EntitiesApi.md#get_entity_by_did) | **GET** /api/v1/{entity_did}/entity | Get Entity By Did | +| [**get_entity_by_name**](EntitiesApi.md#get_entity_by_name) | **GET** /api/v1/entity_by_name | Get Entity By Name | # **attach_entity** @@ -484,3 +485,69 @@ No authorization required | **422** | Validation Error | - | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **get_entity_by_name** + +> Entity get_entity_by_name(entity_name) + +Get Entity By Name + +### Example + +```python +import time +import os +import openapi_client +from openapi_client.models.entity import Entity +from openapi_client.rest import ApiException +from pprint import pprint + +# Defining the host is optional and defaults to http://localhost +# See configuration.py for a list of all supported configuration parameters. +configuration = openapi_client.Configuration( + host = "http://localhost" +) + + +# Enter a context with an instance of the API client +with openapi_client.ApiClient(configuration) as api_client: + # Create an instance of the API class + api_instance = openapi_client.EntitiesApi(api_client) + entity_name = 'entity_name_example' # str | + + try: + # Get Entity By Name + api_response = api_instance.get_entity_by_name(entity_name) + print("The response of EntitiesApi->get_entity_by_name:\n") + pprint(api_response) + except Exception as e: + print("Exception when calling EntitiesApi->get_entity_by_name: %s\n" % e) +``` + +### Parameters + +| Name | Type | Description | Notes | +| --------------- | ------- | ----------- | ----- | +| **entity_name** | **str** | | + +### Return type + +[**Entity**](Entity.md) + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +### HTTP response details + +| Status code | Description | Response headers | +| ----------- | ------------------- | ---------------- | +| **200** | Successful Response | - | +| **422** | Validation Error | - | + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) diff --git a/pkgs/clan-cli/tests/openapi_client/docs/Entity.md b/pkgs/clan-cli/tests/openapi_client/docs/Entity.md index 75d6e99..fc0e2d7 100644 --- a/pkgs/clan-cli/tests/openapi_client/docs/Entity.md +++ b/pkgs/clan-cli/tests/openapi_client/docs/Entity.md @@ -2,13 +2,13 @@ ## Properties -| Name | Type | Description | Notes | -| ------------ | ---------- | ----------- | ------------------------------------------- | -| **did** | **str** | | [optional] [default to 'did:sov:test:1234'] | -| **name** | **str** | | [optional] [default to 'C1'] | -| **ip** | **str** | | [optional] [default to '127.0.0.1'] | -| **visible** | **bool** | | [optional] [default to True] | -| **other** | **object** | | [optional] | +| Name | Type | Description | Notes | +| ------------ | ---------- | ----------- | ----- | +| **did** | **str** | | +| **name** | **str** | | +| **ip** | **str** | | +| **visible** | **bool** | | +| **other** | **object** | | | **attached** | **bool** | | ## Example diff --git a/pkgs/clan-cli/tests/openapi_client/docs/EntityCreate.md b/pkgs/clan-cli/tests/openapi_client/docs/EntityCreate.md index ab0f28a..4fff16a 100644 --- a/pkgs/clan-cli/tests/openapi_client/docs/EntityCreate.md +++ b/pkgs/clan-cli/tests/openapi_client/docs/EntityCreate.md @@ -2,13 +2,13 @@ ## Properties -| Name | Type | Description | Notes | -| ----------- | ---------- | ----------- | ------------------------------------------- | -| **did** | **str** | | [optional] [default to 'did:sov:test:1234'] | -| **name** | **str** | | [optional] [default to 'C1'] | -| **ip** | **str** | | [optional] [default to '127.0.0.1'] | -| **visible** | **bool** | | [optional] [default to True] | -| **other** | **object** | | [optional] | +| Name | Type | Description | Notes | +| ----------- | ---------- | ----------- | ----- | +| **did** | **str** | | +| **name** | **str** | | +| **ip** | **str** | | +| **visible** | **bool** | | +| **other** | **object** | | ## Example diff --git a/pkgs/clan-cli/tests/openapi_client/docs/Resolution.md b/pkgs/clan-cli/tests/openapi_client/docs/Resolution.md index 11bfaee..27928d5 100644 --- a/pkgs/clan-cli/tests/openapi_client/docs/Resolution.md +++ b/pkgs/clan-cli/tests/openapi_client/docs/Resolution.md @@ -2,12 +2,12 @@ ## Properties -| Name | Type | Description | Notes | -| ------------------ | ------------ | ----------- | ------------------------------------------- | -| **requester_name** | **str** | | [optional] [default to 'C1'] | -| **requester_did** | **str** | | [optional] [default to 'did:sov:test:1122'] | -| **resolved_did** | **str** | | [optional] [default to 'did:sov:test:1234'] | -| **other** | **object** | | [optional] | +| Name | Type | Description | Notes | +| ------------------ | ------------ | ----------- | ----- | +| **requester_name** | **str** | | +| **requester_did** | **str** | | +| **resolved_did** | **str** | | +| **other** | **object** | | | **timestamp** | **datetime** | | | **id** | **int** | | diff --git a/pkgs/clan-cli/tests/openapi_client/docs/Service.md b/pkgs/clan-cli/tests/openapi_client/docs/Service.md index dea7f6d..5798f74 100644 --- a/pkgs/clan-cli/tests/openapi_client/docs/Service.md +++ b/pkgs/clan-cli/tests/openapi_client/docs/Service.md @@ -2,15 +2,16 @@ ## Properties -| Name | Type | Description | Notes | -| ---------------- | ---------- | ----------- | -------------------------------------------------------------- | -| **uuid** | **str** | | [optional] [default to '8e285c0c-4e40-430a-a477-26b3b81e30df'] | -| **service_name** | **str** | | [optional] [default to 'Carlos Printing'] | -| **service_type** | **str** | | [optional] [default to '3D Printing'] | -| **endpoint_url** | **str** | | [optional] [default to 'http://127.0.0.1:8000'] | -| **status** | **str** | | [optional] [default to 'unknown'] | -| **other** | **object** | | [optional] | -| **entity_did** | **str** | | [optional] [default to 'did:sov:test:1234'] | +| Name | Type | Description | Notes | +| ---------------- | ----------------------- | ----------- | ----- | +| **uuid** | **str** | | +| **service_name** | **str** | | +| **service_type** | **str** | | +| **endpoint_url** | **str** | | +| **status** | **str** | | +| **other** | **object** | | +| **entity_did** | **str** | | +| **entity** | [**Entity**](Entity.md) | | ## Example diff --git a/pkgs/clan-cli/tests/openapi_client/docs/ServiceCreate.md b/pkgs/clan-cli/tests/openapi_client/docs/ServiceCreate.md index 891a492..7843b1a 100644 --- a/pkgs/clan-cli/tests/openapi_client/docs/ServiceCreate.md +++ b/pkgs/clan-cli/tests/openapi_client/docs/ServiceCreate.md @@ -2,15 +2,15 @@ ## Properties -| Name | Type | Description | Notes | -| ---------------- | ---------- | ----------- | -------------------------------------------------------------- | -| **uuid** | **str** | | [optional] [default to '8e285c0c-4e40-430a-a477-26b3b81e30df'] | -| **service_name** | **str** | | [optional] [default to 'Carlos Printing'] | -| **service_type** | **str** | | [optional] [default to '3D Printing'] | -| **endpoint_url** | **str** | | [optional] [default to 'http://127.0.0.1:8000'] | -| **status** | **str** | | [optional] [default to 'unknown'] | -| **other** | **object** | | [optional] | -| **entity_did** | **str** | | [optional] [default to 'did:sov:test:1234'] | +| Name | Type | Description | Notes | +| ---------------- | ---------- | ----------- | ----- | +| **uuid** | **str** | | +| **service_name** | **str** | | +| **service_type** | **str** | | +| **endpoint_url** | **str** | | +| **status** | **str** | | +| **other** | **object** | | +| **entity_did** | **str** | | ## Example diff --git a/pkgs/clan-cli/tests/openapi_client/models/entity.py b/pkgs/clan-cli/tests/openapi_client/models/entity.py index 888c1ae..e478804 100644 --- a/pkgs/clan-cli/tests/openapi_client/models/entity.py +++ b/pkgs/clan-cli/tests/openapi_client/models/entity.py @@ -18,18 +18,18 @@ import re # noqa: F401 import json -from typing import Any, Dict, Optional +from typing import Any, Dict from pydantic import BaseModel, Field, StrictBool, StrictStr class Entity(BaseModel): """ Entity """ - did: Optional[StrictStr] = 'did:sov:test:1234' - name: Optional[StrictStr] = 'C1' - ip: Optional[StrictStr] = '127.0.0.1' - visible: Optional[StrictBool] = True - other: Optional[Dict[str, Any]] = None + did: StrictStr = Field(...) + name: StrictStr = Field(...) + ip: StrictStr = Field(...) + visible: StrictBool = Field(...) + other: Dict[str, Any] = Field(...) attached: StrictBool = Field(...) __properties = ["did", "name", "ip", "visible", "other", "attached"] @@ -69,10 +69,10 @@ class Entity(BaseModel): return Entity.parse_obj(obj) _obj = Entity.parse_obj({ - "did": obj.get("did") if obj.get("did") is not None else 'did:sov:test:1234', - "name": obj.get("name") if obj.get("name") is not None else 'C1', - "ip": obj.get("ip") if obj.get("ip") is not None else '127.0.0.1', - "visible": obj.get("visible") if obj.get("visible") is not None else True, + "did": obj.get("did"), + "name": obj.get("name"), + "ip": obj.get("ip"), + "visible": obj.get("visible"), "other": obj.get("other"), "attached": obj.get("attached") }) diff --git a/pkgs/clan-cli/tests/openapi_client/models/entity_create.py b/pkgs/clan-cli/tests/openapi_client/models/entity_create.py index 0204840..f9df72b 100644 --- a/pkgs/clan-cli/tests/openapi_client/models/entity_create.py +++ b/pkgs/clan-cli/tests/openapi_client/models/entity_create.py @@ -18,18 +18,18 @@ import re # noqa: F401 import json -from typing import Any, Dict, Optional -from pydantic import BaseModel, StrictBool, StrictStr +from typing import Any, Dict +from pydantic import BaseModel, Field, StrictBool, StrictStr class EntityCreate(BaseModel): """ EntityCreate """ - did: Optional[StrictStr] = 'did:sov:test:1234' - name: Optional[StrictStr] = 'C1' - ip: Optional[StrictStr] = '127.0.0.1' - visible: Optional[StrictBool] = True - other: Optional[Dict[str, Any]] = None + did: StrictStr = Field(...) + name: StrictStr = Field(...) + ip: StrictStr = Field(...) + visible: StrictBool = Field(...) + other: Dict[str, Any] = Field(...) __properties = ["did", "name", "ip", "visible", "other"] class Config: @@ -68,10 +68,10 @@ class EntityCreate(BaseModel): return EntityCreate.parse_obj(obj) _obj = EntityCreate.parse_obj({ - "did": obj.get("did") if obj.get("did") is not None else 'did:sov:test:1234', - "name": obj.get("name") if obj.get("name") is not None else 'C1', - "ip": obj.get("ip") if obj.get("ip") is not None else '127.0.0.1', - "visible": obj.get("visible") if obj.get("visible") is not None else True, + "did": obj.get("did"), + "name": obj.get("name"), + "ip": obj.get("ip"), + "visible": obj.get("visible"), "other": obj.get("other") }) return _obj diff --git a/pkgs/clan-cli/tests/openapi_client/models/resolution.py b/pkgs/clan-cli/tests/openapi_client/models/resolution.py index 4e97999..05d480b 100644 --- a/pkgs/clan-cli/tests/openapi_client/models/resolution.py +++ b/pkgs/clan-cli/tests/openapi_client/models/resolution.py @@ -18,17 +18,17 @@ import re # noqa: F401 import json from datetime import datetime -from typing import Any, Dict, Optional +from typing import Any, Dict from pydantic import BaseModel, Field, StrictInt, StrictStr class Resolution(BaseModel): """ Resolution """ - requester_name: Optional[StrictStr] = 'C1' - requester_did: Optional[StrictStr] = 'did:sov:test:1122' - resolved_did: Optional[StrictStr] = 'did:sov:test:1234' - other: Optional[Dict[str, Any]] = None + requester_name: StrictStr = Field(...) + requester_did: StrictStr = Field(...) + resolved_did: StrictStr = Field(...) + other: Dict[str, Any] = Field(...) timestamp: datetime = Field(...) id: StrictInt = Field(...) __properties = ["requester_name", "requester_did", "resolved_did", "other", "timestamp", "id"] @@ -69,9 +69,9 @@ class Resolution(BaseModel): return Resolution.parse_obj(obj) _obj = Resolution.parse_obj({ - "requester_name": obj.get("requester_name") if obj.get("requester_name") is not None else 'C1', - "requester_did": obj.get("requester_did") if obj.get("requester_did") is not None else 'did:sov:test:1122', - "resolved_did": obj.get("resolved_did") if obj.get("resolved_did") is not None else 'did:sov:test:1234', + "requester_name": obj.get("requester_name"), + "requester_did": obj.get("requester_did"), + "resolved_did": obj.get("resolved_did"), "other": obj.get("other"), "timestamp": obj.get("timestamp"), "id": obj.get("id") diff --git a/pkgs/clan-cli/tests/openapi_client/models/service.py b/pkgs/clan-cli/tests/openapi_client/models/service.py index 14cc136..9d85092 100644 --- a/pkgs/clan-cli/tests/openapi_client/models/service.py +++ b/pkgs/clan-cli/tests/openapi_client/models/service.py @@ -18,21 +18,23 @@ import re # noqa: F401 import json -from typing import Any, Dict, Optional -from pydantic import BaseModel, StrictStr +from typing import Any, Dict +from pydantic import BaseModel, Field, StrictStr +from openapi_client.models.entity import Entity class Service(BaseModel): """ Service """ - uuid: Optional[StrictStr] = '8e285c0c-4e40-430a-a477-26b3b81e30df' - service_name: Optional[StrictStr] = 'Carlos Printing' - service_type: Optional[StrictStr] = '3D Printing' - endpoint_url: Optional[StrictStr] = 'http://127.0.0.1:8000' - status: Optional[StrictStr] = 'unknown' - other: Optional[Dict[str, Any]] = None - entity_did: Optional[StrictStr] = 'did:sov:test:1234' - __properties = ["uuid", "service_name", "service_type", "endpoint_url", "status", "other", "entity_did"] + uuid: StrictStr = Field(...) + service_name: StrictStr = Field(...) + service_type: StrictStr = Field(...) + endpoint_url: StrictStr = Field(...) + status: StrictStr = Field(...) + other: Dict[str, Any] = Field(...) + entity_did: StrictStr = Field(...) + entity: Entity = Field(...) + __properties = ["uuid", "service_name", "service_type", "endpoint_url", "status", "other", "entity_did", "entity"] class Config: """Pydantic configuration""" @@ -58,6 +60,9 @@ class Service(BaseModel): exclude={ }, exclude_none=True) + # override the default output from pydantic by calling `to_dict()` of entity + if self.entity: + _dict['entity'] = self.entity.to_dict() return _dict @classmethod @@ -70,13 +75,14 @@ class Service(BaseModel): return Service.parse_obj(obj) _obj = Service.parse_obj({ - "uuid": obj.get("uuid") if obj.get("uuid") is not None else '8e285c0c-4e40-430a-a477-26b3b81e30df', - "service_name": obj.get("service_name") if obj.get("service_name") is not None else 'Carlos Printing', - "service_type": obj.get("service_type") if obj.get("service_type") is not None else '3D Printing', - "endpoint_url": obj.get("endpoint_url") if obj.get("endpoint_url") is not None else 'http://127.0.0.1:8000', - "status": obj.get("status") if obj.get("status") is not None else 'unknown', + "uuid": obj.get("uuid"), + "service_name": obj.get("service_name"), + "service_type": obj.get("service_type"), + "endpoint_url": obj.get("endpoint_url"), + "status": obj.get("status"), "other": obj.get("other"), - "entity_did": obj.get("entity_did") if obj.get("entity_did") is not None else 'did:sov:test:1234' + "entity_did": obj.get("entity_did"), + "entity": Entity.from_dict(obj.get("entity")) if obj.get("entity") is not None else None }) return _obj diff --git a/pkgs/clan-cli/tests/openapi_client/models/service_create.py b/pkgs/clan-cli/tests/openapi_client/models/service_create.py index 3d6b732..348695e 100644 --- a/pkgs/clan-cli/tests/openapi_client/models/service_create.py +++ b/pkgs/clan-cli/tests/openapi_client/models/service_create.py @@ -18,20 +18,20 @@ import re # noqa: F401 import json -from typing import Any, Dict, Optional -from pydantic import BaseModel, StrictStr +from typing import Any, Dict +from pydantic import BaseModel, Field, StrictStr class ServiceCreate(BaseModel): """ ServiceCreate """ - uuid: Optional[StrictStr] = '8e285c0c-4e40-430a-a477-26b3b81e30df' - service_name: Optional[StrictStr] = 'Carlos Printing' - service_type: Optional[StrictStr] = '3D Printing' - endpoint_url: Optional[StrictStr] = 'http://127.0.0.1:8000' - status: Optional[StrictStr] = 'unknown' - other: Optional[Dict[str, Any]] = None - entity_did: Optional[StrictStr] = 'did:sov:test:1234' + uuid: StrictStr = Field(...) + service_name: StrictStr = Field(...) + service_type: StrictStr = Field(...) + endpoint_url: StrictStr = Field(...) + status: StrictStr = Field(...) + other: Dict[str, Any] = Field(...) + entity_did: StrictStr = Field(...) __properties = ["uuid", "service_name", "service_type", "endpoint_url", "status", "other", "entity_did"] class Config: @@ -70,13 +70,13 @@ class ServiceCreate(BaseModel): return ServiceCreate.parse_obj(obj) _obj = ServiceCreate.parse_obj({ - "uuid": obj.get("uuid") if obj.get("uuid") is not None else '8e285c0c-4e40-430a-a477-26b3b81e30df', - "service_name": obj.get("service_name") if obj.get("service_name") is not None else 'Carlos Printing', - "service_type": obj.get("service_type") if obj.get("service_type") is not None else '3D Printing', - "endpoint_url": obj.get("endpoint_url") if obj.get("endpoint_url") is not None else 'http://127.0.0.1:8000', - "status": obj.get("status") if obj.get("status") is not None else 'unknown', + "uuid": obj.get("uuid"), + "service_name": obj.get("service_name"), + "service_type": obj.get("service_type"), + "endpoint_url": obj.get("endpoint_url"), + "status": obj.get("status"), "other": obj.get("other"), - "entity_did": obj.get("entity_did") if obj.get("entity_did") is not None else 'did:sov:test:1234' + "entity_did": obj.get("entity_did") }) return _obj diff --git a/pkgs/clan-cli/tests/openapi_client/test/test_clients_api.py b/pkgs/clan-cli/tests/openapi_client/test/test_clients_api.py index 6170b17..a78453a 100644 --- a/pkgs/clan-cli/tests/openapi_client/test/test_clients_api.py +++ b/pkgs/clan-cli/tests/openapi_client/test/test_clients_api.py @@ -26,10 +26,10 @@ class TestClientsApi(unittest.TestCase): def tearDown(self) -> None: pass - def test_get_all_clients(self) -> None: - """Test case for get_all_clients + def test_get_clients_by_did(self) -> None: + """Test case for get_clients_by_did - Get All Clients # noqa: E501 + Get Clients By Did # noqa: E501 """ pass diff --git a/pkgs/clan-cli/tests/openapi_client/test/test_entities_api.py b/pkgs/clan-cli/tests/openapi_client/test/test_entities_api.py index 75c7fb4..ecbc5b8 100644 --- a/pkgs/clan-cli/tests/openapi_client/test/test_entities_api.py +++ b/pkgs/clan-cli/tests/openapi_client/test/test_entities_api.py @@ -75,6 +75,13 @@ class TestEntitiesApi(unittest.TestCase): """ pass + def test_get_entity_by_name(self) -> None: + """Test case for get_entity_by_name + + Get Entity By Name # noqa: E501 + """ + pass + if __name__ == '__main__': unittest.main() diff --git a/pkgs/clan-cli/tests/openapi_client/test/test_entity.py b/pkgs/clan-cli/tests/openapi_client/test/test_entity.py index 8f87b61..5733915 100644 --- a/pkgs/clan-cli/tests/openapi_client/test/test_entity.py +++ b/pkgs/clan-cli/tests/openapi_client/test/test_entity.py @@ -40,11 +40,16 @@ class TestEntity(unittest.TestCase): name = 'C1', ip = '127.0.0.1', visible = True, - other = openapi_client.models.other.Other(), + other = {network=Carlos Home Network, roles=[service repository, service prosumer]}, attached = True ) else: return Entity( + did = 'did:sov:test:1234', + name = 'C1', + ip = '127.0.0.1', + visible = True, + other = {network=Carlos Home Network, roles=[service repository, service prosumer]}, attached = True, ) """ diff --git a/pkgs/clan-cli/tests/openapi_client/test/test_entity_create.py b/pkgs/clan-cli/tests/openapi_client/test/test_entity_create.py index 457eee1..e6c4565 100644 --- a/pkgs/clan-cli/tests/openapi_client/test/test_entity_create.py +++ b/pkgs/clan-cli/tests/openapi_client/test/test_entity_create.py @@ -40,10 +40,15 @@ class TestEntityCreate(unittest.TestCase): name = 'C1', ip = '127.0.0.1', visible = True, - other = openapi_client.models.other.Other() + other = {network=Carlos Home Network, roles=[service repository, service prosumer]} ) else: return EntityCreate( + did = 'did:sov:test:1234', + name = 'C1', + ip = '127.0.0.1', + visible = True, + other = {network=Carlos Home Network, roles=[service repository, service prosumer]}, ) """ diff --git a/pkgs/clan-cli/tests/openapi_client/test/test_resolution.py b/pkgs/clan-cli/tests/openapi_client/test/test_resolution.py index 62e85bf..08ecde0 100644 --- a/pkgs/clan-cli/tests/openapi_client/test/test_resolution.py +++ b/pkgs/clan-cli/tests/openapi_client/test/test_resolution.py @@ -39,12 +39,16 @@ class TestResolution(unittest.TestCase): requester_name = 'C1', requester_did = 'did:sov:test:1122', resolved_did = 'did:sov:test:1234', - other = openapi_client.models.other.Other(), + other = {test=test}, timestamp = datetime.datetime.strptime('2013-10-20 19:20:30.00', '%Y-%m-%d %H:%M:%S.%f'), id = 56 ) else: return Resolution( + requester_name = 'C1', + requester_did = 'did:sov:test:1122', + resolved_did = 'did:sov:test:1234', + other = {test=test}, timestamp = datetime.datetime.strptime('2013-10-20 19:20:30.00', '%Y-%m-%d %H:%M:%S.%f'), id = 56, ) diff --git a/pkgs/clan-cli/tests/openapi_client/test/test_service.py b/pkgs/clan-cli/tests/openapi_client/test/test_service.py index 75e01ff..a681b0d 100644 --- a/pkgs/clan-cli/tests/openapi_client/test/test_service.py +++ b/pkgs/clan-cli/tests/openapi_client/test/test_service.py @@ -41,11 +41,32 @@ class TestService(unittest.TestCase): service_type = '3D Printing', endpoint_url = 'http://127.0.0.1:8000', status = 'unknown', - other = openapi_client.models.other.Other(), - entity_did = 'did:sov:test:1234' + other = {action=[register, deregister, delete, create]}, + entity_did = 'did:sov:test:1234', + entity = openapi_client.models.entity.Entity( + did = 'did:sov:test:1234', + name = 'C1', + ip = '127.0.0.1', + visible = True, + other = {network=Carlos Home Network, roles=[service repository, service prosumer]}, + attached = True, ) ) else: return Service( + uuid = '8e285c0c-4e40-430a-a477-26b3b81e30df', + service_name = 'Carlos Printing', + service_type = '3D Printing', + endpoint_url = 'http://127.0.0.1:8000', + status = 'unknown', + other = {action=[register, deregister, delete, create]}, + entity_did = 'did:sov:test:1234', + entity = openapi_client.models.entity.Entity( + did = 'did:sov:test:1234', + name = 'C1', + ip = '127.0.0.1', + visible = True, + other = {network=Carlos Home Network, roles=[service repository, service prosumer]}, + attached = True, ), ) """ diff --git a/pkgs/clan-cli/tests/openapi_client/test/test_service_create.py b/pkgs/clan-cli/tests/openapi_client/test/test_service_create.py index 23adb04..588bb66 100644 --- a/pkgs/clan-cli/tests/openapi_client/test/test_service_create.py +++ b/pkgs/clan-cli/tests/openapi_client/test/test_service_create.py @@ -41,11 +41,18 @@ class TestServiceCreate(unittest.TestCase): service_type = '3D Printing', endpoint_url = 'http://127.0.0.1:8000', status = 'unknown', - other = openapi_client.models.other.Other(), + other = {action=[register, deregister, delete, create]}, entity_did = 'did:sov:test:1234' ) else: return ServiceCreate( + uuid = '8e285c0c-4e40-430a-a477-26b3b81e30df', + service_name = 'Carlos Printing', + service_type = '3D Printing', + endpoint_url = 'http://127.0.0.1:8000', + status = 'unknown', + other = {action=[register, deregister, delete, create]}, + entity_did = 'did:sov:test:1234', ) """ diff --git a/pkgs/clan-cli/tests/test_db_api.py b/pkgs/clan-cli/tests/test_db_api.py index 53dedce..faa5442 100644 --- a/pkgs/clan-cli/tests/test_db_api.py +++ b/pkgs/clan-cli/tests/test_db_api.py @@ -1,16 +1,81 @@ from openapi_client import ApiClient -from openapi_client.api import default_api -from openapi_client.models import Machine, Status +from openapi_client.api import DefaultApi +from openapi_client.api.entities_api import EntitiesApi +from openapi_client.api.services_api import ServicesApi +from openapi_client.models import ( + Entity, + EntityCreate, + Machine, + ServiceCreate, + Status, +) -default_entity_did_url = "entity_did=did%3Asov%3Atest%3A1234" -default_entity_did = "did:sov:test:1234" -default_entity_did2 = "did:sov:test:1235" -default_entity_did3 = "did:sov:test:1236" -default_entity_did4 = "did:sov:test:1237" -default_entity_did5 = "did:sov:test:1238" +uuids = [ + "e95bb72f-b1b3-4452-8065-c7acf09068fc", + "411d772e-1ad0-4d99-8da0-133ab2972322", + "8cfdf359-c3b9-4951-9e51-08dce797725a", + "24b5b4de-9f5f-4e60-878e-cc5be085fd0d", + "d45f9687-c413-43b9-8e0d-cb610b39fcaf", + "083e09a0-1d71-4819-83e2-ce2a6d831713", + "e6f74e55-c163-4368-98c0-a2b04c99d6e3", + "1b577ba7-c9dd-4e66-b695-9350e9db0b6c", + "bfd9e653-98a4-4451-9d97-bcc2908f213d", + "0e481624-b886-437c-89a0-b9e73651cc72", +] def test_health(api_client: ApiClient) -> None: - default = default_api.DefaultApi(api_client=api_client) + default = DefaultApi(api_client=api_client) res: Machine = default.health() assert res.status == Status.ONLINE + + +def test_entities_empty(api_client: ApiClient) -> None: + entity = EntitiesApi(api_client=api_client) + res = entity.get_all_entities() + assert res == [] + + +def create_entities(num: int = 10) -> list[EntityCreate]: + res = [] + for i in range(num): + en = EntityCreate( + did=f"did:sov:test:12{i}", + name=f"C{i}", + ip=f"127.0.0.1:{7000+i}", + visible=True, + other={}, + ) + res.append(en) + return res + + +def create_service(idx: int, entity: Entity) -> ServiceCreate: + se = ServiceCreate( + uuid=uuids[idx], + service_name=f"Carlos Printing{idx}", + service_type="3D Printing", + endpoint_url=f"{entity.ip}/v1/print_daemon{idx}", + status="unknown", + other={"action": ["register", "deregister", "delete", "create"]}, + entity_did=entity.did, + ) + + return se + + +def test_create_entities(api_client: ApiClient) -> None: + api = EntitiesApi(api_client=api_client) + for own_entity in create_entities(): + res: Entity = api.create_entity(own_entity) + assert res.did == own_entity.did + assert res.attached is False + + +def test_create_services(api_client: ApiClient) -> None: + sapi = ServicesApi(api_client=api_client) + eapi = EntitiesApi(api_client=api_client) + for idx, entity in enumerate(eapi.get_all_entities()): + service_obj = create_service(idx, entity) + service = sapi.create_service(service_obj) + assert service.uuid == service_obj.uuid diff --git a/pkgs/ui/shell.nix b/pkgs/ui/shell.nix index 573aecd..44f89ea 100644 --- a/pkgs/ui/shell.nix +++ b/pkgs/ui/shell.nix @@ -20,13 +20,13 @@ pkgs.mkShell { fi ln -sf ${pkgs.roboto}/share/fonts ./src - + export PATH="$PATH:$(realpath ./node_modules)/.bin" - # re-generate the api code + # re-generate the api code rm -rf src/api openapi.json - cp ${clanPkgs.clan-openapi}/openapi.json . + cp ${clanPkgs.clan-openapi}/openapi.json . orval ''; } diff --git a/pkgs/ui/src/app/access-point/page.tsx b/pkgs/ui/src/app/access-point/page.tsx index 91bd903..b5de9d8 100644 --- a/pkgs/ui/src/app/access-point/page.tsx +++ b/pkgs/ui/src/app/access-point/page.tsx @@ -2,7 +2,7 @@ import { mutate } from "swr"; import { useGetAttachedEntities } from "@/api/entities/entities"; -import { useGetRepositories } from "@/api/repositories/repositories"; +import { useGetAllRepositories } from "@/api/repositories/repositories"; import SummaryDetails from "@/components/summary_card"; import CustomTable from "@/components/table"; import { @@ -22,7 +22,7 @@ export default function AccessPoint() { data: APRepositories, isLoading: laodingRepositories, swrKey: repositoriesKeyFunc, - } = useGetRepositories(); + } = useGetAllRepositories(); const onRefresh = () => { const attachedEntitiesKey = diff --git a/pkgs/ui/src/app/client-1/page.tsx b/pkgs/ui/src/app/client-1/page.tsx deleted file mode 100644 index c0343de..0000000 --- a/pkgs/ui/src/app/client-1/page.tsx +++ /dev/null @@ -1,168 +0,0 @@ -"use client"; -import { useEffect, useRef, useState } from "react"; -import { - Client1ConsumerTableConfig, - Client1ProducerTableConfig, -} from "@/config/client_1"; -import CustomTable from "@/components/table"; -import useGetEntityByName from "@/components/hooks/useGetEntityById"; -import { - Alert, - Button, - Card, - CardContent, - CardHeader, - Skeleton, - Snackbar, - Typography, -} from "@mui/material"; -import CopyToClipboard from "@/components/copy_to_clipboard"; -import { mutate } from "swr"; -import { useGetEntity } from "@/api/entities/entities"; -import { BASE_URL } from "@/constants"; -import axios from "axios"; - -export default function Client1() { - const { entity } = useGetEntityByName("C1"); - const { - data: client1, - isLoading, - swrKey: entityKeyFunc, - } = useGetEntity({ entity_did: entity?.did }); - const cardContentRef = useRef(null); - const [isAttached, setIsAttached] = useState(entity?.attached || false); - const [snackbarOpen, setSnackbarOpen] = useState(false); - const [snackbarMessage, setSnackbarMessage] = useState(""); - - const closeSnackBar = () => { - setSnackbarMessage(""); - setSnackbarOpen(false); - }; - - const onAttachEntity = async () => { - try { - const response = await axios.post(`${BASE_URL}/attach`, { - entity_did: entity?.did, - }); - setSnackbarMessage(response.data.message); - setSnackbarOpen(true); - } catch (error) { - console.error(error); - } finally { - setIsAttached(true); - } - }; - - const onDetachEntity = async () => { - try { - const response = await axios.post(`${BASE_URL}/detach`, { - entity_did: entity?.did, - }); - console.log(response); - setSnackbarMessage("Entity detached successfully."); - setSnackbarOpen(true); - } catch (error) { - console.error(error); - } finally { - setIsAttached(false); - } - }; - - const onRefresh = () => { - const entityKey = - typeof entityKeyFunc === "function" ? entityKeyFunc() : entityKeyFunc; - if (entityKey) mutate(entityKey); - }; - - useEffect(() => { - const interval = setInterval(() => { - onRefresh(); - }, 1000); - - return () => clearInterval(interval); - // eslint-disable-next-line react-hooks/exhaustive-deps - }, []); - - if (isLoading) return ; - - return ( -
-
-

Client 1

-
- {isAttached === false ? ( - - ) : ( - - )} - - -
-
- - - } - /> - - - DID: {client1?.data?.did} - - - IP: {client1?.data?.ip} - - - Network: {client1?.data?.other?.network} - - - -
-

Consumer View

- -
-
-

Producer View

- -
- - - {snackbarMessage} - - -
- ); -} diff --git a/pkgs/ui/src/app/client-2/page.tsx b/pkgs/ui/src/app/client/[client_name]/page.tsx similarity index 60% rename from pkgs/ui/src/app/client-2/page.tsx rename to pkgs/ui/src/app/client/[client_name]/page.tsx index 31526a5..55028e9 100644 --- a/pkgs/ui/src/app/client-2/page.tsx +++ b/pkgs/ui/src/app/client/[client_name]/page.tsx @@ -1,70 +1,50 @@ "use client"; -import { useEffect, useRef, useState } from "react"; +import { useEffect, useMemo, useRef, useState } from "react"; import { - Client2ConsumerTableConfig, - Client2ProducerTableConfig, -} from "@/config/client_2"; + ClientTableConfig, + ServiceTableConfig, +} from "@/config/client_1"; import CustomTable from "@/components/table"; -import useGetEntityByName from "@/components/hooks/useGetEntityById"; import { + Alert, Button, Card, CardContent, CardHeader, - Skeleton, - Typography, Snackbar, - Alert, + Typography, } from "@mui/material"; import CopyToClipboard from "@/components/copy_to_clipboard"; -import { useGetEntity } from "@/api/entities/entities"; +import { useGetServicesByName } from "@/api/services/services"; +import { attachEntity, detachEntity } from "@/api/entities/entities"; import { mutate } from "swr"; -import axios from "axios"; -import { BASE_URL } from "@/constants"; +import { Skeleton } from "@mui/material"; +import { Service } from "@/api/model"; + +export default function Client({ + params, +}: { + params: { client_name: string }; +}) { + const { client_name } = params; -export default function Client2() { - const { entity } = useGetEntityByName("C2"); const { - data: client2, - isLoading, + data: services, + isLoading: services_loading, swrKey: entityKeyFunc, - } = useGetEntity({ entity_did: entity?.did }); - const cardContentRef = useRef(null); - const [isAttached, setIsAttached] = useState(entity?.attached); - const [snackbarOpen, setSnackbarOpen] = useState(false); - const [snackbarMessage, setSnackbarMessage] = useState(""); + } = useGetServicesByName({ + entity_name: client_name, + }); - const closeSnackBar = () => { - setSnackbarMessage(""); - setSnackbarOpen(false); - }; - - const onAttachEntity = async () => { - try { - const response = await axios.post(`${BASE_URL}/attach`, { - entity_did: entity?.did, + const entity = services?.data?.entity; + const clients: Service[] = useMemo(() => { + if (services?.data?.services) { + return services.data.services.filter((service) => { + if (service.entity_did !== entity?.did) return true; }); - alert(response.data.message); - } catch (error) { - console.error(error); - } finally { - setIsAttached(true); } - }; - - const onDetachEntity = async () => { - try { - const response = await axios.post(`${BASE_URL}/detach`, { - entity_did: entity?.did, - }); - console.log("detach", response); - alert("Entity Detached Successfully."); - } catch (error) { - console.error(error); - } finally { - setIsAttached(false); - } - }; + return []; + }, [services]); const onRefresh = () => { const entityKey = @@ -81,7 +61,51 @@ export default function Client2() { // eslint-disable-next-line react-hooks/exhaustive-deps }, []); - if (isLoading) return ; + const cardContentRef = useRef(null); + const [snackbarOpen, setSnackbarOpen] = useState(false); + const [snackbarMessage, setSnackbarMessage] = useState(""); + const [isAttached, setIsAttached] = useState(entity?.attached); + + const closeSnackBar = () => { + setSnackbarMessage(""); + setSnackbarOpen(false); + }; + + const onAttachEntity = async () => { + try { + if (entity) { + const response = await attachEntity(entity.did); + setSnackbarMessage(response.data.message); + setSnackbarOpen(true); + } else { + console.error("no entity"); + } + } catch (error) { + console.error(error); + } finally { + setIsAttached(true); + } + }; + + const onDetachEntity = async () => { + try { + if (entity) { + const response = await detachEntity(entity.did); + console.log(response); + setSnackbarMessage("Entity detached successfully."); + setSnackbarOpen(true); + } else { + console.error("no entity"); + } + } catch (error) { + console.error(error); + } finally { + setIsAttached(false); + } + }; + + if (services_loading) return ; + if (!services) return Client not found; return (
@@ -92,7 +116,7 @@ export default function Client2() { justifyContent: "space-between", }} > -

Client 2

+

Client 1

{isAttached === false ? ( @@ -124,30 +149,32 @@ export default function Client2() { /> - DID: {client2?.data?.did} + DID: {entity?.did} - IP: {client2?.data?.ip} + IP: {entity?.ip} - Network: {client2?.data?.other?.network} + Network: {entity?.other?.network}
-

Consumer View

+

Client View

-

Producer View

+

Service View

{ const { children } = props; - const { data: entityData, swrKey: entitiesKeyFunc } = useGetEntities(); + const { data: entityData, swrKey: entitiesKeyFunc } = useGetAllEntities(); const isLoading = false; const error = undefined; diff --git a/pkgs/ui/src/components/sidebar/index.tsx b/pkgs/ui/src/components/sidebar/index.tsx index 3b46170..a7cb52b 100644 --- a/pkgs/ui/src/components/sidebar/index.tsx +++ b/pkgs/ui/src/components/sidebar/index.tsx @@ -35,13 +35,13 @@ const menuEntityEntries: MenuEntry[] = [ { icon: , label: "C1", - to: "/client-1", + to: "/client/C1", disabled: false, }, { icon: , label: "C2", - to: "/client-2", + to: "/client/C2", disabled: false, }, ]; diff --git a/pkgs/ui/src/components/table/index.tsx b/pkgs/ui/src/components/table/index.tsx index 25af334..52b8b5f 100644 --- a/pkgs/ui/src/components/table/index.tsx +++ b/pkgs/ui/src/components/table/index.tsx @@ -11,7 +11,7 @@ import { StyledTableCell, StyledTableRow } from "./style"; import { ICustomTable, CustomTableConfiguration } from "@/types"; import { Checkbox, Skeleton } from "@mui/material"; -const CustomTable = ({ configuration, data, loading }: ICustomTable) => { +const CustomTable = ({ configuration, data, loading, key }: ICustomTable) => { if (loading) return ; @@ -25,7 +25,7 @@ const CustomTable = ({ configuration, data, loading }: ICustomTable) => { render?: (param: any) => void | undefined, ) => { let renderedValue = value; - + console.log(cellKey) // cover use case if the data is an array if (Array.isArray(value)) renderedValue = value.join(", "); @@ -56,11 +56,11 @@ const CustomTable = ({ configuration, data, loading }: ICustomTable) => { {data.map((data: any, rowIndex: number) => ( - {configuration.map((column: CustomTableConfiguration) => { + {configuration.map((column: CustomTableConfiguration, columnIndex: number) => { const cellValue: any = data[column.key]; - const cellKey = column.key; + const cellKey = key + ":" + column.key + ":" + rowIndex; const renderComponent = column?.render; - return renderTableCell(cellValue, cellKey, renderComponent); + return renderTableCell(cellValue, cellKey + ":" + columnIndex, renderComponent); })} ))} diff --git a/pkgs/ui/src/config/client_1/index.tsx b/pkgs/ui/src/config/client_1/index.tsx index ca3a025..3a1db60 100644 --- a/pkgs/ui/src/config/client_1/index.tsx +++ b/pkgs/ui/src/config/client_1/index.tsx @@ -1,6 +1,6 @@ import { Button } from "@mui/material"; -export const Client1ConsumerTableConfig = [ +export const ClientTableConfig = [ { key: "service_name", label: "Service name", @@ -34,7 +34,7 @@ export const Client1ConsumerTableConfig = [ // }, ]; -export const Client1ProducerTableConfig = [ +export const ServiceTableConfig = [ { key: "service_name", label: "Service name", diff --git a/pkgs/ui/src/config/home/index.ts b/pkgs/ui/src/config/home/index.ts index 7f72fe5..4f0a122 100644 --- a/pkgs/ui/src/config/home/index.ts +++ b/pkgs/ui/src/config/home/index.ts @@ -8,7 +8,7 @@ export const HomeTableConfig = [ label: "Entity DID", }, { - key: "other", + key: "network", label: "Network", render: (value: any) => { const renderedValue = typeof value === "object" ? value?.network : "-"; @@ -20,7 +20,7 @@ export const HomeTableConfig = [ label: "IP address", }, { - key: "other", + key: "roles", label: "Roles", render: (value: any) => { const renderedValue = diff --git a/pkgs/ui/src/types/index.ts b/pkgs/ui/src/types/index.ts index fc40cbd..6ac86cc 100644 --- a/pkgs/ui/src/types/index.ts +++ b/pkgs/ui/src/types/index.ts @@ -8,6 +8,7 @@ export interface ICustomTable { configuration: CustomTableConfiguration[]; data: any; loading?: boolean; + key: string; } export interface EntityDetails { From 65354221481fc599190c4db8acaea3f31c646f70 Mon Sep 17 00:00:00 2001 From: Luis-Hebendanz Date: Sun, 7 Jan 2024 14:02:23 +0100 Subject: [PATCH 37/58] Fixed mypy complaints --- pkgs/clan-cli/pyproject.toml | 7 +- .../clan-cli/tests/openapi_client/__init__.py | 2 +- .../tests/openapi_client/api/__init__.py | 1 - .../tests/openapi_client/api/clients_api.py | 200 ------------------ .../tests/openapi_client/api/services_api.py | 156 ++++++++++++++ .../tests/openapi_client/docs/ClientsApi.md | 77 ------- .../tests/openapi_client/docs/ServicesApi.md | 83 +++++++- .../openapi_client/docs/ServicesByName.md | 28 +++ .../tests/openapi_client/models/__init__.py | 1 + .../openapi_client/models/services_by_name.py | 85 ++++++++ .../openapi_client/test/test_clients_api.py | 38 ---- .../openapi_client/test/test_services_api.py | 7 + .../test/test_services_by_name.py | 99 +++++++++ pkgs/ui/src/app/client/[client_name]/page.tsx | 5 +- pkgs/ui/src/components/table/index.tsx | 20 +- 15 files changed, 473 insertions(+), 336 deletions(-) delete mode 100644 pkgs/clan-cli/tests/openapi_client/api/clients_api.py delete mode 100644 pkgs/clan-cli/tests/openapi_client/docs/ClientsApi.md create mode 100644 pkgs/clan-cli/tests/openapi_client/docs/ServicesByName.md create mode 100644 pkgs/clan-cli/tests/openapi_client/models/services_by_name.py delete mode 100644 pkgs/clan-cli/tests/openapi_client/test/test_clients_api.py create mode 100644 pkgs/clan-cli/tests/openapi_client/test/test_services_by_name.py diff --git a/pkgs/clan-cli/pyproject.toml b/pkgs/clan-cli/pyproject.toml index 0149e3a..7fa8caf 100644 --- a/pkgs/clan-cli/pyproject.toml +++ b/pkgs/clan-cli/pyproject.toml @@ -31,12 +31,15 @@ warn_redundant_casts = true disallow_untyped_calls = true disallow_untyped_defs = true no_implicit_optional = true +follow_imports = "normal" exclude = [ "clan_cli.nixpkgs", - "tests/openapi_client", - "openapi_client", ] +[[tool.mypy.overrides]] +module = "openapi_client.*" +ignore_errors = true + [[tool.mypy.overrides]] module = "argcomplete.*" ignore_missing_imports = true diff --git a/pkgs/clan-cli/tests/openapi_client/__init__.py b/pkgs/clan-cli/tests/openapi_client/__init__.py index f46dd78..638483e 100644 --- a/pkgs/clan-cli/tests/openapi_client/__init__.py +++ b/pkgs/clan-cli/tests/openapi_client/__init__.py @@ -17,7 +17,6 @@ __version__ = "1.0.0" # import apis into sdk package -from openapi_client.api.clients_api import ClientsApi from openapi_client.api.default_api import DefaultApi from openapi_client.api.entities_api import EntitiesApi from openapi_client.api.repositories_api import RepositoriesApi @@ -43,6 +42,7 @@ from openapi_client.models.machine import Machine from openapi_client.models.resolution import Resolution from openapi_client.models.service import Service from openapi_client.models.service_create import ServiceCreate +from openapi_client.models.services_by_name import ServicesByName from openapi_client.models.status import Status from openapi_client.models.validation_error import ValidationError from openapi_client.models.validation_error_loc_inner import ValidationErrorLocInner diff --git a/pkgs/clan-cli/tests/openapi_client/api/__init__.py b/pkgs/clan-cli/tests/openapi_client/api/__init__.py index 234e1be..39c3f1b 100644 --- a/pkgs/clan-cli/tests/openapi_client/api/__init__.py +++ b/pkgs/clan-cli/tests/openapi_client/api/__init__.py @@ -1,7 +1,6 @@ # flake8: noqa # import apis into api package -from openapi_client.api.clients_api import ClientsApi from openapi_client.api.default_api import DefaultApi from openapi_client.api.entities_api import EntitiesApi from openapi_client.api.repositories_api import RepositoriesApi diff --git a/pkgs/clan-cli/tests/openapi_client/api/clients_api.py b/pkgs/clan-cli/tests/openapi_client/api/clients_api.py deleted file mode 100644 index 431c420..0000000 --- a/pkgs/clan-cli/tests/openapi_client/api/clients_api.py +++ /dev/null @@ -1,200 +0,0 @@ -# coding: utf-8 - -""" - FastAPI - - No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - - The version of the OpenAPI document: 0.1.0 - Generated by OpenAPI Generator (https://openapi-generator.tech) - - Do not edit the class manually. -""" # noqa: E501 - - -import re # noqa: F401 -import io -import warnings - -from pydantic import validate_arguments, ValidationError - -from pydantic import StrictInt, StrictStr - -from typing import List, Optional - -from openapi_client.models.service import Service - -from openapi_client.api_client import ApiClient -from openapi_client.api_response import ApiResponse -from openapi_client.exceptions import ( # noqa: F401 - ApiTypeError, - ApiValueError -) - - -class ClientsApi: - """NOTE: This class is auto generated by OpenAPI Generator - Ref: https://openapi-generator.tech - - Do not edit the class manually. - """ - - def __init__(self, api_client=None) -> None: - if api_client is None: - api_client = ApiClient.get_default() - self.api_client = api_client - - @validate_arguments - def get_clients_by_did(self, entity_did : StrictStr, skip : Optional[StrictInt] = None, limit : Optional[StrictInt] = None, **kwargs) -> List[Service]: # noqa: E501 - """Get Clients By Did # noqa: E501 - - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True - - >>> thread = api.get_clients_by_did(entity_did, skip, limit, async_req=True) - >>> result = thread.get() - - :param entity_did: (required) - :type entity_did: str - :param skip: - :type skip: int - :param limit: - :type limit: int - :param async_req: Whether to execute the request asynchronously. - :type async_req: bool, optional - :param _request_timeout: timeout setting for this request. - If one number provided, it will be total request - timeout. It can also be a pair (tuple) of - (connection, read) timeouts. - :return: Returns the result object. - If the method is called asynchronously, - returns the request thread. - :rtype: List[Service] - """ - kwargs['_return_http_data_only'] = True - if '_preload_content' in kwargs: - message = "Error! Please call the get_clients_by_did_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data" # noqa: E501 - raise ValueError(message) - return self.get_clients_by_did_with_http_info(entity_did, skip, limit, **kwargs) # noqa: E501 - - @validate_arguments - def get_clients_by_did_with_http_info(self, entity_did : StrictStr, skip : Optional[StrictInt] = None, limit : Optional[StrictInt] = None, **kwargs) -> ApiResponse: # noqa: E501 - """Get Clients By Did # noqa: E501 - - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True - - >>> thread = api.get_clients_by_did_with_http_info(entity_did, skip, limit, async_req=True) - >>> result = thread.get() - - :param entity_did: (required) - :type entity_did: str - :param skip: - :type skip: int - :param limit: - :type limit: int - :param async_req: Whether to execute the request asynchronously. - :type async_req: bool, optional - :param _preload_content: if False, the ApiResponse.data will - be set to none and raw_data will store the - HTTP response body without reading/decoding. - Default is True. - :type _preload_content: bool, optional - :param _return_http_data_only: response data instead of ApiResponse - object with status code, headers, etc - :type _return_http_data_only: bool, optional - :param _request_timeout: timeout setting for this request. If one - number provided, it will be total request - timeout. It can also be a pair (tuple) of - (connection, read) timeouts. - :param _request_auth: set to override the auth_settings for an a single - request; this effectively ignores the authentication - in the spec for a single request. - :type _request_auth: dict, optional - :type _content_type: string, optional: force content-type for the request - :return: Returns the result object. - If the method is called asynchronously, - returns the request thread. - :rtype: tuple(List[Service], status_code(int), headers(HTTPHeaderDict)) - """ - - _params = locals() - - _all_params = [ - 'entity_did', - 'skip', - 'limit' - ] - _all_params.extend( - [ - 'async_req', - '_return_http_data_only', - '_preload_content', - '_request_timeout', - '_request_auth', - '_content_type', - '_headers' - ] - ) - - # validate the arguments - for _key, _val in _params['kwargs'].items(): - if _key not in _all_params: - raise ApiTypeError( - "Got an unexpected keyword argument '%s'" - " to method get_clients_by_did" % _key - ) - _params[_key] = _val - del _params['kwargs'] - - _collection_formats = {} - - # process the path parameters - _path_params = {} - if _params['entity_did']: - _path_params['entity_did'] = _params['entity_did'] - - - # process the query parameters - _query_params = [] - if _params.get('skip') is not None: # noqa: E501 - _query_params.append(('skip', _params['skip'])) - - if _params.get('limit') is not None: # noqa: E501 - _query_params.append(('limit', _params['limit'])) - - # process the header parameters - _header_params = dict(_params.get('_headers', {})) - # process the form parameters - _form_params = [] - _files = {} - # process the body parameter - _body_params = None - # set the HTTP header `Accept` - _header_params['Accept'] = self.api_client.select_header_accept( - ['application/json']) # noqa: E501 - - # authentication setting - _auth_settings = [] # noqa: E501 - - _response_types_map = { - '200': "List[Service]", - '422': "HTTPValidationError", - } - - return self.api_client.call_api( - '/api/v1/{entity_did}/clients', 'GET', - _path_params, - _query_params, - _header_params, - body=_body_params, - post_params=_form_params, - files=_files, - response_types_map=_response_types_map, - auth_settings=_auth_settings, - async_req=_params.get('async_req'), - _return_http_data_only=_params.get('_return_http_data_only'), # noqa: E501 - _preload_content=_params.get('_preload_content', True), - _request_timeout=_params.get('_request_timeout'), - collection_formats=_collection_formats, - _request_auth=_params.get('_request_auth')) diff --git a/pkgs/clan-cli/tests/openapi_client/api/services_api.py b/pkgs/clan-cli/tests/openapi_client/api/services_api.py index 7e13ea0..4c17330 100644 --- a/pkgs/clan-cli/tests/openapi_client/api/services_api.py +++ b/pkgs/clan-cli/tests/openapi_client/api/services_api.py @@ -24,6 +24,7 @@ from typing import Any, List, Optional, Dict from openapi_client.models.service import Service from openapi_client.models.service_create import ServiceCreate +from openapi_client.models.services_by_name import ServicesByName from openapi_client.api_client import ApiClient from openapi_client.api_response import ApiResponse @@ -631,3 +632,158 @@ class ServicesApi: _request_timeout=_params.get('_request_timeout'), collection_formats=_collection_formats, _request_auth=_params.get('_request_auth')) + + @validate_arguments + def get_services_by_name(self, entity_name : StrictStr, skip : Optional[StrictInt] = None, limit : Optional[StrictInt] = None, **kwargs) -> ServicesByName: # noqa: E501 + """Get Services By Name # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.get_services_by_name(entity_name, skip, limit, async_req=True) + >>> result = thread.get() + + :param entity_name: (required) + :type entity_name: str + :param skip: + :type skip: int + :param limit: + :type limit: int + :param async_req: Whether to execute the request asynchronously. + :type async_req: bool, optional + :param _request_timeout: timeout setting for this request. + If one number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :return: Returns the result object. + If the method is called asynchronously, + returns the request thread. + :rtype: ServicesByName + """ + kwargs['_return_http_data_only'] = True + if '_preload_content' in kwargs: + message = "Error! Please call the get_services_by_name_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data" # noqa: E501 + raise ValueError(message) + return self.get_services_by_name_with_http_info(entity_name, skip, limit, **kwargs) # noqa: E501 + + @validate_arguments + def get_services_by_name_with_http_info(self, entity_name : StrictStr, skip : Optional[StrictInt] = None, limit : Optional[StrictInt] = None, **kwargs) -> ApiResponse: # noqa: E501 + """Get Services By Name # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.get_services_by_name_with_http_info(entity_name, skip, limit, async_req=True) + >>> result = thread.get() + + :param entity_name: (required) + :type entity_name: str + :param skip: + :type skip: int + :param limit: + :type limit: int + :param async_req: Whether to execute the request asynchronously. + :type async_req: bool, optional + :param _preload_content: if False, the ApiResponse.data will + be set to none and raw_data will store the + HTTP response body without reading/decoding. + Default is True. + :type _preload_content: bool, optional + :param _return_http_data_only: response data instead of ApiResponse + object with status code, headers, etc + :type _return_http_data_only: bool, optional + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the authentication + in the spec for a single request. + :type _request_auth: dict, optional + :type _content_type: string, optional: force content-type for the request + :return: Returns the result object. + If the method is called asynchronously, + returns the request thread. + :rtype: tuple(ServicesByName, status_code(int), headers(HTTPHeaderDict)) + """ + + _params = locals() + + _all_params = [ + 'entity_name', + 'skip', + 'limit' + ] + _all_params.extend( + [ + 'async_req', + '_return_http_data_only', + '_preload_content', + '_request_timeout', + '_request_auth', + '_content_type', + '_headers' + ] + ) + + # validate the arguments + for _key, _val in _params['kwargs'].items(): + if _key not in _all_params: + raise ApiTypeError( + "Got an unexpected keyword argument '%s'" + " to method get_services_by_name" % _key + ) + _params[_key] = _val + del _params['kwargs'] + + _collection_formats = {} + + # process the path parameters + _path_params = {} + + # process the query parameters + _query_params = [] + if _params.get('entity_name') is not None: # noqa: E501 + _query_params.append(('entity_name', _params['entity_name'])) + + if _params.get('skip') is not None: # noqa: E501 + _query_params.append(('skip', _params['skip'])) + + if _params.get('limit') is not None: # noqa: E501 + _query_params.append(('limit', _params['limit'])) + + # process the header parameters + _header_params = dict(_params.get('_headers', {})) + # process the form parameters + _form_params = [] + _files = {} + # process the body parameter + _body_params = None + # set the HTTP header `Accept` + _header_params['Accept'] = self.api_client.select_header_accept( + ['application/json']) # noqa: E501 + + # authentication setting + _auth_settings = [] # noqa: E501 + + _response_types_map = { + '200': "ServicesByName", + '422': "HTTPValidationError", + } + + return self.api_client.call_api( + '/api/v1/services_by_entity_name', 'GET', + _path_params, + _query_params, + _header_params, + body=_body_params, + post_params=_form_params, + files=_files, + response_types_map=_response_types_map, + auth_settings=_auth_settings, + async_req=_params.get('async_req'), + _return_http_data_only=_params.get('_return_http_data_only'), # noqa: E501 + _preload_content=_params.get('_preload_content', True), + _request_timeout=_params.get('_request_timeout'), + collection_formats=_collection_formats, + _request_auth=_params.get('_request_auth')) diff --git a/pkgs/clan-cli/tests/openapi_client/docs/ClientsApi.md b/pkgs/clan-cli/tests/openapi_client/docs/ClientsApi.md deleted file mode 100644 index e232dcd..0000000 --- a/pkgs/clan-cli/tests/openapi_client/docs/ClientsApi.md +++ /dev/null @@ -1,77 +0,0 @@ -# openapi_client.ClientsApi - -All URIs are relative to _http://localhost_ - -| Method | HTTP request | Description | -| ---------------------------------------------------------- | ------------------------------------ | ------------------ | -| [**get_clients_by_did**](ClientsApi.md#get_clients_by_did) | **GET** /api/v1/{entity_did}/clients | Get Clients By Did | - -# **get_clients_by_did** - -> List[Service] get_clients_by_did(entity_did, skip=skip, limit=limit) - -Get Clients By Did - -### Example - -```python -import time -import os -import openapi_client -from openapi_client.models.service import Service -from openapi_client.rest import ApiException -from pprint import pprint - -# Defining the host is optional and defaults to http://localhost -# See configuration.py for a list of all supported configuration parameters. -configuration = openapi_client.Configuration( - host = "http://localhost" -) - - -# Enter a context with an instance of the API client -with openapi_client.ApiClient(configuration) as api_client: - # Create an instance of the API class - api_instance = openapi_client.ClientsApi(api_client) - entity_did = 'entity_did_example' # str | - skip = 0 # int | (optional) (default to 0) - limit = 100 # int | (optional) (default to 100) - - try: - # Get Clients By Did - api_response = api_instance.get_clients_by_did(entity_did, skip=skip, limit=limit) - print("The response of ClientsApi->get_clients_by_did:\n") - pprint(api_response) - except Exception as e: - print("Exception when calling ClientsApi->get_clients_by_did: %s\n" % e) -``` - -### Parameters - -| Name | Type | Description | Notes | -| -------------- | ------- | ----------- | --------------------------- | -| **entity_did** | **str** | | -| **skip** | **int** | | [optional] [default to 0] | -| **limit** | **int** | | [optional] [default to 100] | - -### Return type - -[**List[Service]**](Service.md) - -### Authorization - -No authorization required - -### HTTP request headers - -- **Content-Type**: Not defined -- **Accept**: application/json - -### HTTP response details - -| Status code | Description | Response headers | -| ----------- | ------------------- | ---------------- | -| **200** | Successful Response | - | -| **422** | Validation Error | - | - -[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) diff --git a/pkgs/clan-cli/tests/openapi_client/docs/ServicesApi.md b/pkgs/clan-cli/tests/openapi_client/docs/ServicesApi.md index 048e944..846a81c 100644 --- a/pkgs/clan-cli/tests/openapi_client/docs/ServicesApi.md +++ b/pkgs/clan-cli/tests/openapi_client/docs/ServicesApi.md @@ -2,12 +2,13 @@ All URIs are relative to _http://localhost_ -| Method | HTTP request | Description | -| ----------------------------------------------------------- | --------------------------------------- | ------------------ | -| [**create_service**](ServicesApi.md#create_service) | **POST** /api/v1/service | Create Service | -| [**delete_service**](ServicesApi.md#delete_service) | **DELETE** /api/v1/{entity_did}/service | Delete Service | -| [**get_all_services**](ServicesApi.md#get_all_services) | **GET** /api/v1/services | Get All Services | -| [**get_service_by_did**](ServicesApi.md#get_service_by_did) | **GET** /api/v1/{entity_did}/service | Get Service By Did | +| Method | HTTP request | Description | +| --------------------------------------------------------------- | --------------------------------------- | -------------------- | +| [**create_service**](ServicesApi.md#create_service) | **POST** /api/v1/service | Create Service | +| [**delete_service**](ServicesApi.md#delete_service) | **DELETE** /api/v1/{entity_did}/service | Delete Service | +| [**get_all_services**](ServicesApi.md#get_all_services) | **GET** /api/v1/services | Get All Services | +| [**get_service_by_did**](ServicesApi.md#get_service_by_did) | **GET** /api/v1/{entity_did}/service | Get Service By Did | +| [**get_services_by_name**](ServicesApi.md#get_services_by_name) | **GET** /api/v1/services_by_entity_name | Get Services By Name | # **create_service** @@ -278,3 +279,73 @@ No authorization required | **422** | Validation Error | - | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **get_services_by_name** + +> ServicesByName get_services_by_name(entity_name, skip=skip, limit=limit) + +Get Services By Name + +### Example + +```python +import time +import os +import openapi_client +from openapi_client.models.services_by_name import ServicesByName +from openapi_client.rest import ApiException +from pprint import pprint + +# Defining the host is optional and defaults to http://localhost +# See configuration.py for a list of all supported configuration parameters. +configuration = openapi_client.Configuration( + host = "http://localhost" +) + + +# Enter a context with an instance of the API client +with openapi_client.ApiClient(configuration) as api_client: + # Create an instance of the API class + api_instance = openapi_client.ServicesApi(api_client) + entity_name = 'entity_name_example' # str | + skip = 0 # int | (optional) (default to 0) + limit = 100 # int | (optional) (default to 100) + + try: + # Get Services By Name + api_response = api_instance.get_services_by_name(entity_name, skip=skip, limit=limit) + print("The response of ServicesApi->get_services_by_name:\n") + pprint(api_response) + except Exception as e: + print("Exception when calling ServicesApi->get_services_by_name: %s\n" % e) +``` + +### Parameters + +| Name | Type | Description | Notes | +| --------------- | ------- | ----------- | --------------------------- | +| **entity_name** | **str** | | +| **skip** | **int** | | [optional] [default to 0] | +| **limit** | **int** | | [optional] [default to 100] | + +### Return type + +[**ServicesByName**](ServicesByName.md) + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +### HTTP response details + +| Status code | Description | Response headers | +| ----------- | ------------------- | ---------------- | +| **200** | Successful Response | - | +| **422** | Validation Error | - | + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) diff --git a/pkgs/clan-cli/tests/openapi_client/docs/ServicesByName.md b/pkgs/clan-cli/tests/openapi_client/docs/ServicesByName.md new file mode 100644 index 0000000..5d25b1e --- /dev/null +++ b/pkgs/clan-cli/tests/openapi_client/docs/ServicesByName.md @@ -0,0 +1,28 @@ +# ServicesByName + +## Properties + +| Name | Type | Description | Notes | +| ------------ | ------------------------------- | ----------- | ----- | +| **entity** | [**Entity**](Entity.md) | | +| **services** | [**List[Service]**](Service.md) | | + +## Example + +```python +from openapi_client.models.services_by_name import ServicesByName + +# TODO update the JSON string below +json = "{}" +# create an instance of ServicesByName from a JSON string +services_by_name_instance = ServicesByName.from_json(json) +# print the JSON string representation of the object +print ServicesByName.to_json() + +# convert the object into a dict +services_by_name_dict = services_by_name_instance.to_dict() +# create an instance of ServicesByName from a dict +services_by_name_form_dict = services_by_name.from_dict(services_by_name_dict) +``` + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/pkgs/clan-cli/tests/openapi_client/models/__init__.py b/pkgs/clan-cli/tests/openapi_client/models/__init__.py index 4955602..822cc4e 100644 --- a/pkgs/clan-cli/tests/openapi_client/models/__init__.py +++ b/pkgs/clan-cli/tests/openapi_client/models/__init__.py @@ -21,6 +21,7 @@ from openapi_client.models.machine import Machine from openapi_client.models.resolution import Resolution from openapi_client.models.service import Service from openapi_client.models.service_create import ServiceCreate +from openapi_client.models.services_by_name import ServicesByName from openapi_client.models.status import Status from openapi_client.models.validation_error import ValidationError from openapi_client.models.validation_error_loc_inner import ValidationErrorLocInner diff --git a/pkgs/clan-cli/tests/openapi_client/models/services_by_name.py b/pkgs/clan-cli/tests/openapi_client/models/services_by_name.py new file mode 100644 index 0000000..0ee9a85 --- /dev/null +++ b/pkgs/clan-cli/tests/openapi_client/models/services_by_name.py @@ -0,0 +1,85 @@ +# coding: utf-8 + +""" + FastAPI + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: 0.1.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + + +from typing import List +from pydantic import BaseModel, Field, conlist +from openapi_client.models.entity import Entity +from openapi_client.models.service import Service + +class ServicesByName(BaseModel): + """ + ServicesByName + """ + entity: Entity = Field(...) + services: conlist(Service) = Field(...) + __properties = ["entity", "services"] + + class Config: + """Pydantic configuration""" + allow_population_by_field_name = True + validate_assignment = True + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.dict(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> ServicesByName: + """Create an instance of ServicesByName from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self): + """Returns the dictionary representation of the model using alias""" + _dict = self.dict(by_alias=True, + exclude={ + }, + exclude_none=True) + # override the default output from pydantic by calling `to_dict()` of entity + if self.entity: + _dict['entity'] = self.entity.to_dict() + # override the default output from pydantic by calling `to_dict()` of each item in services (list) + _items = [] + if self.services: + for _item in self.services: + if _item: + _items.append(_item.to_dict()) + _dict['services'] = _items + return _dict + + @classmethod + def from_dict(cls, obj: dict) -> ServicesByName: + """Create an instance of ServicesByName from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return ServicesByName.parse_obj(obj) + + _obj = ServicesByName.parse_obj({ + "entity": Entity.from_dict(obj.get("entity")) if obj.get("entity") is not None else None, + "services": [Service.from_dict(_item) for _item in obj.get("services")] if obj.get("services") is not None else None + }) + return _obj + + diff --git a/pkgs/clan-cli/tests/openapi_client/test/test_clients_api.py b/pkgs/clan-cli/tests/openapi_client/test/test_clients_api.py deleted file mode 100644 index a78453a..0000000 --- a/pkgs/clan-cli/tests/openapi_client/test/test_clients_api.py +++ /dev/null @@ -1,38 +0,0 @@ -# coding: utf-8 - -""" - FastAPI - - No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - - The version of the OpenAPI document: 0.1.0 - Generated by OpenAPI Generator (https://openapi-generator.tech) - - Do not edit the class manually. -""" # noqa: E501 - - -import unittest - -from openapi_client.api.clients_api import ClientsApi # noqa: E501 - - -class TestClientsApi(unittest.TestCase): - """ClientsApi unit test stubs""" - - def setUp(self) -> None: - self.api = ClientsApi() # noqa: E501 - - def tearDown(self) -> None: - pass - - def test_get_clients_by_did(self) -> None: - """Test case for get_clients_by_did - - Get Clients By Did # noqa: E501 - """ - pass - - -if __name__ == '__main__': - unittest.main() diff --git a/pkgs/clan-cli/tests/openapi_client/test/test_services_api.py b/pkgs/clan-cli/tests/openapi_client/test/test_services_api.py index e92a4d7..b9d196d 100644 --- a/pkgs/clan-cli/tests/openapi_client/test/test_services_api.py +++ b/pkgs/clan-cli/tests/openapi_client/test/test_services_api.py @@ -54,6 +54,13 @@ class TestServicesApi(unittest.TestCase): """ pass + def test_get_services_by_name(self) -> None: + """Test case for get_services_by_name + + Get Services By Name # noqa: E501 + """ + pass + if __name__ == '__main__': unittest.main() diff --git a/pkgs/clan-cli/tests/openapi_client/test/test_services_by_name.py b/pkgs/clan-cli/tests/openapi_client/test/test_services_by_name.py new file mode 100644 index 0000000..b63992b --- /dev/null +++ b/pkgs/clan-cli/tests/openapi_client/test/test_services_by_name.py @@ -0,0 +1,99 @@ +# coding: utf-8 + +""" + FastAPI + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: 0.1.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import unittest +import datetime + +from openapi_client.models.services_by_name import ServicesByName # noqa: E501 + +class TestServicesByName(unittest.TestCase): + """ServicesByName unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional) -> ServicesByName: + """Test ServicesByName + include_option is a boolean, when False only required + params are included, when True both required and + optional params are included """ + # uncomment below to create an instance of `ServicesByName` + """ + model = ServicesByName() # noqa: E501 + if include_optional: + return ServicesByName( + entity = openapi_client.models.entity.Entity( + did = 'did:sov:test:1234', + name = 'C1', + ip = '127.0.0.1', + visible = True, + other = {network=Carlos Home Network, roles=[service repository, service prosumer]}, + attached = True, ), + services = [ + openapi_client.models.service.Service( + uuid = '8e285c0c-4e40-430a-a477-26b3b81e30df', + service_name = 'Carlos Printing', + service_type = '3D Printing', + endpoint_url = 'http://127.0.0.1:8000', + status = 'unknown', + other = {action=[register, deregister, delete, create]}, + entity_did = 'did:sov:test:1234', + entity = openapi_client.models.entity.Entity( + did = 'did:sov:test:1234', + name = 'C1', + ip = '127.0.0.1', + visible = True, + other = {network=Carlos Home Network, roles=[service repository, service prosumer]}, + attached = True, ), ) + ] + ) + else: + return ServicesByName( + entity = openapi_client.models.entity.Entity( + did = 'did:sov:test:1234', + name = 'C1', + ip = '127.0.0.1', + visible = True, + other = {network=Carlos Home Network, roles=[service repository, service prosumer]}, + attached = True, ), + services = [ + openapi_client.models.service.Service( + uuid = '8e285c0c-4e40-430a-a477-26b3b81e30df', + service_name = 'Carlos Printing', + service_type = '3D Printing', + endpoint_url = 'http://127.0.0.1:8000', + status = 'unknown', + other = {action=[register, deregister, delete, create]}, + entity_did = 'did:sov:test:1234', + entity = openapi_client.models.entity.Entity( + did = 'did:sov:test:1234', + name = 'C1', + ip = '127.0.0.1', + visible = True, + other = {network=Carlos Home Network, roles=[service repository, service prosumer]}, + attached = True, ), ) + ], + ) + """ + + def testServicesByName(self): + """Test ServicesByName""" + # inst_req_only = self.make_instance(include_optional=False) + # inst_req_and_optional = self.make_instance(include_optional=True) + +if __name__ == '__main__': + unittest.main() diff --git a/pkgs/ui/src/app/client/[client_name]/page.tsx b/pkgs/ui/src/app/client/[client_name]/page.tsx index 55028e9..259d016 100644 --- a/pkgs/ui/src/app/client/[client_name]/page.tsx +++ b/pkgs/ui/src/app/client/[client_name]/page.tsx @@ -1,9 +1,6 @@ "use client"; import { useEffect, useMemo, useRef, useState } from "react"; -import { - ClientTableConfig, - ServiceTableConfig, -} from "@/config/client_1"; +import { ClientTableConfig, ServiceTableConfig } from "@/config/client_1"; import CustomTable from "@/components/table"; import { Alert, diff --git a/pkgs/ui/src/components/table/index.tsx b/pkgs/ui/src/components/table/index.tsx index 52b8b5f..d0a8b75 100644 --- a/pkgs/ui/src/components/table/index.tsx +++ b/pkgs/ui/src/components/table/index.tsx @@ -25,7 +25,7 @@ const CustomTable = ({ configuration, data, loading, key }: ICustomTable) => { render?: (param: any) => void | undefined, ) => { let renderedValue = value; - console.log(cellKey) + console.log(cellKey); // cover use case if the data is an array if (Array.isArray(value)) renderedValue = value.join(", "); @@ -56,12 +56,18 @@ const CustomTable = ({ configuration, data, loading, key }: ICustomTable) => { {data.map((data: any, rowIndex: number) => ( - {configuration.map((column: CustomTableConfiguration, columnIndex: number) => { - const cellValue: any = data[column.key]; - const cellKey = key + ":" + column.key + ":" + rowIndex; - const renderComponent = column?.render; - return renderTableCell(cellValue, cellKey + ":" + columnIndex, renderComponent); - })} + {configuration.map( + (column: CustomTableConfiguration, columnIndex: number) => { + const cellValue: any = data[column.key]; + const cellKey = key + ":" + column.key + ":" + rowIndex; + const renderComponent = column?.render; + return renderTableCell( + cellValue, + cellKey + ":" + columnIndex, + renderComponent, + ); + }, + )} ))} From 74fbb7890cb150f0cb6ac96d94b745d23a36b78b Mon Sep 17 00:00:00 2001 From: Luis-Hebendanz Date: Sun, 7 Jan 2024 14:56:06 +0100 Subject: [PATCH 38/58] fixed cors issues --- pkgs/clan-cli/clan_cli/webui/app.py | 18 ++++++++---- pkgs/clan-cli/tests/test_db_api.py | 29 +++++++++---------- pkgs/ui/src/app/access-point/page.tsx | 2 ++ pkgs/ui/src/app/client/[client_name]/page.tsx | 8 ++--- .../app/distributed-ledger-gateway/page.tsx | 1 + pkgs/ui/src/app/home/page.tsx | 3 +- pkgs/ui/src/components/table/index.tsx | 7 +++-- pkgs/ui/src/config/client_1/index.tsx | 1 + pkgs/ui/src/types/index.ts | 2 +- 9 files changed, 41 insertions(+), 30 deletions(-) diff --git a/pkgs/clan-cli/clan_cli/webui/app.py b/pkgs/clan-cli/clan_cli/webui/app.py index d34d25d..8913f72 100644 --- a/pkgs/clan-cli/clan_cli/webui/app.py +++ b/pkgs/clan-cli/clan_cli/webui/app.py @@ -17,11 +17,19 @@ from .routers import endpoints, health, root, socket_manager2 # sql router hinz from .sql_db import engine from .tags import tags_metadata -origins = [ - "http://localhost:3000", - "http://127.0.0.1:3000", - "http://0.0.0.0:3000", +cors_url = [ + "http://localhost", + "http://127.0.0.1", + "http://0.0.0.0", + "http://[::]", ] +cors_ports = [2979, 3000] +cors_whitelist = [] +for u in cors_url: + for p in cors_ports: + cors_whitelist.append(f"{u}:{p}") + + # Logging setup log = logging.getLogger(__name__) @@ -44,7 +52,7 @@ def setup_app() -> FastAPI: app = FastAPI(lifespan=lifespan, swagger_ui_parameters={"tryItOutEnabled": True}) app.add_middleware( CORSMiddleware, - allow_origins=origins, + allow_origins=cors_whitelist, allow_credentials=True, allow_methods=["*"], allow_headers=["*"], diff --git a/pkgs/clan-cli/tests/test_db_api.py b/pkgs/clan-cli/tests/test_db_api.py index faa5442..2bb519d 100644 --- a/pkgs/clan-cli/tests/test_db_api.py +++ b/pkgs/clan-cli/tests/test_db_api.py @@ -1,3 +1,6 @@ +import random +import uuid + from openapi_client import ApiClient from openapi_client.api import DefaultApi from openapi_client.api.entities_api import EntitiesApi @@ -10,18 +13,11 @@ from openapi_client.models import ( Status, ) -uuids = [ - "e95bb72f-b1b3-4452-8065-c7acf09068fc", - "411d772e-1ad0-4d99-8da0-133ab2972322", - "8cfdf359-c3b9-4951-9e51-08dce797725a", - "24b5b4de-9f5f-4e60-878e-cc5be085fd0d", - "d45f9687-c413-43b9-8e0d-cb610b39fcaf", - "083e09a0-1d71-4819-83e2-ce2a6d831713", - "e6f74e55-c163-4368-98c0-a2b04c99d6e3", - "1b577ba7-c9dd-4e66-b695-9350e9db0b6c", - "bfd9e653-98a4-4451-9d97-bcc2908f213d", - "0e481624-b886-437c-89a0-b9e73651cc72", -] +random.seed(42) + + +num_uuids = 100 +uuids = [str(uuid.UUID(int=random.getrandbits(128))) for i in range(num_uuids)] def test_health(api_client: ApiClient) -> None: @@ -75,7 +71,8 @@ def test_create_entities(api_client: ApiClient) -> None: def test_create_services(api_client: ApiClient) -> None: sapi = ServicesApi(api_client=api_client) eapi = EntitiesApi(api_client=api_client) - for idx, entity in enumerate(eapi.get_all_entities()): - service_obj = create_service(idx, entity) - service = sapi.create_service(service_obj) - assert service.uuid == service_obj.uuid + for midx, entity in enumerate(eapi.get_all_entities()): + for idx in range(4): + service_obj = create_service(idx + 4 * midx, entity) + service = sapi.create_service(service_obj) + assert service.uuid == service_obj.uuid diff --git a/pkgs/ui/src/app/access-point/page.tsx b/pkgs/ui/src/app/access-point/page.tsx index b5de9d8..34f08cd 100644 --- a/pkgs/ui/src/app/access-point/page.tsx +++ b/pkgs/ui/src/app/access-point/page.tsx @@ -65,6 +65,7 @@ export default function AccessPoint() { loading={loadingAttachements} data={APAttachementData?.data} configuration={APAttachmentsTableConfig} + tkey="attachment-table" />
@@ -73,6 +74,7 @@ export default function AccessPoint() { loading={laodingRepositories} data={APRepositories?.data} configuration={APServiceRepositoryTableConfig} + tkey="service-repository-table" />
diff --git a/pkgs/ui/src/app/client/[client_name]/page.tsx b/pkgs/ui/src/app/client/[client_name]/page.tsx index 259d016..2637d81 100644 --- a/pkgs/ui/src/app/client/[client_name]/page.tsx +++ b/pkgs/ui/src/app/client/[client_name]/page.tsx @@ -41,7 +41,7 @@ export default function Client({ }); } return []; - }, [services]); + }, [services, entity?.did]); const onRefresh = () => { const entityKey = @@ -52,7 +52,7 @@ export default function Client({ useEffect(() => { const interval = setInterval(() => { onRefresh(); - }, 1000); + }, 5000); return () => clearInterval(interval); // eslint-disable-next-line react-hooks/exhaustive-deps @@ -162,7 +162,7 @@ export default function Client({ loading={services_loading} data={clients} configuration={ClientTableConfig} - key="client-table" + tkey="client-table" />
@@ -171,7 +171,7 @@ export default function Client({ loading={services_loading} data={services?.data?.services} configuration={ServiceTableConfig} - key="service-table" + tkey="service-table" />
diff --git a/pkgs/ui/src/app/home/page.tsx b/pkgs/ui/src/app/home/page.tsx index d405ccf..a99e9c9 100644 --- a/pkgs/ui/src/app/home/page.tsx +++ b/pkgs/ui/src/app/home/page.tsx @@ -24,7 +24,7 @@ export default function Home() { useEffect(() => { const interval = setInterval(() => { onRefresh(); - }, 500); + }, 5000); return () => clearInterval(interval); // eslint-disable-next-line react-hooks/exhaustive-deps @@ -45,6 +45,7 @@ export default function Home() { loading={data.loadingEntities} data={data?.allEntities} configuration={HomeTableConfig} + tkey="home_table" /> diff --git a/pkgs/ui/src/components/table/index.tsx b/pkgs/ui/src/components/table/index.tsx index d0a8b75..425606e 100644 --- a/pkgs/ui/src/components/table/index.tsx +++ b/pkgs/ui/src/components/table/index.tsx @@ -11,7 +11,7 @@ import { StyledTableCell, StyledTableRow } from "./style"; import { ICustomTable, CustomTableConfiguration } from "@/types"; import { Checkbox, Skeleton } from "@mui/material"; -const CustomTable = ({ configuration, data, loading, key }: ICustomTable) => { +const CustomTable = ({ configuration, data, loading, tkey }: ICustomTable) => { if (loading) return ; @@ -25,7 +25,7 @@ const CustomTable = ({ configuration, data, loading, key }: ICustomTable) => { render?: (param: any) => void | undefined, ) => { let renderedValue = value; - console.log(cellKey); + // cover use case if the data is an array if (Array.isArray(value)) renderedValue = value.join(", "); @@ -36,6 +36,7 @@ const CustomTable = ({ configuration, data, loading, key }: ICustomTable) => { // cover use case if we want to render a component if (render) renderedValue = render(value); + console.log("renderTableCell key", cellKey); return ( {renderedValue} @@ -59,7 +60,7 @@ const CustomTable = ({ configuration, data, loading, key }: ICustomTable) => { {configuration.map( (column: CustomTableConfiguration, columnIndex: number) => { const cellValue: any = data[column.key]; - const cellKey = key + ":" + column.key + ":" + rowIndex; + const cellKey = tkey + ":" + column.key + ":" + rowIndex; const renderComponent = column?.render; return renderTableCell( cellValue, diff --git a/pkgs/ui/src/config/client_1/index.tsx b/pkgs/ui/src/config/client_1/index.tsx index 3a1db60..b91cd4e 100644 --- a/pkgs/ui/src/config/client_1/index.tsx +++ b/pkgs/ui/src/config/client_1/index.tsx @@ -71,6 +71,7 @@ export const ServiceTableConfig = [ ))} ); + console.log("render", renderedValue); return renderedValue; }, }, diff --git a/pkgs/ui/src/types/index.ts b/pkgs/ui/src/types/index.ts index 6ac86cc..9a4808b 100644 --- a/pkgs/ui/src/types/index.ts +++ b/pkgs/ui/src/types/index.ts @@ -8,7 +8,7 @@ export interface ICustomTable { configuration: CustomTableConfiguration[]; data: any; loading?: boolean; - key: string; + tkey: string; } export interface EntityDetails { From ab3a6d61285cb4d05262e3cf40b90638f7e4e958 Mon Sep 17 00:00:00 2001 From: ui-asset-bot Date: Sun, 7 Jan 2024 14:26:44 +0000 Subject: [PATCH 39/58] update ui-assets.nix --- pkgs/ui/nix/ui-assets.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/ui/nix/ui-assets.nix b/pkgs/ui/nix/ui-assets.nix index 196aeee..540a756 100644 --- a/pkgs/ui/nix/ui-assets.nix +++ b/pkgs/ui/nix/ui-assets.nix @@ -1,5 +1,5 @@ { fetchzip }: fetchzip { - url = "https://gitea.gchq.icu/api/packages/IoSL/generic/IoSL-service-aware-frontend/15d2rn12jhrwry2ipvjhn62dgl7vvdrkc1zkp02xfvaz8ijf18s8/assets.tar.gz"; - sha256 = "sha256-SKPgZERfbdcFuPMHNnPb+9DXhLFQ7huFzzxDKYLNopU="; + url = "https://gitea.gchq.icu/api/packages/IoSL/generic/IoSL-service-aware-frontend/16rrn5b3w5rjkf0j9zr14jgxc6wx0lg2c7c53xrlixlfnb8lip2b/assets.tar.gz"; + sha256 = "16rrn5b3w5rjkf0j9zr14jgxc6wx0lg2c7c53xrlixlfnb8lip2b"; } From 0fbd24fa1157ca929af94998728a40ca456d4293 Mon Sep 17 00:00:00 2001 From: Georg-Stahn Date: Mon, 8 Jan 2024 16:01:54 +0100 Subject: [PATCH 40/58] add emulate with fastapi --- pkgs/clan-cli/tests/emulate_fastapi.py | 145 +++++++++++++++++++++++++ 1 file changed, 145 insertions(+) create mode 100644 pkgs/clan-cli/tests/emulate_fastapi.py diff --git a/pkgs/clan-cli/tests/emulate_fastapi.py b/pkgs/clan-cli/tests/emulate_fastapi.py new file mode 100644 index 0000000..1ccdab2 --- /dev/null +++ b/pkgs/clan-cli/tests/emulate_fastapi.py @@ -0,0 +1,145 @@ +import uvicorn +from fastapi import FastAPI +from fastapi.responses import HTMLResponse + +app = FastAPI() + +# bash tests: curl localhost:8000/ap_list_of_services + +@app.get("/health") +async def healthcheck() -> str: + return "200 OK" + +@app.get("/consume_service_from_other_entity", response_class=HTMLResponse) +async def consume_service_from_other_entity() -> HTMLResponse: + html_content = """ + + +
+ + + """ + return HTMLResponse(content=html_content, status_code=200) + +@app.get("/ap_list_of_services", response_class=HTMLResponse) +async def ap_list_of_services() -> HTMLResponse: + html_content = b'''HTTP/1.1 200 OK\r\n\r\n[[ + { + "uuid": "8e285c0c-4e40-430a-a477-26b3b81e30df", + "service_name": "Carlos Printing", + "service_type": "3D Printing", + "endpoint_url": "http://127.0.0.1:8000", + "status": "unknown", + "other": { + "action": [ + "register", + "deregister", + "delete", + "create" + ] + }, + "entity_did": "did:sov:test:1234" + }, + { + "uuid": "8e285c0c-4e40-430a-a477-26b3b81e30d1", + "service_name": "Luiss Fax", + "service_type": "Fax", + "endpoint_url": "http://127.0.0.1:8000", + "status": "unknown", + "other": { + "action": [ + "register", + "deregister", + "delete", + "create" + ] + }, + "entity_did": "did:sov:test:1235" + }, + { + "uuid": "8e285c0c-4e40-430a-a477-26b3b81e30d2", + "service_name": "Erdems VR-Stream", + "service_type": "VR-Stream", + "endpoint_url": "http://127.0.0.1:8000", + "status": "unknown", + "other": { + "action": [ + "register", + "deregister", + "delete", + "create" + ] + }, + "entity_did": "did:sov:test:1236" + }, + { + "uuid": "8e285c0c-4e40-430a-a477-26b3b81e30d3", + "service_name": "Onurs gallary", + "service_type": "gallary", + "endpoint_url": "http://127.0.0.1:8000", + "status": "unknown", + "other": { + "action": [ + "register", + "deregister", + "delete", + "create" + ] + }, + "entity_did": "did:sov:test:1237" + }, + { + "uuid": "8e285c0c-4e40-430a-a477-26b3b81e30d4", + "service_name": "Saras Game-Shop", + "service_type": "Game-Shop", + "endpoint_url": "http://127.0.0.1:8000", + "status": "unknown", + "other": { + "action": [ + "register", + "deregister", + "delete", + "create" + ] + }, + "entity_did": "did:sov:test:1238" + } +]]''' + return HTMLResponse(content=html_content, status_code=200) + +@app.get("/dlg_list_of_did_resolutions", response_class=HTMLResponse) +async def dlg_list_of_did_resolutions() -> HTMLResponse: + html_content = b'''HTTP/1.1 200 OK\r\n\r\n +[ + { + "did": "did:sov:test:1234", + "name": "C1", + "ip": "127.0.0.1:5100", + "attached": false, + "visible": true, + "other": { + "network": "Carlo1's Home Network", + "roles": [ + "service repository", + "service consumer" + ] + } + }, + { + "did": "did:sov:test:1235", + "name": "C2", + "ip": "127.0.0.1:5100", + "attached": false, + "visible": true, + "other": { + "network": "Carlo2's Home Network", + "roles": [ + "service repository", + "service prosumer" + ] + } + } +]''' + return HTMLResponse(content=html_content, status_code=200) + +uvicorn.run(app, host="localhost", port=8000) \ No newline at end of file From 2ac57b76a661ea29d059be220d766df7413654f7 Mon Sep 17 00:00:00 2001 From: Georg-Stahn Date: Mon, 8 Jan 2024 16:21:43 +0100 Subject: [PATCH 41/58] formatted emulate script --- pkgs/clan-cli/tests/emulate_fastapi.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/pkgs/clan-cli/tests/emulate_fastapi.py b/pkgs/clan-cli/tests/emulate_fastapi.py index 1ccdab2..27a492f 100644 --- a/pkgs/clan-cli/tests/emulate_fastapi.py +++ b/pkgs/clan-cli/tests/emulate_fastapi.py @@ -6,10 +6,12 @@ app = FastAPI() # bash tests: curl localhost:8000/ap_list_of_services + @app.get("/health") async def healthcheck() -> str: return "200 OK" + @app.get("/consume_service_from_other_entity", response_class=HTMLResponse) async def consume_service_from_other_entity() -> HTMLResponse: html_content = """ @@ -21,9 +23,10 @@ async def consume_service_from_other_entity() -> HTMLResponse: """ return HTMLResponse(content=html_content, status_code=200) + @app.get("/ap_list_of_services", response_class=HTMLResponse) async def ap_list_of_services() -> HTMLResponse: - html_content = b'''HTTP/1.1 200 OK\r\n\r\n[[ + html_content = b"""HTTP/1.1 200 OK\r\n\r\n[[ { "uuid": "8e285c0c-4e40-430a-a477-26b3b81e30df", "service_name": "Carlos Printing", @@ -104,12 +107,13 @@ async def ap_list_of_services() -> HTMLResponse: }, "entity_did": "did:sov:test:1238" } -]]''' +]]""" return HTMLResponse(content=html_content, status_code=200) + @app.get("/dlg_list_of_did_resolutions", response_class=HTMLResponse) async def dlg_list_of_did_resolutions() -> HTMLResponse: - html_content = b'''HTTP/1.1 200 OK\r\n\r\n + html_content = b"""HTTP/1.1 200 OK\r\n\r\n [ { "did": "did:sov:test:1234", @@ -139,7 +143,8 @@ async def dlg_list_of_did_resolutions() -> HTMLResponse: ] } } -]''' +]""" return HTMLResponse(content=html_content, status_code=200) -uvicorn.run(app, host="localhost", port=8000) \ No newline at end of file + +uvicorn.run(app, host="localhost", port=8000) From 1cb81473c33842f5b72e877a03794c3d528bd384 Mon Sep 17 00:00:00 2001 From: Luis-Hebendanz Date: Mon, 8 Jan 2024 18:31:19 +0100 Subject: [PATCH 42/58] Trying to fix attach entity --- pkgs/clan-cli/clan_cli/webui/app.py | 1 - .../clan_cli/webui/routers/endpoints.py | 157 +++++++----- pkgs/clan-cli/clan_cli/webui/schemas.py | 1 + pkgs/clan-cli/clan_cli/webui/sql_app.db | Bin 118784 -> 0 bytes pkgs/clan-cli/clan_cli/webui/sql_crud.py | 27 +- pkgs/clan-cli/clan_cli/webui/sql_models.py | 1 + pkgs/clan-cli/clan_cli/webui/tags.py | 5 - pkgs/clan-cli/emulate_entity.sh | 2 +- .../clan-cli/tests/openapi_client/__init__.py | 1 - .../tests/openapi_client/api/entities_api.py | 64 ++--- .../tests/openapi_client/api/services_api.py | 73 +++--- .../tests/openapi_client/docs/DefaultApi.md | 68 ++--- .../tests/openapi_client/docs/EntitiesApi.md | 240 +++++++++--------- .../tests/openapi_client/docs/Entity.md | 21 +- .../tests/openapi_client/docs/EntityCreate.md | 19 +- .../docs/HTTPValidationError.md | 11 +- .../tests/openapi_client/docs/Machine.md | 13 +- .../openapi_client/docs/RepositoriesApi.md | 34 +-- .../tests/openapi_client/docs/Resolution.md | 21 +- .../openapi_client/docs/ResolutionApi.md | 34 +-- .../tests/openapi_client/docs/Service.md | 25 +- .../openapi_client/docs/ServiceCreate.md | 23 +- .../tests/openapi_client/docs/ServicesApi.md | 172 ++++++------- .../openapi_client/docs/ServicesByName.md | 28 -- .../tests/openapi_client/docs/Status.md | 7 +- .../openapi_client/docs/ValidationError.md | 15 +- .../docs/ValidationErrorLocInner.md | 9 +- .../tests/openapi_client/models/__init__.py | 1 - .../openapi_client/models/services_by_name.py | 85 ------- .../openapi_client/test/test_services_api.py | 6 +- .../test/test_services_by_name.py | 99 -------- pkgs/ui/src/app/access-point/page.tsx | 2 +- pkgs/ui/src/app/client/[client_name]/page.tsx | 202 ++++++++++----- ...tyById.tsx => useGetEntityByNameOrDid.tsx} | 4 +- pkgs/ui/src/components/table/index.tsx | 1 - pkgs/ui/src/config/client_1/index.tsx | 1 - 36 files changed, 695 insertions(+), 778 deletions(-) delete mode 100644 pkgs/clan-cli/clan_cli/webui/sql_app.db delete mode 100644 pkgs/clan-cli/tests/openapi_client/docs/ServicesByName.md delete mode 100644 pkgs/clan-cli/tests/openapi_client/models/services_by_name.py delete mode 100644 pkgs/clan-cli/tests/openapi_client/test/test_services_by_name.py rename pkgs/ui/src/components/hooks/{useGetEntityById.tsx => useGetEntityByNameOrDid.tsx} (80%) diff --git a/pkgs/clan-cli/clan_cli/webui/app.py b/pkgs/clan-cli/clan_cli/webui/app.py index 8913f72..99d7e9e 100644 --- a/pkgs/clan-cli/clan_cli/webui/app.py +++ b/pkgs/clan-cli/clan_cli/webui/app.py @@ -33,7 +33,6 @@ for u in cors_url: # Logging setup log = logging.getLogger(__name__) - @asynccontextmanager async def lifespan(app: FastAPI) -> Any: await socket_manager2.brd.connect() diff --git a/pkgs/clan-cli/clan_cli/webui/routers/endpoints.py b/pkgs/clan-cli/clan_cli/webui/routers/endpoints.py index 4aec32b..9b601aa 100644 --- a/pkgs/clan-cli/clan_cli/webui/routers/endpoints.py +++ b/pkgs/clan-cli/clan_cli/webui/routers/endpoints.py @@ -2,6 +2,7 @@ import logging import time from datetime import datetime from typing import List, Optional +import asyncio import httpx from fastapi import APIRouter, BackgroundTasks, Depends @@ -30,7 +31,7 @@ log = logging.getLogger(__name__) # # ######################### @router.post("/api/v1/service", response_model=Service, tags=[Tags.services]) -async def create_service( +def create_service( service: ServiceCreate, db: Session = Depends(sql_db.get_db) ) -> Service: # todo checken ob schon da ... @@ -38,7 +39,7 @@ async def create_service( @router.get("/api/v1/services", response_model=List[Service], tags=[Tags.services]) -async def get_all_services( +def get_all_services( skip: int = 0, limit: int = 100, db: Session = Depends(sql_db.get_db) ) -> List[sql_models.Service]: services = sql_crud.get_services(db, skip=skip, limit=limit) @@ -46,9 +47,9 @@ async def get_all_services( @router.get( - "/api/v1/{entity_did}/service", response_model=List[Service], tags=[Tags.services] + "/api/v1/service", response_model=List[Service], tags=[Tags.services] ) -async def get_service_by_did( +def get_service_by_did( entity_did: str = "did:sov:test:1234", skip: int = 0, limit: int = 100, @@ -59,25 +60,21 @@ async def get_service_by_did( @router.get( - "/api/v1/services_by_entity_name", - response_model=ServicesByName, + "/api/v1/services_without_entity", + response_model=List[Service], tags=[Tags.services], ) -async def get_services_by_name( - entity_name: str, +def get_services_without_entity( + entity_did: str = "did:sov:test:1234", skip: int = 0, limit: int = 100, db: Session = Depends(sql_db.get_db), -) -> ServicesByName: - entity = sql_crud.get_entity_by_name(db, name=entity_name) - if entity is None: - raise ClanError(f"Entity with name '{entity_name}' not found") - services = sql_crud.get_services_by_entity_did(db, entity_did=str(entity.did)) - return ServicesByName(entity=entity, services=services) # type: ignore +) -> List[sql_models.Service]: + service = sql_crud.get_services_without_entity_id(db, entity_did=entity_did) + return service - -@router.delete("/api/v1/{entity_did}/service", tags=[Tags.services]) -async def delete_service( +@router.delete("/api/v1/service", tags=[Tags.services]) +def delete_service( entity_did: str = "did:sov:test:1234", db: Session = Depends(sql_db.get_db), ) -> dict[str, str]: @@ -95,7 +92,7 @@ async def delete_service( response_model=List[Service], tags=[Tags.repositories], ) -async def get_all_repositories( +def get_all_repositories( skip: int = 0, limit: int = 100, db: Session = Depends(sql_db.get_db) ) -> List[sql_models.Service]: repositories = sql_crud.get_services(db, skip=skip, limit=limit) @@ -108,7 +105,7 @@ async def get_all_repositories( # # ######################### @router.post("/api/v1/entity", response_model=Entity, tags=[Tags.entities]) -async def create_entity( +def create_entity( entity: EntityCreate, db: Session = Depends(sql_db.get_db) ) -> EntityCreate: return sql_crud.create_entity(db, entity) @@ -117,7 +114,7 @@ async def create_entity( @router.get( "/api/v1/entity_by_name", response_model=Optional[Entity], tags=[Tags.entities] ) -async def get_entity_by_name( +def get_entity_by_name( entity_name: str, db: Session = Depends(sql_db.get_db) ) -> Optional[sql_models.Entity]: entity = sql_crud.get_entity_by_name(db, name=entity_name) @@ -125,7 +122,7 @@ async def get_entity_by_name( @router.get("/api/v1/entities", response_model=List[Entity], tags=[Tags.entities]) -async def get_all_entities( +def get_all_entities( skip: int = 0, limit: int = 100, db: Session = Depends(sql_db.get_db) ) -> List[sql_models.Entity]: entities = sql_crud.get_entities(db, skip=skip, limit=limit) @@ -133,9 +130,9 @@ async def get_all_entities( @router.get( - "/api/v1/{entity_did}/entity", response_model=Optional[Entity], tags=[Tags.entities] + "/api/v1/entity", response_model=Optional[Entity], tags=[Tags.entities] ) -async def get_entity_by_did( +def get_entity_by_did( entity_did: str = "did:sov:test:1234", db: Session = Depends(sql_db.get_db), ) -> Optional[sql_models.Entity]: @@ -148,61 +145,103 @@ async def get_entity_by_did( response_model=List[Entity], tags=[Tags.entities], ) -async def get_attached_entities( +def get_attached_entities( skip: int = 0, limit: int = 100, db: Session = Depends(sql_db.get_db) ) -> List[sql_models.Entity]: entities = sql_crud.get_attached_entities(db, skip=skip, limit=limit) return entities - -@router.post("/api/v1/{entity_did}/detach", response_model=Entity, tags=[Tags.entities]) -async def detach_entity( - background_tasks: BackgroundTasks, +@router.get("/api/v1/is_attached", tags=[Tags.entities]) +def is_attached( entity_did: str = "did:sov:test:1234", - skip: int = 0, - limit: int = 100, - db: Session = Depends(sql_db.get_db), -) -> sql_models.Entity: - entity = sql_crud.set_attached_by_entity_did(db, entity_did, False) - return entity + db: Session = Depends(sql_db.get_db)) -> dict[str, str]: + + entity = sql_crud.get_entity_by_did(db, did=entity_did) + + if entity is None: + raise ClanError(f"Entity with did '{entity_did}' not found") + + timer = 0.0 + timeout = 2 + while not entity.attached: + time.sleep(0.1) + + timer += 0.1 + if timer > timeout: + url = f"http://{entity.ip}" + raise ClanError(f"Entity at {url} not reachable") + + return {"message": f"Attached to {entity.name} successfully"} -@router.post("/api/v1/{entity_did}/attach", tags=[Tags.entities]) -async def attach_entity( + +@router.post("/api/v1/detach", tags=[Tags.entities]) +def detach_entity( background_tasks: BackgroundTasks, entity_did: str = "did:sov:test:1234", skip: int = 0, limit: int = 100, db: Session = Depends(sql_db.get_db), ) -> dict[str, str]: - if sql_crud.get_entity_by_did(db, entity_did) is None: - raise ClanError(f"Entity with did '{entity_did}' not found") - - background_tasks.add_task(attach_entity_loc, db, entity_did) - return {"message": "Attaching in the background"} + sql_crud.stop_entity_health_task(db, entity_did) + return {"message": f"Detached {entity_did} successfully"} -def attach_entity_loc(db: Session, entity_did: str) -> None: - db_entity = sql_crud.set_attached_by_entity_did(db, entity_did, True) - try: - while db_entity.attached: - # query status endpoint - # https://www.python-httpx.org/ - response = httpx.get(f"http://{db_entity.ip}", timeout=2) - print(response) - # test with: - # while true ; do printf 'HTTP/1.1 200 OK\r\n\r\ncool, thanks' | nc -l -N localhost 5555 ; done - # client test (apt install python3-httpx): - # httpx http://localhost:5555 - # except not reached set false +@router.post("/api/v1/attach", tags=[Tags.entities]) +def attach_entity( + background_tasks: BackgroundTasks, + entity_did: str = "did:sov:test:1234", + skip: int = 0, + limit: int = 100 +) -> dict[str, str]: + # entity = sql_crud.get_entity_by_did(db, did=entity_did) + # if entity is None: + # raise ClanError(f"Entity with did '{entity_did}' not found") + #url = f"http://{entity.ip}" + #log.info("Start health query at", url) + background_tasks.add_task(attach_entity_loc, entity_did) + return {"message": f"Started attachment task for {entity_did}"} + + +def attach_entity_loc(entity_did: str) -> None: + with sql_db.SessionLocal() as db: + entity = sql_crud.get_entity_by_did(db, did=entity_did) + while entity.stop_health_task is False: + entity = sql_crud.get_entity_by_did(db, did=entity_did) + assert entity is not None + log.warning(f"Stop health status task for {entity.stop_health_task}") time.sleep(1) - except Exception: - log.warning(f"Entity {entity_did} not reachable. Setting attached to false") + # entity = sql_crud.get_entity_by_did(db, did=entity_did) + # assert entity is not None + # try: - db_entity = sql_crud.set_attached_by_entity_did(db, entity_did, False) + # while True: -@router.delete("/api/v1/{entity_did}/entity", tags=[Tags.entities]) + # if entity.stop_health_task: + # print(f"Stop health status task for {entity.name}") + # break + + # url = f"http://{entity.ip}" + # response = httpx.get(url, timeout=2) + # #log.warning(f"Response {response.status_code} from {url}") + # print(f"{entity.name}: stop_health_task: {entity.stop_health_task}") + # if response.status_code != 200: + # raise ClanError(f"Entity with did '{entity_did}' returned {response.status_code}") + + # if entity.attached is False: + # sql_crud.set_attached_by_entity_did(db, entity_did, True) + # if entity is None: + # raise ClanError(f"Entity with did '{entity_did}' has been deleted") + + # time.sleep(1) + # except Exception: + # log.warning(f"Entity {entity_did} not reachable at {url}") + # finally: + # sql_crud.set_attached_by_entity_did(db, entity_did, False) + + +@router.delete("/api/v1/entity", tags=[Tags.entities]) async def delete_entity( entity_did: str = "did:sov:test:1234", db: Session = Depends(sql_db.get_db), @@ -216,8 +255,6 @@ async def delete_entity( # Resolution # # # ######################### - - @router.get( "/api/v1/resolutions", response_model=List[Resolution], tags=[Tags.resolutions] ) diff --git a/pkgs/clan-cli/clan_cli/webui/schemas.py b/pkgs/clan-cli/clan_cli/webui/schemas.py index bdb1a2e..f43e8dd 100644 --- a/pkgs/clan-cli/clan_cli/webui/schemas.py +++ b/pkgs/clan-cli/clan_cli/webui/schemas.py @@ -41,6 +41,7 @@ class EntityCreate(EntityBase): class Entity(EntityCreate): attached: bool = Field(...) + stop_health_task: bool = Field(...) class Config: orm_mode = True diff --git a/pkgs/clan-cli/clan_cli/webui/sql_app.db b/pkgs/clan-cli/clan_cli/webui/sql_app.db deleted file mode 100644 index 6d1f62ff087420f261feba70882b3ede2aef8603..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 118784 zcmWFz^vNtqRY=P(%1ta$FlG>7U}R))P*7lCV5nkXV31`%fKmnq1{MUDff0#~i&@2> zm$!?T{|AE%6E_3DGXHVDgM8V1(!3{l{_s?D|K)Dt7T`R*95EL&MTm`^grGf!jU#%1`ZI8{R+NQO;ZTb?m9GcP5zBC{esIX|zsG&i-VI6gB4 z&X#o!a&-)GRq*t4ag9(wQ>EbVrvO)}ppluP*<>QcE-o+6*kWFin3R(WmxMEFx*8sevS=5ajCS8szHd>>3Qwk(pYopplZ9f}sh;cuiz|FqvWn4Ul^^ zxik%>*~DGt85zJ)QCyglS&|x`SXz<~<|9RnAv_#qY9-mlT~!$yWx;APE8>e%3-XII zOY(~{Q;Xw^Q;W(nlT+jK5_40LC8VIi506e{Nfce6xJ8y!&_Fg*Gh2dP+)|aXkrli3 zC5a`a#mL$v@mma5kHt!`xMqqto4BbeV=Y#@KtYIXlLTIyK&mnA0f}nXis1{<)V!2} z{LH+P_|l>rWb4H7T8FF)(^_O%&00}>*24n7q_O}dLdEb}kE{#RdSqG6rU+qnaaC2u zmSS+uMfM^xTLfw!B>y7IC}?nTmSpCp#wQo0CYGe8D7ZL=xQ2N8x+=K1x;cjWgeYh@ zhXw_?`h~=UM1w;deFMOm29dj9`5%=3KvAL);u;a6VQi*}QXs&b4NBX{g#b((6hz44 z$f1lZUJOoL$Remk4NBPoat_$FB$o?Zn&u*G;@+ybayN1q#v3B@L<@!3#qH%88wFtr zA6|06vnt55a8Y4s z1EO8CkPoMqkP{tTBR_6ykkzAk30X?BNs0$j!7_uhDcoo{gBNNCB!j|*LAettqaoFu zpvV~}8O@LvUo{F3i+DpgldpiAUEEfgv5^;+Mv794^K(i|GV}9_<3Yt)aYmvG~=6s!)a2g6=u zNzEEgc5zo_lr{sxvqh!kz_UNIoQSBl^Giqv3ne*6qKpK zu7-G>lQ`=^y71T!lGbeWWM>ywR%UF91m_(jOOTixQ2QYH2T1~ygK#ua5kUvC2f0Q; z$e^`Y!3M)34JkLm(+Rx#1XYG8RZ(V&CYNR)8=JVcETZua&fB1tUrJ^QjLi=93OuR8 zBtS6?3M?2O(t!12WfRwwWlV)d4@@>bvjE0q!)an>0jhzS1)3o&Y~s4IjJX)*fdUC; zA}dZ4L8?&A1c_)SFtdr9$|Bl=FoWU~OG*-xGg9HcXTfPQOeL!6Fj37$MMidUSy{#= zQE)PWSpcJ%pyomn2uu`|I*_6mrNIJnH*%uLEI{VL>{W2`_xEvi1ov|AG(rh9vcmT(GVC7 zfzc2c4S~@R7!85Z5Eu=C(GVC7fzc2c4FNb9?f=7rVw5o&0;3@?8UmvsFd71*Aut*O zqaiRF0;3@?8UmvsFd72GHUvid|HC$FM?E$g0;3@?8UmvsFd71*Aut*OqaiRF0;3@? z8UmvsFd72z5E#Ax4;~bwjL{Gn4S~@R7!85Z5Eu=C(GVC7fzc2c4S~@R7!85Z5E!;0 zFgpJ~Y@>G6W1}H38UmvsFd71*Aut*OqaiRF0;3@?8UmvsFd71*Apj47(f&U?C`K8h nAut*OqaiRF0;3@?8UmvsFd71*Aut*OqaiRF0;3@?Y(oG5zzy9P diff --git a/pkgs/clan-cli/clan_cli/webui/sql_crud.py b/pkgs/clan-cli/clan_cli/webui/sql_crud.py index f18bc4e..7314f23 100644 --- a/pkgs/clan-cli/clan_cli/webui/sql_crud.py +++ b/pkgs/clan-cli/clan_cli/webui/sql_crud.py @@ -64,7 +64,7 @@ def get_services_without_entity_id( # # ######################### def create_entity(db: Session, entity: schemas.EntityCreate) -> sql_models.Entity: - db_entity = sql_models.Entity(**entity.dict(), attached=False) + db_entity = sql_models.Entity(**entity.dict(), attached=False, stop_health_task=False) db.add(db_entity) db.commit() db.refresh(db_entity) @@ -100,20 +100,35 @@ def get_attached_entities( # Returns same entity if setting didnt changed something -def set_attached_by_entity_did( - db: Session, entity_did: str, value: bool -) -> sql_models.Entity: +def stop_entity_health_task( + db: Session, entity_did: str +) -> None: db_entity = get_entity_by_did(db, entity_did) if db_entity is None: raise ClanError(f"Entity with did '{entity_did}' not found") - setattr(db_entity, "attached", value) + setattr(db_entity, "stop_health_task", True) + + # save changes in db + db.add(db_entity) + db.commit() + db.refresh(db_entity) + + + +def set_attached_by_entity_did( + db: Session, entity_did: str, attached: bool +) -> None: + db_entity = get_entity_by_did(db, entity_did) + if db_entity is None: + raise ClanError(f"Entity with did '{entity_did}' not found") + + setattr(db_entity, "attached", attached) # save changes in db db.add(db_entity) db.commit() db.refresh(db_entity) - return db_entity def delete_entity_by_did(db: Session, did: str) -> None: diff --git a/pkgs/clan-cli/clan_cli/webui/sql_models.py b/pkgs/clan-cli/clan_cli/webui/sql_models.py index b0358ce..792b8cc 100644 --- a/pkgs/clan-cli/clan_cli/webui/sql_models.py +++ b/pkgs/clan-cli/clan_cli/webui/sql_models.py @@ -23,6 +23,7 @@ class Entity(Base): ip = Column(String, index=True) attached = Column(Boolean, index=True) visible = Column(Boolean, index=True) + stop_health_task = Column(Boolean) ## Non queryable body ## # In here we deposit: Network, Roles, Visible, etc. diff --git a/pkgs/clan-cli/clan_cli/webui/tags.py b/pkgs/clan-cli/clan_cli/webui/tags.py index 034beb7..712f09b 100644 --- a/pkgs/clan-cli/clan_cli/webui/tags.py +++ b/pkgs/clan-cli/clan_cli/webui/tags.py @@ -4,7 +4,6 @@ from typing import Any, Dict, List class Tags(Enum): services = "services" - clients = "clients" entities = "entities" repositories = "repositories" resolutions = "resolution" @@ -18,10 +17,6 @@ tags_metadata: List[Dict[str, Any]] = [ "name": str(Tags.services), "description": "Operations on a service.", }, - { - "name": str(Tags.clients), - "description": "Operations on a client.", - }, { "name": str(Tags.entities), "description": "Operations on an entity.", diff --git a/pkgs/clan-cli/emulate_entity.sh b/pkgs/clan-cli/emulate_entity.sh index da91b78..b4fdbc8 100755 --- a/pkgs/clan-cli/emulate_entity.sh +++ b/pkgs/clan-cli/emulate_entity.sh @@ -1,3 +1,3 @@ #!/usr/bin/env bash -while true ; do printf 'HTTP/1.1 200 OK\r\n\r\ncool, thanks' | nc -l -N 127.0.0.1 5555 ; done +while true ; do printf 'HTTP/1.1 200 OK\r\n\r\ncool, thanks' | nc -l -N 127.0.0.1 7002 ; done diff --git a/pkgs/clan-cli/tests/openapi_client/__init__.py b/pkgs/clan-cli/tests/openapi_client/__init__.py index 638483e..8263f8b 100644 --- a/pkgs/clan-cli/tests/openapi_client/__init__.py +++ b/pkgs/clan-cli/tests/openapi_client/__init__.py @@ -42,7 +42,6 @@ from openapi_client.models.machine import Machine from openapi_client.models.resolution import Resolution from openapi_client.models.service import Service from openapi_client.models.service_create import ServiceCreate -from openapi_client.models.services_by_name import ServicesByName from openapi_client.models.status import Status from openapi_client.models.validation_error import ValidationError from openapi_client.models.validation_error_loc_inner import ValidationErrorLocInner diff --git a/pkgs/clan-cli/tests/openapi_client/api/entities_api.py b/pkgs/clan-cli/tests/openapi_client/api/entities_api.py index 51f4345..debd9c3 100644 --- a/pkgs/clan-cli/tests/openapi_client/api/entities_api.py +++ b/pkgs/clan-cli/tests/openapi_client/api/entities_api.py @@ -46,7 +46,7 @@ class EntitiesApi: self.api_client = api_client @validate_arguments - def attach_entity(self, entity_did : StrictStr, skip : Optional[StrictInt] = None, limit : Optional[StrictInt] = None, **kwargs) -> Dict[str, str]: # noqa: E501 + def attach_entity(self, entity_did : Optional[StrictStr] = None, skip : Optional[StrictInt] = None, limit : Optional[StrictInt] = None, **kwargs) -> Dict[str, str]: # noqa: E501 """Attach Entity # noqa: E501 This method makes a synchronous HTTP request by default. To make an @@ -55,7 +55,7 @@ class EntitiesApi: >>> thread = api.attach_entity(entity_did, skip, limit, async_req=True) >>> result = thread.get() - :param entity_did: (required) + :param entity_did: :type entity_did: str :param skip: :type skip: int @@ -79,7 +79,7 @@ class EntitiesApi: return self.attach_entity_with_http_info(entity_did, skip, limit, **kwargs) # noqa: E501 @validate_arguments - def attach_entity_with_http_info(self, entity_did : StrictStr, skip : Optional[StrictInt] = None, limit : Optional[StrictInt] = None, **kwargs) -> ApiResponse: # noqa: E501 + def attach_entity_with_http_info(self, entity_did : Optional[StrictStr] = None, skip : Optional[StrictInt] = None, limit : Optional[StrictInt] = None, **kwargs) -> ApiResponse: # noqa: E501 """Attach Entity # noqa: E501 This method makes a synchronous HTTP request by default. To make an @@ -88,7 +88,7 @@ class EntitiesApi: >>> thread = api.attach_entity_with_http_info(entity_did, skip, limit, async_req=True) >>> result = thread.get() - :param entity_did: (required) + :param entity_did: :type entity_did: str :param skip: :type skip: int @@ -152,12 +152,12 @@ class EntitiesApi: # process the path parameters _path_params = {} - if _params['entity_did']: - _path_params['entity_did'] = _params['entity_did'] - # process the query parameters _query_params = [] + if _params.get('entity_did') is not None: # noqa: E501 + _query_params.append(('entity_did', _params['entity_did'])) + if _params.get('skip') is not None: # noqa: E501 _query_params.append(('skip', _params['skip'])) @@ -184,7 +184,7 @@ class EntitiesApi: } return self.api_client.call_api( - '/api/v1/{entity_did}/attach', 'POST', + '/api/v1/attach', 'POST', _path_params, _query_params, _header_params, @@ -347,7 +347,7 @@ class EntitiesApi: _request_auth=_params.get('_request_auth')) @validate_arguments - def delete_entity(self, entity_did : StrictStr, **kwargs) -> Dict[str, str]: # noqa: E501 + def delete_entity(self, entity_did : Optional[StrictStr] = None, **kwargs) -> Dict[str, str]: # noqa: E501 """Delete Entity # noqa: E501 This method makes a synchronous HTTP request by default. To make an @@ -356,7 +356,7 @@ class EntitiesApi: >>> thread = api.delete_entity(entity_did, async_req=True) >>> result = thread.get() - :param entity_did: (required) + :param entity_did: :type entity_did: str :param async_req: Whether to execute the request asynchronously. :type async_req: bool, optional @@ -376,7 +376,7 @@ class EntitiesApi: return self.delete_entity_with_http_info(entity_did, **kwargs) # noqa: E501 @validate_arguments - def delete_entity_with_http_info(self, entity_did : StrictStr, **kwargs) -> ApiResponse: # noqa: E501 + def delete_entity_with_http_info(self, entity_did : Optional[StrictStr] = None, **kwargs) -> ApiResponse: # noqa: E501 """Delete Entity # noqa: E501 This method makes a synchronous HTTP request by default. To make an @@ -385,7 +385,7 @@ class EntitiesApi: >>> thread = api.delete_entity_with_http_info(entity_did, async_req=True) >>> result = thread.get() - :param entity_did: (required) + :param entity_did: :type entity_did: str :param async_req: Whether to execute the request asynchronously. :type async_req: bool, optional @@ -443,12 +443,12 @@ class EntitiesApi: # process the path parameters _path_params = {} - if _params['entity_did']: - _path_params['entity_did'] = _params['entity_did'] - # process the query parameters _query_params = [] + if _params.get('entity_did') is not None: # noqa: E501 + _query_params.append(('entity_did', _params['entity_did'])) + # process the header parameters _header_params = dict(_params.get('_headers', {})) # process the form parameters @@ -469,7 +469,7 @@ class EntitiesApi: } return self.api_client.call_api( - '/api/v1/{entity_did}/entity', 'DELETE', + '/api/v1/entity', 'DELETE', _path_params, _query_params, _header_params, @@ -486,7 +486,7 @@ class EntitiesApi: _request_auth=_params.get('_request_auth')) @validate_arguments - def detach_entity(self, entity_did : StrictStr, skip : Optional[StrictInt] = None, limit : Optional[StrictInt] = None, **kwargs) -> Entity: # noqa: E501 + def detach_entity(self, entity_did : Optional[StrictStr] = None, skip : Optional[StrictInt] = None, limit : Optional[StrictInt] = None, **kwargs) -> Entity: # noqa: E501 """Detach Entity # noqa: E501 This method makes a synchronous HTTP request by default. To make an @@ -495,7 +495,7 @@ class EntitiesApi: >>> thread = api.detach_entity(entity_did, skip, limit, async_req=True) >>> result = thread.get() - :param entity_did: (required) + :param entity_did: :type entity_did: str :param skip: :type skip: int @@ -519,7 +519,7 @@ class EntitiesApi: return self.detach_entity_with_http_info(entity_did, skip, limit, **kwargs) # noqa: E501 @validate_arguments - def detach_entity_with_http_info(self, entity_did : StrictStr, skip : Optional[StrictInt] = None, limit : Optional[StrictInt] = None, **kwargs) -> ApiResponse: # noqa: E501 + def detach_entity_with_http_info(self, entity_did : Optional[StrictStr] = None, skip : Optional[StrictInt] = None, limit : Optional[StrictInt] = None, **kwargs) -> ApiResponse: # noqa: E501 """Detach Entity # noqa: E501 This method makes a synchronous HTTP request by default. To make an @@ -528,7 +528,7 @@ class EntitiesApi: >>> thread = api.detach_entity_with_http_info(entity_did, skip, limit, async_req=True) >>> result = thread.get() - :param entity_did: (required) + :param entity_did: :type entity_did: str :param skip: :type skip: int @@ -592,12 +592,12 @@ class EntitiesApi: # process the path parameters _path_params = {} - if _params['entity_did']: - _path_params['entity_did'] = _params['entity_did'] - # process the query parameters _query_params = [] + if _params.get('entity_did') is not None: # noqa: E501 + _query_params.append(('entity_did', _params['entity_did'])) + if _params.get('skip') is not None: # noqa: E501 _query_params.append(('skip', _params['skip'])) @@ -624,7 +624,7 @@ class EntitiesApi: } return self.api_client.call_api( - '/api/v1/{entity_did}/detach', 'POST', + '/api/v1/detach', 'POST', _path_params, _query_params, _header_params, @@ -935,7 +935,7 @@ class EntitiesApi: _request_auth=_params.get('_request_auth')) @validate_arguments - def get_entity_by_did(self, entity_did : StrictStr, **kwargs) -> Entity: # noqa: E501 + def get_entity_by_did(self, entity_did : Optional[StrictStr] = None, **kwargs) -> Entity: # noqa: E501 """Get Entity By Did # noqa: E501 This method makes a synchronous HTTP request by default. To make an @@ -944,7 +944,7 @@ class EntitiesApi: >>> thread = api.get_entity_by_did(entity_did, async_req=True) >>> result = thread.get() - :param entity_did: (required) + :param entity_did: :type entity_did: str :param async_req: Whether to execute the request asynchronously. :type async_req: bool, optional @@ -964,7 +964,7 @@ class EntitiesApi: return self.get_entity_by_did_with_http_info(entity_did, **kwargs) # noqa: E501 @validate_arguments - def get_entity_by_did_with_http_info(self, entity_did : StrictStr, **kwargs) -> ApiResponse: # noqa: E501 + def get_entity_by_did_with_http_info(self, entity_did : Optional[StrictStr] = None, **kwargs) -> ApiResponse: # noqa: E501 """Get Entity By Did # noqa: E501 This method makes a synchronous HTTP request by default. To make an @@ -973,7 +973,7 @@ class EntitiesApi: >>> thread = api.get_entity_by_did_with_http_info(entity_did, async_req=True) >>> result = thread.get() - :param entity_did: (required) + :param entity_did: :type entity_did: str :param async_req: Whether to execute the request asynchronously. :type async_req: bool, optional @@ -1031,12 +1031,12 @@ class EntitiesApi: # process the path parameters _path_params = {} - if _params['entity_did']: - _path_params['entity_did'] = _params['entity_did'] - # process the query parameters _query_params = [] + if _params.get('entity_did') is not None: # noqa: E501 + _query_params.append(('entity_did', _params['entity_did'])) + # process the header parameters _header_params = dict(_params.get('_headers', {})) # process the form parameters @@ -1057,7 +1057,7 @@ class EntitiesApi: } return self.api_client.call_api( - '/api/v1/{entity_did}/entity', 'GET', + '/api/v1/entity', 'GET', _path_params, _query_params, _header_params, diff --git a/pkgs/clan-cli/tests/openapi_client/api/services_api.py b/pkgs/clan-cli/tests/openapi_client/api/services_api.py index 4c17330..d8eb462 100644 --- a/pkgs/clan-cli/tests/openapi_client/api/services_api.py +++ b/pkgs/clan-cli/tests/openapi_client/api/services_api.py @@ -24,7 +24,6 @@ from typing import Any, List, Optional, Dict from openapi_client.models.service import Service from openapi_client.models.service_create import ServiceCreate -from openapi_client.models.services_by_name import ServicesByName from openapi_client.api_client import ApiClient from openapi_client.api_response import ApiResponse @@ -193,7 +192,7 @@ class ServicesApi: _request_auth=_params.get('_request_auth')) @validate_arguments - def delete_service(self, entity_did : StrictStr, **kwargs) -> Dict[str, str]: # noqa: E501 + def delete_service(self, entity_did : Optional[StrictStr] = None, **kwargs) -> Dict[str, str]: # noqa: E501 """Delete Service # noqa: E501 This method makes a synchronous HTTP request by default. To make an @@ -202,7 +201,7 @@ class ServicesApi: >>> thread = api.delete_service(entity_did, async_req=True) >>> result = thread.get() - :param entity_did: (required) + :param entity_did: :type entity_did: str :param async_req: Whether to execute the request asynchronously. :type async_req: bool, optional @@ -222,7 +221,7 @@ class ServicesApi: return self.delete_service_with_http_info(entity_did, **kwargs) # noqa: E501 @validate_arguments - def delete_service_with_http_info(self, entity_did : StrictStr, **kwargs) -> ApiResponse: # noqa: E501 + def delete_service_with_http_info(self, entity_did : Optional[StrictStr] = None, **kwargs) -> ApiResponse: # noqa: E501 """Delete Service # noqa: E501 This method makes a synchronous HTTP request by default. To make an @@ -231,7 +230,7 @@ class ServicesApi: >>> thread = api.delete_service_with_http_info(entity_did, async_req=True) >>> result = thread.get() - :param entity_did: (required) + :param entity_did: :type entity_did: str :param async_req: Whether to execute the request asynchronously. :type async_req: bool, optional @@ -289,12 +288,12 @@ class ServicesApi: # process the path parameters _path_params = {} - if _params['entity_did']: - _path_params['entity_did'] = _params['entity_did'] - # process the query parameters _query_params = [] + if _params.get('entity_did') is not None: # noqa: E501 + _query_params.append(('entity_did', _params['entity_did'])) + # process the header parameters _header_params = dict(_params.get('_headers', {})) # process the form parameters @@ -315,7 +314,7 @@ class ServicesApi: } return self.api_client.call_api( - '/api/v1/{entity_did}/service', 'DELETE', + '/api/v1/service', 'DELETE', _path_params, _query_params, _header_params, @@ -479,7 +478,7 @@ class ServicesApi: _request_auth=_params.get('_request_auth')) @validate_arguments - def get_service_by_did(self, entity_did : StrictStr, skip : Optional[StrictInt] = None, limit : Optional[StrictInt] = None, **kwargs) -> List[Service]: # noqa: E501 + def get_service_by_did(self, entity_did : Optional[StrictStr] = None, skip : Optional[StrictInt] = None, limit : Optional[StrictInt] = None, **kwargs) -> List[Service]: # noqa: E501 """Get Service By Did # noqa: E501 This method makes a synchronous HTTP request by default. To make an @@ -488,7 +487,7 @@ class ServicesApi: >>> thread = api.get_service_by_did(entity_did, skip, limit, async_req=True) >>> result = thread.get() - :param entity_did: (required) + :param entity_did: :type entity_did: str :param skip: :type skip: int @@ -512,7 +511,7 @@ class ServicesApi: return self.get_service_by_did_with_http_info(entity_did, skip, limit, **kwargs) # noqa: E501 @validate_arguments - def get_service_by_did_with_http_info(self, entity_did : StrictStr, skip : Optional[StrictInt] = None, limit : Optional[StrictInt] = None, **kwargs) -> ApiResponse: # noqa: E501 + def get_service_by_did_with_http_info(self, entity_did : Optional[StrictStr] = None, skip : Optional[StrictInt] = None, limit : Optional[StrictInt] = None, **kwargs) -> ApiResponse: # noqa: E501 """Get Service By Did # noqa: E501 This method makes a synchronous HTTP request by default. To make an @@ -521,7 +520,7 @@ class ServicesApi: >>> thread = api.get_service_by_did_with_http_info(entity_did, skip, limit, async_req=True) >>> result = thread.get() - :param entity_did: (required) + :param entity_did: :type entity_did: str :param skip: :type skip: int @@ -585,12 +584,12 @@ class ServicesApi: # process the path parameters _path_params = {} - if _params['entity_did']: - _path_params['entity_did'] = _params['entity_did'] - # process the query parameters _query_params = [] + if _params.get('entity_did') is not None: # noqa: E501 + _query_params.append(('entity_did', _params['entity_did'])) + if _params.get('skip') is not None: # noqa: E501 _query_params.append(('skip', _params['skip'])) @@ -617,7 +616,7 @@ class ServicesApi: } return self.api_client.call_api( - '/api/v1/{entity_did}/service', 'GET', + '/api/v1/service', 'GET', _path_params, _query_params, _header_params, @@ -634,17 +633,17 @@ class ServicesApi: _request_auth=_params.get('_request_auth')) @validate_arguments - def get_services_by_name(self, entity_name : StrictStr, skip : Optional[StrictInt] = None, limit : Optional[StrictInt] = None, **kwargs) -> ServicesByName: # noqa: E501 - """Get Services By Name # noqa: E501 + def get_services_without_entity(self, entity_did : Optional[StrictStr] = None, skip : Optional[StrictInt] = None, limit : Optional[StrictInt] = None, **kwargs) -> List[Service]: # noqa: E501 + """Get Services Without Entity # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.get_services_by_name(entity_name, skip, limit, async_req=True) + >>> thread = api.get_services_without_entity(entity_did, skip, limit, async_req=True) >>> result = thread.get() - :param entity_name: (required) - :type entity_name: str + :param entity_did: + :type entity_did: str :param skip: :type skip: int :param limit: @@ -658,26 +657,26 @@ class ServicesApi: :return: Returns the result object. If the method is called asynchronously, returns the request thread. - :rtype: ServicesByName + :rtype: List[Service] """ kwargs['_return_http_data_only'] = True if '_preload_content' in kwargs: - message = "Error! Please call the get_services_by_name_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data" # noqa: E501 + message = "Error! Please call the get_services_without_entity_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data" # noqa: E501 raise ValueError(message) - return self.get_services_by_name_with_http_info(entity_name, skip, limit, **kwargs) # noqa: E501 + return self.get_services_without_entity_with_http_info(entity_did, skip, limit, **kwargs) # noqa: E501 @validate_arguments - def get_services_by_name_with_http_info(self, entity_name : StrictStr, skip : Optional[StrictInt] = None, limit : Optional[StrictInt] = None, **kwargs) -> ApiResponse: # noqa: E501 - """Get Services By Name # noqa: E501 + def get_services_without_entity_with_http_info(self, entity_did : Optional[StrictStr] = None, skip : Optional[StrictInt] = None, limit : Optional[StrictInt] = None, **kwargs) -> ApiResponse: # noqa: E501 + """Get Services Without Entity # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.get_services_by_name_with_http_info(entity_name, skip, limit, async_req=True) + >>> thread = api.get_services_without_entity_with_http_info(entity_did, skip, limit, async_req=True) >>> result = thread.get() - :param entity_name: (required) - :type entity_name: str + :param entity_did: + :type entity_did: str :param skip: :type skip: int :param limit: @@ -704,13 +703,13 @@ class ServicesApi: :return: Returns the result object. If the method is called asynchronously, returns the request thread. - :rtype: tuple(ServicesByName, status_code(int), headers(HTTPHeaderDict)) + :rtype: tuple(List[Service], status_code(int), headers(HTTPHeaderDict)) """ _params = locals() _all_params = [ - 'entity_name', + 'entity_did', 'skip', 'limit' ] @@ -731,7 +730,7 @@ class ServicesApi: if _key not in _all_params: raise ApiTypeError( "Got an unexpected keyword argument '%s'" - " to method get_services_by_name" % _key + " to method get_services_without_entity" % _key ) _params[_key] = _val del _params['kwargs'] @@ -743,8 +742,8 @@ class ServicesApi: # process the query parameters _query_params = [] - if _params.get('entity_name') is not None: # noqa: E501 - _query_params.append(('entity_name', _params['entity_name'])) + if _params.get('entity_did') is not None: # noqa: E501 + _query_params.append(('entity_did', _params['entity_did'])) if _params.get('skip') is not None: # noqa: E501 _query_params.append(('skip', _params['skip'])) @@ -767,12 +766,12 @@ class ServicesApi: _auth_settings = [] # noqa: E501 _response_types_map = { - '200': "ServicesByName", + '200': "List[Service]", '422': "HTTPValidationError", } return self.api_client.call_api( - '/api/v1/services_by_entity_name', 'GET', + '/api/v1/services_without_entity', 'GET', _path_params, _query_params, _header_params, diff --git a/pkgs/clan-cli/tests/openapi_client/docs/DefaultApi.md b/pkgs/clan-cli/tests/openapi_client/docs/DefaultApi.md index aef64f7..9a4a45c 100644 --- a/pkgs/clan-cli/tests/openapi_client/docs/DefaultApi.md +++ b/pkgs/clan-cli/tests/openapi_client/docs/DefaultApi.md @@ -1,15 +1,15 @@ # openapi_client.DefaultApi -All URIs are relative to _http://localhost_ +All URIs are relative to *http://localhost* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**get**](DefaultApi.md#get) | **GET** /ws2_example | Get +[**health**](DefaultApi.md#health) | **GET** /health | Health +[**root**](DefaultApi.md#root) | **GET** /{path_name} | Root -| Method | HTTP request | Description | -| ---------------------------------- | -------------------- | ----------- | -| [**get**](DefaultApi.md#get) | **GET** /ws2_example | Get | -| [**health**](DefaultApi.md#health) | **GET** /health | Health | -| [**root**](DefaultApi.md#root) | **GET** /{path_name} | Root | # **get** - > get() Get @@ -42,8 +42,9 @@ with openapi_client.ApiClient(configuration) as api_client: print("Exception when calling DefaultApi->get: %s\n" % e) ``` -### Parameters + +### Parameters This endpoint does not need any parameter. ### Return type @@ -56,19 +57,17 @@ No authorization required ### HTTP request headers -- **Content-Type**: Not defined -- **Accept**: application/json + - **Content-Type**: Not defined + - **Accept**: application/json ### HTTP response details - -| Status code | Description | Response headers | -| ----------- | ------------------- | ---------------- | -| **200** | Successful Response | - | +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | Successful Response | - | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **health** - > Machine health() Health @@ -104,8 +103,9 @@ with openapi_client.ApiClient(configuration) as api_client: print("Exception when calling DefaultApi->health: %s\n" % e) ``` -### Parameters + +### Parameters This endpoint does not need any parameter. ### Return type @@ -118,19 +118,17 @@ No authorization required ### HTTP request headers -- **Content-Type**: Not defined -- **Accept**: application/json + - **Content-Type**: Not defined + - **Accept**: application/json ### HTTP response details - -| Status code | Description | Response headers | -| ----------- | ------------------- | ---------------- | -| **200** | Successful Response | - | +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | Successful Response | - | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **root** - > root(path_name) Root @@ -155,7 +153,7 @@ configuration = openapi_client.Configuration( with openapi_client.ApiClient(configuration) as api_client: # Create an instance of the API class api_instance = openapi_client.DefaultApi(api_client) - path_name = 'path_name_example' # str | + path_name = 'path_name_example' # str | try: # Root @@ -164,11 +162,13 @@ with openapi_client.ApiClient(configuration) as api_client: print("Exception when calling DefaultApi->root: %s\n" % e) ``` + + ### Parameters -| Name | Type | Description | Notes | -| ------------- | ------- | ----------- | ----- | -| **path_name** | **str** | | +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **path_name** | **str**| | ### Return type @@ -180,14 +180,14 @@ No authorization required ### HTTP request headers -- **Content-Type**: Not defined -- **Accept**: application/json + - **Content-Type**: Not defined + - **Accept**: application/json ### HTTP response details - -| Status code | Description | Response headers | -| ----------- | ------------------- | ---------------- | -| **200** | Successful Response | - | -| **422** | Validation Error | - | +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | Successful Response | - | +**422** | Validation Error | - | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + diff --git a/pkgs/clan-cli/tests/openapi_client/docs/EntitiesApi.md b/pkgs/clan-cli/tests/openapi_client/docs/EntitiesApi.md index 86785f9..2264f33 100644 --- a/pkgs/clan-cli/tests/openapi_client/docs/EntitiesApi.md +++ b/pkgs/clan-cli/tests/openapi_client/docs/EntitiesApi.md @@ -1,21 +1,21 @@ # openapi_client.EntitiesApi -All URIs are relative to _http://localhost_ +All URIs are relative to *http://localhost* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**attach_entity**](EntitiesApi.md#attach_entity) | **POST** /api/v1/attach | Attach Entity +[**create_entity**](EntitiesApi.md#create_entity) | **POST** /api/v1/entity | Create Entity +[**delete_entity**](EntitiesApi.md#delete_entity) | **DELETE** /api/v1/entity | Delete Entity +[**detach_entity**](EntitiesApi.md#detach_entity) | **POST** /api/v1/detach | Detach Entity +[**get_all_entities**](EntitiesApi.md#get_all_entities) | **GET** /api/v1/entities | Get All Entities +[**get_attached_entities**](EntitiesApi.md#get_attached_entities) | **GET** /api/v1/attached_entities | Get Attached Entities +[**get_entity_by_did**](EntitiesApi.md#get_entity_by_did) | **GET** /api/v1/entity | Get Entity By Did +[**get_entity_by_name**](EntitiesApi.md#get_entity_by_name) | **GET** /api/v1/entity_by_name | Get Entity By Name -| Method | HTTP request | Description | -| ----------------------------------------------------------------- | -------------------------------------- | --------------------- | -| [**attach_entity**](EntitiesApi.md#attach_entity) | **POST** /api/v1/{entity_did}/attach | Attach Entity | -| [**create_entity**](EntitiesApi.md#create_entity) | **POST** /api/v1/entity | Create Entity | -| [**delete_entity**](EntitiesApi.md#delete_entity) | **DELETE** /api/v1/{entity_did}/entity | Delete Entity | -| [**detach_entity**](EntitiesApi.md#detach_entity) | **POST** /api/v1/{entity_did}/detach | Detach Entity | -| [**get_all_entities**](EntitiesApi.md#get_all_entities) | **GET** /api/v1/entities | Get All Entities | -| [**get_attached_entities**](EntitiesApi.md#get_attached_entities) | **GET** /api/v1/attached_entities | Get Attached Entities | -| [**get_entity_by_did**](EntitiesApi.md#get_entity_by_did) | **GET** /api/v1/{entity_did}/entity | Get Entity By Did | -| [**get_entity_by_name**](EntitiesApi.md#get_entity_by_name) | **GET** /api/v1/entity_by_name | Get Entity By Name | # **attach_entity** - -> Dict[str, str] attach_entity(entity_did, skip=skip, limit=limit) +> Dict[str, str] attach_entity(entity_did=entity_did, skip=skip, limit=limit) Attach Entity @@ -39,26 +39,28 @@ configuration = openapi_client.Configuration( with openapi_client.ApiClient(configuration) as api_client: # Create an instance of the API class api_instance = openapi_client.EntitiesApi(api_client) - entity_did = 'entity_did_example' # str | + entity_did = 'did:sov:test:1234' # str | (optional) (default to 'did:sov:test:1234') skip = 0 # int | (optional) (default to 0) limit = 100 # int | (optional) (default to 100) try: # Attach Entity - api_response = api_instance.attach_entity(entity_did, skip=skip, limit=limit) + api_response = api_instance.attach_entity(entity_did=entity_did, skip=skip, limit=limit) print("The response of EntitiesApi->attach_entity:\n") pprint(api_response) except Exception as e: print("Exception when calling EntitiesApi->attach_entity: %s\n" % e) ``` + + ### Parameters -| Name | Type | Description | Notes | -| -------------- | ------- | ----------- | --------------------------- | -| **entity_did** | **str** | | -| **skip** | **int** | | [optional] [default to 0] | -| **limit** | **int** | | [optional] [default to 100] | +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **entity_did** | **str**| | [optional] [default to 'did:sov:test:1234'] + **skip** | **int**| | [optional] [default to 0] + **limit** | **int**| | [optional] [default to 100] ### Return type @@ -70,20 +72,18 @@ No authorization required ### HTTP request headers -- **Content-Type**: Not defined -- **Accept**: application/json + - **Content-Type**: Not defined + - **Accept**: application/json ### HTTP response details - -| Status code | Description | Response headers | -| ----------- | ------------------- | ---------------- | -| **200** | Successful Response | - | -| **422** | Validation Error | - | +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | Successful Response | - | +**422** | Validation Error | - | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **create_entity** - > Entity create_entity(entity_create) Create Entity @@ -110,7 +110,7 @@ configuration = openapi_client.Configuration( with openapi_client.ApiClient(configuration) as api_client: # Create an instance of the API class api_instance = openapi_client.EntitiesApi(api_client) - entity_create = openapi_client.EntityCreate() # EntityCreate | + entity_create = openapi_client.EntityCreate() # EntityCreate | try: # Create Entity @@ -121,11 +121,13 @@ with openapi_client.ApiClient(configuration) as api_client: print("Exception when calling EntitiesApi->create_entity: %s\n" % e) ``` + + ### Parameters -| Name | Type | Description | Notes | -| ----------------- | ----------------------------------- | ----------- | ----- | -| **entity_create** | [**EntityCreate**](EntityCreate.md) | | +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **entity_create** | [**EntityCreate**](EntityCreate.md)| | ### Return type @@ -137,21 +139,19 @@ No authorization required ### HTTP request headers -- **Content-Type**: application/json -- **Accept**: application/json + - **Content-Type**: application/json + - **Accept**: application/json ### HTTP response details - -| Status code | Description | Response headers | -| ----------- | ------------------- | ---------------- | -| **200** | Successful Response | - | -| **422** | Validation Error | - | +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | Successful Response | - | +**422** | Validation Error | - | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **delete_entity** - -> Dict[str, str] delete_entity(entity_did) +> Dict[str, str] delete_entity(entity_did=entity_did) Delete Entity @@ -175,22 +175,24 @@ configuration = openapi_client.Configuration( with openapi_client.ApiClient(configuration) as api_client: # Create an instance of the API class api_instance = openapi_client.EntitiesApi(api_client) - entity_did = 'entity_did_example' # str | + entity_did = 'did:sov:test:1234' # str | (optional) (default to 'did:sov:test:1234') try: # Delete Entity - api_response = api_instance.delete_entity(entity_did) + api_response = api_instance.delete_entity(entity_did=entity_did) print("The response of EntitiesApi->delete_entity:\n") pprint(api_response) except Exception as e: print("Exception when calling EntitiesApi->delete_entity: %s\n" % e) ``` + + ### Parameters -| Name | Type | Description | Notes | -| -------------- | ------- | ----------- | ----- | -| **entity_did** | **str** | | +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **entity_did** | **str**| | [optional] [default to 'did:sov:test:1234'] ### Return type @@ -202,21 +204,19 @@ No authorization required ### HTTP request headers -- **Content-Type**: Not defined -- **Accept**: application/json + - **Content-Type**: Not defined + - **Accept**: application/json ### HTTP response details - -| Status code | Description | Response headers | -| ----------- | ------------------- | ---------------- | -| **200** | Successful Response | - | -| **422** | Validation Error | - | +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | Successful Response | - | +**422** | Validation Error | - | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **detach_entity** - -> Entity detach_entity(entity_did, skip=skip, limit=limit) +> Entity detach_entity(entity_did=entity_did, skip=skip, limit=limit) Detach Entity @@ -241,26 +241,28 @@ configuration = openapi_client.Configuration( with openapi_client.ApiClient(configuration) as api_client: # Create an instance of the API class api_instance = openapi_client.EntitiesApi(api_client) - entity_did = 'entity_did_example' # str | + entity_did = 'did:sov:test:1234' # str | (optional) (default to 'did:sov:test:1234') skip = 0 # int | (optional) (default to 0) limit = 100 # int | (optional) (default to 100) try: # Detach Entity - api_response = api_instance.detach_entity(entity_did, skip=skip, limit=limit) + api_response = api_instance.detach_entity(entity_did=entity_did, skip=skip, limit=limit) print("The response of EntitiesApi->detach_entity:\n") pprint(api_response) except Exception as e: print("Exception when calling EntitiesApi->detach_entity: %s\n" % e) ``` + + ### Parameters -| Name | Type | Description | Notes | -| -------------- | ------- | ----------- | --------------------------- | -| **entity_did** | **str** | | -| **skip** | **int** | | [optional] [default to 0] | -| **limit** | **int** | | [optional] [default to 100] | +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **entity_did** | **str**| | [optional] [default to 'did:sov:test:1234'] + **skip** | **int**| | [optional] [default to 0] + **limit** | **int**| | [optional] [default to 100] ### Return type @@ -272,20 +274,18 @@ No authorization required ### HTTP request headers -- **Content-Type**: Not defined -- **Accept**: application/json + - **Content-Type**: Not defined + - **Accept**: application/json ### HTTP response details - -| Status code | Description | Response headers | -| ----------- | ------------------- | ---------------- | -| **200** | Successful Response | - | -| **422** | Validation Error | - | +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | Successful Response | - | +**422** | Validation Error | - | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **get_all_entities** - > List[Entity] get_all_entities(skip=skip, limit=limit) Get All Entities @@ -323,12 +323,14 @@ with openapi_client.ApiClient(configuration) as api_client: print("Exception when calling EntitiesApi->get_all_entities: %s\n" % e) ``` + + ### Parameters -| Name | Type | Description | Notes | -| --------- | ------- | ----------- | --------------------------- | -| **skip** | **int** | | [optional] [default to 0] | -| **limit** | **int** | | [optional] [default to 100] | +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **skip** | **int**| | [optional] [default to 0] + **limit** | **int**| | [optional] [default to 100] ### Return type @@ -340,20 +342,18 @@ No authorization required ### HTTP request headers -- **Content-Type**: Not defined -- **Accept**: application/json + - **Content-Type**: Not defined + - **Accept**: application/json ### HTTP response details - -| Status code | Description | Response headers | -| ----------- | ------------------- | ---------------- | -| **200** | Successful Response | - | -| **422** | Validation Error | - | +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | Successful Response | - | +**422** | Validation Error | - | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **get_attached_entities** - > List[Entity] get_attached_entities(skip=skip, limit=limit) Get Attached Entities @@ -391,12 +391,14 @@ with openapi_client.ApiClient(configuration) as api_client: print("Exception when calling EntitiesApi->get_attached_entities: %s\n" % e) ``` + + ### Parameters -| Name | Type | Description | Notes | -| --------- | ------- | ----------- | --------------------------- | -| **skip** | **int** | | [optional] [default to 0] | -| **limit** | **int** | | [optional] [default to 100] | +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **skip** | **int**| | [optional] [default to 0] + **limit** | **int**| | [optional] [default to 100] ### Return type @@ -408,21 +410,19 @@ No authorization required ### HTTP request headers -- **Content-Type**: Not defined -- **Accept**: application/json + - **Content-Type**: Not defined + - **Accept**: application/json ### HTTP response details - -| Status code | Description | Response headers | -| ----------- | ------------------- | ---------------- | -| **200** | Successful Response | - | -| **422** | Validation Error | - | +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | Successful Response | - | +**422** | Validation Error | - | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **get_entity_by_did** - -> Entity get_entity_by_did(entity_did) +> Entity get_entity_by_did(entity_did=entity_did) Get Entity By Did @@ -447,22 +447,24 @@ configuration = openapi_client.Configuration( with openapi_client.ApiClient(configuration) as api_client: # Create an instance of the API class api_instance = openapi_client.EntitiesApi(api_client) - entity_did = 'entity_did_example' # str | + entity_did = 'did:sov:test:1234' # str | (optional) (default to 'did:sov:test:1234') try: # Get Entity By Did - api_response = api_instance.get_entity_by_did(entity_did) + api_response = api_instance.get_entity_by_did(entity_did=entity_did) print("The response of EntitiesApi->get_entity_by_did:\n") pprint(api_response) except Exception as e: print("Exception when calling EntitiesApi->get_entity_by_did: %s\n" % e) ``` + + ### Parameters -| Name | Type | Description | Notes | -| -------------- | ------- | ----------- | ----- | -| **entity_did** | **str** | | +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **entity_did** | **str**| | [optional] [default to 'did:sov:test:1234'] ### Return type @@ -474,20 +476,18 @@ No authorization required ### HTTP request headers -- **Content-Type**: Not defined -- **Accept**: application/json + - **Content-Type**: Not defined + - **Accept**: application/json ### HTTP response details - -| Status code | Description | Response headers | -| ----------- | ------------------- | ---------------- | -| **200** | Successful Response | - | -| **422** | Validation Error | - | +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | Successful Response | - | +**422** | Validation Error | - | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **get_entity_by_name** - > Entity get_entity_by_name(entity_name) Get Entity By Name @@ -513,7 +513,7 @@ configuration = openapi_client.Configuration( with openapi_client.ApiClient(configuration) as api_client: # Create an instance of the API class api_instance = openapi_client.EntitiesApi(api_client) - entity_name = 'entity_name_example' # str | + entity_name = 'entity_name_example' # str | try: # Get Entity By Name @@ -524,11 +524,13 @@ with openapi_client.ApiClient(configuration) as api_client: print("Exception when calling EntitiesApi->get_entity_by_name: %s\n" % e) ``` + + ### Parameters -| Name | Type | Description | Notes | -| --------------- | ------- | ----------- | ----- | -| **entity_name** | **str** | | +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **entity_name** | **str**| | ### Return type @@ -540,14 +542,14 @@ No authorization required ### HTTP request headers -- **Content-Type**: Not defined -- **Accept**: application/json + - **Content-Type**: Not defined + - **Accept**: application/json ### HTTP response details - -| Status code | Description | Response headers | -| ----------- | ------------------- | ---------------- | -| **200** | Successful Response | - | -| **422** | Validation Error | - | +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | Successful Response | - | +**422** | Validation Error | - | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + diff --git a/pkgs/clan-cli/tests/openapi_client/docs/Entity.md b/pkgs/clan-cli/tests/openapi_client/docs/Entity.md index fc0e2d7..18c6174 100644 --- a/pkgs/clan-cli/tests/openapi_client/docs/Entity.md +++ b/pkgs/clan-cli/tests/openapi_client/docs/Entity.md @@ -1,15 +1,15 @@ # Entity -## Properties -| Name | Type | Description | Notes | -| ------------ | ---------- | ----------- | ----- | -| **did** | **str** | | -| **name** | **str** | | -| **ip** | **str** | | -| **visible** | **bool** | | -| **other** | **object** | | -| **attached** | **bool** | | +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**did** | **str** | | +**name** | **str** | | +**ip** | **str** | | +**visible** | **bool** | | +**other** | **object** | | +**attached** | **bool** | | ## Example @@ -28,5 +28,6 @@ entity_dict = entity_instance.to_dict() # create an instance of Entity from a dict entity_form_dict = entity.from_dict(entity_dict) ``` - [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/pkgs/clan-cli/tests/openapi_client/docs/EntityCreate.md b/pkgs/clan-cli/tests/openapi_client/docs/EntityCreate.md index 4fff16a..7cd1831 100644 --- a/pkgs/clan-cli/tests/openapi_client/docs/EntityCreate.md +++ b/pkgs/clan-cli/tests/openapi_client/docs/EntityCreate.md @@ -1,14 +1,14 @@ # EntityCreate -## Properties -| Name | Type | Description | Notes | -| ----------- | ---------- | ----------- | ----- | -| **did** | **str** | | -| **name** | **str** | | -| **ip** | **str** | | -| **visible** | **bool** | | -| **other** | **object** | | +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**did** | **str** | | +**name** | **str** | | +**ip** | **str** | | +**visible** | **bool** | | +**other** | **object** | | ## Example @@ -27,5 +27,6 @@ entity_create_dict = entity_create_instance.to_dict() # create an instance of EntityCreate from a dict entity_create_form_dict = entity_create.from_dict(entity_create_dict) ``` - [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/pkgs/clan-cli/tests/openapi_client/docs/HTTPValidationError.md b/pkgs/clan-cli/tests/openapi_client/docs/HTTPValidationError.md index d4902e7..5eee49b 100644 --- a/pkgs/clan-cli/tests/openapi_client/docs/HTTPValidationError.md +++ b/pkgs/clan-cli/tests/openapi_client/docs/HTTPValidationError.md @@ -1,10 +1,10 @@ # HTTPValidationError -## Properties -| Name | Type | Description | Notes | -| ---------- | ----------------------------------------------- | ----------- | ---------- | -| **detail** | [**List[ValidationError]**](ValidationError.md) | | [optional] | +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**detail** | [**List[ValidationError]**](ValidationError.md) | | [optional] ## Example @@ -23,5 +23,6 @@ http_validation_error_dict = http_validation_error_instance.to_dict() # create an instance of HTTPValidationError from a dict http_validation_error_form_dict = http_validation_error.from_dict(http_validation_error_dict) ``` - [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/pkgs/clan-cli/tests/openapi_client/docs/Machine.md b/pkgs/clan-cli/tests/openapi_client/docs/Machine.md index 062fd51..4ea6dc3 100644 --- a/pkgs/clan-cli/tests/openapi_client/docs/Machine.md +++ b/pkgs/clan-cli/tests/openapi_client/docs/Machine.md @@ -1,11 +1,11 @@ # Machine -## Properties -| Name | Type | Description | Notes | -| ---------- | ----------------------- | ----------- | ----- | -| **name** | **str** | | -| **status** | [**Status**](Status.md) | | +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**name** | **str** | | +**status** | [**Status**](Status.md) | | ## Example @@ -24,5 +24,6 @@ machine_dict = machine_instance.to_dict() # create an instance of Machine from a dict machine_form_dict = machine.from_dict(machine_dict) ``` - [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/pkgs/clan-cli/tests/openapi_client/docs/RepositoriesApi.md b/pkgs/clan-cli/tests/openapi_client/docs/RepositoriesApi.md index ff735f0..7a24ab0 100644 --- a/pkgs/clan-cli/tests/openapi_client/docs/RepositoriesApi.md +++ b/pkgs/clan-cli/tests/openapi_client/docs/RepositoriesApi.md @@ -1,13 +1,13 @@ # openapi_client.RepositoriesApi -All URIs are relative to _http://localhost_ +All URIs are relative to *http://localhost* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**get_all_repositories**](RepositoriesApi.md#get_all_repositories) | **GET** /api/v1/repositories | Get All Repositories -| Method | HTTP request | Description | -| ------------------------------------------------------------------- | ---------------------------- | -------------------- | -| [**get_all_repositories**](RepositoriesApi.md#get_all_repositories) | **GET** /api/v1/repositories | Get All Repositories | # **get_all_repositories** - > List[Service] get_all_repositories(skip=skip, limit=limit) Get All Repositories @@ -45,12 +45,14 @@ with openapi_client.ApiClient(configuration) as api_client: print("Exception when calling RepositoriesApi->get_all_repositories: %s\n" % e) ``` + + ### Parameters -| Name | Type | Description | Notes | -| --------- | ------- | ----------- | --------------------------- | -| **skip** | **int** | | [optional] [default to 0] | -| **limit** | **int** | | [optional] [default to 100] | +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **skip** | **int**| | [optional] [default to 0] + **limit** | **int**| | [optional] [default to 100] ### Return type @@ -62,14 +64,14 @@ No authorization required ### HTTP request headers -- **Content-Type**: Not defined -- **Accept**: application/json + - **Content-Type**: Not defined + - **Accept**: application/json ### HTTP response details - -| Status code | Description | Response headers | -| ----------- | ------------------- | ---------------- | -| **200** | Successful Response | - | -| **422** | Validation Error | - | +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | Successful Response | - | +**422** | Validation Error | - | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + diff --git a/pkgs/clan-cli/tests/openapi_client/docs/Resolution.md b/pkgs/clan-cli/tests/openapi_client/docs/Resolution.md index 27928d5..27a3992 100644 --- a/pkgs/clan-cli/tests/openapi_client/docs/Resolution.md +++ b/pkgs/clan-cli/tests/openapi_client/docs/Resolution.md @@ -1,15 +1,15 @@ # Resolution -## Properties -| Name | Type | Description | Notes | -| ------------------ | ------------ | ----------- | ----- | -| **requester_name** | **str** | | -| **requester_did** | **str** | | -| **resolved_did** | **str** | | -| **other** | **object** | | -| **timestamp** | **datetime** | | -| **id** | **int** | | +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**requester_name** | **str** | | +**requester_did** | **str** | | +**resolved_did** | **str** | | +**other** | **object** | | +**timestamp** | **datetime** | | +**id** | **int** | | ## Example @@ -28,5 +28,6 @@ resolution_dict = resolution_instance.to_dict() # create an instance of Resolution from a dict resolution_form_dict = resolution.from_dict(resolution_dict) ``` - [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/pkgs/clan-cli/tests/openapi_client/docs/ResolutionApi.md b/pkgs/clan-cli/tests/openapi_client/docs/ResolutionApi.md index 24da5fb..a2ae852 100644 --- a/pkgs/clan-cli/tests/openapi_client/docs/ResolutionApi.md +++ b/pkgs/clan-cli/tests/openapi_client/docs/ResolutionApi.md @@ -1,13 +1,13 @@ # openapi_client.ResolutionApi -All URIs are relative to _http://localhost_ +All URIs are relative to *http://localhost* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**get_all_resolutions**](ResolutionApi.md#get_all_resolutions) | **GET** /api/v1/resolutions | Get All Resolutions -| Method | HTTP request | Description | -| --------------------------------------------------------------- | --------------------------- | ------------------- | -| [**get_all_resolutions**](ResolutionApi.md#get_all_resolutions) | **GET** /api/v1/resolutions | Get All Resolutions | # **get_all_resolutions** - > List[Resolution] get_all_resolutions(skip=skip, limit=limit) Get All Resolutions @@ -45,12 +45,14 @@ with openapi_client.ApiClient(configuration) as api_client: print("Exception when calling ResolutionApi->get_all_resolutions: %s\n" % e) ``` + + ### Parameters -| Name | Type | Description | Notes | -| --------- | ------- | ----------- | --------------------------- | -| **skip** | **int** | | [optional] [default to 0] | -| **limit** | **int** | | [optional] [default to 100] | +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **skip** | **int**| | [optional] [default to 0] + **limit** | **int**| | [optional] [default to 100] ### Return type @@ -62,14 +64,14 @@ No authorization required ### HTTP request headers -- **Content-Type**: Not defined -- **Accept**: application/json + - **Content-Type**: Not defined + - **Accept**: application/json ### HTTP response details - -| Status code | Description | Response headers | -| ----------- | ------------------- | ---------------- | -| **200** | Successful Response | - | -| **422** | Validation Error | - | +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | Successful Response | - | +**422** | Validation Error | - | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + diff --git a/pkgs/clan-cli/tests/openapi_client/docs/Service.md b/pkgs/clan-cli/tests/openapi_client/docs/Service.md index 5798f74..bff9e15 100644 --- a/pkgs/clan-cli/tests/openapi_client/docs/Service.md +++ b/pkgs/clan-cli/tests/openapi_client/docs/Service.md @@ -1,17 +1,17 @@ # Service -## Properties -| Name | Type | Description | Notes | -| ---------------- | ----------------------- | ----------- | ----- | -| **uuid** | **str** | | -| **service_name** | **str** | | -| **service_type** | **str** | | -| **endpoint_url** | **str** | | -| **status** | **str** | | -| **other** | **object** | | -| **entity_did** | **str** | | -| **entity** | [**Entity**](Entity.md) | | +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**uuid** | **str** | | +**service_name** | **str** | | +**service_type** | **str** | | +**endpoint_url** | **str** | | +**status** | **str** | | +**other** | **object** | | +**entity_did** | **str** | | +**entity** | [**Entity**](Entity.md) | | ## Example @@ -30,5 +30,6 @@ service_dict = service_instance.to_dict() # create an instance of Service from a dict service_form_dict = service.from_dict(service_dict) ``` - [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/pkgs/clan-cli/tests/openapi_client/docs/ServiceCreate.md b/pkgs/clan-cli/tests/openapi_client/docs/ServiceCreate.md index 7843b1a..f8e84e1 100644 --- a/pkgs/clan-cli/tests/openapi_client/docs/ServiceCreate.md +++ b/pkgs/clan-cli/tests/openapi_client/docs/ServiceCreate.md @@ -1,16 +1,16 @@ # ServiceCreate -## Properties -| Name | Type | Description | Notes | -| ---------------- | ---------- | ----------- | ----- | -| **uuid** | **str** | | -| **service_name** | **str** | | -| **service_type** | **str** | | -| **endpoint_url** | **str** | | -| **status** | **str** | | -| **other** | **object** | | -| **entity_did** | **str** | | +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**uuid** | **str** | | +**service_name** | **str** | | +**service_type** | **str** | | +**endpoint_url** | **str** | | +**status** | **str** | | +**other** | **object** | | +**entity_did** | **str** | | ## Example @@ -29,5 +29,6 @@ service_create_dict = service_create_instance.to_dict() # create an instance of ServiceCreate from a dict service_create_form_dict = service_create.from_dict(service_create_dict) ``` - [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/pkgs/clan-cli/tests/openapi_client/docs/ServicesApi.md b/pkgs/clan-cli/tests/openapi_client/docs/ServicesApi.md index 846a81c..9a2c544 100644 --- a/pkgs/clan-cli/tests/openapi_client/docs/ServicesApi.md +++ b/pkgs/clan-cli/tests/openapi_client/docs/ServicesApi.md @@ -1,17 +1,17 @@ # openapi_client.ServicesApi -All URIs are relative to _http://localhost_ +All URIs are relative to *http://localhost* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**create_service**](ServicesApi.md#create_service) | **POST** /api/v1/service | Create Service +[**delete_service**](ServicesApi.md#delete_service) | **DELETE** /api/v1/service | Delete Service +[**get_all_services**](ServicesApi.md#get_all_services) | **GET** /api/v1/services | Get All Services +[**get_service_by_did**](ServicesApi.md#get_service_by_did) | **GET** /api/v1/service | Get Service By Did +[**get_services_without_entity**](ServicesApi.md#get_services_without_entity) | **GET** /api/v1/services_without_entity | Get Services Without Entity -| Method | HTTP request | Description | -| --------------------------------------------------------------- | --------------------------------------- | -------------------- | -| [**create_service**](ServicesApi.md#create_service) | **POST** /api/v1/service | Create Service | -| [**delete_service**](ServicesApi.md#delete_service) | **DELETE** /api/v1/{entity_did}/service | Delete Service | -| [**get_all_services**](ServicesApi.md#get_all_services) | **GET** /api/v1/services | Get All Services | -| [**get_service_by_did**](ServicesApi.md#get_service_by_did) | **GET** /api/v1/{entity_did}/service | Get Service By Did | -| [**get_services_by_name**](ServicesApi.md#get_services_by_name) | **GET** /api/v1/services_by_entity_name | Get Services By Name | # **create_service** - > Service create_service(service_create) Create Service @@ -38,7 +38,7 @@ configuration = openapi_client.Configuration( with openapi_client.ApiClient(configuration) as api_client: # Create an instance of the API class api_instance = openapi_client.ServicesApi(api_client) - service_create = openapi_client.ServiceCreate() # ServiceCreate | + service_create = openapi_client.ServiceCreate() # ServiceCreate | try: # Create Service @@ -49,11 +49,13 @@ with openapi_client.ApiClient(configuration) as api_client: print("Exception when calling ServicesApi->create_service: %s\n" % e) ``` + + ### Parameters -| Name | Type | Description | Notes | -| ------------------ | ------------------------------------- | ----------- | ----- | -| **service_create** | [**ServiceCreate**](ServiceCreate.md) | | +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **service_create** | [**ServiceCreate**](ServiceCreate.md)| | ### Return type @@ -65,21 +67,19 @@ No authorization required ### HTTP request headers -- **Content-Type**: application/json -- **Accept**: application/json + - **Content-Type**: application/json + - **Accept**: application/json ### HTTP response details - -| Status code | Description | Response headers | -| ----------- | ------------------- | ---------------- | -| **200** | Successful Response | - | -| **422** | Validation Error | - | +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | Successful Response | - | +**422** | Validation Error | - | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **delete_service** - -> Dict[str, str] delete_service(entity_did) +> Dict[str, str] delete_service(entity_did=entity_did) Delete Service @@ -103,22 +103,24 @@ configuration = openapi_client.Configuration( with openapi_client.ApiClient(configuration) as api_client: # Create an instance of the API class api_instance = openapi_client.ServicesApi(api_client) - entity_did = 'entity_did_example' # str | + entity_did = 'did:sov:test:1234' # str | (optional) (default to 'did:sov:test:1234') try: # Delete Service - api_response = api_instance.delete_service(entity_did) + api_response = api_instance.delete_service(entity_did=entity_did) print("The response of ServicesApi->delete_service:\n") pprint(api_response) except Exception as e: print("Exception when calling ServicesApi->delete_service: %s\n" % e) ``` + + ### Parameters -| Name | Type | Description | Notes | -| -------------- | ------- | ----------- | ----- | -| **entity_did** | **str** | | +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **entity_did** | **str**| | [optional] [default to 'did:sov:test:1234'] ### Return type @@ -130,20 +132,18 @@ No authorization required ### HTTP request headers -- **Content-Type**: Not defined -- **Accept**: application/json + - **Content-Type**: Not defined + - **Accept**: application/json ### HTTP response details - -| Status code | Description | Response headers | -| ----------- | ------------------- | ---------------- | -| **200** | Successful Response | - | -| **422** | Validation Error | - | +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | Successful Response | - | +**422** | Validation Error | - | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **get_all_services** - > List[Service] get_all_services(skip=skip, limit=limit) Get All Services @@ -181,12 +181,14 @@ with openapi_client.ApiClient(configuration) as api_client: print("Exception when calling ServicesApi->get_all_services: %s\n" % e) ``` + + ### Parameters -| Name | Type | Description | Notes | -| --------- | ------- | ----------- | --------------------------- | -| **skip** | **int** | | [optional] [default to 0] | -| **limit** | **int** | | [optional] [default to 100] | +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **skip** | **int**| | [optional] [default to 0] + **limit** | **int**| | [optional] [default to 100] ### Return type @@ -198,21 +200,19 @@ No authorization required ### HTTP request headers -- **Content-Type**: Not defined -- **Accept**: application/json + - **Content-Type**: Not defined + - **Accept**: application/json ### HTTP response details - -| Status code | Description | Response headers | -| ----------- | ------------------- | ---------------- | -| **200** | Successful Response | - | -| **422** | Validation Error | - | +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | Successful Response | - | +**422** | Validation Error | - | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **get_service_by_did** - -> List[Service] get_service_by_did(entity_did, skip=skip, limit=limit) +> List[Service] get_service_by_did(entity_did=entity_did, skip=skip, limit=limit) Get Service By Did @@ -237,26 +237,28 @@ configuration = openapi_client.Configuration( with openapi_client.ApiClient(configuration) as api_client: # Create an instance of the API class api_instance = openapi_client.ServicesApi(api_client) - entity_did = 'entity_did_example' # str | + entity_did = 'did:sov:test:1234' # str | (optional) (default to 'did:sov:test:1234') skip = 0 # int | (optional) (default to 0) limit = 100 # int | (optional) (default to 100) try: # Get Service By Did - api_response = api_instance.get_service_by_did(entity_did, skip=skip, limit=limit) + api_response = api_instance.get_service_by_did(entity_did=entity_did, skip=skip, limit=limit) print("The response of ServicesApi->get_service_by_did:\n") pprint(api_response) except Exception as e: print("Exception when calling ServicesApi->get_service_by_did: %s\n" % e) ``` + + ### Parameters -| Name | Type | Description | Notes | -| -------------- | ------- | ----------- | --------------------------- | -| **entity_did** | **str** | | -| **skip** | **int** | | [optional] [default to 0] | -| **limit** | **int** | | [optional] [default to 100] | +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **entity_did** | **str**| | [optional] [default to 'did:sov:test:1234'] + **skip** | **int**| | [optional] [default to 0] + **limit** | **int**| | [optional] [default to 100] ### Return type @@ -268,23 +270,21 @@ No authorization required ### HTTP request headers -- **Content-Type**: Not defined -- **Accept**: application/json + - **Content-Type**: Not defined + - **Accept**: application/json ### HTTP response details - -| Status code | Description | Response headers | -| ----------- | ------------------- | ---------------- | -| **200** | Successful Response | - | -| **422** | Validation Error | - | +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | Successful Response | - | +**422** | Validation Error | - | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) -# **get_services_by_name** +# **get_services_without_entity** +> List[Service] get_services_without_entity(entity_did=entity_did, skip=skip, limit=limit) -> ServicesByName get_services_by_name(entity_name, skip=skip, limit=limit) - -Get Services By Name +Get Services Without Entity ### Example @@ -292,7 +292,7 @@ Get Services By Name import time import os import openapi_client -from openapi_client.models.services_by_name import ServicesByName +from openapi_client.models.service import Service from openapi_client.rest import ApiException from pprint import pprint @@ -307,30 +307,32 @@ configuration = openapi_client.Configuration( with openapi_client.ApiClient(configuration) as api_client: # Create an instance of the API class api_instance = openapi_client.ServicesApi(api_client) - entity_name = 'entity_name_example' # str | + entity_did = 'did:sov:test:1234' # str | (optional) (default to 'did:sov:test:1234') skip = 0 # int | (optional) (default to 0) limit = 100 # int | (optional) (default to 100) try: - # Get Services By Name - api_response = api_instance.get_services_by_name(entity_name, skip=skip, limit=limit) - print("The response of ServicesApi->get_services_by_name:\n") + # Get Services Without Entity + api_response = api_instance.get_services_without_entity(entity_did=entity_did, skip=skip, limit=limit) + print("The response of ServicesApi->get_services_without_entity:\n") pprint(api_response) except Exception as e: - print("Exception when calling ServicesApi->get_services_by_name: %s\n" % e) + print("Exception when calling ServicesApi->get_services_without_entity: %s\n" % e) ``` + + ### Parameters -| Name | Type | Description | Notes | -| --------------- | ------- | ----------- | --------------------------- | -| **entity_name** | **str** | | -| **skip** | **int** | | [optional] [default to 0] | -| **limit** | **int** | | [optional] [default to 100] | +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **entity_did** | **str**| | [optional] [default to 'did:sov:test:1234'] + **skip** | **int**| | [optional] [default to 0] + **limit** | **int**| | [optional] [default to 100] ### Return type -[**ServicesByName**](ServicesByName.md) +[**List[Service]**](Service.md) ### Authorization @@ -338,14 +340,14 @@ No authorization required ### HTTP request headers -- **Content-Type**: Not defined -- **Accept**: application/json + - **Content-Type**: Not defined + - **Accept**: application/json ### HTTP response details - -| Status code | Description | Response headers | -| ----------- | ------------------- | ---------------- | -| **200** | Successful Response | - | -| **422** | Validation Error | - | +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | Successful Response | - | +**422** | Validation Error | - | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + diff --git a/pkgs/clan-cli/tests/openapi_client/docs/ServicesByName.md b/pkgs/clan-cli/tests/openapi_client/docs/ServicesByName.md deleted file mode 100644 index 5d25b1e..0000000 --- a/pkgs/clan-cli/tests/openapi_client/docs/ServicesByName.md +++ /dev/null @@ -1,28 +0,0 @@ -# ServicesByName - -## Properties - -| Name | Type | Description | Notes | -| ------------ | ------------------------------- | ----------- | ----- | -| **entity** | [**Entity**](Entity.md) | | -| **services** | [**List[Service]**](Service.md) | | - -## Example - -```python -from openapi_client.models.services_by_name import ServicesByName - -# TODO update the JSON string below -json = "{}" -# create an instance of ServicesByName from a JSON string -services_by_name_instance = ServicesByName.from_json(json) -# print the JSON string representation of the object -print ServicesByName.to_json() - -# convert the object into a dict -services_by_name_dict = services_by_name_instance.to_dict() -# create an instance of ServicesByName from a dict -services_by_name_form_dict = services_by_name.from_dict(services_by_name_dict) -``` - -[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/pkgs/clan-cli/tests/openapi_client/docs/Status.md b/pkgs/clan-cli/tests/openapi_client/docs/Status.md index 10bd223..3b89cf4 100644 --- a/pkgs/clan-cli/tests/openapi_client/docs/Status.md +++ b/pkgs/clan-cli/tests/openapi_client/docs/Status.md @@ -3,8 +3,9 @@ An enumeration. ## Properties - -| Name | Type | Description | Notes | -| ---- | ---- | ----------- | ----- | +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/pkgs/clan-cli/tests/openapi_client/docs/ValidationError.md b/pkgs/clan-cli/tests/openapi_client/docs/ValidationError.md index b57b565..04310f6 100644 --- a/pkgs/clan-cli/tests/openapi_client/docs/ValidationError.md +++ b/pkgs/clan-cli/tests/openapi_client/docs/ValidationError.md @@ -1,12 +1,12 @@ # ValidationError -## Properties -| Name | Type | Description | Notes | -| -------- | --------------------------------------------------------------- | ----------- | ----- | -| **loc** | [**List[ValidationErrorLocInner]**](ValidationErrorLocInner.md) | | -| **msg** | **str** | | -| **type** | **str** | | +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**loc** | [**List[ValidationErrorLocInner]**](ValidationErrorLocInner.md) | | +**msg** | **str** | | +**type** | **str** | | ## Example @@ -25,5 +25,6 @@ validation_error_dict = validation_error_instance.to_dict() # create an instance of ValidationError from a dict validation_error_form_dict = validation_error.from_dict(validation_error_dict) ``` - [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/pkgs/clan-cli/tests/openapi_client/docs/ValidationErrorLocInner.md b/pkgs/clan-cli/tests/openapi_client/docs/ValidationErrorLocInner.md index 04e49df..0bae52d 100644 --- a/pkgs/clan-cli/tests/openapi_client/docs/ValidationErrorLocInner.md +++ b/pkgs/clan-cli/tests/openapi_client/docs/ValidationErrorLocInner.md @@ -1,9 +1,9 @@ # ValidationErrorLocInner -## Properties -| Name | Type | Description | Notes | -| ---- | ---- | ----------- | ----- | +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- ## Example @@ -22,5 +22,6 @@ validation_error_loc_inner_dict = validation_error_loc_inner_instance.to_dict() # create an instance of ValidationErrorLocInner from a dict validation_error_loc_inner_form_dict = validation_error_loc_inner.from_dict(validation_error_loc_inner_dict) ``` - [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/pkgs/clan-cli/tests/openapi_client/models/__init__.py b/pkgs/clan-cli/tests/openapi_client/models/__init__.py index 822cc4e..4955602 100644 --- a/pkgs/clan-cli/tests/openapi_client/models/__init__.py +++ b/pkgs/clan-cli/tests/openapi_client/models/__init__.py @@ -21,7 +21,6 @@ from openapi_client.models.machine import Machine from openapi_client.models.resolution import Resolution from openapi_client.models.service import Service from openapi_client.models.service_create import ServiceCreate -from openapi_client.models.services_by_name import ServicesByName from openapi_client.models.status import Status from openapi_client.models.validation_error import ValidationError from openapi_client.models.validation_error_loc_inner import ValidationErrorLocInner diff --git a/pkgs/clan-cli/tests/openapi_client/models/services_by_name.py b/pkgs/clan-cli/tests/openapi_client/models/services_by_name.py deleted file mode 100644 index 0ee9a85..0000000 --- a/pkgs/clan-cli/tests/openapi_client/models/services_by_name.py +++ /dev/null @@ -1,85 +0,0 @@ -# coding: utf-8 - -""" - FastAPI - - No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - - The version of the OpenAPI document: 0.1.0 - Generated by OpenAPI Generator (https://openapi-generator.tech) - - Do not edit the class manually. -""" # noqa: E501 - - -from __future__ import annotations -import pprint -import re # noqa: F401 -import json - - -from typing import List -from pydantic import BaseModel, Field, conlist -from openapi_client.models.entity import Entity -from openapi_client.models.service import Service - -class ServicesByName(BaseModel): - """ - ServicesByName - """ - entity: Entity = Field(...) - services: conlist(Service) = Field(...) - __properties = ["entity", "services"] - - class Config: - """Pydantic configuration""" - allow_population_by_field_name = True - validate_assignment = True - - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.dict(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - return json.dumps(self.to_dict()) - - @classmethod - def from_json(cls, json_str: str) -> ServicesByName: - """Create an instance of ServicesByName from a JSON string""" - return cls.from_dict(json.loads(json_str)) - - def to_dict(self): - """Returns the dictionary representation of the model using alias""" - _dict = self.dict(by_alias=True, - exclude={ - }, - exclude_none=True) - # override the default output from pydantic by calling `to_dict()` of entity - if self.entity: - _dict['entity'] = self.entity.to_dict() - # override the default output from pydantic by calling `to_dict()` of each item in services (list) - _items = [] - if self.services: - for _item in self.services: - if _item: - _items.append(_item.to_dict()) - _dict['services'] = _items - return _dict - - @classmethod - def from_dict(cls, obj: dict) -> ServicesByName: - """Create an instance of ServicesByName from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return ServicesByName.parse_obj(obj) - - _obj = ServicesByName.parse_obj({ - "entity": Entity.from_dict(obj.get("entity")) if obj.get("entity") is not None else None, - "services": [Service.from_dict(_item) for _item in obj.get("services")] if obj.get("services") is not None else None - }) - return _obj - - diff --git a/pkgs/clan-cli/tests/openapi_client/test/test_services_api.py b/pkgs/clan-cli/tests/openapi_client/test/test_services_api.py index b9d196d..68470f9 100644 --- a/pkgs/clan-cli/tests/openapi_client/test/test_services_api.py +++ b/pkgs/clan-cli/tests/openapi_client/test/test_services_api.py @@ -54,10 +54,10 @@ class TestServicesApi(unittest.TestCase): """ pass - def test_get_services_by_name(self) -> None: - """Test case for get_services_by_name + def test_get_services_without_entity(self) -> None: + """Test case for get_services_without_entity - Get Services By Name # noqa: E501 + Get Services Without Entity # noqa: E501 """ pass diff --git a/pkgs/clan-cli/tests/openapi_client/test/test_services_by_name.py b/pkgs/clan-cli/tests/openapi_client/test/test_services_by_name.py deleted file mode 100644 index b63992b..0000000 --- a/pkgs/clan-cli/tests/openapi_client/test/test_services_by_name.py +++ /dev/null @@ -1,99 +0,0 @@ -# coding: utf-8 - -""" - FastAPI - - No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - - The version of the OpenAPI document: 0.1.0 - Generated by OpenAPI Generator (https://openapi-generator.tech) - - Do not edit the class manually. -""" # noqa: E501 - - -import unittest -import datetime - -from openapi_client.models.services_by_name import ServicesByName # noqa: E501 - -class TestServicesByName(unittest.TestCase): - """ServicesByName unit test stubs""" - - def setUp(self): - pass - - def tearDown(self): - pass - - def make_instance(self, include_optional) -> ServicesByName: - """Test ServicesByName - include_option is a boolean, when False only required - params are included, when True both required and - optional params are included """ - # uncomment below to create an instance of `ServicesByName` - """ - model = ServicesByName() # noqa: E501 - if include_optional: - return ServicesByName( - entity = openapi_client.models.entity.Entity( - did = 'did:sov:test:1234', - name = 'C1', - ip = '127.0.0.1', - visible = True, - other = {network=Carlos Home Network, roles=[service repository, service prosumer]}, - attached = True, ), - services = [ - openapi_client.models.service.Service( - uuid = '8e285c0c-4e40-430a-a477-26b3b81e30df', - service_name = 'Carlos Printing', - service_type = '3D Printing', - endpoint_url = 'http://127.0.0.1:8000', - status = 'unknown', - other = {action=[register, deregister, delete, create]}, - entity_did = 'did:sov:test:1234', - entity = openapi_client.models.entity.Entity( - did = 'did:sov:test:1234', - name = 'C1', - ip = '127.0.0.1', - visible = True, - other = {network=Carlos Home Network, roles=[service repository, service prosumer]}, - attached = True, ), ) - ] - ) - else: - return ServicesByName( - entity = openapi_client.models.entity.Entity( - did = 'did:sov:test:1234', - name = 'C1', - ip = '127.0.0.1', - visible = True, - other = {network=Carlos Home Network, roles=[service repository, service prosumer]}, - attached = True, ), - services = [ - openapi_client.models.service.Service( - uuid = '8e285c0c-4e40-430a-a477-26b3b81e30df', - service_name = 'Carlos Printing', - service_type = '3D Printing', - endpoint_url = 'http://127.0.0.1:8000', - status = 'unknown', - other = {action=[register, deregister, delete, create]}, - entity_did = 'did:sov:test:1234', - entity = openapi_client.models.entity.Entity( - did = 'did:sov:test:1234', - name = 'C1', - ip = '127.0.0.1', - visible = True, - other = {network=Carlos Home Network, roles=[service repository, service prosumer]}, - attached = True, ), ) - ], - ) - """ - - def testServicesByName(self): - """Test ServicesByName""" - # inst_req_only = self.make_instance(include_optional=False) - # inst_req_and_optional = self.make_instance(include_optional=True) - -if __name__ == '__main__': - unittest.main() diff --git a/pkgs/ui/src/app/access-point/page.tsx b/pkgs/ui/src/app/access-point/page.tsx index 34f08cd..c4783f0 100644 --- a/pkgs/ui/src/app/access-point/page.tsx +++ b/pkgs/ui/src/app/access-point/page.tsx @@ -45,7 +45,7 @@ export default function AccessPoint() { useEffect(() => { const interval = setInterval(() => { onRefresh(); - }, 1000); + }, 5000); return () => clearInterval(interval); // eslint-disable-next-line react-hooks/exhaustive-deps diff --git a/pkgs/ui/src/app/client/[client_name]/page.tsx b/pkgs/ui/src/app/client/[client_name]/page.tsx index 2637d81..4b4e68a 100644 --- a/pkgs/ui/src/app/client/[client_name]/page.tsx +++ b/pkgs/ui/src/app/client/[client_name]/page.tsx @@ -10,13 +10,112 @@ import { CardHeader, Snackbar, Typography, + CircularProgress, + IconButton, } from "@mui/material"; import CopyToClipboard from "@/components/copy_to_clipboard"; -import { useGetServicesByName } from "@/api/services/services"; -import { attachEntity, detachEntity } from "@/api/entities/entities"; +import { + attachEntity, + detachEntity, + isAttached, +} from "@/api/entities/entities"; import { mutate } from "swr"; import { Skeleton } from "@mui/material"; -import { Service } from "@/api/model"; +import { Entity, Service } from "@/api/model"; +import useGetEntityByNameOrDid from "@/components/hooks/useGetEntityByNameOrDid"; +import { useGetAllServices } from "@/api/services/services"; +import axios from "axios"; +import { NoDataOverlay } from "@/components/noDataOverlay"; +import { DashboardCard } from "@/components/card"; +import CloseIcon from "@mui/icons-material/Close"; + +interface SnackMessage { + message: string; + severity: "success" | "error"; +} + +export const RecentActivity = (entity: Entity) => { + return ( + +
+ +
+
+ ); +}; + +type AttachButtonProps = { + entity?: Entity; + setSnackbarMessage: (message: SnackMessage) => void; + setSnackbarOpen: (open: boolean) => void; +}; + +const AttachButton = ({ + entity, + setSnackbarMessage, + setSnackbarOpen, +}: AttachButtonProps) => { + const [loading, setLoading] = useState(false); + + const handleClick = async () => { + setLoading(true); + // Call the attach or detach function depending on the isAttached value + // and await for the result + try { + let response = await (entity?.attached + ? detachEntity({ entity_did: entity?.did }) + : attachEntity({ entity_did: entity?.did })); + + if (!entity?.attached) { + console.log("calling isAttached"); + response = await isAttached({ entity_did: entity?.did }); + console.log("response: ", response); + } + const msg = { + message: response.data.message, + severity: "success", + } as SnackMessage; + setSnackbarMessage(msg); + setSnackbarOpen(true); + } catch (error) { + if (axios.isAxiosError(error)) { + // Extract the error message from the error object + const errorMessage = error.response?.data.detail[0].msg; + + const msg = { + message: `${errorMessage}`, + severity: "error", + } as SnackMessage; + setSnackbarMessage(msg); + setSnackbarOpen(true); + } else { + console.error("error: ", error); + } + } finally { + setLoading(false); + } + }; + + return ( + <> + + + ); +}; export default function Client({ params, @@ -25,18 +124,16 @@ export default function Client({ }) { const { client_name } = params; + const { entity: entity } = useGetEntityByNameOrDid(client_name); const { data: services, isLoading: services_loading, swrKey: entityKeyFunc, - } = useGetServicesByName({ - entity_name: client_name, - }); + } = useGetAllServices(); - const entity = services?.data?.entity; const clients: Service[] = useMemo(() => { - if (services?.data?.services) { - return services.data.services.filter((service) => { + if (services?.data) { + return services.data.filter((service) => { if (service.entity_did !== entity?.did) return true; }); } @@ -60,47 +157,15 @@ export default function Client({ const cardContentRef = useRef(null); const [snackbarOpen, setSnackbarOpen] = useState(false); - const [snackbarMessage, setSnackbarMessage] = useState(""); - const [isAttached, setIsAttached] = useState(entity?.attached); + const [snackbarMessage, setSnackbarMessage] = useState< + SnackMessage | undefined + >(undefined); const closeSnackBar = () => { - setSnackbarMessage(""); + setSnackbarMessage(undefined); setSnackbarOpen(false); }; - const onAttachEntity = async () => { - try { - if (entity) { - const response = await attachEntity(entity.did); - setSnackbarMessage(response.data.message); - setSnackbarOpen(true); - } else { - console.error("no entity"); - } - } catch (error) { - console.error(error); - } finally { - setIsAttached(true); - } - }; - - const onDetachEntity = async () => { - try { - if (entity) { - const response = await detachEntity(entity.did); - console.log(response); - setSnackbarMessage("Entity detached successfully."); - setSnackbarOpen(true); - } else { - console.error("no entity"); - } - } catch (error) { - console.error(error); - } finally { - setIsAttached(false); - } - }; - if (services_loading) return ; if (!services) return Client not found; @@ -113,25 +178,13 @@ export default function Client({ justifyContent: "space-between", }} > -

Client 1

+

Entity {entity?.name}

- {isAttached === false ? ( - - ) : ( - - )} +
diff --git a/pkgs/ui/src/components/hooks/useGetEntityById.tsx b/pkgs/ui/src/components/hooks/useGetEntityByNameOrDid.tsx similarity index 80% rename from pkgs/ui/src/components/hooks/useGetEntityById.tsx rename to pkgs/ui/src/components/hooks/useGetEntityByNameOrDid.tsx index 7736d44..79ee222 100644 --- a/pkgs/ui/src/components/hooks/useGetEntityById.tsx +++ b/pkgs/ui/src/components/hooks/useGetEntityByNameOrDid.tsx @@ -1,7 +1,7 @@ import { useContext } from "react"; import { AppContext } from "./useAppContext"; -const useGetEntityByName = (nameOrDid: string) => { +const useGetEntityByNameOrDid = (nameOrDid: string) => { const { data } = useContext(AppContext); const allEntities = data.allEntities; @@ -16,4 +16,4 @@ const useGetEntityByName = (nameOrDid: string) => { return { entity, isLoading: false }; }; -export default useGetEntityByName; +export default useGetEntityByNameOrDid; diff --git a/pkgs/ui/src/components/table/index.tsx b/pkgs/ui/src/components/table/index.tsx index 425606e..900b65c 100644 --- a/pkgs/ui/src/components/table/index.tsx +++ b/pkgs/ui/src/components/table/index.tsx @@ -36,7 +36,6 @@ const CustomTable = ({ configuration, data, loading, tkey }: ICustomTable) => { // cover use case if we want to render a component if (render) renderedValue = render(value); - console.log("renderTableCell key", cellKey); return ( {renderedValue} diff --git a/pkgs/ui/src/config/client_1/index.tsx b/pkgs/ui/src/config/client_1/index.tsx index b91cd4e..3a1db60 100644 --- a/pkgs/ui/src/config/client_1/index.tsx +++ b/pkgs/ui/src/config/client_1/index.tsx @@ -71,7 +71,6 @@ export const ServiceTableConfig = [ ))} ); - console.log("render", renderedValue); return renderedValue; }, }, From 5f4eb1f521bf522aebd80d13cd600d2a98603e14 Mon Sep 17 00:00:00 2001 From: Luis-Hebendanz Date: Mon, 8 Jan 2024 19:33:29 +0100 Subject: [PATCH 43/58] Fixed background task not stopping on detach --- pkgs/clan-cli/clan_cli/webui/app.py | 1 + .../clan_cli/webui/routers/endpoints.py | 135 +++++------ pkgs/clan-cli/clan_cli/webui/sql_crud.py | 15 +- pkgs/clan-cli/emulate_entity.sh | 2 +- .../tests/openapi_client/docs/DefaultApi.md | 68 +++--- .../tests/openapi_client/docs/EntitiesApi.md | 216 +++++++++--------- .../tests/openapi_client/docs/Entity.md | 21 +- .../tests/openapi_client/docs/EntityCreate.md | 19 +- .../docs/HTTPValidationError.md | 11 +- .../tests/openapi_client/docs/Machine.md | 13 +- .../openapi_client/docs/RepositoriesApi.md | 34 ++- .../tests/openapi_client/docs/Resolution.md | 21 +- .../openapi_client/docs/ResolutionApi.md | 34 ++- .../tests/openapi_client/docs/Service.md | 25 +- .../openapi_client/docs/ServiceCreate.md | 23 +- .../tests/openapi_client/docs/ServicesApi.md | 140 ++++++------ .../tests/openapi_client/docs/Status.md | 7 +- .../openapi_client/docs/ValidationError.md | 15 +- .../docs/ValidationErrorLocInner.md | 9 +- 19 files changed, 389 insertions(+), 420 deletions(-) diff --git a/pkgs/clan-cli/clan_cli/webui/app.py b/pkgs/clan-cli/clan_cli/webui/app.py index 99d7e9e..8913f72 100644 --- a/pkgs/clan-cli/clan_cli/webui/app.py +++ b/pkgs/clan-cli/clan_cli/webui/app.py @@ -33,6 +33,7 @@ for u in cors_url: # Logging setup log = logging.getLogger(__name__) + @asynccontextmanager async def lifespan(app: FastAPI) -> Any: await socket_manager2.brd.connect() diff --git a/pkgs/clan-cli/clan_cli/webui/routers/endpoints.py b/pkgs/clan-cli/clan_cli/webui/routers/endpoints.py index 9b601aa..625d03b 100644 --- a/pkgs/clan-cli/clan_cli/webui/routers/endpoints.py +++ b/pkgs/clan-cli/clan_cli/webui/routers/endpoints.py @@ -2,7 +2,6 @@ import logging import time from datetime import datetime from typing import List, Optional -import asyncio import httpx from fastapi import APIRouter, BackgroundTasks, Depends @@ -16,7 +15,6 @@ from ..schemas import ( Resolution, Service, ServiceCreate, - ServicesByName, ) from ..tags import Tags @@ -46,9 +44,7 @@ def get_all_services( return services -@router.get( - "/api/v1/service", response_model=List[Service], tags=[Tags.services] -) +@router.get("/api/v1/service", response_model=List[Service], tags=[Tags.services]) def get_service_by_did( entity_did: str = "did:sov:test:1234", skip: int = 0, @@ -73,6 +69,7 @@ def get_services_without_entity( service = sql_crud.get_services_without_entity_id(db, entity_did=entity_did) return service + @router.delete("/api/v1/service", tags=[Tags.services]) def delete_service( entity_did: str = "did:sov:test:1234", @@ -129,9 +126,7 @@ def get_all_entities( return entities -@router.get( - "/api/v1/entity", response_model=Optional[Entity], tags=[Tags.entities] -) +@router.get("/api/v1/entity", response_model=Optional[Entity], tags=[Tags.entities]) def get_entity_by_did( entity_did: str = "did:sov:test:1234", db: Session = Depends(sql_db.get_db), @@ -151,11 +146,44 @@ def get_attached_entities( entities = sql_crud.get_attached_entities(db, skip=skip, limit=limit) return entities + +@router.post("/api/v1/detach", tags=[Tags.entities]) +def detach_entity( + background_tasks: BackgroundTasks, + entity_did: str = "did:sov:test:1234", + skip: int = 0, + limit: int = 100, + db: Session = Depends(sql_db.get_db), +) -> dict[str, str]: + entity = sql_crud.get_entity_by_did(db, did=entity_did) + if entity is None: + raise ClanError(f"Entity with did '{entity_did}' not found") + sql_crud.set_stop_health_task(db, entity_did, True) + return {"message": f"Detached {entity_did} successfully"} + + +@router.post("/api/v1/attach", tags=[Tags.entities]) +def attach_entity( + background_tasks: BackgroundTasks, + entity_did: str = "did:sov:test:1234", + skip: int = 0, + limit: int = 100, + db: Session = Depends(sql_db.get_db), +) -> dict[str, str]: + entity = sql_crud.get_entity_by_did(db, did=entity_did) + if entity is None: + raise ClanError(f"Entity with did '{entity_did}' not found") + url = f"http://{entity.ip}" + sql_crud.set_stop_health_task(db, entity_did, False) + print("Start health query at", url) + background_tasks.add_task(attach_entity_loc, db, entity_did) + return {"message": f"Started attachment task for {entity.name}"} + + @router.get("/api/v1/is_attached", tags=[Tags.entities]) def is_attached( - entity_did: str = "did:sov:test:1234", - db: Session = Depends(sql_db.get_db)) -> dict[str, str]: - + entity_did: str = "did:sov:test:1234", db: Session = Depends(sql_db.get_db) +) -> dict[str, str]: entity = sql_crud.get_entity_by_did(db, did=entity_did) if entity is None: @@ -171,74 +199,35 @@ def is_attached( url = f"http://{entity.ip}" raise ClanError(f"Entity at {url} not reachable") + db.refresh(entity) return {"message": f"Attached to {entity.name} successfully"} +def attach_entity_loc(db: Session, entity_did: str) -> None: + entity = sql_crud.get_entity_by_did(db, did=entity_did) + try: + assert entity is not None + url = f"http://{entity.ip}" -@router.post("/api/v1/detach", tags=[Tags.entities]) -def detach_entity( - background_tasks: BackgroundTasks, - entity_did: str = "did:sov:test:1234", - skip: int = 0, - limit: int = 100, - db: Session = Depends(sql_db.get_db), -) -> dict[str, str]: - sql_crud.stop_entity_health_task(db, entity_did) - return {"message": f"Detached {entity_did} successfully"} - - -@router.post("/api/v1/attach", tags=[Tags.entities]) -def attach_entity( - background_tasks: BackgroundTasks, - entity_did: str = "did:sov:test:1234", - skip: int = 0, - limit: int = 100 -) -> dict[str, str]: - # entity = sql_crud.get_entity_by_did(db, did=entity_did) - # if entity is None: - # raise ClanError(f"Entity with did '{entity_did}' not found") - #url = f"http://{entity.ip}" - #log.info("Start health query at", url) - background_tasks.add_task(attach_entity_loc, entity_did) - return {"message": f"Started attachment task for {entity_did}"} - - -def attach_entity_loc(entity_did: str) -> None: - with sql_db.SessionLocal() as db: - entity = sql_crud.get_entity_by_did(db, did=entity_did) while entity.stop_health_task is False: - entity = sql_crud.get_entity_by_did(db, did=entity_did) - assert entity is not None - log.warning(f"Stop health status task for {entity.stop_health_task}") + response = httpx.get(url, timeout=2) + if response.status_code != 200: + raise ClanError( + f"Entity with did '{entity_did}' returned {response.status_code}" + ) + + if entity.attached is False: + sql_crud.set_attached_by_entity_did(db, entity_did, True) + if entity is None: + raise ClanError(f"Entity with did '{entity_did}' has been deleted") + time.sleep(1) - # entity = sql_crud.get_entity_by_did(db, did=entity_did) - # assert entity is not None - # try: - - # while True: - - - # if entity.stop_health_task: - # print(f"Stop health status task for {entity.name}") - # break - - # url = f"http://{entity.ip}" - # response = httpx.get(url, timeout=2) - # #log.warning(f"Response {response.status_code} from {url}") - # print(f"{entity.name}: stop_health_task: {entity.stop_health_task}") - # if response.status_code != 200: - # raise ClanError(f"Entity with did '{entity_did}' returned {response.status_code}") - - # if entity.attached is False: - # sql_crud.set_attached_by_entity_did(db, entity_did, True) - # if entity is None: - # raise ClanError(f"Entity with did '{entity_did}' has been deleted") - - # time.sleep(1) - # except Exception: - # log.warning(f"Entity {entity_did} not reachable at {url}") - # finally: - # sql_crud.set_attached_by_entity_did(db, entity_did, False) + db.refresh(entity) + except Exception: + print(f"Entity {entity_did} not reachable at {url}") + finally: + sql_crud.set_attached_by_entity_did(db, entity_did, False) + sql_crud.set_stop_health_task(db, entity_did, False) @router.delete("/api/v1/entity", tags=[Tags.entities]) diff --git a/pkgs/clan-cli/clan_cli/webui/sql_crud.py b/pkgs/clan-cli/clan_cli/webui/sql_crud.py index 7314f23..3f5fdc0 100644 --- a/pkgs/clan-cli/clan_cli/webui/sql_crud.py +++ b/pkgs/clan-cli/clan_cli/webui/sql_crud.py @@ -64,7 +64,9 @@ def get_services_without_entity_id( # # ######################### def create_entity(db: Session, entity: schemas.EntityCreate) -> sql_models.Entity: - db_entity = sql_models.Entity(**entity.dict(), attached=False, stop_health_task=False) + db_entity = sql_models.Entity( + **entity.dict(), attached=False, stop_health_task=False + ) db.add(db_entity) db.commit() db.refresh(db_entity) @@ -100,14 +102,12 @@ def get_attached_entities( # Returns same entity if setting didnt changed something -def stop_entity_health_task( - db: Session, entity_did: str -) -> None: +def set_stop_health_task(db: Session, entity_did: str, value: bool) -> None: db_entity = get_entity_by_did(db, entity_did) if db_entity is None: raise ClanError(f"Entity with did '{entity_did}' not found") - setattr(db_entity, "stop_health_task", True) + setattr(db_entity, "stop_health_task", value) # save changes in db db.add(db_entity) @@ -115,10 +115,7 @@ def stop_entity_health_task( db.refresh(db_entity) - -def set_attached_by_entity_did( - db: Session, entity_did: str, attached: bool -) -> None: +def set_attached_by_entity_did(db: Session, entity_did: str, attached: bool) -> None: db_entity = get_entity_by_did(db, entity_did) if db_entity is None: raise ClanError(f"Entity with did '{entity_did}' not found") diff --git a/pkgs/clan-cli/emulate_entity.sh b/pkgs/clan-cli/emulate_entity.sh index b4fdbc8..047880a 100755 --- a/pkgs/clan-cli/emulate_entity.sh +++ b/pkgs/clan-cli/emulate_entity.sh @@ -1,3 +1,3 @@ #!/usr/bin/env bash -while true ; do printf 'HTTP/1.1 200 OK\r\n\r\ncool, thanks' | nc -l -N 127.0.0.1 7002 ; done +while true ; do printf 'HTTP/1.1 200 OK\r\n\r\ncool, thanks' | nc -l -N 127.0.0.1 7002; done diff --git a/pkgs/clan-cli/tests/openapi_client/docs/DefaultApi.md b/pkgs/clan-cli/tests/openapi_client/docs/DefaultApi.md index 9a4a45c..aef64f7 100644 --- a/pkgs/clan-cli/tests/openapi_client/docs/DefaultApi.md +++ b/pkgs/clan-cli/tests/openapi_client/docs/DefaultApi.md @@ -1,15 +1,15 @@ # openapi_client.DefaultApi -All URIs are relative to *http://localhost* - -Method | HTTP request | Description -------------- | ------------- | ------------- -[**get**](DefaultApi.md#get) | **GET** /ws2_example | Get -[**health**](DefaultApi.md#health) | **GET** /health | Health -[**root**](DefaultApi.md#root) | **GET** /{path_name} | Root +All URIs are relative to _http://localhost_ +| Method | HTTP request | Description | +| ---------------------------------- | -------------------- | ----------- | +| [**get**](DefaultApi.md#get) | **GET** /ws2_example | Get | +| [**health**](DefaultApi.md#health) | **GET** /health | Health | +| [**root**](DefaultApi.md#root) | **GET** /{path_name} | Root | # **get** + > get() Get @@ -42,9 +42,8 @@ with openapi_client.ApiClient(configuration) as api_client: print("Exception when calling DefaultApi->get: %s\n" % e) ``` - - ### Parameters + This endpoint does not need any parameter. ### Return type @@ -57,17 +56,19 @@ No authorization required ### HTTP request headers - - **Content-Type**: Not defined - - **Accept**: application/json +- **Content-Type**: Not defined +- **Accept**: application/json ### HTTP response details -| Status code | Description | Response headers | -|-------------|-------------|------------------| -**200** | Successful Response | - | + +| Status code | Description | Response headers | +| ----------- | ------------------- | ---------------- | +| **200** | Successful Response | - | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **health** + > Machine health() Health @@ -103,9 +104,8 @@ with openapi_client.ApiClient(configuration) as api_client: print("Exception when calling DefaultApi->health: %s\n" % e) ``` - - ### Parameters + This endpoint does not need any parameter. ### Return type @@ -118,17 +118,19 @@ No authorization required ### HTTP request headers - - **Content-Type**: Not defined - - **Accept**: application/json +- **Content-Type**: Not defined +- **Accept**: application/json ### HTTP response details -| Status code | Description | Response headers | -|-------------|-------------|------------------| -**200** | Successful Response | - | + +| Status code | Description | Response headers | +| ----------- | ------------------- | ---------------- | +| **200** | Successful Response | - | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **root** + > root(path_name) Root @@ -153,7 +155,7 @@ configuration = openapi_client.Configuration( with openapi_client.ApiClient(configuration) as api_client: # Create an instance of the API class api_instance = openapi_client.DefaultApi(api_client) - path_name = 'path_name_example' # str | + path_name = 'path_name_example' # str | try: # Root @@ -162,13 +164,11 @@ with openapi_client.ApiClient(configuration) as api_client: print("Exception when calling DefaultApi->root: %s\n" % e) ``` - - ### Parameters -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **path_name** | **str**| | +| Name | Type | Description | Notes | +| ------------- | ------- | ----------- | ----- | +| **path_name** | **str** | | ### Return type @@ -180,14 +180,14 @@ No authorization required ### HTTP request headers - - **Content-Type**: Not defined - - **Accept**: application/json +- **Content-Type**: Not defined +- **Accept**: application/json ### HTTP response details -| Status code | Description | Response headers | -|-------------|-------------|------------------| -**200** | Successful Response | - | -**422** | Validation Error | - | + +| Status code | Description | Response headers | +| ----------- | ------------------- | ---------------- | +| **200** | Successful Response | - | +| **422** | Validation Error | - | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) - diff --git a/pkgs/clan-cli/tests/openapi_client/docs/EntitiesApi.md b/pkgs/clan-cli/tests/openapi_client/docs/EntitiesApi.md index 2264f33..ccb0216 100644 --- a/pkgs/clan-cli/tests/openapi_client/docs/EntitiesApi.md +++ b/pkgs/clan-cli/tests/openapi_client/docs/EntitiesApi.md @@ -1,20 +1,20 @@ # openapi_client.EntitiesApi -All URIs are relative to *http://localhost* - -Method | HTTP request | Description -------------- | ------------- | ------------- -[**attach_entity**](EntitiesApi.md#attach_entity) | **POST** /api/v1/attach | Attach Entity -[**create_entity**](EntitiesApi.md#create_entity) | **POST** /api/v1/entity | Create Entity -[**delete_entity**](EntitiesApi.md#delete_entity) | **DELETE** /api/v1/entity | Delete Entity -[**detach_entity**](EntitiesApi.md#detach_entity) | **POST** /api/v1/detach | Detach Entity -[**get_all_entities**](EntitiesApi.md#get_all_entities) | **GET** /api/v1/entities | Get All Entities -[**get_attached_entities**](EntitiesApi.md#get_attached_entities) | **GET** /api/v1/attached_entities | Get Attached Entities -[**get_entity_by_did**](EntitiesApi.md#get_entity_by_did) | **GET** /api/v1/entity | Get Entity By Did -[**get_entity_by_name**](EntitiesApi.md#get_entity_by_name) | **GET** /api/v1/entity_by_name | Get Entity By Name +All URIs are relative to _http://localhost_ +| Method | HTTP request | Description | +| ----------------------------------------------------------------- | --------------------------------- | --------------------- | +| [**attach_entity**](EntitiesApi.md#attach_entity) | **POST** /api/v1/attach | Attach Entity | +| [**create_entity**](EntitiesApi.md#create_entity) | **POST** /api/v1/entity | Create Entity | +| [**delete_entity**](EntitiesApi.md#delete_entity) | **DELETE** /api/v1/entity | Delete Entity | +| [**detach_entity**](EntitiesApi.md#detach_entity) | **POST** /api/v1/detach | Detach Entity | +| [**get_all_entities**](EntitiesApi.md#get_all_entities) | **GET** /api/v1/entities | Get All Entities | +| [**get_attached_entities**](EntitiesApi.md#get_attached_entities) | **GET** /api/v1/attached_entities | Get Attached Entities | +| [**get_entity_by_did**](EntitiesApi.md#get_entity_by_did) | **GET** /api/v1/entity | Get Entity By Did | +| [**get_entity_by_name**](EntitiesApi.md#get_entity_by_name) | **GET** /api/v1/entity_by_name | Get Entity By Name | # **attach_entity** + > Dict[str, str] attach_entity(entity_did=entity_did, skip=skip, limit=limit) Attach Entity @@ -52,15 +52,13 @@ with openapi_client.ApiClient(configuration) as api_client: print("Exception when calling EntitiesApi->attach_entity: %s\n" % e) ``` - - ### Parameters -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **entity_did** | **str**| | [optional] [default to 'did:sov:test:1234'] - **skip** | **int**| | [optional] [default to 0] - **limit** | **int**| | [optional] [default to 100] +| Name | Type | Description | Notes | +| -------------- | ------- | ----------- | --------------------------------------------------- | +| **entity_did** | **str** | | [optional] [default to 'did:sov:test:1234'] | +| **skip** | **int** | | [optional] [default to 0] | +| **limit** | **int** | | [optional] [default to 100] | ### Return type @@ -72,18 +70,20 @@ No authorization required ### HTTP request headers - - **Content-Type**: Not defined - - **Accept**: application/json +- **Content-Type**: Not defined +- **Accept**: application/json ### HTTP response details -| Status code | Description | Response headers | -|-------------|-------------|------------------| -**200** | Successful Response | - | -**422** | Validation Error | - | + +| Status code | Description | Response headers | +| ----------- | ------------------- | ---------------- | +| **200** | Successful Response | - | +| **422** | Validation Error | - | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **create_entity** + > Entity create_entity(entity_create) Create Entity @@ -110,7 +110,7 @@ configuration = openapi_client.Configuration( with openapi_client.ApiClient(configuration) as api_client: # Create an instance of the API class api_instance = openapi_client.EntitiesApi(api_client) - entity_create = openapi_client.EntityCreate() # EntityCreate | + entity_create = openapi_client.EntityCreate() # EntityCreate | try: # Create Entity @@ -121,13 +121,11 @@ with openapi_client.ApiClient(configuration) as api_client: print("Exception when calling EntitiesApi->create_entity: %s\n" % e) ``` - - ### Parameters -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **entity_create** | [**EntityCreate**](EntityCreate.md)| | +| Name | Type | Description | Notes | +| ----------------- | ----------------------------------- | ----------- | ----- | +| **entity_create** | [**EntityCreate**](EntityCreate.md) | | ### Return type @@ -139,18 +137,20 @@ No authorization required ### HTTP request headers - - **Content-Type**: application/json - - **Accept**: application/json +- **Content-Type**: application/json +- **Accept**: application/json ### HTTP response details -| Status code | Description | Response headers | -|-------------|-------------|------------------| -**200** | Successful Response | - | -**422** | Validation Error | - | + +| Status code | Description | Response headers | +| ----------- | ------------------- | ---------------- | +| **200** | Successful Response | - | +| **422** | Validation Error | - | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **delete_entity** + > Dict[str, str] delete_entity(entity_did=entity_did) Delete Entity @@ -186,13 +186,11 @@ with openapi_client.ApiClient(configuration) as api_client: print("Exception when calling EntitiesApi->delete_entity: %s\n" % e) ``` - - ### Parameters -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **entity_did** | **str**| | [optional] [default to 'did:sov:test:1234'] +| Name | Type | Description | Notes | +| -------------- | ------- | ----------- | --------------------------------------------------- | +| **entity_did** | **str** | | [optional] [default to 'did:sov:test:1234'] | ### Return type @@ -204,18 +202,20 @@ No authorization required ### HTTP request headers - - **Content-Type**: Not defined - - **Accept**: application/json +- **Content-Type**: Not defined +- **Accept**: application/json ### HTTP response details -| Status code | Description | Response headers | -|-------------|-------------|------------------| -**200** | Successful Response | - | -**422** | Validation Error | - | + +| Status code | Description | Response headers | +| ----------- | ------------------- | ---------------- | +| **200** | Successful Response | - | +| **422** | Validation Error | - | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **detach_entity** + > Entity detach_entity(entity_did=entity_did, skip=skip, limit=limit) Detach Entity @@ -254,15 +254,13 @@ with openapi_client.ApiClient(configuration) as api_client: print("Exception when calling EntitiesApi->detach_entity: %s\n" % e) ``` - - ### Parameters -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **entity_did** | **str**| | [optional] [default to 'did:sov:test:1234'] - **skip** | **int**| | [optional] [default to 0] - **limit** | **int**| | [optional] [default to 100] +| Name | Type | Description | Notes | +| -------------- | ------- | ----------- | --------------------------------------------------- | +| **entity_did** | **str** | | [optional] [default to 'did:sov:test:1234'] | +| **skip** | **int** | | [optional] [default to 0] | +| **limit** | **int** | | [optional] [default to 100] | ### Return type @@ -274,18 +272,20 @@ No authorization required ### HTTP request headers - - **Content-Type**: Not defined - - **Accept**: application/json +- **Content-Type**: Not defined +- **Accept**: application/json ### HTTP response details -| Status code | Description | Response headers | -|-------------|-------------|------------------| -**200** | Successful Response | - | -**422** | Validation Error | - | + +| Status code | Description | Response headers | +| ----------- | ------------------- | ---------------- | +| **200** | Successful Response | - | +| **422** | Validation Error | - | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **get_all_entities** + > List[Entity] get_all_entities(skip=skip, limit=limit) Get All Entities @@ -323,14 +323,12 @@ with openapi_client.ApiClient(configuration) as api_client: print("Exception when calling EntitiesApi->get_all_entities: %s\n" % e) ``` - - ### Parameters -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **skip** | **int**| | [optional] [default to 0] - **limit** | **int**| | [optional] [default to 100] +| Name | Type | Description | Notes | +| --------- | ------- | ----------- | --------------------------- | +| **skip** | **int** | | [optional] [default to 0] | +| **limit** | **int** | | [optional] [default to 100] | ### Return type @@ -342,18 +340,20 @@ No authorization required ### HTTP request headers - - **Content-Type**: Not defined - - **Accept**: application/json +- **Content-Type**: Not defined +- **Accept**: application/json ### HTTP response details -| Status code | Description | Response headers | -|-------------|-------------|------------------| -**200** | Successful Response | - | -**422** | Validation Error | - | + +| Status code | Description | Response headers | +| ----------- | ------------------- | ---------------- | +| **200** | Successful Response | - | +| **422** | Validation Error | - | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **get_attached_entities** + > List[Entity] get_attached_entities(skip=skip, limit=limit) Get Attached Entities @@ -391,14 +391,12 @@ with openapi_client.ApiClient(configuration) as api_client: print("Exception when calling EntitiesApi->get_attached_entities: %s\n" % e) ``` - - ### Parameters -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **skip** | **int**| | [optional] [default to 0] - **limit** | **int**| | [optional] [default to 100] +| Name | Type | Description | Notes | +| --------- | ------- | ----------- | --------------------------- | +| **skip** | **int** | | [optional] [default to 0] | +| **limit** | **int** | | [optional] [default to 100] | ### Return type @@ -410,18 +408,20 @@ No authorization required ### HTTP request headers - - **Content-Type**: Not defined - - **Accept**: application/json +- **Content-Type**: Not defined +- **Accept**: application/json ### HTTP response details -| Status code | Description | Response headers | -|-------------|-------------|------------------| -**200** | Successful Response | - | -**422** | Validation Error | - | + +| Status code | Description | Response headers | +| ----------- | ------------------- | ---------------- | +| **200** | Successful Response | - | +| **422** | Validation Error | - | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **get_entity_by_did** + > Entity get_entity_by_did(entity_did=entity_did) Get Entity By Did @@ -458,13 +458,11 @@ with openapi_client.ApiClient(configuration) as api_client: print("Exception when calling EntitiesApi->get_entity_by_did: %s\n" % e) ``` - - ### Parameters -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **entity_did** | **str**| | [optional] [default to 'did:sov:test:1234'] +| Name | Type | Description | Notes | +| -------------- | ------- | ----------- | --------------------------------------------------- | +| **entity_did** | **str** | | [optional] [default to 'did:sov:test:1234'] | ### Return type @@ -476,18 +474,20 @@ No authorization required ### HTTP request headers - - **Content-Type**: Not defined - - **Accept**: application/json +- **Content-Type**: Not defined +- **Accept**: application/json ### HTTP response details -| Status code | Description | Response headers | -|-------------|-------------|------------------| -**200** | Successful Response | - | -**422** | Validation Error | - | + +| Status code | Description | Response headers | +| ----------- | ------------------- | ---------------- | +| **200** | Successful Response | - | +| **422** | Validation Error | - | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **get_entity_by_name** + > Entity get_entity_by_name(entity_name) Get Entity By Name @@ -513,7 +513,7 @@ configuration = openapi_client.Configuration( with openapi_client.ApiClient(configuration) as api_client: # Create an instance of the API class api_instance = openapi_client.EntitiesApi(api_client) - entity_name = 'entity_name_example' # str | + entity_name = 'entity_name_example' # str | try: # Get Entity By Name @@ -524,13 +524,11 @@ with openapi_client.ApiClient(configuration) as api_client: print("Exception when calling EntitiesApi->get_entity_by_name: %s\n" % e) ``` - - ### Parameters -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **entity_name** | **str**| | +| Name | Type | Description | Notes | +| --------------- | ------- | ----------- | ----- | +| **entity_name** | **str** | | ### Return type @@ -542,14 +540,14 @@ No authorization required ### HTTP request headers - - **Content-Type**: Not defined - - **Accept**: application/json +- **Content-Type**: Not defined +- **Accept**: application/json ### HTTP response details -| Status code | Description | Response headers | -|-------------|-------------|------------------| -**200** | Successful Response | - | -**422** | Validation Error | - | + +| Status code | Description | Response headers | +| ----------- | ------------------- | ---------------- | +| **200** | Successful Response | - | +| **422** | Validation Error | - | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) - diff --git a/pkgs/clan-cli/tests/openapi_client/docs/Entity.md b/pkgs/clan-cli/tests/openapi_client/docs/Entity.md index 18c6174..fc0e2d7 100644 --- a/pkgs/clan-cli/tests/openapi_client/docs/Entity.md +++ b/pkgs/clan-cli/tests/openapi_client/docs/Entity.md @@ -1,15 +1,15 @@ # Entity - ## Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**did** | **str** | | -**name** | **str** | | -**ip** | **str** | | -**visible** | **bool** | | -**other** | **object** | | -**attached** | **bool** | | + +| Name | Type | Description | Notes | +| ------------ | ---------- | ----------- | ----- | +| **did** | **str** | | +| **name** | **str** | | +| **ip** | **str** | | +| **visible** | **bool** | | +| **other** | **object** | | +| **attached** | **bool** | | ## Example @@ -28,6 +28,5 @@ entity_dict = entity_instance.to_dict() # create an instance of Entity from a dict entity_form_dict = entity.from_dict(entity_dict) ``` + [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) - - diff --git a/pkgs/clan-cli/tests/openapi_client/docs/EntityCreate.md b/pkgs/clan-cli/tests/openapi_client/docs/EntityCreate.md index 7cd1831..4fff16a 100644 --- a/pkgs/clan-cli/tests/openapi_client/docs/EntityCreate.md +++ b/pkgs/clan-cli/tests/openapi_client/docs/EntityCreate.md @@ -1,14 +1,14 @@ # EntityCreate - ## Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**did** | **str** | | -**name** | **str** | | -**ip** | **str** | | -**visible** | **bool** | | -**other** | **object** | | + +| Name | Type | Description | Notes | +| ----------- | ---------- | ----------- | ----- | +| **did** | **str** | | +| **name** | **str** | | +| **ip** | **str** | | +| **visible** | **bool** | | +| **other** | **object** | | ## Example @@ -27,6 +27,5 @@ entity_create_dict = entity_create_instance.to_dict() # create an instance of EntityCreate from a dict entity_create_form_dict = entity_create.from_dict(entity_create_dict) ``` + [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) - - diff --git a/pkgs/clan-cli/tests/openapi_client/docs/HTTPValidationError.md b/pkgs/clan-cli/tests/openapi_client/docs/HTTPValidationError.md index 5eee49b..d4902e7 100644 --- a/pkgs/clan-cli/tests/openapi_client/docs/HTTPValidationError.md +++ b/pkgs/clan-cli/tests/openapi_client/docs/HTTPValidationError.md @@ -1,10 +1,10 @@ # HTTPValidationError - ## Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**detail** | [**List[ValidationError]**](ValidationError.md) | | [optional] + +| Name | Type | Description | Notes | +| ---------- | ----------------------------------------------- | ----------- | ---------- | +| **detail** | [**List[ValidationError]**](ValidationError.md) | | [optional] | ## Example @@ -23,6 +23,5 @@ http_validation_error_dict = http_validation_error_instance.to_dict() # create an instance of HTTPValidationError from a dict http_validation_error_form_dict = http_validation_error.from_dict(http_validation_error_dict) ``` + [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) - - diff --git a/pkgs/clan-cli/tests/openapi_client/docs/Machine.md b/pkgs/clan-cli/tests/openapi_client/docs/Machine.md index 4ea6dc3..062fd51 100644 --- a/pkgs/clan-cli/tests/openapi_client/docs/Machine.md +++ b/pkgs/clan-cli/tests/openapi_client/docs/Machine.md @@ -1,11 +1,11 @@ # Machine - ## Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**name** | **str** | | -**status** | [**Status**](Status.md) | | + +| Name | Type | Description | Notes | +| ---------- | ----------------------- | ----------- | ----- | +| **name** | **str** | | +| **status** | [**Status**](Status.md) | | ## Example @@ -24,6 +24,5 @@ machine_dict = machine_instance.to_dict() # create an instance of Machine from a dict machine_form_dict = machine.from_dict(machine_dict) ``` + [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) - - diff --git a/pkgs/clan-cli/tests/openapi_client/docs/RepositoriesApi.md b/pkgs/clan-cli/tests/openapi_client/docs/RepositoriesApi.md index 7a24ab0..ff735f0 100644 --- a/pkgs/clan-cli/tests/openapi_client/docs/RepositoriesApi.md +++ b/pkgs/clan-cli/tests/openapi_client/docs/RepositoriesApi.md @@ -1,13 +1,13 @@ # openapi_client.RepositoriesApi -All URIs are relative to *http://localhost* - -Method | HTTP request | Description -------------- | ------------- | ------------- -[**get_all_repositories**](RepositoriesApi.md#get_all_repositories) | **GET** /api/v1/repositories | Get All Repositories +All URIs are relative to _http://localhost_ +| Method | HTTP request | Description | +| ------------------------------------------------------------------- | ---------------------------- | -------------------- | +| [**get_all_repositories**](RepositoriesApi.md#get_all_repositories) | **GET** /api/v1/repositories | Get All Repositories | # **get_all_repositories** + > List[Service] get_all_repositories(skip=skip, limit=limit) Get All Repositories @@ -45,14 +45,12 @@ with openapi_client.ApiClient(configuration) as api_client: print("Exception when calling RepositoriesApi->get_all_repositories: %s\n" % e) ``` - - ### Parameters -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **skip** | **int**| | [optional] [default to 0] - **limit** | **int**| | [optional] [default to 100] +| Name | Type | Description | Notes | +| --------- | ------- | ----------- | --------------------------- | +| **skip** | **int** | | [optional] [default to 0] | +| **limit** | **int** | | [optional] [default to 100] | ### Return type @@ -64,14 +62,14 @@ No authorization required ### HTTP request headers - - **Content-Type**: Not defined - - **Accept**: application/json +- **Content-Type**: Not defined +- **Accept**: application/json ### HTTP response details -| Status code | Description | Response headers | -|-------------|-------------|------------------| -**200** | Successful Response | - | -**422** | Validation Error | - | + +| Status code | Description | Response headers | +| ----------- | ------------------- | ---------------- | +| **200** | Successful Response | - | +| **422** | Validation Error | - | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) - diff --git a/pkgs/clan-cli/tests/openapi_client/docs/Resolution.md b/pkgs/clan-cli/tests/openapi_client/docs/Resolution.md index 27a3992..27928d5 100644 --- a/pkgs/clan-cli/tests/openapi_client/docs/Resolution.md +++ b/pkgs/clan-cli/tests/openapi_client/docs/Resolution.md @@ -1,15 +1,15 @@ # Resolution - ## Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**requester_name** | **str** | | -**requester_did** | **str** | | -**resolved_did** | **str** | | -**other** | **object** | | -**timestamp** | **datetime** | | -**id** | **int** | | + +| Name | Type | Description | Notes | +| ------------------ | ------------ | ----------- | ----- | +| **requester_name** | **str** | | +| **requester_did** | **str** | | +| **resolved_did** | **str** | | +| **other** | **object** | | +| **timestamp** | **datetime** | | +| **id** | **int** | | ## Example @@ -28,6 +28,5 @@ resolution_dict = resolution_instance.to_dict() # create an instance of Resolution from a dict resolution_form_dict = resolution.from_dict(resolution_dict) ``` + [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) - - diff --git a/pkgs/clan-cli/tests/openapi_client/docs/ResolutionApi.md b/pkgs/clan-cli/tests/openapi_client/docs/ResolutionApi.md index a2ae852..24da5fb 100644 --- a/pkgs/clan-cli/tests/openapi_client/docs/ResolutionApi.md +++ b/pkgs/clan-cli/tests/openapi_client/docs/ResolutionApi.md @@ -1,13 +1,13 @@ # openapi_client.ResolutionApi -All URIs are relative to *http://localhost* - -Method | HTTP request | Description -------------- | ------------- | ------------- -[**get_all_resolutions**](ResolutionApi.md#get_all_resolutions) | **GET** /api/v1/resolutions | Get All Resolutions +All URIs are relative to _http://localhost_ +| Method | HTTP request | Description | +| --------------------------------------------------------------- | --------------------------- | ------------------- | +| [**get_all_resolutions**](ResolutionApi.md#get_all_resolutions) | **GET** /api/v1/resolutions | Get All Resolutions | # **get_all_resolutions** + > List[Resolution] get_all_resolutions(skip=skip, limit=limit) Get All Resolutions @@ -45,14 +45,12 @@ with openapi_client.ApiClient(configuration) as api_client: print("Exception when calling ResolutionApi->get_all_resolutions: %s\n" % e) ``` - - ### Parameters -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **skip** | **int**| | [optional] [default to 0] - **limit** | **int**| | [optional] [default to 100] +| Name | Type | Description | Notes | +| --------- | ------- | ----------- | --------------------------- | +| **skip** | **int** | | [optional] [default to 0] | +| **limit** | **int** | | [optional] [default to 100] | ### Return type @@ -64,14 +62,14 @@ No authorization required ### HTTP request headers - - **Content-Type**: Not defined - - **Accept**: application/json +- **Content-Type**: Not defined +- **Accept**: application/json ### HTTP response details -| Status code | Description | Response headers | -|-------------|-------------|------------------| -**200** | Successful Response | - | -**422** | Validation Error | - | + +| Status code | Description | Response headers | +| ----------- | ------------------- | ---------------- | +| **200** | Successful Response | - | +| **422** | Validation Error | - | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) - diff --git a/pkgs/clan-cli/tests/openapi_client/docs/Service.md b/pkgs/clan-cli/tests/openapi_client/docs/Service.md index bff9e15..5798f74 100644 --- a/pkgs/clan-cli/tests/openapi_client/docs/Service.md +++ b/pkgs/clan-cli/tests/openapi_client/docs/Service.md @@ -1,17 +1,17 @@ # Service - ## Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**uuid** | **str** | | -**service_name** | **str** | | -**service_type** | **str** | | -**endpoint_url** | **str** | | -**status** | **str** | | -**other** | **object** | | -**entity_did** | **str** | | -**entity** | [**Entity**](Entity.md) | | + +| Name | Type | Description | Notes | +| ---------------- | ----------------------- | ----------- | ----- | +| **uuid** | **str** | | +| **service_name** | **str** | | +| **service_type** | **str** | | +| **endpoint_url** | **str** | | +| **status** | **str** | | +| **other** | **object** | | +| **entity_did** | **str** | | +| **entity** | [**Entity**](Entity.md) | | ## Example @@ -30,6 +30,5 @@ service_dict = service_instance.to_dict() # create an instance of Service from a dict service_form_dict = service.from_dict(service_dict) ``` + [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) - - diff --git a/pkgs/clan-cli/tests/openapi_client/docs/ServiceCreate.md b/pkgs/clan-cli/tests/openapi_client/docs/ServiceCreate.md index f8e84e1..7843b1a 100644 --- a/pkgs/clan-cli/tests/openapi_client/docs/ServiceCreate.md +++ b/pkgs/clan-cli/tests/openapi_client/docs/ServiceCreate.md @@ -1,16 +1,16 @@ # ServiceCreate - ## Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**uuid** | **str** | | -**service_name** | **str** | | -**service_type** | **str** | | -**endpoint_url** | **str** | | -**status** | **str** | | -**other** | **object** | | -**entity_did** | **str** | | + +| Name | Type | Description | Notes | +| ---------------- | ---------- | ----------- | ----- | +| **uuid** | **str** | | +| **service_name** | **str** | | +| **service_type** | **str** | | +| **endpoint_url** | **str** | | +| **status** | **str** | | +| **other** | **object** | | +| **entity_did** | **str** | | ## Example @@ -29,6 +29,5 @@ service_create_dict = service_create_instance.to_dict() # create an instance of ServiceCreate from a dict service_create_form_dict = service_create.from_dict(service_create_dict) ``` + [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) - - diff --git a/pkgs/clan-cli/tests/openapi_client/docs/ServicesApi.md b/pkgs/clan-cli/tests/openapi_client/docs/ServicesApi.md index 9a2c544..006615a 100644 --- a/pkgs/clan-cli/tests/openapi_client/docs/ServicesApi.md +++ b/pkgs/clan-cli/tests/openapi_client/docs/ServicesApi.md @@ -1,17 +1,17 @@ # openapi_client.ServicesApi -All URIs are relative to *http://localhost* - -Method | HTTP request | Description -------------- | ------------- | ------------- -[**create_service**](ServicesApi.md#create_service) | **POST** /api/v1/service | Create Service -[**delete_service**](ServicesApi.md#delete_service) | **DELETE** /api/v1/service | Delete Service -[**get_all_services**](ServicesApi.md#get_all_services) | **GET** /api/v1/services | Get All Services -[**get_service_by_did**](ServicesApi.md#get_service_by_did) | **GET** /api/v1/service | Get Service By Did -[**get_services_without_entity**](ServicesApi.md#get_services_without_entity) | **GET** /api/v1/services_without_entity | Get Services Without Entity +All URIs are relative to _http://localhost_ +| Method | HTTP request | Description | +| ----------------------------------------------------------------------------- | --------------------------------------- | --------------------------- | +| [**create_service**](ServicesApi.md#create_service) | **POST** /api/v1/service | Create Service | +| [**delete_service**](ServicesApi.md#delete_service) | **DELETE** /api/v1/service | Delete Service | +| [**get_all_services**](ServicesApi.md#get_all_services) | **GET** /api/v1/services | Get All Services | +| [**get_service_by_did**](ServicesApi.md#get_service_by_did) | **GET** /api/v1/service | Get Service By Did | +| [**get_services_without_entity**](ServicesApi.md#get_services_without_entity) | **GET** /api/v1/services_without_entity | Get Services Without Entity | # **create_service** + > Service create_service(service_create) Create Service @@ -38,7 +38,7 @@ configuration = openapi_client.Configuration( with openapi_client.ApiClient(configuration) as api_client: # Create an instance of the API class api_instance = openapi_client.ServicesApi(api_client) - service_create = openapi_client.ServiceCreate() # ServiceCreate | + service_create = openapi_client.ServiceCreate() # ServiceCreate | try: # Create Service @@ -49,13 +49,11 @@ with openapi_client.ApiClient(configuration) as api_client: print("Exception when calling ServicesApi->create_service: %s\n" % e) ``` - - ### Parameters -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **service_create** | [**ServiceCreate**](ServiceCreate.md)| | +| Name | Type | Description | Notes | +| ------------------ | ------------------------------------- | ----------- | ----- | +| **service_create** | [**ServiceCreate**](ServiceCreate.md) | | ### Return type @@ -67,18 +65,20 @@ No authorization required ### HTTP request headers - - **Content-Type**: application/json - - **Accept**: application/json +- **Content-Type**: application/json +- **Accept**: application/json ### HTTP response details -| Status code | Description | Response headers | -|-------------|-------------|------------------| -**200** | Successful Response | - | -**422** | Validation Error | - | + +| Status code | Description | Response headers | +| ----------- | ------------------- | ---------------- | +| **200** | Successful Response | - | +| **422** | Validation Error | - | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **delete_service** + > Dict[str, str] delete_service(entity_did=entity_did) Delete Service @@ -114,13 +114,11 @@ with openapi_client.ApiClient(configuration) as api_client: print("Exception when calling ServicesApi->delete_service: %s\n" % e) ``` - - ### Parameters -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **entity_did** | **str**| | [optional] [default to 'did:sov:test:1234'] +| Name | Type | Description | Notes | +| -------------- | ------- | ----------- | --------------------------------------------------- | +| **entity_did** | **str** | | [optional] [default to 'did:sov:test:1234'] | ### Return type @@ -132,18 +130,20 @@ No authorization required ### HTTP request headers - - **Content-Type**: Not defined - - **Accept**: application/json +- **Content-Type**: Not defined +- **Accept**: application/json ### HTTP response details -| Status code | Description | Response headers | -|-------------|-------------|------------------| -**200** | Successful Response | - | -**422** | Validation Error | - | + +| Status code | Description | Response headers | +| ----------- | ------------------- | ---------------- | +| **200** | Successful Response | - | +| **422** | Validation Error | - | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **get_all_services** + > List[Service] get_all_services(skip=skip, limit=limit) Get All Services @@ -181,14 +181,12 @@ with openapi_client.ApiClient(configuration) as api_client: print("Exception when calling ServicesApi->get_all_services: %s\n" % e) ``` - - ### Parameters -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **skip** | **int**| | [optional] [default to 0] - **limit** | **int**| | [optional] [default to 100] +| Name | Type | Description | Notes | +| --------- | ------- | ----------- | --------------------------- | +| **skip** | **int** | | [optional] [default to 0] | +| **limit** | **int** | | [optional] [default to 100] | ### Return type @@ -200,18 +198,20 @@ No authorization required ### HTTP request headers - - **Content-Type**: Not defined - - **Accept**: application/json +- **Content-Type**: Not defined +- **Accept**: application/json ### HTTP response details -| Status code | Description | Response headers | -|-------------|-------------|------------------| -**200** | Successful Response | - | -**422** | Validation Error | - | + +| Status code | Description | Response headers | +| ----------- | ------------------- | ---------------- | +| **200** | Successful Response | - | +| **422** | Validation Error | - | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **get_service_by_did** + > List[Service] get_service_by_did(entity_did=entity_did, skip=skip, limit=limit) Get Service By Did @@ -250,15 +250,13 @@ with openapi_client.ApiClient(configuration) as api_client: print("Exception when calling ServicesApi->get_service_by_did: %s\n" % e) ``` - - ### Parameters -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **entity_did** | **str**| | [optional] [default to 'did:sov:test:1234'] - **skip** | **int**| | [optional] [default to 0] - **limit** | **int**| | [optional] [default to 100] +| Name | Type | Description | Notes | +| -------------- | ------- | ----------- | --------------------------------------------------- | +| **entity_did** | **str** | | [optional] [default to 'did:sov:test:1234'] | +| **skip** | **int** | | [optional] [default to 0] | +| **limit** | **int** | | [optional] [default to 100] | ### Return type @@ -270,18 +268,20 @@ No authorization required ### HTTP request headers - - **Content-Type**: Not defined - - **Accept**: application/json +- **Content-Type**: Not defined +- **Accept**: application/json ### HTTP response details -| Status code | Description | Response headers | -|-------------|-------------|------------------| -**200** | Successful Response | - | -**422** | Validation Error | - | + +| Status code | Description | Response headers | +| ----------- | ------------------- | ---------------- | +| **200** | Successful Response | - | +| **422** | Validation Error | - | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **get_services_without_entity** + > List[Service] get_services_without_entity(entity_did=entity_did, skip=skip, limit=limit) Get Services Without Entity @@ -320,15 +320,13 @@ with openapi_client.ApiClient(configuration) as api_client: print("Exception when calling ServicesApi->get_services_without_entity: %s\n" % e) ``` - - ### Parameters -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **entity_did** | **str**| | [optional] [default to 'did:sov:test:1234'] - **skip** | **int**| | [optional] [default to 0] - **limit** | **int**| | [optional] [default to 100] +| Name | Type | Description | Notes | +| -------------- | ------- | ----------- | --------------------------------------------------- | +| **entity_did** | **str** | | [optional] [default to 'did:sov:test:1234'] | +| **skip** | **int** | | [optional] [default to 0] | +| **limit** | **int** | | [optional] [default to 100] | ### Return type @@ -340,14 +338,14 @@ No authorization required ### HTTP request headers - - **Content-Type**: Not defined - - **Accept**: application/json +- **Content-Type**: Not defined +- **Accept**: application/json ### HTTP response details -| Status code | Description | Response headers | -|-------------|-------------|------------------| -**200** | Successful Response | - | -**422** | Validation Error | - | + +| Status code | Description | Response headers | +| ----------- | ------------------- | ---------------- | +| **200** | Successful Response | - | +| **422** | Validation Error | - | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) - diff --git a/pkgs/clan-cli/tests/openapi_client/docs/Status.md b/pkgs/clan-cli/tests/openapi_client/docs/Status.md index 3b89cf4..10bd223 100644 --- a/pkgs/clan-cli/tests/openapi_client/docs/Status.md +++ b/pkgs/clan-cli/tests/openapi_client/docs/Status.md @@ -3,9 +3,8 @@ An enumeration. ## Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) - - diff --git a/pkgs/clan-cli/tests/openapi_client/docs/ValidationError.md b/pkgs/clan-cli/tests/openapi_client/docs/ValidationError.md index 04310f6..b57b565 100644 --- a/pkgs/clan-cli/tests/openapi_client/docs/ValidationError.md +++ b/pkgs/clan-cli/tests/openapi_client/docs/ValidationError.md @@ -1,12 +1,12 @@ # ValidationError - ## Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**loc** | [**List[ValidationErrorLocInner]**](ValidationErrorLocInner.md) | | -**msg** | **str** | | -**type** | **str** | | + +| Name | Type | Description | Notes | +| -------- | --------------------------------------------------------------- | ----------- | ----- | +| **loc** | [**List[ValidationErrorLocInner]**](ValidationErrorLocInner.md) | | +| **msg** | **str** | | +| **type** | **str** | | ## Example @@ -25,6 +25,5 @@ validation_error_dict = validation_error_instance.to_dict() # create an instance of ValidationError from a dict validation_error_form_dict = validation_error.from_dict(validation_error_dict) ``` + [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) - - diff --git a/pkgs/clan-cli/tests/openapi_client/docs/ValidationErrorLocInner.md b/pkgs/clan-cli/tests/openapi_client/docs/ValidationErrorLocInner.md index 0bae52d..04e49df 100644 --- a/pkgs/clan-cli/tests/openapi_client/docs/ValidationErrorLocInner.md +++ b/pkgs/clan-cli/tests/openapi_client/docs/ValidationErrorLocInner.md @@ -1,9 +1,9 @@ # ValidationErrorLocInner - ## Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | ## Example @@ -22,6 +22,5 @@ validation_error_loc_inner_dict = validation_error_loc_inner_instance.to_dict() # create an instance of ValidationErrorLocInner from a dict validation_error_loc_inner_form_dict = validation_error_loc_inner.from_dict(validation_error_loc_inner_dict) ``` + [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) - - From 2aa7dbcf09077cd9f467604998bc2b985c5f999f Mon Sep 17 00:00:00 2001 From: Luis-Hebendanz Date: Mon, 8 Jan 2024 19:50:38 +0100 Subject: [PATCH 44/58] Fixing static port for test. Use unused port --- pkgs/clan-cli/tests/api.py | 5 +++-- pkgs/clan-cli/tests/test_db_api.py | 6 ------ 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/pkgs/clan-cli/tests/api.py b/pkgs/clan-cli/tests/api.py index c95c1f9..026acf8 100644 --- a/pkgs/clan-cli/tests/api.py +++ b/pkgs/clan-cli/tests/api.py @@ -12,6 +12,7 @@ from openapi_client import ApiClient, Configuration from clan_cli.webui.app import app +from ports import PortFunction @pytest.fixture(scope="session") def test_client() -> TestClient: @@ -31,8 +32,8 @@ def get_health(*, url: str, max_retries: int = 20, delay: float = 0.2) -> str | # Pytest fixture to run the server in a separate process @pytest.fixture(scope="session") -def server_url() -> Generator[str, None, None]: - port = 8000 +def server_url(unused_tcp_port: PortFunction) -> Generator[str, None, None]: + port = unused_tcp_port() host = "127.0.0.1" proc = Process( target=uvicorn.run, diff --git a/pkgs/clan-cli/tests/test_db_api.py b/pkgs/clan-cli/tests/test_db_api.py index 2bb519d..cf8f479 100644 --- a/pkgs/clan-cli/tests/test_db_api.py +++ b/pkgs/clan-cli/tests/test_db_api.py @@ -26,12 +26,6 @@ def test_health(api_client: ApiClient) -> None: assert res.status == Status.ONLINE -def test_entities_empty(api_client: ApiClient) -> None: - entity = EntitiesApi(api_client=api_client) - res = entity.get_all_entities() - assert res == [] - - def create_entities(num: int = 10) -> list[EntityCreate]: res = [] for i in range(num): From f5b7c38451a8e1237e5f9050b4b652b19aca1436 Mon Sep 17 00:00:00 2001 From: Luis-Hebendanz Date: Mon, 8 Jan 2024 19:52:11 +0100 Subject: [PATCH 45/58] nix fmt --- pkgs/clan-cli/tests/api.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/clan-cli/tests/api.py b/pkgs/clan-cli/tests/api.py index 026acf8..1c3644d 100644 --- a/pkgs/clan-cli/tests/api.py +++ b/pkgs/clan-cli/tests/api.py @@ -9,10 +9,10 @@ import pytest import uvicorn from fastapi.testclient import TestClient from openapi_client import ApiClient, Configuration +from ports import PortFunction from clan_cli.webui.app import app -from ports import PortFunction @pytest.fixture(scope="session") def test_client() -> TestClient: From aab8c88fe2ae9b833a7fc942515938c59cd101dd Mon Sep 17 00:00:00 2001 From: Luis-Hebendanz Date: Mon, 8 Jan 2024 19:58:56 +0100 Subject: [PATCH 46/58] new openapi_client --- .../tests/openapi_client/api/entities_api.py | 147 ++++++++- .../tests/openapi_client/docs/DefaultApi.md | 68 ++--- .../tests/openapi_client/docs/EntitiesApi.md | 287 +++++++++++------- .../tests/openapi_client/docs/Entity.md | 22 +- .../tests/openapi_client/docs/EntityCreate.md | 19 +- .../docs/HTTPValidationError.md | 11 +- .../tests/openapi_client/docs/Machine.md | 13 +- .../openapi_client/docs/RepositoriesApi.md | 34 ++- .../tests/openapi_client/docs/Resolution.md | 21 +- .../openapi_client/docs/ResolutionApi.md | 34 ++- .../tests/openapi_client/docs/Service.md | 25 +- .../openapi_client/docs/ServiceCreate.md | 23 +- .../tests/openapi_client/docs/ServicesApi.md | 140 ++++----- .../tests/openapi_client/docs/Status.md | 7 +- .../openapi_client/docs/ValidationError.md | 15 +- .../docs/ValidationErrorLocInner.md | 9 +- .../tests/openapi_client/models/entity.py | 6 +- .../openapi_client/test/test_entities_api.py | 7 + .../tests/openapi_client/test/test_entity.py | 4 +- .../tests/openapi_client/test/test_service.py | 6 +- 20 files changed, 567 insertions(+), 331 deletions(-) diff --git a/pkgs/clan-cli/tests/openapi_client/api/entities_api.py b/pkgs/clan-cli/tests/openapi_client/api/entities_api.py index debd9c3..82431a5 100644 --- a/pkgs/clan-cli/tests/openapi_client/api/entities_api.py +++ b/pkgs/clan-cli/tests/openapi_client/api/entities_api.py @@ -486,7 +486,7 @@ class EntitiesApi: _request_auth=_params.get('_request_auth')) @validate_arguments - def detach_entity(self, entity_did : Optional[StrictStr] = None, skip : Optional[StrictInt] = None, limit : Optional[StrictInt] = None, **kwargs) -> Entity: # noqa: E501 + def detach_entity(self, entity_did : Optional[StrictStr] = None, skip : Optional[StrictInt] = None, limit : Optional[StrictInt] = None, **kwargs) -> Dict[str, str]: # noqa: E501 """Detach Entity # noqa: E501 This method makes a synchronous HTTP request by default. To make an @@ -510,7 +510,7 @@ class EntitiesApi: :return: Returns the result object. If the method is called asynchronously, returns the request thread. - :rtype: Entity + :rtype: Dict[str, str] """ kwargs['_return_http_data_only'] = True if '_preload_content' in kwargs: @@ -556,7 +556,7 @@ class EntitiesApi: :return: Returns the result object. If the method is called asynchronously, returns the request thread. - :rtype: tuple(Entity, status_code(int), headers(HTTPHeaderDict)) + :rtype: tuple(Dict[str, str], status_code(int), headers(HTTPHeaderDict)) """ _params = locals() @@ -619,7 +619,7 @@ class EntitiesApi: _auth_settings = [] # noqa: E501 _response_types_map = { - '200': "Entity", + '200': "Dict[str, str]", '422': "HTTPValidationError", } @@ -1211,3 +1211,142 @@ class EntitiesApi: _request_timeout=_params.get('_request_timeout'), collection_formats=_collection_formats, _request_auth=_params.get('_request_auth')) + + @validate_arguments + def is_attached(self, entity_did : Optional[StrictStr] = None, **kwargs) -> Dict[str, str]: # noqa: E501 + """Is Attached # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.is_attached(entity_did, async_req=True) + >>> result = thread.get() + + :param entity_did: + :type entity_did: str + :param async_req: Whether to execute the request asynchronously. + :type async_req: bool, optional + :param _request_timeout: timeout setting for this request. + If one number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :return: Returns the result object. + If the method is called asynchronously, + returns the request thread. + :rtype: Dict[str, str] + """ + kwargs['_return_http_data_only'] = True + if '_preload_content' in kwargs: + message = "Error! Please call the is_attached_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data" # noqa: E501 + raise ValueError(message) + return self.is_attached_with_http_info(entity_did, **kwargs) # noqa: E501 + + @validate_arguments + def is_attached_with_http_info(self, entity_did : Optional[StrictStr] = None, **kwargs) -> ApiResponse: # noqa: E501 + """Is Attached # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.is_attached_with_http_info(entity_did, async_req=True) + >>> result = thread.get() + + :param entity_did: + :type entity_did: str + :param async_req: Whether to execute the request asynchronously. + :type async_req: bool, optional + :param _preload_content: if False, the ApiResponse.data will + be set to none and raw_data will store the + HTTP response body without reading/decoding. + Default is True. + :type _preload_content: bool, optional + :param _return_http_data_only: response data instead of ApiResponse + object with status code, headers, etc + :type _return_http_data_only: bool, optional + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the authentication + in the spec for a single request. + :type _request_auth: dict, optional + :type _content_type: string, optional: force content-type for the request + :return: Returns the result object. + If the method is called asynchronously, + returns the request thread. + :rtype: tuple(Dict[str, str], status_code(int), headers(HTTPHeaderDict)) + """ + + _params = locals() + + _all_params = [ + 'entity_did' + ] + _all_params.extend( + [ + 'async_req', + '_return_http_data_only', + '_preload_content', + '_request_timeout', + '_request_auth', + '_content_type', + '_headers' + ] + ) + + # validate the arguments + for _key, _val in _params['kwargs'].items(): + if _key not in _all_params: + raise ApiTypeError( + "Got an unexpected keyword argument '%s'" + " to method is_attached" % _key + ) + _params[_key] = _val + del _params['kwargs'] + + _collection_formats = {} + + # process the path parameters + _path_params = {} + + # process the query parameters + _query_params = [] + if _params.get('entity_did') is not None: # noqa: E501 + _query_params.append(('entity_did', _params['entity_did'])) + + # process the header parameters + _header_params = dict(_params.get('_headers', {})) + # process the form parameters + _form_params = [] + _files = {} + # process the body parameter + _body_params = None + # set the HTTP header `Accept` + _header_params['Accept'] = self.api_client.select_header_accept( + ['application/json']) # noqa: E501 + + # authentication setting + _auth_settings = [] # noqa: E501 + + _response_types_map = { + '200': "Dict[str, str]", + '422': "HTTPValidationError", + } + + return self.api_client.call_api( + '/api/v1/is_attached', 'GET', + _path_params, + _query_params, + _header_params, + body=_body_params, + post_params=_form_params, + files=_files, + response_types_map=_response_types_map, + auth_settings=_auth_settings, + async_req=_params.get('async_req'), + _return_http_data_only=_params.get('_return_http_data_only'), # noqa: E501 + _preload_content=_params.get('_preload_content', True), + _request_timeout=_params.get('_request_timeout'), + collection_formats=_collection_formats, + _request_auth=_params.get('_request_auth')) diff --git a/pkgs/clan-cli/tests/openapi_client/docs/DefaultApi.md b/pkgs/clan-cli/tests/openapi_client/docs/DefaultApi.md index aef64f7..9a4a45c 100644 --- a/pkgs/clan-cli/tests/openapi_client/docs/DefaultApi.md +++ b/pkgs/clan-cli/tests/openapi_client/docs/DefaultApi.md @@ -1,15 +1,15 @@ # openapi_client.DefaultApi -All URIs are relative to _http://localhost_ +All URIs are relative to *http://localhost* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**get**](DefaultApi.md#get) | **GET** /ws2_example | Get +[**health**](DefaultApi.md#health) | **GET** /health | Health +[**root**](DefaultApi.md#root) | **GET** /{path_name} | Root -| Method | HTTP request | Description | -| ---------------------------------- | -------------------- | ----------- | -| [**get**](DefaultApi.md#get) | **GET** /ws2_example | Get | -| [**health**](DefaultApi.md#health) | **GET** /health | Health | -| [**root**](DefaultApi.md#root) | **GET** /{path_name} | Root | # **get** - > get() Get @@ -42,8 +42,9 @@ with openapi_client.ApiClient(configuration) as api_client: print("Exception when calling DefaultApi->get: %s\n" % e) ``` -### Parameters + +### Parameters This endpoint does not need any parameter. ### Return type @@ -56,19 +57,17 @@ No authorization required ### HTTP request headers -- **Content-Type**: Not defined -- **Accept**: application/json + - **Content-Type**: Not defined + - **Accept**: application/json ### HTTP response details - -| Status code | Description | Response headers | -| ----------- | ------------------- | ---------------- | -| **200** | Successful Response | - | +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | Successful Response | - | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **health** - > Machine health() Health @@ -104,8 +103,9 @@ with openapi_client.ApiClient(configuration) as api_client: print("Exception when calling DefaultApi->health: %s\n" % e) ``` -### Parameters + +### Parameters This endpoint does not need any parameter. ### Return type @@ -118,19 +118,17 @@ No authorization required ### HTTP request headers -- **Content-Type**: Not defined -- **Accept**: application/json + - **Content-Type**: Not defined + - **Accept**: application/json ### HTTP response details - -| Status code | Description | Response headers | -| ----------- | ------------------- | ---------------- | -| **200** | Successful Response | - | +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | Successful Response | - | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **root** - > root(path_name) Root @@ -155,7 +153,7 @@ configuration = openapi_client.Configuration( with openapi_client.ApiClient(configuration) as api_client: # Create an instance of the API class api_instance = openapi_client.DefaultApi(api_client) - path_name = 'path_name_example' # str | + path_name = 'path_name_example' # str | try: # Root @@ -164,11 +162,13 @@ with openapi_client.ApiClient(configuration) as api_client: print("Exception when calling DefaultApi->root: %s\n" % e) ``` + + ### Parameters -| Name | Type | Description | Notes | -| ------------- | ------- | ----------- | ----- | -| **path_name** | **str** | | +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **path_name** | **str**| | ### Return type @@ -180,14 +180,14 @@ No authorization required ### HTTP request headers -- **Content-Type**: Not defined -- **Accept**: application/json + - **Content-Type**: Not defined + - **Accept**: application/json ### HTTP response details - -| Status code | Description | Response headers | -| ----------- | ------------------- | ---------------- | -| **200** | Successful Response | - | -| **422** | Validation Error | - | +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | Successful Response | - | +**422** | Validation Error | - | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + diff --git a/pkgs/clan-cli/tests/openapi_client/docs/EntitiesApi.md b/pkgs/clan-cli/tests/openapi_client/docs/EntitiesApi.md index ccb0216..4a99b6c 100644 --- a/pkgs/clan-cli/tests/openapi_client/docs/EntitiesApi.md +++ b/pkgs/clan-cli/tests/openapi_client/docs/EntitiesApi.md @@ -1,20 +1,21 @@ # openapi_client.EntitiesApi -All URIs are relative to _http://localhost_ +All URIs are relative to *http://localhost* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**attach_entity**](EntitiesApi.md#attach_entity) | **POST** /api/v1/attach | Attach Entity +[**create_entity**](EntitiesApi.md#create_entity) | **POST** /api/v1/entity | Create Entity +[**delete_entity**](EntitiesApi.md#delete_entity) | **DELETE** /api/v1/entity | Delete Entity +[**detach_entity**](EntitiesApi.md#detach_entity) | **POST** /api/v1/detach | Detach Entity +[**get_all_entities**](EntitiesApi.md#get_all_entities) | **GET** /api/v1/entities | Get All Entities +[**get_attached_entities**](EntitiesApi.md#get_attached_entities) | **GET** /api/v1/attached_entities | Get Attached Entities +[**get_entity_by_did**](EntitiesApi.md#get_entity_by_did) | **GET** /api/v1/entity | Get Entity By Did +[**get_entity_by_name**](EntitiesApi.md#get_entity_by_name) | **GET** /api/v1/entity_by_name | Get Entity By Name +[**is_attached**](EntitiesApi.md#is_attached) | **GET** /api/v1/is_attached | Is Attached -| Method | HTTP request | Description | -| ----------------------------------------------------------------- | --------------------------------- | --------------------- | -| [**attach_entity**](EntitiesApi.md#attach_entity) | **POST** /api/v1/attach | Attach Entity | -| [**create_entity**](EntitiesApi.md#create_entity) | **POST** /api/v1/entity | Create Entity | -| [**delete_entity**](EntitiesApi.md#delete_entity) | **DELETE** /api/v1/entity | Delete Entity | -| [**detach_entity**](EntitiesApi.md#detach_entity) | **POST** /api/v1/detach | Detach Entity | -| [**get_all_entities**](EntitiesApi.md#get_all_entities) | **GET** /api/v1/entities | Get All Entities | -| [**get_attached_entities**](EntitiesApi.md#get_attached_entities) | **GET** /api/v1/attached_entities | Get Attached Entities | -| [**get_entity_by_did**](EntitiesApi.md#get_entity_by_did) | **GET** /api/v1/entity | Get Entity By Did | -| [**get_entity_by_name**](EntitiesApi.md#get_entity_by_name) | **GET** /api/v1/entity_by_name | Get Entity By Name | # **attach_entity** - > Dict[str, str] attach_entity(entity_did=entity_did, skip=skip, limit=limit) Attach Entity @@ -52,13 +53,15 @@ with openapi_client.ApiClient(configuration) as api_client: print("Exception when calling EntitiesApi->attach_entity: %s\n" % e) ``` + + ### Parameters -| Name | Type | Description | Notes | -| -------------- | ------- | ----------- | --------------------------------------------------- | -| **entity_did** | **str** | | [optional] [default to 'did:sov:test:1234'] | -| **skip** | **int** | | [optional] [default to 0] | -| **limit** | **int** | | [optional] [default to 100] | +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **entity_did** | **str**| | [optional] [default to 'did:sov:test:1234'] + **skip** | **int**| | [optional] [default to 0] + **limit** | **int**| | [optional] [default to 100] ### Return type @@ -70,20 +73,18 @@ No authorization required ### HTTP request headers -- **Content-Type**: Not defined -- **Accept**: application/json + - **Content-Type**: Not defined + - **Accept**: application/json ### HTTP response details - -| Status code | Description | Response headers | -| ----------- | ------------------- | ---------------- | -| **200** | Successful Response | - | -| **422** | Validation Error | - | +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | Successful Response | - | +**422** | Validation Error | - | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **create_entity** - > Entity create_entity(entity_create) Create Entity @@ -110,7 +111,7 @@ configuration = openapi_client.Configuration( with openapi_client.ApiClient(configuration) as api_client: # Create an instance of the API class api_instance = openapi_client.EntitiesApi(api_client) - entity_create = openapi_client.EntityCreate() # EntityCreate | + entity_create = openapi_client.EntityCreate() # EntityCreate | try: # Create Entity @@ -121,11 +122,13 @@ with openapi_client.ApiClient(configuration) as api_client: print("Exception when calling EntitiesApi->create_entity: %s\n" % e) ``` + + ### Parameters -| Name | Type | Description | Notes | -| ----------------- | ----------------------------------- | ----------- | ----- | -| **entity_create** | [**EntityCreate**](EntityCreate.md) | | +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **entity_create** | [**EntityCreate**](EntityCreate.md)| | ### Return type @@ -137,20 +140,18 @@ No authorization required ### HTTP request headers -- **Content-Type**: application/json -- **Accept**: application/json + - **Content-Type**: application/json + - **Accept**: application/json ### HTTP response details - -| Status code | Description | Response headers | -| ----------- | ------------------- | ---------------- | -| **200** | Successful Response | - | -| **422** | Validation Error | - | +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | Successful Response | - | +**422** | Validation Error | - | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **delete_entity** - > Dict[str, str] delete_entity(entity_did=entity_did) Delete Entity @@ -186,11 +187,13 @@ with openapi_client.ApiClient(configuration) as api_client: print("Exception when calling EntitiesApi->delete_entity: %s\n" % e) ``` + + ### Parameters -| Name | Type | Description | Notes | -| -------------- | ------- | ----------- | --------------------------------------------------- | -| **entity_did** | **str** | | [optional] [default to 'did:sov:test:1234'] | +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **entity_did** | **str**| | [optional] [default to 'did:sov:test:1234'] ### Return type @@ -202,21 +205,19 @@ No authorization required ### HTTP request headers -- **Content-Type**: Not defined -- **Accept**: application/json + - **Content-Type**: Not defined + - **Accept**: application/json ### HTTP response details - -| Status code | Description | Response headers | -| ----------- | ------------------- | ---------------- | -| **200** | Successful Response | - | -| **422** | Validation Error | - | +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | Successful Response | - | +**422** | Validation Error | - | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **detach_entity** - -> Entity detach_entity(entity_did=entity_did, skip=skip, limit=limit) +> Dict[str, str] detach_entity(entity_did=entity_did, skip=skip, limit=limit) Detach Entity @@ -226,7 +227,6 @@ Detach Entity import time import os import openapi_client -from openapi_client.models.entity import Entity from openapi_client.rest import ApiException from pprint import pprint @@ -254,17 +254,19 @@ with openapi_client.ApiClient(configuration) as api_client: print("Exception when calling EntitiesApi->detach_entity: %s\n" % e) ``` + + ### Parameters -| Name | Type | Description | Notes | -| -------------- | ------- | ----------- | --------------------------------------------------- | -| **entity_did** | **str** | | [optional] [default to 'did:sov:test:1234'] | -| **skip** | **int** | | [optional] [default to 0] | -| **limit** | **int** | | [optional] [default to 100] | +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **entity_did** | **str**| | [optional] [default to 'did:sov:test:1234'] + **skip** | **int**| | [optional] [default to 0] + **limit** | **int**| | [optional] [default to 100] ### Return type -[**Entity**](Entity.md) +**Dict[str, str]** ### Authorization @@ -272,20 +274,18 @@ No authorization required ### HTTP request headers -- **Content-Type**: Not defined -- **Accept**: application/json + - **Content-Type**: Not defined + - **Accept**: application/json ### HTTP response details - -| Status code | Description | Response headers | -| ----------- | ------------------- | ---------------- | -| **200** | Successful Response | - | -| **422** | Validation Error | - | +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | Successful Response | - | +**422** | Validation Error | - | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **get_all_entities** - > List[Entity] get_all_entities(skip=skip, limit=limit) Get All Entities @@ -323,12 +323,14 @@ with openapi_client.ApiClient(configuration) as api_client: print("Exception when calling EntitiesApi->get_all_entities: %s\n" % e) ``` + + ### Parameters -| Name | Type | Description | Notes | -| --------- | ------- | ----------- | --------------------------- | -| **skip** | **int** | | [optional] [default to 0] | -| **limit** | **int** | | [optional] [default to 100] | +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **skip** | **int**| | [optional] [default to 0] + **limit** | **int**| | [optional] [default to 100] ### Return type @@ -340,20 +342,18 @@ No authorization required ### HTTP request headers -- **Content-Type**: Not defined -- **Accept**: application/json + - **Content-Type**: Not defined + - **Accept**: application/json ### HTTP response details - -| Status code | Description | Response headers | -| ----------- | ------------------- | ---------------- | -| **200** | Successful Response | - | -| **422** | Validation Error | - | +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | Successful Response | - | +**422** | Validation Error | - | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **get_attached_entities** - > List[Entity] get_attached_entities(skip=skip, limit=limit) Get Attached Entities @@ -391,12 +391,14 @@ with openapi_client.ApiClient(configuration) as api_client: print("Exception when calling EntitiesApi->get_attached_entities: %s\n" % e) ``` + + ### Parameters -| Name | Type | Description | Notes | -| --------- | ------- | ----------- | --------------------------- | -| **skip** | **int** | | [optional] [default to 0] | -| **limit** | **int** | | [optional] [default to 100] | +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **skip** | **int**| | [optional] [default to 0] + **limit** | **int**| | [optional] [default to 100] ### Return type @@ -408,20 +410,18 @@ No authorization required ### HTTP request headers -- **Content-Type**: Not defined -- **Accept**: application/json + - **Content-Type**: Not defined + - **Accept**: application/json ### HTTP response details - -| Status code | Description | Response headers | -| ----------- | ------------------- | ---------------- | -| **200** | Successful Response | - | -| **422** | Validation Error | - | +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | Successful Response | - | +**422** | Validation Error | - | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **get_entity_by_did** - > Entity get_entity_by_did(entity_did=entity_did) Get Entity By Did @@ -458,11 +458,13 @@ with openapi_client.ApiClient(configuration) as api_client: print("Exception when calling EntitiesApi->get_entity_by_did: %s\n" % e) ``` + + ### Parameters -| Name | Type | Description | Notes | -| -------------- | ------- | ----------- | --------------------------------------------------- | -| **entity_did** | **str** | | [optional] [default to 'did:sov:test:1234'] | +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **entity_did** | **str**| | [optional] [default to 'did:sov:test:1234'] ### Return type @@ -474,20 +476,18 @@ No authorization required ### HTTP request headers -- **Content-Type**: Not defined -- **Accept**: application/json + - **Content-Type**: Not defined + - **Accept**: application/json ### HTTP response details - -| Status code | Description | Response headers | -| ----------- | ------------------- | ---------------- | -| **200** | Successful Response | - | -| **422** | Validation Error | - | +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | Successful Response | - | +**422** | Validation Error | - | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **get_entity_by_name** - > Entity get_entity_by_name(entity_name) Get Entity By Name @@ -513,7 +513,7 @@ configuration = openapi_client.Configuration( with openapi_client.ApiClient(configuration) as api_client: # Create an instance of the API class api_instance = openapi_client.EntitiesApi(api_client) - entity_name = 'entity_name_example' # str | + entity_name = 'entity_name_example' # str | try: # Get Entity By Name @@ -524,11 +524,13 @@ with openapi_client.ApiClient(configuration) as api_client: print("Exception when calling EntitiesApi->get_entity_by_name: %s\n" % e) ``` + + ### Parameters -| Name | Type | Description | Notes | -| --------------- | ------- | ----------- | ----- | -| **entity_name** | **str** | | +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **entity_name** | **str**| | ### Return type @@ -540,14 +542,79 @@ No authorization required ### HTTP request headers -- **Content-Type**: Not defined -- **Accept**: application/json + - **Content-Type**: Not defined + - **Accept**: application/json ### HTTP response details - -| Status code | Description | Response headers | -| ----------- | ------------------- | ---------------- | -| **200** | Successful Response | - | -| **422** | Validation Error | - | +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | Successful Response | - | +**422** | Validation Error | - | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **is_attached** +> Dict[str, str] is_attached(entity_did=entity_did) + +Is Attached + +### Example + +```python +import time +import os +import openapi_client +from openapi_client.rest import ApiException +from pprint import pprint + +# Defining the host is optional and defaults to http://localhost +# See configuration.py for a list of all supported configuration parameters. +configuration = openapi_client.Configuration( + host = "http://localhost" +) + + +# Enter a context with an instance of the API client +with openapi_client.ApiClient(configuration) as api_client: + # Create an instance of the API class + api_instance = openapi_client.EntitiesApi(api_client) + entity_did = 'did:sov:test:1234' # str | (optional) (default to 'did:sov:test:1234') + + try: + # Is Attached + api_response = api_instance.is_attached(entity_did=entity_did) + print("The response of EntitiesApi->is_attached:\n") + pprint(api_response) + except Exception as e: + print("Exception when calling EntitiesApi->is_attached: %s\n" % e) +``` + + + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **entity_did** | **str**| | [optional] [default to 'did:sov:test:1234'] + +### Return type + +**Dict[str, str]** + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | Successful Response | - | +**422** | Validation Error | - | + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + diff --git a/pkgs/clan-cli/tests/openapi_client/docs/Entity.md b/pkgs/clan-cli/tests/openapi_client/docs/Entity.md index fc0e2d7..ed3b3be 100644 --- a/pkgs/clan-cli/tests/openapi_client/docs/Entity.md +++ b/pkgs/clan-cli/tests/openapi_client/docs/Entity.md @@ -1,15 +1,16 @@ # Entity -## Properties -| Name | Type | Description | Notes | -| ------------ | ---------- | ----------- | ----- | -| **did** | **str** | | -| **name** | **str** | | -| **ip** | **str** | | -| **visible** | **bool** | | -| **other** | **object** | | -| **attached** | **bool** | | +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**did** | **str** | | +**name** | **str** | | +**ip** | **str** | | +**visible** | **bool** | | +**other** | **object** | | +**attached** | **bool** | | +**stop_health_task** | **bool** | | ## Example @@ -28,5 +29,6 @@ entity_dict = entity_instance.to_dict() # create an instance of Entity from a dict entity_form_dict = entity.from_dict(entity_dict) ``` - [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/pkgs/clan-cli/tests/openapi_client/docs/EntityCreate.md b/pkgs/clan-cli/tests/openapi_client/docs/EntityCreate.md index 4fff16a..7cd1831 100644 --- a/pkgs/clan-cli/tests/openapi_client/docs/EntityCreate.md +++ b/pkgs/clan-cli/tests/openapi_client/docs/EntityCreate.md @@ -1,14 +1,14 @@ # EntityCreate -## Properties -| Name | Type | Description | Notes | -| ----------- | ---------- | ----------- | ----- | -| **did** | **str** | | -| **name** | **str** | | -| **ip** | **str** | | -| **visible** | **bool** | | -| **other** | **object** | | +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**did** | **str** | | +**name** | **str** | | +**ip** | **str** | | +**visible** | **bool** | | +**other** | **object** | | ## Example @@ -27,5 +27,6 @@ entity_create_dict = entity_create_instance.to_dict() # create an instance of EntityCreate from a dict entity_create_form_dict = entity_create.from_dict(entity_create_dict) ``` - [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/pkgs/clan-cli/tests/openapi_client/docs/HTTPValidationError.md b/pkgs/clan-cli/tests/openapi_client/docs/HTTPValidationError.md index d4902e7..5eee49b 100644 --- a/pkgs/clan-cli/tests/openapi_client/docs/HTTPValidationError.md +++ b/pkgs/clan-cli/tests/openapi_client/docs/HTTPValidationError.md @@ -1,10 +1,10 @@ # HTTPValidationError -## Properties -| Name | Type | Description | Notes | -| ---------- | ----------------------------------------------- | ----------- | ---------- | -| **detail** | [**List[ValidationError]**](ValidationError.md) | | [optional] | +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**detail** | [**List[ValidationError]**](ValidationError.md) | | [optional] ## Example @@ -23,5 +23,6 @@ http_validation_error_dict = http_validation_error_instance.to_dict() # create an instance of HTTPValidationError from a dict http_validation_error_form_dict = http_validation_error.from_dict(http_validation_error_dict) ``` - [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/pkgs/clan-cli/tests/openapi_client/docs/Machine.md b/pkgs/clan-cli/tests/openapi_client/docs/Machine.md index 062fd51..4ea6dc3 100644 --- a/pkgs/clan-cli/tests/openapi_client/docs/Machine.md +++ b/pkgs/clan-cli/tests/openapi_client/docs/Machine.md @@ -1,11 +1,11 @@ # Machine -## Properties -| Name | Type | Description | Notes | -| ---------- | ----------------------- | ----------- | ----- | -| **name** | **str** | | -| **status** | [**Status**](Status.md) | | +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**name** | **str** | | +**status** | [**Status**](Status.md) | | ## Example @@ -24,5 +24,6 @@ machine_dict = machine_instance.to_dict() # create an instance of Machine from a dict machine_form_dict = machine.from_dict(machine_dict) ``` - [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/pkgs/clan-cli/tests/openapi_client/docs/RepositoriesApi.md b/pkgs/clan-cli/tests/openapi_client/docs/RepositoriesApi.md index ff735f0..7a24ab0 100644 --- a/pkgs/clan-cli/tests/openapi_client/docs/RepositoriesApi.md +++ b/pkgs/clan-cli/tests/openapi_client/docs/RepositoriesApi.md @@ -1,13 +1,13 @@ # openapi_client.RepositoriesApi -All URIs are relative to _http://localhost_ +All URIs are relative to *http://localhost* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**get_all_repositories**](RepositoriesApi.md#get_all_repositories) | **GET** /api/v1/repositories | Get All Repositories -| Method | HTTP request | Description | -| ------------------------------------------------------------------- | ---------------------------- | -------------------- | -| [**get_all_repositories**](RepositoriesApi.md#get_all_repositories) | **GET** /api/v1/repositories | Get All Repositories | # **get_all_repositories** - > List[Service] get_all_repositories(skip=skip, limit=limit) Get All Repositories @@ -45,12 +45,14 @@ with openapi_client.ApiClient(configuration) as api_client: print("Exception when calling RepositoriesApi->get_all_repositories: %s\n" % e) ``` + + ### Parameters -| Name | Type | Description | Notes | -| --------- | ------- | ----------- | --------------------------- | -| **skip** | **int** | | [optional] [default to 0] | -| **limit** | **int** | | [optional] [default to 100] | +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **skip** | **int**| | [optional] [default to 0] + **limit** | **int**| | [optional] [default to 100] ### Return type @@ -62,14 +64,14 @@ No authorization required ### HTTP request headers -- **Content-Type**: Not defined -- **Accept**: application/json + - **Content-Type**: Not defined + - **Accept**: application/json ### HTTP response details - -| Status code | Description | Response headers | -| ----------- | ------------------- | ---------------- | -| **200** | Successful Response | - | -| **422** | Validation Error | - | +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | Successful Response | - | +**422** | Validation Error | - | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + diff --git a/pkgs/clan-cli/tests/openapi_client/docs/Resolution.md b/pkgs/clan-cli/tests/openapi_client/docs/Resolution.md index 27928d5..27a3992 100644 --- a/pkgs/clan-cli/tests/openapi_client/docs/Resolution.md +++ b/pkgs/clan-cli/tests/openapi_client/docs/Resolution.md @@ -1,15 +1,15 @@ # Resolution -## Properties -| Name | Type | Description | Notes | -| ------------------ | ------------ | ----------- | ----- | -| **requester_name** | **str** | | -| **requester_did** | **str** | | -| **resolved_did** | **str** | | -| **other** | **object** | | -| **timestamp** | **datetime** | | -| **id** | **int** | | +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**requester_name** | **str** | | +**requester_did** | **str** | | +**resolved_did** | **str** | | +**other** | **object** | | +**timestamp** | **datetime** | | +**id** | **int** | | ## Example @@ -28,5 +28,6 @@ resolution_dict = resolution_instance.to_dict() # create an instance of Resolution from a dict resolution_form_dict = resolution.from_dict(resolution_dict) ``` - [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/pkgs/clan-cli/tests/openapi_client/docs/ResolutionApi.md b/pkgs/clan-cli/tests/openapi_client/docs/ResolutionApi.md index 24da5fb..a2ae852 100644 --- a/pkgs/clan-cli/tests/openapi_client/docs/ResolutionApi.md +++ b/pkgs/clan-cli/tests/openapi_client/docs/ResolutionApi.md @@ -1,13 +1,13 @@ # openapi_client.ResolutionApi -All URIs are relative to _http://localhost_ +All URIs are relative to *http://localhost* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**get_all_resolutions**](ResolutionApi.md#get_all_resolutions) | **GET** /api/v1/resolutions | Get All Resolutions -| Method | HTTP request | Description | -| --------------------------------------------------------------- | --------------------------- | ------------------- | -| [**get_all_resolutions**](ResolutionApi.md#get_all_resolutions) | **GET** /api/v1/resolutions | Get All Resolutions | # **get_all_resolutions** - > List[Resolution] get_all_resolutions(skip=skip, limit=limit) Get All Resolutions @@ -45,12 +45,14 @@ with openapi_client.ApiClient(configuration) as api_client: print("Exception when calling ResolutionApi->get_all_resolutions: %s\n" % e) ``` + + ### Parameters -| Name | Type | Description | Notes | -| --------- | ------- | ----------- | --------------------------- | -| **skip** | **int** | | [optional] [default to 0] | -| **limit** | **int** | | [optional] [default to 100] | +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **skip** | **int**| | [optional] [default to 0] + **limit** | **int**| | [optional] [default to 100] ### Return type @@ -62,14 +64,14 @@ No authorization required ### HTTP request headers -- **Content-Type**: Not defined -- **Accept**: application/json + - **Content-Type**: Not defined + - **Accept**: application/json ### HTTP response details - -| Status code | Description | Response headers | -| ----------- | ------------------- | ---------------- | -| **200** | Successful Response | - | -| **422** | Validation Error | - | +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | Successful Response | - | +**422** | Validation Error | - | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + diff --git a/pkgs/clan-cli/tests/openapi_client/docs/Service.md b/pkgs/clan-cli/tests/openapi_client/docs/Service.md index 5798f74..bff9e15 100644 --- a/pkgs/clan-cli/tests/openapi_client/docs/Service.md +++ b/pkgs/clan-cli/tests/openapi_client/docs/Service.md @@ -1,17 +1,17 @@ # Service -## Properties -| Name | Type | Description | Notes | -| ---------------- | ----------------------- | ----------- | ----- | -| **uuid** | **str** | | -| **service_name** | **str** | | -| **service_type** | **str** | | -| **endpoint_url** | **str** | | -| **status** | **str** | | -| **other** | **object** | | -| **entity_did** | **str** | | -| **entity** | [**Entity**](Entity.md) | | +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**uuid** | **str** | | +**service_name** | **str** | | +**service_type** | **str** | | +**endpoint_url** | **str** | | +**status** | **str** | | +**other** | **object** | | +**entity_did** | **str** | | +**entity** | [**Entity**](Entity.md) | | ## Example @@ -30,5 +30,6 @@ service_dict = service_instance.to_dict() # create an instance of Service from a dict service_form_dict = service.from_dict(service_dict) ``` - [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/pkgs/clan-cli/tests/openapi_client/docs/ServiceCreate.md b/pkgs/clan-cli/tests/openapi_client/docs/ServiceCreate.md index 7843b1a..f8e84e1 100644 --- a/pkgs/clan-cli/tests/openapi_client/docs/ServiceCreate.md +++ b/pkgs/clan-cli/tests/openapi_client/docs/ServiceCreate.md @@ -1,16 +1,16 @@ # ServiceCreate -## Properties -| Name | Type | Description | Notes | -| ---------------- | ---------- | ----------- | ----- | -| **uuid** | **str** | | -| **service_name** | **str** | | -| **service_type** | **str** | | -| **endpoint_url** | **str** | | -| **status** | **str** | | -| **other** | **object** | | -| **entity_did** | **str** | | +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**uuid** | **str** | | +**service_name** | **str** | | +**service_type** | **str** | | +**endpoint_url** | **str** | | +**status** | **str** | | +**other** | **object** | | +**entity_did** | **str** | | ## Example @@ -29,5 +29,6 @@ service_create_dict = service_create_instance.to_dict() # create an instance of ServiceCreate from a dict service_create_form_dict = service_create.from_dict(service_create_dict) ``` - [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/pkgs/clan-cli/tests/openapi_client/docs/ServicesApi.md b/pkgs/clan-cli/tests/openapi_client/docs/ServicesApi.md index 006615a..9a2c544 100644 --- a/pkgs/clan-cli/tests/openapi_client/docs/ServicesApi.md +++ b/pkgs/clan-cli/tests/openapi_client/docs/ServicesApi.md @@ -1,17 +1,17 @@ # openapi_client.ServicesApi -All URIs are relative to _http://localhost_ +All URIs are relative to *http://localhost* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**create_service**](ServicesApi.md#create_service) | **POST** /api/v1/service | Create Service +[**delete_service**](ServicesApi.md#delete_service) | **DELETE** /api/v1/service | Delete Service +[**get_all_services**](ServicesApi.md#get_all_services) | **GET** /api/v1/services | Get All Services +[**get_service_by_did**](ServicesApi.md#get_service_by_did) | **GET** /api/v1/service | Get Service By Did +[**get_services_without_entity**](ServicesApi.md#get_services_without_entity) | **GET** /api/v1/services_without_entity | Get Services Without Entity -| Method | HTTP request | Description | -| ----------------------------------------------------------------------------- | --------------------------------------- | --------------------------- | -| [**create_service**](ServicesApi.md#create_service) | **POST** /api/v1/service | Create Service | -| [**delete_service**](ServicesApi.md#delete_service) | **DELETE** /api/v1/service | Delete Service | -| [**get_all_services**](ServicesApi.md#get_all_services) | **GET** /api/v1/services | Get All Services | -| [**get_service_by_did**](ServicesApi.md#get_service_by_did) | **GET** /api/v1/service | Get Service By Did | -| [**get_services_without_entity**](ServicesApi.md#get_services_without_entity) | **GET** /api/v1/services_without_entity | Get Services Without Entity | # **create_service** - > Service create_service(service_create) Create Service @@ -38,7 +38,7 @@ configuration = openapi_client.Configuration( with openapi_client.ApiClient(configuration) as api_client: # Create an instance of the API class api_instance = openapi_client.ServicesApi(api_client) - service_create = openapi_client.ServiceCreate() # ServiceCreate | + service_create = openapi_client.ServiceCreate() # ServiceCreate | try: # Create Service @@ -49,11 +49,13 @@ with openapi_client.ApiClient(configuration) as api_client: print("Exception when calling ServicesApi->create_service: %s\n" % e) ``` + + ### Parameters -| Name | Type | Description | Notes | -| ------------------ | ------------------------------------- | ----------- | ----- | -| **service_create** | [**ServiceCreate**](ServiceCreate.md) | | +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **service_create** | [**ServiceCreate**](ServiceCreate.md)| | ### Return type @@ -65,20 +67,18 @@ No authorization required ### HTTP request headers -- **Content-Type**: application/json -- **Accept**: application/json + - **Content-Type**: application/json + - **Accept**: application/json ### HTTP response details - -| Status code | Description | Response headers | -| ----------- | ------------------- | ---------------- | -| **200** | Successful Response | - | -| **422** | Validation Error | - | +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | Successful Response | - | +**422** | Validation Error | - | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **delete_service** - > Dict[str, str] delete_service(entity_did=entity_did) Delete Service @@ -114,11 +114,13 @@ with openapi_client.ApiClient(configuration) as api_client: print("Exception when calling ServicesApi->delete_service: %s\n" % e) ``` + + ### Parameters -| Name | Type | Description | Notes | -| -------------- | ------- | ----------- | --------------------------------------------------- | -| **entity_did** | **str** | | [optional] [default to 'did:sov:test:1234'] | +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **entity_did** | **str**| | [optional] [default to 'did:sov:test:1234'] ### Return type @@ -130,20 +132,18 @@ No authorization required ### HTTP request headers -- **Content-Type**: Not defined -- **Accept**: application/json + - **Content-Type**: Not defined + - **Accept**: application/json ### HTTP response details - -| Status code | Description | Response headers | -| ----------- | ------------------- | ---------------- | -| **200** | Successful Response | - | -| **422** | Validation Error | - | +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | Successful Response | - | +**422** | Validation Error | - | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **get_all_services** - > List[Service] get_all_services(skip=skip, limit=limit) Get All Services @@ -181,12 +181,14 @@ with openapi_client.ApiClient(configuration) as api_client: print("Exception when calling ServicesApi->get_all_services: %s\n" % e) ``` + + ### Parameters -| Name | Type | Description | Notes | -| --------- | ------- | ----------- | --------------------------- | -| **skip** | **int** | | [optional] [default to 0] | -| **limit** | **int** | | [optional] [default to 100] | +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **skip** | **int**| | [optional] [default to 0] + **limit** | **int**| | [optional] [default to 100] ### Return type @@ -198,20 +200,18 @@ No authorization required ### HTTP request headers -- **Content-Type**: Not defined -- **Accept**: application/json + - **Content-Type**: Not defined + - **Accept**: application/json ### HTTP response details - -| Status code | Description | Response headers | -| ----------- | ------------------- | ---------------- | -| **200** | Successful Response | - | -| **422** | Validation Error | - | +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | Successful Response | - | +**422** | Validation Error | - | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **get_service_by_did** - > List[Service] get_service_by_did(entity_did=entity_did, skip=skip, limit=limit) Get Service By Did @@ -250,13 +250,15 @@ with openapi_client.ApiClient(configuration) as api_client: print("Exception when calling ServicesApi->get_service_by_did: %s\n" % e) ``` + + ### Parameters -| Name | Type | Description | Notes | -| -------------- | ------- | ----------- | --------------------------------------------------- | -| **entity_did** | **str** | | [optional] [default to 'did:sov:test:1234'] | -| **skip** | **int** | | [optional] [default to 0] | -| **limit** | **int** | | [optional] [default to 100] | +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **entity_did** | **str**| | [optional] [default to 'did:sov:test:1234'] + **skip** | **int**| | [optional] [default to 0] + **limit** | **int**| | [optional] [default to 100] ### Return type @@ -268,20 +270,18 @@ No authorization required ### HTTP request headers -- **Content-Type**: Not defined -- **Accept**: application/json + - **Content-Type**: Not defined + - **Accept**: application/json ### HTTP response details - -| Status code | Description | Response headers | -| ----------- | ------------------- | ---------------- | -| **200** | Successful Response | - | -| **422** | Validation Error | - | +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | Successful Response | - | +**422** | Validation Error | - | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **get_services_without_entity** - > List[Service] get_services_without_entity(entity_did=entity_did, skip=skip, limit=limit) Get Services Without Entity @@ -320,13 +320,15 @@ with openapi_client.ApiClient(configuration) as api_client: print("Exception when calling ServicesApi->get_services_without_entity: %s\n" % e) ``` + + ### Parameters -| Name | Type | Description | Notes | -| -------------- | ------- | ----------- | --------------------------------------------------- | -| **entity_did** | **str** | | [optional] [default to 'did:sov:test:1234'] | -| **skip** | **int** | | [optional] [default to 0] | -| **limit** | **int** | | [optional] [default to 100] | +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **entity_did** | **str**| | [optional] [default to 'did:sov:test:1234'] + **skip** | **int**| | [optional] [default to 0] + **limit** | **int**| | [optional] [default to 100] ### Return type @@ -338,14 +340,14 @@ No authorization required ### HTTP request headers -- **Content-Type**: Not defined -- **Accept**: application/json + - **Content-Type**: Not defined + - **Accept**: application/json ### HTTP response details - -| Status code | Description | Response headers | -| ----------- | ------------------- | ---------------- | -| **200** | Successful Response | - | -| **422** | Validation Error | - | +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | Successful Response | - | +**422** | Validation Error | - | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + diff --git a/pkgs/clan-cli/tests/openapi_client/docs/Status.md b/pkgs/clan-cli/tests/openapi_client/docs/Status.md index 10bd223..3b89cf4 100644 --- a/pkgs/clan-cli/tests/openapi_client/docs/Status.md +++ b/pkgs/clan-cli/tests/openapi_client/docs/Status.md @@ -3,8 +3,9 @@ An enumeration. ## Properties - -| Name | Type | Description | Notes | -| ---- | ---- | ----------- | ----- | +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/pkgs/clan-cli/tests/openapi_client/docs/ValidationError.md b/pkgs/clan-cli/tests/openapi_client/docs/ValidationError.md index b57b565..04310f6 100644 --- a/pkgs/clan-cli/tests/openapi_client/docs/ValidationError.md +++ b/pkgs/clan-cli/tests/openapi_client/docs/ValidationError.md @@ -1,12 +1,12 @@ # ValidationError -## Properties -| Name | Type | Description | Notes | -| -------- | --------------------------------------------------------------- | ----------- | ----- | -| **loc** | [**List[ValidationErrorLocInner]**](ValidationErrorLocInner.md) | | -| **msg** | **str** | | -| **type** | **str** | | +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**loc** | [**List[ValidationErrorLocInner]**](ValidationErrorLocInner.md) | | +**msg** | **str** | | +**type** | **str** | | ## Example @@ -25,5 +25,6 @@ validation_error_dict = validation_error_instance.to_dict() # create an instance of ValidationError from a dict validation_error_form_dict = validation_error.from_dict(validation_error_dict) ``` - [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/pkgs/clan-cli/tests/openapi_client/docs/ValidationErrorLocInner.md b/pkgs/clan-cli/tests/openapi_client/docs/ValidationErrorLocInner.md index 04e49df..0bae52d 100644 --- a/pkgs/clan-cli/tests/openapi_client/docs/ValidationErrorLocInner.md +++ b/pkgs/clan-cli/tests/openapi_client/docs/ValidationErrorLocInner.md @@ -1,9 +1,9 @@ # ValidationErrorLocInner -## Properties -| Name | Type | Description | Notes | -| ---- | ---- | ----------- | ----- | +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- ## Example @@ -22,5 +22,6 @@ validation_error_loc_inner_dict = validation_error_loc_inner_instance.to_dict() # create an instance of ValidationErrorLocInner from a dict validation_error_loc_inner_form_dict = validation_error_loc_inner.from_dict(validation_error_loc_inner_dict) ``` - [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/pkgs/clan-cli/tests/openapi_client/models/entity.py b/pkgs/clan-cli/tests/openapi_client/models/entity.py index e478804..0ff4d16 100644 --- a/pkgs/clan-cli/tests/openapi_client/models/entity.py +++ b/pkgs/clan-cli/tests/openapi_client/models/entity.py @@ -31,7 +31,8 @@ class Entity(BaseModel): visible: StrictBool = Field(...) other: Dict[str, Any] = Field(...) attached: StrictBool = Field(...) - __properties = ["did", "name", "ip", "visible", "other", "attached"] + stop_health_task: StrictBool = Field(...) + __properties = ["did", "name", "ip", "visible", "other", "attached", "stop_health_task"] class Config: """Pydantic configuration""" @@ -74,7 +75,8 @@ class Entity(BaseModel): "ip": obj.get("ip"), "visible": obj.get("visible"), "other": obj.get("other"), - "attached": obj.get("attached") + "attached": obj.get("attached"), + "stop_health_task": obj.get("stop_health_task") }) return _obj diff --git a/pkgs/clan-cli/tests/openapi_client/test/test_entities_api.py b/pkgs/clan-cli/tests/openapi_client/test/test_entities_api.py index ecbc5b8..91626e2 100644 --- a/pkgs/clan-cli/tests/openapi_client/test/test_entities_api.py +++ b/pkgs/clan-cli/tests/openapi_client/test/test_entities_api.py @@ -82,6 +82,13 @@ class TestEntitiesApi(unittest.TestCase): """ pass + def test_is_attached(self) -> None: + """Test case for is_attached + + Is Attached # noqa: E501 + """ + pass + if __name__ == '__main__': unittest.main() diff --git a/pkgs/clan-cli/tests/openapi_client/test/test_entity.py b/pkgs/clan-cli/tests/openapi_client/test/test_entity.py index 5733915..747c942 100644 --- a/pkgs/clan-cli/tests/openapi_client/test/test_entity.py +++ b/pkgs/clan-cli/tests/openapi_client/test/test_entity.py @@ -41,7 +41,8 @@ class TestEntity(unittest.TestCase): ip = '127.0.0.1', visible = True, other = {network=Carlos Home Network, roles=[service repository, service prosumer]}, - attached = True + attached = True, + stop_health_task = True ) else: return Entity( @@ -51,6 +52,7 @@ class TestEntity(unittest.TestCase): visible = True, other = {network=Carlos Home Network, roles=[service repository, service prosumer]}, attached = True, + stop_health_task = True, ) """ diff --git a/pkgs/clan-cli/tests/openapi_client/test/test_service.py b/pkgs/clan-cli/tests/openapi_client/test/test_service.py index a681b0d..bc07518 100644 --- a/pkgs/clan-cli/tests/openapi_client/test/test_service.py +++ b/pkgs/clan-cli/tests/openapi_client/test/test_service.py @@ -49,7 +49,8 @@ class TestService(unittest.TestCase): ip = '127.0.0.1', visible = True, other = {network=Carlos Home Network, roles=[service repository, service prosumer]}, - attached = True, ) + attached = True, + stop_health_task = True, ) ) else: return Service( @@ -66,7 +67,8 @@ class TestService(unittest.TestCase): ip = '127.0.0.1', visible = True, other = {network=Carlos Home Network, roles=[service repository, service prosumer]}, - attached = True, ), + attached = True, + stop_health_task = True, ), ) """ From 8fba3e6a5e02613e5dfbd2d10343c0104beddd6f Mon Sep 17 00:00:00 2001 From: Georg-Stahn Date: Mon, 8 Jan 2024 20:19:07 +0100 Subject: [PATCH 47/58] add event msg with populate and the right table in swagger --- .../clan_cli/webui/routers/endpoints.py | 28 ++ pkgs/clan-cli/clan_cli/webui/schemas.py | 27 ++ pkgs/clan-cli/clan_cli/webui/sql_crud.py | 23 ++ pkgs/clan-cli/clan_cli/webui/sql_models.py | 29 +- pkgs/clan-cli/clan_cli/webui/tags.py | 5 + .../clan-cli/tests/openapi_client/__init__.py | 3 + .../tests/openapi_client/api/__init__.py | 1 + .../openapi_client/api/eventmessages_api.py | 339 ++++++++++++++++++ .../tests/openapi_client/docs/Eventmessage.md | 34 ++ .../openapi_client/docs/EventmessageCreate.md | 34 ++ .../openapi_client/docs/EventmessagesApi.md | 143 ++++++++ .../tests/openapi_client/models/__init__.py | 2 + .../openapi_client/models/eventmessage.py | 85 +++++ .../models/eventmessage_create.py | 85 +++++ .../openapi_client/test/test_eventmessage.py | 67 ++++ .../test/test_eventmessage_create.py | 67 ++++ .../test/test_eventmessages_api.py | 45 +++ pkgs/clan-cli/tests/test_db_api.py | 70 ++++ 18 files changed, 1079 insertions(+), 8 deletions(-) create mode 100644 pkgs/clan-cli/tests/openapi_client/api/eventmessages_api.py create mode 100644 pkgs/clan-cli/tests/openapi_client/docs/Eventmessage.md create mode 100644 pkgs/clan-cli/tests/openapi_client/docs/EventmessageCreate.md create mode 100644 pkgs/clan-cli/tests/openapi_client/docs/EventmessagesApi.md create mode 100644 pkgs/clan-cli/tests/openapi_client/models/eventmessage.py create mode 100644 pkgs/clan-cli/tests/openapi_client/models/eventmessage_create.py create mode 100644 pkgs/clan-cli/tests/openapi_client/test/test_eventmessage.py create mode 100644 pkgs/clan-cli/tests/openapi_client/test/test_eventmessage_create.py create mode 100644 pkgs/clan-cli/tests/openapi_client/test/test_eventmessages_api.py diff --git a/pkgs/clan-cli/clan_cli/webui/routers/endpoints.py b/pkgs/clan-cli/clan_cli/webui/routers/endpoints.py index 625d03b..6a16fda 100644 --- a/pkgs/clan-cli/clan_cli/webui/routers/endpoints.py +++ b/pkgs/clan-cli/clan_cli/webui/routers/endpoints.py @@ -12,6 +12,8 @@ from .. import sql_crud, sql_db, sql_models from ..schemas import ( Entity, EntityCreate, + Eventmessage, + EventmessageCreate, Resolution, Service, ServiceCreate, @@ -262,3 +264,29 @@ async def get_all_resolutions( id=1, ) ] + + +######################### +# # +# Eventmessage # +# # +######################### + + +@router.post("/api/v1/send_msg", response_model=Eventmessage, tags=[Tags.eventmessages]) +async def create_eventmessage( + eventmsg: EventmessageCreate, db: Session = Depends(sql_db.get_db) +) -> EventmessageCreate: + return sql_crud.create_eventmessage(db, eventmsg) + + +@router.get( + "/api/v1/event_messages", + response_model=List[Eventmessage], + tags=[Tags.eventmessages], +) +async def get_all_eventmessages( + skip: int = 0, limit: int = 100, db: Session = Depends(sql_db.get_db) +) -> List[sql_models.Eventmessage]: + eventmessages = sql_crud.get_eventmessages(db, skip=skip, limit=limit) + return eventmessages diff --git a/pkgs/clan-cli/clan_cli/webui/schemas.py b/pkgs/clan-cli/clan_cli/webui/schemas.py index f43e8dd..b3175f0 100644 --- a/pkgs/clan-cli/clan_cli/webui/schemas.py +++ b/pkgs/clan-cli/clan_cli/webui/schemas.py @@ -104,3 +104,30 @@ class Resolution(ResolutionCreate): class Config: orm_mode = True + + +######################### +# # +# Eventmessage # +# # +######################### +class EventmessageBase(BaseModel): + id: int = Field(..., example=123456) + timestamp: int = Field(..., example=1234123413) + group: int = Field(..., example=1) # event group type (for the label) + group_id: int = Field( + ..., example=12345 + ) # specific to one group needed to enable visually nested groups + msg_type: int = Field(..., example=1) # message type for the label + src_did: str = Field(..., example="did:sov:test:2234") + des_did: str = Field(..., example="did:sov:test:1234") + + +class EventmessageCreate(EventmessageBase): + msg: dict = Field(..., example={"optinal": "values"}) # optional + pass + + +class Eventmessage(EventmessageCreate): + class Config: + orm_mode = True diff --git a/pkgs/clan-cli/clan_cli/webui/sql_crud.py b/pkgs/clan-cli/clan_cli/webui/sql_crud.py index 3f5fdc0..64b968c 100644 --- a/pkgs/clan-cli/clan_cli/webui/sql_crud.py +++ b/pkgs/clan-cli/clan_cli/webui/sql_crud.py @@ -136,3 +136,26 @@ def delete_entity_by_did(db: Session, did: str) -> None: def delete_entity_by_did_recursive(db: Session, did: str) -> None: delete_service_by_entity_did(db, did) delete_entity_by_did(db, did) + + +######################### +# # +# Eventmessage # +# # +######################### + + +def create_eventmessage( + db: Session, eventmsg: schemas.EventmessageCreate +) -> sql_models.Eventmessage: + db_eventmessage = sql_models.Eventmessage(**eventmsg.dict()) + db.add(db_eventmessage) + db.commit() + db.refresh(db_eventmessage) + return db_eventmessage + + +def get_eventmessages( + db: Session, skip: int = 0, limit: int = 100 +) -> List[sql_models.Eventmessage]: + return db.query(sql_models.Eventmessage).offset(skip).limit(limit).all() diff --git a/pkgs/clan-cli/clan_cli/webui/sql_models.py b/pkgs/clan-cli/clan_cli/webui/sql_models.py index 792b8cc..742b237 100644 --- a/pkgs/clan-cli/clan_cli/webui/sql_models.py +++ b/pkgs/clan-cli/clan_cli/webui/sql_models.py @@ -1,11 +1,4 @@ -from sqlalchemy import ( - JSON, - Boolean, - Column, - ForeignKey, - String, - Text, -) +from sqlalchemy import JSON, Boolean, Column, ForeignKey, Integer, String, Text from sqlalchemy.orm import relationship from .sql_db import Base @@ -55,3 +48,23 @@ class Service(ServiceAbstract): # One entity can have many services entity = relationship("Entity", back_populates="services") entity_did = Column(String, ForeignKey("entities.did")) + + +class Eventmessage(Base): + __tablename__ = "eventmessages" + + ## Queryable body ## + id = Column(Integer, primary_key=True, index=True) + timestamp = Column(Integer, unique=True, index=True) + group = Column(Integer, index=True) + group_id = Column(Integer, index=True) + msg_type = Column(Integer, index=True) # message type for the label + src_did = Column(String, index=True) + des_did = Column(String, index=True) + + ## Non queryable body ## + # In here we deposit: Network, Roles, Visible, etc. + msg = Column(JSON) + + ## Relations ## + # One entity can send many messages diff --git a/pkgs/clan-cli/clan_cli/webui/tags.py b/pkgs/clan-cli/clan_cli/webui/tags.py index 712f09b..3d52367 100644 --- a/pkgs/clan-cli/clan_cli/webui/tags.py +++ b/pkgs/clan-cli/clan_cli/webui/tags.py @@ -7,6 +7,7 @@ class Tags(Enum): entities = "entities" repositories = "repositories" resolutions = "resolution" + eventmessages = "eventmessages" def __str__(self) -> str: return self.value @@ -29,4 +30,8 @@ tags_metadata: List[Dict[str, Any]] = [ "name": str(Tags.resolutions), "description": "Operations on a resolution.", }, + { + "name": str(Tags.eventmessages), + "description": "Operations for event messages.", + }, ] diff --git a/pkgs/clan-cli/tests/openapi_client/__init__.py b/pkgs/clan-cli/tests/openapi_client/__init__.py index 8263f8b..c30337b 100644 --- a/pkgs/clan-cli/tests/openapi_client/__init__.py +++ b/pkgs/clan-cli/tests/openapi_client/__init__.py @@ -19,6 +19,7 @@ __version__ = "1.0.0" # import apis into sdk package from openapi_client.api.default_api import DefaultApi from openapi_client.api.entities_api import EntitiesApi +from openapi_client.api.eventmessages_api import EventmessagesApi from openapi_client.api.repositories_api import RepositoriesApi from openapi_client.api.resolution_api import ResolutionApi from openapi_client.api.services_api import ServicesApi @@ -37,6 +38,8 @@ from openapi_client.exceptions import ApiException # import models into sdk package from openapi_client.models.entity import Entity from openapi_client.models.entity_create import EntityCreate +from openapi_client.models.eventmessage import Eventmessage +from openapi_client.models.eventmessage_create import EventmessageCreate from openapi_client.models.http_validation_error import HTTPValidationError from openapi_client.models.machine import Machine from openapi_client.models.resolution import Resolution diff --git a/pkgs/clan-cli/tests/openapi_client/api/__init__.py b/pkgs/clan-cli/tests/openapi_client/api/__init__.py index 39c3f1b..87b34f9 100644 --- a/pkgs/clan-cli/tests/openapi_client/api/__init__.py +++ b/pkgs/clan-cli/tests/openapi_client/api/__init__.py @@ -3,6 +3,7 @@ # import apis into api package from openapi_client.api.default_api import DefaultApi from openapi_client.api.entities_api import EntitiesApi +from openapi_client.api.eventmessages_api import EventmessagesApi from openapi_client.api.repositories_api import RepositoriesApi from openapi_client.api.resolution_api import ResolutionApi from openapi_client.api.services_api import ServicesApi diff --git a/pkgs/clan-cli/tests/openapi_client/api/eventmessages_api.py b/pkgs/clan-cli/tests/openapi_client/api/eventmessages_api.py new file mode 100644 index 0000000..092ef36 --- /dev/null +++ b/pkgs/clan-cli/tests/openapi_client/api/eventmessages_api.py @@ -0,0 +1,339 @@ +# coding: utf-8 + +""" + FastAPI + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: 0.1.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import re # noqa: F401 +import io +import warnings + +from pydantic import validate_arguments, ValidationError + +from pydantic import StrictInt + +from typing import List, Optional + +from openapi_client.models.eventmessage import Eventmessage +from openapi_client.models.eventmessage_create import EventmessageCreate + +from openapi_client.api_client import ApiClient +from openapi_client.api_response import ApiResponse +from openapi_client.exceptions import ( # noqa: F401 + ApiTypeError, + ApiValueError +) + + +class EventmessagesApi: + """NOTE: This class is auto generated by OpenAPI Generator + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + def __init__(self, api_client=None) -> None: + if api_client is None: + api_client = ApiClient.get_default() + self.api_client = api_client + + @validate_arguments + def create_eventmessage(self, eventmessage_create : EventmessageCreate, **kwargs) -> Eventmessage: # noqa: E501 + """Create Eventmessage # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.create_eventmessage(eventmessage_create, async_req=True) + >>> result = thread.get() + + :param eventmessage_create: (required) + :type eventmessage_create: EventmessageCreate + :param async_req: Whether to execute the request asynchronously. + :type async_req: bool, optional + :param _request_timeout: timeout setting for this request. + If one number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :return: Returns the result object. + If the method is called asynchronously, + returns the request thread. + :rtype: Eventmessage + """ + kwargs['_return_http_data_only'] = True + if '_preload_content' in kwargs: + message = "Error! Please call the create_eventmessage_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data" # noqa: E501 + raise ValueError(message) + return self.create_eventmessage_with_http_info(eventmessage_create, **kwargs) # noqa: E501 + + @validate_arguments + def create_eventmessage_with_http_info(self, eventmessage_create : EventmessageCreate, **kwargs) -> ApiResponse: # noqa: E501 + """Create Eventmessage # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.create_eventmessage_with_http_info(eventmessage_create, async_req=True) + >>> result = thread.get() + + :param eventmessage_create: (required) + :type eventmessage_create: EventmessageCreate + :param async_req: Whether to execute the request asynchronously. + :type async_req: bool, optional + :param _preload_content: if False, the ApiResponse.data will + be set to none and raw_data will store the + HTTP response body without reading/decoding. + Default is True. + :type _preload_content: bool, optional + :param _return_http_data_only: response data instead of ApiResponse + object with status code, headers, etc + :type _return_http_data_only: bool, optional + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the authentication + in the spec for a single request. + :type _request_auth: dict, optional + :type _content_type: string, optional: force content-type for the request + :return: Returns the result object. + If the method is called asynchronously, + returns the request thread. + :rtype: tuple(Eventmessage, status_code(int), headers(HTTPHeaderDict)) + """ + + _params = locals() + + _all_params = [ + 'eventmessage_create' + ] + _all_params.extend( + [ + 'async_req', + '_return_http_data_only', + '_preload_content', + '_request_timeout', + '_request_auth', + '_content_type', + '_headers' + ] + ) + + # validate the arguments + for _key, _val in _params['kwargs'].items(): + if _key not in _all_params: + raise ApiTypeError( + "Got an unexpected keyword argument '%s'" + " to method create_eventmessage" % _key + ) + _params[_key] = _val + del _params['kwargs'] + + _collection_formats = {} + + # process the path parameters + _path_params = {} + + # process the query parameters + _query_params = [] + # process the header parameters + _header_params = dict(_params.get('_headers', {})) + # process the form parameters + _form_params = [] + _files = {} + # process the body parameter + _body_params = None + if _params['eventmessage_create'] is not None: + _body_params = _params['eventmessage_create'] + + # set the HTTP header `Accept` + _header_params['Accept'] = self.api_client.select_header_accept( + ['application/json']) # noqa: E501 + + # set the HTTP header `Content-Type` + _content_types_list = _params.get('_content_type', + self.api_client.select_header_content_type( + ['application/json'])) + if _content_types_list: + _header_params['Content-Type'] = _content_types_list + + # authentication setting + _auth_settings = [] # noqa: E501 + + _response_types_map = { + '200': "Eventmessage", + '422': "HTTPValidationError", + } + + return self.api_client.call_api( + '/api/v1/send_msg', 'POST', + _path_params, + _query_params, + _header_params, + body=_body_params, + post_params=_form_params, + files=_files, + response_types_map=_response_types_map, + auth_settings=_auth_settings, + async_req=_params.get('async_req'), + _return_http_data_only=_params.get('_return_http_data_only'), # noqa: E501 + _preload_content=_params.get('_preload_content', True), + _request_timeout=_params.get('_request_timeout'), + collection_formats=_collection_formats, + _request_auth=_params.get('_request_auth')) + + @validate_arguments + def get_all_eventmessages(self, skip : Optional[StrictInt] = None, limit : Optional[StrictInt] = None, **kwargs) -> List[Eventmessage]: # noqa: E501 + """Get All Eventmessages # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.get_all_eventmessages(skip, limit, async_req=True) + >>> result = thread.get() + + :param skip: + :type skip: int + :param limit: + :type limit: int + :param async_req: Whether to execute the request asynchronously. + :type async_req: bool, optional + :param _request_timeout: timeout setting for this request. + If one number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :return: Returns the result object. + If the method is called asynchronously, + returns the request thread. + :rtype: List[Eventmessage] + """ + kwargs['_return_http_data_only'] = True + if '_preload_content' in kwargs: + message = "Error! Please call the get_all_eventmessages_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data" # noqa: E501 + raise ValueError(message) + return self.get_all_eventmessages_with_http_info(skip, limit, **kwargs) # noqa: E501 + + @validate_arguments + def get_all_eventmessages_with_http_info(self, skip : Optional[StrictInt] = None, limit : Optional[StrictInt] = None, **kwargs) -> ApiResponse: # noqa: E501 + """Get All Eventmessages # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.get_all_eventmessages_with_http_info(skip, limit, async_req=True) + >>> result = thread.get() + + :param skip: + :type skip: int + :param limit: + :type limit: int + :param async_req: Whether to execute the request asynchronously. + :type async_req: bool, optional + :param _preload_content: if False, the ApiResponse.data will + be set to none and raw_data will store the + HTTP response body without reading/decoding. + Default is True. + :type _preload_content: bool, optional + :param _return_http_data_only: response data instead of ApiResponse + object with status code, headers, etc + :type _return_http_data_only: bool, optional + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the authentication + in the spec for a single request. + :type _request_auth: dict, optional + :type _content_type: string, optional: force content-type for the request + :return: Returns the result object. + If the method is called asynchronously, + returns the request thread. + :rtype: tuple(List[Eventmessage], status_code(int), headers(HTTPHeaderDict)) + """ + + _params = locals() + + _all_params = [ + 'skip', + 'limit' + ] + _all_params.extend( + [ + 'async_req', + '_return_http_data_only', + '_preload_content', + '_request_timeout', + '_request_auth', + '_content_type', + '_headers' + ] + ) + + # validate the arguments + for _key, _val in _params['kwargs'].items(): + if _key not in _all_params: + raise ApiTypeError( + "Got an unexpected keyword argument '%s'" + " to method get_all_eventmessages" % _key + ) + _params[_key] = _val + del _params['kwargs'] + + _collection_formats = {} + + # process the path parameters + _path_params = {} + + # process the query parameters + _query_params = [] + if _params.get('skip') is not None: # noqa: E501 + _query_params.append(('skip', _params['skip'])) + + if _params.get('limit') is not None: # noqa: E501 + _query_params.append(('limit', _params['limit'])) + + # process the header parameters + _header_params = dict(_params.get('_headers', {})) + # process the form parameters + _form_params = [] + _files = {} + # process the body parameter + _body_params = None + # set the HTTP header `Accept` + _header_params['Accept'] = self.api_client.select_header_accept( + ['application/json']) # noqa: E501 + + # authentication setting + _auth_settings = [] # noqa: E501 + + _response_types_map = { + '200': "List[Eventmessage]", + '422': "HTTPValidationError", + } + + return self.api_client.call_api( + '/api/v1/event_messages', 'GET', + _path_params, + _query_params, + _header_params, + body=_body_params, + post_params=_form_params, + files=_files, + response_types_map=_response_types_map, + auth_settings=_auth_settings, + async_req=_params.get('async_req'), + _return_http_data_only=_params.get('_return_http_data_only'), # noqa: E501 + _preload_content=_params.get('_preload_content', True), + _request_timeout=_params.get('_request_timeout'), + collection_formats=_collection_formats, + _request_auth=_params.get('_request_auth')) diff --git a/pkgs/clan-cli/tests/openapi_client/docs/Eventmessage.md b/pkgs/clan-cli/tests/openapi_client/docs/Eventmessage.md new file mode 100644 index 0000000..cbe65cb --- /dev/null +++ b/pkgs/clan-cli/tests/openapi_client/docs/Eventmessage.md @@ -0,0 +1,34 @@ +# Eventmessage + +## Properties + +| Name | Type | Description | Notes | +| ------------- | ---------- | ----------- | ----- | +| **id** | **int** | | +| **timestamp** | **int** | | +| **group** | **int** | | +| **group_id** | **int** | | +| **msg_type** | **int** | | +| **src_did** | **str** | | +| **des_did** | **str** | | +| **msg** | **object** | | + +## Example + +```python +from openapi_client.models.eventmessage import Eventmessage + +# TODO update the JSON string below +json = "{}" +# create an instance of Eventmessage from a JSON string +eventmessage_instance = Eventmessage.from_json(json) +# print the JSON string representation of the object +print Eventmessage.to_json() + +# convert the object into a dict +eventmessage_dict = eventmessage_instance.to_dict() +# create an instance of Eventmessage from a dict +eventmessage_form_dict = eventmessage.from_dict(eventmessage_dict) +``` + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/pkgs/clan-cli/tests/openapi_client/docs/EventmessageCreate.md b/pkgs/clan-cli/tests/openapi_client/docs/EventmessageCreate.md new file mode 100644 index 0000000..eb6f16d --- /dev/null +++ b/pkgs/clan-cli/tests/openapi_client/docs/EventmessageCreate.md @@ -0,0 +1,34 @@ +# EventmessageCreate + +## Properties + +| Name | Type | Description | Notes | +| ------------- | ---------- | ----------- | ----- | +| **id** | **int** | | +| **timestamp** | **int** | | +| **group** | **int** | | +| **group_id** | **int** | | +| **msg_type** | **int** | | +| **src_did** | **str** | | +| **des_did** | **str** | | +| **msg** | **object** | | + +## Example + +```python +from openapi_client.models.eventmessage_create import EventmessageCreate + +# TODO update the JSON string below +json = "{}" +# create an instance of EventmessageCreate from a JSON string +eventmessage_create_instance = EventmessageCreate.from_json(json) +# print the JSON string representation of the object +print EventmessageCreate.to_json() + +# convert the object into a dict +eventmessage_create_dict = eventmessage_create_instance.to_dict() +# create an instance of EventmessageCreate from a dict +eventmessage_create_form_dict = eventmessage_create.from_dict(eventmessage_create_dict) +``` + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/pkgs/clan-cli/tests/openapi_client/docs/EventmessagesApi.md b/pkgs/clan-cli/tests/openapi_client/docs/EventmessagesApi.md new file mode 100644 index 0000000..d6affb9 --- /dev/null +++ b/pkgs/clan-cli/tests/openapi_client/docs/EventmessagesApi.md @@ -0,0 +1,143 @@ +# openapi_client.EventmessagesApi + +All URIs are relative to _http://localhost_ + +| Method | HTTP request | Description | +| ---------------------------------------------------------------------- | ------------------------------ | --------------------- | +| [**create_eventmessage**](EventmessagesApi.md#create_eventmessage) | **POST** /api/v1/send_msg | Create Eventmessage | +| [**get_all_eventmessages**](EventmessagesApi.md#get_all_eventmessages) | **GET** /api/v1/event_messages | Get All Eventmessages | + +# **create_eventmessage** + +> Eventmessage create_eventmessage(eventmessage_create) + +Create Eventmessage + +### Example + +```python +import time +import os +import openapi_client +from openapi_client.models.eventmessage import Eventmessage +from openapi_client.models.eventmessage_create import EventmessageCreate +from openapi_client.rest import ApiException +from pprint import pprint + +# Defining the host is optional and defaults to http://localhost +# See configuration.py for a list of all supported configuration parameters. +configuration = openapi_client.Configuration( + host = "http://localhost" +) + + +# Enter a context with an instance of the API client +with openapi_client.ApiClient(configuration) as api_client: + # Create an instance of the API class + api_instance = openapi_client.EventmessagesApi(api_client) + eventmessage_create = openapi_client.EventmessageCreate() # EventmessageCreate | + + try: + # Create Eventmessage + api_response = api_instance.create_eventmessage(eventmessage_create) + print("The response of EventmessagesApi->create_eventmessage:\n") + pprint(api_response) + except Exception as e: + print("Exception when calling EventmessagesApi->create_eventmessage: %s\n" % e) +``` + +### Parameters + +| Name | Type | Description | Notes | +| ----------------------- | ----------------------------------------------- | ----------- | ----- | +| **eventmessage_create** | [**EventmessageCreate**](EventmessageCreate.md) | | + +### Return type + +[**Eventmessage**](Eventmessage.md) + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: application/json + +### HTTP response details + +| Status code | Description | Response headers | +| ----------- | ------------------- | ---------------- | +| **200** | Successful Response | - | +| **422** | Validation Error | - | + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **get_all_eventmessages** + +> List[Eventmessage] get_all_eventmessages(skip=skip, limit=limit) + +Get All Eventmessages + +### Example + +```python +import time +import os +import openapi_client +from openapi_client.models.eventmessage import Eventmessage +from openapi_client.rest import ApiException +from pprint import pprint + +# Defining the host is optional and defaults to http://localhost +# See configuration.py for a list of all supported configuration parameters. +configuration = openapi_client.Configuration( + host = "http://localhost" +) + + +# Enter a context with an instance of the API client +with openapi_client.ApiClient(configuration) as api_client: + # Create an instance of the API class + api_instance = openapi_client.EventmessagesApi(api_client) + skip = 0 # int | (optional) (default to 0) + limit = 100 # int | (optional) (default to 100) + + try: + # Get All Eventmessages + api_response = api_instance.get_all_eventmessages(skip=skip, limit=limit) + print("The response of EventmessagesApi->get_all_eventmessages:\n") + pprint(api_response) + except Exception as e: + print("Exception when calling EventmessagesApi->get_all_eventmessages: %s\n" % e) +``` + +### Parameters + +| Name | Type | Description | Notes | +| --------- | ------- | ----------- | --------------------------- | +| **skip** | **int** | | [optional] [default to 0] | +| **limit** | **int** | | [optional] [default to 100] | + +### Return type + +[**List[Eventmessage]**](Eventmessage.md) + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +### HTTP response details + +| Status code | Description | Response headers | +| ----------- | ------------------- | ---------------- | +| **200** | Successful Response | - | +| **422** | Validation Error | - | + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) diff --git a/pkgs/clan-cli/tests/openapi_client/models/__init__.py b/pkgs/clan-cli/tests/openapi_client/models/__init__.py index 4955602..4460d22 100644 --- a/pkgs/clan-cli/tests/openapi_client/models/__init__.py +++ b/pkgs/clan-cli/tests/openapi_client/models/__init__.py @@ -16,6 +16,8 @@ # import models into model package from openapi_client.models.entity import Entity from openapi_client.models.entity_create import EntityCreate +from openapi_client.models.eventmessage import Eventmessage +from openapi_client.models.eventmessage_create import EventmessageCreate from openapi_client.models.http_validation_error import HTTPValidationError from openapi_client.models.machine import Machine from openapi_client.models.resolution import Resolution diff --git a/pkgs/clan-cli/tests/openapi_client/models/eventmessage.py b/pkgs/clan-cli/tests/openapi_client/models/eventmessage.py new file mode 100644 index 0000000..ece8617 --- /dev/null +++ b/pkgs/clan-cli/tests/openapi_client/models/eventmessage.py @@ -0,0 +1,85 @@ +# coding: utf-8 + +""" + FastAPI + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: 0.1.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + + +from typing import Any, Dict +from pydantic import BaseModel, Field, StrictInt, StrictStr + +class Eventmessage(BaseModel): + """ + Eventmessage + """ + id: StrictInt = Field(...) + timestamp: StrictInt = Field(...) + group: StrictInt = Field(...) + group_id: StrictInt = Field(...) + msg_type: StrictInt = Field(...) + src_did: StrictStr = Field(...) + des_did: StrictStr = Field(...) + msg: Dict[str, Any] = Field(...) + __properties = ["id", "timestamp", "group", "group_id", "msg_type", "src_did", "des_did", "msg"] + + class Config: + """Pydantic configuration""" + allow_population_by_field_name = True + validate_assignment = True + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.dict(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Eventmessage: + """Create an instance of Eventmessage from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self): + """Returns the dictionary representation of the model using alias""" + _dict = self.dict(by_alias=True, + exclude={ + }, + exclude_none=True) + return _dict + + @classmethod + def from_dict(cls, obj: dict) -> Eventmessage: + """Create an instance of Eventmessage from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return Eventmessage.parse_obj(obj) + + _obj = Eventmessage.parse_obj({ + "id": obj.get("id"), + "timestamp": obj.get("timestamp"), + "group": obj.get("group"), + "group_id": obj.get("group_id"), + "msg_type": obj.get("msg_type"), + "src_did": obj.get("src_did"), + "des_did": obj.get("des_did"), + "msg": obj.get("msg") + }) + return _obj + + diff --git a/pkgs/clan-cli/tests/openapi_client/models/eventmessage_create.py b/pkgs/clan-cli/tests/openapi_client/models/eventmessage_create.py new file mode 100644 index 0000000..34915bb --- /dev/null +++ b/pkgs/clan-cli/tests/openapi_client/models/eventmessage_create.py @@ -0,0 +1,85 @@ +# coding: utf-8 + +""" + FastAPI + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: 0.1.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + + +from typing import Any, Dict +from pydantic import BaseModel, Field, StrictInt, StrictStr + +class EventmessageCreate(BaseModel): + """ + EventmessageCreate + """ + id: StrictInt = Field(...) + timestamp: StrictInt = Field(...) + group: StrictInt = Field(...) + group_id: StrictInt = Field(...) + msg_type: StrictInt = Field(...) + src_did: StrictStr = Field(...) + des_did: StrictStr = Field(...) + msg: Dict[str, Any] = Field(...) + __properties = ["id", "timestamp", "group", "group_id", "msg_type", "src_did", "des_did", "msg"] + + class Config: + """Pydantic configuration""" + allow_population_by_field_name = True + validate_assignment = True + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.dict(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> EventmessageCreate: + """Create an instance of EventmessageCreate from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self): + """Returns the dictionary representation of the model using alias""" + _dict = self.dict(by_alias=True, + exclude={ + }, + exclude_none=True) + return _dict + + @classmethod + def from_dict(cls, obj: dict) -> EventmessageCreate: + """Create an instance of EventmessageCreate from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return EventmessageCreate.parse_obj(obj) + + _obj = EventmessageCreate.parse_obj({ + "id": obj.get("id"), + "timestamp": obj.get("timestamp"), + "group": obj.get("group"), + "group_id": obj.get("group_id"), + "msg_type": obj.get("msg_type"), + "src_did": obj.get("src_did"), + "des_did": obj.get("des_did"), + "msg": obj.get("msg") + }) + return _obj + + diff --git a/pkgs/clan-cli/tests/openapi_client/test/test_eventmessage.py b/pkgs/clan-cli/tests/openapi_client/test/test_eventmessage.py new file mode 100644 index 0000000..21852d5 --- /dev/null +++ b/pkgs/clan-cli/tests/openapi_client/test/test_eventmessage.py @@ -0,0 +1,67 @@ +# coding: utf-8 + +""" + FastAPI + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: 0.1.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import unittest +import datetime + +from openapi_client.models.eventmessage import Eventmessage # noqa: E501 + +class TestEventmessage(unittest.TestCase): + """Eventmessage unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional) -> Eventmessage: + """Test Eventmessage + include_option is a boolean, when False only required + params are included, when True both required and + optional params are included """ + # uncomment below to create an instance of `Eventmessage` + """ + model = Eventmessage() # noqa: E501 + if include_optional: + return Eventmessage( + id = 123456, + timestamp = 1234123413, + group = 1, + group_id = 12345, + msg_type = 1, + src_did = 'did:sov:test:2234', + des_did = 'did:sov:test:1234', + msg = {optinal=values} + ) + else: + return Eventmessage( + id = 123456, + timestamp = 1234123413, + group = 1, + group_id = 12345, + msg_type = 1, + src_did = 'did:sov:test:2234', + des_did = 'did:sov:test:1234', + msg = {optinal=values}, + ) + """ + + def testEventmessage(self): + """Test Eventmessage""" + # inst_req_only = self.make_instance(include_optional=False) + # inst_req_and_optional = self.make_instance(include_optional=True) + +if __name__ == '__main__': + unittest.main() diff --git a/pkgs/clan-cli/tests/openapi_client/test/test_eventmessage_create.py b/pkgs/clan-cli/tests/openapi_client/test/test_eventmessage_create.py new file mode 100644 index 0000000..8bc282d --- /dev/null +++ b/pkgs/clan-cli/tests/openapi_client/test/test_eventmessage_create.py @@ -0,0 +1,67 @@ +# coding: utf-8 + +""" + FastAPI + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: 0.1.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import unittest +import datetime + +from openapi_client.models.eventmessage_create import EventmessageCreate # noqa: E501 + +class TestEventmessageCreate(unittest.TestCase): + """EventmessageCreate unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional) -> EventmessageCreate: + """Test EventmessageCreate + include_option is a boolean, when False only required + params are included, when True both required and + optional params are included """ + # uncomment below to create an instance of `EventmessageCreate` + """ + model = EventmessageCreate() # noqa: E501 + if include_optional: + return EventmessageCreate( + id = 123456, + timestamp = 1234123413, + group = 1, + group_id = 12345, + msg_type = 1, + src_did = 'did:sov:test:2234', + des_did = 'did:sov:test:1234', + msg = {optinal=values} + ) + else: + return EventmessageCreate( + id = 123456, + timestamp = 1234123413, + group = 1, + group_id = 12345, + msg_type = 1, + src_did = 'did:sov:test:2234', + des_did = 'did:sov:test:1234', + msg = {optinal=values}, + ) + """ + + def testEventmessageCreate(self): + """Test EventmessageCreate""" + # inst_req_only = self.make_instance(include_optional=False) + # inst_req_and_optional = self.make_instance(include_optional=True) + +if __name__ == '__main__': + unittest.main() diff --git a/pkgs/clan-cli/tests/openapi_client/test/test_eventmessages_api.py b/pkgs/clan-cli/tests/openapi_client/test/test_eventmessages_api.py new file mode 100644 index 0000000..e2841ab --- /dev/null +++ b/pkgs/clan-cli/tests/openapi_client/test/test_eventmessages_api.py @@ -0,0 +1,45 @@ +# coding: utf-8 + +""" + FastAPI + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: 0.1.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import unittest + +from openapi_client.api.eventmessages_api import EventmessagesApi # noqa: E501 + + +class TestEventmessagesApi(unittest.TestCase): + """EventmessagesApi unit test stubs""" + + def setUp(self) -> None: + self.api = EventmessagesApi() # noqa: E501 + + def tearDown(self) -> None: + pass + + def test_create_eventmessage(self) -> None: + """Test case for create_eventmessage + + Create Eventmessage # noqa: E501 + """ + pass + + def test_get_all_eventmessages(self) -> None: + """Test case for get_all_eventmessages + + Get All Eventmessages # noqa: E501 + """ + pass + + +if __name__ == '__main__': + unittest.main() diff --git a/pkgs/clan-cli/tests/test_db_api.py b/pkgs/clan-cli/tests/test_db_api.py index cf8f479..b619729 100644 --- a/pkgs/clan-cli/tests/test_db_api.py +++ b/pkgs/clan-cli/tests/test_db_api.py @@ -1,13 +1,17 @@ import random +import time import uuid from openapi_client import ApiClient from openapi_client.api import DefaultApi from openapi_client.api.entities_api import EntitiesApi +from openapi_client.api.eventmessages_api import EventmessagesApi from openapi_client.api.services_api import ServicesApi from openapi_client.models import ( Entity, EntityCreate, + Eventmessage, + EventmessageCreate, Machine, ServiceCreate, Status, @@ -70,3 +74,69 @@ def test_create_services(api_client: ApiClient) -> None: service_obj = create_service(idx + 4 * midx, entity) service = sapi.create_service(service_obj) assert service.uuid == service_obj.uuid + + +random.seed(77) + + +def create_eventmessages(num: int = 2) -> list[EventmessageCreate]: + res = [] + starttime = int(time.time()) + for i in range(num): + group_id = i % 5 + random.getrandbits(6) + em_req_send = EventmessageCreate( + id=random.getrandbits(18), + timestamp=starttime + i * 10, + group=i % 5, + group_id=group_id, + msg_type=1, + src_did=f"did:sov:test:12{i}", + des_did=f"did:sov:test:12{i+1}", + msg={}, + ) + res.append(em_req_send) + em_req_rec = EventmessageCreate( + id=random.getrandbits(18), + timestamp=starttime + (i * 10) + 2, + group=i % 5, + group_id=group_id, + msg_type=2, + src_did=f"did:sov:test:12{i}", + des_did=f"did:sov:test:12{i+1}", + msg={}, + ) + res.append(em_req_rec) + group_id = i % 5 + random.getrandbits(6) + em_res_send = EventmessageCreate( + id=random.getrandbits(18), + timestamp=starttime + i * 10 + 4, + group=i % 5, + group_id=group_id, + msg_type=3, + src_did=f"did:sov:test:12{i+1}", + des_did=f"did:sov:test:12{i}", + msg={}, + ) + res.append(em_res_send) + em_res_rec = EventmessageCreate( + id=random.getrandbits(6), + timestamp=starttime + (i * 10) + 8, + group=i % 5, + group_id=group_id, + msg_type=4, + src_did=f"did:sov:test:12{i+1}", + des_did=f"did:sov:test:12{i}", + msg={}, + ) + res.append(em_res_rec) + return res + + +def test_create_eventmessages(api_client: ApiClient) -> None: + api = EventmessagesApi(api_client=api_client) + assert [] == api.get_all_eventmessages() + for own_eventmsg in create_eventmessages(): + res: Eventmessage = api.create_eventmessage(own_eventmsg) + # breakpoint() + assert res.id == own_eventmsg.id + assert [] != api.get_all_eventmessages() From e22e954a4a2bb53231a0bc9a7ae3ee616f2af55b Mon Sep 17 00:00:00 2001 From: Luis-Hebendanz Date: Mon, 8 Jan 2024 20:22:56 +0100 Subject: [PATCH 48/58] fixed build error in ui --- pkgs/clan-cli/tests/api.py | 6 +++--- pkgs/ui/src/app/client/[client_name]/page.tsx | 12 ------------ 2 files changed, 3 insertions(+), 15 deletions(-) diff --git a/pkgs/clan-cli/tests/api.py b/pkgs/clan-cli/tests/api.py index 1c3644d..4c140c3 100644 --- a/pkgs/clan-cli/tests/api.py +++ b/pkgs/clan-cli/tests/api.py @@ -14,7 +14,7 @@ from ports import PortFunction from clan_cli.webui.app import app -@pytest.fixture(scope="session") +@pytest.fixture() def test_client() -> TestClient: return TestClient(app) @@ -31,7 +31,7 @@ def get_health(*, url: str, max_retries: int = 20, delay: float = 0.2) -> str | # Pytest fixture to run the server in a separate process -@pytest.fixture(scope="session") +@pytest.fixture() def server_url(unused_tcp_port: PortFunction) -> Generator[str, None, None]: port = unused_tcp_port() host = "127.0.0.1" @@ -52,7 +52,7 @@ def server_url(unused_tcp_port: PortFunction) -> Generator[str, None, None]: proc.terminate() -@pytest.fixture(scope="session") +@pytest.fixture() def api_client(server_url: str) -> Generator[ApiClient, None, None]: configuration = Configuration(host=server_url) diff --git a/pkgs/ui/src/app/client/[client_name]/page.tsx b/pkgs/ui/src/app/client/[client_name]/page.tsx index 4b4e68a..e47d6b4 100644 --- a/pkgs/ui/src/app/client/[client_name]/page.tsx +++ b/pkgs/ui/src/app/client/[client_name]/page.tsx @@ -25,8 +25,6 @@ import { Entity, Service } from "@/api/model"; import useGetEntityByNameOrDid from "@/components/hooks/useGetEntityByNameOrDid"; import { useGetAllServices } from "@/api/services/services"; import axios from "axios"; -import { NoDataOverlay } from "@/components/noDataOverlay"; -import { DashboardCard } from "@/components/card"; import CloseIcon from "@mui/icons-material/Close"; interface SnackMessage { @@ -34,16 +32,6 @@ interface SnackMessage { severity: "success" | "error"; } -export const RecentActivity = (entity: Entity) => { - return ( - -
- -
-
- ); -}; - type AttachButtonProps = { entity?: Entity; setSnackbarMessage: (message: SnackMessage) => void; From acb84b8f0b56af974c57d271457a9c35875c2911 Mon Sep 17 00:00:00 2001 From: Luis-Hebendanz Date: Mon, 8 Jan 2024 20:37:17 +0100 Subject: [PATCH 49/58] Moved from xdist to normal pytest. Removed test folder from openapi_client --- pkgs/clan-cli/bin/gen-python-client | 2 + pkgs/clan-cli/default.nix | 2 - pkgs/clan-cli/pyproject.toml | 2 +- pkgs/clan-cli/tests/api.py | 6 +- .../tests/openapi_client/test/__init__.py | 0 .../openapi_client/test/test_default_api.py | 52 ---------- .../openapi_client/test/test_entities_api.py | 94 ------------------- .../tests/openapi_client/test/test_entity.py | 65 ------------- .../openapi_client/test/test_entity_create.py | 61 ------------ .../test/test_http_validation_error.py | 59 ------------ .../tests/openapi_client/test/test_machine.py | 55 ----------- .../test/test_repositories_api.py | 38 -------- .../openapi_client/test/test_resolution.py | 63 ------------- .../test/test_resolution_api.py | 38 -------- .../tests/openapi_client/test/test_service.py | 81 ---------------- .../test/test_service_create.py | 65 ------------- .../openapi_client/test/test_services_api.py | 66 ------------- .../tests/openapi_client/test/test_status.py | 34 ------- .../test/test_validation_error.py | 61 ------------ .../test/test_validation_error_loc_inner.py | 51 ---------- 20 files changed, 6 insertions(+), 889 deletions(-) delete mode 100644 pkgs/clan-cli/tests/openapi_client/test/__init__.py delete mode 100644 pkgs/clan-cli/tests/openapi_client/test/test_default_api.py delete mode 100644 pkgs/clan-cli/tests/openapi_client/test/test_entities_api.py delete mode 100644 pkgs/clan-cli/tests/openapi_client/test/test_entity.py delete mode 100644 pkgs/clan-cli/tests/openapi_client/test/test_entity_create.py delete mode 100644 pkgs/clan-cli/tests/openapi_client/test/test_http_validation_error.py delete mode 100644 pkgs/clan-cli/tests/openapi_client/test/test_machine.py delete mode 100644 pkgs/clan-cli/tests/openapi_client/test/test_repositories_api.py delete mode 100644 pkgs/clan-cli/tests/openapi_client/test/test_resolution.py delete mode 100644 pkgs/clan-cli/tests/openapi_client/test/test_resolution_api.py delete mode 100644 pkgs/clan-cli/tests/openapi_client/test/test_service.py delete mode 100644 pkgs/clan-cli/tests/openapi_client/test/test_service_create.py delete mode 100644 pkgs/clan-cli/tests/openapi_client/test/test_services_api.py delete mode 100644 pkgs/clan-cli/tests/openapi_client/test/test_status.py delete mode 100644 pkgs/clan-cli/tests/openapi_client/test/test_validation_error.py delete mode 100644 pkgs/clan-cli/tests/openapi_client/test/test_validation_error_loc_inner.py diff --git a/pkgs/clan-cli/bin/gen-python-client b/pkgs/clan-cli/bin/gen-python-client index 3c83d1b..58adc16 100755 --- a/pkgs/clan-cli/bin/gen-python-client +++ b/pkgs/clan-cli/bin/gen-python-client @@ -80,6 +80,8 @@ def main() -> None: replacement = "from typing import Any, List, Optional, Dict" replace_in_directory(directory_path=src_client, pattern=pattern, replacement=replacement) + src_clients_tests = src_client / "test" + shutil.rmtree(src_clients_tests) dst_client: Path = args.out / "openapi_client" shutil.rmtree(dst_client, ignore_errors=True) shutil.copytree(src_client, dst_client) diff --git a/pkgs/clan-cli/default.nix b/pkgs/clan-cli/default.nix index 6d3cd26..d52472f 100644 --- a/pkgs/clan-cli/default.nix +++ b/pkgs/clan-cli/default.nix @@ -8,7 +8,6 @@ , openssh , pytest , pytest-cov -, pytest-xdist , pytest-subprocess , pytest-timeout , remote-pdb @@ -56,7 +55,6 @@ let pytest pytest-cov pytest-subprocess - pytest-xdist pytest-timeout remote-pdb ipdb diff --git a/pkgs/clan-cli/pyproject.toml b/pkgs/clan-cli/pyproject.toml index 7fa8caf..adbf1ca 100644 --- a/pkgs/clan-cli/pyproject.toml +++ b/pkgs/clan-cli/pyproject.toml @@ -21,7 +21,7 @@ testpaths = "tests" faulthandler_timeout = 60 log_level = "DEBUG" log_format = "%(levelname)s: %(message)s" -addopts = "--cov . --cov-report term --cov-report html:.reports/html --no-cov-on-fail --durations 5 --color=yes --maxfail=1 --new-first -nauto" # Add --pdb for debugging +addopts = "--cov . --cov-report term --cov-report html:.reports/html --no-cov-on-fail --durations 5 --color=yes --maxfail=1 --new-first" # Add --pdb for debugging norecursedirs = "tests/helpers" markers = [ "impure" ] diff --git a/pkgs/clan-cli/tests/api.py b/pkgs/clan-cli/tests/api.py index 4c140c3..1c3644d 100644 --- a/pkgs/clan-cli/tests/api.py +++ b/pkgs/clan-cli/tests/api.py @@ -14,7 +14,7 @@ from ports import PortFunction from clan_cli.webui.app import app -@pytest.fixture() +@pytest.fixture(scope="session") def test_client() -> TestClient: return TestClient(app) @@ -31,7 +31,7 @@ def get_health(*, url: str, max_retries: int = 20, delay: float = 0.2) -> str | # Pytest fixture to run the server in a separate process -@pytest.fixture() +@pytest.fixture(scope="session") def server_url(unused_tcp_port: PortFunction) -> Generator[str, None, None]: port = unused_tcp_port() host = "127.0.0.1" @@ -52,7 +52,7 @@ def server_url(unused_tcp_port: PortFunction) -> Generator[str, None, None]: proc.terminate() -@pytest.fixture() +@pytest.fixture(scope="session") def api_client(server_url: str) -> Generator[ApiClient, None, None]: configuration = Configuration(host=server_url) diff --git a/pkgs/clan-cli/tests/openapi_client/test/__init__.py b/pkgs/clan-cli/tests/openapi_client/test/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/pkgs/clan-cli/tests/openapi_client/test/test_default_api.py b/pkgs/clan-cli/tests/openapi_client/test/test_default_api.py deleted file mode 100644 index c8d82a9..0000000 --- a/pkgs/clan-cli/tests/openapi_client/test/test_default_api.py +++ /dev/null @@ -1,52 +0,0 @@ -# coding: utf-8 - -""" - FastAPI - - No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - - The version of the OpenAPI document: 0.1.0 - Generated by OpenAPI Generator (https://openapi-generator.tech) - - Do not edit the class manually. -""" # noqa: E501 - - -import unittest - -from openapi_client.api.default_api import DefaultApi # noqa: E501 - - -class TestDefaultApi(unittest.TestCase): - """DefaultApi unit test stubs""" - - def setUp(self) -> None: - self.api = DefaultApi() # noqa: E501 - - def tearDown(self) -> None: - pass - - def test_get(self) -> None: - """Test case for get - - Get # noqa: E501 - """ - pass - - def test_health(self) -> None: - """Test case for health - - Health # noqa: E501 - """ - pass - - def test_root(self) -> None: - """Test case for root - - Root # noqa: E501 - """ - pass - - -if __name__ == '__main__': - unittest.main() diff --git a/pkgs/clan-cli/tests/openapi_client/test/test_entities_api.py b/pkgs/clan-cli/tests/openapi_client/test/test_entities_api.py deleted file mode 100644 index 91626e2..0000000 --- a/pkgs/clan-cli/tests/openapi_client/test/test_entities_api.py +++ /dev/null @@ -1,94 +0,0 @@ -# coding: utf-8 - -""" - FastAPI - - No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - - The version of the OpenAPI document: 0.1.0 - Generated by OpenAPI Generator (https://openapi-generator.tech) - - Do not edit the class manually. -""" # noqa: E501 - - -import unittest - -from openapi_client.api.entities_api import EntitiesApi # noqa: E501 - - -class TestEntitiesApi(unittest.TestCase): - """EntitiesApi unit test stubs""" - - def setUp(self) -> None: - self.api = EntitiesApi() # noqa: E501 - - def tearDown(self) -> None: - pass - - def test_attach_entity(self) -> None: - """Test case for attach_entity - - Attach Entity # noqa: E501 - """ - pass - - def test_create_entity(self) -> None: - """Test case for create_entity - - Create Entity # noqa: E501 - """ - pass - - def test_delete_entity(self) -> None: - """Test case for delete_entity - - Delete Entity # noqa: E501 - """ - pass - - def test_detach_entity(self) -> None: - """Test case for detach_entity - - Detach Entity # noqa: E501 - """ - pass - - def test_get_all_entities(self) -> None: - """Test case for get_all_entities - - Get All Entities # noqa: E501 - """ - pass - - def test_get_attached_entities(self) -> None: - """Test case for get_attached_entities - - Get Attached Entities # noqa: E501 - """ - pass - - def test_get_entity_by_did(self) -> None: - """Test case for get_entity_by_did - - Get Entity By Did # noqa: E501 - """ - pass - - def test_get_entity_by_name(self) -> None: - """Test case for get_entity_by_name - - Get Entity By Name # noqa: E501 - """ - pass - - def test_is_attached(self) -> None: - """Test case for is_attached - - Is Attached # noqa: E501 - """ - pass - - -if __name__ == '__main__': - unittest.main() diff --git a/pkgs/clan-cli/tests/openapi_client/test/test_entity.py b/pkgs/clan-cli/tests/openapi_client/test/test_entity.py deleted file mode 100644 index 747c942..0000000 --- a/pkgs/clan-cli/tests/openapi_client/test/test_entity.py +++ /dev/null @@ -1,65 +0,0 @@ -# coding: utf-8 - -""" - FastAPI - - No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - - The version of the OpenAPI document: 0.1.0 - Generated by OpenAPI Generator (https://openapi-generator.tech) - - Do not edit the class manually. -""" # noqa: E501 - - -import unittest -import datetime - -from openapi_client.models.entity import Entity # noqa: E501 - -class TestEntity(unittest.TestCase): - """Entity unit test stubs""" - - def setUp(self): - pass - - def tearDown(self): - pass - - def make_instance(self, include_optional) -> Entity: - """Test Entity - include_option is a boolean, when False only required - params are included, when True both required and - optional params are included """ - # uncomment below to create an instance of `Entity` - """ - model = Entity() # noqa: E501 - if include_optional: - return Entity( - did = 'did:sov:test:1234', - name = 'C1', - ip = '127.0.0.1', - visible = True, - other = {network=Carlos Home Network, roles=[service repository, service prosumer]}, - attached = True, - stop_health_task = True - ) - else: - return Entity( - did = 'did:sov:test:1234', - name = 'C1', - ip = '127.0.0.1', - visible = True, - other = {network=Carlos Home Network, roles=[service repository, service prosumer]}, - attached = True, - stop_health_task = True, - ) - """ - - def testEntity(self): - """Test Entity""" - # inst_req_only = self.make_instance(include_optional=False) - # inst_req_and_optional = self.make_instance(include_optional=True) - -if __name__ == '__main__': - unittest.main() diff --git a/pkgs/clan-cli/tests/openapi_client/test/test_entity_create.py b/pkgs/clan-cli/tests/openapi_client/test/test_entity_create.py deleted file mode 100644 index e6c4565..0000000 --- a/pkgs/clan-cli/tests/openapi_client/test/test_entity_create.py +++ /dev/null @@ -1,61 +0,0 @@ -# coding: utf-8 - -""" - FastAPI - - No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - - The version of the OpenAPI document: 0.1.0 - Generated by OpenAPI Generator (https://openapi-generator.tech) - - Do not edit the class manually. -""" # noqa: E501 - - -import unittest -import datetime - -from openapi_client.models.entity_create import EntityCreate # noqa: E501 - -class TestEntityCreate(unittest.TestCase): - """EntityCreate unit test stubs""" - - def setUp(self): - pass - - def tearDown(self): - pass - - def make_instance(self, include_optional) -> EntityCreate: - """Test EntityCreate - include_option is a boolean, when False only required - params are included, when True both required and - optional params are included """ - # uncomment below to create an instance of `EntityCreate` - """ - model = EntityCreate() # noqa: E501 - if include_optional: - return EntityCreate( - did = 'did:sov:test:1234', - name = 'C1', - ip = '127.0.0.1', - visible = True, - other = {network=Carlos Home Network, roles=[service repository, service prosumer]} - ) - else: - return EntityCreate( - did = 'did:sov:test:1234', - name = 'C1', - ip = '127.0.0.1', - visible = True, - other = {network=Carlos Home Network, roles=[service repository, service prosumer]}, - ) - """ - - def testEntityCreate(self): - """Test EntityCreate""" - # inst_req_only = self.make_instance(include_optional=False) - # inst_req_and_optional = self.make_instance(include_optional=True) - -if __name__ == '__main__': - unittest.main() diff --git a/pkgs/clan-cli/tests/openapi_client/test/test_http_validation_error.py b/pkgs/clan-cli/tests/openapi_client/test/test_http_validation_error.py deleted file mode 100644 index 9c2d93d..0000000 --- a/pkgs/clan-cli/tests/openapi_client/test/test_http_validation_error.py +++ /dev/null @@ -1,59 +0,0 @@ -# coding: utf-8 - -""" - FastAPI - - No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - - The version of the OpenAPI document: 0.1.0 - Generated by OpenAPI Generator (https://openapi-generator.tech) - - Do not edit the class manually. -""" # noqa: E501 - - -import unittest -import datetime - -from openapi_client.models.http_validation_error import HTTPValidationError # noqa: E501 - -class TestHTTPValidationError(unittest.TestCase): - """HTTPValidationError unit test stubs""" - - def setUp(self): - pass - - def tearDown(self): - pass - - def make_instance(self, include_optional) -> HTTPValidationError: - """Test HTTPValidationError - include_option is a boolean, when False only required - params are included, when True both required and - optional params are included """ - # uncomment below to create an instance of `HTTPValidationError` - """ - model = HTTPValidationError() # noqa: E501 - if include_optional: - return HTTPValidationError( - detail = [ - openapi_client.models.validation_error.ValidationError( - loc = [ - null - ], - msg = '', - type = '', ) - ] - ) - else: - return HTTPValidationError( - ) - """ - - def testHTTPValidationError(self): - """Test HTTPValidationError""" - # inst_req_only = self.make_instance(include_optional=False) - # inst_req_and_optional = self.make_instance(include_optional=True) - -if __name__ == '__main__': - unittest.main() diff --git a/pkgs/clan-cli/tests/openapi_client/test/test_machine.py b/pkgs/clan-cli/tests/openapi_client/test/test_machine.py deleted file mode 100644 index 1138964..0000000 --- a/pkgs/clan-cli/tests/openapi_client/test/test_machine.py +++ /dev/null @@ -1,55 +0,0 @@ -# coding: utf-8 - -""" - FastAPI - - No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - - The version of the OpenAPI document: 0.1.0 - Generated by OpenAPI Generator (https://openapi-generator.tech) - - Do not edit the class manually. -""" # noqa: E501 - - -import unittest -import datetime - -from openapi_client.models.machine import Machine # noqa: E501 - -class TestMachine(unittest.TestCase): - """Machine unit test stubs""" - - def setUp(self): - pass - - def tearDown(self): - pass - - def make_instance(self, include_optional) -> Machine: - """Test Machine - include_option is a boolean, when False only required - params are included, when True both required and - optional params are included """ - # uncomment below to create an instance of `Machine` - """ - model = Machine() # noqa: E501 - if include_optional: - return Machine( - name = '', - status = 'online' - ) - else: - return Machine( - name = '', - status = 'online', - ) - """ - - def testMachine(self): - """Test Machine""" - # inst_req_only = self.make_instance(include_optional=False) - # inst_req_and_optional = self.make_instance(include_optional=True) - -if __name__ == '__main__': - unittest.main() diff --git a/pkgs/clan-cli/tests/openapi_client/test/test_repositories_api.py b/pkgs/clan-cli/tests/openapi_client/test/test_repositories_api.py deleted file mode 100644 index ac87716..0000000 --- a/pkgs/clan-cli/tests/openapi_client/test/test_repositories_api.py +++ /dev/null @@ -1,38 +0,0 @@ -# coding: utf-8 - -""" - FastAPI - - No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - - The version of the OpenAPI document: 0.1.0 - Generated by OpenAPI Generator (https://openapi-generator.tech) - - Do not edit the class manually. -""" # noqa: E501 - - -import unittest - -from openapi_client.api.repositories_api import RepositoriesApi # noqa: E501 - - -class TestRepositoriesApi(unittest.TestCase): - """RepositoriesApi unit test stubs""" - - def setUp(self) -> None: - self.api = RepositoriesApi() # noqa: E501 - - def tearDown(self) -> None: - pass - - def test_get_all_repositories(self) -> None: - """Test case for get_all_repositories - - Get All Repositories # noqa: E501 - """ - pass - - -if __name__ == '__main__': - unittest.main() diff --git a/pkgs/clan-cli/tests/openapi_client/test/test_resolution.py b/pkgs/clan-cli/tests/openapi_client/test/test_resolution.py deleted file mode 100644 index 08ecde0..0000000 --- a/pkgs/clan-cli/tests/openapi_client/test/test_resolution.py +++ /dev/null @@ -1,63 +0,0 @@ -# coding: utf-8 - -""" - FastAPI - - No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - - The version of the OpenAPI document: 0.1.0 - Generated by OpenAPI Generator (https://openapi-generator.tech) - - Do not edit the class manually. -""" # noqa: E501 - - -import unittest -import datetime - -from openapi_client.models.resolution import Resolution # noqa: E501 - -class TestResolution(unittest.TestCase): - """Resolution unit test stubs""" - - def setUp(self): - pass - - def tearDown(self): - pass - - def make_instance(self, include_optional) -> Resolution: - """Test Resolution - include_option is a boolean, when False only required - params are included, when True both required and - optional params are included """ - # uncomment below to create an instance of `Resolution` - """ - model = Resolution() # noqa: E501 - if include_optional: - return Resolution( - requester_name = 'C1', - requester_did = 'did:sov:test:1122', - resolved_did = 'did:sov:test:1234', - other = {test=test}, - timestamp = datetime.datetime.strptime('2013-10-20 19:20:30.00', '%Y-%m-%d %H:%M:%S.%f'), - id = 56 - ) - else: - return Resolution( - requester_name = 'C1', - requester_did = 'did:sov:test:1122', - resolved_did = 'did:sov:test:1234', - other = {test=test}, - timestamp = datetime.datetime.strptime('2013-10-20 19:20:30.00', '%Y-%m-%d %H:%M:%S.%f'), - id = 56, - ) - """ - - def testResolution(self): - """Test Resolution""" - # inst_req_only = self.make_instance(include_optional=False) - # inst_req_and_optional = self.make_instance(include_optional=True) - -if __name__ == '__main__': - unittest.main() diff --git a/pkgs/clan-cli/tests/openapi_client/test/test_resolution_api.py b/pkgs/clan-cli/tests/openapi_client/test/test_resolution_api.py deleted file mode 100644 index 7f26f22..0000000 --- a/pkgs/clan-cli/tests/openapi_client/test/test_resolution_api.py +++ /dev/null @@ -1,38 +0,0 @@ -# coding: utf-8 - -""" - FastAPI - - No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - - The version of the OpenAPI document: 0.1.0 - Generated by OpenAPI Generator (https://openapi-generator.tech) - - Do not edit the class manually. -""" # noqa: E501 - - -import unittest - -from openapi_client.api.resolution_api import ResolutionApi # noqa: E501 - - -class TestResolutionApi(unittest.TestCase): - """ResolutionApi unit test stubs""" - - def setUp(self) -> None: - self.api = ResolutionApi() # noqa: E501 - - def tearDown(self) -> None: - pass - - def test_get_all_resolutions(self) -> None: - """Test case for get_all_resolutions - - Get All Resolutions # noqa: E501 - """ - pass - - -if __name__ == '__main__': - unittest.main() diff --git a/pkgs/clan-cli/tests/openapi_client/test/test_service.py b/pkgs/clan-cli/tests/openapi_client/test/test_service.py deleted file mode 100644 index bc07518..0000000 --- a/pkgs/clan-cli/tests/openapi_client/test/test_service.py +++ /dev/null @@ -1,81 +0,0 @@ -# coding: utf-8 - -""" - FastAPI - - No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - - The version of the OpenAPI document: 0.1.0 - Generated by OpenAPI Generator (https://openapi-generator.tech) - - Do not edit the class manually. -""" # noqa: E501 - - -import unittest -import datetime - -from openapi_client.models.service import Service # noqa: E501 - -class TestService(unittest.TestCase): - """Service unit test stubs""" - - def setUp(self): - pass - - def tearDown(self): - pass - - def make_instance(self, include_optional) -> Service: - """Test Service - include_option is a boolean, when False only required - params are included, when True both required and - optional params are included """ - # uncomment below to create an instance of `Service` - """ - model = Service() # noqa: E501 - if include_optional: - return Service( - uuid = '8e285c0c-4e40-430a-a477-26b3b81e30df', - service_name = 'Carlos Printing', - service_type = '3D Printing', - endpoint_url = 'http://127.0.0.1:8000', - status = 'unknown', - other = {action=[register, deregister, delete, create]}, - entity_did = 'did:sov:test:1234', - entity = openapi_client.models.entity.Entity( - did = 'did:sov:test:1234', - name = 'C1', - ip = '127.0.0.1', - visible = True, - other = {network=Carlos Home Network, roles=[service repository, service prosumer]}, - attached = True, - stop_health_task = True, ) - ) - else: - return Service( - uuid = '8e285c0c-4e40-430a-a477-26b3b81e30df', - service_name = 'Carlos Printing', - service_type = '3D Printing', - endpoint_url = 'http://127.0.0.1:8000', - status = 'unknown', - other = {action=[register, deregister, delete, create]}, - entity_did = 'did:sov:test:1234', - entity = openapi_client.models.entity.Entity( - did = 'did:sov:test:1234', - name = 'C1', - ip = '127.0.0.1', - visible = True, - other = {network=Carlos Home Network, roles=[service repository, service prosumer]}, - attached = True, - stop_health_task = True, ), - ) - """ - - def testService(self): - """Test Service""" - # inst_req_only = self.make_instance(include_optional=False) - # inst_req_and_optional = self.make_instance(include_optional=True) - -if __name__ == '__main__': - unittest.main() diff --git a/pkgs/clan-cli/tests/openapi_client/test/test_service_create.py b/pkgs/clan-cli/tests/openapi_client/test/test_service_create.py deleted file mode 100644 index 588bb66..0000000 --- a/pkgs/clan-cli/tests/openapi_client/test/test_service_create.py +++ /dev/null @@ -1,65 +0,0 @@ -# coding: utf-8 - -""" - FastAPI - - No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - - The version of the OpenAPI document: 0.1.0 - Generated by OpenAPI Generator (https://openapi-generator.tech) - - Do not edit the class manually. -""" # noqa: E501 - - -import unittest -import datetime - -from openapi_client.models.service_create import ServiceCreate # noqa: E501 - -class TestServiceCreate(unittest.TestCase): - """ServiceCreate unit test stubs""" - - def setUp(self): - pass - - def tearDown(self): - pass - - def make_instance(self, include_optional) -> ServiceCreate: - """Test ServiceCreate - include_option is a boolean, when False only required - params are included, when True both required and - optional params are included """ - # uncomment below to create an instance of `ServiceCreate` - """ - model = ServiceCreate() # noqa: E501 - if include_optional: - return ServiceCreate( - uuid = '8e285c0c-4e40-430a-a477-26b3b81e30df', - service_name = 'Carlos Printing', - service_type = '3D Printing', - endpoint_url = 'http://127.0.0.1:8000', - status = 'unknown', - other = {action=[register, deregister, delete, create]}, - entity_did = 'did:sov:test:1234' - ) - else: - return ServiceCreate( - uuid = '8e285c0c-4e40-430a-a477-26b3b81e30df', - service_name = 'Carlos Printing', - service_type = '3D Printing', - endpoint_url = 'http://127.0.0.1:8000', - status = 'unknown', - other = {action=[register, deregister, delete, create]}, - entity_did = 'did:sov:test:1234', - ) - """ - - def testServiceCreate(self): - """Test ServiceCreate""" - # inst_req_only = self.make_instance(include_optional=False) - # inst_req_and_optional = self.make_instance(include_optional=True) - -if __name__ == '__main__': - unittest.main() diff --git a/pkgs/clan-cli/tests/openapi_client/test/test_services_api.py b/pkgs/clan-cli/tests/openapi_client/test/test_services_api.py deleted file mode 100644 index 68470f9..0000000 --- a/pkgs/clan-cli/tests/openapi_client/test/test_services_api.py +++ /dev/null @@ -1,66 +0,0 @@ -# coding: utf-8 - -""" - FastAPI - - No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - - The version of the OpenAPI document: 0.1.0 - Generated by OpenAPI Generator (https://openapi-generator.tech) - - Do not edit the class manually. -""" # noqa: E501 - - -import unittest - -from openapi_client.api.services_api import ServicesApi # noqa: E501 - - -class TestServicesApi(unittest.TestCase): - """ServicesApi unit test stubs""" - - def setUp(self) -> None: - self.api = ServicesApi() # noqa: E501 - - def tearDown(self) -> None: - pass - - def test_create_service(self) -> None: - """Test case for create_service - - Create Service # noqa: E501 - """ - pass - - def test_delete_service(self) -> None: - """Test case for delete_service - - Delete Service # noqa: E501 - """ - pass - - def test_get_all_services(self) -> None: - """Test case for get_all_services - - Get All Services # noqa: E501 - """ - pass - - def test_get_service_by_did(self) -> None: - """Test case for get_service_by_did - - Get Service By Did # noqa: E501 - """ - pass - - def test_get_services_without_entity(self) -> None: - """Test case for get_services_without_entity - - Get Services Without Entity # noqa: E501 - """ - pass - - -if __name__ == '__main__': - unittest.main() diff --git a/pkgs/clan-cli/tests/openapi_client/test/test_status.py b/pkgs/clan-cli/tests/openapi_client/test/test_status.py deleted file mode 100644 index 8a69573..0000000 --- a/pkgs/clan-cli/tests/openapi_client/test/test_status.py +++ /dev/null @@ -1,34 +0,0 @@ -# coding: utf-8 - -""" - FastAPI - - No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - - The version of the OpenAPI document: 0.1.0 - Generated by OpenAPI Generator (https://openapi-generator.tech) - - Do not edit the class manually. -""" # noqa: E501 - - -import unittest -import datetime - -from openapi_client.models.status import Status # noqa: E501 - -class TestStatus(unittest.TestCase): - """Status unit test stubs""" - - def setUp(self): - pass - - def tearDown(self): - pass - - def testStatus(self): - """Test Status""" - # inst = Status() - -if __name__ == '__main__': - unittest.main() diff --git a/pkgs/clan-cli/tests/openapi_client/test/test_validation_error.py b/pkgs/clan-cli/tests/openapi_client/test/test_validation_error.py deleted file mode 100644 index 3636285..0000000 --- a/pkgs/clan-cli/tests/openapi_client/test/test_validation_error.py +++ /dev/null @@ -1,61 +0,0 @@ -# coding: utf-8 - -""" - FastAPI - - No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - - The version of the OpenAPI document: 0.1.0 - Generated by OpenAPI Generator (https://openapi-generator.tech) - - Do not edit the class manually. -""" # noqa: E501 - - -import unittest -import datetime - -from openapi_client.models.validation_error import ValidationError # noqa: E501 - -class TestValidationError(unittest.TestCase): - """ValidationError unit test stubs""" - - def setUp(self): - pass - - def tearDown(self): - pass - - def make_instance(self, include_optional) -> ValidationError: - """Test ValidationError - include_option is a boolean, when False only required - params are included, when True both required and - optional params are included """ - # uncomment below to create an instance of `ValidationError` - """ - model = ValidationError() # noqa: E501 - if include_optional: - return ValidationError( - loc = [ - null - ], - msg = '', - type = '' - ) - else: - return ValidationError( - loc = [ - null - ], - msg = '', - type = '', - ) - """ - - def testValidationError(self): - """Test ValidationError""" - # inst_req_only = self.make_instance(include_optional=False) - # inst_req_and_optional = self.make_instance(include_optional=True) - -if __name__ == '__main__': - unittest.main() diff --git a/pkgs/clan-cli/tests/openapi_client/test/test_validation_error_loc_inner.py b/pkgs/clan-cli/tests/openapi_client/test/test_validation_error_loc_inner.py deleted file mode 100644 index 545e84d..0000000 --- a/pkgs/clan-cli/tests/openapi_client/test/test_validation_error_loc_inner.py +++ /dev/null @@ -1,51 +0,0 @@ -# coding: utf-8 - -""" - FastAPI - - No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - - The version of the OpenAPI document: 0.1.0 - Generated by OpenAPI Generator (https://openapi-generator.tech) - - Do not edit the class manually. -""" # noqa: E501 - - -import unittest -import datetime - -from openapi_client.models.validation_error_loc_inner import ValidationErrorLocInner # noqa: E501 - -class TestValidationErrorLocInner(unittest.TestCase): - """ValidationErrorLocInner unit test stubs""" - - def setUp(self): - pass - - def tearDown(self): - pass - - def make_instance(self, include_optional) -> ValidationErrorLocInner: - """Test ValidationErrorLocInner - include_option is a boolean, when False only required - params are included, when True both required and - optional params are included """ - # uncomment below to create an instance of `ValidationErrorLocInner` - """ - model = ValidationErrorLocInner() # noqa: E501 - if include_optional: - return ValidationErrorLocInner( - ) - else: - return ValidationErrorLocInner( - ) - """ - - def testValidationErrorLocInner(self): - """Test ValidationErrorLocInner""" - # inst_req_only = self.make_instance(include_optional=False) - # inst_req_and_optional = self.make_instance(include_optional=True) - -if __name__ == '__main__': - unittest.main() From 2a9f31394ee5e31e71a5d0f1d9366fbaa379b701 Mon Sep 17 00:00:00 2001 From: Luis-Hebendanz Date: Mon, 8 Jan 2024 20:52:23 +0100 Subject: [PATCH 50/58] nix fmt --- .../tests/openapi_client/docs/DefaultApi.md | 68 ++--- .../tests/openapi_client/docs/EntitiesApi.md | 240 +++++++++--------- .../tests/openapi_client/docs/Entity.md | 23 +- .../tests/openapi_client/docs/EntityCreate.md | 19 +- .../docs/HTTPValidationError.md | 11 +- .../tests/openapi_client/docs/Machine.md | 13 +- .../openapi_client/docs/RepositoriesApi.md | 34 ++- .../tests/openapi_client/docs/Resolution.md | 21 +- .../openapi_client/docs/ResolutionApi.md | 34 ++- .../tests/openapi_client/docs/Service.md | 25 +- .../openapi_client/docs/ServiceCreate.md | 23 +- .../tests/openapi_client/docs/ServicesApi.md | 140 +++++----- .../tests/openapi_client/docs/Status.md | 7 +- .../openapi_client/docs/ValidationError.md | 15 +- .../docs/ValidationErrorLocInner.md | 9 +- 15 files changed, 332 insertions(+), 350 deletions(-) diff --git a/pkgs/clan-cli/tests/openapi_client/docs/DefaultApi.md b/pkgs/clan-cli/tests/openapi_client/docs/DefaultApi.md index 9a4a45c..aef64f7 100644 --- a/pkgs/clan-cli/tests/openapi_client/docs/DefaultApi.md +++ b/pkgs/clan-cli/tests/openapi_client/docs/DefaultApi.md @@ -1,15 +1,15 @@ # openapi_client.DefaultApi -All URIs are relative to *http://localhost* - -Method | HTTP request | Description -------------- | ------------- | ------------- -[**get**](DefaultApi.md#get) | **GET** /ws2_example | Get -[**health**](DefaultApi.md#health) | **GET** /health | Health -[**root**](DefaultApi.md#root) | **GET** /{path_name} | Root +All URIs are relative to _http://localhost_ +| Method | HTTP request | Description | +| ---------------------------------- | -------------------- | ----------- | +| [**get**](DefaultApi.md#get) | **GET** /ws2_example | Get | +| [**health**](DefaultApi.md#health) | **GET** /health | Health | +| [**root**](DefaultApi.md#root) | **GET** /{path_name} | Root | # **get** + > get() Get @@ -42,9 +42,8 @@ with openapi_client.ApiClient(configuration) as api_client: print("Exception when calling DefaultApi->get: %s\n" % e) ``` - - ### Parameters + This endpoint does not need any parameter. ### Return type @@ -57,17 +56,19 @@ No authorization required ### HTTP request headers - - **Content-Type**: Not defined - - **Accept**: application/json +- **Content-Type**: Not defined +- **Accept**: application/json ### HTTP response details -| Status code | Description | Response headers | -|-------------|-------------|------------------| -**200** | Successful Response | - | + +| Status code | Description | Response headers | +| ----------- | ------------------- | ---------------- | +| **200** | Successful Response | - | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **health** + > Machine health() Health @@ -103,9 +104,8 @@ with openapi_client.ApiClient(configuration) as api_client: print("Exception when calling DefaultApi->health: %s\n" % e) ``` - - ### Parameters + This endpoint does not need any parameter. ### Return type @@ -118,17 +118,19 @@ No authorization required ### HTTP request headers - - **Content-Type**: Not defined - - **Accept**: application/json +- **Content-Type**: Not defined +- **Accept**: application/json ### HTTP response details -| Status code | Description | Response headers | -|-------------|-------------|------------------| -**200** | Successful Response | - | + +| Status code | Description | Response headers | +| ----------- | ------------------- | ---------------- | +| **200** | Successful Response | - | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **root** + > root(path_name) Root @@ -153,7 +155,7 @@ configuration = openapi_client.Configuration( with openapi_client.ApiClient(configuration) as api_client: # Create an instance of the API class api_instance = openapi_client.DefaultApi(api_client) - path_name = 'path_name_example' # str | + path_name = 'path_name_example' # str | try: # Root @@ -162,13 +164,11 @@ with openapi_client.ApiClient(configuration) as api_client: print("Exception when calling DefaultApi->root: %s\n" % e) ``` - - ### Parameters -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **path_name** | **str**| | +| Name | Type | Description | Notes | +| ------------- | ------- | ----------- | ----- | +| **path_name** | **str** | | ### Return type @@ -180,14 +180,14 @@ No authorization required ### HTTP request headers - - **Content-Type**: Not defined - - **Accept**: application/json +- **Content-Type**: Not defined +- **Accept**: application/json ### HTTP response details -| Status code | Description | Response headers | -|-------------|-------------|------------------| -**200** | Successful Response | - | -**422** | Validation Error | - | + +| Status code | Description | Response headers | +| ----------- | ------------------- | ---------------- | +| **200** | Successful Response | - | +| **422** | Validation Error | - | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) - diff --git a/pkgs/clan-cli/tests/openapi_client/docs/EntitiesApi.md b/pkgs/clan-cli/tests/openapi_client/docs/EntitiesApi.md index 4a99b6c..dc621f8 100644 --- a/pkgs/clan-cli/tests/openapi_client/docs/EntitiesApi.md +++ b/pkgs/clan-cli/tests/openapi_client/docs/EntitiesApi.md @@ -1,21 +1,21 @@ # openapi_client.EntitiesApi -All URIs are relative to *http://localhost* - -Method | HTTP request | Description -------------- | ------------- | ------------- -[**attach_entity**](EntitiesApi.md#attach_entity) | **POST** /api/v1/attach | Attach Entity -[**create_entity**](EntitiesApi.md#create_entity) | **POST** /api/v1/entity | Create Entity -[**delete_entity**](EntitiesApi.md#delete_entity) | **DELETE** /api/v1/entity | Delete Entity -[**detach_entity**](EntitiesApi.md#detach_entity) | **POST** /api/v1/detach | Detach Entity -[**get_all_entities**](EntitiesApi.md#get_all_entities) | **GET** /api/v1/entities | Get All Entities -[**get_attached_entities**](EntitiesApi.md#get_attached_entities) | **GET** /api/v1/attached_entities | Get Attached Entities -[**get_entity_by_did**](EntitiesApi.md#get_entity_by_did) | **GET** /api/v1/entity | Get Entity By Did -[**get_entity_by_name**](EntitiesApi.md#get_entity_by_name) | **GET** /api/v1/entity_by_name | Get Entity By Name -[**is_attached**](EntitiesApi.md#is_attached) | **GET** /api/v1/is_attached | Is Attached +All URIs are relative to _http://localhost_ +| Method | HTTP request | Description | +| ----------------------------------------------------------------- | --------------------------------- | --------------------- | +| [**attach_entity**](EntitiesApi.md#attach_entity) | **POST** /api/v1/attach | Attach Entity | +| [**create_entity**](EntitiesApi.md#create_entity) | **POST** /api/v1/entity | Create Entity | +| [**delete_entity**](EntitiesApi.md#delete_entity) | **DELETE** /api/v1/entity | Delete Entity | +| [**detach_entity**](EntitiesApi.md#detach_entity) | **POST** /api/v1/detach | Detach Entity | +| [**get_all_entities**](EntitiesApi.md#get_all_entities) | **GET** /api/v1/entities | Get All Entities | +| [**get_attached_entities**](EntitiesApi.md#get_attached_entities) | **GET** /api/v1/attached_entities | Get Attached Entities | +| [**get_entity_by_did**](EntitiesApi.md#get_entity_by_did) | **GET** /api/v1/entity | Get Entity By Did | +| [**get_entity_by_name**](EntitiesApi.md#get_entity_by_name) | **GET** /api/v1/entity_by_name | Get Entity By Name | +| [**is_attached**](EntitiesApi.md#is_attached) | **GET** /api/v1/is_attached | Is Attached | # **attach_entity** + > Dict[str, str] attach_entity(entity_did=entity_did, skip=skip, limit=limit) Attach Entity @@ -53,15 +53,13 @@ with openapi_client.ApiClient(configuration) as api_client: print("Exception when calling EntitiesApi->attach_entity: %s\n" % e) ``` - - ### Parameters -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **entity_did** | **str**| | [optional] [default to 'did:sov:test:1234'] - **skip** | **int**| | [optional] [default to 0] - **limit** | **int**| | [optional] [default to 100] +| Name | Type | Description | Notes | +| -------------- | ------- | ----------- | --------------------------------------------------- | +| **entity_did** | **str** | | [optional] [default to 'did:sov:test:1234'] | +| **skip** | **int** | | [optional] [default to 0] | +| **limit** | **int** | | [optional] [default to 100] | ### Return type @@ -73,18 +71,20 @@ No authorization required ### HTTP request headers - - **Content-Type**: Not defined - - **Accept**: application/json +- **Content-Type**: Not defined +- **Accept**: application/json ### HTTP response details -| Status code | Description | Response headers | -|-------------|-------------|------------------| -**200** | Successful Response | - | -**422** | Validation Error | - | + +| Status code | Description | Response headers | +| ----------- | ------------------- | ---------------- | +| **200** | Successful Response | - | +| **422** | Validation Error | - | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **create_entity** + > Entity create_entity(entity_create) Create Entity @@ -111,7 +111,7 @@ configuration = openapi_client.Configuration( with openapi_client.ApiClient(configuration) as api_client: # Create an instance of the API class api_instance = openapi_client.EntitiesApi(api_client) - entity_create = openapi_client.EntityCreate() # EntityCreate | + entity_create = openapi_client.EntityCreate() # EntityCreate | try: # Create Entity @@ -122,13 +122,11 @@ with openapi_client.ApiClient(configuration) as api_client: print("Exception when calling EntitiesApi->create_entity: %s\n" % e) ``` - - ### Parameters -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **entity_create** | [**EntityCreate**](EntityCreate.md)| | +| Name | Type | Description | Notes | +| ----------------- | ----------------------------------- | ----------- | ----- | +| **entity_create** | [**EntityCreate**](EntityCreate.md) | | ### Return type @@ -140,18 +138,20 @@ No authorization required ### HTTP request headers - - **Content-Type**: application/json - - **Accept**: application/json +- **Content-Type**: application/json +- **Accept**: application/json ### HTTP response details -| Status code | Description | Response headers | -|-------------|-------------|------------------| -**200** | Successful Response | - | -**422** | Validation Error | - | + +| Status code | Description | Response headers | +| ----------- | ------------------- | ---------------- | +| **200** | Successful Response | - | +| **422** | Validation Error | - | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **delete_entity** + > Dict[str, str] delete_entity(entity_did=entity_did) Delete Entity @@ -187,13 +187,11 @@ with openapi_client.ApiClient(configuration) as api_client: print("Exception when calling EntitiesApi->delete_entity: %s\n" % e) ``` - - ### Parameters -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **entity_did** | **str**| | [optional] [default to 'did:sov:test:1234'] +| Name | Type | Description | Notes | +| -------------- | ------- | ----------- | --------------------------------------------------- | +| **entity_did** | **str** | | [optional] [default to 'did:sov:test:1234'] | ### Return type @@ -205,18 +203,20 @@ No authorization required ### HTTP request headers - - **Content-Type**: Not defined - - **Accept**: application/json +- **Content-Type**: Not defined +- **Accept**: application/json ### HTTP response details -| Status code | Description | Response headers | -|-------------|-------------|------------------| -**200** | Successful Response | - | -**422** | Validation Error | - | + +| Status code | Description | Response headers | +| ----------- | ------------------- | ---------------- | +| **200** | Successful Response | - | +| **422** | Validation Error | - | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **detach_entity** + > Dict[str, str] detach_entity(entity_did=entity_did, skip=skip, limit=limit) Detach Entity @@ -254,15 +254,13 @@ with openapi_client.ApiClient(configuration) as api_client: print("Exception when calling EntitiesApi->detach_entity: %s\n" % e) ``` - - ### Parameters -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **entity_did** | **str**| | [optional] [default to 'did:sov:test:1234'] - **skip** | **int**| | [optional] [default to 0] - **limit** | **int**| | [optional] [default to 100] +| Name | Type | Description | Notes | +| -------------- | ------- | ----------- | --------------------------------------------------- | +| **entity_did** | **str** | | [optional] [default to 'did:sov:test:1234'] | +| **skip** | **int** | | [optional] [default to 0] | +| **limit** | **int** | | [optional] [default to 100] | ### Return type @@ -274,18 +272,20 @@ No authorization required ### HTTP request headers - - **Content-Type**: Not defined - - **Accept**: application/json +- **Content-Type**: Not defined +- **Accept**: application/json ### HTTP response details -| Status code | Description | Response headers | -|-------------|-------------|------------------| -**200** | Successful Response | - | -**422** | Validation Error | - | + +| Status code | Description | Response headers | +| ----------- | ------------------- | ---------------- | +| **200** | Successful Response | - | +| **422** | Validation Error | - | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **get_all_entities** + > List[Entity] get_all_entities(skip=skip, limit=limit) Get All Entities @@ -323,14 +323,12 @@ with openapi_client.ApiClient(configuration) as api_client: print("Exception when calling EntitiesApi->get_all_entities: %s\n" % e) ``` - - ### Parameters -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **skip** | **int**| | [optional] [default to 0] - **limit** | **int**| | [optional] [default to 100] +| Name | Type | Description | Notes | +| --------- | ------- | ----------- | --------------------------- | +| **skip** | **int** | | [optional] [default to 0] | +| **limit** | **int** | | [optional] [default to 100] | ### Return type @@ -342,18 +340,20 @@ No authorization required ### HTTP request headers - - **Content-Type**: Not defined - - **Accept**: application/json +- **Content-Type**: Not defined +- **Accept**: application/json ### HTTP response details -| Status code | Description | Response headers | -|-------------|-------------|------------------| -**200** | Successful Response | - | -**422** | Validation Error | - | + +| Status code | Description | Response headers | +| ----------- | ------------------- | ---------------- | +| **200** | Successful Response | - | +| **422** | Validation Error | - | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **get_attached_entities** + > List[Entity] get_attached_entities(skip=skip, limit=limit) Get Attached Entities @@ -391,14 +391,12 @@ with openapi_client.ApiClient(configuration) as api_client: print("Exception when calling EntitiesApi->get_attached_entities: %s\n" % e) ``` - - ### Parameters -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **skip** | **int**| | [optional] [default to 0] - **limit** | **int**| | [optional] [default to 100] +| Name | Type | Description | Notes | +| --------- | ------- | ----------- | --------------------------- | +| **skip** | **int** | | [optional] [default to 0] | +| **limit** | **int** | | [optional] [default to 100] | ### Return type @@ -410,18 +408,20 @@ No authorization required ### HTTP request headers - - **Content-Type**: Not defined - - **Accept**: application/json +- **Content-Type**: Not defined +- **Accept**: application/json ### HTTP response details -| Status code | Description | Response headers | -|-------------|-------------|------------------| -**200** | Successful Response | - | -**422** | Validation Error | - | + +| Status code | Description | Response headers | +| ----------- | ------------------- | ---------------- | +| **200** | Successful Response | - | +| **422** | Validation Error | - | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **get_entity_by_did** + > Entity get_entity_by_did(entity_did=entity_did) Get Entity By Did @@ -458,13 +458,11 @@ with openapi_client.ApiClient(configuration) as api_client: print("Exception when calling EntitiesApi->get_entity_by_did: %s\n" % e) ``` - - ### Parameters -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **entity_did** | **str**| | [optional] [default to 'did:sov:test:1234'] +| Name | Type | Description | Notes | +| -------------- | ------- | ----------- | --------------------------------------------------- | +| **entity_did** | **str** | | [optional] [default to 'did:sov:test:1234'] | ### Return type @@ -476,18 +474,20 @@ No authorization required ### HTTP request headers - - **Content-Type**: Not defined - - **Accept**: application/json +- **Content-Type**: Not defined +- **Accept**: application/json ### HTTP response details -| Status code | Description | Response headers | -|-------------|-------------|------------------| -**200** | Successful Response | - | -**422** | Validation Error | - | + +| Status code | Description | Response headers | +| ----------- | ------------------- | ---------------- | +| **200** | Successful Response | - | +| **422** | Validation Error | - | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **get_entity_by_name** + > Entity get_entity_by_name(entity_name) Get Entity By Name @@ -513,7 +513,7 @@ configuration = openapi_client.Configuration( with openapi_client.ApiClient(configuration) as api_client: # Create an instance of the API class api_instance = openapi_client.EntitiesApi(api_client) - entity_name = 'entity_name_example' # str | + entity_name = 'entity_name_example' # str | try: # Get Entity By Name @@ -524,13 +524,11 @@ with openapi_client.ApiClient(configuration) as api_client: print("Exception when calling EntitiesApi->get_entity_by_name: %s\n" % e) ``` - - ### Parameters -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **entity_name** | **str**| | +| Name | Type | Description | Notes | +| --------------- | ------- | ----------- | ----- | +| **entity_name** | **str** | | ### Return type @@ -542,18 +540,20 @@ No authorization required ### HTTP request headers - - **Content-Type**: Not defined - - **Accept**: application/json +- **Content-Type**: Not defined +- **Accept**: application/json ### HTTP response details -| Status code | Description | Response headers | -|-------------|-------------|------------------| -**200** | Successful Response | - | -**422** | Validation Error | - | + +| Status code | Description | Response headers | +| ----------- | ------------------- | ---------------- | +| **200** | Successful Response | - | +| **422** | Validation Error | - | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **is_attached** + > Dict[str, str] is_attached(entity_did=entity_did) Is Attached @@ -589,13 +589,11 @@ with openapi_client.ApiClient(configuration) as api_client: print("Exception when calling EntitiesApi->is_attached: %s\n" % e) ``` - - ### Parameters -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **entity_did** | **str**| | [optional] [default to 'did:sov:test:1234'] +| Name | Type | Description | Notes | +| -------------- | ------- | ----------- | --------------------------------------------------- | +| **entity_did** | **str** | | [optional] [default to 'did:sov:test:1234'] | ### Return type @@ -607,14 +605,14 @@ No authorization required ### HTTP request headers - - **Content-Type**: Not defined - - **Accept**: application/json +- **Content-Type**: Not defined +- **Accept**: application/json ### HTTP response details -| Status code | Description | Response headers | -|-------------|-------------|------------------| -**200** | Successful Response | - | -**422** | Validation Error | - | + +| Status code | Description | Response headers | +| ----------- | ------------------- | ---------------- | +| **200** | Successful Response | - | +| **422** | Validation Error | - | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) - diff --git a/pkgs/clan-cli/tests/openapi_client/docs/Entity.md b/pkgs/clan-cli/tests/openapi_client/docs/Entity.md index ed3b3be..fa7efb2 100644 --- a/pkgs/clan-cli/tests/openapi_client/docs/Entity.md +++ b/pkgs/clan-cli/tests/openapi_client/docs/Entity.md @@ -1,16 +1,16 @@ # Entity - ## Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**did** | **str** | | -**name** | **str** | | -**ip** | **str** | | -**visible** | **bool** | | -**other** | **object** | | -**attached** | **bool** | | -**stop_health_task** | **bool** | | + +| Name | Type | Description | Notes | +| -------------------- | ---------- | ----------- | ----- | +| **did** | **str** | | +| **name** | **str** | | +| **ip** | **str** | | +| **visible** | **bool** | | +| **other** | **object** | | +| **attached** | **bool** | | +| **stop_health_task** | **bool** | | ## Example @@ -29,6 +29,5 @@ entity_dict = entity_instance.to_dict() # create an instance of Entity from a dict entity_form_dict = entity.from_dict(entity_dict) ``` + [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) - - diff --git a/pkgs/clan-cli/tests/openapi_client/docs/EntityCreate.md b/pkgs/clan-cli/tests/openapi_client/docs/EntityCreate.md index 7cd1831..4fff16a 100644 --- a/pkgs/clan-cli/tests/openapi_client/docs/EntityCreate.md +++ b/pkgs/clan-cli/tests/openapi_client/docs/EntityCreate.md @@ -1,14 +1,14 @@ # EntityCreate - ## Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**did** | **str** | | -**name** | **str** | | -**ip** | **str** | | -**visible** | **bool** | | -**other** | **object** | | + +| Name | Type | Description | Notes | +| ----------- | ---------- | ----------- | ----- | +| **did** | **str** | | +| **name** | **str** | | +| **ip** | **str** | | +| **visible** | **bool** | | +| **other** | **object** | | ## Example @@ -27,6 +27,5 @@ entity_create_dict = entity_create_instance.to_dict() # create an instance of EntityCreate from a dict entity_create_form_dict = entity_create.from_dict(entity_create_dict) ``` + [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) - - diff --git a/pkgs/clan-cli/tests/openapi_client/docs/HTTPValidationError.md b/pkgs/clan-cli/tests/openapi_client/docs/HTTPValidationError.md index 5eee49b..d4902e7 100644 --- a/pkgs/clan-cli/tests/openapi_client/docs/HTTPValidationError.md +++ b/pkgs/clan-cli/tests/openapi_client/docs/HTTPValidationError.md @@ -1,10 +1,10 @@ # HTTPValidationError - ## Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**detail** | [**List[ValidationError]**](ValidationError.md) | | [optional] + +| Name | Type | Description | Notes | +| ---------- | ----------------------------------------------- | ----------- | ---------- | +| **detail** | [**List[ValidationError]**](ValidationError.md) | | [optional] | ## Example @@ -23,6 +23,5 @@ http_validation_error_dict = http_validation_error_instance.to_dict() # create an instance of HTTPValidationError from a dict http_validation_error_form_dict = http_validation_error.from_dict(http_validation_error_dict) ``` + [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) - - diff --git a/pkgs/clan-cli/tests/openapi_client/docs/Machine.md b/pkgs/clan-cli/tests/openapi_client/docs/Machine.md index 4ea6dc3..062fd51 100644 --- a/pkgs/clan-cli/tests/openapi_client/docs/Machine.md +++ b/pkgs/clan-cli/tests/openapi_client/docs/Machine.md @@ -1,11 +1,11 @@ # Machine - ## Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**name** | **str** | | -**status** | [**Status**](Status.md) | | + +| Name | Type | Description | Notes | +| ---------- | ----------------------- | ----------- | ----- | +| **name** | **str** | | +| **status** | [**Status**](Status.md) | | ## Example @@ -24,6 +24,5 @@ machine_dict = machine_instance.to_dict() # create an instance of Machine from a dict machine_form_dict = machine.from_dict(machine_dict) ``` + [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) - - diff --git a/pkgs/clan-cli/tests/openapi_client/docs/RepositoriesApi.md b/pkgs/clan-cli/tests/openapi_client/docs/RepositoriesApi.md index 7a24ab0..ff735f0 100644 --- a/pkgs/clan-cli/tests/openapi_client/docs/RepositoriesApi.md +++ b/pkgs/clan-cli/tests/openapi_client/docs/RepositoriesApi.md @@ -1,13 +1,13 @@ # openapi_client.RepositoriesApi -All URIs are relative to *http://localhost* - -Method | HTTP request | Description -------------- | ------------- | ------------- -[**get_all_repositories**](RepositoriesApi.md#get_all_repositories) | **GET** /api/v1/repositories | Get All Repositories +All URIs are relative to _http://localhost_ +| Method | HTTP request | Description | +| ------------------------------------------------------------------- | ---------------------------- | -------------------- | +| [**get_all_repositories**](RepositoriesApi.md#get_all_repositories) | **GET** /api/v1/repositories | Get All Repositories | # **get_all_repositories** + > List[Service] get_all_repositories(skip=skip, limit=limit) Get All Repositories @@ -45,14 +45,12 @@ with openapi_client.ApiClient(configuration) as api_client: print("Exception when calling RepositoriesApi->get_all_repositories: %s\n" % e) ``` - - ### Parameters -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **skip** | **int**| | [optional] [default to 0] - **limit** | **int**| | [optional] [default to 100] +| Name | Type | Description | Notes | +| --------- | ------- | ----------- | --------------------------- | +| **skip** | **int** | | [optional] [default to 0] | +| **limit** | **int** | | [optional] [default to 100] | ### Return type @@ -64,14 +62,14 @@ No authorization required ### HTTP request headers - - **Content-Type**: Not defined - - **Accept**: application/json +- **Content-Type**: Not defined +- **Accept**: application/json ### HTTP response details -| Status code | Description | Response headers | -|-------------|-------------|------------------| -**200** | Successful Response | - | -**422** | Validation Error | - | + +| Status code | Description | Response headers | +| ----------- | ------------------- | ---------------- | +| **200** | Successful Response | - | +| **422** | Validation Error | - | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) - diff --git a/pkgs/clan-cli/tests/openapi_client/docs/Resolution.md b/pkgs/clan-cli/tests/openapi_client/docs/Resolution.md index 27a3992..27928d5 100644 --- a/pkgs/clan-cli/tests/openapi_client/docs/Resolution.md +++ b/pkgs/clan-cli/tests/openapi_client/docs/Resolution.md @@ -1,15 +1,15 @@ # Resolution - ## Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**requester_name** | **str** | | -**requester_did** | **str** | | -**resolved_did** | **str** | | -**other** | **object** | | -**timestamp** | **datetime** | | -**id** | **int** | | + +| Name | Type | Description | Notes | +| ------------------ | ------------ | ----------- | ----- | +| **requester_name** | **str** | | +| **requester_did** | **str** | | +| **resolved_did** | **str** | | +| **other** | **object** | | +| **timestamp** | **datetime** | | +| **id** | **int** | | ## Example @@ -28,6 +28,5 @@ resolution_dict = resolution_instance.to_dict() # create an instance of Resolution from a dict resolution_form_dict = resolution.from_dict(resolution_dict) ``` + [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) - - diff --git a/pkgs/clan-cli/tests/openapi_client/docs/ResolutionApi.md b/pkgs/clan-cli/tests/openapi_client/docs/ResolutionApi.md index a2ae852..24da5fb 100644 --- a/pkgs/clan-cli/tests/openapi_client/docs/ResolutionApi.md +++ b/pkgs/clan-cli/tests/openapi_client/docs/ResolutionApi.md @@ -1,13 +1,13 @@ # openapi_client.ResolutionApi -All URIs are relative to *http://localhost* - -Method | HTTP request | Description -------------- | ------------- | ------------- -[**get_all_resolutions**](ResolutionApi.md#get_all_resolutions) | **GET** /api/v1/resolutions | Get All Resolutions +All URIs are relative to _http://localhost_ +| Method | HTTP request | Description | +| --------------------------------------------------------------- | --------------------------- | ------------------- | +| [**get_all_resolutions**](ResolutionApi.md#get_all_resolutions) | **GET** /api/v1/resolutions | Get All Resolutions | # **get_all_resolutions** + > List[Resolution] get_all_resolutions(skip=skip, limit=limit) Get All Resolutions @@ -45,14 +45,12 @@ with openapi_client.ApiClient(configuration) as api_client: print("Exception when calling ResolutionApi->get_all_resolutions: %s\n" % e) ``` - - ### Parameters -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **skip** | **int**| | [optional] [default to 0] - **limit** | **int**| | [optional] [default to 100] +| Name | Type | Description | Notes | +| --------- | ------- | ----------- | --------------------------- | +| **skip** | **int** | | [optional] [default to 0] | +| **limit** | **int** | | [optional] [default to 100] | ### Return type @@ -64,14 +62,14 @@ No authorization required ### HTTP request headers - - **Content-Type**: Not defined - - **Accept**: application/json +- **Content-Type**: Not defined +- **Accept**: application/json ### HTTP response details -| Status code | Description | Response headers | -|-------------|-------------|------------------| -**200** | Successful Response | - | -**422** | Validation Error | - | + +| Status code | Description | Response headers | +| ----------- | ------------------- | ---------------- | +| **200** | Successful Response | - | +| **422** | Validation Error | - | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) - diff --git a/pkgs/clan-cli/tests/openapi_client/docs/Service.md b/pkgs/clan-cli/tests/openapi_client/docs/Service.md index bff9e15..5798f74 100644 --- a/pkgs/clan-cli/tests/openapi_client/docs/Service.md +++ b/pkgs/clan-cli/tests/openapi_client/docs/Service.md @@ -1,17 +1,17 @@ # Service - ## Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**uuid** | **str** | | -**service_name** | **str** | | -**service_type** | **str** | | -**endpoint_url** | **str** | | -**status** | **str** | | -**other** | **object** | | -**entity_did** | **str** | | -**entity** | [**Entity**](Entity.md) | | + +| Name | Type | Description | Notes | +| ---------------- | ----------------------- | ----------- | ----- | +| **uuid** | **str** | | +| **service_name** | **str** | | +| **service_type** | **str** | | +| **endpoint_url** | **str** | | +| **status** | **str** | | +| **other** | **object** | | +| **entity_did** | **str** | | +| **entity** | [**Entity**](Entity.md) | | ## Example @@ -30,6 +30,5 @@ service_dict = service_instance.to_dict() # create an instance of Service from a dict service_form_dict = service.from_dict(service_dict) ``` + [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) - - diff --git a/pkgs/clan-cli/tests/openapi_client/docs/ServiceCreate.md b/pkgs/clan-cli/tests/openapi_client/docs/ServiceCreate.md index f8e84e1..7843b1a 100644 --- a/pkgs/clan-cli/tests/openapi_client/docs/ServiceCreate.md +++ b/pkgs/clan-cli/tests/openapi_client/docs/ServiceCreate.md @@ -1,16 +1,16 @@ # ServiceCreate - ## Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**uuid** | **str** | | -**service_name** | **str** | | -**service_type** | **str** | | -**endpoint_url** | **str** | | -**status** | **str** | | -**other** | **object** | | -**entity_did** | **str** | | + +| Name | Type | Description | Notes | +| ---------------- | ---------- | ----------- | ----- | +| **uuid** | **str** | | +| **service_name** | **str** | | +| **service_type** | **str** | | +| **endpoint_url** | **str** | | +| **status** | **str** | | +| **other** | **object** | | +| **entity_did** | **str** | | ## Example @@ -29,6 +29,5 @@ service_create_dict = service_create_instance.to_dict() # create an instance of ServiceCreate from a dict service_create_form_dict = service_create.from_dict(service_create_dict) ``` + [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) - - diff --git a/pkgs/clan-cli/tests/openapi_client/docs/ServicesApi.md b/pkgs/clan-cli/tests/openapi_client/docs/ServicesApi.md index 9a2c544..006615a 100644 --- a/pkgs/clan-cli/tests/openapi_client/docs/ServicesApi.md +++ b/pkgs/clan-cli/tests/openapi_client/docs/ServicesApi.md @@ -1,17 +1,17 @@ # openapi_client.ServicesApi -All URIs are relative to *http://localhost* - -Method | HTTP request | Description -------------- | ------------- | ------------- -[**create_service**](ServicesApi.md#create_service) | **POST** /api/v1/service | Create Service -[**delete_service**](ServicesApi.md#delete_service) | **DELETE** /api/v1/service | Delete Service -[**get_all_services**](ServicesApi.md#get_all_services) | **GET** /api/v1/services | Get All Services -[**get_service_by_did**](ServicesApi.md#get_service_by_did) | **GET** /api/v1/service | Get Service By Did -[**get_services_without_entity**](ServicesApi.md#get_services_without_entity) | **GET** /api/v1/services_without_entity | Get Services Without Entity +All URIs are relative to _http://localhost_ +| Method | HTTP request | Description | +| ----------------------------------------------------------------------------- | --------------------------------------- | --------------------------- | +| [**create_service**](ServicesApi.md#create_service) | **POST** /api/v1/service | Create Service | +| [**delete_service**](ServicesApi.md#delete_service) | **DELETE** /api/v1/service | Delete Service | +| [**get_all_services**](ServicesApi.md#get_all_services) | **GET** /api/v1/services | Get All Services | +| [**get_service_by_did**](ServicesApi.md#get_service_by_did) | **GET** /api/v1/service | Get Service By Did | +| [**get_services_without_entity**](ServicesApi.md#get_services_without_entity) | **GET** /api/v1/services_without_entity | Get Services Without Entity | # **create_service** + > Service create_service(service_create) Create Service @@ -38,7 +38,7 @@ configuration = openapi_client.Configuration( with openapi_client.ApiClient(configuration) as api_client: # Create an instance of the API class api_instance = openapi_client.ServicesApi(api_client) - service_create = openapi_client.ServiceCreate() # ServiceCreate | + service_create = openapi_client.ServiceCreate() # ServiceCreate | try: # Create Service @@ -49,13 +49,11 @@ with openapi_client.ApiClient(configuration) as api_client: print("Exception when calling ServicesApi->create_service: %s\n" % e) ``` - - ### Parameters -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **service_create** | [**ServiceCreate**](ServiceCreate.md)| | +| Name | Type | Description | Notes | +| ------------------ | ------------------------------------- | ----------- | ----- | +| **service_create** | [**ServiceCreate**](ServiceCreate.md) | | ### Return type @@ -67,18 +65,20 @@ No authorization required ### HTTP request headers - - **Content-Type**: application/json - - **Accept**: application/json +- **Content-Type**: application/json +- **Accept**: application/json ### HTTP response details -| Status code | Description | Response headers | -|-------------|-------------|------------------| -**200** | Successful Response | - | -**422** | Validation Error | - | + +| Status code | Description | Response headers | +| ----------- | ------------------- | ---------------- | +| **200** | Successful Response | - | +| **422** | Validation Error | - | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **delete_service** + > Dict[str, str] delete_service(entity_did=entity_did) Delete Service @@ -114,13 +114,11 @@ with openapi_client.ApiClient(configuration) as api_client: print("Exception when calling ServicesApi->delete_service: %s\n" % e) ``` - - ### Parameters -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **entity_did** | **str**| | [optional] [default to 'did:sov:test:1234'] +| Name | Type | Description | Notes | +| -------------- | ------- | ----------- | --------------------------------------------------- | +| **entity_did** | **str** | | [optional] [default to 'did:sov:test:1234'] | ### Return type @@ -132,18 +130,20 @@ No authorization required ### HTTP request headers - - **Content-Type**: Not defined - - **Accept**: application/json +- **Content-Type**: Not defined +- **Accept**: application/json ### HTTP response details -| Status code | Description | Response headers | -|-------------|-------------|------------------| -**200** | Successful Response | - | -**422** | Validation Error | - | + +| Status code | Description | Response headers | +| ----------- | ------------------- | ---------------- | +| **200** | Successful Response | - | +| **422** | Validation Error | - | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **get_all_services** + > List[Service] get_all_services(skip=skip, limit=limit) Get All Services @@ -181,14 +181,12 @@ with openapi_client.ApiClient(configuration) as api_client: print("Exception when calling ServicesApi->get_all_services: %s\n" % e) ``` - - ### Parameters -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **skip** | **int**| | [optional] [default to 0] - **limit** | **int**| | [optional] [default to 100] +| Name | Type | Description | Notes | +| --------- | ------- | ----------- | --------------------------- | +| **skip** | **int** | | [optional] [default to 0] | +| **limit** | **int** | | [optional] [default to 100] | ### Return type @@ -200,18 +198,20 @@ No authorization required ### HTTP request headers - - **Content-Type**: Not defined - - **Accept**: application/json +- **Content-Type**: Not defined +- **Accept**: application/json ### HTTP response details -| Status code | Description | Response headers | -|-------------|-------------|------------------| -**200** | Successful Response | - | -**422** | Validation Error | - | + +| Status code | Description | Response headers | +| ----------- | ------------------- | ---------------- | +| **200** | Successful Response | - | +| **422** | Validation Error | - | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **get_service_by_did** + > List[Service] get_service_by_did(entity_did=entity_did, skip=skip, limit=limit) Get Service By Did @@ -250,15 +250,13 @@ with openapi_client.ApiClient(configuration) as api_client: print("Exception when calling ServicesApi->get_service_by_did: %s\n" % e) ``` - - ### Parameters -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **entity_did** | **str**| | [optional] [default to 'did:sov:test:1234'] - **skip** | **int**| | [optional] [default to 0] - **limit** | **int**| | [optional] [default to 100] +| Name | Type | Description | Notes | +| -------------- | ------- | ----------- | --------------------------------------------------- | +| **entity_did** | **str** | | [optional] [default to 'did:sov:test:1234'] | +| **skip** | **int** | | [optional] [default to 0] | +| **limit** | **int** | | [optional] [default to 100] | ### Return type @@ -270,18 +268,20 @@ No authorization required ### HTTP request headers - - **Content-Type**: Not defined - - **Accept**: application/json +- **Content-Type**: Not defined +- **Accept**: application/json ### HTTP response details -| Status code | Description | Response headers | -|-------------|-------------|------------------| -**200** | Successful Response | - | -**422** | Validation Error | - | + +| Status code | Description | Response headers | +| ----------- | ------------------- | ---------------- | +| **200** | Successful Response | - | +| **422** | Validation Error | - | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **get_services_without_entity** + > List[Service] get_services_without_entity(entity_did=entity_did, skip=skip, limit=limit) Get Services Without Entity @@ -320,15 +320,13 @@ with openapi_client.ApiClient(configuration) as api_client: print("Exception when calling ServicesApi->get_services_without_entity: %s\n" % e) ``` - - ### Parameters -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **entity_did** | **str**| | [optional] [default to 'did:sov:test:1234'] - **skip** | **int**| | [optional] [default to 0] - **limit** | **int**| | [optional] [default to 100] +| Name | Type | Description | Notes | +| -------------- | ------- | ----------- | --------------------------------------------------- | +| **entity_did** | **str** | | [optional] [default to 'did:sov:test:1234'] | +| **skip** | **int** | | [optional] [default to 0] | +| **limit** | **int** | | [optional] [default to 100] | ### Return type @@ -340,14 +338,14 @@ No authorization required ### HTTP request headers - - **Content-Type**: Not defined - - **Accept**: application/json +- **Content-Type**: Not defined +- **Accept**: application/json ### HTTP response details -| Status code | Description | Response headers | -|-------------|-------------|------------------| -**200** | Successful Response | - | -**422** | Validation Error | - | + +| Status code | Description | Response headers | +| ----------- | ------------------- | ---------------- | +| **200** | Successful Response | - | +| **422** | Validation Error | - | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) - diff --git a/pkgs/clan-cli/tests/openapi_client/docs/Status.md b/pkgs/clan-cli/tests/openapi_client/docs/Status.md index 3b89cf4..10bd223 100644 --- a/pkgs/clan-cli/tests/openapi_client/docs/Status.md +++ b/pkgs/clan-cli/tests/openapi_client/docs/Status.md @@ -3,9 +3,8 @@ An enumeration. ## Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) - - diff --git a/pkgs/clan-cli/tests/openapi_client/docs/ValidationError.md b/pkgs/clan-cli/tests/openapi_client/docs/ValidationError.md index 04310f6..b57b565 100644 --- a/pkgs/clan-cli/tests/openapi_client/docs/ValidationError.md +++ b/pkgs/clan-cli/tests/openapi_client/docs/ValidationError.md @@ -1,12 +1,12 @@ # ValidationError - ## Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**loc** | [**List[ValidationErrorLocInner]**](ValidationErrorLocInner.md) | | -**msg** | **str** | | -**type** | **str** | | + +| Name | Type | Description | Notes | +| -------- | --------------------------------------------------------------- | ----------- | ----- | +| **loc** | [**List[ValidationErrorLocInner]**](ValidationErrorLocInner.md) | | +| **msg** | **str** | | +| **type** | **str** | | ## Example @@ -25,6 +25,5 @@ validation_error_dict = validation_error_instance.to_dict() # create an instance of ValidationError from a dict validation_error_form_dict = validation_error.from_dict(validation_error_dict) ``` + [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) - - diff --git a/pkgs/clan-cli/tests/openapi_client/docs/ValidationErrorLocInner.md b/pkgs/clan-cli/tests/openapi_client/docs/ValidationErrorLocInner.md index 0bae52d..04e49df 100644 --- a/pkgs/clan-cli/tests/openapi_client/docs/ValidationErrorLocInner.md +++ b/pkgs/clan-cli/tests/openapi_client/docs/ValidationErrorLocInner.md @@ -1,9 +1,9 @@ # ValidationErrorLocInner - ## Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | ## Example @@ -22,6 +22,5 @@ validation_error_loc_inner_dict = validation_error_loc_inner_instance.to_dict() # create an instance of ValidationErrorLocInner from a dict validation_error_loc_inner_form_dict = validation_error_loc_inner.from_dict(validation_error_loc_inner_dict) ``` + [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) - - From 5bd84b85320d58fd64af4ad095d4dd8a7d33c4f9 Mon Sep 17 00:00:00 2001 From: ui-asset-bot Date: Mon, 8 Jan 2024 20:00:05 +0000 Subject: [PATCH 51/58] update ui-assets.nix --- pkgs/ui/nix/ui-assets.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/ui/nix/ui-assets.nix b/pkgs/ui/nix/ui-assets.nix index 540a756..1914722 100644 --- a/pkgs/ui/nix/ui-assets.nix +++ b/pkgs/ui/nix/ui-assets.nix @@ -1,5 +1,5 @@ { fetchzip }: fetchzip { - url = "https://gitea.gchq.icu/api/packages/IoSL/generic/IoSL-service-aware-frontend/16rrn5b3w5rjkf0j9zr14jgxc6wx0lg2c7c53xrlixlfnb8lip2b/assets.tar.gz"; - sha256 = "16rrn5b3w5rjkf0j9zr14jgxc6wx0lg2c7c53xrlixlfnb8lip2b"; + url = "https://gitea.gchq.icu/api/packages/IoSL/generic/IoSL-service-aware-frontend/0zz102k9sm0q9rlkrb06fkz2ap8i42gm65wr1qp4lxsg9kpgca70/assets.tar.gz"; + sha256 = "0zz102k9sm0q9rlkrb06fkz2ap8i42gm65wr1qp4lxsg9kpgca70"; } From a0c6dab00a2c201868c1175a553825a79b33e93f Mon Sep 17 00:00:00 2001 From: Luis-Hebendanz Date: Wed, 10 Jan 2024 14:17:41 +0100 Subject: [PATCH 52/58] Fixed broken populate flag --- pkgs/clan-cli/clan_cli/webui/server.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/clan-cli/clan_cli/webui/server.py b/pkgs/clan-cli/clan_cli/webui/server.py index 762ccb2..b1ad401 100644 --- a/pkgs/clan-cli/clan_cli/webui/server.py +++ b/pkgs/clan-cli/clan_cli/webui/server.py @@ -123,7 +123,7 @@ def start_server(args: argparse.Namespace) -> None: import subprocess - cmd = ["pytest", "-s", "-n0", str(test_db_api)] + cmd = ["pytest", "-s", str(test_db_api)] subprocess.run(cmd, check=True) uvicorn.run( From 9aa468b84e5b5fa43b5bce9ac6c49b0d4dcce2bf Mon Sep 17 00:00:00 2001 From: Georg-Stahn Date: Wed, 10 Jan 2024 15:35:47 +0100 Subject: [PATCH 53/58] small emulate changes --- README.md | 2 ++ pkgs/clan-cli/tests/emulate_fastapi.py | 3 +++ 2 files changed, 5 insertions(+) diff --git a/README.md b/README.md index 5d285c8..89d5105 100644 --- a/README.md +++ b/README.md @@ -78,6 +78,8 @@ sudo echo "experimental-features = nix-command flakes" > '/etc/nix/nix.conf' - The server will automatically restart if any Python files change. - The `--populate` flag will automatically populate the database with dummy data + - To emulate some distributed system behavior run `python3 tests/emulate_fastapi.py` + 8. **Build the Frontend**: - In a different shell, navigate to the `pkgs/ui` directory and execute: diff --git a/pkgs/clan-cli/tests/emulate_fastapi.py b/pkgs/clan-cli/tests/emulate_fastapi.py index 27a492f..1033a81 100644 --- a/pkgs/clan-cli/tests/emulate_fastapi.py +++ b/pkgs/clan-cli/tests/emulate_fastapi.py @@ -1,3 +1,5 @@ +import time + import uvicorn from fastapi import FastAPI from fastapi.responses import HTMLResponse @@ -21,6 +23,7 @@ async def consume_service_from_other_entity() -> HTMLResponse: """ + time.sleep(3) return HTMLResponse(content=html_content, status_code=200) From d56bad265fd934bfd727d5835d681ac1b4dafb8b Mon Sep 17 00:00:00 2001 From: Georg-Stahn Date: Wed, 10 Jan 2024 17:44:02 +0100 Subject: [PATCH 54/58] draft emulating flag --- pkgs/clan-cli/clan_cli/webui/schemas.py | 10 + pkgs/clan-cli/clan_cli/webui/server.py | 21 ++ pkgs/clan-cli/clan_cli/webui/sql_models.py | 7 +- pkgs/clan-cli/tests/api.py | 104 +++++++- pkgs/clan-cli/tests/emulate_fastapi.py | 61 ++++- .../clan-cli/tests/openapi_client/__init__.py | 1 + .../tests/openapi_client/docs/DefaultApi.md | 68 ++--- .../tests/openapi_client/docs/EntitiesApi.md | 240 +++++++++--------- .../tests/openapi_client/docs/Entity.md | 25 +- .../tests/openapi_client/docs/EntityCreate.md | 21 +- .../tests/openapi_client/docs/Eventmessage.md | 25 +- .../openapi_client/docs/EventmessageCreate.md | 25 +- .../openapi_client/docs/EventmessagesApi.md | 60 ++--- .../docs/HTTPValidationError.md | 11 +- .../tests/openapi_client/docs/Machine.md | 13 +- .../openapi_client/docs/RepositoriesApi.md | 34 +-- .../tests/openapi_client/docs/Resolution.md | 21 +- .../openapi_client/docs/ResolutionApi.md | 34 +-- .../tests/openapi_client/docs/Service.md | 25 +- .../openapi_client/docs/ServiceCreate.md | 23 +- .../tests/openapi_client/docs/ServicesApi.md | 140 +++++----- .../tests/openapi_client/docs/Status.md | 7 +- .../openapi_client/docs/ValidationError.md | 15 +- .../docs/ValidationErrorLocInner.md | 9 +- .../tests/openapi_client/models/__init__.py | 1 + .../tests/openapi_client/models/entity.py | 7 +- .../openapi_client/models/entity_create.py | 7 +- .../openapi_client/test/test_eventmessage.py | 67 ----- .../test/test_eventmessage_create.py | 67 ----- .../test/test_eventmessages_api.py | 45 ---- pkgs/clan-cli/tests/test_db_api.py | 33 ++- 31 files changed, 648 insertions(+), 579 deletions(-) delete mode 100644 pkgs/clan-cli/tests/openapi_client/test/test_eventmessage.py delete mode 100644 pkgs/clan-cli/tests/openapi_client/test/test_eventmessage_create.py delete mode 100644 pkgs/clan-cli/tests/openapi_client/test/test_eventmessages_api.py diff --git a/pkgs/clan-cli/clan_cli/webui/schemas.py b/pkgs/clan-cli/clan_cli/webui/schemas.py index b3175f0..ea2e3e3 100644 --- a/pkgs/clan-cli/clan_cli/webui/schemas.py +++ b/pkgs/clan-cli/clan_cli/webui/schemas.py @@ -11,6 +11,12 @@ class Status(Enum): UNKNOWN = "unknown" +class Roles(Enum): + PROSUMER = "service_prosumer" + AP = "AP" + DLG = "DLG" + + class Machine(BaseModel): name: str status: Status @@ -25,6 +31,10 @@ class EntityBase(BaseModel): did: str = Field(..., example="did:sov:test:1234") name: str = Field(..., example="C1") ip: str = Field(..., example="127.0.0.1") + network: str = Field(..., example="255.255.0.0") + role: Roles = Field( + ..., example=Roles("service_prosumer") + ) # roles are needed for UI to show the correct view visible: bool = Field(..., example=True) other: dict = Field( ..., diff --git a/pkgs/clan-cli/clan_cli/webui/server.py b/pkgs/clan-cli/clan_cli/webui/server.py index b1ad401..5d0f388 100644 --- a/pkgs/clan-cli/clan_cli/webui/server.py +++ b/pkgs/clan-cli/clan_cli/webui/server.py @@ -126,6 +126,27 @@ def start_server(args: argparse.Namespace) -> None: cmd = ["pytest", "-s", str(test_db_api)] subprocess.run(cmd, check=True) + if args.emulate: + # todo move emu + from .emulate_fastapi import (app_dlg, app_ap, app_c1, app_c2) + from .api import (get_health, port_dlg, port_ap, port_client_base) + import multiprocessing as mp + port = port_dlg + host = host + # server + proc = mp.Process( + target=uvicorn.run, + args=(app_dlg,), + kwargs={"host": host, "port": port, "log_level": "info"}, + daemon=True, + ) + proc.start() + + url = f"http://{host}:{port}" + res = get_health(url=url + "/health") + if res is None: + raise Exception(f"Couldn't reach {url} after starting server") + uvicorn.run( "clan_cli.webui.app:app", host=args.host, diff --git a/pkgs/clan-cli/clan_cli/webui/sql_models.py b/pkgs/clan-cli/clan_cli/webui/sql_models.py index 742b237..9b8bb29 100644 --- a/pkgs/clan-cli/clan_cli/webui/sql_models.py +++ b/pkgs/clan-cli/clan_cli/webui/sql_models.py @@ -1,6 +1,7 @@ -from sqlalchemy import JSON, Boolean, Column, ForeignKey, Integer, String, Text +from sqlalchemy import JSON, Boolean, Column, ForeignKey, Integer, String, Text, Enum from sqlalchemy.orm import relationship +from .schemas import Roles from .sql_db import Base # Relationsship example @@ -14,12 +15,14 @@ class Entity(Base): did = Column(String, primary_key=True, index=True) name = Column(String, index=True, unique=True) ip = Column(String, index=True) + network = Column(String, index=True) + role = Column(Enum(Roles), index=True) attached = Column(Boolean, index=True) visible = Column(Boolean, index=True) stop_health_task = Column(Boolean) ## Non queryable body ## - # In here we deposit: Network, Roles, Visible, etc. + # In here we deposit: Not yet defined stuff other = Column(JSON) ## Relations ## diff --git a/pkgs/clan-cli/tests/api.py b/pkgs/clan-cli/tests/api.py index 1c3644d..8e4c784 100644 --- a/pkgs/clan-cli/tests/api.py +++ b/pkgs/clan-cli/tests/api.py @@ -13,6 +13,15 @@ from ports import PortFunction from clan_cli.webui.app import app +import emulate_fastapi + + +# TODO config file +#is linked to the emulate_fastapi.py and api.py +host = "127.0.0.1" +port_dlg = 6000 +port_ap = 6600 +port_client_base = 7000 @pytest.fixture(scope="session") def test_client() -> TestClient: @@ -31,10 +40,11 @@ def get_health(*, url: str, max_retries: int = 20, delay: float = 0.2) -> str | # Pytest fixture to run the server in a separate process +# server @pytest.fixture(scope="session") def server_url(unused_tcp_port: PortFunction) -> Generator[str, None, None]: port = unused_tcp_port() - host = "127.0.0.1" + host = host proc = Process( target=uvicorn.run, args=(app,), @@ -51,6 +61,98 @@ def server_url(unused_tcp_port: PortFunction) -> Generator[str, None, None]: yield url proc.terminate() +# Pytest fixture to run the server in a separate process +# emulating c1 +@pytest.fixture(scope="session") +def server_c1() -> Generator[str, None, None]: + port = port_client_base + host = host + # server + proc = Process( + target=uvicorn.run, + args=(app,), + kwargs={"host": host, "port": port, "log_level": "info"}, + daemon=True, + ) + proc.start() + + url = f"http://{host}:{port}" + res = get_health(url=url + "/health") + if res is None: + raise Exception(f"Couldn't reach {url} after starting server") + + yield url + proc.terminate() + +# Pytest fixture to run the server in a separate process +# emulating c2 +@pytest.fixture(scope="session") +def server_c2() -> Generator[str, None, None]: + port = port_client_base+1 + host = host + # server + proc = Process( + target=uvicorn.run, + args=(app,), + kwargs={"host": host, "port": port, "log_level": "info"}, + daemon=True, + ) + proc.start() + + url = f"http://{host}:{port}" + res = get_health(url=url + "/health") + if res is None: + raise Exception(f"Couldn't reach {url} after starting server") + + yield url + proc.terminate() + proc.terminate() + +# Pytest fixture to run the server in a separate process +# emulating ap +@pytest.fixture(scope="session") +def server_ap() -> Generator[str, None, None]: + port = port_ap + host = host + # server + proc = Process( + target=uvicorn.run, + args=(app,), + kwargs={"host": host, "port": port, "log_level": "info"}, + daemon=True, + ) + proc.start() + + url = f"http://{host}:{port}" + res = get_health(url=url + "/health") + if res is None: + raise Exception(f"Couldn't reach {url} after starting server") + + yield url + proc.terminate() + +# Pytest fixture to run the server in a separate process +# emulating dlg +@pytest.fixture(scope="session") +def server_dlg() -> Generator[str, None, None]: + port = port_dlg + host = host + # server + proc = Process( + target=uvicorn.run, + args=(app,), + kwargs={"host": host, "port": port, "log_level": "info"}, + daemon=True, + ) + proc.start() + + url = f"http://{host}:{port}" + res = get_health(url=url + "/health") + if res is None: + raise Exception(f"Couldn't reach {url} after starting server") + + yield url + proc.terminate() @pytest.fixture(scope="session") def api_client(server_url: str) -> Generator[ApiClient, None, None]: diff --git a/pkgs/clan-cli/tests/emulate_fastapi.py b/pkgs/clan-cli/tests/emulate_fastapi.py index 1033a81..c131f54 100644 --- a/pkgs/clan-cli/tests/emulate_fastapi.py +++ b/pkgs/clan-cli/tests/emulate_fastapi.py @@ -1,20 +1,61 @@ +import sys import time - +import urllib import uvicorn from fastapi import FastAPI from fastapi.responses import HTMLResponse +import test_db_api -app = FastAPI() +app_dlg = FastAPI() +app_ap = FastAPI() +app_c1 = FastAPI() +app_c2 = FastAPI() # bash tests: curl localhost:8000/ap_list_of_services -@app.get("/health") +#### HEALTH + +@app_c1.get("/health") +async def healthcheck() -> str: + return "200 OK" +@app_c2.get("/health") +async def healthcheck() -> str: + return "200 OK" +@app_dlg.get("/health") +async def healthcheck() -> str: + return "200 OK" +@app_ap.get("/health") async def healthcheck() -> str: return "200 OK" +def get_health(*, url: str, max_retries: int = 20, delay: float = 0.2) -> str | None: + for attempt in range(max_retries): + try: + with urllib.request.urlopen(url) as response: + return response.read() + except urllib.URLError as e: + print(f"Attempt {attempt + 1} failed: {e.reason}", file=sys.stderr) + time.sleep(delay) + return None -@app.get("/consume_service_from_other_entity", response_class=HTMLResponse) + +#### CONSUME SERVICE + +# TODO send_msg??? + +@app_c1.get("/consume_service_from_other_entity", response_class=HTMLResponse) +async def consume_service_from_other_entity() -> HTMLResponse: + html_content = """ + + +
+ + + """ + time.sleep(3) + return HTMLResponse(content=html_content, status_code=200) +@app_c2.get("/consume_service_from_other_entity", response_class=HTMLResponse) async def consume_service_from_other_entity() -> HTMLResponse: html_content = """ @@ -27,7 +68,9 @@ async def consume_service_from_other_entity() -> HTMLResponse: return HTMLResponse(content=html_content, status_code=200) -@app.get("/ap_list_of_services", response_class=HTMLResponse) +#### ap_list_of_services + +@app_ap.get("/ap_list_of_services", response_class=HTMLResponse) async def ap_list_of_services() -> HTMLResponse: html_content = b"""HTTP/1.1 200 OK\r\n\r\n[[ { @@ -114,7 +157,7 @@ async def ap_list_of_services() -> HTMLResponse: return HTMLResponse(content=html_content, status_code=200) -@app.get("/dlg_list_of_did_resolutions", response_class=HTMLResponse) +@app_dlg.get("/dlg_list_of_did_resolutions", response_class=HTMLResponse) async def dlg_list_of_did_resolutions() -> HTMLResponse: html_content = b"""HTTP/1.1 200 OK\r\n\r\n [ @@ -149,5 +192,7 @@ async def dlg_list_of_did_resolutions() -> HTMLResponse: ]""" return HTMLResponse(content=html_content, status_code=200) - -uvicorn.run(app, host="localhost", port=8000) +uvicorn.run(app_dlg, host=f"{test_db_api.host}", port=test_db_api.port_dlg) +uvicorn.run(app_ap, host=f"{test_db_api.host}", port=test_db_api.port_dlg) +uvicorn.run(app_c1, host=f"{test_db_api.host}", port=test_db_api.port_client_base) +uvicorn.run(app_c2, host=f"{test_db_api.host}", port=test_db_api.port_client_base+1) diff --git a/pkgs/clan-cli/tests/openapi_client/__init__.py b/pkgs/clan-cli/tests/openapi_client/__init__.py index c30337b..b3656f9 100644 --- a/pkgs/clan-cli/tests/openapi_client/__init__.py +++ b/pkgs/clan-cli/tests/openapi_client/__init__.py @@ -43,6 +43,7 @@ from openapi_client.models.eventmessage_create import EventmessageCreate from openapi_client.models.http_validation_error import HTTPValidationError from openapi_client.models.machine import Machine from openapi_client.models.resolution import Resolution +from openapi_client.models.roles import Roles from openapi_client.models.service import Service from openapi_client.models.service_create import ServiceCreate from openapi_client.models.status import Status diff --git a/pkgs/clan-cli/tests/openapi_client/docs/DefaultApi.md b/pkgs/clan-cli/tests/openapi_client/docs/DefaultApi.md index aef64f7..9a4a45c 100644 --- a/pkgs/clan-cli/tests/openapi_client/docs/DefaultApi.md +++ b/pkgs/clan-cli/tests/openapi_client/docs/DefaultApi.md @@ -1,15 +1,15 @@ # openapi_client.DefaultApi -All URIs are relative to _http://localhost_ +All URIs are relative to *http://localhost* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**get**](DefaultApi.md#get) | **GET** /ws2_example | Get +[**health**](DefaultApi.md#health) | **GET** /health | Health +[**root**](DefaultApi.md#root) | **GET** /{path_name} | Root -| Method | HTTP request | Description | -| ---------------------------------- | -------------------- | ----------- | -| [**get**](DefaultApi.md#get) | **GET** /ws2_example | Get | -| [**health**](DefaultApi.md#health) | **GET** /health | Health | -| [**root**](DefaultApi.md#root) | **GET** /{path_name} | Root | # **get** - > get() Get @@ -42,8 +42,9 @@ with openapi_client.ApiClient(configuration) as api_client: print("Exception when calling DefaultApi->get: %s\n" % e) ``` -### Parameters + +### Parameters This endpoint does not need any parameter. ### Return type @@ -56,19 +57,17 @@ No authorization required ### HTTP request headers -- **Content-Type**: Not defined -- **Accept**: application/json + - **Content-Type**: Not defined + - **Accept**: application/json ### HTTP response details - -| Status code | Description | Response headers | -| ----------- | ------------------- | ---------------- | -| **200** | Successful Response | - | +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | Successful Response | - | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **health** - > Machine health() Health @@ -104,8 +103,9 @@ with openapi_client.ApiClient(configuration) as api_client: print("Exception when calling DefaultApi->health: %s\n" % e) ``` -### Parameters + +### Parameters This endpoint does not need any parameter. ### Return type @@ -118,19 +118,17 @@ No authorization required ### HTTP request headers -- **Content-Type**: Not defined -- **Accept**: application/json + - **Content-Type**: Not defined + - **Accept**: application/json ### HTTP response details - -| Status code | Description | Response headers | -| ----------- | ------------------- | ---------------- | -| **200** | Successful Response | - | +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | Successful Response | - | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **root** - > root(path_name) Root @@ -155,7 +153,7 @@ configuration = openapi_client.Configuration( with openapi_client.ApiClient(configuration) as api_client: # Create an instance of the API class api_instance = openapi_client.DefaultApi(api_client) - path_name = 'path_name_example' # str | + path_name = 'path_name_example' # str | try: # Root @@ -164,11 +162,13 @@ with openapi_client.ApiClient(configuration) as api_client: print("Exception when calling DefaultApi->root: %s\n" % e) ``` + + ### Parameters -| Name | Type | Description | Notes | -| ------------- | ------- | ----------- | ----- | -| **path_name** | **str** | | +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **path_name** | **str**| | ### Return type @@ -180,14 +180,14 @@ No authorization required ### HTTP request headers -- **Content-Type**: Not defined -- **Accept**: application/json + - **Content-Type**: Not defined + - **Accept**: application/json ### HTTP response details - -| Status code | Description | Response headers | -| ----------- | ------------------- | ---------------- | -| **200** | Successful Response | - | -| **422** | Validation Error | - | +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | Successful Response | - | +**422** | Validation Error | - | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + diff --git a/pkgs/clan-cli/tests/openapi_client/docs/EntitiesApi.md b/pkgs/clan-cli/tests/openapi_client/docs/EntitiesApi.md index dc621f8..4a99b6c 100644 --- a/pkgs/clan-cli/tests/openapi_client/docs/EntitiesApi.md +++ b/pkgs/clan-cli/tests/openapi_client/docs/EntitiesApi.md @@ -1,21 +1,21 @@ # openapi_client.EntitiesApi -All URIs are relative to _http://localhost_ +All URIs are relative to *http://localhost* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**attach_entity**](EntitiesApi.md#attach_entity) | **POST** /api/v1/attach | Attach Entity +[**create_entity**](EntitiesApi.md#create_entity) | **POST** /api/v1/entity | Create Entity +[**delete_entity**](EntitiesApi.md#delete_entity) | **DELETE** /api/v1/entity | Delete Entity +[**detach_entity**](EntitiesApi.md#detach_entity) | **POST** /api/v1/detach | Detach Entity +[**get_all_entities**](EntitiesApi.md#get_all_entities) | **GET** /api/v1/entities | Get All Entities +[**get_attached_entities**](EntitiesApi.md#get_attached_entities) | **GET** /api/v1/attached_entities | Get Attached Entities +[**get_entity_by_did**](EntitiesApi.md#get_entity_by_did) | **GET** /api/v1/entity | Get Entity By Did +[**get_entity_by_name**](EntitiesApi.md#get_entity_by_name) | **GET** /api/v1/entity_by_name | Get Entity By Name +[**is_attached**](EntitiesApi.md#is_attached) | **GET** /api/v1/is_attached | Is Attached -| Method | HTTP request | Description | -| ----------------------------------------------------------------- | --------------------------------- | --------------------- | -| [**attach_entity**](EntitiesApi.md#attach_entity) | **POST** /api/v1/attach | Attach Entity | -| [**create_entity**](EntitiesApi.md#create_entity) | **POST** /api/v1/entity | Create Entity | -| [**delete_entity**](EntitiesApi.md#delete_entity) | **DELETE** /api/v1/entity | Delete Entity | -| [**detach_entity**](EntitiesApi.md#detach_entity) | **POST** /api/v1/detach | Detach Entity | -| [**get_all_entities**](EntitiesApi.md#get_all_entities) | **GET** /api/v1/entities | Get All Entities | -| [**get_attached_entities**](EntitiesApi.md#get_attached_entities) | **GET** /api/v1/attached_entities | Get Attached Entities | -| [**get_entity_by_did**](EntitiesApi.md#get_entity_by_did) | **GET** /api/v1/entity | Get Entity By Did | -| [**get_entity_by_name**](EntitiesApi.md#get_entity_by_name) | **GET** /api/v1/entity_by_name | Get Entity By Name | -| [**is_attached**](EntitiesApi.md#is_attached) | **GET** /api/v1/is_attached | Is Attached | # **attach_entity** - > Dict[str, str] attach_entity(entity_did=entity_did, skip=skip, limit=limit) Attach Entity @@ -53,13 +53,15 @@ with openapi_client.ApiClient(configuration) as api_client: print("Exception when calling EntitiesApi->attach_entity: %s\n" % e) ``` + + ### Parameters -| Name | Type | Description | Notes | -| -------------- | ------- | ----------- | --------------------------------------------------- | -| **entity_did** | **str** | | [optional] [default to 'did:sov:test:1234'] | -| **skip** | **int** | | [optional] [default to 0] | -| **limit** | **int** | | [optional] [default to 100] | +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **entity_did** | **str**| | [optional] [default to 'did:sov:test:1234'] + **skip** | **int**| | [optional] [default to 0] + **limit** | **int**| | [optional] [default to 100] ### Return type @@ -71,20 +73,18 @@ No authorization required ### HTTP request headers -- **Content-Type**: Not defined -- **Accept**: application/json + - **Content-Type**: Not defined + - **Accept**: application/json ### HTTP response details - -| Status code | Description | Response headers | -| ----------- | ------------------- | ---------------- | -| **200** | Successful Response | - | -| **422** | Validation Error | - | +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | Successful Response | - | +**422** | Validation Error | - | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **create_entity** - > Entity create_entity(entity_create) Create Entity @@ -111,7 +111,7 @@ configuration = openapi_client.Configuration( with openapi_client.ApiClient(configuration) as api_client: # Create an instance of the API class api_instance = openapi_client.EntitiesApi(api_client) - entity_create = openapi_client.EntityCreate() # EntityCreate | + entity_create = openapi_client.EntityCreate() # EntityCreate | try: # Create Entity @@ -122,11 +122,13 @@ with openapi_client.ApiClient(configuration) as api_client: print("Exception when calling EntitiesApi->create_entity: %s\n" % e) ``` + + ### Parameters -| Name | Type | Description | Notes | -| ----------------- | ----------------------------------- | ----------- | ----- | -| **entity_create** | [**EntityCreate**](EntityCreate.md) | | +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **entity_create** | [**EntityCreate**](EntityCreate.md)| | ### Return type @@ -138,20 +140,18 @@ No authorization required ### HTTP request headers -- **Content-Type**: application/json -- **Accept**: application/json + - **Content-Type**: application/json + - **Accept**: application/json ### HTTP response details - -| Status code | Description | Response headers | -| ----------- | ------------------- | ---------------- | -| **200** | Successful Response | - | -| **422** | Validation Error | - | +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | Successful Response | - | +**422** | Validation Error | - | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **delete_entity** - > Dict[str, str] delete_entity(entity_did=entity_did) Delete Entity @@ -187,11 +187,13 @@ with openapi_client.ApiClient(configuration) as api_client: print("Exception when calling EntitiesApi->delete_entity: %s\n" % e) ``` + + ### Parameters -| Name | Type | Description | Notes | -| -------------- | ------- | ----------- | --------------------------------------------------- | -| **entity_did** | **str** | | [optional] [default to 'did:sov:test:1234'] | +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **entity_did** | **str**| | [optional] [default to 'did:sov:test:1234'] ### Return type @@ -203,20 +205,18 @@ No authorization required ### HTTP request headers -- **Content-Type**: Not defined -- **Accept**: application/json + - **Content-Type**: Not defined + - **Accept**: application/json ### HTTP response details - -| Status code | Description | Response headers | -| ----------- | ------------------- | ---------------- | -| **200** | Successful Response | - | -| **422** | Validation Error | - | +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | Successful Response | - | +**422** | Validation Error | - | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **detach_entity** - > Dict[str, str] detach_entity(entity_did=entity_did, skip=skip, limit=limit) Detach Entity @@ -254,13 +254,15 @@ with openapi_client.ApiClient(configuration) as api_client: print("Exception when calling EntitiesApi->detach_entity: %s\n" % e) ``` + + ### Parameters -| Name | Type | Description | Notes | -| -------------- | ------- | ----------- | --------------------------------------------------- | -| **entity_did** | **str** | | [optional] [default to 'did:sov:test:1234'] | -| **skip** | **int** | | [optional] [default to 0] | -| **limit** | **int** | | [optional] [default to 100] | +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **entity_did** | **str**| | [optional] [default to 'did:sov:test:1234'] + **skip** | **int**| | [optional] [default to 0] + **limit** | **int**| | [optional] [default to 100] ### Return type @@ -272,20 +274,18 @@ No authorization required ### HTTP request headers -- **Content-Type**: Not defined -- **Accept**: application/json + - **Content-Type**: Not defined + - **Accept**: application/json ### HTTP response details - -| Status code | Description | Response headers | -| ----------- | ------------------- | ---------------- | -| **200** | Successful Response | - | -| **422** | Validation Error | - | +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | Successful Response | - | +**422** | Validation Error | - | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **get_all_entities** - > List[Entity] get_all_entities(skip=skip, limit=limit) Get All Entities @@ -323,12 +323,14 @@ with openapi_client.ApiClient(configuration) as api_client: print("Exception when calling EntitiesApi->get_all_entities: %s\n" % e) ``` + + ### Parameters -| Name | Type | Description | Notes | -| --------- | ------- | ----------- | --------------------------- | -| **skip** | **int** | | [optional] [default to 0] | -| **limit** | **int** | | [optional] [default to 100] | +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **skip** | **int**| | [optional] [default to 0] + **limit** | **int**| | [optional] [default to 100] ### Return type @@ -340,20 +342,18 @@ No authorization required ### HTTP request headers -- **Content-Type**: Not defined -- **Accept**: application/json + - **Content-Type**: Not defined + - **Accept**: application/json ### HTTP response details - -| Status code | Description | Response headers | -| ----------- | ------------------- | ---------------- | -| **200** | Successful Response | - | -| **422** | Validation Error | - | +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | Successful Response | - | +**422** | Validation Error | - | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **get_attached_entities** - > List[Entity] get_attached_entities(skip=skip, limit=limit) Get Attached Entities @@ -391,12 +391,14 @@ with openapi_client.ApiClient(configuration) as api_client: print("Exception when calling EntitiesApi->get_attached_entities: %s\n" % e) ``` + + ### Parameters -| Name | Type | Description | Notes | -| --------- | ------- | ----------- | --------------------------- | -| **skip** | **int** | | [optional] [default to 0] | -| **limit** | **int** | | [optional] [default to 100] | +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **skip** | **int**| | [optional] [default to 0] + **limit** | **int**| | [optional] [default to 100] ### Return type @@ -408,20 +410,18 @@ No authorization required ### HTTP request headers -- **Content-Type**: Not defined -- **Accept**: application/json + - **Content-Type**: Not defined + - **Accept**: application/json ### HTTP response details - -| Status code | Description | Response headers | -| ----------- | ------------------- | ---------------- | -| **200** | Successful Response | - | -| **422** | Validation Error | - | +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | Successful Response | - | +**422** | Validation Error | - | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **get_entity_by_did** - > Entity get_entity_by_did(entity_did=entity_did) Get Entity By Did @@ -458,11 +458,13 @@ with openapi_client.ApiClient(configuration) as api_client: print("Exception when calling EntitiesApi->get_entity_by_did: %s\n" % e) ``` + + ### Parameters -| Name | Type | Description | Notes | -| -------------- | ------- | ----------- | --------------------------------------------------- | -| **entity_did** | **str** | | [optional] [default to 'did:sov:test:1234'] | +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **entity_did** | **str**| | [optional] [default to 'did:sov:test:1234'] ### Return type @@ -474,20 +476,18 @@ No authorization required ### HTTP request headers -- **Content-Type**: Not defined -- **Accept**: application/json + - **Content-Type**: Not defined + - **Accept**: application/json ### HTTP response details - -| Status code | Description | Response headers | -| ----------- | ------------------- | ---------------- | -| **200** | Successful Response | - | -| **422** | Validation Error | - | +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | Successful Response | - | +**422** | Validation Error | - | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **get_entity_by_name** - > Entity get_entity_by_name(entity_name) Get Entity By Name @@ -513,7 +513,7 @@ configuration = openapi_client.Configuration( with openapi_client.ApiClient(configuration) as api_client: # Create an instance of the API class api_instance = openapi_client.EntitiesApi(api_client) - entity_name = 'entity_name_example' # str | + entity_name = 'entity_name_example' # str | try: # Get Entity By Name @@ -524,11 +524,13 @@ with openapi_client.ApiClient(configuration) as api_client: print("Exception when calling EntitiesApi->get_entity_by_name: %s\n" % e) ``` + + ### Parameters -| Name | Type | Description | Notes | -| --------------- | ------- | ----------- | ----- | -| **entity_name** | **str** | | +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **entity_name** | **str**| | ### Return type @@ -540,20 +542,18 @@ No authorization required ### HTTP request headers -- **Content-Type**: Not defined -- **Accept**: application/json + - **Content-Type**: Not defined + - **Accept**: application/json ### HTTP response details - -| Status code | Description | Response headers | -| ----------- | ------------------- | ---------------- | -| **200** | Successful Response | - | -| **422** | Validation Error | - | +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | Successful Response | - | +**422** | Validation Error | - | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **is_attached** - > Dict[str, str] is_attached(entity_did=entity_did) Is Attached @@ -589,11 +589,13 @@ with openapi_client.ApiClient(configuration) as api_client: print("Exception when calling EntitiesApi->is_attached: %s\n" % e) ``` + + ### Parameters -| Name | Type | Description | Notes | -| -------------- | ------- | ----------- | --------------------------------------------------- | -| **entity_did** | **str** | | [optional] [default to 'did:sov:test:1234'] | +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **entity_did** | **str**| | [optional] [default to 'did:sov:test:1234'] ### Return type @@ -605,14 +607,14 @@ No authorization required ### HTTP request headers -- **Content-Type**: Not defined -- **Accept**: application/json + - **Content-Type**: Not defined + - **Accept**: application/json ### HTTP response details - -| Status code | Description | Response headers | -| ----------- | ------------------- | ---------------- | -| **200** | Successful Response | - | -| **422** | Validation Error | - | +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | Successful Response | - | +**422** | Validation Error | - | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + diff --git a/pkgs/clan-cli/tests/openapi_client/docs/Entity.md b/pkgs/clan-cli/tests/openapi_client/docs/Entity.md index fa7efb2..4818b3b 100644 --- a/pkgs/clan-cli/tests/openapi_client/docs/Entity.md +++ b/pkgs/clan-cli/tests/openapi_client/docs/Entity.md @@ -1,16 +1,18 @@ # Entity -## Properties -| Name | Type | Description | Notes | -| -------------------- | ---------- | ----------- | ----- | -| **did** | **str** | | -| **name** | **str** | | -| **ip** | **str** | | -| **visible** | **bool** | | -| **other** | **object** | | -| **attached** | **bool** | | -| **stop_health_task** | **bool** | | +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**did** | **str** | | +**name** | **str** | | +**ip** | **str** | | +**network** | **str** | | +**role** | [**Roles**](Roles.md) | | +**visible** | **bool** | | +**other** | **object** | | +**attached** | **bool** | | +**stop_health_task** | **bool** | | ## Example @@ -29,5 +31,6 @@ entity_dict = entity_instance.to_dict() # create an instance of Entity from a dict entity_form_dict = entity.from_dict(entity_dict) ``` - [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/pkgs/clan-cli/tests/openapi_client/docs/EntityCreate.md b/pkgs/clan-cli/tests/openapi_client/docs/EntityCreate.md index 4fff16a..306e4c0 100644 --- a/pkgs/clan-cli/tests/openapi_client/docs/EntityCreate.md +++ b/pkgs/clan-cli/tests/openapi_client/docs/EntityCreate.md @@ -1,14 +1,16 @@ # EntityCreate -## Properties -| Name | Type | Description | Notes | -| ----------- | ---------- | ----------- | ----- | -| **did** | **str** | | -| **name** | **str** | | -| **ip** | **str** | | -| **visible** | **bool** | | -| **other** | **object** | | +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**did** | **str** | | +**name** | **str** | | +**ip** | **str** | | +**network** | **str** | | +**role** | [**Roles**](Roles.md) | | +**visible** | **bool** | | +**other** | **object** | | ## Example @@ -27,5 +29,6 @@ entity_create_dict = entity_create_instance.to_dict() # create an instance of EntityCreate from a dict entity_create_form_dict = entity_create.from_dict(entity_create_dict) ``` - [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/pkgs/clan-cli/tests/openapi_client/docs/Eventmessage.md b/pkgs/clan-cli/tests/openapi_client/docs/Eventmessage.md index cbe65cb..e51e987 100644 --- a/pkgs/clan-cli/tests/openapi_client/docs/Eventmessage.md +++ b/pkgs/clan-cli/tests/openapi_client/docs/Eventmessage.md @@ -1,17 +1,17 @@ # Eventmessage -## Properties -| Name | Type | Description | Notes | -| ------------- | ---------- | ----------- | ----- | -| **id** | **int** | | -| **timestamp** | **int** | | -| **group** | **int** | | -| **group_id** | **int** | | -| **msg_type** | **int** | | -| **src_did** | **str** | | -| **des_did** | **str** | | -| **msg** | **object** | | +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | **int** | | +**timestamp** | **int** | | +**group** | **int** | | +**group_id** | **int** | | +**msg_type** | **int** | | +**src_did** | **str** | | +**des_did** | **str** | | +**msg** | **object** | | ## Example @@ -30,5 +30,6 @@ eventmessage_dict = eventmessage_instance.to_dict() # create an instance of Eventmessage from a dict eventmessage_form_dict = eventmessage.from_dict(eventmessage_dict) ``` - [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/pkgs/clan-cli/tests/openapi_client/docs/EventmessageCreate.md b/pkgs/clan-cli/tests/openapi_client/docs/EventmessageCreate.md index eb6f16d..bfb7347 100644 --- a/pkgs/clan-cli/tests/openapi_client/docs/EventmessageCreate.md +++ b/pkgs/clan-cli/tests/openapi_client/docs/EventmessageCreate.md @@ -1,17 +1,17 @@ # EventmessageCreate -## Properties -| Name | Type | Description | Notes | -| ------------- | ---------- | ----------- | ----- | -| **id** | **int** | | -| **timestamp** | **int** | | -| **group** | **int** | | -| **group_id** | **int** | | -| **msg_type** | **int** | | -| **src_did** | **str** | | -| **des_did** | **str** | | -| **msg** | **object** | | +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | **int** | | +**timestamp** | **int** | | +**group** | **int** | | +**group_id** | **int** | | +**msg_type** | **int** | | +**src_did** | **str** | | +**des_did** | **str** | | +**msg** | **object** | | ## Example @@ -30,5 +30,6 @@ eventmessage_create_dict = eventmessage_create_instance.to_dict() # create an instance of EventmessageCreate from a dict eventmessage_create_form_dict = eventmessage_create.from_dict(eventmessage_create_dict) ``` - [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/pkgs/clan-cli/tests/openapi_client/docs/EventmessagesApi.md b/pkgs/clan-cli/tests/openapi_client/docs/EventmessagesApi.md index d6affb9..e146d13 100644 --- a/pkgs/clan-cli/tests/openapi_client/docs/EventmessagesApi.md +++ b/pkgs/clan-cli/tests/openapi_client/docs/EventmessagesApi.md @@ -1,14 +1,14 @@ # openapi_client.EventmessagesApi -All URIs are relative to _http://localhost_ +All URIs are relative to *http://localhost* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**create_eventmessage**](EventmessagesApi.md#create_eventmessage) | **POST** /api/v1/send_msg | Create Eventmessage +[**get_all_eventmessages**](EventmessagesApi.md#get_all_eventmessages) | **GET** /api/v1/event_messages | Get All Eventmessages -| Method | HTTP request | Description | -| ---------------------------------------------------------------------- | ------------------------------ | --------------------- | -| [**create_eventmessage**](EventmessagesApi.md#create_eventmessage) | **POST** /api/v1/send_msg | Create Eventmessage | -| [**get_all_eventmessages**](EventmessagesApi.md#get_all_eventmessages) | **GET** /api/v1/event_messages | Get All Eventmessages | # **create_eventmessage** - > Eventmessage create_eventmessage(eventmessage_create) Create Eventmessage @@ -35,7 +35,7 @@ configuration = openapi_client.Configuration( with openapi_client.ApiClient(configuration) as api_client: # Create an instance of the API class api_instance = openapi_client.EventmessagesApi(api_client) - eventmessage_create = openapi_client.EventmessageCreate() # EventmessageCreate | + eventmessage_create = openapi_client.EventmessageCreate() # EventmessageCreate | try: # Create Eventmessage @@ -46,11 +46,13 @@ with openapi_client.ApiClient(configuration) as api_client: print("Exception when calling EventmessagesApi->create_eventmessage: %s\n" % e) ``` + + ### Parameters -| Name | Type | Description | Notes | -| ----------------------- | ----------------------------------------------- | ----------- | ----- | -| **eventmessage_create** | [**EventmessageCreate**](EventmessageCreate.md) | | +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **eventmessage_create** | [**EventmessageCreate**](EventmessageCreate.md)| | ### Return type @@ -62,20 +64,18 @@ No authorization required ### HTTP request headers -- **Content-Type**: application/json -- **Accept**: application/json + - **Content-Type**: application/json + - **Accept**: application/json ### HTTP response details - -| Status code | Description | Response headers | -| ----------- | ------------------- | ---------------- | -| **200** | Successful Response | - | -| **422** | Validation Error | - | +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | Successful Response | - | +**422** | Validation Error | - | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **get_all_eventmessages** - > List[Eventmessage] get_all_eventmessages(skip=skip, limit=limit) Get All Eventmessages @@ -113,12 +113,14 @@ with openapi_client.ApiClient(configuration) as api_client: print("Exception when calling EventmessagesApi->get_all_eventmessages: %s\n" % e) ``` + + ### Parameters -| Name | Type | Description | Notes | -| --------- | ------- | ----------- | --------------------------- | -| **skip** | **int** | | [optional] [default to 0] | -| **limit** | **int** | | [optional] [default to 100] | +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **skip** | **int**| | [optional] [default to 0] + **limit** | **int**| | [optional] [default to 100] ### Return type @@ -130,14 +132,14 @@ No authorization required ### HTTP request headers -- **Content-Type**: Not defined -- **Accept**: application/json + - **Content-Type**: Not defined + - **Accept**: application/json ### HTTP response details - -| Status code | Description | Response headers | -| ----------- | ------------------- | ---------------- | -| **200** | Successful Response | - | -| **422** | Validation Error | - | +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | Successful Response | - | +**422** | Validation Error | - | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + diff --git a/pkgs/clan-cli/tests/openapi_client/docs/HTTPValidationError.md b/pkgs/clan-cli/tests/openapi_client/docs/HTTPValidationError.md index d4902e7..5eee49b 100644 --- a/pkgs/clan-cli/tests/openapi_client/docs/HTTPValidationError.md +++ b/pkgs/clan-cli/tests/openapi_client/docs/HTTPValidationError.md @@ -1,10 +1,10 @@ # HTTPValidationError -## Properties -| Name | Type | Description | Notes | -| ---------- | ----------------------------------------------- | ----------- | ---------- | -| **detail** | [**List[ValidationError]**](ValidationError.md) | | [optional] | +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**detail** | [**List[ValidationError]**](ValidationError.md) | | [optional] ## Example @@ -23,5 +23,6 @@ http_validation_error_dict = http_validation_error_instance.to_dict() # create an instance of HTTPValidationError from a dict http_validation_error_form_dict = http_validation_error.from_dict(http_validation_error_dict) ``` - [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/pkgs/clan-cli/tests/openapi_client/docs/Machine.md b/pkgs/clan-cli/tests/openapi_client/docs/Machine.md index 062fd51..4ea6dc3 100644 --- a/pkgs/clan-cli/tests/openapi_client/docs/Machine.md +++ b/pkgs/clan-cli/tests/openapi_client/docs/Machine.md @@ -1,11 +1,11 @@ # Machine -## Properties -| Name | Type | Description | Notes | -| ---------- | ----------------------- | ----------- | ----- | -| **name** | **str** | | -| **status** | [**Status**](Status.md) | | +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**name** | **str** | | +**status** | [**Status**](Status.md) | | ## Example @@ -24,5 +24,6 @@ machine_dict = machine_instance.to_dict() # create an instance of Machine from a dict machine_form_dict = machine.from_dict(machine_dict) ``` - [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/pkgs/clan-cli/tests/openapi_client/docs/RepositoriesApi.md b/pkgs/clan-cli/tests/openapi_client/docs/RepositoriesApi.md index ff735f0..7a24ab0 100644 --- a/pkgs/clan-cli/tests/openapi_client/docs/RepositoriesApi.md +++ b/pkgs/clan-cli/tests/openapi_client/docs/RepositoriesApi.md @@ -1,13 +1,13 @@ # openapi_client.RepositoriesApi -All URIs are relative to _http://localhost_ +All URIs are relative to *http://localhost* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**get_all_repositories**](RepositoriesApi.md#get_all_repositories) | **GET** /api/v1/repositories | Get All Repositories -| Method | HTTP request | Description | -| ------------------------------------------------------------------- | ---------------------------- | -------------------- | -| [**get_all_repositories**](RepositoriesApi.md#get_all_repositories) | **GET** /api/v1/repositories | Get All Repositories | # **get_all_repositories** - > List[Service] get_all_repositories(skip=skip, limit=limit) Get All Repositories @@ -45,12 +45,14 @@ with openapi_client.ApiClient(configuration) as api_client: print("Exception when calling RepositoriesApi->get_all_repositories: %s\n" % e) ``` + + ### Parameters -| Name | Type | Description | Notes | -| --------- | ------- | ----------- | --------------------------- | -| **skip** | **int** | | [optional] [default to 0] | -| **limit** | **int** | | [optional] [default to 100] | +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **skip** | **int**| | [optional] [default to 0] + **limit** | **int**| | [optional] [default to 100] ### Return type @@ -62,14 +64,14 @@ No authorization required ### HTTP request headers -- **Content-Type**: Not defined -- **Accept**: application/json + - **Content-Type**: Not defined + - **Accept**: application/json ### HTTP response details - -| Status code | Description | Response headers | -| ----------- | ------------------- | ---------------- | -| **200** | Successful Response | - | -| **422** | Validation Error | - | +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | Successful Response | - | +**422** | Validation Error | - | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + diff --git a/pkgs/clan-cli/tests/openapi_client/docs/Resolution.md b/pkgs/clan-cli/tests/openapi_client/docs/Resolution.md index 27928d5..27a3992 100644 --- a/pkgs/clan-cli/tests/openapi_client/docs/Resolution.md +++ b/pkgs/clan-cli/tests/openapi_client/docs/Resolution.md @@ -1,15 +1,15 @@ # Resolution -## Properties -| Name | Type | Description | Notes | -| ------------------ | ------------ | ----------- | ----- | -| **requester_name** | **str** | | -| **requester_did** | **str** | | -| **resolved_did** | **str** | | -| **other** | **object** | | -| **timestamp** | **datetime** | | -| **id** | **int** | | +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**requester_name** | **str** | | +**requester_did** | **str** | | +**resolved_did** | **str** | | +**other** | **object** | | +**timestamp** | **datetime** | | +**id** | **int** | | ## Example @@ -28,5 +28,6 @@ resolution_dict = resolution_instance.to_dict() # create an instance of Resolution from a dict resolution_form_dict = resolution.from_dict(resolution_dict) ``` - [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/pkgs/clan-cli/tests/openapi_client/docs/ResolutionApi.md b/pkgs/clan-cli/tests/openapi_client/docs/ResolutionApi.md index 24da5fb..a2ae852 100644 --- a/pkgs/clan-cli/tests/openapi_client/docs/ResolutionApi.md +++ b/pkgs/clan-cli/tests/openapi_client/docs/ResolutionApi.md @@ -1,13 +1,13 @@ # openapi_client.ResolutionApi -All URIs are relative to _http://localhost_ +All URIs are relative to *http://localhost* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**get_all_resolutions**](ResolutionApi.md#get_all_resolutions) | **GET** /api/v1/resolutions | Get All Resolutions -| Method | HTTP request | Description | -| --------------------------------------------------------------- | --------------------------- | ------------------- | -| [**get_all_resolutions**](ResolutionApi.md#get_all_resolutions) | **GET** /api/v1/resolutions | Get All Resolutions | # **get_all_resolutions** - > List[Resolution] get_all_resolutions(skip=skip, limit=limit) Get All Resolutions @@ -45,12 +45,14 @@ with openapi_client.ApiClient(configuration) as api_client: print("Exception when calling ResolutionApi->get_all_resolutions: %s\n" % e) ``` + + ### Parameters -| Name | Type | Description | Notes | -| --------- | ------- | ----------- | --------------------------- | -| **skip** | **int** | | [optional] [default to 0] | -| **limit** | **int** | | [optional] [default to 100] | +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **skip** | **int**| | [optional] [default to 0] + **limit** | **int**| | [optional] [default to 100] ### Return type @@ -62,14 +64,14 @@ No authorization required ### HTTP request headers -- **Content-Type**: Not defined -- **Accept**: application/json + - **Content-Type**: Not defined + - **Accept**: application/json ### HTTP response details - -| Status code | Description | Response headers | -| ----------- | ------------------- | ---------------- | -| **200** | Successful Response | - | -| **422** | Validation Error | - | +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | Successful Response | - | +**422** | Validation Error | - | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + diff --git a/pkgs/clan-cli/tests/openapi_client/docs/Service.md b/pkgs/clan-cli/tests/openapi_client/docs/Service.md index 5798f74..bff9e15 100644 --- a/pkgs/clan-cli/tests/openapi_client/docs/Service.md +++ b/pkgs/clan-cli/tests/openapi_client/docs/Service.md @@ -1,17 +1,17 @@ # Service -## Properties -| Name | Type | Description | Notes | -| ---------------- | ----------------------- | ----------- | ----- | -| **uuid** | **str** | | -| **service_name** | **str** | | -| **service_type** | **str** | | -| **endpoint_url** | **str** | | -| **status** | **str** | | -| **other** | **object** | | -| **entity_did** | **str** | | -| **entity** | [**Entity**](Entity.md) | | +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**uuid** | **str** | | +**service_name** | **str** | | +**service_type** | **str** | | +**endpoint_url** | **str** | | +**status** | **str** | | +**other** | **object** | | +**entity_did** | **str** | | +**entity** | [**Entity**](Entity.md) | | ## Example @@ -30,5 +30,6 @@ service_dict = service_instance.to_dict() # create an instance of Service from a dict service_form_dict = service.from_dict(service_dict) ``` - [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/pkgs/clan-cli/tests/openapi_client/docs/ServiceCreate.md b/pkgs/clan-cli/tests/openapi_client/docs/ServiceCreate.md index 7843b1a..f8e84e1 100644 --- a/pkgs/clan-cli/tests/openapi_client/docs/ServiceCreate.md +++ b/pkgs/clan-cli/tests/openapi_client/docs/ServiceCreate.md @@ -1,16 +1,16 @@ # ServiceCreate -## Properties -| Name | Type | Description | Notes | -| ---------------- | ---------- | ----------- | ----- | -| **uuid** | **str** | | -| **service_name** | **str** | | -| **service_type** | **str** | | -| **endpoint_url** | **str** | | -| **status** | **str** | | -| **other** | **object** | | -| **entity_did** | **str** | | +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**uuid** | **str** | | +**service_name** | **str** | | +**service_type** | **str** | | +**endpoint_url** | **str** | | +**status** | **str** | | +**other** | **object** | | +**entity_did** | **str** | | ## Example @@ -29,5 +29,6 @@ service_create_dict = service_create_instance.to_dict() # create an instance of ServiceCreate from a dict service_create_form_dict = service_create.from_dict(service_create_dict) ``` - [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/pkgs/clan-cli/tests/openapi_client/docs/ServicesApi.md b/pkgs/clan-cli/tests/openapi_client/docs/ServicesApi.md index 006615a..9a2c544 100644 --- a/pkgs/clan-cli/tests/openapi_client/docs/ServicesApi.md +++ b/pkgs/clan-cli/tests/openapi_client/docs/ServicesApi.md @@ -1,17 +1,17 @@ # openapi_client.ServicesApi -All URIs are relative to _http://localhost_ +All URIs are relative to *http://localhost* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**create_service**](ServicesApi.md#create_service) | **POST** /api/v1/service | Create Service +[**delete_service**](ServicesApi.md#delete_service) | **DELETE** /api/v1/service | Delete Service +[**get_all_services**](ServicesApi.md#get_all_services) | **GET** /api/v1/services | Get All Services +[**get_service_by_did**](ServicesApi.md#get_service_by_did) | **GET** /api/v1/service | Get Service By Did +[**get_services_without_entity**](ServicesApi.md#get_services_without_entity) | **GET** /api/v1/services_without_entity | Get Services Without Entity -| Method | HTTP request | Description | -| ----------------------------------------------------------------------------- | --------------------------------------- | --------------------------- | -| [**create_service**](ServicesApi.md#create_service) | **POST** /api/v1/service | Create Service | -| [**delete_service**](ServicesApi.md#delete_service) | **DELETE** /api/v1/service | Delete Service | -| [**get_all_services**](ServicesApi.md#get_all_services) | **GET** /api/v1/services | Get All Services | -| [**get_service_by_did**](ServicesApi.md#get_service_by_did) | **GET** /api/v1/service | Get Service By Did | -| [**get_services_without_entity**](ServicesApi.md#get_services_without_entity) | **GET** /api/v1/services_without_entity | Get Services Without Entity | # **create_service** - > Service create_service(service_create) Create Service @@ -38,7 +38,7 @@ configuration = openapi_client.Configuration( with openapi_client.ApiClient(configuration) as api_client: # Create an instance of the API class api_instance = openapi_client.ServicesApi(api_client) - service_create = openapi_client.ServiceCreate() # ServiceCreate | + service_create = openapi_client.ServiceCreate() # ServiceCreate | try: # Create Service @@ -49,11 +49,13 @@ with openapi_client.ApiClient(configuration) as api_client: print("Exception when calling ServicesApi->create_service: %s\n" % e) ``` + + ### Parameters -| Name | Type | Description | Notes | -| ------------------ | ------------------------------------- | ----------- | ----- | -| **service_create** | [**ServiceCreate**](ServiceCreate.md) | | +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **service_create** | [**ServiceCreate**](ServiceCreate.md)| | ### Return type @@ -65,20 +67,18 @@ No authorization required ### HTTP request headers -- **Content-Type**: application/json -- **Accept**: application/json + - **Content-Type**: application/json + - **Accept**: application/json ### HTTP response details - -| Status code | Description | Response headers | -| ----------- | ------------------- | ---------------- | -| **200** | Successful Response | - | -| **422** | Validation Error | - | +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | Successful Response | - | +**422** | Validation Error | - | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **delete_service** - > Dict[str, str] delete_service(entity_did=entity_did) Delete Service @@ -114,11 +114,13 @@ with openapi_client.ApiClient(configuration) as api_client: print("Exception when calling ServicesApi->delete_service: %s\n" % e) ``` + + ### Parameters -| Name | Type | Description | Notes | -| -------------- | ------- | ----------- | --------------------------------------------------- | -| **entity_did** | **str** | | [optional] [default to 'did:sov:test:1234'] | +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **entity_did** | **str**| | [optional] [default to 'did:sov:test:1234'] ### Return type @@ -130,20 +132,18 @@ No authorization required ### HTTP request headers -- **Content-Type**: Not defined -- **Accept**: application/json + - **Content-Type**: Not defined + - **Accept**: application/json ### HTTP response details - -| Status code | Description | Response headers | -| ----------- | ------------------- | ---------------- | -| **200** | Successful Response | - | -| **422** | Validation Error | - | +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | Successful Response | - | +**422** | Validation Error | - | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **get_all_services** - > List[Service] get_all_services(skip=skip, limit=limit) Get All Services @@ -181,12 +181,14 @@ with openapi_client.ApiClient(configuration) as api_client: print("Exception when calling ServicesApi->get_all_services: %s\n" % e) ``` + + ### Parameters -| Name | Type | Description | Notes | -| --------- | ------- | ----------- | --------------------------- | -| **skip** | **int** | | [optional] [default to 0] | -| **limit** | **int** | | [optional] [default to 100] | +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **skip** | **int**| | [optional] [default to 0] + **limit** | **int**| | [optional] [default to 100] ### Return type @@ -198,20 +200,18 @@ No authorization required ### HTTP request headers -- **Content-Type**: Not defined -- **Accept**: application/json + - **Content-Type**: Not defined + - **Accept**: application/json ### HTTP response details - -| Status code | Description | Response headers | -| ----------- | ------------------- | ---------------- | -| **200** | Successful Response | - | -| **422** | Validation Error | - | +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | Successful Response | - | +**422** | Validation Error | - | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **get_service_by_did** - > List[Service] get_service_by_did(entity_did=entity_did, skip=skip, limit=limit) Get Service By Did @@ -250,13 +250,15 @@ with openapi_client.ApiClient(configuration) as api_client: print("Exception when calling ServicesApi->get_service_by_did: %s\n" % e) ``` + + ### Parameters -| Name | Type | Description | Notes | -| -------------- | ------- | ----------- | --------------------------------------------------- | -| **entity_did** | **str** | | [optional] [default to 'did:sov:test:1234'] | -| **skip** | **int** | | [optional] [default to 0] | -| **limit** | **int** | | [optional] [default to 100] | +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **entity_did** | **str**| | [optional] [default to 'did:sov:test:1234'] + **skip** | **int**| | [optional] [default to 0] + **limit** | **int**| | [optional] [default to 100] ### Return type @@ -268,20 +270,18 @@ No authorization required ### HTTP request headers -- **Content-Type**: Not defined -- **Accept**: application/json + - **Content-Type**: Not defined + - **Accept**: application/json ### HTTP response details - -| Status code | Description | Response headers | -| ----------- | ------------------- | ---------------- | -| **200** | Successful Response | - | -| **422** | Validation Error | - | +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | Successful Response | - | +**422** | Validation Error | - | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **get_services_without_entity** - > List[Service] get_services_without_entity(entity_did=entity_did, skip=skip, limit=limit) Get Services Without Entity @@ -320,13 +320,15 @@ with openapi_client.ApiClient(configuration) as api_client: print("Exception when calling ServicesApi->get_services_without_entity: %s\n" % e) ``` + + ### Parameters -| Name | Type | Description | Notes | -| -------------- | ------- | ----------- | --------------------------------------------------- | -| **entity_did** | **str** | | [optional] [default to 'did:sov:test:1234'] | -| **skip** | **int** | | [optional] [default to 0] | -| **limit** | **int** | | [optional] [default to 100] | +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **entity_did** | **str**| | [optional] [default to 'did:sov:test:1234'] + **skip** | **int**| | [optional] [default to 0] + **limit** | **int**| | [optional] [default to 100] ### Return type @@ -338,14 +340,14 @@ No authorization required ### HTTP request headers -- **Content-Type**: Not defined -- **Accept**: application/json + - **Content-Type**: Not defined + - **Accept**: application/json ### HTTP response details - -| Status code | Description | Response headers | -| ----------- | ------------------- | ---------------- | -| **200** | Successful Response | - | -| **422** | Validation Error | - | +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | Successful Response | - | +**422** | Validation Error | - | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + diff --git a/pkgs/clan-cli/tests/openapi_client/docs/Status.md b/pkgs/clan-cli/tests/openapi_client/docs/Status.md index 10bd223..3b89cf4 100644 --- a/pkgs/clan-cli/tests/openapi_client/docs/Status.md +++ b/pkgs/clan-cli/tests/openapi_client/docs/Status.md @@ -3,8 +3,9 @@ An enumeration. ## Properties - -| Name | Type | Description | Notes | -| ---- | ---- | ----------- | ----- | +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/pkgs/clan-cli/tests/openapi_client/docs/ValidationError.md b/pkgs/clan-cli/tests/openapi_client/docs/ValidationError.md index b57b565..04310f6 100644 --- a/pkgs/clan-cli/tests/openapi_client/docs/ValidationError.md +++ b/pkgs/clan-cli/tests/openapi_client/docs/ValidationError.md @@ -1,12 +1,12 @@ # ValidationError -## Properties -| Name | Type | Description | Notes | -| -------- | --------------------------------------------------------------- | ----------- | ----- | -| **loc** | [**List[ValidationErrorLocInner]**](ValidationErrorLocInner.md) | | -| **msg** | **str** | | -| **type** | **str** | | +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**loc** | [**List[ValidationErrorLocInner]**](ValidationErrorLocInner.md) | | +**msg** | **str** | | +**type** | **str** | | ## Example @@ -25,5 +25,6 @@ validation_error_dict = validation_error_instance.to_dict() # create an instance of ValidationError from a dict validation_error_form_dict = validation_error.from_dict(validation_error_dict) ``` - [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/pkgs/clan-cli/tests/openapi_client/docs/ValidationErrorLocInner.md b/pkgs/clan-cli/tests/openapi_client/docs/ValidationErrorLocInner.md index 04e49df..0bae52d 100644 --- a/pkgs/clan-cli/tests/openapi_client/docs/ValidationErrorLocInner.md +++ b/pkgs/clan-cli/tests/openapi_client/docs/ValidationErrorLocInner.md @@ -1,9 +1,9 @@ # ValidationErrorLocInner -## Properties -| Name | Type | Description | Notes | -| ---- | ---- | ----------- | ----- | +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- ## Example @@ -22,5 +22,6 @@ validation_error_loc_inner_dict = validation_error_loc_inner_instance.to_dict() # create an instance of ValidationErrorLocInner from a dict validation_error_loc_inner_form_dict = validation_error_loc_inner.from_dict(validation_error_loc_inner_dict) ``` - [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/pkgs/clan-cli/tests/openapi_client/models/__init__.py b/pkgs/clan-cli/tests/openapi_client/models/__init__.py index 4460d22..f28cdd8 100644 --- a/pkgs/clan-cli/tests/openapi_client/models/__init__.py +++ b/pkgs/clan-cli/tests/openapi_client/models/__init__.py @@ -21,6 +21,7 @@ from openapi_client.models.eventmessage_create import EventmessageCreate from openapi_client.models.http_validation_error import HTTPValidationError from openapi_client.models.machine import Machine from openapi_client.models.resolution import Resolution +from openapi_client.models.roles import Roles from openapi_client.models.service import Service from openapi_client.models.service_create import ServiceCreate from openapi_client.models.status import Status diff --git a/pkgs/clan-cli/tests/openapi_client/models/entity.py b/pkgs/clan-cli/tests/openapi_client/models/entity.py index 0ff4d16..a78e778 100644 --- a/pkgs/clan-cli/tests/openapi_client/models/entity.py +++ b/pkgs/clan-cli/tests/openapi_client/models/entity.py @@ -20,6 +20,7 @@ import json from typing import Any, Dict from pydantic import BaseModel, Field, StrictBool, StrictStr +from openapi_client.models.roles import Roles class Entity(BaseModel): """ @@ -28,11 +29,13 @@ class Entity(BaseModel): did: StrictStr = Field(...) name: StrictStr = Field(...) ip: StrictStr = Field(...) + network: StrictStr = Field(...) + role: Roles = Field(...) visible: StrictBool = Field(...) other: Dict[str, Any] = Field(...) attached: StrictBool = Field(...) stop_health_task: StrictBool = Field(...) - __properties = ["did", "name", "ip", "visible", "other", "attached", "stop_health_task"] + __properties = ["did", "name", "ip", "network", "role", "visible", "other", "attached", "stop_health_task"] class Config: """Pydantic configuration""" @@ -73,6 +76,8 @@ class Entity(BaseModel): "did": obj.get("did"), "name": obj.get("name"), "ip": obj.get("ip"), + "network": obj.get("network"), + "role": obj.get("role"), "visible": obj.get("visible"), "other": obj.get("other"), "attached": obj.get("attached"), diff --git a/pkgs/clan-cli/tests/openapi_client/models/entity_create.py b/pkgs/clan-cli/tests/openapi_client/models/entity_create.py index f9df72b..d7385e1 100644 --- a/pkgs/clan-cli/tests/openapi_client/models/entity_create.py +++ b/pkgs/clan-cli/tests/openapi_client/models/entity_create.py @@ -20,6 +20,7 @@ import json from typing import Any, Dict from pydantic import BaseModel, Field, StrictBool, StrictStr +from openapi_client.models.roles import Roles class EntityCreate(BaseModel): """ @@ -28,9 +29,11 @@ class EntityCreate(BaseModel): did: StrictStr = Field(...) name: StrictStr = Field(...) ip: StrictStr = Field(...) + network: StrictStr = Field(...) + role: Roles = Field(...) visible: StrictBool = Field(...) other: Dict[str, Any] = Field(...) - __properties = ["did", "name", "ip", "visible", "other"] + __properties = ["did", "name", "ip", "network", "role", "visible", "other"] class Config: """Pydantic configuration""" @@ -71,6 +74,8 @@ class EntityCreate(BaseModel): "did": obj.get("did"), "name": obj.get("name"), "ip": obj.get("ip"), + "network": obj.get("network"), + "role": obj.get("role"), "visible": obj.get("visible"), "other": obj.get("other") }) diff --git a/pkgs/clan-cli/tests/openapi_client/test/test_eventmessage.py b/pkgs/clan-cli/tests/openapi_client/test/test_eventmessage.py deleted file mode 100644 index 21852d5..0000000 --- a/pkgs/clan-cli/tests/openapi_client/test/test_eventmessage.py +++ /dev/null @@ -1,67 +0,0 @@ -# coding: utf-8 - -""" - FastAPI - - No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - - The version of the OpenAPI document: 0.1.0 - Generated by OpenAPI Generator (https://openapi-generator.tech) - - Do not edit the class manually. -""" # noqa: E501 - - -import unittest -import datetime - -from openapi_client.models.eventmessage import Eventmessage # noqa: E501 - -class TestEventmessage(unittest.TestCase): - """Eventmessage unit test stubs""" - - def setUp(self): - pass - - def tearDown(self): - pass - - def make_instance(self, include_optional) -> Eventmessage: - """Test Eventmessage - include_option is a boolean, when False only required - params are included, when True both required and - optional params are included """ - # uncomment below to create an instance of `Eventmessage` - """ - model = Eventmessage() # noqa: E501 - if include_optional: - return Eventmessage( - id = 123456, - timestamp = 1234123413, - group = 1, - group_id = 12345, - msg_type = 1, - src_did = 'did:sov:test:2234', - des_did = 'did:sov:test:1234', - msg = {optinal=values} - ) - else: - return Eventmessage( - id = 123456, - timestamp = 1234123413, - group = 1, - group_id = 12345, - msg_type = 1, - src_did = 'did:sov:test:2234', - des_did = 'did:sov:test:1234', - msg = {optinal=values}, - ) - """ - - def testEventmessage(self): - """Test Eventmessage""" - # inst_req_only = self.make_instance(include_optional=False) - # inst_req_and_optional = self.make_instance(include_optional=True) - -if __name__ == '__main__': - unittest.main() diff --git a/pkgs/clan-cli/tests/openapi_client/test/test_eventmessage_create.py b/pkgs/clan-cli/tests/openapi_client/test/test_eventmessage_create.py deleted file mode 100644 index 8bc282d..0000000 --- a/pkgs/clan-cli/tests/openapi_client/test/test_eventmessage_create.py +++ /dev/null @@ -1,67 +0,0 @@ -# coding: utf-8 - -""" - FastAPI - - No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - - The version of the OpenAPI document: 0.1.0 - Generated by OpenAPI Generator (https://openapi-generator.tech) - - Do not edit the class manually. -""" # noqa: E501 - - -import unittest -import datetime - -from openapi_client.models.eventmessage_create import EventmessageCreate # noqa: E501 - -class TestEventmessageCreate(unittest.TestCase): - """EventmessageCreate unit test stubs""" - - def setUp(self): - pass - - def tearDown(self): - pass - - def make_instance(self, include_optional) -> EventmessageCreate: - """Test EventmessageCreate - include_option is a boolean, when False only required - params are included, when True both required and - optional params are included """ - # uncomment below to create an instance of `EventmessageCreate` - """ - model = EventmessageCreate() # noqa: E501 - if include_optional: - return EventmessageCreate( - id = 123456, - timestamp = 1234123413, - group = 1, - group_id = 12345, - msg_type = 1, - src_did = 'did:sov:test:2234', - des_did = 'did:sov:test:1234', - msg = {optinal=values} - ) - else: - return EventmessageCreate( - id = 123456, - timestamp = 1234123413, - group = 1, - group_id = 12345, - msg_type = 1, - src_did = 'did:sov:test:2234', - des_did = 'did:sov:test:1234', - msg = {optinal=values}, - ) - """ - - def testEventmessageCreate(self): - """Test EventmessageCreate""" - # inst_req_only = self.make_instance(include_optional=False) - # inst_req_and_optional = self.make_instance(include_optional=True) - -if __name__ == '__main__': - unittest.main() diff --git a/pkgs/clan-cli/tests/openapi_client/test/test_eventmessages_api.py b/pkgs/clan-cli/tests/openapi_client/test/test_eventmessages_api.py deleted file mode 100644 index e2841ab..0000000 --- a/pkgs/clan-cli/tests/openapi_client/test/test_eventmessages_api.py +++ /dev/null @@ -1,45 +0,0 @@ -# coding: utf-8 - -""" - FastAPI - - No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - - The version of the OpenAPI document: 0.1.0 - Generated by OpenAPI Generator (https://openapi-generator.tech) - - Do not edit the class manually. -""" # noqa: E501 - - -import unittest - -from openapi_client.api.eventmessages_api import EventmessagesApi # noqa: E501 - - -class TestEventmessagesApi(unittest.TestCase): - """EventmessagesApi unit test stubs""" - - def setUp(self) -> None: - self.api = EventmessagesApi() # noqa: E501 - - def tearDown(self) -> None: - pass - - def test_create_eventmessage(self) -> None: - """Test case for create_eventmessage - - Create Eventmessage # noqa: E501 - """ - pass - - def test_get_all_eventmessages(self) -> None: - """Test case for get_all_eventmessages - - Get All Eventmessages # noqa: E501 - """ - pass - - -if __name__ == '__main__': - unittest.main() diff --git a/pkgs/clan-cli/tests/test_db_api.py b/pkgs/clan-cli/tests/test_db_api.py index b619729..2248503 100644 --- a/pkgs/clan-cli/tests/test_db_api.py +++ b/pkgs/clan-cli/tests/test_db_api.py @@ -1,6 +1,7 @@ import random import time import uuid +import api from openapi_client import ApiClient from openapi_client.api import DefaultApi @@ -15,10 +16,16 @@ from openapi_client.models import ( Machine, ServiceCreate, Status, + Roles, ) random.seed(42) +#is linked to the emulate_fastapi.py and api.py +host = api.host +port_dlg = api.port_dlg +port_ap = api.port_ap +port_client_base = api.port_client_base num_uuids = 100 uuids = [str(uuid.UUID(int=random.getrandbits(128))) for i in range(num_uuids)] @@ -36,11 +43,33 @@ def create_entities(num: int = 10) -> list[EntityCreate]: en = EntityCreate( did=f"did:sov:test:12{i}", name=f"C{i}", - ip=f"127.0.0.1:{7000+i}", + ip=f"{host}:{port_client_base+i}", + network=f"255.255.0.0", + role=Roles("service_prosumer"), visible=True, other={}, ) res.append(en) + dlg = EntityCreate( + did=f"did:sov:test:{port_dlg}", + name=f"DLG", + ip=f"{host}:{port_dlg}/health", + network=f"255.255.0.0", + role=Roles("DLG"), + visible=True, + other={}, + ) + res.append(dlg) + ap = EntityCreate( + did=f"did:sov:test:{port_ap}", + name=f"AP", + ip=f"{host}:{port_ap}/health", + network=f"255.255.0.0", + role=Roles("AP"), + visible=True, + other={}, + ) + res.append(ap) return res @@ -139,4 +168,4 @@ def test_create_eventmessages(api_client: ApiClient) -> None: res: Eventmessage = api.create_eventmessage(own_eventmsg) # breakpoint() assert res.id == own_eventmsg.id - assert [] != api.get_all_eventmessages() + assert [] != api.get_all_eventmessages() \ No newline at end of file From b6793826229eada8f6f01e888ab792d37e469282 Mon Sep 17 00:00:00 2001 From: Georg-Stahn Date: Wed, 10 Jan 2024 19:32:07 +0100 Subject: [PATCH 55/58] draft2 emulating flag config added --- pkgs/clan-cli/tests/api.py | 10 +- pkgs/clan-cli/tests/emulate_fastapi.py | 198 ------------------------- 2 files changed, 2 insertions(+), 206 deletions(-) delete mode 100644 pkgs/clan-cli/tests/emulate_fastapi.py diff --git a/pkgs/clan-cli/tests/api.py b/pkgs/clan-cli/tests/api.py index 8e4c784..d538f42 100644 --- a/pkgs/clan-cli/tests/api.py +++ b/pkgs/clan-cli/tests/api.py @@ -14,15 +14,9 @@ from ports import PortFunction from clan_cli.webui.app import app import emulate_fastapi +import config -# TODO config file -#is linked to the emulate_fastapi.py and api.py -host = "127.0.0.1" -port_dlg = 6000 -port_ap = 6600 -port_client_base = 7000 - @pytest.fixture(scope="session") def test_client() -> TestClient: return TestClient(app) @@ -44,7 +38,7 @@ def get_health(*, url: str, max_retries: int = 20, delay: float = 0.2) -> str | @pytest.fixture(scope="session") def server_url(unused_tcp_port: PortFunction) -> Generator[str, None, None]: port = unused_tcp_port() - host = host + host = config.host proc = Process( target=uvicorn.run, args=(app,), diff --git a/pkgs/clan-cli/tests/emulate_fastapi.py b/pkgs/clan-cli/tests/emulate_fastapi.py deleted file mode 100644 index c131f54..0000000 --- a/pkgs/clan-cli/tests/emulate_fastapi.py +++ /dev/null @@ -1,198 +0,0 @@ -import sys -import time -import urllib -import uvicorn -from fastapi import FastAPI -from fastapi.responses import HTMLResponse -import test_db_api - -app_dlg = FastAPI() -app_ap = FastAPI() -app_c1 = FastAPI() -app_c2 = FastAPI() - -# bash tests: curl localhost:8000/ap_list_of_services - - -#### HEALTH - -@app_c1.get("/health") -async def healthcheck() -> str: - return "200 OK" -@app_c2.get("/health") -async def healthcheck() -> str: - return "200 OK" -@app_dlg.get("/health") -async def healthcheck() -> str: - return "200 OK" -@app_ap.get("/health") -async def healthcheck() -> str: - return "200 OK" - -def get_health(*, url: str, max_retries: int = 20, delay: float = 0.2) -> str | None: - for attempt in range(max_retries): - try: - with urllib.request.urlopen(url) as response: - return response.read() - except urllib.URLError as e: - print(f"Attempt {attempt + 1} failed: {e.reason}", file=sys.stderr) - time.sleep(delay) - return None - - -#### CONSUME SERVICE - -# TODO send_msg??? - -@app_c1.get("/consume_service_from_other_entity", response_class=HTMLResponse) -async def consume_service_from_other_entity() -> HTMLResponse: - html_content = """ - - -
- - - """ - time.sleep(3) - return HTMLResponse(content=html_content, status_code=200) -@app_c2.get("/consume_service_from_other_entity", response_class=HTMLResponse) -async def consume_service_from_other_entity() -> HTMLResponse: - html_content = """ - - -
- - - """ - time.sleep(3) - return HTMLResponse(content=html_content, status_code=200) - - -#### ap_list_of_services - -@app_ap.get("/ap_list_of_services", response_class=HTMLResponse) -async def ap_list_of_services() -> HTMLResponse: - html_content = b"""HTTP/1.1 200 OK\r\n\r\n[[ - { - "uuid": "8e285c0c-4e40-430a-a477-26b3b81e30df", - "service_name": "Carlos Printing", - "service_type": "3D Printing", - "endpoint_url": "http://127.0.0.1:8000", - "status": "unknown", - "other": { - "action": [ - "register", - "deregister", - "delete", - "create" - ] - }, - "entity_did": "did:sov:test:1234" - }, - { - "uuid": "8e285c0c-4e40-430a-a477-26b3b81e30d1", - "service_name": "Luiss Fax", - "service_type": "Fax", - "endpoint_url": "http://127.0.0.1:8000", - "status": "unknown", - "other": { - "action": [ - "register", - "deregister", - "delete", - "create" - ] - }, - "entity_did": "did:sov:test:1235" - }, - { - "uuid": "8e285c0c-4e40-430a-a477-26b3b81e30d2", - "service_name": "Erdems VR-Stream", - "service_type": "VR-Stream", - "endpoint_url": "http://127.0.0.1:8000", - "status": "unknown", - "other": { - "action": [ - "register", - "deregister", - "delete", - "create" - ] - }, - "entity_did": "did:sov:test:1236" - }, - { - "uuid": "8e285c0c-4e40-430a-a477-26b3b81e30d3", - "service_name": "Onurs gallary", - "service_type": "gallary", - "endpoint_url": "http://127.0.0.1:8000", - "status": "unknown", - "other": { - "action": [ - "register", - "deregister", - "delete", - "create" - ] - }, - "entity_did": "did:sov:test:1237" - }, - { - "uuid": "8e285c0c-4e40-430a-a477-26b3b81e30d4", - "service_name": "Saras Game-Shop", - "service_type": "Game-Shop", - "endpoint_url": "http://127.0.0.1:8000", - "status": "unknown", - "other": { - "action": [ - "register", - "deregister", - "delete", - "create" - ] - }, - "entity_did": "did:sov:test:1238" - } -]]""" - return HTMLResponse(content=html_content, status_code=200) - - -@app_dlg.get("/dlg_list_of_did_resolutions", response_class=HTMLResponse) -async def dlg_list_of_did_resolutions() -> HTMLResponse: - html_content = b"""HTTP/1.1 200 OK\r\n\r\n -[ - { - "did": "did:sov:test:1234", - "name": "C1", - "ip": "127.0.0.1:5100", - "attached": false, - "visible": true, - "other": { - "network": "Carlo1's Home Network", - "roles": [ - "service repository", - "service consumer" - ] - } - }, - { - "did": "did:sov:test:1235", - "name": "C2", - "ip": "127.0.0.1:5100", - "attached": false, - "visible": true, - "other": { - "network": "Carlo2's Home Network", - "roles": [ - "service repository", - "service prosumer" - ] - } - } -]""" - return HTMLResponse(content=html_content, status_code=200) - -uvicorn.run(app_dlg, host=f"{test_db_api.host}", port=test_db_api.port_dlg) -uvicorn.run(app_ap, host=f"{test_db_api.host}", port=test_db_api.port_dlg) -uvicorn.run(app_c1, host=f"{test_db_api.host}", port=test_db_api.port_client_base) -uvicorn.run(app_c2, host=f"{test_db_api.host}", port=test_db_api.port_client_base+1) From b01b01a9593ab50d4df419f45b909b19d32f950e Mon Sep 17 00:00:00 2001 From: Georg-Stahn Date: Thu, 11 Jan 2024 15:34:01 +0100 Subject: [PATCH 56/58] backend with --emulate flag --- pkgs/clan-cli/clan_cli/webui/__init__.py | 6 + pkgs/clan-cli/clan_cli/webui/server.py | 43 ++-- pkgs/clan-cli/clan_cli/webui/sql_models.py | 5 +- pkgs/clan-cli/config.py | 4 + pkgs/clan-cli/emulate_fastapi.py | 205 +++++++++++++++ pkgs/clan-cli/tests/api.py | 96 +------ .../tests/openapi_client/docs/DefaultApi.md | 68 ++--- .../tests/openapi_client/docs/EntitiesApi.md | 240 +++++++++--------- .../tests/openapi_client/docs/Entity.md | 27 +- .../tests/openapi_client/docs/EntityCreate.md | 23 +- .../tests/openapi_client/docs/Eventmessage.md | 25 +- .../openapi_client/docs/EventmessageCreate.md | 25 +- .../openapi_client/docs/EventmessagesApi.md | 60 +++-- .../docs/HTTPValidationError.md | 11 +- .../tests/openapi_client/docs/Machine.md | 13 +- .../openapi_client/docs/RepositoriesApi.md | 34 ++- .../tests/openapi_client/docs/Resolution.md | 21 +- .../openapi_client/docs/ResolutionApi.md | 34 ++- .../tests/openapi_client/docs/Roles.md | 10 + .../tests/openapi_client/docs/Service.md | 25 +- .../openapi_client/docs/ServiceCreate.md | 23 +- .../tests/openapi_client/docs/ServicesApi.md | 140 +++++----- .../tests/openapi_client/docs/Status.md | 7 +- .../openapi_client/docs/ValidationError.md | 15 +- .../docs/ValidationErrorLocInner.md | 9 +- .../tests/openapi_client/models/roles.py | 41 +++ pkgs/clan-cli/tests/test_db_api.py | 27 +- 27 files changed, 699 insertions(+), 538 deletions(-) create mode 100644 pkgs/clan-cli/config.py create mode 100644 pkgs/clan-cli/emulate_fastapi.py create mode 100644 pkgs/clan-cli/tests/openapi_client/docs/Roles.md create mode 100644 pkgs/clan-cli/tests/openapi_client/models/roles.py diff --git a/pkgs/clan-cli/clan_cli/webui/__init__.py b/pkgs/clan-cli/clan_cli/webui/__init__.py index 1305e78..3848f9d 100644 --- a/pkgs/clan-cli/clan_cli/webui/__init__.py +++ b/pkgs/clan-cli/clan_cli/webui/__init__.py @@ -28,6 +28,12 @@ def register_parser(parser: argparse.ArgumentParser) -> None: help="Populate the database with dummy data", default=False, ) + parser.add_argument( + "--emulate", + action="store_true", + help="Emulate two entities c1 and c2 + dlg and ap", + default=False, + ) parser.add_argument( "--no-open", action="store_true", help="Don't open the browser", default=False ) diff --git a/pkgs/clan-cli/clan_cli/webui/server.py b/pkgs/clan-cli/clan_cli/webui/server.py index 5d0f388..932e1d6 100644 --- a/pkgs/clan-cli/clan_cli/webui/server.py +++ b/pkgs/clan-cli/clan_cli/webui/server.py @@ -127,25 +127,34 @@ def start_server(args: argparse.Namespace) -> None: subprocess.run(cmd, check=True) if args.emulate: - # todo move emu - from .emulate_fastapi import (app_dlg, app_ap, app_c1, app_c2) - from .api import (get_health, port_dlg, port_ap, port_client_base) import multiprocessing as mp - port = port_dlg - host = host - # server - proc = mp.Process( - target=uvicorn.run, - args=(app_dlg,), - kwargs={"host": host, "port": port, "log_level": "info"}, - daemon=True, - ) - proc.start() - url = f"http://{host}:{port}" - res = get_health(url=url + "/health") - if res is None: - raise Exception(f"Couldn't reach {url} after starting server") + from config import host, port_ap, port_client_base, port_dlg + from emulate_fastapi import app_ap, app_c1, app_c2, app_dlg, get_health + + app_ports = [ + (app_dlg, port_dlg), + (app_ap, port_ap), + (app_c1, port_client_base), + (app_c2, port_client_base + 1), + ] + urls = list() + # start servers as processes (dlg, ap, c1 and c2 for tests) + for app, port in app_ports: + breakpoint() + proc = mp.Process( + target=uvicorn.run, + args=(app,), + kwargs={"host": host, "port": port, "log_level": "info"}, + daemon=True, + ) + proc.start() + urls.append(f"http://{host}:{port}") + # check server health + for url in urls: + res = get_health(url=url + "/health") + if res is None: + raise Exception(f"Couldn't reach {url} after starting server") uvicorn.run( "clan_cli.webui.app:app", diff --git a/pkgs/clan-cli/clan_cli/webui/sql_models.py b/pkgs/clan-cli/clan_cli/webui/sql_models.py index 9b8bb29..d7c4f2a 100644 --- a/pkgs/clan-cli/clan_cli/webui/sql_models.py +++ b/pkgs/clan-cli/clan_cli/webui/sql_models.py @@ -1,4 +1,4 @@ -from sqlalchemy import JSON, Boolean, Column, ForeignKey, Integer, String, Text, Enum +from sqlalchemy import JSON, Boolean, Column, Enum, ForeignKey, Integer, String, Text from sqlalchemy.orm import relationship from .schemas import Roles @@ -16,7 +16,8 @@ class Entity(Base): name = Column(String, index=True, unique=True) ip = Column(String, index=True) network = Column(String, index=True) - role = Column(Enum(Roles), index=True) + role = Column(Enum(Roles), index=True, nullable=False) # type: ignore + # role = Column(String, index=True, nullable=False) attached = Column(Boolean, index=True) visible = Column(Boolean, index=True) stop_health_task = Column(Boolean) diff --git a/pkgs/clan-cli/config.py b/pkgs/clan-cli/config.py new file mode 100644 index 0000000..2874a7d --- /dev/null +++ b/pkgs/clan-cli/config.py @@ -0,0 +1,4 @@ +host = "127.0.0.1" +port_dlg = 6000 +port_ap = 6600 +port_client_base = 7000 diff --git a/pkgs/clan-cli/emulate_fastapi.py b/pkgs/clan-cli/emulate_fastapi.py new file mode 100644 index 0000000..d663c9a --- /dev/null +++ b/pkgs/clan-cli/emulate_fastapi.py @@ -0,0 +1,205 @@ +import sys +import time +import urllib + +from fastapi import FastAPI +from fastapi.responses import HTMLResponse + +app_dlg = FastAPI() +app_ap = FastAPI() +app_c1 = FastAPI() +app_c2 = FastAPI() + +# bash tests: curl localhost:6600/ap_list_of_services +# curl localhost:7001/consume_service_from_other_entity + + +#### HEALTH + + +@app_c1.get("/health") +async def healthcheck_c1() -> str: + return "200 OK" + + +@app_c2.get("/health") +async def healthcheck_c2() -> str: + return "200 OK" + + +@app_dlg.get("/health") +async def healthcheck_dlg() -> str: + return "200 OK" + + +@app_ap.get("/health") +async def healthcheck_ap() -> str: + return "200 OK" + + +def get_health(*, url: str, max_retries: int = 20, delay: float = 0.2) -> str | None: + for attempt in range(max_retries): + try: + with urllib.request.urlopen(url) as response: + return response.read() + except urllib.error.URLError as e: + print(f"Attempt {attempt + 1} failed: {e.reason}", file=sys.stderr) + time.sleep(delay) + return None + + +#### CONSUME SERVICE + +# TODO send_msg??? + + +@app_c1.get("/consume_service_from_other_entity", response_class=HTMLResponse) +async def consume_service_from_other_entity_c1() -> HTMLResponse: + html_content = """ + + +
+ + + """ + time.sleep(3) + return HTMLResponse(content=html_content, status_code=200) + + +@app_c2.get("/consume_service_from_other_entity", response_class=HTMLResponse) +async def consume_service_from_other_entity_c2() -> HTMLResponse: + html_content = """ + + +
+ + + """ + time.sleep(3) + return HTMLResponse(content=html_content, status_code=200) + + +#### ap_list_of_services + + +@app_ap.get("/ap_list_of_services", response_class=HTMLResponse) +async def ap_list_of_services() -> HTMLResponse: + html_content = b"""HTTP/1.1 200 OK\r\n\r\n[[ + { + "uuid": "8e285c0c-4e40-430a-a477-26b3b81e30df", + "service_name": "Carlos Printing", + "service_type": "3D Printing", + "endpoint_url": "http://127.0.0.1:8000", + "status": "unknown", + "other": { + "action": [ + "register", + "deregister", + "delete", + "create" + ] + }, + "entity_did": "did:sov:test:1234" + }, + { + "uuid": "8e285c0c-4e40-430a-a477-26b3b81e30d1", + "service_name": "Luiss Fax", + "service_type": "Fax", + "endpoint_url": "http://127.0.0.1:8000", + "status": "unknown", + "other": { + "action": [ + "register", + "deregister", + "delete", + "create" + ] + }, + "entity_did": "did:sov:test:1235" + }, + { + "uuid": "8e285c0c-4e40-430a-a477-26b3b81e30d2", + "service_name": "Erdems VR-Stream", + "service_type": "VR-Stream", + "endpoint_url": "http://127.0.0.1:8000", + "status": "unknown", + "other": { + "action": [ + "register", + "deregister", + "delete", + "create" + ] + }, + "entity_did": "did:sov:test:1236" + }, + { + "uuid": "8e285c0c-4e40-430a-a477-26b3b81e30d3", + "service_name": "Onurs gallary", + "service_type": "gallary", + "endpoint_url": "http://127.0.0.1:8000", + "status": "unknown", + "other": { + "action": [ + "register", + "deregister", + "delete", + "create" + ] + }, + "entity_did": "did:sov:test:1237" + }, + { + "uuid": "8e285c0c-4e40-430a-a477-26b3b81e30d4", + "service_name": "Saras Game-Shop", + "service_type": "Game-Shop", + "endpoint_url": "http://127.0.0.1:8000", + "status": "unknown", + "other": { + "action": [ + "register", + "deregister", + "delete", + "create" + ] + }, + "entity_did": "did:sov:test:1238" + } +]]""" + return HTMLResponse(content=html_content, status_code=200) + + +@app_dlg.get("/dlg_list_of_did_resolutions", response_class=HTMLResponse) +async def dlg_list_of_did_resolutions() -> HTMLResponse: + html_content = b"""HTTP/1.1 200 OK\r\n\r\n +[ + { + "did": "did:sov:test:1234", + "name": "C1", + "ip": "127.0.0.1:5100", + "attached": false, + "visible": true, + "other": { + "network": "Carlo1's Home Network", + "roles": [ + "service repository", + "service consumer" + ] + } + }, + { + "did": "did:sov:test:1235", + "name": "C2", + "ip": "127.0.0.1:5100", + "attached": false, + "visible": true, + "other": { + "network": "Carlo2's Home Network", + "roles": [ + "service repository", + "service prosumer" + ] + } + } +]""" + return HTMLResponse(content=html_content, status_code=200) diff --git a/pkgs/clan-cli/tests/api.py b/pkgs/clan-cli/tests/api.py index d538f42..101f3e3 100644 --- a/pkgs/clan-cli/tests/api.py +++ b/pkgs/clan-cli/tests/api.py @@ -11,10 +11,8 @@ from fastapi.testclient import TestClient from openapi_client import ApiClient, Configuration from ports import PortFunction -from clan_cli.webui.app import app - -import emulate_fastapi import config +from clan_cli.webui.app import app @pytest.fixture(scope="session") @@ -55,98 +53,6 @@ def server_url(unused_tcp_port: PortFunction) -> Generator[str, None, None]: yield url proc.terminate() -# Pytest fixture to run the server in a separate process -# emulating c1 -@pytest.fixture(scope="session") -def server_c1() -> Generator[str, None, None]: - port = port_client_base - host = host - # server - proc = Process( - target=uvicorn.run, - args=(app,), - kwargs={"host": host, "port": port, "log_level": "info"}, - daemon=True, - ) - proc.start() - - url = f"http://{host}:{port}" - res = get_health(url=url + "/health") - if res is None: - raise Exception(f"Couldn't reach {url} after starting server") - - yield url - proc.terminate() - -# Pytest fixture to run the server in a separate process -# emulating c2 -@pytest.fixture(scope="session") -def server_c2() -> Generator[str, None, None]: - port = port_client_base+1 - host = host - # server - proc = Process( - target=uvicorn.run, - args=(app,), - kwargs={"host": host, "port": port, "log_level": "info"}, - daemon=True, - ) - proc.start() - - url = f"http://{host}:{port}" - res = get_health(url=url + "/health") - if res is None: - raise Exception(f"Couldn't reach {url} after starting server") - - yield url - proc.terminate() - proc.terminate() - -# Pytest fixture to run the server in a separate process -# emulating ap -@pytest.fixture(scope="session") -def server_ap() -> Generator[str, None, None]: - port = port_ap - host = host - # server - proc = Process( - target=uvicorn.run, - args=(app,), - kwargs={"host": host, "port": port, "log_level": "info"}, - daemon=True, - ) - proc.start() - - url = f"http://{host}:{port}" - res = get_health(url=url + "/health") - if res is None: - raise Exception(f"Couldn't reach {url} after starting server") - - yield url - proc.terminate() - -# Pytest fixture to run the server in a separate process -# emulating dlg -@pytest.fixture(scope="session") -def server_dlg() -> Generator[str, None, None]: - port = port_dlg - host = host - # server - proc = Process( - target=uvicorn.run, - args=(app,), - kwargs={"host": host, "port": port, "log_level": "info"}, - daemon=True, - ) - proc.start() - - url = f"http://{host}:{port}" - res = get_health(url=url + "/health") - if res is None: - raise Exception(f"Couldn't reach {url} after starting server") - - yield url - proc.terminate() @pytest.fixture(scope="session") def api_client(server_url: str) -> Generator[ApiClient, None, None]: diff --git a/pkgs/clan-cli/tests/openapi_client/docs/DefaultApi.md b/pkgs/clan-cli/tests/openapi_client/docs/DefaultApi.md index 9a4a45c..aef64f7 100644 --- a/pkgs/clan-cli/tests/openapi_client/docs/DefaultApi.md +++ b/pkgs/clan-cli/tests/openapi_client/docs/DefaultApi.md @@ -1,15 +1,15 @@ # openapi_client.DefaultApi -All URIs are relative to *http://localhost* - -Method | HTTP request | Description -------------- | ------------- | ------------- -[**get**](DefaultApi.md#get) | **GET** /ws2_example | Get -[**health**](DefaultApi.md#health) | **GET** /health | Health -[**root**](DefaultApi.md#root) | **GET** /{path_name} | Root +All URIs are relative to _http://localhost_ +| Method | HTTP request | Description | +| ---------------------------------- | -------------------- | ----------- | +| [**get**](DefaultApi.md#get) | **GET** /ws2_example | Get | +| [**health**](DefaultApi.md#health) | **GET** /health | Health | +| [**root**](DefaultApi.md#root) | **GET** /{path_name} | Root | # **get** + > get() Get @@ -42,9 +42,8 @@ with openapi_client.ApiClient(configuration) as api_client: print("Exception when calling DefaultApi->get: %s\n" % e) ``` - - ### Parameters + This endpoint does not need any parameter. ### Return type @@ -57,17 +56,19 @@ No authorization required ### HTTP request headers - - **Content-Type**: Not defined - - **Accept**: application/json +- **Content-Type**: Not defined +- **Accept**: application/json ### HTTP response details -| Status code | Description | Response headers | -|-------------|-------------|------------------| -**200** | Successful Response | - | + +| Status code | Description | Response headers | +| ----------- | ------------------- | ---------------- | +| **200** | Successful Response | - | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **health** + > Machine health() Health @@ -103,9 +104,8 @@ with openapi_client.ApiClient(configuration) as api_client: print("Exception when calling DefaultApi->health: %s\n" % e) ``` - - ### Parameters + This endpoint does not need any parameter. ### Return type @@ -118,17 +118,19 @@ No authorization required ### HTTP request headers - - **Content-Type**: Not defined - - **Accept**: application/json +- **Content-Type**: Not defined +- **Accept**: application/json ### HTTP response details -| Status code | Description | Response headers | -|-------------|-------------|------------------| -**200** | Successful Response | - | + +| Status code | Description | Response headers | +| ----------- | ------------------- | ---------------- | +| **200** | Successful Response | - | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **root** + > root(path_name) Root @@ -153,7 +155,7 @@ configuration = openapi_client.Configuration( with openapi_client.ApiClient(configuration) as api_client: # Create an instance of the API class api_instance = openapi_client.DefaultApi(api_client) - path_name = 'path_name_example' # str | + path_name = 'path_name_example' # str | try: # Root @@ -162,13 +164,11 @@ with openapi_client.ApiClient(configuration) as api_client: print("Exception when calling DefaultApi->root: %s\n" % e) ``` - - ### Parameters -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **path_name** | **str**| | +| Name | Type | Description | Notes | +| ------------- | ------- | ----------- | ----- | +| **path_name** | **str** | | ### Return type @@ -180,14 +180,14 @@ No authorization required ### HTTP request headers - - **Content-Type**: Not defined - - **Accept**: application/json +- **Content-Type**: Not defined +- **Accept**: application/json ### HTTP response details -| Status code | Description | Response headers | -|-------------|-------------|------------------| -**200** | Successful Response | - | -**422** | Validation Error | - | + +| Status code | Description | Response headers | +| ----------- | ------------------- | ---------------- | +| **200** | Successful Response | - | +| **422** | Validation Error | - | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) - diff --git a/pkgs/clan-cli/tests/openapi_client/docs/EntitiesApi.md b/pkgs/clan-cli/tests/openapi_client/docs/EntitiesApi.md index 4a99b6c..dc621f8 100644 --- a/pkgs/clan-cli/tests/openapi_client/docs/EntitiesApi.md +++ b/pkgs/clan-cli/tests/openapi_client/docs/EntitiesApi.md @@ -1,21 +1,21 @@ # openapi_client.EntitiesApi -All URIs are relative to *http://localhost* - -Method | HTTP request | Description -------------- | ------------- | ------------- -[**attach_entity**](EntitiesApi.md#attach_entity) | **POST** /api/v1/attach | Attach Entity -[**create_entity**](EntitiesApi.md#create_entity) | **POST** /api/v1/entity | Create Entity -[**delete_entity**](EntitiesApi.md#delete_entity) | **DELETE** /api/v1/entity | Delete Entity -[**detach_entity**](EntitiesApi.md#detach_entity) | **POST** /api/v1/detach | Detach Entity -[**get_all_entities**](EntitiesApi.md#get_all_entities) | **GET** /api/v1/entities | Get All Entities -[**get_attached_entities**](EntitiesApi.md#get_attached_entities) | **GET** /api/v1/attached_entities | Get Attached Entities -[**get_entity_by_did**](EntitiesApi.md#get_entity_by_did) | **GET** /api/v1/entity | Get Entity By Did -[**get_entity_by_name**](EntitiesApi.md#get_entity_by_name) | **GET** /api/v1/entity_by_name | Get Entity By Name -[**is_attached**](EntitiesApi.md#is_attached) | **GET** /api/v1/is_attached | Is Attached +All URIs are relative to _http://localhost_ +| Method | HTTP request | Description | +| ----------------------------------------------------------------- | --------------------------------- | --------------------- | +| [**attach_entity**](EntitiesApi.md#attach_entity) | **POST** /api/v1/attach | Attach Entity | +| [**create_entity**](EntitiesApi.md#create_entity) | **POST** /api/v1/entity | Create Entity | +| [**delete_entity**](EntitiesApi.md#delete_entity) | **DELETE** /api/v1/entity | Delete Entity | +| [**detach_entity**](EntitiesApi.md#detach_entity) | **POST** /api/v1/detach | Detach Entity | +| [**get_all_entities**](EntitiesApi.md#get_all_entities) | **GET** /api/v1/entities | Get All Entities | +| [**get_attached_entities**](EntitiesApi.md#get_attached_entities) | **GET** /api/v1/attached_entities | Get Attached Entities | +| [**get_entity_by_did**](EntitiesApi.md#get_entity_by_did) | **GET** /api/v1/entity | Get Entity By Did | +| [**get_entity_by_name**](EntitiesApi.md#get_entity_by_name) | **GET** /api/v1/entity_by_name | Get Entity By Name | +| [**is_attached**](EntitiesApi.md#is_attached) | **GET** /api/v1/is_attached | Is Attached | # **attach_entity** + > Dict[str, str] attach_entity(entity_did=entity_did, skip=skip, limit=limit) Attach Entity @@ -53,15 +53,13 @@ with openapi_client.ApiClient(configuration) as api_client: print("Exception when calling EntitiesApi->attach_entity: %s\n" % e) ``` - - ### Parameters -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **entity_did** | **str**| | [optional] [default to 'did:sov:test:1234'] - **skip** | **int**| | [optional] [default to 0] - **limit** | **int**| | [optional] [default to 100] +| Name | Type | Description | Notes | +| -------------- | ------- | ----------- | --------------------------------------------------- | +| **entity_did** | **str** | | [optional] [default to 'did:sov:test:1234'] | +| **skip** | **int** | | [optional] [default to 0] | +| **limit** | **int** | | [optional] [default to 100] | ### Return type @@ -73,18 +71,20 @@ No authorization required ### HTTP request headers - - **Content-Type**: Not defined - - **Accept**: application/json +- **Content-Type**: Not defined +- **Accept**: application/json ### HTTP response details -| Status code | Description | Response headers | -|-------------|-------------|------------------| -**200** | Successful Response | - | -**422** | Validation Error | - | + +| Status code | Description | Response headers | +| ----------- | ------------------- | ---------------- | +| **200** | Successful Response | - | +| **422** | Validation Error | - | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **create_entity** + > Entity create_entity(entity_create) Create Entity @@ -111,7 +111,7 @@ configuration = openapi_client.Configuration( with openapi_client.ApiClient(configuration) as api_client: # Create an instance of the API class api_instance = openapi_client.EntitiesApi(api_client) - entity_create = openapi_client.EntityCreate() # EntityCreate | + entity_create = openapi_client.EntityCreate() # EntityCreate | try: # Create Entity @@ -122,13 +122,11 @@ with openapi_client.ApiClient(configuration) as api_client: print("Exception when calling EntitiesApi->create_entity: %s\n" % e) ``` - - ### Parameters -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **entity_create** | [**EntityCreate**](EntityCreate.md)| | +| Name | Type | Description | Notes | +| ----------------- | ----------------------------------- | ----------- | ----- | +| **entity_create** | [**EntityCreate**](EntityCreate.md) | | ### Return type @@ -140,18 +138,20 @@ No authorization required ### HTTP request headers - - **Content-Type**: application/json - - **Accept**: application/json +- **Content-Type**: application/json +- **Accept**: application/json ### HTTP response details -| Status code | Description | Response headers | -|-------------|-------------|------------------| -**200** | Successful Response | - | -**422** | Validation Error | - | + +| Status code | Description | Response headers | +| ----------- | ------------------- | ---------------- | +| **200** | Successful Response | - | +| **422** | Validation Error | - | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **delete_entity** + > Dict[str, str] delete_entity(entity_did=entity_did) Delete Entity @@ -187,13 +187,11 @@ with openapi_client.ApiClient(configuration) as api_client: print("Exception when calling EntitiesApi->delete_entity: %s\n" % e) ``` - - ### Parameters -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **entity_did** | **str**| | [optional] [default to 'did:sov:test:1234'] +| Name | Type | Description | Notes | +| -------------- | ------- | ----------- | --------------------------------------------------- | +| **entity_did** | **str** | | [optional] [default to 'did:sov:test:1234'] | ### Return type @@ -205,18 +203,20 @@ No authorization required ### HTTP request headers - - **Content-Type**: Not defined - - **Accept**: application/json +- **Content-Type**: Not defined +- **Accept**: application/json ### HTTP response details -| Status code | Description | Response headers | -|-------------|-------------|------------------| -**200** | Successful Response | - | -**422** | Validation Error | - | + +| Status code | Description | Response headers | +| ----------- | ------------------- | ---------------- | +| **200** | Successful Response | - | +| **422** | Validation Error | - | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **detach_entity** + > Dict[str, str] detach_entity(entity_did=entity_did, skip=skip, limit=limit) Detach Entity @@ -254,15 +254,13 @@ with openapi_client.ApiClient(configuration) as api_client: print("Exception when calling EntitiesApi->detach_entity: %s\n" % e) ``` - - ### Parameters -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **entity_did** | **str**| | [optional] [default to 'did:sov:test:1234'] - **skip** | **int**| | [optional] [default to 0] - **limit** | **int**| | [optional] [default to 100] +| Name | Type | Description | Notes | +| -------------- | ------- | ----------- | --------------------------------------------------- | +| **entity_did** | **str** | | [optional] [default to 'did:sov:test:1234'] | +| **skip** | **int** | | [optional] [default to 0] | +| **limit** | **int** | | [optional] [default to 100] | ### Return type @@ -274,18 +272,20 @@ No authorization required ### HTTP request headers - - **Content-Type**: Not defined - - **Accept**: application/json +- **Content-Type**: Not defined +- **Accept**: application/json ### HTTP response details -| Status code | Description | Response headers | -|-------------|-------------|------------------| -**200** | Successful Response | - | -**422** | Validation Error | - | + +| Status code | Description | Response headers | +| ----------- | ------------------- | ---------------- | +| **200** | Successful Response | - | +| **422** | Validation Error | - | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **get_all_entities** + > List[Entity] get_all_entities(skip=skip, limit=limit) Get All Entities @@ -323,14 +323,12 @@ with openapi_client.ApiClient(configuration) as api_client: print("Exception when calling EntitiesApi->get_all_entities: %s\n" % e) ``` - - ### Parameters -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **skip** | **int**| | [optional] [default to 0] - **limit** | **int**| | [optional] [default to 100] +| Name | Type | Description | Notes | +| --------- | ------- | ----------- | --------------------------- | +| **skip** | **int** | | [optional] [default to 0] | +| **limit** | **int** | | [optional] [default to 100] | ### Return type @@ -342,18 +340,20 @@ No authorization required ### HTTP request headers - - **Content-Type**: Not defined - - **Accept**: application/json +- **Content-Type**: Not defined +- **Accept**: application/json ### HTTP response details -| Status code | Description | Response headers | -|-------------|-------------|------------------| -**200** | Successful Response | - | -**422** | Validation Error | - | + +| Status code | Description | Response headers | +| ----------- | ------------------- | ---------------- | +| **200** | Successful Response | - | +| **422** | Validation Error | - | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **get_attached_entities** + > List[Entity] get_attached_entities(skip=skip, limit=limit) Get Attached Entities @@ -391,14 +391,12 @@ with openapi_client.ApiClient(configuration) as api_client: print("Exception when calling EntitiesApi->get_attached_entities: %s\n" % e) ``` - - ### Parameters -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **skip** | **int**| | [optional] [default to 0] - **limit** | **int**| | [optional] [default to 100] +| Name | Type | Description | Notes | +| --------- | ------- | ----------- | --------------------------- | +| **skip** | **int** | | [optional] [default to 0] | +| **limit** | **int** | | [optional] [default to 100] | ### Return type @@ -410,18 +408,20 @@ No authorization required ### HTTP request headers - - **Content-Type**: Not defined - - **Accept**: application/json +- **Content-Type**: Not defined +- **Accept**: application/json ### HTTP response details -| Status code | Description | Response headers | -|-------------|-------------|------------------| -**200** | Successful Response | - | -**422** | Validation Error | - | + +| Status code | Description | Response headers | +| ----------- | ------------------- | ---------------- | +| **200** | Successful Response | - | +| **422** | Validation Error | - | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **get_entity_by_did** + > Entity get_entity_by_did(entity_did=entity_did) Get Entity By Did @@ -458,13 +458,11 @@ with openapi_client.ApiClient(configuration) as api_client: print("Exception when calling EntitiesApi->get_entity_by_did: %s\n" % e) ``` - - ### Parameters -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **entity_did** | **str**| | [optional] [default to 'did:sov:test:1234'] +| Name | Type | Description | Notes | +| -------------- | ------- | ----------- | --------------------------------------------------- | +| **entity_did** | **str** | | [optional] [default to 'did:sov:test:1234'] | ### Return type @@ -476,18 +474,20 @@ No authorization required ### HTTP request headers - - **Content-Type**: Not defined - - **Accept**: application/json +- **Content-Type**: Not defined +- **Accept**: application/json ### HTTP response details -| Status code | Description | Response headers | -|-------------|-------------|------------------| -**200** | Successful Response | - | -**422** | Validation Error | - | + +| Status code | Description | Response headers | +| ----------- | ------------------- | ---------------- | +| **200** | Successful Response | - | +| **422** | Validation Error | - | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **get_entity_by_name** + > Entity get_entity_by_name(entity_name) Get Entity By Name @@ -513,7 +513,7 @@ configuration = openapi_client.Configuration( with openapi_client.ApiClient(configuration) as api_client: # Create an instance of the API class api_instance = openapi_client.EntitiesApi(api_client) - entity_name = 'entity_name_example' # str | + entity_name = 'entity_name_example' # str | try: # Get Entity By Name @@ -524,13 +524,11 @@ with openapi_client.ApiClient(configuration) as api_client: print("Exception when calling EntitiesApi->get_entity_by_name: %s\n" % e) ``` - - ### Parameters -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **entity_name** | **str**| | +| Name | Type | Description | Notes | +| --------------- | ------- | ----------- | ----- | +| **entity_name** | **str** | | ### Return type @@ -542,18 +540,20 @@ No authorization required ### HTTP request headers - - **Content-Type**: Not defined - - **Accept**: application/json +- **Content-Type**: Not defined +- **Accept**: application/json ### HTTP response details -| Status code | Description | Response headers | -|-------------|-------------|------------------| -**200** | Successful Response | - | -**422** | Validation Error | - | + +| Status code | Description | Response headers | +| ----------- | ------------------- | ---------------- | +| **200** | Successful Response | - | +| **422** | Validation Error | - | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **is_attached** + > Dict[str, str] is_attached(entity_did=entity_did) Is Attached @@ -589,13 +589,11 @@ with openapi_client.ApiClient(configuration) as api_client: print("Exception when calling EntitiesApi->is_attached: %s\n" % e) ``` - - ### Parameters -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **entity_did** | **str**| | [optional] [default to 'did:sov:test:1234'] +| Name | Type | Description | Notes | +| -------------- | ------- | ----------- | --------------------------------------------------- | +| **entity_did** | **str** | | [optional] [default to 'did:sov:test:1234'] | ### Return type @@ -607,14 +605,14 @@ No authorization required ### HTTP request headers - - **Content-Type**: Not defined - - **Accept**: application/json +- **Content-Type**: Not defined +- **Accept**: application/json ### HTTP response details -| Status code | Description | Response headers | -|-------------|-------------|------------------| -**200** | Successful Response | - | -**422** | Validation Error | - | + +| Status code | Description | Response headers | +| ----------- | ------------------- | ---------------- | +| **200** | Successful Response | - | +| **422** | Validation Error | - | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) - diff --git a/pkgs/clan-cli/tests/openapi_client/docs/Entity.md b/pkgs/clan-cli/tests/openapi_client/docs/Entity.md index 4818b3b..807f6a6 100644 --- a/pkgs/clan-cli/tests/openapi_client/docs/Entity.md +++ b/pkgs/clan-cli/tests/openapi_client/docs/Entity.md @@ -1,18 +1,18 @@ # Entity - ## Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**did** | **str** | | -**name** | **str** | | -**ip** | **str** | | -**network** | **str** | | -**role** | [**Roles**](Roles.md) | | -**visible** | **bool** | | -**other** | **object** | | -**attached** | **bool** | | -**stop_health_task** | **bool** | | + +| Name | Type | Description | Notes | +| -------------------- | --------------------- | ----------- | ----- | +| **did** | **str** | | +| **name** | **str** | | +| **ip** | **str** | | +| **network** | **str** | | +| **role** | [**Roles**](Roles.md) | | +| **visible** | **bool** | | +| **other** | **object** | | +| **attached** | **bool** | | +| **stop_health_task** | **bool** | | ## Example @@ -31,6 +31,5 @@ entity_dict = entity_instance.to_dict() # create an instance of Entity from a dict entity_form_dict = entity.from_dict(entity_dict) ``` + [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) - - diff --git a/pkgs/clan-cli/tests/openapi_client/docs/EntityCreate.md b/pkgs/clan-cli/tests/openapi_client/docs/EntityCreate.md index 306e4c0..ea30366 100644 --- a/pkgs/clan-cli/tests/openapi_client/docs/EntityCreate.md +++ b/pkgs/clan-cli/tests/openapi_client/docs/EntityCreate.md @@ -1,16 +1,16 @@ # EntityCreate - ## Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**did** | **str** | | -**name** | **str** | | -**ip** | **str** | | -**network** | **str** | | -**role** | [**Roles**](Roles.md) | | -**visible** | **bool** | | -**other** | **object** | | + +| Name | Type | Description | Notes | +| ----------- | --------------------- | ----------- | ----- | +| **did** | **str** | | +| **name** | **str** | | +| **ip** | **str** | | +| **network** | **str** | | +| **role** | [**Roles**](Roles.md) | | +| **visible** | **bool** | | +| **other** | **object** | | ## Example @@ -29,6 +29,5 @@ entity_create_dict = entity_create_instance.to_dict() # create an instance of EntityCreate from a dict entity_create_form_dict = entity_create.from_dict(entity_create_dict) ``` + [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) - - diff --git a/pkgs/clan-cli/tests/openapi_client/docs/Eventmessage.md b/pkgs/clan-cli/tests/openapi_client/docs/Eventmessage.md index e51e987..cbe65cb 100644 --- a/pkgs/clan-cli/tests/openapi_client/docs/Eventmessage.md +++ b/pkgs/clan-cli/tests/openapi_client/docs/Eventmessage.md @@ -1,17 +1,17 @@ # Eventmessage - ## Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**id** | **int** | | -**timestamp** | **int** | | -**group** | **int** | | -**group_id** | **int** | | -**msg_type** | **int** | | -**src_did** | **str** | | -**des_did** | **str** | | -**msg** | **object** | | + +| Name | Type | Description | Notes | +| ------------- | ---------- | ----------- | ----- | +| **id** | **int** | | +| **timestamp** | **int** | | +| **group** | **int** | | +| **group_id** | **int** | | +| **msg_type** | **int** | | +| **src_did** | **str** | | +| **des_did** | **str** | | +| **msg** | **object** | | ## Example @@ -30,6 +30,5 @@ eventmessage_dict = eventmessage_instance.to_dict() # create an instance of Eventmessage from a dict eventmessage_form_dict = eventmessage.from_dict(eventmessage_dict) ``` + [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) - - diff --git a/pkgs/clan-cli/tests/openapi_client/docs/EventmessageCreate.md b/pkgs/clan-cli/tests/openapi_client/docs/EventmessageCreate.md index bfb7347..eb6f16d 100644 --- a/pkgs/clan-cli/tests/openapi_client/docs/EventmessageCreate.md +++ b/pkgs/clan-cli/tests/openapi_client/docs/EventmessageCreate.md @@ -1,17 +1,17 @@ # EventmessageCreate - ## Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**id** | **int** | | -**timestamp** | **int** | | -**group** | **int** | | -**group_id** | **int** | | -**msg_type** | **int** | | -**src_did** | **str** | | -**des_did** | **str** | | -**msg** | **object** | | + +| Name | Type | Description | Notes | +| ------------- | ---------- | ----------- | ----- | +| **id** | **int** | | +| **timestamp** | **int** | | +| **group** | **int** | | +| **group_id** | **int** | | +| **msg_type** | **int** | | +| **src_did** | **str** | | +| **des_did** | **str** | | +| **msg** | **object** | | ## Example @@ -30,6 +30,5 @@ eventmessage_create_dict = eventmessage_create_instance.to_dict() # create an instance of EventmessageCreate from a dict eventmessage_create_form_dict = eventmessage_create.from_dict(eventmessage_create_dict) ``` + [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) - - diff --git a/pkgs/clan-cli/tests/openapi_client/docs/EventmessagesApi.md b/pkgs/clan-cli/tests/openapi_client/docs/EventmessagesApi.md index e146d13..d6affb9 100644 --- a/pkgs/clan-cli/tests/openapi_client/docs/EventmessagesApi.md +++ b/pkgs/clan-cli/tests/openapi_client/docs/EventmessagesApi.md @@ -1,14 +1,14 @@ # openapi_client.EventmessagesApi -All URIs are relative to *http://localhost* - -Method | HTTP request | Description -------------- | ------------- | ------------- -[**create_eventmessage**](EventmessagesApi.md#create_eventmessage) | **POST** /api/v1/send_msg | Create Eventmessage -[**get_all_eventmessages**](EventmessagesApi.md#get_all_eventmessages) | **GET** /api/v1/event_messages | Get All Eventmessages +All URIs are relative to _http://localhost_ +| Method | HTTP request | Description | +| ---------------------------------------------------------------------- | ------------------------------ | --------------------- | +| [**create_eventmessage**](EventmessagesApi.md#create_eventmessage) | **POST** /api/v1/send_msg | Create Eventmessage | +| [**get_all_eventmessages**](EventmessagesApi.md#get_all_eventmessages) | **GET** /api/v1/event_messages | Get All Eventmessages | # **create_eventmessage** + > Eventmessage create_eventmessage(eventmessage_create) Create Eventmessage @@ -35,7 +35,7 @@ configuration = openapi_client.Configuration( with openapi_client.ApiClient(configuration) as api_client: # Create an instance of the API class api_instance = openapi_client.EventmessagesApi(api_client) - eventmessage_create = openapi_client.EventmessageCreate() # EventmessageCreate | + eventmessage_create = openapi_client.EventmessageCreate() # EventmessageCreate | try: # Create Eventmessage @@ -46,13 +46,11 @@ with openapi_client.ApiClient(configuration) as api_client: print("Exception when calling EventmessagesApi->create_eventmessage: %s\n" % e) ``` - - ### Parameters -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **eventmessage_create** | [**EventmessageCreate**](EventmessageCreate.md)| | +| Name | Type | Description | Notes | +| ----------------------- | ----------------------------------------------- | ----------- | ----- | +| **eventmessage_create** | [**EventmessageCreate**](EventmessageCreate.md) | | ### Return type @@ -64,18 +62,20 @@ No authorization required ### HTTP request headers - - **Content-Type**: application/json - - **Accept**: application/json +- **Content-Type**: application/json +- **Accept**: application/json ### HTTP response details -| Status code | Description | Response headers | -|-------------|-------------|------------------| -**200** | Successful Response | - | -**422** | Validation Error | - | + +| Status code | Description | Response headers | +| ----------- | ------------------- | ---------------- | +| **200** | Successful Response | - | +| **422** | Validation Error | - | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **get_all_eventmessages** + > List[Eventmessage] get_all_eventmessages(skip=skip, limit=limit) Get All Eventmessages @@ -113,14 +113,12 @@ with openapi_client.ApiClient(configuration) as api_client: print("Exception when calling EventmessagesApi->get_all_eventmessages: %s\n" % e) ``` - - ### Parameters -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **skip** | **int**| | [optional] [default to 0] - **limit** | **int**| | [optional] [default to 100] +| Name | Type | Description | Notes | +| --------- | ------- | ----------- | --------------------------- | +| **skip** | **int** | | [optional] [default to 0] | +| **limit** | **int** | | [optional] [default to 100] | ### Return type @@ -132,14 +130,14 @@ No authorization required ### HTTP request headers - - **Content-Type**: Not defined - - **Accept**: application/json +- **Content-Type**: Not defined +- **Accept**: application/json ### HTTP response details -| Status code | Description | Response headers | -|-------------|-------------|------------------| -**200** | Successful Response | - | -**422** | Validation Error | - | + +| Status code | Description | Response headers | +| ----------- | ------------------- | ---------------- | +| **200** | Successful Response | - | +| **422** | Validation Error | - | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) - diff --git a/pkgs/clan-cli/tests/openapi_client/docs/HTTPValidationError.md b/pkgs/clan-cli/tests/openapi_client/docs/HTTPValidationError.md index 5eee49b..d4902e7 100644 --- a/pkgs/clan-cli/tests/openapi_client/docs/HTTPValidationError.md +++ b/pkgs/clan-cli/tests/openapi_client/docs/HTTPValidationError.md @@ -1,10 +1,10 @@ # HTTPValidationError - ## Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**detail** | [**List[ValidationError]**](ValidationError.md) | | [optional] + +| Name | Type | Description | Notes | +| ---------- | ----------------------------------------------- | ----------- | ---------- | +| **detail** | [**List[ValidationError]**](ValidationError.md) | | [optional] | ## Example @@ -23,6 +23,5 @@ http_validation_error_dict = http_validation_error_instance.to_dict() # create an instance of HTTPValidationError from a dict http_validation_error_form_dict = http_validation_error.from_dict(http_validation_error_dict) ``` + [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) - - diff --git a/pkgs/clan-cli/tests/openapi_client/docs/Machine.md b/pkgs/clan-cli/tests/openapi_client/docs/Machine.md index 4ea6dc3..062fd51 100644 --- a/pkgs/clan-cli/tests/openapi_client/docs/Machine.md +++ b/pkgs/clan-cli/tests/openapi_client/docs/Machine.md @@ -1,11 +1,11 @@ # Machine - ## Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**name** | **str** | | -**status** | [**Status**](Status.md) | | + +| Name | Type | Description | Notes | +| ---------- | ----------------------- | ----------- | ----- | +| **name** | **str** | | +| **status** | [**Status**](Status.md) | | ## Example @@ -24,6 +24,5 @@ machine_dict = machine_instance.to_dict() # create an instance of Machine from a dict machine_form_dict = machine.from_dict(machine_dict) ``` + [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) - - diff --git a/pkgs/clan-cli/tests/openapi_client/docs/RepositoriesApi.md b/pkgs/clan-cli/tests/openapi_client/docs/RepositoriesApi.md index 7a24ab0..ff735f0 100644 --- a/pkgs/clan-cli/tests/openapi_client/docs/RepositoriesApi.md +++ b/pkgs/clan-cli/tests/openapi_client/docs/RepositoriesApi.md @@ -1,13 +1,13 @@ # openapi_client.RepositoriesApi -All URIs are relative to *http://localhost* - -Method | HTTP request | Description -------------- | ------------- | ------------- -[**get_all_repositories**](RepositoriesApi.md#get_all_repositories) | **GET** /api/v1/repositories | Get All Repositories +All URIs are relative to _http://localhost_ +| Method | HTTP request | Description | +| ------------------------------------------------------------------- | ---------------------------- | -------------------- | +| [**get_all_repositories**](RepositoriesApi.md#get_all_repositories) | **GET** /api/v1/repositories | Get All Repositories | # **get_all_repositories** + > List[Service] get_all_repositories(skip=skip, limit=limit) Get All Repositories @@ -45,14 +45,12 @@ with openapi_client.ApiClient(configuration) as api_client: print("Exception when calling RepositoriesApi->get_all_repositories: %s\n" % e) ``` - - ### Parameters -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **skip** | **int**| | [optional] [default to 0] - **limit** | **int**| | [optional] [default to 100] +| Name | Type | Description | Notes | +| --------- | ------- | ----------- | --------------------------- | +| **skip** | **int** | | [optional] [default to 0] | +| **limit** | **int** | | [optional] [default to 100] | ### Return type @@ -64,14 +62,14 @@ No authorization required ### HTTP request headers - - **Content-Type**: Not defined - - **Accept**: application/json +- **Content-Type**: Not defined +- **Accept**: application/json ### HTTP response details -| Status code | Description | Response headers | -|-------------|-------------|------------------| -**200** | Successful Response | - | -**422** | Validation Error | - | + +| Status code | Description | Response headers | +| ----------- | ------------------- | ---------------- | +| **200** | Successful Response | - | +| **422** | Validation Error | - | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) - diff --git a/pkgs/clan-cli/tests/openapi_client/docs/Resolution.md b/pkgs/clan-cli/tests/openapi_client/docs/Resolution.md index 27a3992..27928d5 100644 --- a/pkgs/clan-cli/tests/openapi_client/docs/Resolution.md +++ b/pkgs/clan-cli/tests/openapi_client/docs/Resolution.md @@ -1,15 +1,15 @@ # Resolution - ## Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**requester_name** | **str** | | -**requester_did** | **str** | | -**resolved_did** | **str** | | -**other** | **object** | | -**timestamp** | **datetime** | | -**id** | **int** | | + +| Name | Type | Description | Notes | +| ------------------ | ------------ | ----------- | ----- | +| **requester_name** | **str** | | +| **requester_did** | **str** | | +| **resolved_did** | **str** | | +| **other** | **object** | | +| **timestamp** | **datetime** | | +| **id** | **int** | | ## Example @@ -28,6 +28,5 @@ resolution_dict = resolution_instance.to_dict() # create an instance of Resolution from a dict resolution_form_dict = resolution.from_dict(resolution_dict) ``` + [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) - - diff --git a/pkgs/clan-cli/tests/openapi_client/docs/ResolutionApi.md b/pkgs/clan-cli/tests/openapi_client/docs/ResolutionApi.md index a2ae852..24da5fb 100644 --- a/pkgs/clan-cli/tests/openapi_client/docs/ResolutionApi.md +++ b/pkgs/clan-cli/tests/openapi_client/docs/ResolutionApi.md @@ -1,13 +1,13 @@ # openapi_client.ResolutionApi -All URIs are relative to *http://localhost* - -Method | HTTP request | Description -------------- | ------------- | ------------- -[**get_all_resolutions**](ResolutionApi.md#get_all_resolutions) | **GET** /api/v1/resolutions | Get All Resolutions +All URIs are relative to _http://localhost_ +| Method | HTTP request | Description | +| --------------------------------------------------------------- | --------------------------- | ------------------- | +| [**get_all_resolutions**](ResolutionApi.md#get_all_resolutions) | **GET** /api/v1/resolutions | Get All Resolutions | # **get_all_resolutions** + > List[Resolution] get_all_resolutions(skip=skip, limit=limit) Get All Resolutions @@ -45,14 +45,12 @@ with openapi_client.ApiClient(configuration) as api_client: print("Exception when calling ResolutionApi->get_all_resolutions: %s\n" % e) ``` - - ### Parameters -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **skip** | **int**| | [optional] [default to 0] - **limit** | **int**| | [optional] [default to 100] +| Name | Type | Description | Notes | +| --------- | ------- | ----------- | --------------------------- | +| **skip** | **int** | | [optional] [default to 0] | +| **limit** | **int** | | [optional] [default to 100] | ### Return type @@ -64,14 +62,14 @@ No authorization required ### HTTP request headers - - **Content-Type**: Not defined - - **Accept**: application/json +- **Content-Type**: Not defined +- **Accept**: application/json ### HTTP response details -| Status code | Description | Response headers | -|-------------|-------------|------------------| -**200** | Successful Response | - | -**422** | Validation Error | - | + +| Status code | Description | Response headers | +| ----------- | ------------------- | ---------------- | +| **200** | Successful Response | - | +| **422** | Validation Error | - | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) - diff --git a/pkgs/clan-cli/tests/openapi_client/docs/Roles.md b/pkgs/clan-cli/tests/openapi_client/docs/Roles.md new file mode 100644 index 0000000..994fa4c --- /dev/null +++ b/pkgs/clan-cli/tests/openapi_client/docs/Roles.md @@ -0,0 +1,10 @@ +# Roles + +An enumeration. + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/pkgs/clan-cli/tests/openapi_client/docs/Service.md b/pkgs/clan-cli/tests/openapi_client/docs/Service.md index bff9e15..5798f74 100644 --- a/pkgs/clan-cli/tests/openapi_client/docs/Service.md +++ b/pkgs/clan-cli/tests/openapi_client/docs/Service.md @@ -1,17 +1,17 @@ # Service - ## Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**uuid** | **str** | | -**service_name** | **str** | | -**service_type** | **str** | | -**endpoint_url** | **str** | | -**status** | **str** | | -**other** | **object** | | -**entity_did** | **str** | | -**entity** | [**Entity**](Entity.md) | | + +| Name | Type | Description | Notes | +| ---------------- | ----------------------- | ----------- | ----- | +| **uuid** | **str** | | +| **service_name** | **str** | | +| **service_type** | **str** | | +| **endpoint_url** | **str** | | +| **status** | **str** | | +| **other** | **object** | | +| **entity_did** | **str** | | +| **entity** | [**Entity**](Entity.md) | | ## Example @@ -30,6 +30,5 @@ service_dict = service_instance.to_dict() # create an instance of Service from a dict service_form_dict = service.from_dict(service_dict) ``` + [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) - - diff --git a/pkgs/clan-cli/tests/openapi_client/docs/ServiceCreate.md b/pkgs/clan-cli/tests/openapi_client/docs/ServiceCreate.md index f8e84e1..7843b1a 100644 --- a/pkgs/clan-cli/tests/openapi_client/docs/ServiceCreate.md +++ b/pkgs/clan-cli/tests/openapi_client/docs/ServiceCreate.md @@ -1,16 +1,16 @@ # ServiceCreate - ## Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**uuid** | **str** | | -**service_name** | **str** | | -**service_type** | **str** | | -**endpoint_url** | **str** | | -**status** | **str** | | -**other** | **object** | | -**entity_did** | **str** | | + +| Name | Type | Description | Notes | +| ---------------- | ---------- | ----------- | ----- | +| **uuid** | **str** | | +| **service_name** | **str** | | +| **service_type** | **str** | | +| **endpoint_url** | **str** | | +| **status** | **str** | | +| **other** | **object** | | +| **entity_did** | **str** | | ## Example @@ -29,6 +29,5 @@ service_create_dict = service_create_instance.to_dict() # create an instance of ServiceCreate from a dict service_create_form_dict = service_create.from_dict(service_create_dict) ``` + [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) - - diff --git a/pkgs/clan-cli/tests/openapi_client/docs/ServicesApi.md b/pkgs/clan-cli/tests/openapi_client/docs/ServicesApi.md index 9a2c544..006615a 100644 --- a/pkgs/clan-cli/tests/openapi_client/docs/ServicesApi.md +++ b/pkgs/clan-cli/tests/openapi_client/docs/ServicesApi.md @@ -1,17 +1,17 @@ # openapi_client.ServicesApi -All URIs are relative to *http://localhost* - -Method | HTTP request | Description -------------- | ------------- | ------------- -[**create_service**](ServicesApi.md#create_service) | **POST** /api/v1/service | Create Service -[**delete_service**](ServicesApi.md#delete_service) | **DELETE** /api/v1/service | Delete Service -[**get_all_services**](ServicesApi.md#get_all_services) | **GET** /api/v1/services | Get All Services -[**get_service_by_did**](ServicesApi.md#get_service_by_did) | **GET** /api/v1/service | Get Service By Did -[**get_services_without_entity**](ServicesApi.md#get_services_without_entity) | **GET** /api/v1/services_without_entity | Get Services Without Entity +All URIs are relative to _http://localhost_ +| Method | HTTP request | Description | +| ----------------------------------------------------------------------------- | --------------------------------------- | --------------------------- | +| [**create_service**](ServicesApi.md#create_service) | **POST** /api/v1/service | Create Service | +| [**delete_service**](ServicesApi.md#delete_service) | **DELETE** /api/v1/service | Delete Service | +| [**get_all_services**](ServicesApi.md#get_all_services) | **GET** /api/v1/services | Get All Services | +| [**get_service_by_did**](ServicesApi.md#get_service_by_did) | **GET** /api/v1/service | Get Service By Did | +| [**get_services_without_entity**](ServicesApi.md#get_services_without_entity) | **GET** /api/v1/services_without_entity | Get Services Without Entity | # **create_service** + > Service create_service(service_create) Create Service @@ -38,7 +38,7 @@ configuration = openapi_client.Configuration( with openapi_client.ApiClient(configuration) as api_client: # Create an instance of the API class api_instance = openapi_client.ServicesApi(api_client) - service_create = openapi_client.ServiceCreate() # ServiceCreate | + service_create = openapi_client.ServiceCreate() # ServiceCreate | try: # Create Service @@ -49,13 +49,11 @@ with openapi_client.ApiClient(configuration) as api_client: print("Exception when calling ServicesApi->create_service: %s\n" % e) ``` - - ### Parameters -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **service_create** | [**ServiceCreate**](ServiceCreate.md)| | +| Name | Type | Description | Notes | +| ------------------ | ------------------------------------- | ----------- | ----- | +| **service_create** | [**ServiceCreate**](ServiceCreate.md) | | ### Return type @@ -67,18 +65,20 @@ No authorization required ### HTTP request headers - - **Content-Type**: application/json - - **Accept**: application/json +- **Content-Type**: application/json +- **Accept**: application/json ### HTTP response details -| Status code | Description | Response headers | -|-------------|-------------|------------------| -**200** | Successful Response | - | -**422** | Validation Error | - | + +| Status code | Description | Response headers | +| ----------- | ------------------- | ---------------- | +| **200** | Successful Response | - | +| **422** | Validation Error | - | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **delete_service** + > Dict[str, str] delete_service(entity_did=entity_did) Delete Service @@ -114,13 +114,11 @@ with openapi_client.ApiClient(configuration) as api_client: print("Exception when calling ServicesApi->delete_service: %s\n" % e) ``` - - ### Parameters -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **entity_did** | **str**| | [optional] [default to 'did:sov:test:1234'] +| Name | Type | Description | Notes | +| -------------- | ------- | ----------- | --------------------------------------------------- | +| **entity_did** | **str** | | [optional] [default to 'did:sov:test:1234'] | ### Return type @@ -132,18 +130,20 @@ No authorization required ### HTTP request headers - - **Content-Type**: Not defined - - **Accept**: application/json +- **Content-Type**: Not defined +- **Accept**: application/json ### HTTP response details -| Status code | Description | Response headers | -|-------------|-------------|------------------| -**200** | Successful Response | - | -**422** | Validation Error | - | + +| Status code | Description | Response headers | +| ----------- | ------------------- | ---------------- | +| **200** | Successful Response | - | +| **422** | Validation Error | - | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **get_all_services** + > List[Service] get_all_services(skip=skip, limit=limit) Get All Services @@ -181,14 +181,12 @@ with openapi_client.ApiClient(configuration) as api_client: print("Exception when calling ServicesApi->get_all_services: %s\n" % e) ``` - - ### Parameters -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **skip** | **int**| | [optional] [default to 0] - **limit** | **int**| | [optional] [default to 100] +| Name | Type | Description | Notes | +| --------- | ------- | ----------- | --------------------------- | +| **skip** | **int** | | [optional] [default to 0] | +| **limit** | **int** | | [optional] [default to 100] | ### Return type @@ -200,18 +198,20 @@ No authorization required ### HTTP request headers - - **Content-Type**: Not defined - - **Accept**: application/json +- **Content-Type**: Not defined +- **Accept**: application/json ### HTTP response details -| Status code | Description | Response headers | -|-------------|-------------|------------------| -**200** | Successful Response | - | -**422** | Validation Error | - | + +| Status code | Description | Response headers | +| ----------- | ------------------- | ---------------- | +| **200** | Successful Response | - | +| **422** | Validation Error | - | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **get_service_by_did** + > List[Service] get_service_by_did(entity_did=entity_did, skip=skip, limit=limit) Get Service By Did @@ -250,15 +250,13 @@ with openapi_client.ApiClient(configuration) as api_client: print("Exception when calling ServicesApi->get_service_by_did: %s\n" % e) ``` - - ### Parameters -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **entity_did** | **str**| | [optional] [default to 'did:sov:test:1234'] - **skip** | **int**| | [optional] [default to 0] - **limit** | **int**| | [optional] [default to 100] +| Name | Type | Description | Notes | +| -------------- | ------- | ----------- | --------------------------------------------------- | +| **entity_did** | **str** | | [optional] [default to 'did:sov:test:1234'] | +| **skip** | **int** | | [optional] [default to 0] | +| **limit** | **int** | | [optional] [default to 100] | ### Return type @@ -270,18 +268,20 @@ No authorization required ### HTTP request headers - - **Content-Type**: Not defined - - **Accept**: application/json +- **Content-Type**: Not defined +- **Accept**: application/json ### HTTP response details -| Status code | Description | Response headers | -|-------------|-------------|------------------| -**200** | Successful Response | - | -**422** | Validation Error | - | + +| Status code | Description | Response headers | +| ----------- | ------------------- | ---------------- | +| **200** | Successful Response | - | +| **422** | Validation Error | - | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **get_services_without_entity** + > List[Service] get_services_without_entity(entity_did=entity_did, skip=skip, limit=limit) Get Services Without Entity @@ -320,15 +320,13 @@ with openapi_client.ApiClient(configuration) as api_client: print("Exception when calling ServicesApi->get_services_without_entity: %s\n" % e) ``` - - ### Parameters -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **entity_did** | **str**| | [optional] [default to 'did:sov:test:1234'] - **skip** | **int**| | [optional] [default to 0] - **limit** | **int**| | [optional] [default to 100] +| Name | Type | Description | Notes | +| -------------- | ------- | ----------- | --------------------------------------------------- | +| **entity_did** | **str** | | [optional] [default to 'did:sov:test:1234'] | +| **skip** | **int** | | [optional] [default to 0] | +| **limit** | **int** | | [optional] [default to 100] | ### Return type @@ -340,14 +338,14 @@ No authorization required ### HTTP request headers - - **Content-Type**: Not defined - - **Accept**: application/json +- **Content-Type**: Not defined +- **Accept**: application/json ### HTTP response details -| Status code | Description | Response headers | -|-------------|-------------|------------------| -**200** | Successful Response | - | -**422** | Validation Error | - | + +| Status code | Description | Response headers | +| ----------- | ------------------- | ---------------- | +| **200** | Successful Response | - | +| **422** | Validation Error | - | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) - diff --git a/pkgs/clan-cli/tests/openapi_client/docs/Status.md b/pkgs/clan-cli/tests/openapi_client/docs/Status.md index 3b89cf4..10bd223 100644 --- a/pkgs/clan-cli/tests/openapi_client/docs/Status.md +++ b/pkgs/clan-cli/tests/openapi_client/docs/Status.md @@ -3,9 +3,8 @@ An enumeration. ## Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) - - diff --git a/pkgs/clan-cli/tests/openapi_client/docs/ValidationError.md b/pkgs/clan-cli/tests/openapi_client/docs/ValidationError.md index 04310f6..b57b565 100644 --- a/pkgs/clan-cli/tests/openapi_client/docs/ValidationError.md +++ b/pkgs/clan-cli/tests/openapi_client/docs/ValidationError.md @@ -1,12 +1,12 @@ # ValidationError - ## Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**loc** | [**List[ValidationErrorLocInner]**](ValidationErrorLocInner.md) | | -**msg** | **str** | | -**type** | **str** | | + +| Name | Type | Description | Notes | +| -------- | --------------------------------------------------------------- | ----------- | ----- | +| **loc** | [**List[ValidationErrorLocInner]**](ValidationErrorLocInner.md) | | +| **msg** | **str** | | +| **type** | **str** | | ## Example @@ -25,6 +25,5 @@ validation_error_dict = validation_error_instance.to_dict() # create an instance of ValidationError from a dict validation_error_form_dict = validation_error.from_dict(validation_error_dict) ``` + [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) - - diff --git a/pkgs/clan-cli/tests/openapi_client/docs/ValidationErrorLocInner.md b/pkgs/clan-cli/tests/openapi_client/docs/ValidationErrorLocInner.md index 0bae52d..04e49df 100644 --- a/pkgs/clan-cli/tests/openapi_client/docs/ValidationErrorLocInner.md +++ b/pkgs/clan-cli/tests/openapi_client/docs/ValidationErrorLocInner.md @@ -1,9 +1,9 @@ # ValidationErrorLocInner - ## Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | ## Example @@ -22,6 +22,5 @@ validation_error_loc_inner_dict = validation_error_loc_inner_instance.to_dict() # create an instance of ValidationErrorLocInner from a dict validation_error_loc_inner_form_dict = validation_error_loc_inner.from_dict(validation_error_loc_inner_dict) ``` + [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) - - diff --git a/pkgs/clan-cli/tests/openapi_client/models/roles.py b/pkgs/clan-cli/tests/openapi_client/models/roles.py new file mode 100644 index 0000000..189cbd3 --- /dev/null +++ b/pkgs/clan-cli/tests/openapi_client/models/roles.py @@ -0,0 +1,41 @@ +# coding: utf-8 + +""" + FastAPI + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: 0.1.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import json +import pprint +import re # noqa: F401 +from aenum import Enum, no_arg + + + + + +class Roles(str, Enum): + """ + An enumeration. + """ + + """ + allowed enum values + """ + SERVICE_PROSUMER = 'service_prosumer' + AP = 'AP' + DLG = 'DLG' + + @classmethod + def from_json(cls, json_str: str) -> Roles: + """Create an instance of Roles from a JSON string""" + return Roles(json.loads(json_str)) + + diff --git a/pkgs/clan-cli/tests/test_db_api.py b/pkgs/clan-cli/tests/test_db_api.py index 2248503..5cf4324 100644 --- a/pkgs/clan-cli/tests/test_db_api.py +++ b/pkgs/clan-cli/tests/test_db_api.py @@ -1,7 +1,6 @@ import random import time import uuid -import api from openapi_client import ApiClient from openapi_client.api import DefaultApi @@ -14,18 +13,20 @@ from openapi_client.models import ( Eventmessage, EventmessageCreate, Machine, + Roles, ServiceCreate, Status, - Roles, ) +import config + random.seed(42) -#is linked to the emulate_fastapi.py and api.py -host = api.host -port_dlg = api.port_dlg -port_ap = api.port_ap -port_client_base = api.port_client_base + +host = config.host +port_dlg = config.port_dlg +port_ap = config.port_ap +port_client_base = config.port_client_base num_uuids = 100 uuids = [str(uuid.UUID(int=random.getrandbits(128))) for i in range(num_uuids)] @@ -44,7 +45,7 @@ def create_entities(num: int = 10) -> list[EntityCreate]: did=f"did:sov:test:12{i}", name=f"C{i}", ip=f"{host}:{port_client_base+i}", - network=f"255.255.0.0", + network="255.255.0.0", role=Roles("service_prosumer"), visible=True, other={}, @@ -52,9 +53,9 @@ def create_entities(num: int = 10) -> list[EntityCreate]: res.append(en) dlg = EntityCreate( did=f"did:sov:test:{port_dlg}", - name=f"DLG", + name="DLG", ip=f"{host}:{port_dlg}/health", - network=f"255.255.0.0", + network="255.255.0.0", role=Roles("DLG"), visible=True, other={}, @@ -62,9 +63,9 @@ def create_entities(num: int = 10) -> list[EntityCreate]: res.append(dlg) ap = EntityCreate( did=f"did:sov:test:{port_ap}", - name=f"AP", + name="AP", ip=f"{host}:{port_ap}/health", - network=f"255.255.0.0", + network="255.255.0.0", role=Roles("AP"), visible=True, other={}, @@ -168,4 +169,4 @@ def test_create_eventmessages(api_client: ApiClient) -> None: res: Eventmessage = api.create_eventmessage(own_eventmsg) # breakpoint() assert res.id == own_eventmsg.id - assert [] != api.get_all_eventmessages() \ No newline at end of file + assert [] != api.get_all_eventmessages() From 36492a14c9153632e9c5332caf0c6bef568beb71 Mon Sep 17 00:00:00 2001 From: Georg-Stahn Date: Thu, 11 Jan 2024 15:35:50 +0100 Subject: [PATCH 57/58] readme for --emulate flag --- README.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 89d5105..d506cd8 100644 --- a/README.md +++ b/README.md @@ -73,12 +73,11 @@ sudo echo "experimental-features = nix-command flakes" > '/etc/nix/nix.conf' - To start the backend server, execute: ```bash - clan webui --reload --no-open --log-level debug --populate + clan webui --reload --no-open --log-level debug --populate --emulate ``` - The server will automatically restart if any Python files change. - The `--populate` flag will automatically populate the database with dummy data - - - To emulate some distributed system behavior run `python3 tests/emulate_fastapi.py` + - The `--emulate` flag will automatically run servers the database with dummy data for the fronted to communicate with (ap, dlg, c1 and c2) 8. **Build the Frontend**: From 09fe544d909a07c05b9ee7f97c31ac69fdd14942 Mon Sep 17 00:00:00 2001 From: Georg-Stahn Date: Thu, 11 Jan 2024 15:45:32 +0100 Subject: [PATCH 58/58] dealte breakpoint :') --- pkgs/clan-cli/clan_cli/webui/server.py | 1 - 1 file changed, 1 deletion(-) diff --git a/pkgs/clan-cli/clan_cli/webui/server.py b/pkgs/clan-cli/clan_cli/webui/server.py index 932e1d6..7cd9165 100644 --- a/pkgs/clan-cli/clan_cli/webui/server.py +++ b/pkgs/clan-cli/clan_cli/webui/server.py @@ -141,7 +141,6 @@ def start_server(args: argparse.Namespace) -> None: urls = list() # start servers as processes (dlg, ap, c1 and c2 for tests) for app, port in app_ports: - breakpoint() proc = mp.Process( target=uvicorn.run, args=(app,),