network create request, remove old tfweb pending rewrite

This commit is contained in:
core 2023-12-16 21:14:12 -05:00
parent e4ab3769ba
commit 908e1b845c
Signed by: core
GPG Key ID: FDBF740DADDCEECF
270 changed files with 389 additions and 20171 deletions

1
Cargo.lock generated
View File

@ -3081,6 +3081,7 @@ dependencies = [
"actix-web",
"bb8",
"chacha20poly1305",
"chrono",
"diesel",
"diesel-async",
"diesel_migrations",

View File

@ -1,7 +1,7 @@
use bindgen::CargoCallbacks;
use std::path::Path;
use std::path::PathBuf;
use std::{env, process};
use bindgen::CargoCallbacks;
fn get_cargo_target_dir() -> Result<std::path::PathBuf, Box<dyn std::error::Error>> {
let skip_triple = std::env::var("TARGET")? == std::env::var("HOST")?;
@ -69,10 +69,7 @@ fn main() {
println!("Go compile success");
println!(
"cargo:rustc-link-search={}",
env::var("OUT_DIR").unwrap()
);
println!("cargo:rustc-link-search={}", env::var("OUT_DIR").unwrap());
if compile_config.link_type == "c-shared" {
copy_shared_lib(&compile_config);
@ -91,7 +88,12 @@ fn main() {
println!("Generating bindings");
let bindings = bindgen::Builder::default()
.header(out_path.join(compile_config.header_filename).display().to_string())
.header(
out_path
.join(compile_config.header_filename)
.display()
.to_string(),
)
.parse_callbacks(Box::new(CargoCallbacks::new()))
.generate()
.expect("Error generating CFFI bindings");
@ -130,31 +132,44 @@ struct GoCompileConfig {
goos: String,
link_type: String,
lib_filename: String,
header_filename: String
header_filename: String,
}
fn get_compile_config() -> GoCompileConfig {
let goarch = goarch();
let goos = goos();
let platform_value = format!("{}/{}", goos, goarch);
let (preferred_link_type, lib_filename, header_filename) = match (goos.as_str(), goarch.as_str()) {
("darwin", _) => ("c-archive", "libnebula.a", "libnebula.h"),
("windows", _) => ("c-archive", "libnebula.a", "libnebula.h"),
("linux", "386") | ("linux", "amd64") | ("linux", "arm") | ("linux", "armbe") | ("linux", "arm64") | ("linux", "arm64be") | ("linux", "loong64") | ("linux", "ppc64le") | ("linux", "riscv64") | ("linux", "s390x") => ("c-archive", "libnebula.a", "libnebula.h"),
("freebsd", "amd64") => ("c-archive", "libnebula.a", "libnebula.h"),
_ => panic!("unsupported platform {} / {}", env::var("TARGET").unwrap(), platform_value)
};
let (preferred_link_type, lib_filename, header_filename) =
match (goos.as_str(), goarch.as_str()) {
("darwin", _) => ("c-archive", "libnebula.a", "libnebula.h"),
("windows", _) => ("c-archive", "libnebula.a", "libnebula.h"),
("linux", "386")
| ("linux", "amd64")
| ("linux", "arm")
| ("linux", "armbe")
| ("linux", "arm64")
| ("linux", "arm64be")
| ("linux", "loong64")
| ("linux", "ppc64le")
| ("linux", "riscv64")
| ("linux", "s390x") => ("c-archive", "libnebula.a", "libnebula.h"),
("freebsd", "amd64") => ("c-archive", "libnebula.a", "libnebula.h"),
_ => panic!(
"unsupported platform {} / {}",
env::var("TARGET").unwrap(),
platform_value
),
};
GoCompileConfig {
goarch,
goos,
link_type: preferred_link_type.to_string(),
lib_filename: lib_filename.to_string(),
header_filename: header_filename.to_string()
header_filename: header_filename.to_string(),
}
}
fn goarch() -> String {
match env::var("CARGO_CFG_TARGET_ARCH").unwrap().as_str() {
"x86" => "386",
@ -182,4 +197,4 @@ fn goos() -> String {
os => panic!("unsupported operating system {os}"),
}
.to_string()
}
}

View File

@ -1,12 +1,12 @@
use crate::api::APIErrorResponse;
use crate::{HostCommands, HostOverrideCommands, TableStyle};
use comfy_table::modifiers::UTF8_ROUND_CORNERS;
use comfy_table::presets::UTF8_FULL;
use comfy_table::Table;
use serde::{Deserialize, Serialize};
use std::error::Error;
use std::fs;
use std::net::{Ipv4Addr, SocketAddrV4};
use comfy_table::modifiers::UTF8_ROUND_CORNERS;
use comfy_table::presets::UTF8_FULL;
use comfy_table::Table;
use url::Url;
pub async fn host_main(command: HostCommands, server: Url) -> Result<(), Box<dyn Error>> {
@ -172,18 +172,55 @@ pub async fn list_hosts(server: Url, table_style: TableStyle) -> Result<(), Box<
match table_style {
TableStyle::List => unreachable!(),
TableStyle::Basic => (),
TableStyle::Pretty => { table.load_preset(UTF8_FULL).apply_modifier(UTF8_ROUND_CORNERS) ; },
TableStyle::Pretty => {
table
.load_preset(UTF8_FULL)
.apply_modifier(UTF8_ROUND_CORNERS);
}
};
table.set_header(vec!["ID", "Name", "Organization ID", "Network ID", "Role ID", "IP Address", "Static Addresses", "Listen Port", "Type", "Blocked", "Last Seen"]);
table.set_header(vec![
"ID",
"Name",
"Organization ID",
"Network ID",
"Role ID",
"IP Address",
"Static Addresses",
"Listen Port",
"Type",
"Blocked",
"Last Seen",
]);
for host in &resp.data {
table.add_row(vec![host.id.as_str(), &host.name, &host.organization_id, &host.network_id, &host.role_id, &host.ip_address, &host.static_addresses.iter().map(|u| u.to_string()).collect::<Vec<_>>().join(" "), &host.listen_port.to_string(), if host.is_lighthouse { "Lighthouse" } else if host.is_relay { "Relay" } else { "Host" }, if host.is_blocked { "true" } else { "false" }, &host.metadata.last_seen_at]);
table.add_row(vec![
host.id.as_str(),
&host.name,
&host.organization_id,
&host.network_id,
&host.role_id,
&host.ip_address,
&host
.static_addresses
.iter()
.map(|u| u.to_string())
.collect::<Vec<_>>()
.join(" "),
&host.listen_port.to_string(),
if host.is_lighthouse {
"Lighthouse"
} else if host.is_relay {
"Relay"
} else {
"Host"
},
if host.is_blocked { "true" } else { "false" },
&host.metadata.last_seen_at,
]);
}
println!("{table}");
} else {
let resp: APIErrorResponse = res.json().await?;

View File

@ -1,15 +1,15 @@
use std::error::Error;
use std::fmt::{Display, Formatter};
use std::fs;
use std::net::{Ipv4Addr, SocketAddrV4};
use clap::{Parser, Subcommand, ValueEnum};
use ipnet::Ipv4Net;
use url::Url;
use crate::account::account_main;
use crate::host::host_main;
use crate::network::network_main;
use crate::org::org_main;
use crate::role::role_main;
use clap::{Parser, Subcommand, ValueEnum};
use ipnet::Ipv4Net;
use std::error::Error;
use std::fmt::{Display, Formatter};
use std::fs;
use std::net::{Ipv4Addr, SocketAddrV4};
use url::Url;
pub mod account;
pub mod api;
@ -96,7 +96,7 @@ pub enum NetworkCommands {
/// List all networks associated with your trifid account.
List {
#[clap(short = 'T', long, default_value_t = TableStyle::Basic)]
table_style: TableStyle
table_style: TableStyle,
},
/// Lookup a specific network by ID.
Lookup {
@ -129,7 +129,7 @@ pub enum RoleCommands {
/// List all roles attached to your organization
List {
#[clap(short = 'T', long, default_value_t = TableStyle::Basic)]
table_style: TableStyle
table_style: TableStyle,
},
/// Lookup a specific role by it's ID
Lookup {
@ -177,7 +177,7 @@ pub enum HostCommands {
/// List all hosts on your network
List {
#[clap(short = 'T', long, default_value_t = TableStyle::Basic)]
table_style: TableStyle
table_style: TableStyle,
},
/// Lookup a specific host by it's ID
Lookup {
@ -254,7 +254,7 @@ pub enum HostOverrideCommands {
pub enum TableStyle {
List,
Basic,
Pretty
Pretty,
}
impl Default for TableStyle {
fn default() -> Self {
@ -266,7 +266,7 @@ impl Display for TableStyle {
match self {
Self::List => write!(f, "list"),
Self::Basic => write!(f, "basic"),
Self::Pretty => write!(f, "pretty")
Self::Pretty => write!(f, "pretty"),
}
}
}

View File

@ -1,17 +1,17 @@
use std::error::Error;
use std::fs;
use crate::api::APIErrorResponse;
use crate::{NetworkCommands, TableStyle};
use comfy_table::modifiers::UTF8_ROUND_CORNERS;
use comfy_table::presets::UTF8_FULL;
use comfy_table::Table;
use serde::Deserialize;
use std::error::Error;
use std::fs;
use url::Url;
use crate::api::APIErrorResponse;
use crate::{NetworkCommands, TableStyle};
pub async fn network_main(command: NetworkCommands, server: Url) -> Result<(), Box<dyn Error>> {
match command {
NetworkCommands::List { table_style } => list_networks(server, table_style).await,
NetworkCommands::Lookup {id} => get_network(id, server).await
NetworkCommands::Lookup { id } => get_network(id, server).await,
}
}
@ -78,13 +78,33 @@ pub async fn list_networks(server: Url, table_style: TableStyle) -> Result<(), B
match table_style {
TableStyle::List => unreachable!(),
TableStyle::Basic => (),
TableStyle::Pretty => { table.load_preset(UTF8_FULL).apply_modifier(UTF8_ROUND_CORNERS) ; },
TableStyle::Pretty => {
table
.load_preset(UTF8_FULL)
.apply_modifier(UTF8_ROUND_CORNERS);
}
};
table.set_header(vec!["ID", "Name", "CIDR", "Organization ID", "Signing CA ID", "Dedicated Relays", "Created At"]);
table.set_header(vec![
"ID",
"Name",
"CIDR",
"Organization ID",
"Signing CA ID",
"Dedicated Relays",
"Created At",
]);
for network in &resp.data {
table.add_row(vec![&network.id, &network.name, &network.cidr, &network.organization_id, &network.signing_ca_id, (!network.lighthouses_as_relays).to_string().as_str(), &network.created_at]);
table.add_row(vec![
&network.id,
&network.name,
&network.cidr,
&network.organization_id,
&network.signing_ca_id,
(!network.lighthouses_as_relays).to_string().as_str(),
&network.created_at,
]);
}
println!("{table}");

View File

@ -1,18 +1,22 @@
use std::error::Error;
use std::fs;
use crate::api::APIErrorResponse;
use crate::{RoleCommands, TableStyle};
use comfy_table::modifiers::UTF8_ROUND_CORNERS;
use comfy_table::presets::UTF8_FULL;
use comfy_table::Table;
use serde::{Deserialize, Serialize};
use std::error::Error;
use std::fs;
use url::Url;
use crate::api::APIErrorResponse;
use crate::{RoleCommands, TableStyle};
pub async fn role_main(command: RoleCommands, server: Url) -> Result<(), Box<dyn Error>> {
match command {
RoleCommands::List { table_style } => list_roles(server, table_style).await,
RoleCommands::Lookup {id} => get_role(id, server).await,
RoleCommands::Create { name, description, rules_json } => create_role(name, description, rules_json, server).await,
RoleCommands::Lookup { id } => get_role(id, server).await,
RoleCommands::Create {
name,
description,
rules_json,
} => create_role(name, description, rules_json, server).await,
RoleCommands::Delete { id } => delete_role(id, server).await,
RoleCommands::Update {
id,
@ -85,9 +89,21 @@ pub async fn list_roles(server: Url, table_style: TableStyle) -> Result<(), Box<
println!(" Description: {}", role.description);
for rule in &role.firewall_rules {
println!("Rule Description: {}", rule.description);
println!(" Allowed Role: {}", rule.allowed_role_id.as_ref().unwrap_or(&"All roles".to_string()));
println!(
" Allowed Role: {}",
rule.allowed_role_id
.as_ref()
.unwrap_or(&"All roles".to_string())
);
println!(" Protocol: {}", rule.protocol);
println!(" Port Range: {}", if let Some(pr) = rule.port_range.as_ref() { format!("{}-{}", pr.from, pr.to) } else { "Any".to_string() });
println!(
" Port Range: {}",
if let Some(pr) = rule.port_range.as_ref() {
format!("{}-{}", pr.from, pr.to)
} else {
"Any".to_string()
}
);
}
println!(" Created: {}", role.created_at);
println!(" Updated: {}", role.modified_at);
@ -99,12 +115,30 @@ pub async fn list_roles(server: Url, table_style: TableStyle) -> Result<(), Box<
match table_style {
TableStyle::List => unreachable!(),
TableStyle::Basic => (),
TableStyle::Pretty => { table.load_preset(UTF8_FULL).apply_modifier(UTF8_ROUND_CORNERS); },
TableStyle::Pretty => {
table
.load_preset(UTF8_FULL)
.apply_modifier(UTF8_ROUND_CORNERS);
}
};
table.set_header(vec!["ID", "Name", "Description", "Rule Count", "Created", "Updated"]);
table.set_header(vec![
"ID",
"Name",
"Description",
"Rule Count",
"Created",
"Updated",
]);
for role in &resp.data {
table.add_row(vec![&role.id, &role.name, &role.description, role.firewall_rules.len().to_string().as_str(), &role.created_at, &role.modified_at]);
table.add_row(vec![
&role.id,
&role.name,
&role.description,
role.firewall_rules.len().to_string().as_str(),
&role.created_at,
&role.modified_at,
]);
}
println!("{table}");

View File

@ -1,13 +0,0 @@
.DS_Store
node_modules
/build
/.svelte-kit
/package
.env
.env.*
!.env.example
# Ignore files for PNPM, NPM and YARN
pnpm-lock.yaml
package-lock.json
yarn.lock

View File

@ -1,29 +0,0 @@
module.exports = {
root: true,
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:svelte/recommended'
],
parser: '@typescript-eslint/parser',
plugins: ['@typescript-eslint'],
parserOptions: {
sourceType: 'module',
ecmaVersion: 2020,
extraFileExtensions: ['.svelte']
},
env: {
browser: true,
es2017: true,
node: true
},
overrides: [
{
files: ['*.svelte'],
parser: 'svelte-eslint-parser',
parserOptions: {
parser: '@typescript-eslint/parser'
}
}
]
};

11
tfweb/.gitignore vendored
View File

@ -1,11 +0,0 @@
.DS_Store
node_modules
/build
/.svelte-kit
/package
.env
.env.*
!.env.example
vite.config.js.timestamp-*
vite.config.ts.timestamp-*
.idea

View File

@ -1,2 +0,0 @@
engine-strict=true
resolution-mode=highest

View File

@ -1,38 +0,0 @@
# create-svelte
Everything you need to build a Svelte project, powered by [`create-svelte`](https://github.com/sveltejs/kit/tree/master/packages/create-svelte).
## Creating a project
If you're seeing this, you've probably already done this step. Congrats!
```bash
# create a new project in the current directory
npm create svelte@latest
# create a new project in my-app
npm create svelte@latest my-app
```
## Developing
Once you've created a project and installed dependencies with `npm install` (or `pnpm install` or `yarn`), start a development server:
```bash
npm run dev
# or start the server and open the app in a new browser tab
npm run dev -- --open
```
## Building
To create a production version of your app:
```bash
npm run build
```
You can preview the production build with `npm run preview`.
> To deploy your app, you may need to install an [adapter](https://kit.svelte.dev/docs/adapters) for your target environment.

File diff suppressed because it is too large Load Diff

View File

@ -1,7 +0,0 @@
{
"$schema": "./node_modules/@openapitools/openapi-generator-cli/config.schema.json",
"spaces": 2,
"generator-cli": {
"version": "6.6.0"
}
}

View File

@ -1,37 +0,0 @@
{
"name": "tfweb",
"version": "0.0.1",
"private": true,
"scripts": {
"dev": "vite dev",
"build": "vite build",
"preview": "vite preview",
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
"lint": "eslint ."
},
"devDependencies": {
"@sveltejs/adapter-auto": "^2.0.0",
"@sveltejs/adapter-node": "^1.3.1",
"@sveltejs/kit": "^1.5.0",
"@typescript-eslint/eslint-plugin": "^5.45.0",
"@typescript-eslint/parser": "^5.45.0",
"eslint": "^8.28.0",
"eslint-plugin-svelte": "^2.26.0",
"svelte": "^3.54.0",
"svelte-check": "^3.0.1",
"tslib": "^2.4.1",
"typescript": "^5.0.0",
"vite": "^4.3.0"
},
"type": "module",
"dependencies": {
"@fortawesome/fontawesome-free": "^6.4.2",
"@popperjs/core": "^2.11.8",
"@types/qrcode": "^1.5.0",
"bootstrap": "^5.3.2",
"bootswatch": "^5.3.2",
"qrcode": "^1.5.3",
"sveltekit-i18n": "^2.4.2"
}
}

12
tfweb/src/app.d.ts vendored
View File

@ -1,12 +0,0 @@
// See https://kit.svelte.dev/docs/types#app
// for information about these interfaces
declare global {
namespace App {
// interface Error {}
// interface Locals {}
// interface PageData {}
// interface Platform {}
}
}
export {};

View File

@ -1,12 +0,0 @@
<!DOCTYPE html>
<html lang="en" style="height: 100%;">
<head>
<meta charset="utf-8" />
<link rel="icon" href="%sveltekit.assets%/favicon.png" />
<meta name="viewport" content="width=device-width" />
%sveltekit.head%
</head>
<body data-sveltekit-preload-data="hover" style="height: 100%;">
%sveltekit.body%
</body>
</html>

View File

@ -1,16 +0,0 @@
<script lang="ts">
import Sidebar from "$components/Sidebar.svelte";
export let selected;
</script>
<div class="container-fluid g-0">
<div class="row">
<div class="col-sm-3 col-md-3 col-lg-3 col-xl-2">
<Sidebar bind:selected={selected} />
</div>
<div class="col me-3 mt-2">
<slot></slot>
</div>
</div>
</div>

View File

@ -1,42 +0,0 @@
<script lang="ts">
import {logDeltaReset, Logger, logSetup} from "$lib/logger";
import {t} from "$lib/i18n/translations";
export let isLoading;
export let isError;
export let error;
logSetup();
let logger = new Logger("LoadingWrapper.svelte");
function loadingproclog() {
if (!isLoading) {
logger.info("page loaded - content paint");
logDeltaReset();
}
}
$: isLoading, loadingproclog();
</script>
{#if isLoading}
<div class="h-100 d-flex align-items-center justify-content-center">
<div class="card">
<div class="card-body text-center">
<h4 class="card-title mb-0">{$t("common.loading")} <i class="fas fa-gear fa-spin"></i></h4>
</div>
</div>
</div>
{:else}
{#if isError}
<div class="h-100 d-flex align-items-center justify-content-center">
<div class="card w-25">
<div class="card-body text-center">
<h4 class="card-title mb-0 text-danger">{error}</h4>
</div>
</div>
</div>
{:else}
<slot></slot>
{/if}
{/if}

View File

@ -1,35 +0,0 @@
<script lang="ts">
import {Logger, logSetup} from "$lib/logger";
import QRCode from "qrcode";
import {onMount} from "svelte";
export let value;
let canvas;
logSetup();
let logger = new Logger("QrCode.svelte");
function updateQrCode() {
if (canvas === undefined) {
logger.warn(`component has not yet mounted, delaying 500ms and trying again`);
setTimeout(() => {
updateQrCode();
}, 500);
return;
}
logger.info(`updating qrcode to ${value}`);
QRCode.toCanvas(canvas, value, (err) => {
if (err) {
logger.error(`error updating qrcode: ${err}`);
} else {
logger.info(`qrcode updated successfully`);
}
})
}
$: value, updateQrCode();
</script>
<canvas bind:this={canvas} id="canvas"></canvas>

View File

@ -1,48 +0,0 @@
<script lang="ts">
import {t} from "$lib/i18n/translations";
export let selected;
</script>
<div class="sticky-top d-flex flex-column flex-shrink-0 p-3 vh-100 bg-dark">
<p class="d-flex align-items-center mb-3 mb-md-0 me-md-auto text-white text-decoration-none ml-5 fs-4">
<i class="fas fa-satellite fa-fw bi me-2"></i>
Trifid
</p>
<hr>
<ul class="nav nav-pills flex-column mb-auto">
<li class="nav-item">
<a class="nav-link py-2 px-4" class:active={selected === 'hosts'} href="/hosts">
<i class="bi me-2 fas fa-computer fa-fw"></i>
{$t("common.page.hosts")}
</a>
</li>
<li class="nav-item">
<a class="nav-link py-2 px-4" class:active={selected === 'lighthouses'} href="/lighthouses">
<i class="bi me-2 fas fa-server fa-fw"></i>
{$t("common.page.lighthouses")}
</a>
</li>
<li class="nav-item">
<a class="nav-link py-2 px-4" class:active={selected === 'relays'} href="/relays">
<i class="bi me-2 fas fa-network-wired fa=fw"></i>
{$t("common.page.relays")}
</a>
</li>
<li class="nav-item">
<a class="nav-link py-2 px-4" class:active={selected === 'roles'} href="/roles">
<i class="bi me-2 fas fa-address-book fa-fw"></i>
{$t("common.page.roles")}
</a>
</li>
</ul>
<hr>
<div class="nav-item">
<button class="nav-link py-2 px-4" on:click={() => {window.localStorage.setItem("mfa", ""); window.location.href = "/2fa"}}>
<i class="me-2 fas fa-right-from-bracket fa-fw"></i>
{$t("common.logout")}
</button>
</div>
</div>

View File

@ -1,11 +0,0 @@
import { writable } from "svelte/store";
import { browser } from "$app/environment";
export function persist(name, def_val = "") {
const store = writable(browser && localStorage.getItem(name) || def_val);
store.subscribe((value) => {
if (browser)
return (localStorage.setItem(name, value));
});
return store;
}
//# sourceMappingURL=PersistentStore.js.map

View File

@ -1 +0,0 @@
{"version":3,"file":"PersistentStore.js","sourceRoot":"","sources":["PersistentStore.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,QAAQ,EAAC,MAAM,cAAc,CAAC;AACtC,OAAO,EAAC,OAAO,EAAC,MAAM,kBAAkB,CAAC;AAEzC,MAAM,UAAU,OAAO,CAAC,IAAY,EAAE,OAAO,GAAG,EAAE;IAC9C,MAAM,KAAK,GAAG,QAAQ,CAAC,OAAO,IAAI,YAAY,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,OAAO,CAAC,CAAC;IACzE,KAAK,CAAC,SAAS,CAAC,CAAC,KAAU,EAAE,EAAE;QAC3B,IAAI,OAAO;YAAE,OAAO,CAAC,YAAY,CAAC,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC;IAC5D,CAAC,CAAC,CAAC;IACH,OAAO,KAAK,CAAC;AACjB,CAAC"}

View File

@ -1,11 +0,0 @@
import type { Writable } from "svelte/store";
import {writable} from "svelte/store";
import {browser} from "$app/environment";
export function persist(name: string, def_val = ""): Writable<any> {
const store = writable(browser && localStorage.getItem(name) || def_val);
store.subscribe((value: any) => {
if (browser) return (localStorage.setItem(name, value));
});
return store;
}

View File

@ -1,17 +0,0 @@
import {browser} from "$app/environment";
export function updateTooltips() {
if (browser) {
setTimeout(() => {
const tooltipTriggerList = document.querySelectorAll('[data-bs-toggle="tooltip"]')
const tooltipList = [...tooltipTriggerList].map(tooltipTriggerEl => {
let tooltip = new document.B.Tooltip(tooltipTriggerEl, {trigger: 'hover'})
tooltipTriggerEl.addEventListener('click', () => {
tooltip.hide();
tooltip.dispose();
})
});
console.log(tooltipList);
});
}
}

View File

@ -1,23 +0,0 @@
# OpenAPI Generator Ignore
# Generated by openapi-generator https://github.com/openapitools/openapi-generator
# Use this file to prevent files from being overwritten by the generator.
# The patterns follow closely to .gitignore or .dockerignore.
# As an example, the C# client generator defines ApiClient.cs.
# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line:
#ApiClient.cs
# You can match any string of characters against a directory, file or extension with a single asterisk (*):
#foo/*/qux
# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux
# You can recursively match patterns against a directory, file or extension with a double asterisk (**):
#foo/**/qux
# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux
# You can also negate patterns with an exclamation (!).
# For example, you can ignore all files in a docs folder with the file extension .md:
#docs/*.md
# Then explicitly reverse the ignore rule for a single file:
#!docs/README.md

View File

@ -1,61 +0,0 @@
.openapi-generator-ignore
apis/AuditLogsApi.ts
apis/DownloadsApi.ts
apis/HostsApi.ts
apis/NetworksApi.ts
apis/RolesApi.ts
apis/index.ts
index.ts
models/Actor.ts
models/ActorAPIKey.ts
models/ActorHost.ts
models/ActorOIDCUser.ts
models/ActorSupport.ts
models/ActorSystem.ts
models/ActorUser.ts
models/AuditLog.ts
models/AuditLogsList200Response.ts
models/Downloads.ts
models/DownloadsDNClientLinks.ts
models/DownloadsDnclient.ts
models/DownloadsList200Response.ts
models/DownloadsMobile.ts
models/DownloadsVersionInfo.ts
models/DownloadsVersionInfoDnclientValue.ts
models/DownloadsVersionInfoLatest.ts
models/Event.ts
models/FirewallRule.ts
models/FirewallRulePortRange.ts
models/Host.ts
models/HostAndEnrollCodeCreate200Response.ts
models/HostAndEnrollCodeCreate200ResponseData.ts
models/HostAndEnrollCodeCreate200ResponseDataEnrollmentCode.ts
models/HostAndEnrollCodeCreate400Response.ts
models/HostBlock200Response.ts
models/HostBlock200ResponseData.ts
models/HostCreate200Response.ts
models/HostCreate400Response.ts
models/HostCreateRequest.ts
models/HostDelete200Response.ts
models/HostEdit200Response.ts
models/HostEditRequest.ts
models/HostEnrollCodeCreate200Response.ts
models/HostEnrollCodeCreate200ResponseData.ts
models/HostEnrollCodeCreate200ResponseDataEnrollmentCode.ts
models/HostGet200Response.ts
models/HostMetadata.ts
models/HostsList200Response.ts
models/ModelError.ts
models/Network.ts
models/NetworkGet200Response.ts
models/NetworksList200Response.ts
models/PaginationMetadata.ts
models/PaginationMetadataPage.ts
models/Role.ts
models/RoleCreate200Response.ts
models/RoleCreateRequest.ts
models/RoleEditRequest.ts
models/RolesList200Response.ts
models/Target.ts
models/index.ts
runtime.ts

View File

@ -1 +0,0 @@
6.6.0

View File

@ -1,78 +0,0 @@
/* tslint:disable */
/* eslint-disable */
/**
* Defined Networking API
* <br/> <br/> This API enables automated administration of Defined Networking hosts, roles, logs, and more. To authenticate, obtain an api key to use as a bearer token from your Defined Networking admin panel [API Keys page](https://admin.defined.net/settings/api-keys). API keys must be given the appropriate permission scopes for every method and endpoint, as specified throughout this documentation. Please [contact us](https://www.defined.net/contact?reason=support) for any questions or issues. In the event of a token leak, please take care to [rotate the key](/guides/rotating-api-keys). <div className=\'introduction-end\'></div>
*
* The version of the OpenAPI document: 1.0.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
import * as runtime from '../runtime';
import { AuditLogsList200ResponseFromJSON, AuditLogsList200ResponseToJSON, } from '../models';
/**
*
*/
export class AuditLogsApi extends runtime.BaseAPI {
/**
* Get a paginated list of audit logs. Token scope required: `audit-logs:list` ### Request
* List audit logs
*/
async auditLogsListRaw(requestParameters, initOverrides) {
const queryParameters = {};
if (requestParameters.includeCounts !== undefined) {
queryParameters['includeCounts'] = requestParameters.includeCounts;
}
if (requestParameters.cursor !== undefined) {
queryParameters['cursor'] = requestParameters.cursor;
}
if (requestParameters.pageSize !== undefined) {
queryParameters['pageSize'] = requestParameters.pageSize;
}
if (requestParameters.filterTargetID !== undefined) {
queryParameters['filter.targetID'] = requestParameters.filterTargetID;
}
if (requestParameters.filterTargetType !== undefined) {
queryParameters['filter.targetType'] = requestParameters.filterTargetType;
}
const headerParameters = {};
if (this.configuration && this.configuration.accessToken) {
const token = this.configuration.accessToken;
const tokenString = await token("ApiToken", []);
if (tokenString) {
headerParameters["Authorization"] = `Bearer ${tokenString}`;
}
}
const response = await this.request({
path: `/v1/audit-logs`,
method: 'GET',
headers: headerParameters,
query: queryParameters,
}, initOverrides);
return new runtime.JSONApiResponse(response, (jsonValue) => AuditLogsList200ResponseFromJSON(jsonValue));
}
/**
* Get a paginated list of audit logs. Token scope required: `audit-logs:list` ### Request
* List audit logs
*/
async auditLogsList(requestParameters = {}, initOverrides) {
const response = await this.auditLogsListRaw(requestParameters, initOverrides);
return await response.value();
}
}
/**
* @export
*/
export const AuditLogsListFilterTargetTypeEnum = {
ApiKey: 'apiKey',
Host: 'host',
Network: 'network',
Role: 'role',
User: 'user',
Ca: 'ca',
OidcProvider: 'oidcProvider'
};
//# sourceMappingURL=AuditLogsApi.js.map

View File

@ -1 +0,0 @@
{"version":3,"file":"AuditLogsApi.js","sourceRoot":"","sources":["AuditLogsApi.ts"],"names":[],"mappings":"AAAA,oBAAoB;AACpB,oBAAoB;AACpB;;;;;;;;;;GAUG;AAGH,OAAO,KAAK,OAAO,MAAM,YAAY,CAAC;AAItC,OAAO,EACH,gCAAgC,EAChC,8BAA8B,GACjC,MAAM,WAAW,CAAC;AAUnB;;GAEG;AACH,MAAM,OAAO,YAAa,SAAQ,OAAO,CAAC,OAAO;IAE7C;;;OAGG;IACH,KAAK,CAAC,gBAAgB,CAAC,iBAAuC,EAAE,aAA0D;QACtH,MAAM,eAAe,GAAQ,EAAE,CAAC;QAEhC,IAAI,iBAAiB,CAAC,aAAa,KAAK,SAAS,EAAE;YAC/C,eAAe,CAAC,eAAe,CAAC,GAAG,iBAAiB,CAAC,aAAa,CAAC;SACtE;QAED,IAAI,iBAAiB,CAAC,MAAM,KAAK,SAAS,EAAE;YACxC,eAAe,CAAC,QAAQ,CAAC,GAAG,iBAAiB,CAAC,MAAM,CAAC;SACxD;QAED,IAAI,iBAAiB,CAAC,QAAQ,KAAK,SAAS,EAAE;YAC1C,eAAe,CAAC,UAAU,CAAC,GAAG,iBAAiB,CAAC,QAAQ,CAAC;SAC5D;QAED,IAAI,iBAAiB,CAAC,cAAc,KAAK,SAAS,EAAE;YAChD,eAAe,CAAC,iBAAiB,CAAC,GAAG,iBAAiB,CAAC,cAAc,CAAC;SACzE;QAED,IAAI,iBAAiB,CAAC,gBAAgB,KAAK,SAAS,EAAE;YAClD,eAAe,CAAC,mBAAmB,CAAC,GAAG,iBAAiB,CAAC,gBAAgB,CAAC;SAC7E;QAED,MAAM,gBAAgB,GAAwB,EAAE,CAAC;QAEjD,IAAI,IAAI,CAAC,aAAa,IAAI,IAAI,CAAC,aAAa,CAAC,WAAW,EAAE;YACtD,MAAM,KAAK,GAAG,IAAI,CAAC,aAAa,CAAC,WAAW,CAAC;YAC7C,MAAM,WAAW,GAAG,MAAM,KAAK,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC;YAEhD,IAAI,WAAW,EAAE;gBACb,gBAAgB,CAAC,eAAe,CAAC,GAAG,UAAU,WAAW,EAAE,CAAC;aAC/D;SACJ;QACD,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC;YAChC,IAAI,EAAE,gBAAgB;YACtB,MAAM,EAAE,KAAK;YACb,OAAO,EAAE,gBAAgB;YACzB,KAAK,EAAE,eAAe;SACzB,EAAE,aAAa,CAAC,CAAC;QAElB,OAAO,IAAI,OAAO,CAAC,eAAe,CAAC,QAAQ,EAAE,CAAC,SAAS,EAAE,EAAE,CAAC,gCAAgC,CAAC,SAAS,CAAC,CAAC,CAAC;IAC7G,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,aAAa,CAAC,oBAA0C,EAAE,EAAE,aAA0D;QACxH,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,gBAAgB,CAAC,iBAAiB,EAAE,aAAa,CAAC,CAAC;QAC/E,OAAO,MAAM,QAAQ,CAAC,KAAK,EAAE,CAAC;IAClC,CAAC;CAEJ;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,iCAAiC,GAAG;IAC7C,MAAM,EAAE,QAAQ;IAChB,IAAI,EAAE,MAAM;IACZ,OAAO,EAAE,SAAS;IAClB,IAAI,EAAE,MAAM;IACZ,IAAI,EAAE,MAAM;IACZ,EAAE,EAAE,IAAI;IACR,YAAY,EAAE,cAAc;CACtB,CAAC"}

View File

@ -1,108 +0,0 @@
/* tslint:disable */
/* eslint-disable */
/**
* Defined Networking API
* <br/> <br/> This API enables automated administration of Defined Networking hosts, roles, logs, and more. To authenticate, obtain an api key to use as a bearer token from your Defined Networking admin panel [API Keys page](https://admin.defined.net/settings/api-keys). API keys must be given the appropriate permission scopes for every method and endpoint, as specified throughout this documentation. Please [contact us](https://www.defined.net/contact?reason=support) for any questions or issues. In the event of a token leak, please take care to [rotate the key](/guides/rotating-api-keys). <div className=\'introduction-end\'></div>
*
* The version of the OpenAPI document: 1.0.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
import * as runtime from '../runtime';
import type {
AuditLogsList200Response,
} from '../models';
import {
AuditLogsList200ResponseFromJSON,
AuditLogsList200ResponseToJSON,
} from '../models';
export interface AuditLogsListRequest {
includeCounts?: boolean;
cursor?: string;
pageSize?: number;
filterTargetID?: string;
filterTargetType?: AuditLogsListFilterTargetTypeEnum;
}
/**
*
*/
export class AuditLogsApi extends runtime.BaseAPI {
/**
* Get a paginated list of audit logs. Token scope required: `audit-logs:list` ### Request
* List audit logs
*/
async auditLogsListRaw(requestParameters: AuditLogsListRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<AuditLogsList200Response>> {
const queryParameters: any = {};
if (requestParameters.includeCounts !== undefined) {
queryParameters['includeCounts'] = requestParameters.includeCounts;
}
if (requestParameters.cursor !== undefined) {
queryParameters['cursor'] = requestParameters.cursor;
}
if (requestParameters.pageSize !== undefined) {
queryParameters['pageSize'] = requestParameters.pageSize;
}
if (requestParameters.filterTargetID !== undefined) {
queryParameters['filter.targetID'] = requestParameters.filterTargetID;
}
if (requestParameters.filterTargetType !== undefined) {
queryParameters['filter.targetType'] = requestParameters.filterTargetType;
}
const headerParameters: runtime.HTTPHeaders = {};
if (this.configuration && this.configuration.accessToken) {
const token = this.configuration.accessToken;
const tokenString = await token("ApiToken", []);
if (tokenString) {
headerParameters["Authorization"] = `Bearer ${tokenString}`;
}
}
const response = await this.request({
path: `/v1/audit-logs`,
method: 'GET',
headers: headerParameters,
query: queryParameters,
}, initOverrides);
return new runtime.JSONApiResponse(response, (jsonValue) => AuditLogsList200ResponseFromJSON(jsonValue));
}
/**
* Get a paginated list of audit logs. Token scope required: `audit-logs:list` ### Request
* List audit logs
*/
async auditLogsList(requestParameters: AuditLogsListRequest = {}, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<AuditLogsList200Response> {
const response = await this.auditLogsListRaw(requestParameters, initOverrides);
return await response.value();
}
}
/**
* @export
*/
export const AuditLogsListFilterTargetTypeEnum = {
ApiKey: 'apiKey',
Host: 'host',
Network: 'network',
Role: 'role',
User: 'user',
Ca: 'ca',
OidcProvider: 'oidcProvider'
} as const;
export type AuditLogsListFilterTargetTypeEnum = typeof AuditLogsListFilterTargetTypeEnum[keyof typeof AuditLogsListFilterTargetTypeEnum];

View File

@ -1,51 +0,0 @@
/* tslint:disable */
/* eslint-disable */
/**
* Defined Networking API
* <br/> <br/> This API enables automated administration of Defined Networking hosts, roles, logs, and more. To authenticate, obtain an api key to use as a bearer token from your Defined Networking admin panel [API Keys page](https://admin.defined.net/settings/api-keys). API keys must be given the appropriate permission scopes for every method and endpoint, as specified throughout this documentation. Please [contact us](https://www.defined.net/contact?reason=support) for any questions or issues. In the event of a token leak, please take care to [rotate the key](/guides/rotating-api-keys). <div className=\'introduction-end\'></div>
*
* The version of the OpenAPI document: 1.0.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
import * as runtime from '../runtime';
import { DownloadsList200ResponseFromJSON, DownloadsList200ResponseToJSON, } from '../models';
/**
*
*/
export class DownloadsApi extends runtime.BaseAPI {
/**
* Get a list of recently released software download links and basic info. This endpoint is unauthenticated. ### Request
* List software downloads
*/
async downloadsListRaw(initOverrides) {
const queryParameters = {};
const headerParameters = {};
if (this.configuration && this.configuration.accessToken) {
const token = this.configuration.accessToken;
const tokenString = await token("ApiToken", []);
if (tokenString) {
headerParameters["Authorization"] = `Bearer ${tokenString}`;
}
}
const response = await this.request({
path: `/v1/downloads`,
method: 'GET',
headers: headerParameters,
query: queryParameters,
}, initOverrides);
return new runtime.JSONApiResponse(response, (jsonValue) => DownloadsList200ResponseFromJSON(jsonValue));
}
/**
* Get a list of recently released software download links and basic info. This endpoint is unauthenticated. ### Request
* List software downloads
*/
async downloadsList(initOverrides) {
const response = await this.downloadsListRaw(initOverrides);
return await response.value();
}
}
//# sourceMappingURL=DownloadsApi.js.map

View File

@ -1 +0,0 @@
{"version":3,"file":"DownloadsApi.js","sourceRoot":"","sources":["DownloadsApi.ts"],"names":[],"mappings":"AAAA,oBAAoB;AACpB,oBAAoB;AACpB;;;;;;;;;;GAUG;AAGH,OAAO,KAAK,OAAO,MAAM,YAAY,CAAC;AAItC,OAAO,EACH,gCAAgC,EAChC,8BAA8B,GACjC,MAAM,WAAW,CAAC;AAEnB;;GAEG;AACH,MAAM,OAAO,YAAa,SAAQ,OAAO,CAAC,OAAO;IAE7C;;;OAGG;IACH,KAAK,CAAC,gBAAgB,CAAC,aAA0D;QAC7E,MAAM,eAAe,GAAQ,EAAE,CAAC;QAEhC,MAAM,gBAAgB,GAAwB,EAAE,CAAC;QAEjD,IAAI,IAAI,CAAC,aAAa,IAAI,IAAI,CAAC,aAAa,CAAC,WAAW,EAAE;YACtD,MAAM,KAAK,GAAG,IAAI,CAAC,aAAa,CAAC,WAAW,CAAC;YAC7C,MAAM,WAAW,GAAG,MAAM,KAAK,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC;YAEhD,IAAI,WAAW,EAAE;gBACb,gBAAgB,CAAC,eAAe,CAAC,GAAG,UAAU,WAAW,EAAE,CAAC;aAC/D;SACJ;QACD,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC;YAChC,IAAI,EAAE,eAAe;YACrB,MAAM,EAAE,KAAK;YACb,OAAO,EAAE,gBAAgB;YACzB,KAAK,EAAE,eAAe;SACzB,EAAE,aAAa,CAAC,CAAC;QAElB,OAAO,IAAI,OAAO,CAAC,eAAe,CAAC,QAAQ,EAAE,CAAC,SAAS,EAAE,EAAE,CAAC,gCAAgC,CAAC,SAAS,CAAC,CAAC,CAAC;IAC7G,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,aAAa,CAAC,aAA0D;QAC1E,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,gBAAgB,CAAC,aAAa,CAAC,CAAC;QAC5D,OAAO,MAAM,QAAQ,CAAC,KAAK,EAAE,CAAC;IAClC,CAAC;CAEJ"}

View File

@ -1,66 +0,0 @@
/* tslint:disable */
/* eslint-disable */
/**
* Defined Networking API
* <br/> <br/> This API enables automated administration of Defined Networking hosts, roles, logs, and more. To authenticate, obtain an api key to use as a bearer token from your Defined Networking admin panel [API Keys page](https://admin.defined.net/settings/api-keys). API keys must be given the appropriate permission scopes for every method and endpoint, as specified throughout this documentation. Please [contact us](https://www.defined.net/contact?reason=support) for any questions or issues. In the event of a token leak, please take care to [rotate the key](/guides/rotating-api-keys). <div className=\'introduction-end\'></div>
*
* The version of the OpenAPI document: 1.0.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
import * as runtime from '../runtime';
import type {
DownloadsList200Response,
} from '../models';
import {
DownloadsList200ResponseFromJSON,
DownloadsList200ResponseToJSON,
} from '../models';
/**
*
*/
export class DownloadsApi extends runtime.BaseAPI {
/**
* Get a list of recently released software download links and basic info. This endpoint is unauthenticated. ### Request
* List software downloads
*/
async downloadsListRaw(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<DownloadsList200Response>> {
const queryParameters: any = {};
const headerParameters: runtime.HTTPHeaders = {};
if (this.configuration && this.configuration.accessToken) {
const token = this.configuration.accessToken;
const tokenString = await token("ApiToken", []);
if (tokenString) {
headerParameters["Authorization"] = `Bearer ${tokenString}`;
}
}
const response = await this.request({
path: `/v1/downloads`,
method: 'GET',
headers: headerParameters,
query: queryParameters,
}, initOverrides);
return new runtime.JSONApiResponse(response, (jsonValue) => DownloadsList200ResponseFromJSON(jsonValue));
}
/**
* Get a list of recently released software download links and basic info. This endpoint is unauthenticated. ### Request
* List software downloads
*/
async downloadsList(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<DownloadsList200Response> {
const response = await this.downloadsListRaw(initOverrides);
return await response.value();
}
}

View File

@ -1,332 +0,0 @@
/* tslint:disable */
/* eslint-disable */
/**
* Defined Networking API
* <br/> <br/> This API enables automated administration of Defined Networking hosts, roles, logs, and more. To authenticate, obtain an api key to use as a bearer token from your Defined Networking admin panel [API Keys page](https://admin.defined.net/settings/api-keys). API keys must be given the appropriate permission scopes for every method and endpoint, as specified throughout this documentation. Please [contact us](https://www.defined.net/contact?reason=support) for any questions or issues. In the event of a token leak, please take care to [rotate the key](/guides/rotating-api-keys). <div className=\'introduction-end\'></div>
*
* The version of the OpenAPI document: 1.0.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
import * as runtime from '../runtime';
import { HostAndEnrollCodeCreate200ResponseFromJSON, HostAndEnrollCodeCreate200ResponseToJSON, HostAndEnrollCodeCreate400ResponseFromJSON, HostAndEnrollCodeCreate400ResponseToJSON, HostBlock200ResponseFromJSON, HostBlock200ResponseToJSON, HostCreate200ResponseFromJSON, HostCreate200ResponseToJSON, HostCreate400ResponseFromJSON, HostCreate400ResponseToJSON, HostCreateRequestFromJSON, HostCreateRequestToJSON, HostDelete200ResponseFromJSON, HostDelete200ResponseToJSON, HostEdit200ResponseFromJSON, HostEdit200ResponseToJSON, HostEditRequestFromJSON, HostEditRequestToJSON, HostEnrollCodeCreate200ResponseFromJSON, HostEnrollCodeCreate200ResponseToJSON, HostGet200ResponseFromJSON, HostGet200ResponseToJSON, HostsList200ResponseFromJSON, HostsList200ResponseToJSON, } from '../models';
/**
*
*/
export class HostsApi extends runtime.BaseAPI {
/**
* Token scopes required: `hosts:create`, `hosts:enroll` ### Request
* Create host & enrollment code
*/
async hostAndEnrollCodeCreateRaw(requestParameters, initOverrides) {
if (requestParameters.hostCreateRequest === null || requestParameters.hostCreateRequest === undefined) {
throw new runtime.RequiredError('hostCreateRequest', 'Required parameter requestParameters.hostCreateRequest was null or undefined when calling hostAndEnrollCodeCreate.');
}
const queryParameters = {};
const headerParameters = {};
headerParameters['Content-Type'] = 'application/json';
if (this.configuration && this.configuration.accessToken) {
const token = this.configuration.accessToken;
const tokenString = await token("ApiToken", []);
if (tokenString) {
headerParameters["Authorization"] = `Bearer ${tokenString}`;
}
}
const response = await this.request({
path: `/v1/host-and-enrollment-code`,
method: 'POST',
headers: headerParameters,
query: queryParameters,
body: HostCreateRequestToJSON(requestParameters.hostCreateRequest),
}, initOverrides);
return new runtime.JSONApiResponse(response, (jsonValue) => HostAndEnrollCodeCreate200ResponseFromJSON(jsonValue));
}
/**
* Token scopes required: `hosts:create`, `hosts:enroll` ### Request
* Create host & enrollment code
*/
async hostAndEnrollCodeCreate(requestParameters, initOverrides) {
const response = await this.hostAndEnrollCodeCreateRaw(requestParameters, initOverrides);
return await response.value();
}
/**
* Prevent a host from being able to interact with other nodes on your network. See https://www.defined.net/blog/blocklisting/ for more details. To unblock, re-enroll the host. Token scope required: `hosts:block` ### Request
* Block host
*/
async hostBlockRaw(requestParameters, initOverrides) {
if (requestParameters.hostID === null || requestParameters.hostID === undefined) {
throw new runtime.RequiredError('hostID', 'Required parameter requestParameters.hostID was null or undefined when calling hostBlock.');
}
const queryParameters = {};
const headerParameters = {};
if (this.configuration && this.configuration.accessToken) {
const token = this.configuration.accessToken;
const tokenString = await token("ApiToken", []);
if (tokenString) {
headerParameters["Authorization"] = `Bearer ${tokenString}`;
}
}
const response = await this.request({
path: `/v1/hosts/{hostID}/block`.replace(`{${"hostID"}}`, encodeURIComponent(String(requestParameters.hostID))),
method: 'POST',
headers: headerParameters,
query: queryParameters,
}, initOverrides);
return new runtime.JSONApiResponse(response, (jsonValue) => HostBlock200ResponseFromJSON(jsonValue));
}
/**
* Prevent a host from being able to interact with other nodes on your network. See https://www.defined.net/blog/blocklisting/ for more details. To unblock, re-enroll the host. Token scope required: `hosts:block` ### Request
* Block host
*/
async hostBlock(requestParameters, initOverrides) {
const response = await this.hostBlockRaw(requestParameters, initOverrides);
return await response.value();
}
/**
* Create a new host, lighthouse, or relay. Token scope required: `hosts:create` ### Request
* Create host
*/
async hostCreateRaw(requestParameters, initOverrides) {
if (requestParameters.hostCreateRequest === null || requestParameters.hostCreateRequest === undefined) {
throw new runtime.RequiredError('hostCreateRequest', 'Required parameter requestParameters.hostCreateRequest was null or undefined when calling hostCreate.');
}
const queryParameters = {};
const headerParameters = {};
headerParameters['Content-Type'] = 'application/json';
if (this.configuration && this.configuration.accessToken) {
const token = this.configuration.accessToken;
const tokenString = await token("ApiToken", []);