diff --git a/Dockerfile.snap b/Dockerfile.snap new file mode 100644 index 000000000000..a3991a811df9 --- /dev/null +++ b/Dockerfile.snap @@ -0,0 +1,79 @@ +# Note to maintainers: after you make changes to this file, please run `make snap_image`. +# The script will gives instructions to complete the update once it finishes. Be patient, it +# takes a long time to run. +# +# For help with the technical aspects of this Dockerfile, see +# https://snapcraft.io/docs/t/creating-docker-images-for-snapcraft/11739 +# https://raw.githubusercontent.com/snapcore/snapcraft/master/docker/stable.Dockerfile +# and https://forum.snapcraft.io/. Note that the snapcraft forum does not appear to be indexed +# effectively (at all?) by google. +# +# See https://docs.docker.com/develop/develop-images/dockerfile_best-practices/ +# for guidance on the style of this Dockerfile +FROM ubuntu:focal as builder + +RUN apt-get update && apt-get install --yes \ + curl \ + jq \ + squashfs-tools + +# Grab the core snap (for backwards compatibility) from the stable channel and unpack it in the proper place +RUN curl -L $(curl -H 'X-Ubuntu-Series: 16' 'https://api.snapcraft.io/api/v1/snaps/details/core' | jq '.download_url' -r) --output core.snap && \ + mkdir -p /snap/core && \ + unsquashfs -d /snap/core/current core.snap + +# Grab the core18 snap (which snapcraft uses as a base) from the stable channel and unpack it in the proper place. +RUN curl -L $(curl -H 'X-Ubuntu-Series: 16' 'https://api.snapcraft.io/api/v1/snaps/details/core18' | jq '.download_url' -r) --output core18.snap && \ + mkdir -p /snap/core18 && \ + unsquashfs -d /snap/core18/current core18.snap + +# Grab the core20 snap from the stable channel and unpack it in the proper place. +RUN curl -L $(curl -H 'X-Ubuntu-Series: 16' 'https://api.snapcraft.io/api/v1/snaps/details/core20' | jq '.download_url' -r) --output core20.snap && \ + mkdir -p /snap/core20 && \ + unsquashfs -d /snap/core20/current core20.snap + +# Grab the snapcraft snap from the stable channel and unpack it in the proper place +RUN curl -L $(curl -H 'X-Ubuntu-Series: 16' 'https://api.snapcraft.io/api/v1/snaps/details/snapcraft?channel=stable' | jq '.download_url' -r) --output snapcraft.snap && \ + mkdir -p /snap/snapcraft && \ + unsquashfs -d /snap/snapcraft/current snapcraft.snap + +# Create a snapcraft runner (TODO: move version detection to the core of snapcraft) +RUN mkdir -p /snap/bin && \ + echo "#!/bin/sh" > /snap/bin/snapcraft && \ + snap_version="$(awk '/^version:/{print $2}' /snap/snapcraft/current/meta/snap.yaml)" && \ + echo "export SNAP_VERSION=\"$snap_version\"" >> /snap/bin/snapcraft && \ + echo 'exec "$SNAP/usr/bin/python3" "$SNAP/bin/snapcraft" "$@"' >> /snap/bin/snapcraft && \ + chmod +x /snap/bin/snapcraft + +# Grab the golang snap from the stable channel, unpack it in the proper place, and create a runner for it +RUN curl -L $(curl -H 'X-Ubuntu-Series: 16' 'https://api.snapcraft.io/api/v1/snaps/details/go?channel=1.16/stable' | jq '.download_url' -r) --output go.snap && \ + mkdir -p /snap/go && \ + unsquashfs -d /snap/go/current go.snap && \ + cd /snap/bin && \ + ln -s /snap/go/current/bin/go + +FROM ubuntu:focal +COPY --from=builder /snap /snap + +# Install Snap build-time dependencies & generate locale +ARG DEBIAN_FRONTEND=noninteractive +RUN apt-get clean && apt-get update && apt-get install --yes \ + build-essential \ + golang-go \ + git \ + locales \ + snapd && \ + locale-gen en_US.UTF-8 && \ + rm -rf /var/lib/apt/lists/* + +# Set the proper environment +ENV LANG en_US.UTF-8 +ENV LANGUAGE en_US:en +ENV LC_ALL en_US.UTF-8 +ENV PATH "/snap/bin:$PATH" +ENV SNAP /snap/snapcraft/current +ENV SNAP_NAME snapcraft +ENV SNAP_ARCH amd64 + +SHELL ["/bin/bash", "-c"] +ENTRYPOINT "snapcraft" diff --git a/MHD Blockchain .sh b/MHD Blockchain .sh new file mode 100644 index 000000000000..26229f38e99a --- /dev/null +++ b/MHD Blockchain .sh @@ -0,0 +1,67 @@ +#!/bin/bash + +echo "🚀 Starting MHD Blockchain Environment Setup for macOS..." + +# Step 1: Install Homebrew if not installed +if ! command -v brew &>/dev/null; then + echo "🔧 Installing Homebrew..." + /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" +fi + +echo "✅ Homebrew installed." + +# Step 2: Install Node.js and npm +echo "🔧 Installing Node.js..." +brew install node + +# Step 3: Install Python +echo "🔧 Installing Python 3..." +brew install python + +# Step 4: Install Docker +echo "🔧 Installing Docker..." +brew install --cask docker + +# Step 5: Install Visual Studio Code +echo "🔧 Installing VS Code..." +brew install --cask visual-studio-code + +# Step 6: Install Git and GitHub CLI +echo "🔧 Installing Git and GitHub CLI..." +brew install git +brew install gh + +# Step 7: Install Go (optional for node engine) +echo "🔧 Installing GoLang..." +brew install go + +# Step 8: Install Rust (optional for performance-critical modules) +echo "🔧 Installing Rust..." +if curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y; then + echo "✅ Rust installed successfully." +else + echo "❌ Failed to install Rust. Please check the installation logs for more details." + exit 1 +fi + +# Step 9: Install Hardhat +echo "🔧 Setting up Hardhat..." +mkdir MHD-Blockchain +cd MHD-Blockchain +npm init -y +npm install --save-dev hardhat +npx hardhat --version + +# Step 10: Create Hardhat Project +npx hardhat init + +echo "✅ MHD Blockchain environment setup is complete!" +echo "📁 Project directory: MHD-Blockchain" +echo "💡 To start working, run: cd MHD-Blockchain && code ." + +# Step 11: Add deployment script execution +echo "🔧 Executing deployment script..." +chmod +x /workspaces/MHD/MHD-Blockchain/MHD-Blockchain/MHD-Blockchain/deploy.sh +/workspaces/MHD/MHD-Blockchain/MHD-Blockchain/MHD-Blockchain/deploy.sh sepolia + +echo "✅ Deployment script executed." diff --git a/Untitled-1.sh b/Untitled-1.sh new file mode 100644 index 000000000000..cc0461d892c9 --- /dev/null +++ b/Untitled-1.sh @@ -0,0 +1,58 @@ +#!/bin/bash + +# Step 1: Update Homebrew +echo "🔧 Updating Homebrew..." +brew update + +# Step 2: Install Node.js and npm +echo "🔧 Installing Node.js..." +brew install node + +# Step 3: Install Python +echo "🔧 Installing Python 3..." +brew install python + +# Step 4: Install Docker +echo "🔧 Installing Docker..." +brew install --cask docker + +# Step 5: Install Visual Studio Code +echo "🔧 Installing VS Code..." +brew install --cask visual-studio-code + +# Step 6: Install Git and GitHub CLI +echo "🔧 Installing Git and GitHub CLI..." +brew install git +brew install gh + +# Step 7: Install Go (optional for node engine) +echo "🔧 Installing GoLang..." +brew install go + +# Step 8: Install Rust (optional for performance-critical modules) +echo "🔧 Installing Rust..." +if ! command -v rustc &>/dev/null; then + if curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y; then + echo "✅ Rust installed successfully." + else + echo "❌ Failed to install Rust. Please check the installation logs for more details." + exit 1 + fi +else + echo "✅ Rust is already installed." +fi + +# Step 9: Install Hardhat +echo "🔧 Setting up Hardhat..." +mkdir MHD-Blockchain +cd MHD-Blockchain +npm init -y +npm install --save-dev hardhat +npx hardhat --version + +# Step 10: Create Hardhat Project +npx hardhat init + +echo "✅ MHD Blockchain environment setup is complete!" +echo "📁 Project directory: MHD-Blockchain" +echo "💡 To start working, run: cd MHD-Blockchain && code ." \ No newline at end of file diff --git a/WEB_CONCURRENCY.sh b/WEB_CONCURRENCY.sh new file mode 100644 index 000000000000..c4ea72096ecc --- /dev/null +++ b/WEB_CONCURRENCY.sh @@ -0,0 +1,95 @@ +#!/usr/bin/env bash + +# This script was created by the Python buildpack to automatically set the `WEB_CONCURRENCY` +# environment variable at dyno boot (if it's not already set), based on the available memory +# and number of CPU cores. The env var is then used by some Python web servers (such as +# gunicorn and uvicorn) to control the default number of server processes that they launch. +# +# The default `WEB_CONCURRENCY` value is calculated as the lowest of either: +# - ` * 2 + 1` +# - ` / 256` (to ensure each process has at least 256 MB RAM) +# +# Currently, on Heroku dynos this results in the following concurrency values: +# - Eco / Basic / Standard-1X: 2 (capped by the 512 MB available memory) +# - Standard-2X / Private-S / Shield-S: 4 (capped by the 1 GB available memory) +# - Performance-M / Private-M / Shield-M: 5 (based on the 2 CPU cores) +# - Performance-L / Private-L / Shield-L: 17 (based on the 8 CPU cores) +# - Performance-L-RAM / Private-L-RAM / Shield-L-RAM: 9 (based on the 4 CPU cores) +# - Performance-XL / Private-XL / Shield-XL: 17 (based on the 8 CPU cores) +# - Performance-2XL / Private-2XL / Shield-2XL: 33 (based on the 16 CPU cores) +# +# To override these default values, either set `WEB_CONCURRENCY` as an explicit config var +# on the app, or pass `--workers ` when invoking gunicorn/uvicorn in your Procfile. + +# Note: Since this is a .profile.d/ script it will be sourced, meaning that we cannot enable +# exit on error, have to use return not exit, and returning non-zero doesn't have an effect. + +function detect_memory_limit_in_mb() { + local memory_limit_file='/sys/fs/cgroup/memory/memory.limit_in_bytes' + + # This memory limits file only exists on Heroku, or when using cgroups v1 (Docker < 20.10). + if [[ -f "${memory_limit_file}" ]]; then + local memory_limit_in_mb=$(($(cat "${memory_limit_file}") / 1048576)) + + # Ignore values above 1TB RAM, since when using cgroups v1 the limits file reports a + # bogus value of thousands of TB RAM when there is no container memory limit set. + if ((memory_limit_in_mb <= 1048576)); then + echo "${memory_limit_in_mb}" + return 0 + fi + fi + + return 1 +} + +function output() { + # Only display log output for web dynos, to prevent breaking one-off dyno scripting use-cases, + # and to prevent confusion from messages about WEB_CONCURRENCY in the logs of non-web workers. + # (We still actually set the env vars for all dyno types for consistency and easier debugging.) + if [[ "${DYNO:-}" == web.* ]]; then + echo "Python buildpack: $*" >&2 + fi +} + +if ! available_memory_in_mb=$(detect_memory_limit_in_mb); then + # This should never occur on Heroku, but will be common for non-Heroku environments such as Dokku. + output "Couldn't determine available memory. Skipping automatic configuration of WEB_CONCURRENCY." + return 0 +fi + +if ! cpu_cores=$(nproc); then + # This should never occur in practice, since this buildpack only supports being run on our base + # images, and nproc is installed in all of them. + output "Couldn't determine number of CPU cores. Skipping automatic configuration of WEB_CONCURRENCY." + return 0 +fi + +output "Detected ${available_memory_in_mb} MB available memory and ${cpu_cores} CPU cores." + +# This env var is undocumented and not consistent with what other buildpacks set, however, +# GitHub code search shows there are Python apps in the wild that do rely upon it. +export DYNO_RAM="${available_memory_in_mb}" + +if [[ -v WEB_CONCURRENCY ]]; then + output "Skipping automatic configuration of WEB_CONCURRENCY since it's already set." + return 0 +fi + +minimum_memory_per_process_in_mb=256 + +# Prevents WEB_CONCURRENCY being set to zero if the environment is extremely memory constrained. +if ((available_memory_in_mb < minimum_memory_per_process_in_mb)); then + max_concurrency_for_available_memory=1 +else + max_concurrency_for_available_memory=$((available_memory_in_mb / minimum_memory_per_process_in_mb)) +fi + +max_concurrency_for_cpu_cores=$((cpu_cores * 2 + 1)) + +if ((max_concurrency_for_available_memory < max_concurrency_for_cpu_cores)); then + export WEB_CONCURRENCY="${max_concurrency_for_available_memory}" + output "Defaulting WEB_CONCURRENCY to ${WEB_CONCURRENCY} based on the available memory." +else + export WEB_CONCURRENCY="${max_concurrency_for_cpu_cores}" + output "Defaulting WEB_CONCURRENCY to ${WEB_CONCURRENCY} based on the number of CPU cores." +fi diff --git a/_build_snap.sh b/_build_snap.sh new file mode 100644 index 000000000000..d0173341da7f --- /dev/null +++ b/_build_snap.sh @@ -0,0 +1,11 @@ +#!/usr/bin/env bash + +set -euo pipefail + +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )/../" + +make clean + +echo "building snap" +echo "" +cd "$DIR" && docker run --rm -v "$DIR":/build -w /build sammytheshark/doctl-snap-base diff --git a/brew.sh b/brew.sh new file mode 100644 index 000000000000..98bd32a7d73a --- /dev/null +++ b/brew.sh @@ -0,0 +1,1076 @@ +##### +##### First do the essential, fast things to ensure commands like `brew --prefix` and others that we want +##### to be able to `source` in shell configurations run quickly. +##### + +case "${MACHTYPE}" in + arm64-* | aarch64-*) + HOMEBREW_PROCESSOR="arm64" + ;; + x86_64-*) + HOMEBREW_PROCESSOR="x86_64" + ;; + *) + HOMEBREW_PROCESSOR="$(uname -m)" + ;; +esac + +case "${OSTYPE}" in + darwin*) + HOMEBREW_SYSTEM="Darwin" + HOMEBREW_MACOS="1" + ;; + linux*) + HOMEBREW_SYSTEM="Linux" + HOMEBREW_LINUX="1" + ;; + *) + HOMEBREW_SYSTEM="$(uname -s)" + ;; +esac +HOMEBREW_PHYSICAL_PROCESSOR="${HOMEBREW_PROCESSOR}" + +HOMEBREW_MACOS_ARM_DEFAULT_PREFIX="/opt/homebrew" +HOMEBREW_MACOS_ARM_DEFAULT_REPOSITORY="${HOMEBREW_MACOS_ARM_DEFAULT_PREFIX}" +HOMEBREW_LINUX_DEFAULT_PREFIX="/home/linuxbrew/.linuxbrew" +HOMEBREW_LINUX_DEFAULT_REPOSITORY="${HOMEBREW_LINUX_DEFAULT_PREFIX}/Homebrew" +HOMEBREW_GENERIC_DEFAULT_PREFIX="/usr/local" +HOMEBREW_GENERIC_DEFAULT_REPOSITORY="${HOMEBREW_GENERIC_DEFAULT_PREFIX}/Homebrew" +if [[ -n "${HOMEBREW_MACOS}" && "${HOMEBREW_PROCESSOR}" == "arm64" ]] +then + HOMEBREW_DEFAULT_PREFIX="${HOMEBREW_MACOS_ARM_DEFAULT_PREFIX}" + HOMEBREW_DEFAULT_REPOSITORY="${HOMEBREW_MACOS_ARM_DEFAULT_REPOSITORY}" +elif [[ -n "${HOMEBREW_LINUX}" ]] +then + HOMEBREW_DEFAULT_PREFIX="${HOMEBREW_LINUX_DEFAULT_PREFIX}" + HOMEBREW_DEFAULT_REPOSITORY="${HOMEBREW_LINUX_DEFAULT_REPOSITORY}" +else + HOMEBREW_DEFAULT_PREFIX="${HOMEBREW_GENERIC_DEFAULT_PREFIX}" + HOMEBREW_DEFAULT_REPOSITORY="${HOMEBREW_GENERIC_DEFAULT_REPOSITORY}" +fi + +if [[ -n "${HOMEBREW_MACOS}" ]] +then + HOMEBREW_DEFAULT_CACHE="${HOME}/Library/Caches/Homebrew" + HOMEBREW_DEFAULT_LOGS="${HOME}/Library/Logs/Homebrew" + HOMEBREW_DEFAULT_TEMP="/private/tmp" + + HOMEBREW_MACOS_VERSION="$(/usr/bin/sw_vers -productVersion)" + + IFS=. read -r -a MACOS_VERSION_ARRAY <<<"${HOMEBREW_MACOS_VERSION}" + printf -v HOMEBREW_MACOS_VERSION_NUMERIC "%02d%02d%02d" "${MACOS_VERSION_ARRAY[@]}" + + unset MACOS_VERSION_ARRAY +else + CACHE_HOME="${HOMEBREW_XDG_CACHE_HOME:-${HOME}/.cache}" + HOMEBREW_DEFAULT_CACHE="${CACHE_HOME}/Homebrew" + HOMEBREW_DEFAULT_LOGS="${CACHE_HOME}/Homebrew/Logs" + HOMEBREW_DEFAULT_TEMP="/tmp" +fi + +realpath() { + (cd "$1" &>/dev/null && pwd -P) +} + +# Support systems where HOMEBREW_PREFIX is the default, +# but a parent directory is a symlink. +# Example: Fedora Silverblue symlinks /home -> var/home +if [[ "${HOMEBREW_PREFIX}" != "${HOMEBREW_DEFAULT_PREFIX}" && "$(realpath "${HOMEBREW_DEFAULT_PREFIX}")" == "${HOMEBREW_PREFIX}" ]] +then + HOMEBREW_PREFIX="${HOMEBREW_DEFAULT_PREFIX}" +fi + +# Support systems where HOMEBREW_REPOSITORY is the default, +# but a parent directory is a symlink. +# Example: Fedora Silverblue symlinks /home -> var/home +if [[ "${HOMEBREW_REPOSITORY}" != "${HOMEBREW_DEFAULT_REPOSITORY}" && "$(realpath "${HOMEBREW_DEFAULT_REPOSITORY}")" == "${HOMEBREW_REPOSITORY}" ]] +then + HOMEBREW_REPOSITORY="${HOMEBREW_DEFAULT_REPOSITORY}" +fi + +# Where we store built products; a Cellar in HOMEBREW_PREFIX (often /usr/local +# for bottles) unless there's already a Cellar in HOMEBREW_REPOSITORY. +# These variables are set by bin/brew +# shellcheck disable=SC2154 +if [[ -d "${HOMEBREW_REPOSITORY}/Cellar" ]] +then + HOMEBREW_CELLAR="${HOMEBREW_REPOSITORY}/Cellar" +else + HOMEBREW_CELLAR="${HOMEBREW_PREFIX}/Cellar" +fi + +HOMEBREW_CASKROOM="${HOMEBREW_PREFIX}/Caskroom" + +HOMEBREW_CACHE="${HOMEBREW_CACHE:-${HOMEBREW_DEFAULT_CACHE}}" +HOMEBREW_LOGS="${HOMEBREW_LOGS:-${HOMEBREW_DEFAULT_LOGS}}" +HOMEBREW_TEMP="${HOMEBREW_TEMP:-${HOMEBREW_DEFAULT_TEMP}}" + +# commands that take a single or no arguments. +# HOMEBREW_LIBRARY set by bin/brew +# shellcheck disable=SC2154 +# doesn't need a default case as other arguments handled elsewhere. +# shellcheck disable=SC2249 +case "$1" in + formulae) + source "${HOMEBREW_LIBRARY}/Homebrew/cmd/formulae.sh" + homebrew-formulae + exit 0 + ;; + casks) + source "${HOMEBREW_LIBRARY}/Homebrew/cmd/casks.sh" + homebrew-casks + exit 0 + ;; + shellenv) + source "${HOMEBREW_LIBRARY}/Homebrew/cmd/shellenv.sh" + shift + homebrew-shellenv "$1" + exit 0 + ;; +esac + +source "${HOMEBREW_LIBRARY}/Homebrew/help.sh" + +# functions that take multiple arguments or handle multiple commands. +# doesn't need a default case as other arguments handled elsewhere. +# shellcheck disable=SC2249 +case "$@" in + --cellar) + echo "${HOMEBREW_CELLAR}" + exit 0 + ;; + --repository | --repo) + echo "${HOMEBREW_REPOSITORY}" + exit 0 + ;; + --caskroom) + echo "${HOMEBREW_CASKROOM}" + exit 0 + ;; + --cache) + echo "${HOMEBREW_CACHE}" + exit 0 + ;; + # falls back to cmd/--prefix.rb and cmd/--cellar.rb on a non-zero return + --prefix* | --cellar*) + source "${HOMEBREW_LIBRARY}/Homebrew/formula_path.sh" + homebrew-formula-path "$@" && exit 0 + ;; + # falls back to cmd/command.rb on a non-zero return + command*) + source "${HOMEBREW_LIBRARY}/Homebrew/command_path.sh" + homebrew-command-path "$@" && exit 0 + ;; + # falls back to cmd/list.rb on a non-zero return + list* | ls*) + source "${HOMEBREW_LIBRARY}/Homebrew/list.sh" + homebrew-list "$@" && exit 0 + ;; + # homebrew-tap only handles invocations with no arguments + tap) + source "${HOMEBREW_LIBRARY}/Homebrew/tap.sh" + homebrew-tap "$@" + exit 0 + ;; + # falls back to cmd/help.rb on a non-zero return + help | --help | -h | --usage | "-?" | "") + homebrew-help "$@" && exit 0 + ;; +esac + +# Include some helper functions. +source "${HOMEBREW_LIBRARY}/Homebrew/utils/helpers.sh" + +# Require HOMEBREW_BREW_WRAPPER to be set if HOMEBREW_FORCE_BREW_WRAPPER is set +# (and HOMEBREW_NO_FORCE_BREW_WRAPPER is not set) for all non-trivial commands +# (i.e. not defined above this line e.g. formulae or --cellar). +if [[ -z "${HOMEBREW_NO_FORCE_BREW_WRAPPER:-}" && -n "${HOMEBREW_FORCE_BREW_WRAPPER:-}" ]] +then + HOMEBREW_FORCE_BREW_WRAPPER_WITHOUT_BREW="${HOMEBREW_FORCE_BREW_WRAPPER%/brew}" + if [[ -z "${HOMEBREW_BREW_WRAPPER:-}" ]] + then + odie </dev/null)" ]] + then + needs_auto_update=1 + break + fi + done + if [[ -z "${needs_auto_update}" ]] + then + return + fi + + brew update --auto-update + + unset HOMEBREW_AUTO_UPDATING + unset HOMEBREW_AUTO_UPDATE_TAP + + # exec a new process to set any new environment variables. + exec "${HOMEBREW_BREW_FILE}" "$@" + fi + + unset AUTO_UPDATE_COMMANDS + unset AUTO_UPDATE_CORE_TAP_COMMANDS + unset AUTO_UPDATE_CASK_TAP_COMMANDS + unset HOMEBREW_AUTO_UPDATE_CORE_TAP + unset HOMEBREW_AUTO_UPDATE_CASK_TAP +} + +##### +##### Setup output so e.g. odie looks as nice as possible. +##### + +# Colorize output on GitHub Actions. +# This is set by the user environment. +# shellcheck disable=SC2154 +if [[ -n "${GITHUB_ACTIONS}" ]] +then + export HOMEBREW_COLOR="1" +fi + +# Force UTF-8 to avoid encoding issues for users with broken locale settings. +if [[ -n "${HOMEBREW_MACOS}" ]] +then + if [[ "$(locale charmap)" != "UTF-8" ]] + then + export LC_ALL="en_US.UTF-8" + fi +else + if ! command -v locale >/dev/null + then + export LC_ALL=C + elif [[ "$(locale charmap)" != "UTF-8" ]] + then + locales="$(locale -a)" + c_utf_regex='\bC\.(utf8|UTF-8)\b' + en_us_regex='\ben_US\.(utf8|UTF-8)\b' + utf_regex='\b[a-z][a-z]_[A-Z][A-Z]\.(utf8|UTF-8)\b' + if [[ ${locales} =~ ${c_utf_regex} || ${locales} =~ ${en_us_regex} || ${locales} =~ ${utf_regex} ]] + then + export LC_ALL="${BASH_REMATCH[0]}" + else + export LC_ALL=C + fi + fi +fi + +##### +##### odie as quickly as possible. +##### + +if [[ "${HOMEBREW_PREFIX}" == "/" || "${HOMEBREW_PREFIX}" == "/usr" ]] +then + # it may work, but I only see pain this route and don't want to support it + odie "Cowardly refusing to continue at this prefix: ${HOMEBREW_PREFIX}" +fi + +##### +##### Now, do everything else (that may be a bit slower). +##### + +# Docker image deprecation +if [[ -f "${HOMEBREW_REPOSITORY}/.docker-deprecate" ]] +then + read -r DOCKER_DEPRECATION_MESSAGE <"${HOMEBREW_REPOSITORY}/.docker-deprecate" + if [[ -n "${GITHUB_ACTIONS}" ]] + then + echo "::warning::${DOCKER_DEPRECATION_MESSAGE}" >&2 + else + opoo "${DOCKER_DEPRECATION_MESSAGE}" + fi +fi + +# USER isn't always set so provide a fall back for `brew` and subprocesses. +export USER="${USER:-$(id -un)}" + +# A depth of 1 means this command was directly invoked by a user. +# Higher depths mean this command was invoked by another Homebrew command. +export HOMEBREW_COMMAND_DEPTH="$((HOMEBREW_COMMAND_DEPTH + 1))" + +setup_curl() { + # This is set by the user environment. + # shellcheck disable=SC2154 + HOMEBREW_BREWED_CURL_PATH="${HOMEBREW_PREFIX}/opt/curl/bin/curl" + if [[ -n "${HOMEBREW_FORCE_BREWED_CURL}" && -x "${HOMEBREW_BREWED_CURL_PATH}" ]] && + "${HOMEBREW_BREWED_CURL_PATH}" --version &>/dev/null + then + HOMEBREW_CURL="${HOMEBREW_BREWED_CURL_PATH}" + elif [[ -n "${HOMEBREW_CURL_PATH}" ]] + then + HOMEBREW_CURL="${HOMEBREW_CURL_PATH}" + else + HOMEBREW_CURL="curl" + fi +} + +setup_git() { + # This is set by the user environment. + # shellcheck disable=SC2154 + if [[ -n "${HOMEBREW_FORCE_BREWED_GIT}" && -x "${HOMEBREW_PREFIX}/opt/git/bin/git" ]] && + "${HOMEBREW_PREFIX}/opt/git/bin/git" --version &>/dev/null + then + HOMEBREW_GIT="${HOMEBREW_PREFIX}/opt/git/bin/git" + elif [[ -n "${HOMEBREW_GIT_PATH}" ]] + then + HOMEBREW_GIT="${HOMEBREW_GIT_PATH}" + else + HOMEBREW_GIT="git" + fi +} + +setup_curl +setup_git + +GIT_DESCRIBE_CACHE="${HOMEBREW_REPOSITORY}/.git/describe-cache" +GIT_REVISION=$("${HOMEBREW_GIT}" -C "${HOMEBREW_REPOSITORY}" rev-parse HEAD 2>/dev/null) + +# safe fallback in case git rev-parse fails e.g. if this is not considered a safe git directory +if [[ -z "${GIT_REVISION}" ]] +then + read -r GIT_HEAD 2>/dev/null <"${HOMEBREW_REPOSITORY}/.git/HEAD" + if [[ "${GIT_HEAD}" == "ref: refs/heads/master" ]] + then + read -r GIT_REVISION 2>/dev/null <"${HOMEBREW_REPOSITORY}/.git/refs/heads/master" + elif [[ "${GIT_HEAD}" == "ref: refs/heads/stable" ]] + then + read -r GIT_REVISION 2>/dev/null <"${HOMEBREW_REPOSITORY}/.git/refs/heads/stable" + fi + unset GIT_HEAD +fi + +if [[ -n "${GIT_REVISION}" ]] +then + GIT_DESCRIBE_CACHE_FILE="${GIT_DESCRIBE_CACHE}/${GIT_REVISION}" + if [[ -r "${GIT_DESCRIBE_CACHE_FILE}" ]] && "${HOMEBREW_GIT}" -C "${HOMEBREW_REPOSITORY}" diff --quiet --no-ext-diff 2>/dev/null + then + read -r GIT_DESCRIBE_CACHE_HOMEBREW_VERSION <"${GIT_DESCRIBE_CACHE_FILE}" + if [[ -n "${GIT_DESCRIBE_CACHE_HOMEBREW_VERSION}" && "${GIT_DESCRIBE_CACHE_HOMEBREW_VERSION}" != *"-dirty" ]] + then + HOMEBREW_VERSION="${GIT_DESCRIBE_CACHE_HOMEBREW_VERSION}" + fi + unset GIT_DESCRIBE_CACHE_HOMEBREW_VERSION + fi + + if [[ -z "${HOMEBREW_VERSION}" ]] + then + HOMEBREW_VERSION="$("${HOMEBREW_GIT}" -C "${HOMEBREW_REPOSITORY}" describe --tags --dirty --abbrev=7 2>/dev/null)" + # Don't output any permissions errors here. The user may not have write + # permissions to the cache but we don't care because it's an optional + # performance improvement. + rm -rf "${GIT_DESCRIBE_CACHE}" 2>/dev/null + mkdir -p "${GIT_DESCRIBE_CACHE}" 2>/dev/null + echo "${HOMEBREW_VERSION}" | tee "${GIT_DESCRIBE_CACHE_FILE}" &>/dev/null + fi + unset GIT_DESCRIBE_CACHE_FILE +else + # Don't care about permission errors here either. + rm -rf "${GIT_DESCRIBE_CACHE}" 2>/dev/null +fi +unset GIT_REVISION +unset GIT_DESCRIBE_CACHE + +HOMEBREW_USER_AGENT_VERSION="${HOMEBREW_VERSION}" +if [[ -z "${HOMEBREW_VERSION}" ]] +then + HOMEBREW_VERSION=">=4.3.0 (shallow or no git repository)" + HOMEBREW_USER_AGENT_VERSION="4.X.Y" +fi + +HOMEBREW_CORE_REPOSITORY="${HOMEBREW_LIBRARY}/Taps/homebrew/homebrew-core" +# Used in --version.sh +# shellcheck disable=SC2034 +HOMEBREW_CASK_REPOSITORY="${HOMEBREW_LIBRARY}/Taps/homebrew/homebrew-cask" + +# Shift the -v to the end of the parameter list +if [[ "$1" == "-v" ]] +then + shift + set -- "$@" -v +fi + +# commands that take a single or no arguments. +# doesn't need a default case as other arguments handled elsewhere. +# shellcheck disable=SC2249 +case "$1" in + --version | -v) + source "${HOMEBREW_LIBRARY}/Homebrew/cmd/--version.sh" + homebrew-version + exit 0 + ;; +esac + +# TODO: bump version when new macOS is released or announced and update references in: +# - docs/Installation.md +# - https://github.com/Homebrew/install/blob/HEAD/install.sh +# - Library/Homebrew/os/mac.rb (latest_sdk_version) +# and, if needed: +# - MacOSVersion::SYMBOLS +HOMEBREW_MACOS_NEWEST_UNSUPPORTED="16" +# TODO: bump version when new macOS is released and update references in: +# - docs/Installation.md +# - HOMEBREW_MACOS_OLDEST_SUPPORTED in .github/workflows/pkg-installer.yml +# - `os-version min` in package/Distribution.xml +# - https://github.com/Homebrew/install/blob/HEAD/install.sh +HOMEBREW_MACOS_OLDEST_SUPPORTED="13" +HOMEBREW_MACOS_OLDEST_ALLOWED="10.11" + +if [[ -n "${HOMEBREW_MACOS}" ]] +then + HOMEBREW_PRODUCT="Homebrew" + HOMEBREW_SYSTEM="Macintosh" + [[ "${HOMEBREW_PROCESSOR}" == "x86_64" ]] && HOMEBREW_PROCESSOR="Intel" + # Don't change this from Mac OS X to match what macOS itself does in Safari on 10.12 + HOMEBREW_OS_USER_AGENT_VERSION="Mac OS X ${HOMEBREW_MACOS_VERSION}" + + if [[ "$(sysctl -n hw.optional.arm64 2>/dev/null)" == "1" ]] + then + # used in vendor-install.sh + # shellcheck disable=SC2034 + HOMEBREW_PHYSICAL_PROCESSOR="arm64" + fi + + IFS=. read -r -a MACOS_VERSION_ARRAY <<<"${HOMEBREW_MACOS_OLDEST_ALLOWED}" + printf -v HOMEBREW_MACOS_OLDEST_ALLOWED_NUMERIC "%02d%02d%02d" "${MACOS_VERSION_ARRAY[@]}" + + unset MACOS_VERSION_ARRAY + + # Don't include minor versions for Big Sur and later. + if [[ "${HOMEBREW_MACOS_VERSION_NUMERIC}" -gt "110000" ]] + then + HOMEBREW_OS_VERSION="macOS ${HOMEBREW_MACOS_VERSION%.*}" + else + HOMEBREW_OS_VERSION="macOS ${HOMEBREW_MACOS_VERSION}" + fi + + # Refuse to run on pre-El Capitan + if [[ "${HOMEBREW_MACOS_VERSION_NUMERIC}" -lt "${HOMEBREW_MACOS_OLDEST_ALLOWED_NUMERIC}" ]] + then + printf "ERROR: Your version of macOS (%s) is too old to run Homebrew!\\n" "${HOMEBREW_MACOS_VERSION}" >&2 + if [[ "${HOMEBREW_MACOS_VERSION_NUMERIC}" -lt "100700" ]] + then + printf " For 10.4 - 10.6 support see: https://github.com/mistydemeo/tigerbrew\\n" >&2 + fi + printf "\\n" >&2 + fi + + # Versions before Sierra don't handle custom cert files correctly, so need a full brewed curl. + if [[ "${HOMEBREW_MACOS_VERSION_NUMERIC}" -lt "101200" ]] + then + HOMEBREW_SYSTEM_CURL_TOO_OLD="1" + HOMEBREW_FORCE_BREWED_CURL="1" + fi + + # The system libressl has a bug before macOS 10.15.6 where it incorrectly handles expired roots. + if [[ -z "${HOMEBREW_SYSTEM_CURL_TOO_OLD}" && "${HOMEBREW_MACOS_VERSION_NUMERIC}" -lt "101506" ]] + then + HOMEBREW_SYSTEM_CA_CERTIFICATES_TOO_OLD="1" + HOMEBREW_FORCE_BREWED_CA_CERTIFICATES="1" + fi + + # TEMP: backwards compatiblity with existing 10.11-cross image + # Can (probably) be removed in March 2024. + if [[ -n "${HOMEBREW_FAKE_EL_CAPITAN}" ]] + then + export HOMEBREW_FAKE_MACOS="10.11.6" + fi + + if [[ "${HOMEBREW_FAKE_MACOS}" =~ ^10\.11(\.|$) ]] + then + # We only need this to work enough to update brew and build the set portable formulae, so relax the requirement. + HOMEBREW_MINIMUM_GIT_VERSION="2.7.4" + else + # The system Git on macOS versions before Sierra is too old for some Homebrew functionality we rely on. + HOMEBREW_MINIMUM_GIT_VERSION="2.14.3" + if [[ "${HOMEBREW_MACOS_VERSION_NUMERIC}" -lt "101200" ]] + then + HOMEBREW_FORCE_BREWED_GIT="1" + fi + fi +else + HOMEBREW_PRODUCT="${HOMEBREW_SYSTEM}brew" + # Don't try to follow /etc/os-release + # shellcheck disable=SC1091,SC2154 + [[ -n "${HOMEBREW_LINUX}" ]] && HOMEBREW_OS_VERSION="$(source /etc/os-release && echo "${PRETTY_NAME}")" + : "${HOMEBREW_OS_VERSION:=$(uname -r)}" + HOMEBREW_OS_USER_AGENT_VERSION="${HOMEBREW_OS_VERSION}" + + # Ensure the system Curl is a version that supports modern HTTPS certificates. + HOMEBREW_MINIMUM_CURL_VERSION="7.41.0" + + curl_version_output="$(${HOMEBREW_CURL} --version 2>/dev/null)" + curl_name_and_version="${curl_version_output%% (*}" + if [[ "$(numeric "${curl_name_and_version##* }")" -lt "$(numeric "${HOMEBREW_MINIMUM_CURL_VERSION}")" ]] + then + message="Please update your system curl or set HOMEBREW_CURL_PATH to a newer version. +Minimum required version: ${HOMEBREW_MINIMUM_CURL_VERSION} +Your curl version: ${curl_name_and_version##* } +Your curl executable: $(type -p "${HOMEBREW_CURL}")" + + if [[ -z ${HOMEBREW_CURL_PATH} ]] + then + HOMEBREW_SYSTEM_CURL_TOO_OLD=1 + HOMEBREW_FORCE_BREWED_CURL=1 + if [[ -z ${HOMEBREW_CURL_WARNING} ]] + then + onoe "${message}" + HOMEBREW_CURL_WARNING=1 + fi + else + odie "${message}" + fi + fi + + # Ensure the system Git is at or newer than the minimum required version. + # Git 2.7.4 is the version of git on Ubuntu 16.04 LTS (Xenial Xerus). + HOMEBREW_MINIMUM_GIT_VERSION="2.7.0" + git_version_output="$(${HOMEBREW_GIT} --version 2>/dev/null)" + # $extra is intentionally discarded. + # shellcheck disable=SC2034 + IFS='.' read -r major minor micro build extra <<<"${git_version_output##* }" + if [[ "$(numeric "${major}.${minor}.${micro}.${build}")" -lt "$(numeric "${HOMEBREW_MINIMUM_GIT_VERSION}")" ]] + then + message="Please update your system Git or set HOMEBREW_GIT_PATH to a newer version. +Minimum required version: ${HOMEBREW_MINIMUM_GIT_VERSION} +Your Git version: ${major}.${minor}.${micro}.${build} +Your Git executable: $(unset git && type -p "${HOMEBREW_GIT}")" + if [[ -z ${HOMEBREW_GIT_PATH} ]] + then + HOMEBREW_FORCE_BREWED_GIT="1" + if [[ -z ${HOMEBREW_GIT_WARNING} ]] + then + onoe "${message}" + HOMEBREW_GIT_WARNING=1 + fi + else + odie "${message}" + fi + fi + + HOMEBREW_LINUX_MINIMUM_GLIBC_VERSION="2.13" + + HOMEBREW_CORE_REPOSITORY_ORIGIN="$("${HOMEBREW_GIT}" -C "${HOMEBREW_CORE_REPOSITORY}" remote get-url origin 2>/dev/null)" + if [[ "${HOMEBREW_CORE_REPOSITORY_ORIGIN}" =~ (/linuxbrew|Linuxbrew/homebrew)-core(\.git)?$ ]] + then + # triggers migration code in update.sh + # shellcheck disable=SC2034 + HOMEBREW_LINUXBREW_CORE_MIGRATION=1 + fi +fi + +setup_ca_certificates() { + if [[ -n "${HOMEBREW_FORCE_BREWED_CA_CERTIFICATES}" && -f "${HOMEBREW_PREFIX}/etc/ca-certificates/cert.pem" ]] + then + export SSL_CERT_FILE="${HOMEBREW_PREFIX}/etc/ca-certificates/cert.pem" + export GIT_SSL_CAINFO="${HOMEBREW_PREFIX}/etc/ca-certificates/cert.pem" + export GIT_SSL_CAPATH="${HOMEBREW_PREFIX}/etc/ca-certificates" + fi +} +setup_ca_certificates + +# Redetermine curl and git paths as we may have forced some options above. +setup_curl +setup_git + +# A bug in the auto-update process prior to 3.1.2 means $HOMEBREW_BOTTLE_DOMAIN +# could be passed down with the default domain. +# This is problematic as this is will be the old bottle domain. +# This workaround is necessary for many CI images starting on old version, +# and will only be unnecessary when updating from <3.1.2 is not a concern. +# That will be when macOS 12 is the minimum required version. +# HOMEBREW_BOTTLE_DOMAIN is set from the user environment +# shellcheck disable=SC2154 +if [[ -n "${HOMEBREW_BOTTLE_DEFAULT_DOMAIN}" ]] && + [[ "${HOMEBREW_BOTTLE_DOMAIN}" == "${HOMEBREW_BOTTLE_DEFAULT_DOMAIN}" ]] +then + unset HOMEBREW_BOTTLE_DOMAIN +fi + +HOMEBREW_API_DEFAULT_DOMAIN="https://formulae.brew.sh/api" +HOMEBREW_BOTTLE_DEFAULT_DOMAIN="https://ghcr.io/v2/homebrew/core" + +HOMEBREW_USER_AGENT="${HOMEBREW_PRODUCT}/${HOMEBREW_USER_AGENT_VERSION} (${HOMEBREW_SYSTEM}; ${HOMEBREW_PROCESSOR} ${HOMEBREW_OS_USER_AGENT_VERSION})" +curl_version_output="$(curl --version 2>/dev/null)" +curl_name_and_version="${curl_version_output%% (*}" +HOMEBREW_USER_AGENT_CURL="${HOMEBREW_USER_AGENT} ${curl_name_and_version// //}" + +# Timeout values to check for dead connections +# We don't use --max-time to support slow connections +HOMEBREW_CURL_SPEED_LIMIT=100 +HOMEBREW_CURL_SPEED_TIME=5 + +export HOMEBREW_HELP_MESSAGE +export HOMEBREW_VERSION +export HOMEBREW_MACOS_ARM_DEFAULT_PREFIX +export HOMEBREW_LINUX_DEFAULT_PREFIX +export HOMEBREW_GENERIC_DEFAULT_PREFIX +export HOMEBREW_DEFAULT_PREFIX +export HOMEBREW_MACOS_ARM_DEFAULT_REPOSITORY +export HOMEBREW_LINUX_DEFAULT_REPOSITORY +export HOMEBREW_GENERIC_DEFAULT_REPOSITORY +export HOMEBREW_DEFAULT_REPOSITORY +export HOMEBREW_DEFAULT_CACHE +export HOMEBREW_CACHE +export HOMEBREW_DEFAULT_LOGS +export HOMEBREW_LOGS +export HOMEBREW_DEFAULT_TEMP +export HOMEBREW_TEMP +export HOMEBREW_CELLAR +export HOMEBREW_CASKROOM +export HOMEBREW_SYSTEM +export HOMEBREW_SYSTEM_CA_CERTIFICATES_TOO_OLD +export HOMEBREW_CURL +export HOMEBREW_BREWED_CURL_PATH +export HOMEBREW_CURL_WARNING +export HOMEBREW_SYSTEM_CURL_TOO_OLD +export HOMEBREW_GIT +export HOMEBREW_GIT_WARNING +export HOMEBREW_MINIMUM_GIT_VERSION +export HOMEBREW_LINUX_MINIMUM_GLIBC_VERSION +export HOMEBREW_PHYSICAL_PROCESSOR +export HOMEBREW_PROCESSOR +export HOMEBREW_PRODUCT +export HOMEBREW_OS_VERSION +export HOMEBREW_MACOS_VERSION +export HOMEBREW_MACOS_VERSION_NUMERIC +export HOMEBREW_MACOS_NEWEST_UNSUPPORTED +export HOMEBREW_MACOS_OLDEST_SUPPORTED +export HOMEBREW_MACOS_OLDEST_ALLOWED +export HOMEBREW_USER_AGENT +export HOMEBREW_USER_AGENT_CURL +export HOMEBREW_API_DEFAULT_DOMAIN +export HOMEBREW_BOTTLE_DEFAULT_DOMAIN +export HOMEBREW_CURL_SPEED_LIMIT +export HOMEBREW_CURL_SPEED_TIME + +if [[ -n "${HOMEBREW_MACOS}" && -x "/usr/bin/xcode-select" ]] +then + XCODE_SELECT_PATH="$('/usr/bin/xcode-select' --print-path 2>/dev/null)" + if [[ "${XCODE_SELECT_PATH}" == "/" ]] + then + odie </dev/null)" + if [[ "${HOMEBREW_GIT_CONFIG_DEVELOPERMODE}" == "true" ]] + then + export HOMEBREW_DEV_CMD_RUN="1" + fi + + # Don't allow non-developers to customise Ruby warnings. + unset HOMEBREW_RUBY_WARNINGS +fi + +unset HOMEBREW_AUTO_UPDATE_COMMAND + +# Check for commands that should call `brew update --auto-update` first. +AUTO_UPDATE_COMMANDS=( + install + outdated + upgrade + bundle + release +) +if check-array-membership "${HOMEBREW_COMMAND}" "${AUTO_UPDATE_COMMANDS[@]}" || + [[ "${HOMEBREW_COMMAND}" == "tap" && "${HOMEBREW_ARG_COUNT}" -gt 1 ]] +then + export HOMEBREW_AUTO_UPDATE_COMMAND="1" +fi + +# Check for commands that should auto-update the homebrew-core tap. +AUTO_UPDATE_CORE_TAP_COMMANDS=( + bump + bump-formula-pr +) +if check-array-membership "${HOMEBREW_COMMAND}" "${AUTO_UPDATE_CORE_TAP_COMMANDS[@]}" +then + export HOMEBREW_AUTO_UPDATE_COMMAND="1" + export HOMEBREW_AUTO_UPDATE_CORE_TAP="1" +elif [[ -z "${HOMEBREW_AUTO_UPDATING}" ]] +then + unset HOMEBREW_AUTO_UPDATE_CORE_TAP +fi + +# Check for commands that should auto-update the homebrew-cask tap. +AUTO_UPDATE_CASK_TAP_COMMANDS=( + bump + bump-cask-pr + bump-unversioned-casks +) +if check-array-membership "${HOMEBREW_COMMAND}" "${AUTO_UPDATE_CASK_TAP_COMMANDS[@]}" +then + export HOMEBREW_AUTO_UPDATE_COMMAND="1" + export HOMEBREW_AUTO_UPDATE_CASK_TAP="1" +elif [[ -z "${HOMEBREW_AUTO_UPDATING}" ]] +then + unset HOMEBREW_AUTO_UPDATE_CASK_TAP +fi + +if [[ -z "${HOMEBREW_RUBY_WARNINGS}" ]] +then + export HOMEBREW_RUBY_WARNINGS="-W1" +fi + +export HOMEBREW_BREW_DEFAULT_GIT_REMOTE="https://github.com/Homebrew/brew" +if [[ -z "${HOMEBREW_BREW_GIT_REMOTE}" ]] +then + HOMEBREW_BREW_GIT_REMOTE="${HOMEBREW_BREW_DEFAULT_GIT_REMOTE}" +fi +export HOMEBREW_BREW_GIT_REMOTE + +export HOMEBREW_CORE_DEFAULT_GIT_REMOTE="https://github.com/Homebrew/homebrew-core" +if [[ -z "${HOMEBREW_CORE_GIT_REMOTE}" ]] +then + HOMEBREW_CORE_GIT_REMOTE="${HOMEBREW_CORE_DEFAULT_GIT_REMOTE}" +fi +export HOMEBREW_CORE_GIT_REMOTE + +# Set HOMEBREW_DEVELOPER_COMMAND if the command being run is a developer command +unset HOMEBREW_DEVELOPER_COMMAND +if [[ -f "${HOMEBREW_LIBRARY}/Homebrew/dev-cmd/${HOMEBREW_COMMAND}.sh" ]] || + [[ -f "${HOMEBREW_LIBRARY}/Homebrew/dev-cmd/${HOMEBREW_COMMAND}.rb" ]] +then + export HOMEBREW_DEVELOPER_COMMAND="1" +fi + +if [[ -n "${HOMEBREW_DEVELOPER_COMMAND}" && -z "${HOMEBREW_DEVELOPER}" ]] +then + if [[ -z "${HOMEBREW_DEV_CMD_RUN}" ]] + then + opoo </dev/null + export HOMEBREW_DEV_CMD_RUN="1" +fi + +if [[ -n "${HOMEBREW_DEVELOPER}" || -n "${HOMEBREW_DEV_CMD_RUN}" ]] +then + # Always run with Sorbet for Homebrew developers or when a Homebrew developer command has been run. + export HOMEBREW_SORBET_RUNTIME="1" +fi + +# Provide a (temporary, undocumented) way to disable Sorbet globally if needed +# to avoid reverting the above. +if [[ -n "${HOMEBREW_NO_SORBET_RUNTIME}" ]] +then + unset HOMEBREW_SORBET_RUNTIME +fi + +if [[ -f "${HOMEBREW_LIBRARY}/Homebrew/cmd/${HOMEBREW_COMMAND}.sh" ]] +then + HOMEBREW_BASH_COMMAND="${HOMEBREW_LIBRARY}/Homebrew/cmd/${HOMEBREW_COMMAND}.sh" +elif [[ -f "${HOMEBREW_LIBRARY}/Homebrew/dev-cmd/${HOMEBREW_COMMAND}.sh" ]] +then + HOMEBREW_BASH_COMMAND="${HOMEBREW_LIBRARY}/Homebrew/dev-cmd/${HOMEBREW_COMMAND}.sh" +fi + +check-run-command-as-root + +check-prefix-is-not-tmpdir + +if [[ "${HOMEBREW_PREFIX}" == "/usr/local" ]] && + [[ "${HOMEBREW_PREFIX}" != "${HOMEBREW_REPOSITORY}" ]] && + [[ "${HOMEBREW_CELLAR}" == "${HOMEBREW_REPOSITORY}/Cellar" ]] +then + cat >&2 <&2 + exit 1 +} + +case "${STACK:?}" in + heroku-20 | heroku-22 | heroku-24) + SUPPORTED_PYTHON_VERSIONS=( + "3.9" + "3.10" + "3.11" + "3.12" + "3.13" + ) + ;; + *) + abort "Unsupported stack '${STACK}'!" + ;; +esac + +if [[ ! " ${SUPPORTED_PYTHON_VERSIONS[*]} " == *" ${PYTHON_MAJOR_VERSION} "* ]]; then + abort "Python ${PYTHON_MAJOR_VERSION} is not supported on ${STACK}!" +fi + +# The release keys can be found on https://www.python.org/downloads/ -> "OpenPGP Public Keys". +case "${PYTHON_MAJOR_VERSION}" in + 3.13) + # https://github.com/Yhg1s.gpg + GPG_KEY_FINGERPRINT='7169605F62C751356D054A26A821E680E5FA6305' + ;; + 3.12) + # https://github.com/Yhg1s.gpg + GPG_KEY_FINGERPRINT='7169605F62C751356D054A26A821E680E5FA6305' + ;; + 3.10 | 3.11) + # https://keybase.io/pablogsal/ + GPG_KEY_FINGERPRINT='A035C8C19219BA821ECEA86B64E628F8D684696D' + ;; + 3.9) + # https://keybase.io/ambv/ + GPG_KEY_FINGERPRINT='E3FF2839C048B25C084DEBE9B26995E310250568' + ;; + *) + abort "Unsupported Python version '${PYTHON_MAJOR_VERSION}'!" + ;; +esac + +echo "Building Python ${PYTHON_VERSION} for ${STACK} (${ARCH})..." + +SOURCE_URL="https://www.python.org/ftp/python/${PYTHON_VERSION}/Python-${PYTHON_VERSION}.tgz" +SIGNATURE_URL="${SOURCE_URL}.asc" + +set -o xtrace + +mkdir -p "${SRC_DIR}" "${INSTALL_DIR}" "${UPLOAD_DIR}" + +curl --fail --retry 3 --retry-connrefused --connect-timeout 10 --max-time 60 -o python.tgz "${SOURCE_URL}" +curl --fail --retry 3 --retry-connrefused --connect-timeout 10 --max-time 60 -o python.tgz.asc "${SIGNATURE_URL}" + +gpg --batch --verbose --recv-keys "${GPG_KEY_FINGERPRINT}" +gpg --batch --verify python.tgz.asc python.tgz + +tar --extract --file python.tgz --strip-components=1 --directory "${SRC_DIR}" +cd "${SRC_DIR}" + +# Work around PGO profile test failures with Python 3.13 on Ubuntu 22.04, due to the tests +# checking the raw libexpat version which doesn't account for Ubuntu backports: +# https://github.com/heroku/heroku-buildpack-python/pull/1661#issuecomment-2405259352 +# https://github.com/python/cpython/issues/125067 +if [[ "${PYTHON_MAJOR_VERSION}" == "3.13" && "${STACK}" == "heroku-22" ]]; then + patch -p1 /dev/null) +TAR_FILEPATH="${UPLOAD_DIR}/python-${PYTHON_VERSION}-ubuntu-${UBUNTU_VERSION}-${ARCH}.tar" +tar --create --format=pax --sort=name --file "${TAR_FILEPATH}" --directory="${INSTALL_DIR}" . +zstd -T0 -22 --ultra --long --no-progress --rm "${TAR_FILEPATH}" + +du --max-depth 1 --human-readable "${INSTALL_DIR}" +du --all --human-readable "${UPLOAD_DIR}" diff --git a/ci.sh b/ci.sh new file mode 100644 index 000000000000..ce1e95cbc002 --- /dev/null +++ b/ci.sh @@ -0,0 +1,51 @@ +#!/usr/bin/env bash + +set -o errexit + +if [ "$TEST" = "integration" ]; then + + npm test + +elif [ "$TEST" = "geth" ]; then + + npx geth-dev-assistant \ + --launch \ + --tag 'latest' \ + --accounts 4 \ + --balance 100 \ + --gasLimit 8000000 + + npm test + docker stop geth-client + +elif [ "$TEST" = "colony" ]; then + + npm install -g yarn + git clone https://github.com/JoinColony/colonyNetwork.git + cd colonyNetwork || exit + yarn + yarn remove -W eth-gas-reporter --dev + + env + + SLUG="$TRAVIS_REPO_SLUG" + BRANCH="$TRAVIS_BRANCH" + + if [ -n "$TRAVIS_PULL_REQUEST_SLUG" ]; then + SLUG="$TRAVIS_PULL_REQUEST_SLUG" + fi + + if [ -n "$TRAVIS_PULL_REQUEST_BRANCH" ]; then + BRANCH="$TRAVIS_PULL_REQUEST_BRANCH" + fi + + echo ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>" + echo "TESTING BRANCH: https://github.com/$SLUG.git#$BRANCH" + echo ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>" + + yarn add -W https://github.com/"$SLUG".git#"$BRANCH" + git submodule update --init + yarn run provision:token:contracts + DEBUG_CODECHECKS_TABLE=true yarn run test:contracts:gasCosts + +fi \ No newline at end of file diff --git a/cli.js b/cli.js new file mode 100644 index 000000000000..58f2861f9f37 --- /dev/null +++ b/cli.js @@ -0,0 +1,5 @@ +#!/usr/bin/env node +'use strict'; +const isDocker = require('.'); + +process.exitCode = isDocker() ? 0 : 2; diff --git a/client_metadata.ts b/client_metadata.ts new file mode 100644 index 000000000000..1e825ed2bf72 --- /dev/null +++ b/client_metadata.ts @@ -0,0 +1,320 @@ +import * as os from 'os'; +import * as process from 'process'; + +import { BSON, type Document, Int32 } from '../../bson'; +import { MongoInvalidArgumentError } from '../../error'; +import type { MongoOptions } from '../../mongo_client'; +import { fileIsAccessible } from '../../utils'; + +// eslint-disable-next-line @typescript-eslint/no-require-imports +const NODE_DRIVER_VERSION = require('../../../package.json').version; + +/** + * @public + * @see https://github.com/mongodb/specifications/blob/master/source/mongodb-handshake/handshake.md#hello-command + */ +export interface ClientMetadata { + driver: { + name: string; + version: string; + }; + os: { + type: string; + name?: NodeJS.Platform; + architecture?: string; + version?: string; + }; + platform: string; + application?: { + name: string; + }; + /** FaaS environment information */ + env?: { + name: 'aws.lambda' | 'gcp.func' | 'azure.func' | 'vercel'; + timeout_sec?: Int32; + memory_mb?: Int32; + region?: string; + url?: string; + }; +} + +/** @public */ +export interface ClientMetadataOptions { + driverInfo?: { + name?: string; + version?: string; + platform?: string; + }; + appName?: string; +} + +/** @internal */ +export class LimitedSizeDocument { + private document = new Map(); + /** BSON overhead: Int32 + Null byte */ + private documentSize = 5; + constructor(private maxSize: number) {} + + /** Only adds key/value if the bsonByteLength is less than MAX_SIZE */ + public ifItFitsItSits(key: string, value: Record | string): boolean { + // The BSON byteLength of the new element is the same as serializing it to its own document + // subtracting the document size int32 and the null terminator. + const newElementSize = BSON.serialize(new Map().set(key, value)).byteLength - 5; + + if (newElementSize + this.documentSize > this.maxSize) { + return false; + } + + this.documentSize += newElementSize; + + this.document.set(key, value); + + return true; + } + + toObject(): Document { + return BSON.deserialize(BSON.serialize(this.document), { + promoteLongs: false, + promoteBuffers: false, + promoteValues: false, + useBigInt64: false + }); + } +} + +type MakeClientMetadataOptions = Pick; +/** + * From the specs: + * Implementors SHOULD cumulatively update fields in the following order until the document is under the size limit: + * 1. Omit fields from `env` except `env.name`. + * 2. Omit fields from `os` except `os.type`. + * 3. Omit the `env` document entirely. + * 4. Truncate `platform`. -- special we do not truncate this field + */ +export function makeClientMetadata(options: MakeClientMetadataOptions): ClientMetadata { + const metadataDocument = new LimitedSizeDocument(512); + + const { appName = '' } = options; + // Add app name first, it must be sent + if (appName.length > 0) { + const name = + Buffer.byteLength(appName, 'utf8') <= 128 + ? options.appName + : Buffer.from(appName, 'utf8').subarray(0, 128).toString('utf8'); + metadataDocument.ifItFitsItSits('application', { name }); + } + + const { name = '', version = '', platform = '' } = options.driverInfo; + + const driverInfo = { + name: name.length > 0 ? `nodejs|${name}` : 'nodejs', + version: version.length > 0 ? `${NODE_DRIVER_VERSION}|${version}` : NODE_DRIVER_VERSION + }; + + if (!metadataDocument.ifItFitsItSits('driver', driverInfo)) { + throw new MongoInvalidArgumentError( + 'Unable to include driverInfo name and version, metadata cannot exceed 512 bytes' + ); + } + + let runtimeInfo = getRuntimeInfo(); + if (platform.length > 0) { + runtimeInfo = `${runtimeInfo}|${platform}`; + } + + if (!metadataDocument.ifItFitsItSits('platform', runtimeInfo)) { + throw new MongoInvalidArgumentError( + 'Unable to include driverInfo platform, metadata cannot exceed 512 bytes' + ); + } + + // Note: order matters, os.type is last so it will be removed last if we're at maxSize + const osInfo = new Map() + .set('name', process.platform) + .set('architecture', process.arch) + .set('version', os.release()) + .set('type', os.type()); + + if (!metadataDocument.ifItFitsItSits('os', osInfo)) { + for (const key of osInfo.keys()) { + osInfo.delete(key); + if (osInfo.size === 0) break; + if (metadataDocument.ifItFitsItSits('os', osInfo)) break; + } + } + + const faasEnv = getFAASEnv(); + if (faasEnv != null) { + if (!metadataDocument.ifItFitsItSits('env', faasEnv)) { + for (const key of faasEnv.keys()) { + faasEnv.delete(key); + if (faasEnv.size === 0) break; + if (metadataDocument.ifItFitsItSits('env', faasEnv)) break; + } + } + } + return metadataDocument.toObject() as ClientMetadata; +} + +let dockerPromise: Promise; +/** @internal */ +async function getContainerMetadata() { + const containerMetadata: Record = {}; + dockerPromise ??= fileIsAccessible('/.dockerenv'); + const isDocker = await dockerPromise; + + const { KUBERNETES_SERVICE_HOST = '' } = process.env; + const isKubernetes = KUBERNETES_SERVICE_HOST.length > 0 ? true : false; + + if (isDocker) containerMetadata.runtime = 'docker'; + if (isKubernetes) containerMetadata.orchestrator = 'kubernetes'; + + return containerMetadata; +} + +/** + * @internal + * Re-add each metadata value. + * Attempt to add new env container metadata, but keep old data if it does not fit. + */ +export async function addContainerMetadata(originalMetadata: ClientMetadata) { + const containerMetadata = await getContainerMetadata(); + if (Object.keys(containerMetadata).length === 0) return originalMetadata; + + const extendedMetadata = new LimitedSizeDocument(512); + + const extendedEnvMetadata = { ...originalMetadata?.env, container: containerMetadata }; + + for (const [key, val] of Object.entries(originalMetadata)) { + if (key !== 'env') { + extendedMetadata.ifItFitsItSits(key, val); + } else { + if (!extendedMetadata.ifItFitsItSits('env', extendedEnvMetadata)) { + // add in old data if newer / extended metadata does not fit + extendedMetadata.ifItFitsItSits('env', val); + } + } + } + + if (!('env' in originalMetadata)) { + extendedMetadata.ifItFitsItSits('env', extendedEnvMetadata); + } + + return extendedMetadata.toObject(); +} + +/** + * Collects FaaS metadata. + * - `name` MUST be the last key in the Map returned. + */ +export function getFAASEnv(): Map | null { + const { + AWS_EXECUTION_ENV = '', + AWS_LAMBDA_RUNTIME_API = '', + FUNCTIONS_WORKER_RUNTIME = '', + K_SERVICE = '', + FUNCTION_NAME = '', + VERCEL = '', + AWS_LAMBDA_FUNCTION_MEMORY_SIZE = '', + AWS_REGION = '', + FUNCTION_MEMORY_MB = '', + FUNCTION_REGION = '', + FUNCTION_TIMEOUT_SEC = '', + VERCEL_REGION = '' + } = process.env; + + const isAWSFaaS = + AWS_EXECUTION_ENV.startsWith('AWS_Lambda_') || AWS_LAMBDA_RUNTIME_API.length > 0; + const isAzureFaaS = FUNCTIONS_WORKER_RUNTIME.length > 0; + const isGCPFaaS = K_SERVICE.length > 0 || FUNCTION_NAME.length > 0; + const isVercelFaaS = VERCEL.length > 0; + + // Note: order matters, name must always be the last key + const faasEnv = new Map(); + + // When isVercelFaaS is true so is isAWSFaaS; Vercel inherits the AWS env + if (isVercelFaaS && !(isAzureFaaS || isGCPFaaS)) { + if (VERCEL_REGION.length > 0) { + faasEnv.set('region', VERCEL_REGION); + } + + faasEnv.set('name', 'vercel'); + return faasEnv; + } + + if (isAWSFaaS && !(isAzureFaaS || isGCPFaaS || isVercelFaaS)) { + if (AWS_REGION.length > 0) { + faasEnv.set('region', AWS_REGION); + } + + if ( + AWS_LAMBDA_FUNCTION_MEMORY_SIZE.length > 0 && + Number.isInteger(+AWS_LAMBDA_FUNCTION_MEMORY_SIZE) + ) { + faasEnv.set('memory_mb', new Int32(AWS_LAMBDA_FUNCTION_MEMORY_SIZE)); + } + + faasEnv.set('name', 'aws.lambda'); + return faasEnv; + } + + if (isAzureFaaS && !(isGCPFaaS || isAWSFaaS || isVercelFaaS)) { + faasEnv.set('name', 'azure.func'); + return faasEnv; + } + + if (isGCPFaaS && !(isAzureFaaS || isAWSFaaS || isVercelFaaS)) { + if (FUNCTION_REGION.length > 0) { + faasEnv.set('region', FUNCTION_REGION); + } + + if (FUNCTION_MEMORY_MB.length > 0 && Number.isInteger(+FUNCTION_MEMORY_MB)) { + faasEnv.set('memory_mb', new Int32(FUNCTION_MEMORY_MB)); + } + + if (FUNCTION_TIMEOUT_SEC.length > 0 && Number.isInteger(+FUNCTION_TIMEOUT_SEC)) { + faasEnv.set('timeout_sec', new Int32(FUNCTION_TIMEOUT_SEC)); + } + + faasEnv.set('name', 'gcp.func'); + return faasEnv; + } + + return null; +} + +/** + * @internal + * This type represents the global Deno object and the minimal type contract we expect it to satisfy. + */ +declare const Deno: { version?: { deno?: string } } | undefined; + +/** + * @internal + * This type represents the global Bun object and the minimal type contract we expect it to satisfy. + */ +declare const Bun: { (): void; version?: string } | undefined; + +/** + * @internal + * Get current JavaScript runtime platform + * + * NOTE: The version information fetching is intentionally written defensively + * to avoid having a released driver version that becomes incompatible + * with a future change to these global objects. + */ +function getRuntimeInfo(): string { + if ('Deno' in globalThis) { + const version = typeof Deno?.version?.deno === 'string' ? Deno?.version?.deno : '0.0.0-unknown'; + + return `Deno v${version}, ${os.endianness()}`; + } + + if ('Bun' in globalThis) { + const version = typeof Bun?.version === 'string' ? Bun?.version : '0.0.0-unknown'; + + return `Bun v${version}, ${os.endianness()}`; + } + + return `Node.js ${process.version}, ${os.endianness()}`; +} diff --git a/cloudbuild.harness.yaml b/cloudbuild.harness.yaml new file mode 100644 index 000000000000..13b0a34c3cf7 --- /dev/null +++ b/cloudbuild.harness.yaml @@ -0,0 +1,21 @@ +# Copyright 2019 The Go Authors. All rights reserved. +# Use of this source code is governed by a BSD-style +# license that can be found in the LICENSE file. + +# Build the govim test harness that will be used to run govim integration tests +# for gopls. See README.md for instructions on how to use this. +steps: + - name: 'gcr.io/cloud-builders/docker' + args: ['build', + # To allow for breaking changes to this test harness, tag with a major + # version number. + '-t', 'gcr.io/$PROJECT_ID/govim-harness:latest', + '-t', 'gcr.io/$PROJECT_ID/govim-harness:3', + # It is assumed that this build is running from the root directory of the + # tools repository. + '-f', 'gopls/integration/govim/Dockerfile', + # Use the integration test directory as build context: the test harness + # doesn't actually require any local files. + 'gopls/integration/govim'] +images: + - gcr.io/$PROJECT_ID/govim-harness diff --git a/compile b/compile new file mode 100644 index 000000000000..b75752b91b00 --- /dev/null +++ b/compile @@ -0,0 +1,327 @@ +#!/usr/bin/env bash +# Usage: bin/compile +# See: https://devcenter.heroku.com/articles/buildpack-api +# shellcheck disable=SC2250 # TODO: Use braces around variable references even when not strictly required. + +set -euo pipefail +shopt -s inherit_errexit + +# Note: This can't be enabled via app config vars, since at this point they haven't been loaded from ENV_DIR. +if [[ "${BUILDPACK_XTRACE:-0}" == "1" ]]; then + set -o xtrace +fi + +BUILD_DIR="${1}" +CACHE_DIR="${2}" +ENV_DIR="${3}" + +# The absolute path to the root of the buildpack. +BUILDPACK_DIR=$(cd "$(dirname "$(dirname "${BASH_SOURCE[0]}")")" && pwd) + +source "${BUILDPACK_DIR}/bin/utils" +source "${BUILDPACK_DIR}/lib/utils.sh" +source "${BUILDPACK_DIR}/lib/cache.sh" +source "${BUILDPACK_DIR}/lib/checks.sh" +source "${BUILDPACK_DIR}/lib/hooks.sh" +source "${BUILDPACK_DIR}/lib/metadata.sh" +source "${BUILDPACK_DIR}/lib/output.sh" +source "${BUILDPACK_DIR}/lib/package_manager.sh" +source "${BUILDPACK_DIR}/lib/pip.sh" +source "${BUILDPACK_DIR}/lib/pipenv.sh" +source "${BUILDPACK_DIR}/lib/poetry.sh" +source "${BUILDPACK_DIR}/lib/python_version.sh" +source "${BUILDPACK_DIR}/lib/python.sh" + +compile_start_time=$(nowms) + +# Initialise the buildpack metadata store. +# This is used to track state across builds (for cache invalidation and messaging when build +# configuration changes) and also so that `bin/report` can generate the build report. +meta_init "${CACHE_DIR}" "python" +meta_setup + +checks::ensure_supported_stack "${STACK:?Required env var STACK is not set}" +checks::warn_if_duplicate_python_buildpack "${BUILD_DIR}" + +# Prepend proper path for old-school virtualenv hackery. +# This may not be necessary. +export PATH=:/usr/local/bin:$PATH + +# Exported for use in subshells, such as the steps run via sub_env. +export BUILD_DIR CACHE_DIR ENV_DIR + +# Common Problem Warnings: +# This section creates a temporary file in which to stick the output of `pip install`. +# The `warnings` subscript then greps through this for common problems and guides +# the user towards resolution of known issues. +WARNINGS_LOG=$(mktemp) + +# Sanitize externally-provided environment variables: +# The following environment variables are either problematic or simply unnecessary +# for the buildpack to have knowledge of, so we unset them, to keep the environment +# as clean and pristine as possible. +unset PYTHONHOME PYTHONPATH + +# Import the warnings script, which contains the `pip install` user warning mechanisms +# (mentioned and explained above) +source "${BUILDPACK_DIR}/bin/warnings" + +# Make the directory in which we will create symlinks from the temporary build directory +# to `/app`. +# Symlinks are required, since Python is not a portable installation. +# More on this topic later. +mkdir -p /app/.heroku + +PROFILE_PATH="$BUILD_DIR/.profile.d/python.sh" +EXPORT_PATH="${BUILDPACK_DIR}/export" +GUNICORN_PROFILE_PATH="$BUILD_DIR/.profile.d/python.gunicorn.sh" +WEB_CONCURRENCY_PROFILE_PATH="$BUILD_DIR/.profile.d/WEB_CONCURRENCY.sh" +python_home='/app/.heroku/python' + +# NB: Python must be added to PATH using the symlinked `/app` location and not its actual location +# in BUILD_DIR, so that Python reports its location (via `sys.prefix`, `sys.executable` and others) +# using `/app` paths which will still work at run-time after relocation. Amongst other things, this +# ensures that the shebang lines in the entrypoint scripts of installed packages are correct. +export PATH="/app/.heroku/python/bin:${PATH}" +# Tell Python to not buffer it's stdin/stdout. +export PYTHONUNBUFFERED=1 +# Ensure Python uses a Unicode locale, to prevent the issues described in: +# https://github.com/docker-library/python/pull/570 +export LANG="en_US.UTF-8" +export C_INCLUDE_PATH="/app/.heroku/python/include${C_INCLUDE_PATH:+:${C_INCLUDE_PATH}}" +export CPLUS_INCLUDE_PATH="/app/.heroku/python/include${CPLUS_INCLUDE_PATH:+:${CPLUS_INCLUDE_PATH}}" +export LIBRARY_PATH="/app/.heroku/python/lib${LIBRARY_PATH:+:${LIBRARY_PATH}}" +export LD_LIBRARY_PATH="/app/.heroku/python/lib${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}" +export PKG_CONFIG_PATH="/app/.heroku/python/lib/pkg-config${PKG_CONFIG_PATH:+:${PKG_CONFIG_PATH}}" + +cd "$BUILD_DIR" + +# Runs a `bin/pre_compile` script if found in the app source, allowing build customisation. +hooks::run_hook "pre_compile" + +# This check must be after the pre_compile hook, so that we can check not only the original +# app source, but also that the hook hasn't written to '.heroku/python/' either. +checks::warn_if_existing_python_dir_present "${BUILD_DIR}" + +package_manager="$(package_manager::determine_package_manager "${BUILD_DIR}")" +meta_set "package_manager" "${package_manager}" + +cached_python_full_version="$(cache::cached_python_full_version "${CACHE_DIR}")" + +# We use the Bash 4.3+ `nameref` feature to pass back multiple values from this function +# without having to hardcode globals. See: https://stackoverflow.com/a/38997681 +python_version::read_requested_python_version "${BUILD_DIR}" "${package_manager}" "${cached_python_full_version}" requested_python_version python_version_origin +meta_set "python_version_requested" "${requested_python_version}" +meta_set "python_version_reason" "${python_version_origin}" + +# TODO: More strongly recommend specifying a Python version (eg switch the messaging to +# be a warning instead, after version resolution, and mention .python-version inline) +case "${python_version_origin}" in + default) + output::step "No Python version was specified. Using the buildpack default: Python ${requested_python_version}" + echo " To use a different version, see: https://devcenter.heroku.com/articles/python-runtimes" + ;; + cached) + output::step "No Python version was specified. Using the same major version as the last build: Python ${requested_python_version}" + echo " To use a different version, see: https://devcenter.heroku.com/articles/python-runtimes" + ;; + *) + output::step "Using Python ${requested_python_version} specified in ${python_version_origin}" + ;; +esac + +python_full_version="$(python_version::resolve_python_version "${requested_python_version}" "${python_version_origin}")" +python_major_version="${python_full_version%.*}" +meta_set "python_version" "${python_full_version}" +meta_set "python_version_major" "${python_major_version}" + +if [[ "${requested_python_version}" == "${python_full_version}" ]]; then + meta_set "python_version_pinned" "true" +else + meta_set "python_version_pinned" "false" +fi + +if [[ "${python_version_origin}" == "runtime.txt" ]]; then + output::warning <<-EOF + Warning: The runtime.txt file is deprecated. + + The runtime.txt file is deprecated since it has been replaced + by the more widely supported .python-version file: + https://devcenter.heroku.com/changelog-items/3141 + + Please delete your runtime.txt file and create a new file named: + .python-version + + Make sure to include the '.' at the start of the filename. + + In the new file, specify your app's Python version without + quotes or a 'python-' prefix. For example: + ${python_major_version} + + We strongly recommend that you use the major version form + instead of pinning to an exact version, since it will allow + your app to receive Python security updates. + + In the future support for runtime.txt will be removed and + this warning will be made an error. + EOF +fi + +python_version::warn_if_deprecated_major_version "${python_major_version}" "${python_version_origin}" +python_version::warn_if_patch_update_available "${python_full_version}" "${python_major_version}" "${python_version_origin}" + +cache::restore "${BUILD_DIR}" "${CACHE_DIR}" "${STACK}" "${cached_python_full_version}" "${python_full_version}" "${package_manager}" + +# The directory for the .profile.d scripts. +mkdir -p "$(dirname "$PROFILE_PATH")" + +# On Heroku CI, builds happen in `/app`. Otherwise, on the Heroku platform, +# they occur in a temp directory. Because Python is not portable, we must create +# symlinks to emulate that we are operating in `/app` during the build process. +# This is (hopefully obviously) because apps end up running from `/app` in production. +# Realpath is used to support use-cases where one of the locations is a symlink to the other. +# shellcheck disable=SC2312 # TODO: Invoke this command separately to avoid masking its return value. +if [[ "$(realpath "${BUILD_DIR}")" != "$(realpath /app)" ]]; then + # python expects to reside in /app, so set up symlinks + # we will not remove these later so subsequent buildpacks can still invoke it + ln -nsf "$BUILD_DIR/.heroku/python" /app/.heroku/python +fi + +python::install "${BUILD_DIR}" "${STACK}" "${python_full_version}" "${python_major_version}" "${python_version_origin}" + +# Install the package manager and related tools. +package_manager_install_start_time=$(nowms) +case "${package_manager}" in + pip) + pip::install_pip_setuptools_wheel "${python_home}" "${python_major_version}" + ;; + pipenv) + # TODO: Stop installing pip when using Pipenv. + pip::install_pip_setuptools_wheel "${python_home}" "${python_major_version}" + pipenv::install_pipenv + ;; + poetry) + poetry::install_poetry "${python_home}" "${python_major_version}" "${CACHE_DIR}" "${EXPORT_PATH}" + ;; + *) + utils::abort_internal_error "Unhandled package manager: ${package_manager}" + ;; +esac +meta_time "package_manager_install_duration" "${package_manager_install_start_time}" + +# SQLite3 support. +# Installs the sqlite3 dev headers and sqlite3 binary but not the +# libsqlite3-0 library since that exists in the base image. +# We skip this step on Python 3.13 or when using Poetry, as a first step towards removing this feature. +if [[ "${python_major_version}" == +(3.9|3.10|3.11|3.12) && "${package_manager}" != "poetry" ]]; then + install_sqlite_start_time=$(nowms) + source "${BUILDPACK_DIR}/bin/steps/sqlite3" + buildpack_sqlite3_install + meta_time "sqlite_install_duration" "${install_sqlite_start_time}" +fi + +# Install app dependencies. +dependencies_install_start_time=$(nowms) +case "${package_manager}" in + pip) + pip::install_dependencies + ;; + pipenv) + pipenv::install_dependencies + ;; + poetry) + poetry::install_dependencies + ;; + *) + utils::abort_internal_error "Unhandled package manager: ${package_manager}" + ;; +esac +meta_time "dependencies_install_duration" "${dependencies_install_start_time}" + +# Support for NLTK corpora. +nltk_downloader_start_time=$(nowms) +sub_env "${BUILDPACK_DIR}/bin/steps/nltk" +meta_time "nltk_downloader_duration" "${nltk_downloader_start_time}" + +# Django collectstatic support. +# The buildpack automatically runs collectstatic for Django applications. +collectstatic_start_time=$(nowms) +sub_env "${BUILDPACK_DIR}/bin/steps/collectstatic" +meta_time "django_collectstatic_duration" "${collectstatic_start_time}" + +# Programmatically create .profile.d script for application runtime environment variables. + +# Set the PATH to include Python / pip / pipenv / etc. +set_env PATH "\${HOME}/.heroku/python/bin:\${PATH}" +# Tell Python to run in unbuffered mode. +set_env PYTHONUNBUFFERED true +# Tell Python where it lives. +set_env PYTHONHOME "\${HOME}/.heroku/python" +# Set variables for C libraries. +set_env LIBRARY_PATH "\${HOME}/.heroku/python/lib\${LIBRARY_PATH:+:\${LIBRARY_PATH}}" +set_env LD_LIBRARY_PATH "\${HOME}/.heroku/python/lib\${LD_LIBRARY_PATH:+:\${LD_LIBRARY_PATH}}" +# Locale. +set_default_env LANG en_US.UTF-8 +# The Python hash seed is set to random. +set_default_env PYTHONHASHSEED random +# Tell Python to look for Python modules in the /app dir. Don't change this. +set_default_env PYTHONPATH "\${HOME}" + +# Python expects to be in /app, if at runtime, it is not, set +# up symlinks… this can occur when the subdir buildpack is used. +cat <>"$PROFILE_PATH" +if [[ \$HOME != "/app" ]]; then + mkdir -p /app/.heroku + ln -nsf "\$HOME/.heroku/python" /app/.heroku/python +fi +EOT + +# When dependencies are installed in editable mode, the package manager/build backend creates `.pth` +# (and related) files in site-packages, which contain absolute path references to the actual location +# of the packages. By default the Heroku build runs from a directory like `/tmp/build_`, which +# changes every build and also differs from the app location at runtime (`/app`). This means any build +# directory paths referenced in .pth and related files will no longer exist at runtime or during cached +# rebuilds, unless we rewrite the paths. +# +# Ideally, we would be able to rewrite all paths to use the `/app/.heroku/python/` symlink trick we use +# when invoking Python, since then the same path would work across the current build, runtime and cached +# rebuilds. However, this trick only works for paths under that directory (since it's not possible to +# symlink `/app` or other directories we don't own), and when apps use path-based editable dependencies +# the paths will be outside of that (such as a subdirectory of the app source, or even the root of the +# build directory). We also can't just rewrite all paths now ready for runtime, since other buildpacks +# might run after this one that make use of the editable dependencies. As such, we have to perform path +# rewriting for path-based editable dependencies at app boot instead. +# +# For VCS editable dependencies, we can use the symlink trick and so configure the repo checkout location +# as `/app/.heroku/python/src/`, which in theory should mean the `.pth` files use that path. However, +# some build backends (such as setuptools' PEP660 implementation) call realpath on it causing the +# `/tmp/build_*` location to be written instead, meaning VCS src paths need to be rewritten regardless. +# +# In addition to ensuring dependencies work for subsequent buildpacks and at runtime, they must also +# work for cached rebuilds. Most package managers will reinstall editable dependencies regardless on +# next install, which means we can avoid having to rewrite paths on cache restore from the old build +# directory to the new location (`/tmp/build_`). However, Pipenv has a bug when using +# PEP660 style editable VCS dependencies where it won't reinstall if it's missing (or in our case, the +# path has changed), which means we must make sure that VCS src paths stored in the cache do use the +# symlink path. See: https://github.com/pypa/pipenv/issues/6348 +# +# As such, we have to perform two rewrites: +# 1. At build time, of just the VCS editable paths (which we can safely change to /app paths early). +# 2. At runtime, to rewrite the remaining path-based editable dependency paths. +if [[ "${BUILD_DIR}" != "/app" ]]; then + find .heroku/python/lib/python*/site-packages/ -type f -and \( -name '*.egg-link' -or -name '*.pth' -or -name '__editable___*_finder.py' \) -exec sed -i -e "s#${BUILD_DIR}/.heroku/python#/app/.heroku/python#" {} \+ + cat <<-EOT >>"${PROFILE_PATH}" + find .heroku/python/lib/python*/site-packages/ -type f -and \( -name '*.egg-link' -or -name '*.pth' -or -name '__editable___*_finder.py' \) -exec sed -i -e 's#${BUILD_DIR}#/app#' {} \+ + EOT +fi + +# Install sane-default script for $WEB_CONCURRENCY and $FORWARDED_ALLOW_IPS. +cp "${BUILDPACK_DIR}/vendor/WEB_CONCURRENCY.sh" "$WEB_CONCURRENCY_PROFILE_PATH" +cp "${BUILDPACK_DIR}/vendor/python.gunicorn.sh" "$GUNICORN_PROFILE_PATH" + +# Runs a `bin/post_compile` script if found in the app source, allowing build customisation. +hooks::run_hook "post_compile" + +cache::save "${BUILD_DIR}" "${CACHE_DIR}" "${STACK}" "${python_full_version}" "${package_manager}" + +meta_time "total_duration" "${compile_start_time}" diff --git a/copy_resources.sh b/copy_resources.sh new file mode 100644 index 000000000000..ab0bf9ccb204 --- /dev/null +++ b/copy_resources.sh @@ -0,0 +1,7 @@ +#!/bin/bash +set -e + +rm -rf temp_publish_docker +mkdir temp_publish_docker +cp -r $FILES_TO_PACKAGE temp_publish_docker +ls diff --git a/credentials.go b/credentials.go new file mode 100644 index 000000000000..da8b594e7f89 --- /dev/null +++ b/credentials.go @@ -0,0 +1,186 @@ +package credentials + +import ( + "bufio" + "bytes" + "encoding/json" + "fmt" + "io" + "os" + "strings" +) + +// Credentials holds the information shared between docker and the credentials store. +type Credentials struct { + ServerURL string + Username string + Secret string +} + +// isValid checks the integrity of Credentials object such that no credentials lack +// a server URL or a username. +// It returns whether the credentials are valid and the error if it isn't. +// error values can be errCredentialsMissingServerURL or errCredentialsMissingUsername +func (c *Credentials) isValid() (bool, error) { + if len(c.ServerURL) == 0 { + return false, NewErrCredentialsMissingServerURL() + } + + if len(c.Username) == 0 { + return false, NewErrCredentialsMissingUsername() + } + + return true, nil +} + +// CredsLabel holds the way Docker credentials should be labeled as such in credentials stores that allow labelling. +// That label allows to filter out non-Docker credentials too at lookup/search in macOS keychain, +// Windows credentials manager and Linux libsecret. Default value is "Docker Credentials" +var CredsLabel = "Docker Credentials" + +// SetCredsLabel is a simple setter for CredsLabel +func SetCredsLabel(label string) { + CredsLabel = label +} + +// Serve initializes the credentials helper and parses the action argument. +// This function is designed to be called from a command line interface. +// It uses os.Args[1] as the key for the action. +// It uses os.Stdin as input and os.Stdout as output. +// This function terminates the program with os.Exit(1) if there is an error. +func Serve(helper Helper) { + var err error + if len(os.Args) != 2 { + err = fmt.Errorf("Usage: %s ", os.Args[0]) + } + + if err == nil { + err = HandleCommand(helper, os.Args[1], os.Stdin, os.Stdout) + } + + if err != nil { + fmt.Fprintf(os.Stdout, "%v\n", err) + os.Exit(1) + } +} + +// HandleCommand uses a helper and a key to run a credential action. +func HandleCommand(helper Helper, key string, in io.Reader, out io.Writer) error { + switch key { + case "store": + return Store(helper, in) + case "get": + return Get(helper, in, out) + case "erase": + return Erase(helper, in) + case "list": + return List(helper, out) + case "version": + return PrintVersion(out) + } + return fmt.Errorf("Unknown credential action `%s`", key) +} + +// Store uses a helper and an input reader to save credentials. +// The reader must contain the JSON serialization of a Credentials struct. +func Store(helper Helper, reader io.Reader) error { + scanner := bufio.NewScanner(reader) + + buffer := new(bytes.Buffer) + for scanner.Scan() { + buffer.Write(scanner.Bytes()) + } + + if err := scanner.Err(); err != nil && err != io.EOF { + return err + } + + var creds Credentials + if err := json.NewDecoder(buffer).Decode(&creds); err != nil { + return err + } + + if ok, err := creds.isValid(); !ok { + return err + } + + return helper.Add(&creds) +} + +// Get retrieves the credentials for a given server url. +// The reader must contain the server URL to search. +// The writer is used to write the JSON serialization of the credentials. +func Get(helper Helper, reader io.Reader, writer io.Writer) error { + scanner := bufio.NewScanner(reader) + + buffer := new(bytes.Buffer) + for scanner.Scan() { + buffer.Write(scanner.Bytes()) + } + + if err := scanner.Err(); err != nil && err != io.EOF { + return err + } + + serverURL := strings.TrimSpace(buffer.String()) + if len(serverURL) == 0 { + return NewErrCredentialsMissingServerURL() + } + + username, secret, err := helper.Get(serverURL) + if err != nil { + return err + } + + resp := Credentials{ + ServerURL: serverURL, + Username: username, + Secret: secret, + } + + buffer.Reset() + if err := json.NewEncoder(buffer).Encode(resp); err != nil { + return err + } + + fmt.Fprint(writer, buffer.String()) + return nil +} + +// Erase removes credentials from the store. +// The reader must contain the server URL to remove. +func Erase(helper Helper, reader io.Reader) error { + scanner := bufio.NewScanner(reader) + + buffer := new(bytes.Buffer) + for scanner.Scan() { + buffer.Write(scanner.Bytes()) + } + + if err := scanner.Err(); err != nil && err != io.EOF { + return err + } + + serverURL := strings.TrimSpace(buffer.String()) + if len(serverURL) == 0 { + return NewErrCredentialsMissingServerURL() + } + + return helper.Delete(serverURL) +} + +//List returns all the serverURLs of keys in +//the OS store as a list of strings +func List(helper Helper, writer io.Writer) error { + accts, err := helper.List() + if err != nil { + return err + } + return json.NewEncoder(writer).Encode(accts) +} + +//PrintVersion outputs the current version. +func PrintVersion(writer io.Writer) error { + fmt.Fprintln(writer, Version) + return nil +} diff --git a/debugRun.sh b/debugRun.sh new file mode 100644 index 000000000000..2bfe969c944e --- /dev/null +++ b/debugRun.sh @@ -0,0 +1,20 @@ +#!/bin/sh + +# Move to the Etherpad base directory. +MY_DIR=$(cd "${0%/*}" && pwd -P) || exit 1 +cd "${MY_DIR}/.." || exit 1 + +# Source constants and useful functions +. bin/functions.sh + +# Prepare the environment +bin/installDeps.sh || exit 1 + +echo "If you are new to debugging Node.js with Chrome DevTools, take a look at this page:" +echo "https://medium.com/@paul_irish/debugging-node-js-nightlies-with-chrome-devtools-7c4a1b95ae27" +echo "Open 'chrome://inspect' on Chrome to start debugging." + +cd src +# Use 0.0.0.0 to allow external connections to the debugger +# (ex: running Etherpad on a docker container). Use default port # (9229) +exec node --import tsx --inspect=0.0.0.0:9229 ./node/server.ts "$@" diff --git a/docker-compose.yaml b/docker-compose.yaml new file mode 100644 index 000000000000..f006b5370006 --- /dev/null +++ b/docker-compose.yaml @@ -0,0 +1,18 @@ +version: "3.7" +x-project-base: + &project-base + restart: always + networks: + - remixide + +networks: + remixide: + +services: + remixide: + <<: *project-base + image: remixproject/remix-ide:$TAG + container_name: remixide-${TAG} + ports: + - 8080:80 + - 65520:65520 diff --git a/dotnet-install.sh b/dotnet-install.sh new file mode 100644 index 000000000000..8330fa904634 --- /dev/null +++ b/dotnet-install.sh @@ -0,0 +1,1942 @@ +#!/usr/bin/env bash +# Copyright (c) .NET Foundation and contributors. All rights reserved. +# Licensed under the MIT license. See LICENSE file in the project root for full license information. +# + +# Stop script on NZEC +set -e +# Stop script if unbound variable found (use ${var:-} if intentional) +set -u +# By default cmd1 | cmd2 returns exit code of cmd2 regardless of cmd1 success +# This is causing it to fail +set -o pipefail + +# Use in the the functions: eval $invocation +invocation='say_verbose "Calling: ${yellow:-}${FUNCNAME[0]} ${green:-}$*${normal:-}"' + +# standard output may be used as a return value in the functions +# we need a way to write text on the screen in the functions so that +# it won't interfere with the return value. +# Exposing stream 3 as a pipe to standard output of the script itself +exec 3>&1 + +# Setup some colors to use. These need to work in fairly limited shells, like the Ubuntu Docker container where there are only 8 colors. +# See if stdout is a terminal +if [ -t 1 ] && command -v tput > /dev/null; then + # see if it supports colors + ncolors=$(tput colors || echo 0) + if [ -n "$ncolors" ] && [ $ncolors -ge 8 ]; then + bold="$(tput bold || echo)" + normal="$(tput sgr0 || echo)" + black="$(tput setaf 0 || echo)" + red="$(tput setaf 1 || echo)" + green="$(tput setaf 2 || echo)" + yellow="$(tput setaf 3 || echo)" + blue="$(tput setaf 4 || echo)" + magenta="$(tput setaf 5 || echo)" + cyan="$(tput setaf 6 || echo)" + white="$(tput setaf 7 || echo)" + fi +fi + +say_warning() { + printf "%b\n" "${yellow:-}dotnet_install: Warning: $1${normal:-}" >&3 +} + +say_err() { + printf "%b\n" "${red:-}dotnet_install: Error: $1${normal:-}" >&2 +} + +say() { + # using stream 3 (defined in the beginning) to not interfere with stdout of functions + # which may be used as return value + printf "%b\n" "${cyan:-}dotnet-install:${normal:-} $1" >&3 +} + +say_verbose() { + if [ "$verbose" = true ]; then + say "$1" + fi +} + +# This platform list is finite - if the SDK/Runtime has supported Linux distribution-specific assets, +# then and only then should the Linux distribution appear in this list. +# Adding a Linux distribution to this list does not imply distribution-specific support. +get_legacy_os_name_from_platform() { + eval $invocation + + platform="$1" + case "$platform" in + "centos.7") + echo "centos" + return 0 + ;; + "debian.8") + echo "debian" + return 0 + ;; + "debian.9") + echo "debian.9" + return 0 + ;; + "fedora.23") + echo "fedora.23" + return 0 + ;; + "fedora.24") + echo "fedora.24" + return 0 + ;; + "fedora.27") + echo "fedora.27" + return 0 + ;; + "fedora.28") + echo "fedora.28" + return 0 + ;; + "opensuse.13.2") + echo "opensuse.13.2" + return 0 + ;; + "opensuse.42.1") + echo "opensuse.42.1" + return 0 + ;; + "opensuse.42.3") + echo "opensuse.42.3" + return 0 + ;; + "rhel.7"*) + echo "rhel" + return 0 + ;; + "ubuntu.14.04") + echo "ubuntu" + return 0 + ;; + "ubuntu.16.04") + echo "ubuntu.16.04" + return 0 + ;; + "ubuntu.16.10") + echo "ubuntu.16.10" + return 0 + ;; + "ubuntu.18.04") + echo "ubuntu.18.04" + return 0 + ;; + "alpine.3.4.3") + echo "alpine" + return 0 + ;; + esac + return 1 +} + +get_legacy_os_name() { + eval $invocation + + local uname=$(uname) + if [ "$uname" = "Darwin" ]; then + echo "osx" + return 0 + elif [ -n "$runtime_id" ]; then + echo $(get_legacy_os_name_from_platform "${runtime_id%-*}" || echo "${runtime_id%-*}") + return 0 + else + if [ -e /etc/os-release ]; then + . /etc/os-release + os=$(get_legacy_os_name_from_platform "$ID${VERSION_ID:+.${VERSION_ID}}" || echo "") + if [ -n "$os" ]; then + echo "$os" + return 0 + fi + fi + fi + + say_verbose "Distribution specific OS name and version could not be detected: UName = $uname" + return 1 +} + +get_linux_platform_name() { + eval $invocation + + if [ -n "$runtime_id" ]; then + echo "${runtime_id%-*}" + return 0 + else + if [ -e /etc/os-release ]; then + . /etc/os-release + echo "$ID${VERSION_ID:+.${VERSION_ID}}" + return 0 + elif [ -e /etc/redhat-release ]; then + local redhatRelease=$(&1 || true) | grep -q musl +} + +get_current_os_name() { + eval $invocation + + local uname=$(uname) + if [ "$uname" = "Darwin" ]; then + echo "osx" + return 0 + elif [ "$uname" = "FreeBSD" ]; then + echo "freebsd" + return 0 + elif [ "$uname" = "Linux" ]; then + local linux_platform_name="" + linux_platform_name="$(get_linux_platform_name)" || true + + if [ "$linux_platform_name" = "rhel.6" ]; then + echo $linux_platform_name + return 0 + elif is_musl_based_distro; then + echo "linux-musl" + return 0 + elif [ "$linux_platform_name" = "linux-musl" ]; then + echo "linux-musl" + return 0 + else + echo "linux" + return 0 + fi + fi + + say_err "OS name could not be detected: UName = $uname" + return 1 +} + +machine_has() { + eval $invocation + + command -v "$1" > /dev/null 2>&1 + return $? +} + +check_min_reqs() { + local hasMinimum=false + if machine_has "curl"; then + hasMinimum=true + elif machine_has "wget"; then + hasMinimum=true + fi + + if [ "$hasMinimum" = "false" ]; then + say_err "curl (recommended) or wget are required to download dotnet. Install missing prerequisite to proceed." + return 1 + fi + return 0 +} + +# args: +# input - $1 +to_lowercase() { + #eval $invocation + + echo "$1" | tr '[:upper:]' '[:lower:]' + return 0 +} + +# args: +# input - $1 +remove_trailing_slash() { + #eval $invocation + + local input="${1:-}" + echo "${input%/}" + return 0 +} + +# args: +# input - $1 +remove_beginning_slash() { + #eval $invocation + + local input="${1:-}" + echo "${input#/}" + return 0 +} + +# args: +# root_path - $1 +# child_path - $2 - this parameter can be empty +combine_paths() { + eval $invocation + + # TODO: Consider making it work with any number of paths. For now: + if [ ! -z "${3:-}" ]; then + say_err "combine_paths: Function takes two parameters." + return 1 + fi + + local root_path="$(remove_trailing_slash "$1")" + local child_path="$(remove_beginning_slash "${2:-}")" + say_verbose "combine_paths: root_path=$root_path" + say_verbose "combine_paths: child_path=$child_path" + echo "$root_path/$child_path" + return 0 +} + +get_machine_architecture() { + eval $invocation + + if command -v uname > /dev/null; then + CPUName=$(uname -m) + case $CPUName in + armv1*|armv2*|armv3*|armv4*|armv5*|armv6*) + echo "armv6-or-below" + return 0 + ;; + armv*l) + echo "arm" + return 0 + ;; + aarch64|arm64) + if [ "$(getconf LONG_BIT)" -lt 64 ]; then + # This is 32-bit OS running on 64-bit CPU (for example Raspberry Pi OS) + echo "arm" + return 0 + fi + echo "arm64" + return 0 + ;; + s390x) + echo "s390x" + return 0 + ;; + ppc64le) + echo "ppc64le" + return 0 + ;; + loongarch64) + echo "loongarch64" + return 0 + ;; + riscv64) + echo "riscv64" + return 0 + ;; + powerpc|ppc) + echo "ppc" + return 0 + ;; + esac + fi + + # Always default to 'x64' + echo "x64" + return 0 +} + +# args: +# architecture - $1 +get_normalized_architecture_from_architecture() { + eval $invocation + + local architecture="$(to_lowercase "$1")" + + if [[ $architecture == \ ]]; then + machine_architecture="$(get_machine_architecture)" + if [[ "$machine_architecture" == "armv6-or-below" ]]; then + say_err "Architecture \`$machine_architecture\` not supported. If you think this is a bug, report it at https://github.com/dotnet/install-scripts/issues" + return 1 + fi + + echo $machine_architecture + return 0 + fi + + case "$architecture" in + amd64|x64) + echo "x64" + return 0 + ;; + arm) + echo "arm" + return 0 + ;; + arm64) + echo "arm64" + return 0 + ;; + s390x) + echo "s390x" + return 0 + ;; + ppc64le) + echo "ppc64le" + return 0 + ;; + loongarch64) + echo "loongarch64" + return 0 + ;; + esac + + say_err "Architecture \`$architecture\` not supported. If you think this is a bug, report it at https://github.com/dotnet/install-scripts/issues" + return 1 +} + +# args: +# version - $1 +# channel - $2 +# architecture - $3 +get_normalized_architecture_for_specific_sdk_version() { + eval $invocation + + local is_version_support_arm64="$(is_arm64_supported "$1")" + local is_channel_support_arm64="$(is_arm64_supported "$2")" + local architecture="$3"; + local osname="$(get_current_os_name)" + + if [ "$osname" == "osx" ] && [ "$architecture" == "arm64" ] && { [ "$is_version_support_arm64" = false ] || [ "$is_channel_support_arm64" = false ]; }; then + #check if rosetta is installed + if [ "$(/usr/bin/pgrep oahd >/dev/null 2>&1;echo $?)" -eq 0 ]; then + say_verbose "Changing user architecture from '$architecture' to 'x64' because .NET SDKs prior to version 6.0 do not support arm64." + echo "x64" + return 0; + else + say_err "Architecture \`$architecture\` is not supported for .NET SDK version \`$version\`. Please install Rosetta to allow emulation of the \`$architecture\` .NET SDK on this platform" + return 1 + fi + fi + + echo "$architecture" + return 0 +} + +# args: +# version or channel - $1 +is_arm64_supported() { + # Extract the major version by splitting on the dot + major_version="${1%%.*}" + + # Check if the major version is a valid number and less than 6 + case "$major_version" in + [0-9]*) + if [ "$major_version" -lt 6 ]; then + echo false + return 0 + fi + ;; + esac + + echo true + return 0 +} + +# args: +# user_defined_os - $1 +get_normalized_os() { + eval $invocation + + local osname="$(to_lowercase "$1")" + if [ ! -z "$osname" ]; then + case "$osname" in + osx | freebsd | rhel.6 | linux-musl | linux) + echo "$osname" + return 0 + ;; + macos) + osname='osx' + echo "$osname" + return 0 + ;; + *) + say_err "'$user_defined_os' is not a supported value for --os option, supported values are: osx, macos, linux, linux-musl, freebsd, rhel.6. If you think this is a bug, report it at https://github.com/dotnet/install-scripts/issues." + return 1 + ;; + esac + else + osname="$(get_current_os_name)" || return 1 + fi + echo "$osname" + return 0 +} + +# args: +# quality - $1 +get_normalized_quality() { + eval $invocation + + local quality="$(to_lowercase "$1")" + if [ ! -z "$quality" ]; then + case "$quality" in + daily | signed | validated | preview) + echo "$quality" + return 0 + ;; + ga) + #ga quality is available without specifying quality, so normalizing it to empty + return 0 + ;; + *) + say_err "'$quality' is not a supported value for --quality option. Supported values are: daily, signed, validated, preview, ga. If you think this is a bug, report it at https://github.com/dotnet/install-scripts/issues." + return 1 + ;; + esac + fi + return 0 +} + +# args: +# channel - $1 +get_normalized_channel() { + eval $invocation + + local channel="$(to_lowercase "$1")" + + if [[ $channel == current ]]; then + say_warning 'Value "Current" is deprecated for -Channel option. Use "STS" instead.' + fi + + if [[ $channel == release/* ]]; then + say_warning 'Using branch name with -Channel option is no longer supported with newer releases. Use -Quality option with a channel in X.Y format instead.'; + fi + + if [ ! -z "$channel" ]; then + case "$channel" in + lts) + echo "LTS" + return 0 + ;; + sts) + echo "STS" + return 0 + ;; + current) + echo "STS" + return 0 + ;; + *) + echo "$channel" + return 0 + ;; + esac + fi + + return 0 +} + +# args: +# runtime - $1 +get_normalized_product() { + eval $invocation + + local product="" + local runtime="$(to_lowercase "$1")" + if [[ "$runtime" == "dotnet" ]]; then + product="dotnet-runtime" + elif [[ "$runtime" == "aspnetcore" ]]; then + product="aspnetcore-runtime" + elif [ -z "$runtime" ]; then + product="dotnet-sdk" + fi + echo "$product" + return 0 +} + +# The version text returned from the feeds is a 1-line or 2-line string: +# For the SDK and the dotnet runtime (2 lines): +# Line 1: # commit_hash +# Line 2: # 4-part version +# For the aspnetcore runtime (1 line): +# Line 1: # 4-part version + +# args: +# version_text - stdin +get_version_from_latestversion_file_content() { + eval $invocation + + cat | tail -n 1 | sed 's/\r$//' + return 0 +} + +# args: +# install_root - $1 +# relative_path_to_package - $2 +# specific_version - $3 +is_dotnet_package_installed() { + eval $invocation + + local install_root="$1" + local relative_path_to_package="$2" + local specific_version="${3//[$'\t\r\n']}" + + local dotnet_package_path="$(combine_paths "$(combine_paths "$install_root" "$relative_path_to_package")" "$specific_version")" + say_verbose "is_dotnet_package_installed: dotnet_package_path=$dotnet_package_path" + + if [ -d "$dotnet_package_path" ]; then + return 0 + else + return 1 + fi +} + +# args: +# downloaded file - $1 +# remote_file_size - $2 +validate_remote_local_file_sizes() +{ + eval $invocation + + local downloaded_file="$1" + local remote_file_size="$2" + local file_size='' + + if [[ "$OSTYPE" == "linux-gnu"* ]]; then + file_size="$(stat -c '%s' "$downloaded_file")" + elif [[ "$OSTYPE" == "darwin"* ]]; then + # hardcode in order to avoid conflicts with GNU stat + file_size="$(/usr/bin/stat -f '%z' "$downloaded_file")" + fi + + if [ -n "$file_size" ]; then + say "Downloaded file size is $file_size bytes." + + if [ -n "$remote_file_size" ] && [ -n "$file_size" ]; then + if [ "$remote_file_size" -ne "$file_size" ]; then + say "The remote and local file sizes are not equal. The remote file size is $remote_file_size bytes and the local size is $file_size bytes. The local package may be corrupted." + else + say "The remote and local file sizes are equal." + fi + fi + + else + say "Either downloaded or local package size can not be measured. One of them may be corrupted." + fi +} + +# args: +# azure_feed - $1 +# channel - $2 +# normalized_architecture - $3 +get_version_from_latestversion_file() { + eval $invocation + + local azure_feed="$1" + local channel="$2" + local normalized_architecture="$3" + + local version_file_url=null + if [[ "$runtime" == "dotnet" ]]; then + version_file_url="$azure_feed/Runtime/$channel/latest.version" + elif [[ "$runtime" == "aspnetcore" ]]; then + version_file_url="$azure_feed/aspnetcore/Runtime/$channel/latest.version" + elif [ -z "$runtime" ]; then + version_file_url="$azure_feed/Sdk/$channel/latest.version" + else + say_err "Invalid value for \$runtime" + return 1 + fi + say_verbose "get_version_from_latestversion_file: latest url: $version_file_url" + + download "$version_file_url" || return $? + return 0 +} + +# args: +# json_file - $1 +parse_globaljson_file_for_version() { + eval $invocation + + local json_file="$1" + if [ ! -f "$json_file" ]; then + say_err "Unable to find \`$json_file\`" + return 1 + fi + + sdk_section=$(cat $json_file | tr -d "\r" | awk '/"sdk"/,/}/') + if [ -z "$sdk_section" ]; then + say_err "Unable to parse the SDK node in \`$json_file\`" + return 1 + fi + + sdk_list=$(echo $sdk_section | awk -F"[{}]" '{print $2}') + sdk_list=${sdk_list//[\" ]/} + sdk_list=${sdk_list//,/$'\n'} + + local version_info="" + while read -r line; do + IFS=: + while read -r key value; do + if [[ "$key" == "version" ]]; then + version_info=$value + fi + done <<< "$line" + done <<< "$sdk_list" + if [ -z "$version_info" ]; then + say_err "Unable to find the SDK:version node in \`$json_file\`" + return 1 + fi + + unset IFS; + echo "$version_info" + return 0 +} + +# args: +# azure_feed - $1 +# channel - $2 +# normalized_architecture - $3 +# version - $4 +# json_file - $5 +get_specific_version_from_version() { + eval $invocation + + local azure_feed="$1" + local channel="$2" + local normalized_architecture="$3" + local version="$(to_lowercase "$4")" + local json_file="$5" + + if [ -z "$json_file" ]; then + if [[ "$version" == "latest" ]]; then + local version_info + version_info="$(get_version_from_latestversion_file "$azure_feed" "$channel" "$normalized_architecture" false)" || return 1 + say_verbose "get_specific_version_from_version: version_info=$version_info" + echo "$version_info" | get_version_from_latestversion_file_content + return 0 + else + echo "$version" + return 0 + fi + else + local version_info + version_info="$(parse_globaljson_file_for_version "$json_file")" || return 1 + echo "$version_info" + return 0 + fi +} + +# args: +# azure_feed - $1 +# channel - $2 +# normalized_architecture - $3 +# specific_version - $4 +# normalized_os - $5 +construct_download_link() { + eval $invocation + + local azure_feed="$1" + local channel="$2" + local normalized_architecture="$3" + local specific_version="${4//[$'\t\r\n']}" + local specific_product_version="$(get_specific_product_version "$1" "$4")" + local osname="$5" + + local download_link=null + if [[ "$runtime" == "dotnet" ]]; then + download_link="$azure_feed/Runtime/$specific_version/dotnet-runtime-$specific_product_version-$osname-$normalized_architecture.tar.gz" + elif [[ "$runtime" == "aspnetcore" ]]; then + download_link="$azure_feed/aspnetcore/Runtime/$specific_version/aspnetcore-runtime-$specific_product_version-$osname-$normalized_architecture.tar.gz" + elif [ -z "$runtime" ]; then + download_link="$azure_feed/Sdk/$specific_version/dotnet-sdk-$specific_product_version-$osname-$normalized_architecture.tar.gz" + else + return 1 + fi + + echo "$download_link" + return 0 +} + +# args: +# azure_feed - $1 +# specific_version - $2 +# download link - $3 (optional) +get_specific_product_version() { + # If we find a 'productVersion.txt' at the root of any folder, we'll use its contents + # to resolve the version of what's in the folder, superseding the specified version. + # if 'productVersion.txt' is missing but download link is already available, product version will be taken from download link + eval $invocation + + local azure_feed="$1" + local specific_version="${2//[$'\t\r\n']}" + local package_download_link="" + if [ $# -gt 2 ]; then + local package_download_link="$3" + fi + local specific_product_version=null + + # Try to get the version number, using the productVersion.txt file located next to the installer file. + local download_links=($(get_specific_product_version_url "$azure_feed" "$specific_version" true "$package_download_link") + $(get_specific_product_version_url "$azure_feed" "$specific_version" false "$package_download_link")) + + for download_link in "${download_links[@]}" + do + say_verbose "Checking for the existence of $download_link" + + if machine_has "curl" + then + if ! specific_product_version=$(curl -s --fail "${download_link}${feed_credential}" 2>&1); then + continue + else + echo "${specific_product_version//[$'\t\r\n']}" + return 0 + fi + + elif machine_has "wget" + then + specific_product_version=$(wget -qO- "${download_link}${feed_credential}" 2>&1) + if [ $? = 0 ]; then + echo "${specific_product_version//[$'\t\r\n']}" + return 0 + fi + fi + done + + # Getting the version number with productVersion.txt has failed. Try parsing the download link for a version number. + say_verbose "Failed to get the version using productVersion.txt file. Download link will be parsed instead." + specific_product_version="$(get_product_specific_version_from_download_link "$package_download_link" "$specific_version")" + echo "${specific_product_version//[$'\t\r\n']}" + return 0 +} + +# args: +# azure_feed - $1 +# specific_version - $2 +# is_flattened - $3 +# download link - $4 (optional) +get_specific_product_version_url() { + eval $invocation + + local azure_feed="$1" + local specific_version="$2" + local is_flattened="$3" + local package_download_link="" + if [ $# -gt 3 ]; then + local package_download_link="$4" + fi + + local pvFileName="productVersion.txt" + if [ "$is_flattened" = true ]; then + if [ -z "$runtime" ]; then + pvFileName="sdk-productVersion.txt" + elif [[ "$runtime" == "dotnet" ]]; then + pvFileName="runtime-productVersion.txt" + else + pvFileName="$runtime-productVersion.txt" + fi + fi + + local download_link=null + + if [ -z "$package_download_link" ]; then + if [[ "$runtime" == "dotnet" ]]; then + download_link="$azure_feed/Runtime/$specific_version/${pvFileName}" + elif [[ "$runtime" == "aspnetcore" ]]; then + download_link="$azure_feed/aspnetcore/Runtime/$specific_version/${pvFileName}" + elif [ -z "$runtime" ]; then + download_link="$azure_feed/Sdk/$specific_version/${pvFileName}" + else + return 1 + fi + else + download_link="${package_download_link%/*}/${pvFileName}" + fi + + say_verbose "Constructed productVersion link: $download_link" + echo "$download_link" + return 0 +} + +# args: +# download link - $1 +# specific version - $2 +get_product_specific_version_from_download_link() +{ + eval $invocation + + local download_link="$1" + local specific_version="$2" + local specific_product_version="" + + if [ -z "$download_link" ]; then + echo "$specific_version" + return 0 + fi + + #get filename + filename="${download_link##*/}" + + #product specific version follows the product name + #for filename 'dotnet-sdk-3.1.404-linux-x64.tar.gz': the product version is 3.1.404 + IFS='-' + read -ra filename_elems <<< "$filename" + count=${#filename_elems[@]} + if [[ "$count" -gt 2 ]]; then + specific_product_version="${filename_elems[2]}" + else + specific_product_version=$specific_version + fi + unset IFS; + echo "$specific_product_version" + return 0 +} + +# args: +# azure_feed - $1 +# channel - $2 +# normalized_architecture - $3 +# specific_version - $4 +construct_legacy_download_link() { + eval $invocation + + local azure_feed="$1" + local channel="$2" + local normalized_architecture="$3" + local specific_version="${4//[$'\t\r\n']}" + + local distro_specific_osname + distro_specific_osname="$(get_legacy_os_name)" || return 1 + + local legacy_download_link=null + if [[ "$runtime" == "dotnet" ]]; then + legacy_download_link="$azure_feed/Runtime/$specific_version/dotnet-$distro_specific_osname-$normalized_architecture.$specific_version.tar.gz" + elif [ -z "$runtime" ]; then + legacy_download_link="$azure_feed/Sdk/$specific_version/dotnet-dev-$distro_specific_osname-$normalized_architecture.$specific_version.tar.gz" + else + return 1 + fi + + echo "$legacy_download_link" + return 0 +} + +get_user_install_path() { + eval $invocation + + if [ ! -z "${DOTNET_INSTALL_DIR:-}" ]; then + echo "$DOTNET_INSTALL_DIR" + else + echo "$HOME/.dotnet" + fi + return 0 +} + +# args: +# install_dir - $1 +resolve_installation_path() { + eval $invocation + + local install_dir=$1 + if [ "$install_dir" = "" ]; then + local user_install_path="$(get_user_install_path)" + say_verbose "resolve_installation_path: user_install_path=$user_install_path" + echo "$user_install_path" + return 0 + fi + + echo "$install_dir" + return 0 +} + +# args: +# relative_or_absolute_path - $1 +get_absolute_path() { + eval $invocation + + local relative_or_absolute_path=$1 + echo "$(cd "$(dirname "$1")" && pwd -P)/$(basename "$1")" + return 0 +} + +# args: +# override - $1 (boolean, true or false) +get_cp_options() { + eval $invocation + + local override="$1" + local override_switch="" + + if [ "$override" = false ]; then + override_switch="-n" + + # create temporary files to check if 'cp -u' is supported + tmp_dir="$(mktemp -d)" + tmp_file="$tmp_dir/testfile" + tmp_file2="$tmp_dir/testfile2" + + touch "$tmp_file" + + # use -u instead of -n if it's available + if cp -u "$tmp_file" "$tmp_file2" 2>/dev/null; then + override_switch="-u" + fi + + # clean up + rm -f "$tmp_file" "$tmp_file2" + rm -rf "$tmp_dir" + fi + + echo "$override_switch" +} + +# args: +# input_files - stdin +# root_path - $1 +# out_path - $2 +# override - $3 +copy_files_or_dirs_from_list() { + eval $invocation + + local root_path="$(remove_trailing_slash "$1")" + local out_path="$(remove_trailing_slash "$2")" + local override="$3" + local override_switch="$(get_cp_options "$override")" + + cat | uniq | while read -r file_path; do + local path="$(remove_beginning_slash "${file_path#$root_path}")" + local target="$out_path/$path" + if [ "$override" = true ] || (! ([ -d "$target" ] || [ -e "$target" ])); then + mkdir -p "$out_path/$(dirname "$path")" + if [ -d "$target" ]; then + rm -rf "$target" + fi + cp -R $override_switch "$root_path/$path" "$target" + fi + done +} + +# args: +# zip_uri - $1 +get_remote_file_size() { + local zip_uri="$1" + + if machine_has "curl"; then + file_size=$(curl -sI "$zip_uri" | grep -i content-length | awk '{ num = $2 + 0; print num }') + elif machine_has "wget"; then + file_size=$(wget --spider --server-response -O /dev/null "$zip_uri" 2>&1 | grep -i 'Content-Length:' | awk '{ num = $2 + 0; print num }') + else + say "Neither curl nor wget is available on this system." + return + fi + + if [ -n "$file_size" ]; then + say "Remote file $zip_uri size is $file_size bytes." + echo "$file_size" + else + say_verbose "Content-Length header was not extracted for $zip_uri." + echo "" + fi +} + +# args: +# zip_path - $1 +# out_path - $2 +# remote_file_size - $3 +extract_dotnet_package() { + eval $invocation + + local zip_path="$1" + local out_path="$2" + local remote_file_size="$3" + + local temp_out_path="$(mktemp -d "$temporary_file_template")" + + local failed=false + tar -xzf "$zip_path" -C "$temp_out_path" > /dev/null || failed=true + + local folders_with_version_regex='^.*/[0-9]+\.[0-9]+[^/]+/' + find "$temp_out_path" -type f | grep -Eo "$folders_with_version_regex" | sort | copy_files_or_dirs_from_list "$temp_out_path" "$out_path" false + find "$temp_out_path" -type f | grep -Ev "$folders_with_version_regex" | copy_files_or_dirs_from_list "$temp_out_path" "$out_path" "$override_non_versioned_files" + + validate_remote_local_file_sizes "$zip_path" "$remote_file_size" + + rm -rf "$temp_out_path" + if [ -z ${keep_zip+x} ]; then + rm -f "$zip_path" && say_verbose "Temporary archive file $zip_path was removed" + fi + + if [ "$failed" = true ]; then + say_err "Extraction failed" + return 1 + fi + return 0 +} + +# args: +# remote_path - $1 +# disable_feed_credential - $2 +get_http_header() +{ + eval $invocation + local remote_path="$1" + local disable_feed_credential="$2" + + local failed=false + local response + if machine_has "curl"; then + get_http_header_curl $remote_path $disable_feed_credential || failed=true + elif machine_has "wget"; then + get_http_header_wget $remote_path $disable_feed_credential || failed=true + else + failed=true + fi + if [ "$failed" = true ]; then + say_verbose "Failed to get HTTP header: '$remote_path'." + return 1 + fi + return 0 +} + +# args: +# remote_path - $1 +# disable_feed_credential - $2 +get_http_header_curl() { + eval $invocation + local remote_path="$1" + local disable_feed_credential="$2" + + remote_path_with_credential="$remote_path" + if [ "$disable_feed_credential" = false ]; then + remote_path_with_credential+="$feed_credential" + fi + + curl_options="-I -sSL --retry 5 --retry-delay 2 --connect-timeout 15 " + curl $curl_options "$remote_path_with_credential" 2>&1 || return 1 + return 0 +} + +# args: +# remote_path - $1 +# disable_feed_credential - $2 +get_http_header_wget() { + eval $invocation + local remote_path="$1" + local disable_feed_credential="$2" + local wget_options="-q -S --spider --tries 5 " + + local wget_options_extra='' + + # Test for options that aren't supported on all wget implementations. + if [[ $(wget -h 2>&1 | grep -E 'waitretry|connect-timeout') ]]; then + wget_options_extra="--waitretry 2 --connect-timeout 15 " + else + say "wget extra options are unavailable for this environment" + fi + + remote_path_with_credential="$remote_path" + if [ "$disable_feed_credential" = false ]; then + remote_path_with_credential+="$feed_credential" + fi + + wget $wget_options $wget_options_extra "$remote_path_with_credential" 2>&1 + + return $? +} + +# args: +# remote_path - $1 +# [out_path] - $2 - stdout if not provided +download() { + eval $invocation + + local remote_path="$1" + local out_path="${2:-}" + + if [[ "$remote_path" != "http"* ]]; then + cp "$remote_path" "$out_path" + return $? + fi + + local failed=false + local attempts=0 + while [ $attempts -lt 3 ]; do + attempts=$((attempts+1)) + failed=false + if machine_has "curl"; then + downloadcurl "$remote_path" "$out_path" || failed=true + elif machine_has "wget"; then + downloadwget "$remote_path" "$out_path" || failed=true + else + say_err "Missing dependency: neither curl nor wget was found." + exit 1 + fi + + if [ "$failed" = false ] || [ $attempts -ge 3 ] || { [ ! -z $http_code ] && [ $http_code = "404" ]; }; then + break + fi + + say "Download attempt #$attempts has failed: $http_code $download_error_msg" + say "Attempt #$((attempts+1)) will start in $((attempts*10)) seconds." + sleep $((attempts*10)) + done + + if [ "$failed" = true ]; then + say_verbose "Download failed: $remote_path" + return 1 + fi + return 0 +} + +# Updates global variables $http_code and $download_error_msg +downloadcurl() { + eval $invocation + unset http_code + unset download_error_msg + local remote_path="$1" + local out_path="${2:-}" + # Append feed_credential as late as possible before calling curl to avoid logging feed_credential + # Avoid passing URI with credentials to functions: note, most of them echoing parameters of invocation in verbose output. + local remote_path_with_credential="${remote_path}${feed_credential}" + local curl_options="--retry 20 --retry-delay 2 --connect-timeout 15 -sSL -f --create-dirs " + local curl_exit_code=0; + if [ -z "$out_path" ]; then + curl $curl_options "$remote_path_with_credential" 2>&1 + curl_exit_code=$? + else + curl $curl_options -o "$out_path" "$remote_path_with_credential" 2>&1 + curl_exit_code=$? + fi + + if [ $curl_exit_code -gt 0 ]; then + download_error_msg="Unable to download $remote_path." + # Check for curl timeout codes + if [[ $curl_exit_code == 7 || $curl_exit_code == 28 ]]; then + download_error_msg+=" Failed to reach the server: connection timeout." + else + local disable_feed_credential=false + local response=$(get_http_header_curl $remote_path $disable_feed_credential) + http_code=$( echo "$response" | awk '/^HTTP/{print $2}' | tail -1 ) + if [[ ! -z $http_code && $http_code != 2* ]]; then + download_error_msg+=" Returned HTTP status code: $http_code." + fi + fi + say_verbose "$download_error_msg" + return 1 + fi + return 0 +} + + +# Updates global variables $http_code and $download_error_msg +downloadwget() { + eval $invocation + unset http_code + unset download_error_msg + local remote_path="$1" + local out_path="${2:-}" + # Append feed_credential as late as possible before calling wget to avoid logging feed_credential + local remote_path_with_credential="${remote_path}${feed_credential}" + local wget_options="--tries 20 " + + local wget_options_extra='' + local wget_result='' + + # Test for options that aren't supported on all wget implementations. + if [[ $(wget -h 2>&1 | grep -E 'waitretry|connect-timeout') ]]; then + wget_options_extra="--waitretry 2 --connect-timeout 15 " + else + say "wget extra options are unavailable for this environment" + fi + + if [ -z "$out_path" ]; then + wget -q $wget_options $wget_options_extra -O - "$remote_path_with_credential" 2>&1 + wget_result=$? + else + wget $wget_options $wget_options_extra -O "$out_path" "$remote_path_with_credential" 2>&1 + wget_result=$? + fi + + if [[ $wget_result != 0 ]]; then + local disable_feed_credential=false + local response=$(get_http_header_wget $remote_path $disable_feed_credential) + http_code=$( echo "$response" | awk '/^ HTTP/{print $2}' | tail -1 ) + download_error_msg="Unable to download $remote_path." + if [[ ! -z $http_code && $http_code != 2* ]]; then + download_error_msg+=" Returned HTTP status code: $http_code." + # wget exit code 4 stands for network-issue + elif [[ $wget_result == 4 ]]; then + download_error_msg+=" Failed to reach the server: connection timeout." + fi + say_verbose "$download_error_msg" + return 1 + fi + + return 0 +} + +extract_stem() { + local url="$1" + # extract the protocol + proto="$(echo $1 | grep :// | sed -e's,^\(.*://\).*,\1,g')" + # remove the protocol + url="${1/$proto/}" + # extract the path (if any) - since we know all of our feeds have a first path segment, we can skip the first one. otherwise we'd use -f2- to get the full path + full_path="$(echo $url | grep / | cut -d/ -f2-)" + path="$(echo $full_path | cut -d/ -f2-)" + echo $path +} + +check_url_exists() { + eval $invocation + local url="$1" + + local code="" + if machine_has "curl" + then + code=$(curl --head -o /dev/null -w "%{http_code}" -s --fail "$url"); + elif machine_has "wget" + then + # get the http response, grab the status code + server_response=$(wget -qO- --method=HEAD --server-response "$url" 2>&1) + code=$(echo "$server_response" | grep "HTTP/" | awk '{print $2}') + fi + if [ $code = "200" ]; then + return 0 + else + return 1 + fi +} + +sanitize_redirect_url() { + eval $invocation + + local url_stem + url_stem=$(extract_stem "$1") + say_verbose "Checking configured feeds for the asset at ${yellow:-}$url_stem${normal:-}" + + for feed in "${feeds[@]}" + do + local trial_url="$feed/$url_stem" + say_verbose "Checking ${yellow:-}$trial_url${normal:-}" + if check_url_exists "$trial_url"; then + say_verbose "Found a match at ${yellow:-}$trial_url${normal:-}" + echo "$trial_url" + return 0 + else + say_verbose "No match at ${yellow:-}$trial_url${normal:-}" + fi + done + return 1 +} + +get_download_link_from_aka_ms() { + eval $invocation + + #quality is not supported for LTS or STS channel + #STS maps to current + if [[ ! -z "$normalized_quality" && ("$normalized_channel" == "LTS" || "$normalized_channel" == "STS") ]]; then + normalized_quality="" + say_warning "Specifying quality for STS or LTS channel is not supported, the quality will be ignored." + fi + + say_verbose "Retrieving primary payload URL from aka.ms for channel: '$normalized_channel', quality: '$normalized_quality', product: '$normalized_product', os: '$normalized_os', architecture: '$normalized_architecture'." + + #construct aka.ms link + aka_ms_link="https://aka.ms/dotnet" + if [ "$internal" = true ]; then + aka_ms_link="$aka_ms_link/internal" + fi + aka_ms_link="$aka_ms_link/$normalized_channel" + if [[ ! -z "$normalized_quality" ]]; then + aka_ms_link="$aka_ms_link/$normalized_quality" + fi + aka_ms_link="$aka_ms_link/$normalized_product-$normalized_os-$normalized_architecture.tar.gz" + say_verbose "Constructed aka.ms link: '$aka_ms_link'." + + #get HTTP response + #do not pass credentials as a part of the $aka_ms_link and do not apply credentials in the get_http_header function + #otherwise the redirect link would have credentials as well + #it would result in applying credentials twice to the resulting link and thus breaking it, and in echoing credentials to the output as a part of redirect link + disable_feed_credential=true + response="$(get_http_header $aka_ms_link $disable_feed_credential)" + + say_verbose "Received response: $response" + # Get results of all the redirects. + http_codes=$( echo "$response" | awk '$1 ~ /^HTTP/ {print $2}' ) + # They all need to be 301, otherwise some links are broken (except for the last, which is not a redirect but 200 or 404). + broken_redirects=$( echo "$http_codes" | sed '$d' | grep -v '301' ) + # The response may end without final code 2xx/4xx/5xx somehow, e.g. network restrictions on www.bing.com causes redirecting to bing.com fails with connection refused. + # In this case it should not exclude the last. + last_http_code=$( echo "$http_codes" | tail -n 1 ) + if ! [[ $last_http_code =~ ^(2|4|5)[0-9][0-9]$ ]]; then + broken_redirects=$( echo "$http_codes" | grep -v '301' ) + fi + + # All HTTP codes are 301 (Moved Permanently), the redirect link exists. + if [[ -z "$broken_redirects" ]]; then + aka_ms_download_link=$( echo "$response" | awk '$1 ~ /^Location/{print $2}' | tail -1 | tr -d '\r') + + if [[ -z "$aka_ms_download_link" ]]; then + say_verbose "The aka.ms link '$aka_ms_link' is not valid: failed to get redirect location." + return 1 + fi + + sanitized_redirect_url=$(sanitize_redirect_url "$aka_ms_download_link") + if [[ -n "$sanitized_redirect_url" ]]; then + aka_ms_download_link="$sanitized_redirect_url" + fi + + say_verbose "The redirect location retrieved: '$aka_ms_download_link'." + return 0 + else + say_verbose "The aka.ms link '$aka_ms_link' is not valid: received HTTP code: $(echo "$broken_redirects" | paste -sd "," -)." + return 1 + fi +} + +get_feeds_to_use() +{ + feeds=( + "https://builds.dotnet.microsoft.com/dotnet" + "https://ci.dot.net/public" + ) + + if [[ -n "$azure_feed" ]]; then + feeds=("$azure_feed") + fi + + if [[ -n "$uncached_feed" ]]; then + feeds=("$uncached_feed") + fi +} + +# THIS FUNCTION MAY EXIT (if the determined version is already installed). +generate_download_links() { + + download_links=() + specific_versions=() + effective_versions=() + link_types=() + + # If generate_akams_links returns false, no fallback to old links. Just terminate. + # This function may also 'exit' (if the determined version is already installed). + generate_akams_links || return + + # Check other feeds only if we haven't been able to find an aka.ms link. + if [[ "${#download_links[@]}" -lt 1 ]]; then + for feed in ${feeds[@]} + do + # generate_regular_links may also 'exit' (if the determined version is already installed). + generate_regular_links $feed || return + done + fi + + if [[ "${#download_links[@]}" -eq 0 ]]; then + say_err "Failed to resolve the exact version number." + return 1 + fi + + say_verbose "Generated ${#download_links[@]} links." + for link_index in ${!download_links[@]} + do + say_verbose "Link $link_index: ${link_types[$link_index]}, ${effective_versions[$link_index]}, ${download_links[$link_index]}" + done +} + +# THIS FUNCTION MAY EXIT (if the determined version is already installed). +generate_akams_links() { + local valid_aka_ms_link=true; + + normalized_version="$(to_lowercase "$version")" + if [[ "$normalized_version" != "latest" ]] && [ -n "$normalized_quality" ]; then + say_err "Quality and Version options are not allowed to be specified simultaneously. See https://learn.microsoft.com/dotnet/core/tools/dotnet-install-script#options for details." + return 1 + fi + + if [[ -n "$json_file" || "$normalized_version" != "latest" ]]; then + # aka.ms links are not needed when exact version is specified via command or json file + return + fi + + get_download_link_from_aka_ms || valid_aka_ms_link=false + + if [[ "$valid_aka_ms_link" == true ]]; then + say_verbose "Retrieved primary payload URL from aka.ms link: '$aka_ms_download_link'." + say_verbose "Downloading using legacy url will not be attempted." + + download_link=$aka_ms_download_link + + #get version from the path + IFS='/' + read -ra pathElems <<< "$download_link" + count=${#pathElems[@]} + specific_version="${pathElems[count-2]}" + unset IFS; + say_verbose "Version: '$specific_version'." + + #Retrieve effective version + effective_version="$(get_specific_product_version "$azure_feed" "$specific_version" "$download_link")" + + # Add link info to arrays + download_links+=($download_link) + specific_versions+=($specific_version) + effective_versions+=($effective_version) + link_types+=("aka.ms") + + # Check if the SDK version is already installed. + if [[ "$dry_run" != true ]] && is_dotnet_package_installed "$install_root" "$asset_relative_path" "$effective_version"; then + say "$asset_name with version '$effective_version' is already installed." + exit 0 + fi + + return 0 + fi + + # if quality is specified - exit with error - there is no fallback approach + if [ ! -z "$normalized_quality" ]; then + say_err "Failed to locate the latest version in the channel '$normalized_channel' with '$normalized_quality' quality for '$normalized_product', os: '$normalized_os', architecture: '$normalized_architecture'." + say_err "Refer to: https://aka.ms/dotnet-os-lifecycle for information on .NET Core support." + return 1 + fi + say_verbose "Falling back to latest.version file approach." +} + +# THIS FUNCTION MAY EXIT (if the determined version is already installed) +# args: +# feed - $1 +generate_regular_links() { + local feed="$1" + local valid_legacy_download_link=true + + specific_version=$(get_specific_version_from_version "$feed" "$channel" "$normalized_architecture" "$version" "$json_file") || specific_version='0' + + if [[ "$specific_version" == '0' ]]; then + say_verbose "Failed to resolve the specific version number using feed '$feed'" + return + fi + + effective_version="$(get_specific_product_version "$feed" "$specific_version")" + say_verbose "specific_version=$specific_version" + + download_link="$(construct_download_link "$feed" "$channel" "$normalized_architecture" "$specific_version" "$normalized_os")" + say_verbose "Constructed primary named payload URL: $download_link" + + # Add link info to arrays + download_links+=($download_link) + specific_versions+=($specific_version) + effective_versions+=($effective_version) + link_types+=("primary") + + legacy_download_link="$(construct_legacy_download_link "$feed" "$channel" "$normalized_architecture" "$specific_version")" || valid_legacy_download_link=false + + if [ "$valid_legacy_download_link" = true ]; then + say_verbose "Constructed legacy named payload URL: $legacy_download_link" + + download_links+=($legacy_download_link) + specific_versions+=($specific_version) + effective_versions+=($effective_version) + link_types+=("legacy") + else + legacy_download_link="" + say_verbose "Could not construct a legacy_download_link; omitting..." + fi + + # Check if the SDK version is already installed. + if [[ "$dry_run" != true ]] && is_dotnet_package_installed "$install_root" "$asset_relative_path" "$effective_version"; then + say "$asset_name with version '$effective_version' is already installed." + exit 0 + fi +} + +print_dry_run() { + + say "Payload URLs:" + + for link_index in "${!download_links[@]}" + do + say "URL #$link_index - ${link_types[$link_index]}: ${download_links[$link_index]}" + done + + resolved_version=${specific_versions[0]} + repeatable_command="./$script_name --version "\""$resolved_version"\"" --install-dir "\""$install_root"\"" --architecture "\""$normalized_architecture"\"" --os "\""$normalized_os"\""" + + if [ ! -z "$normalized_quality" ]; then + repeatable_command+=" --quality "\""$normalized_quality"\""" + fi + + if [[ "$runtime" == "dotnet" ]]; then + repeatable_command+=" --runtime "\""dotnet"\""" + elif [[ "$runtime" == "aspnetcore" ]]; then + repeatable_command+=" --runtime "\""aspnetcore"\""" + fi + + repeatable_command+="$non_dynamic_parameters" + + if [ -n "$feed_credential" ]; then + repeatable_command+=" --feed-credential "\"""\""" + fi + + say "Repeatable invocation: $repeatable_command" +} + +calculate_vars() { + eval $invocation + + script_name=$(basename "$0") + normalized_architecture="$(get_normalized_architecture_from_architecture "$architecture")" + say_verbose "Normalized architecture: '$normalized_architecture'." + normalized_os="$(get_normalized_os "$user_defined_os")" + say_verbose "Normalized OS: '$normalized_os'." + normalized_quality="$(get_normalized_quality "$quality")" + say_verbose "Normalized quality: '$normalized_quality'." + normalized_channel="$(get_normalized_channel "$channel")" + say_verbose "Normalized channel: '$normalized_channel'." + normalized_product="$(get_normalized_product "$runtime")" + say_verbose "Normalized product: '$normalized_product'." + install_root="$(resolve_installation_path "$install_dir")" + say_verbose "InstallRoot: '$install_root'." + + normalized_architecture="$(get_normalized_architecture_for_specific_sdk_version "$version" "$normalized_channel" "$normalized_architecture")" + + if [[ "$runtime" == "dotnet" ]]; then + asset_relative_path="shared/Microsoft.NETCore.App" + asset_name=".NET Core Runtime" + elif [[ "$runtime" == "aspnetcore" ]]; then + asset_relative_path="shared/Microsoft.AspNetCore.App" + asset_name="ASP.NET Core Runtime" + elif [ -z "$runtime" ]; then + asset_relative_path="sdk" + asset_name=".NET Core SDK" + fi + + get_feeds_to_use +} + +install_dotnet() { + eval $invocation + local download_failed=false + local download_completed=false + local remote_file_size=0 + + mkdir -p "$install_root" + zip_path="${zip_path:-$(mktemp "$temporary_file_template")}" + say_verbose "Archive path: $zip_path" + + for link_index in "${!download_links[@]}" + do + download_link="${download_links[$link_index]}" + specific_version="${specific_versions[$link_index]}" + effective_version="${effective_versions[$link_index]}" + link_type="${link_types[$link_index]}" + + say "Attempting to download using $link_type link $download_link" + + # The download function will set variables $http_code and $download_error_msg in case of failure. + download_failed=false + download "$download_link" "$zip_path" 2>&1 || download_failed=true + + if [ "$download_failed" = true ]; then + case $http_code in + 404) + say "The resource at $link_type link '$download_link' is not available." + ;; + *) + say "Failed to download $link_type link '$download_link': $http_code $download_error_msg" + ;; + esac + rm -f "$zip_path" 2>&1 && say_verbose "Temporary archive file $zip_path was removed" + else + download_completed=true + break + fi + done + + if [[ "$download_completed" == false ]]; then + say_err "Could not find \`$asset_name\` with version = $specific_version" + say_err "Refer to: https://aka.ms/dotnet-os-lifecycle for information on .NET Core support" + return 1 + fi + + remote_file_size="$(get_remote_file_size "$download_link")" + + say "Extracting archive from $download_link" + extract_dotnet_package "$zip_path" "$install_root" "$remote_file_size" || return 1 + + # Check if the SDK version is installed; if not, fail the installation. + # if the version contains "RTM" or "servicing"; check if a 'release-type' SDK version is installed. + if [[ $specific_version == *"rtm"* || $specific_version == *"servicing"* ]]; then + IFS='-' + read -ra verArr <<< "$specific_version" + release_version="${verArr[0]}" + unset IFS; + say_verbose "Checking installation: version = $release_version" + if is_dotnet_package_installed "$install_root" "$asset_relative_path" "$release_version"; then + say "Installed version is $effective_version" + return 0 + fi + fi + + # Check if the standard SDK version is installed. + say_verbose "Checking installation: version = $effective_version" + if is_dotnet_package_installed "$install_root" "$asset_relative_path" "$effective_version"; then + say "Installed version is $effective_version" + return 0 + fi + + # Version verification failed. More likely something is wrong either with the downloaded content or with the verification algorithm. + say_err "Failed to verify the version of installed \`$asset_name\`.\nInstallation source: $download_link.\nInstallation location: $install_root.\nReport the bug at https://github.com/dotnet/install-scripts/issues." + say_err "\`$asset_name\` with version = $effective_version failed to install with an error." + return 1 +} + +args=("$@") + +local_version_file_relative_path="/.version" +bin_folder_relative_path="" +temporary_file_template="${TMPDIR:-/tmp}/dotnet.XXXXXXXXX" + +channel="LTS" +version="Latest" +json_file="" +install_dir="" +architecture="" +dry_run=false +no_path=false +azure_feed="" +uncached_feed="" +feed_credential="" +verbose=false +runtime="" +runtime_id="" +quality="" +internal=false +override_non_versioned_files=true +non_dynamic_parameters="" +user_defined_os="" + +while [ $# -ne 0 ] +do + name="$1" + case "$name" in + -c|--channel|-[Cc]hannel) + shift + channel="$1" + ;; + -v|--version|-[Vv]ersion) + shift + version="$1" + ;; + -q|--quality|-[Qq]uality) + shift + quality="$1" + ;; + --internal|-[Ii]nternal) + internal=true + non_dynamic_parameters+=" $name" + ;; + -i|--install-dir|-[Ii]nstall[Dd]ir) + shift + install_dir="$1" + ;; + --arch|--architecture|-[Aa]rch|-[Aa]rchitecture) + shift + architecture="$1" + ;; + --os|-[Oo][SS]) + shift + user_defined_os="$1" + ;; + --shared-runtime|-[Ss]hared[Rr]untime) + say_warning "The --shared-runtime flag is obsolete and may be removed in a future version of this script. The recommended usage is to specify '--runtime dotnet'." + if [ -z "$runtime" ]; then + runtime="dotnet" + fi + ;; + --runtime|-[Rr]untime) + shift + runtime="$1" + if [[ "$runtime" != "dotnet" ]] && [[ "$runtime" != "aspnetcore" ]]; then + say_err "Unsupported value for --runtime: '$1'. Valid values are 'dotnet' and 'aspnetcore'." + if [[ "$runtime" == "windowsdesktop" ]]; then + say_err "WindowsDesktop archives are manufactured for Windows platforms only." + fi + exit 1 + fi + ;; + --dry-run|-[Dd]ry[Rr]un) + dry_run=true + ;; + --no-path|-[Nn]o[Pp]ath) + no_path=true + non_dynamic_parameters+=" $name" + ;; + --verbose|-[Vv]erbose) + verbose=true + non_dynamic_parameters+=" $name" + ;; + --azure-feed|-[Aa]zure[Ff]eed) + shift + azure_feed="$1" + non_dynamic_parameters+=" $name "\""$1"\""" + ;; + --uncached-feed|-[Uu]ncached[Ff]eed) + shift + uncached_feed="$1" + non_dynamic_parameters+=" $name "\""$1"\""" + ;; + --feed-credential|-[Ff]eed[Cc]redential) + shift + feed_credential="$1" + #feed_credential should start with "?", for it to be added to the end of the link. + #adding "?" at the beginning of the feed_credential if needed. + [[ -z "$(echo $feed_credential)" ]] || [[ $feed_credential == \?* ]] || feed_credential="?$feed_credential" + ;; + --runtime-id|-[Rr]untime[Ii]d) + shift + runtime_id="$1" + non_dynamic_parameters+=" $name "\""$1"\""" + say_warning "Use of --runtime-id is obsolete and should be limited to the versions below 2.1. To override architecture, use --architecture option instead. To override OS, use --os option instead." + ;; + --jsonfile|-[Jj][Ss]on[Ff]ile) + shift + json_file="$1" + ;; + --skip-non-versioned-files|-[Ss]kip[Nn]on[Vv]ersioned[Ff]iles) + override_non_versioned_files=false + non_dynamic_parameters+=" $name" + ;; + --keep-zip|-[Kk]eep[Zz]ip) + keep_zip=true + non_dynamic_parameters+=" $name" + ;; + --zip-path|-[Zz]ip[Pp]ath) + shift + zip_path="$1" + ;; + -?|--?|-h|--help|-[Hh]elp) + script_name="dotnet-install.sh" + echo ".NET Tools Installer" + echo "Usage:" + echo " # Install a .NET SDK of a given Quality from a given Channel" + echo " $script_name [-c|--channel ] [-q|--quality ]" + echo " # Install a .NET SDK of a specific public version" + echo " $script_name [-v|--version ]" + echo " $script_name -h|-?|--help" + echo "" + echo "$script_name is a simple command line interface for obtaining dotnet cli." + echo " Note that the intended use of this script is for Continuous Integration (CI) scenarios, where:" + echo " - The SDK needs to be installed without user interaction and without admin rights." + echo " - The SDK installation doesn't need to persist across multiple CI runs." + echo " To set up a development environment or to run apps, use installers rather than this script. Visit https://dotnet.microsoft.com/download to get the installer." + echo "" + echo "Options:" + echo " -c,--channel Download from the channel specified, Defaults to \`$channel\`." + echo " -Channel" + echo " Possible values:" + echo " - STS - the most recent Standard Term Support release" + echo " - LTS - the most recent Long Term Support release" + echo " - 2-part version in a format A.B - represents a specific release" + echo " examples: 2.0; 1.0" + echo " - 3-part version in a format A.B.Cxx - represents a specific SDK release" + echo " examples: 5.0.1xx, 5.0.2xx." + echo " Supported since 5.0 release" + echo " Warning: Value 'Current' is deprecated for the Channel parameter. Use 'STS' instead." + echo " Note: The version parameter overrides the channel parameter when any version other than 'latest' is used." + echo " -v,--version Use specific VERSION, Defaults to \`$version\`." + echo " -Version" + echo " Possible values:" + echo " - latest - the latest build on specific channel" + echo " - 3-part version in a format A.B.C - represents specific version of build" + echo " examples: 2.0.0-preview2-006120; 1.1.0" + echo " -q,--quality Download the latest build of specified quality in the channel." + echo " -Quality" + echo " The possible values are: daily, signed, validated, preview, GA." + echo " Works only in combination with channel. Not applicable for STS and LTS channels and will be ignored if those channels are used." + echo " For SDK use channel in A.B.Cxx format. Using quality for SDK together with channel in A.B format is not supported." + echo " Supported since 5.0 release." + echo " Note: The version parameter overrides the channel parameter when any version other than 'latest' is used, and therefore overrides the quality." + echo " --internal,-Internal Download internal builds. Requires providing credentials via --feed-credential parameter." + echo " --feed-credential Token to access Azure feed. Used as a query string to append to the Azure feed." + echo " -FeedCredential This parameter typically is not specified." + echo " -i,--install-dir Install under specified location (see Install Location below)" + echo " -InstallDir" + echo " --architecture Architecture of dotnet binaries to be installed, Defaults to \`$architecture\`." + echo " --arch,-Architecture,-Arch" + echo " Possible values: x64, arm, arm64, s390x, ppc64le and loongarch64" + echo " --os Specifies operating system to be used when selecting the installer." + echo " Overrides the OS determination approach used by the script. Supported values: osx, linux, linux-musl, freebsd, rhel.6." + echo " In case any other value is provided, the platform will be determined by the script based on machine configuration." + echo " Not supported for legacy links. Use --runtime-id to specify platform for legacy links." + echo " Refer to: https://aka.ms/dotnet-os-lifecycle for more information." + echo " --runtime Installs a shared runtime only, without the SDK." + echo " -Runtime" + echo " Possible values:" + echo " - dotnet - the Microsoft.NETCore.App shared runtime" + echo " - aspnetcore - the Microsoft.AspNetCore.App shared runtime" + echo " --dry-run,-DryRun Do not perform installation. Display download link." + echo " --no-path, -NoPath Do not set PATH for the current process." + echo " --verbose,-Verbose Display diagnostics information." + echo " --azure-feed,-AzureFeed For internal use only." + echo " Allows using a different storage to download SDK archives from." + echo " --uncached-feed,-UncachedFeed For internal use only." + echo " Allows using a different storage to download SDK archives from." + echo " --skip-non-versioned-files Skips non-versioned files if they already exist, such as the dotnet executable." + echo " -SkipNonVersionedFiles" + echo " --jsonfile Determines the SDK version from a user specified global.json file." + echo " Note: global.json must have a value for 'SDK:Version'" + echo " --keep-zip,-KeepZip If set, downloaded file is kept." + echo " --zip-path, -ZipPath If set, downloaded file is stored at the specified path." + echo " -?,--?,-h,--help,-Help Shows this help message" + echo "" + echo "Install Location:" + echo " Location is chosen in following order:" + echo " - --install-dir option" + echo " - Environmental variable DOTNET_INSTALL_DIR" + echo " - $HOME/.dotnet" + exit 0 + ;; + *) + say_err "Unknown argument \`$name\`" + exit 1 + ;; + esac + + shift +done + +say_verbose "Note that the intended use of this script is for Continuous Integration (CI) scenarios, where:" +say_verbose "- The SDK needs to be installed without user interaction and without admin rights." +say_verbose "- The SDK installation doesn't need to persist across multiple CI runs." +say_verbose "To set up a development environment or to run apps, use installers rather than this script. Visit https://dotnet.microsoft.com/download to get the installer.\n" + +if [ "$internal" = true ] && [ -z "$(echo $feed_credential)" ]; then + message="Provide credentials via --feed-credential parameter." + if [ "$dry_run" = true ]; then + say_warning "$message" + else + say_err "$message" + exit 1 + fi +fi + +check_min_reqs +calculate_vars +# generate_regular_links call below will 'exit' if the determined version is already installed. +generate_download_links + +if [[ "$dry_run" = true ]]; then + print_dry_run + exit 0 +fi + +install_dotnet + +bin_path="$(get_absolute_path "$(combine_paths "$install_root" "$bin_folder_relative_path")")" +if [ "$no_path" = false ]; then + say "Adding to current process PATH: \`$bin_path\`. Note: This change will be visible only when sourcing script." + export PATH="$bin_path":"$PATH" +else + say "Binaries of dotnet can be found in $bin_path" +fi + +say "Note that the script does not resolve dependencies during installation." +say "To check the list of dependencies, go to https://learn.microsoft.com/dotnet/core/install, select your operating system and check the \"Dependencies\" section." +say "Installation finished successfully." diff --git a/error.go b/error.go new file mode 100644 index 000000000000..fe6a5aef45c0 --- /dev/null +++ b/error.go @@ -0,0 +1,102 @@ +package credentials + +const ( + // ErrCredentialsNotFound standardizes the not found error, so every helper returns + // the same message and docker can handle it properly. + errCredentialsNotFoundMessage = "credentials not found in native keychain" + + // ErrCredentialsMissingServerURL and ErrCredentialsMissingUsername standardize + // invalid credentials or credentials management operations + errCredentialsMissingServerURLMessage = "no credentials server URL" + errCredentialsMissingUsernameMessage = "no credentials username" +) + +// errCredentialsNotFound represents an error +// raised when credentials are not in the store. +type errCredentialsNotFound struct{} + +// Error returns the standard error message +// for when the credentials are not in the store. +func (errCredentialsNotFound) Error() string { + return errCredentialsNotFoundMessage +} + +// NewErrCredentialsNotFound creates a new error +// for when the credentials are not in the store. +func NewErrCredentialsNotFound() error { + return errCredentialsNotFound{} +} + +// IsErrCredentialsNotFound returns true if the error +// was caused by not having a set of credentials in a store. +func IsErrCredentialsNotFound(err error) bool { + _, ok := err.(errCredentialsNotFound) + return ok +} + +// IsErrCredentialsNotFoundMessage returns true if the error +// was caused by not having a set of credentials in a store. +// +// This function helps to check messages returned by an +// external program via its standard output. +func IsErrCredentialsNotFoundMessage(err string) bool { + return err == errCredentialsNotFoundMessage +} + +// errCredentialsMissingServerURL represents an error raised +// when the credentials object has no server URL or when no +// server URL is provided to a credentials operation requiring +// one. +type errCredentialsMissingServerURL struct{} + +func (errCredentialsMissingServerURL) Error() string { + return errCredentialsMissingServerURLMessage +} + +// errCredentialsMissingUsername represents an error raised +// when the credentials object has no username or when no +// username is provided to a credentials operation requiring +// one. +type errCredentialsMissingUsername struct{} + +func (errCredentialsMissingUsername) Error() string { + return errCredentialsMissingUsernameMessage +} + +// NewErrCredentialsMissingServerURL creates a new error for +// errCredentialsMissingServerURL. +func NewErrCredentialsMissingServerURL() error { + return errCredentialsMissingServerURL{} +} + +// NewErrCredentialsMissingUsername creates a new error for +// errCredentialsMissingUsername. +func NewErrCredentialsMissingUsername() error { + return errCredentialsMissingUsername{} +} + +// IsCredentialsMissingServerURL returns true if the error +// was an errCredentialsMissingServerURL. +func IsCredentialsMissingServerURL(err error) bool { + _, ok := err.(errCredentialsMissingServerURL) + return ok +} + +// IsCredentialsMissingServerURLMessage checks for an +// errCredentialsMissingServerURL in the error message. +func IsCredentialsMissingServerURLMessage(err string) bool { + return err == errCredentialsMissingServerURLMessage +} + +// IsCredentialsMissingUsername returns true if the error +// was an errCredentialsMissingUsername. +func IsCredentialsMissingUsername(err error) bool { + _, ok := err.(errCredentialsMissingUsername) + return ok +} + +// IsCredentialsMissingUsernameMessage checks for an +// errCredentialsMissingUsername in the error message. +func IsCredentialsMissingUsernameMessage(err string) bool { + return err == errCredentialsMissingUsernameMessage +} diff --git a/esbuild b/esbuild new file mode 100644 index 000000000000..e9d198ad282e --- /dev/null +++ b/esbuild @@ -0,0 +1,221 @@ +#!/usr/bin/env node +"use strict"; +var __create = Object.create; +var __defProp = Object.defineProperty; +var __getOwnPropDesc = Object.getOwnPropertyDescriptor; +var __getOwnPropNames = Object.getOwnPropertyNames; +var __getProtoOf = Object.getPrototypeOf; +var __hasOwnProp = Object.prototype.hasOwnProperty; +var __copyProps = (to, from, except, desc) => { + if (from && typeof from === "object" || typeof from === "function") { + for (let key of __getOwnPropNames(from)) + if (!__hasOwnProp.call(to, key) && key !== except) + __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); + } + return to; +}; +var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( + // If the importer is in node compatibility mode or this is not an ESM + // file that has been converted to a CommonJS file using a Babel- + // compatible transform (i.e. "__esModule" has not been set), then set + // "default" to the CommonJS "module.exports" for node compatibility. + isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, + mod +)); + +// lib/npm/node-platform.ts +var fs = require("fs"); +var os = require("os"); +var path = require("path"); +var ESBUILD_BINARY_PATH = process.env.ESBUILD_BINARY_PATH || ESBUILD_BINARY_PATH; +var isValidBinaryPath = (x) => !!x && x !== "/usr/bin/esbuild"; +var packageDarwin_arm64 = "@esbuild/darwin-arm64"; +var packageDarwin_x64 = "@esbuild/darwin-x64"; +var knownWindowsPackages = { + "win32 arm64 LE": "@esbuild/win32-arm64", + "win32 ia32 LE": "@esbuild/win32-ia32", + "win32 x64 LE": "@esbuild/win32-x64" +}; +var knownUnixlikePackages = { + "aix ppc64 BE": "@esbuild/aix-ppc64", + "android arm64 LE": "@esbuild/android-arm64", + "darwin arm64 LE": "@esbuild/darwin-arm64", + "darwin x64 LE": "@esbuild/darwin-x64", + "freebsd arm64 LE": "@esbuild/freebsd-arm64", + "freebsd x64 LE": "@esbuild/freebsd-x64", + "linux arm LE": "@esbuild/linux-arm", + "linux arm64 LE": "@esbuild/linux-arm64", + "linux ia32 LE": "@esbuild/linux-ia32", + "linux mips64el LE": "@esbuild/linux-mips64el", + "linux ppc64 LE": "@esbuild/linux-ppc64", + "linux riscv64 LE": "@esbuild/linux-riscv64", + "linux s390x BE": "@esbuild/linux-s390x", + "linux x64 LE": "@esbuild/linux-x64", + "linux loong64 LE": "@esbuild/linux-loong64", + "netbsd x64 LE": "@esbuild/netbsd-x64", + "openbsd arm64 LE": "@esbuild/openbsd-arm64", + "openbsd x64 LE": "@esbuild/openbsd-x64", + "sunos x64 LE": "@esbuild/sunos-x64" +}; +var knownWebAssemblyFallbackPackages = { + "android arm LE": "@esbuild/android-arm", + "android x64 LE": "@esbuild/android-x64" +}; +function pkgAndSubpathForCurrentPlatform() { + let pkg; + let subpath; + let isWASM2 = false; + let platformKey = `${process.platform} ${os.arch()} ${os.endianness()}`; + if (platformKey in knownWindowsPackages) { + pkg = knownWindowsPackages[platformKey]; + subpath = "esbuild.exe"; + } else if (platformKey in knownUnixlikePackages) { + pkg = knownUnixlikePackages[platformKey]; + subpath = "bin/esbuild"; + } else if (platformKey in knownWebAssemblyFallbackPackages) { + pkg = knownWebAssemblyFallbackPackages[platformKey]; + subpath = "bin/esbuild"; + isWASM2 = true; + } else { + throw new Error(`Unsupported platform: ${platformKey}`); + } + return { pkg, subpath, isWASM: isWASM2 }; +} +function pkgForSomeOtherPlatform() { + const libMainJS = require.resolve("esbuild"); + const nodeModulesDirectory = path.dirname(path.dirname(path.dirname(libMainJS))); + if (path.basename(nodeModulesDirectory) === "node_modules") { + for (const unixKey in knownUnixlikePackages) { + try { + const pkg = knownUnixlikePackages[unixKey]; + if (fs.existsSync(path.join(nodeModulesDirectory, pkg))) return pkg; + } catch { + } + } + for (const windowsKey in knownWindowsPackages) { + try { + const pkg = knownWindowsPackages[windowsKey]; + if (fs.existsSync(path.join(nodeModulesDirectory, pkg))) return pkg; + } catch { + } + } + } + return null; +} +function downloadedBinPath(pkg, subpath) { + const esbuildLibDir = path.dirname(require.resolve("esbuild")); + return path.join(esbuildLibDir, `downloaded-${pkg.replace("/", "-")}-${path.basename(subpath)}`); +} +function generateBinPath() { + if (isValidBinaryPath(ESBUILD_BINARY_PATH)) { + if (!fs.existsSync(ESBUILD_BINARY_PATH)) { + console.warn(`[esbuild] Ignoring bad configuration: ESBUILD_BINARY_PATH=${ESBUILD_BINARY_PATH}`); + } else { + return { binPath: ESBUILD_BINARY_PATH, isWASM: false }; + } + } + const { pkg, subpath, isWASM: isWASM2 } = pkgAndSubpathForCurrentPlatform(); + let binPath2; + try { + binPath2 = require.resolve(`${pkg}/${subpath}`); + } catch (e) { + binPath2 = downloadedBinPath(pkg, subpath); + if (!fs.existsSync(binPath2)) { + try { + require.resolve(pkg); + } catch { + const otherPkg = pkgForSomeOtherPlatform(); + if (otherPkg) { + let suggestions = ` +Specifically the "${otherPkg}" package is present but this platform +needs the "${pkg}" package instead. People often get into this +situation by installing esbuild on Windows or macOS and copying "node_modules" +into a Docker image that runs Linux, or by copying "node_modules" between +Windows and WSL environments. + +If you are installing with npm, you can try not copying the "node_modules" +directory when you copy the files over, and running "npm ci" or "npm install" +on the destination platform after the copy. Or you could consider using yarn +instead of npm which has built-in support for installing a package on multiple +platforms simultaneously. + +If you are installing with yarn, you can try listing both this platform and the +other platform in your ".yarnrc.yml" file using the "supportedArchitectures" +feature: https://yarnpkg.com/configuration/yarnrc/#supportedArchitectures +Keep in mind that this means multiple copies of esbuild will be present. +`; + if (pkg === packageDarwin_x64 && otherPkg === packageDarwin_arm64 || pkg === packageDarwin_arm64 && otherPkg === packageDarwin_x64) { + suggestions = ` +Specifically the "${otherPkg}" package is present but this platform +needs the "${pkg}" package instead. People often get into this +situation by installing esbuild with npm running inside of Rosetta 2 and then +trying to use it with node running outside of Rosetta 2, or vice versa (Rosetta +2 is Apple's on-the-fly x86_64-to-arm64 translation service). + +If you are installing with npm, you can try ensuring that both npm and node are +not running under Rosetta 2 and then reinstalling esbuild. This likely involves +changing how you installed npm and/or node. For example, installing node with +the universal installer here should work: https://nodejs.org/en/download/. Or +you could consider using yarn instead of npm which has built-in support for +installing a package on multiple platforms simultaneously. + +If you are installing with yarn, you can try listing both "arm64" and "x64" +in your ".yarnrc.yml" file using the "supportedArchitectures" feature: +https://yarnpkg.com/configuration/yarnrc/#supportedArchitectures +Keep in mind that this means multiple copies of esbuild will be present. +`; + } + throw new Error(` +You installed esbuild for another platform than the one you're currently using. +This won't work because esbuild is written with native code and needs to +install a platform-specific binary executable. +${suggestions} +Another alternative is to use the "esbuild-wasm" package instead, which works +the same way on all platforms. But it comes with a heavy performance cost and +can sometimes be 10x slower than the "esbuild" package, so you may also not +want to do that. +`); + } + throw new Error(`The package "${pkg}" could not be found, and is needed by esbuild. + +If you are installing esbuild with npm, make sure that you don't specify the +"--no-optional" or "--omit=optional" flags. The "optionalDependencies" feature +of "package.json" is used by esbuild to install the correct binary executable +for your current platform.`); + } + throw e; + } + } + if (/\.zip\//.test(binPath2)) { + let pnpapi; + try { + pnpapi = require("pnpapi"); + } catch (e) { + } + if (pnpapi) { + const root = pnpapi.getPackageInformation(pnpapi.topLevel).packageLocation; + const binTargetPath = path.join( + root, + "node_modules", + ".cache", + "esbuild", + `pnpapi-${pkg.replace("/", "-")}-${"0.23.1"}-${path.basename(subpath)}` + ); + if (!fs.existsSync(binTargetPath)) { + fs.mkdirSync(path.dirname(binTargetPath), { recursive: true }); + fs.copyFileSync(binPath2, binTargetPath); + fs.chmodSync(binTargetPath, 493); + } + return { binPath: binTargetPath, isWASM: isWASM2 }; + } + } + return { binPath: binPath2, isWASM: isWASM2 }; +} + +// lib/npm/node-shim.ts +var { binPath, isWASM } = generateBinPath(); +if (isWASM) { + require("child_process").execFileSync("node", [binPath].concat(process.argv.slice(2)), { stdio: "inherit" }); +} else { + require("child_process").execFileSync(binPath, process.argv.slice(2), { stdio: "inherit" }); +} diff --git a/helper.go b/helper.go new file mode 100644 index 000000000000..135acd254d7d --- /dev/null +++ b/helper.go @@ -0,0 +1,14 @@ +package credentials + +// Helper is the interface a credentials store helper must implement. +type Helper interface { + // Add appends credentials to the store. + Add(*Credentials) error + // Delete removes credentials from the store. + Delete(serverURL string) error + // Get retrieves credentials from the store. + // It returns username and secret as strings. + Get(serverURL string) (string, string, error) + // List returns the stored serverURLs and their associated usernames. + List() (map[string]string, error) +} diff --git a/index.d.ts b/index.d.ts new file mode 100644 index 000000000000..c801881dee42 --- /dev/null +++ b/index.d.ts @@ -0,0 +1,15 @@ +/** +Check if the process is running inside a Docker container. + +@example +``` +import isDocker = require('is-docker'); + +if (isDocker()) { + console.log('Running inside a Docker container'); +} +``` +*/ +declare function isDocker(): boolean; + +export = isDocker; diff --git a/index.js b/index.js new file mode 100644 index 000000000000..cbb7b6f756ee --- /dev/null +++ b/index.js @@ -0,0 +1,29 @@ +'use strict'; +const fs = require('fs'); + +let isDocker; + +function hasDockerEnv() { + try { + fs.statSync('/.dockerenv'); + return true; + } catch (_) { + return false; + } +} + +function hasDockerCGroup() { + try { + return fs.readFileSync('/proc/self/cgroup', 'utf8').includes('docker'); + } catch (_) { + return false; + } +} + +module.exports = () => { + if (isDocker === undefined) { + isDocker = hasDockerEnv() || hasDockerCGroup(); + } + + return isDocker; +}; diff --git a/influxdb-restart.sh b/influxdb-restart.sh new file mode 100644 index 000000000000..9c8620d3428c --- /dev/null +++ b/influxdb-restart.sh @@ -0,0 +1,112 @@ +#!/usr/bin/env bash +# +# The MIT License +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +# THE SOFTWARE. +# + +set -e + +DEFAULT_INFLUXDB_VERSION="1.8.3" +INFLUXDB_VERSION="${INFLUXDB_VERSION:-$DEFAULT_INFLUXDB_VERSION}" +INFLUXDB_IMAGE=influxdb:${INFLUXDB_VERSION}-alpine + +DEFAULT_INFLUXDB_V2_VERSION="latest" +INFLUXDB_V2_VERSION="${INFLUXDB_V2_VERSION:-$DEFAULT_INFLUXDB_V2_VERSION}" +INFLUXDB_V2_IMAGE=influxdb:${INFLUXDB_V2_VERSION} + +SCRIPT_PATH="$( cd "$(dirname "$0")" ; pwd -P )" + +docker kill influxdb || true +docker rm influxdb || true +docker kill influxdb_v2 || true +docker rm influxdb_v2 || true +docker kill influxdb_v2_onboarding || true +docker rm influxdb_v2_onboarding || true +docker network rm influx_network || true +docker network create -d bridge influx_network --subnet 192.168.0.0/24 --gateway 192.168.0.1 + + +echo +echo "Restarting InfluxDB [${INFLUXDB_IMAGE}] ..." +echo + +# +# InfluxDB 1.8 +# + +docker pull ${INFLUXDB_IMAGE} || true +docker run \ + --detach \ + --name influxdb \ + --network influx_network \ + --publish 8087:8086 \ + --volume ${SCRIPT_PATH}/influxdb.conf:/etc/influxdb/influxdb.conf \ + ${INFLUXDB_IMAGE} + +echo "Wait to start InfluxDB" +wget -S --spider --tries=20 --retry-connrefused --waitretry=5 http://localhost:8087/ping +echo +echo "Post with create dabase" +echo +curl -X POST localhost:8087/query --data-urlencode "q=create database mydb" +# +# InfluxDB 2.0 +# +echo +echo "Restarting InfluxDB 2.0 [${INFLUXDB_V2_IMAGE}] ... " +echo + +docker pull ${INFLUXDB_V2_IMAGE} || true +docker run \ + --detach \ + --name influxdb_v2 \ + --network influx_network \ + --publish 8086:8086 \ + ${INFLUXDB_V2_IMAGE} + +echo "Wait to start InfluxDB 2.0" +wget -S --spider --tries=20 --retry-connrefused --waitretry=5 http://localhost:8086/metrics + +echo +echo "Post onBoarding request, to setup initial user (my-user@my-password), org (my-org) and bucketSetup (my-bucket)" +echo +curl -i -X POST http://localhost:8086/api/v2/setup -H 'accept: application/json' \ + -d '{ + "username": "my-user", + "password": "my-password", + "org": "my-org", + "bucket": "my-bucket", + "token": "my-token" + }' + +# +# InfluxDB 2.0 +# +echo +echo "Restarting InfluxDB 2.0 for onboarding test... " +echo + +docker run \ + --detach \ + --name influxdb_v2_onboarding \ + --network influx_network \ + --publish 8089:8086 \ + ${INFLUXDB_V2_IMAGE} + diff --git a/integration_test.sh b/integration_test.sh new file mode 100644 index 000000000000..2761b12868ee --- /dev/null +++ b/integration_test.sh @@ -0,0 +1,15 @@ +#!/bin/bash +# Copyright 2022 The Go Authors. All rights reserved. +# Use of this source code is governed by a BSD-style +# license that can be found in the LICENSE file. + +# Runs the integration tests for whole program analysis. +# Assumes this is run from vuln/cmd/govulncheck/integration + +echo "Building govulncheck docker image" +# The building context is vuln/ so we can have the current +# version of both govulncheck and its vuln dependencies +docker build -f Dockerfile -t govulncheck-integration ../../../ + +echo "Running govulncheck integration tests in the docker image" +docker run govulncheck-integration ./integration_run.sh diff --git a/license b/license new file mode 100644 index 000000000000..fa7ceba3eb4a --- /dev/null +++ b/license @@ -0,0 +1,9 @@ +MIT License + +Copyright (c) Sindre Sorhus (https://sindresorhus.com) + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/mkall.sh b/mkall.sh new file mode 100644 index 000000000000..e6f31d374df5 --- /dev/null +++ b/mkall.sh @@ -0,0 +1,249 @@ +#!/usr/bin/env bash +# Copyright 2009 The Go Authors. All rights reserved. +# Use of this source code is governed by a BSD-style +# license that can be found in the LICENSE file. + +# This script runs or (given -n) prints suggested commands to generate files for +# the Architecture/OS specified by the GOARCH and GOOS environment variables. +# See README.md for more information about how the build system works. + +GOOSARCH="${GOOS}_${GOARCH}" + +# defaults +mksyscall="go run mksyscall.go" +mkerrors="./mkerrors.sh" +zerrors="zerrors_$GOOSARCH.go" +mksysctl="" +zsysctl="zsysctl_$GOOSARCH.go" +mksysnum= +mktypes= +mkasm= +run="sh" +cmd="" + +case "$1" in +-syscalls) + for i in zsyscall*go + do + # Run the command line that appears in the first line + # of the generated file to regenerate it. + sed 1q $i | sed 's;^// ;;' | sh > _$i && gofmt < _$i > $i + rm _$i + done + exit 0 + ;; +-n) + run="cat" + cmd="echo" + shift +esac + +case "$#" in +0) + ;; +*) + echo 'usage: mkall.sh [-n]' 1>&2 + exit 2 +esac + +if [[ "$GOOS" = "linux" ]]; then + # Use the Docker-based build system + # Files generated through docker (use $cmd so you can Ctl-C the build or run) + $cmd docker build --tag generate:$GOOS $GOOS + $cmd docker run --interactive --tty --volume $(cd -- "$(dirname -- "$0")/.." && pwd):/build generate:$GOOS + exit +fi + +GOOSARCH_in=syscall_$GOOSARCH.go +case "$GOOSARCH" in +_* | *_ | _) + echo 'undefined $GOOS_$GOARCH:' "$GOOSARCH" 1>&2 + exit 1 + ;; +aix_ppc) + mkerrors="$mkerrors -maix32" + mksyscall="go run mksyscall_aix_ppc.go -aix" + mktypes="GOARCH=$GOARCH go tool cgo -godefs" + ;; +aix_ppc64) + mkerrors="$mkerrors -maix64" + mksyscall="go run mksyscall_aix_ppc64.go -aix" + mktypes="GOARCH=$GOARCH go tool cgo -godefs" + ;; +darwin_amd64) + mkerrors="$mkerrors -m64" + mktypes="GOARCH=$GOARCH go tool cgo -godefs" + mkasm="go run mkasm.go" + ;; +darwin_arm64) + mkerrors="$mkerrors -m64" + mktypes="GOARCH=$GOARCH go tool cgo -godefs" + mkasm="go run mkasm.go" + ;; +dragonfly_amd64) + mkerrors="$mkerrors -m64" + mksyscall="go run mksyscall.go -dragonfly" + mksysnum="go run mksysnum.go 'https://gitweb.dragonflybsd.org/dragonfly.git/blob_plain/HEAD:/sys/kern/syscalls.master'" + mktypes="GOARCH=$GOARCH go tool cgo -godefs" + ;; +freebsd_386) + mkerrors="$mkerrors -m32" + mksyscall="go run mksyscall.go -l32" + mksysnum="go run mksysnum.go 'https://cgit.freebsd.org/src/plain/sys/kern/syscalls.master?h=stable/12'" + mktypes="GOARCH=$GOARCH go tool cgo -godefs" + ;; +freebsd_amd64) + mkerrors="$mkerrors -m64" + mksysnum="go run mksysnum.go 'https://cgit.freebsd.org/src/plain/sys/kern/syscalls.master?h=stable/12'" + mktypes="GOARCH=$GOARCH go tool cgo -godefs" + ;; +freebsd_arm) + mkerrors="$mkerrors" + mksyscall="go run mksyscall.go -l32 -arm" + mksysnum="go run mksysnum.go 'https://cgit.freebsd.org/src/plain/sys/kern/syscalls.master?h=stable/12'" + # Let the type of C char be signed for making the bare syscall + # API consistent across platforms. + mktypes="GOARCH=$GOARCH go tool cgo -godefs -- -fsigned-char" + ;; +freebsd_arm64) + mkerrors="$mkerrors -m64" + mksysnum="go run mksysnum.go 'https://cgit.freebsd.org/src/plain/sys/kern/syscalls.master?h=stable/12'" + mktypes="GOARCH=$GOARCH go tool cgo -godefs -- -fsigned-char" + ;; +freebsd_riscv64) + mkerrors="$mkerrors -m64" + mksysnum="go run mksysnum.go 'https://cgit.freebsd.org/src/plain/sys/kern/syscalls.master?h=stable/12'" + mktypes="GOARCH=$GOARCH go tool cgo -godefs -- -fsigned-char" + ;; +netbsd_386) + mkerrors="$mkerrors -m32" + mksyscall="go run mksyscall.go -l32 -netbsd" + mksysnum="go run mksysnum.go 'http://cvsweb.netbsd.org/bsdweb.cgi/~checkout~/src/sys/kern/syscalls.master'" + mktypes="GOARCH=$GOARCH go tool cgo -godefs" + ;; +netbsd_amd64) + mkerrors="$mkerrors -m64" + mksyscall="go run mksyscall.go -netbsd" + mksysnum="go run mksysnum.go 'http://cvsweb.netbsd.org/bsdweb.cgi/~checkout~/src/sys/kern/syscalls.master'" + mktypes="GOARCH=$GOARCH go tool cgo -godefs" + ;; +netbsd_arm) + mkerrors="$mkerrors" + mksyscall="go run mksyscall.go -l32 -netbsd -arm" + mksysnum="go run mksysnum.go 'http://cvsweb.netbsd.org/bsdweb.cgi/~checkout~/src/sys/kern/syscalls.master'" + # Let the type of C char be signed for making the bare syscall + # API consistent across platforms. + mktypes="GOARCH=$GOARCH go tool cgo -godefs -- -fsigned-char" + ;; +netbsd_arm64) + mkerrors="$mkerrors -m64" + mksyscall="go run mksyscall.go -netbsd" + mksysnum="go run mksysnum.go 'http://cvsweb.netbsd.org/bsdweb.cgi/~checkout~/src/sys/kern/syscalls.master'" + mktypes="GOARCH=$GOARCH go tool cgo -godefs" + ;; +openbsd_386) + mkasm="go run mkasm.go" + mkerrors="$mkerrors -m32" + mksyscall="go run mksyscall.go -l32 -openbsd -libc" + mksysctl="go run mksysctl_openbsd.go" + mktypes="GOARCH=$GOARCH go tool cgo -godefs" + ;; +openbsd_amd64) + mkasm="go run mkasm.go" + mkerrors="$mkerrors -m64" + mksyscall="go run mksyscall.go -openbsd -libc" + mksysctl="go run mksysctl_openbsd.go" + mktypes="GOARCH=$GOARCH go tool cgo -godefs" + ;; +openbsd_arm) + mkasm="go run mkasm.go" + mkerrors="$mkerrors" + mksyscall="go run mksyscall.go -l32 -openbsd -arm -libc" + mksysctl="go run mksysctl_openbsd.go" + # Let the type of C char be signed for making the bare syscall + # API consistent across platforms. + mktypes="GOARCH=$GOARCH go tool cgo -godefs -- -fsigned-char" + ;; +openbsd_arm64) + mkasm="go run mkasm.go" + mkerrors="$mkerrors -m64" + mksyscall="go run mksyscall.go -openbsd -libc" + mksysctl="go run mksysctl_openbsd.go" + # Let the type of C char be signed for making the bare syscall + # API consistent across platforms. + mktypes="GOARCH=$GOARCH go tool cgo -godefs -- -fsigned-char" + ;; +openbsd_mips64) + mkasm="go run mkasm.go" + mkerrors="$mkerrors -m64" + mksyscall="go run mksyscall.go -openbsd -libc" + mksysctl="go run mksysctl_openbsd.go" + # Let the type of C char be signed for making the bare syscall + # API consistent across platforms. + mktypes="GOARCH=$GOARCH go tool cgo -godefs -- -fsigned-char" + ;; +openbsd_ppc64) + mkasm="go run mkasm.go" + mkerrors="$mkerrors -m64" + mksyscall="go run mksyscall.go -openbsd -libc" + mksysctl="go run mksysctl_openbsd.go" + # Let the type of C char be signed for making the bare syscall + # API consistent across platforms. + mktypes="GOARCH=$GOARCH go tool cgo -godefs -- -fsigned-char" + ;; +openbsd_riscv64) + mkasm="go run mkasm.go" + mkerrors="$mkerrors -m64" + mksyscall="go run mksyscall.go -openbsd -libc" + mksysctl="go run mksysctl_openbsd.go" + # Let the type of C char be signed for making the bare syscall + # API consistent across platforms. + mktypes="GOARCH=$GOARCH go tool cgo -godefs -- -fsigned-char" + ;; +solaris_amd64) + mksyscall="go run mksyscall_solaris.go" + mkerrors="$mkerrors -m64" + mksysnum= + mktypes="GOARCH=$GOARCH go tool cgo -godefs" + ;; +illumos_amd64) + mksyscall="go run mksyscall_solaris.go" + mkerrors= + mksysnum= + mktypes="GOARCH=$GOARCH go tool cgo -godefs" + ;; +*) + echo 'unrecognized $GOOS_$GOARCH: ' "$GOOSARCH" 1>&2 + exit 1 + ;; +esac + +( + if [ -n "$mkerrors" ]; then echo "$mkerrors |gofmt >$zerrors"; fi + case "$GOOS" in + *) + syscall_goos="syscall_$GOOS.go" + case "$GOOS" in + darwin | dragonfly | freebsd | netbsd | openbsd) + syscall_goos="syscall_bsd.go $syscall_goos" + ;; + esac + if [ -n "$mksyscall" ]; then + if [ "$GOOSARCH" == "aix_ppc64" ]; then + # aix/ppc64 script generates files instead of writing to stdin. + echo "$mksyscall -tags $GOOS,$GOARCH $syscall_goos $GOOSARCH_in && gofmt -w zsyscall_$GOOSARCH.go && gofmt -w zsyscall_"$GOOSARCH"_gccgo.go && gofmt -w zsyscall_"$GOOSARCH"_gc.go " ; + elif [ "$GOOS" == "illumos" ]; then + # illumos code generation requires a --illumos switch + echo "$mksyscall -illumos -tags illumos,$GOARCH syscall_illumos.go |gofmt > zsyscall_illumos_$GOARCH.go"; + # illumos implies solaris, so solaris code generation is also required + echo "$mksyscall -tags solaris,$GOARCH syscall_solaris.go syscall_solaris_$GOARCH.go |gofmt >zsyscall_solaris_$GOARCH.go"; + else + echo "$mksyscall -tags $GOOS,$GOARCH $syscall_goos $GOOSARCH_in |gofmt >zsyscall_$GOOSARCH.go"; + fi + fi + esac + if [ -n "$mksysctl" ]; then echo "$mksysctl |gofmt >$zsysctl"; fi + if [ -n "$mksysnum" ]; then echo "$mksysnum |gofmt >zsysnum_$GOOSARCH.go"; fi + if [ -n "$mktypes" ]; then echo "$mktypes types_$GOOS.go | go run mkpost.go > ztypes_$GOOSARCH.go"; fi + if [ -n "$mkasm" ]; then echo "$mkasm $GOOS $GOARCH"; fi +) | $run diff --git a/mkerrors.sh b/mkerrors.sh new file mode 100644 index 000000000000..6e6afcaa1d04 --- /dev/null +++ b/mkerrors.sh @@ -0,0 +1,759 @@ +#!/usr/bin/env bash +# Copyright 2009 The Go Authors. All rights reserved. +# Use of this source code is governed by a BSD-style +# license that can be found in the LICENSE file. + +# Generate Go code listing errors and other #defined constant +# values (ENAMETOOLONG etc.), by asking the preprocessor +# about the definitions. + +unset LANG +export LC_ALL=C +export LC_CTYPE=C + +if test -z "$GOARCH" -o -z "$GOOS"; then + echo 1>&2 "GOARCH or GOOS not defined in environment" + exit 1 +fi + +# Check that we are using the new build system if we should +if [[ "$GOOS" = "linux" ]] && [[ "$GOLANG_SYS_BUILD" != "docker" ]]; then + echo 1>&2 "In the Docker based build system, mkerrors should not be called directly." + echo 1>&2 "See README.md" + exit 1 +fi + +if [[ "$GOOS" = "aix" ]]; then + CC=${CC:-gcc} +else + CC=${CC:-cc} +fi + +if [[ "$GOOS" = "solaris" ]]; then + # Assumes GNU versions of utilities in PATH. + export PATH=/usr/gnu/bin:$PATH +fi + +uname=$(uname) + +includes_AIX=' +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define AF_LOCAL AF_UNIX +' + +includes_Darwin=' +#define _DARWIN_C_SOURCE +#define KERNEL +#define _DARWIN_USE_64_BIT_INODE +#define __APPLE_USE_RFC_3542 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +' + +includes_DragonFly=' +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +' + +includes_FreeBSD=' +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#if __FreeBSD__ >= 10 +#define IFT_CARP 0xf8 // IFT_CARP is deprecated in FreeBSD 10 +#undef SIOCAIFADDR +#define SIOCAIFADDR _IOW(105, 26, struct oifaliasreq) // ifaliasreq contains if_data +#undef SIOCSIFPHYADDR +#define SIOCSIFPHYADDR _IOW(105, 70, struct oifaliasreq) // ifaliasreq contains if_data +#endif +' + +includes_Linux=' +#define _LARGEFILE_SOURCE +#define _LARGEFILE64_SOURCE +#ifndef __LP64__ +#define _FILE_OFFSET_BITS 64 +#endif +#define _GNU_SOURCE + +// is broken on powerpc64, as it fails to include definitions of +// these structures. We just include them copied from . +#if defined(__powerpc__) +struct sgttyb { + char sg_ispeed; + char sg_ospeed; + char sg_erase; + char sg_kill; + short sg_flags; +}; + +struct tchars { + char t_intrc; + char t_quitc; + char t_startc; + char t_stopc; + char t_eofc; + char t_brkc; +}; + +struct ltchars { + char t_suspc; + char t_dsuspc; + char t_rprntc; + char t_flushc; + char t_werasc; + char t_lnextc; +}; +#endif + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#if defined(__sparc__) +// On sparc{,64}, the kernel defines struct termios2 itself which clashes with the +// definition in glibc. As only the error constants are needed here, include the +// generic termibits.h (which is included by termbits.h on sparc). +#include +#else +#include +#endif + +#ifndef MSG_FASTOPEN +#define MSG_FASTOPEN 0x20000000 +#endif + +#ifndef PTRACE_GETREGS +#define PTRACE_GETREGS 0xc +#endif + +#ifndef PTRACE_SETREGS +#define PTRACE_SETREGS 0xd +#endif + +#ifndef SOL_NETLINK +#define SOL_NETLINK 270 +#endif + +#ifdef SOL_BLUETOOTH +// SPARC includes this in /usr/include/sparc64-linux-gnu/bits/socket.h +// but it is already in bluetooth_linux.go +#undef SOL_BLUETOOTH +#endif + +// Certain constants are missing from the fs/crypto UAPI +#define FS_KEY_DESC_PREFIX "fscrypt:" +#define FS_KEY_DESC_PREFIX_SIZE 8 +#define FS_MAX_KEY_SIZE 64 + +// The code generator produces -0x1 for (~0), but an unsigned value is necessary +// for the tipc_subscr timeout __u32 field. +#undef TIPC_WAIT_FOREVER +#define TIPC_WAIT_FOREVER 0xffffffff + +// Copied from linux/l2tp.h +// Including linux/l2tp.h here causes conflicts between linux/in.h +// and netinet/in.h included via net/route.h above. +#define IPPROTO_L2TP 115 + +// Copied from linux/hid.h. +// Keep in sync with the size of the referenced fields. +#define _HIDIOCGRAWNAME_LEN 128 // sizeof_field(struct hid_device, name) +#define _HIDIOCGRAWPHYS_LEN 64 // sizeof_field(struct hid_device, phys) +#define _HIDIOCGRAWUNIQ_LEN 64 // sizeof_field(struct hid_device, uniq) + +#define _HIDIOCGRAWNAME HIDIOCGRAWNAME(_HIDIOCGRAWNAME_LEN) +#define _HIDIOCGRAWPHYS HIDIOCGRAWPHYS(_HIDIOCGRAWPHYS_LEN) +#define _HIDIOCGRAWUNIQ HIDIOCGRAWUNIQ(_HIDIOCGRAWUNIQ_LEN) + +' + +includes_NetBSD=' +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// Needed since refers to it... +#define schedppq 1 +' + +includes_OpenBSD=' +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// We keep some constants not supported in OpenBSD 5.5 and beyond for +// the promise of compatibility. +#define EMUL_ENABLED 0x1 +#define EMUL_NATIVE 0x2 +#define IPV6_FAITH 0x1d +#define IPV6_OPTIONS 0x1 +#define IPV6_RTHDR_STRICT 0x1 +#define IPV6_SOCKOPT_RESERVED1 0x3 +#define SIOCGIFGENERIC 0xc020693a +#define SIOCSIFGENERIC 0x80206939 +#define WALTSIG 0x4 +' + +includes_SunOS=' +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +' + + +includes=' +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +' +ccflags="$@" + +# Write go tool cgo -godefs input. +( + echo package unix + echo + echo '/*' + indirect="includes_$(uname)" + echo "${!indirect} $includes" + echo '*/' + echo 'import "C"' + echo 'import "syscall"' + echo + echo 'const (' + + # The gcc command line prints all the #defines + # it encounters while processing the input + echo "${!indirect} $includes" | $CC -x c - -E -dM $ccflags | + awk ' + $1 != "#define" || $2 ~ /\(/ || $3 == "" {next} + + $2 ~ /^E([ABCD]X|[BIS]P|[SD]I|S|FL)$/ {next} # 386 registers + $2 ~ /^(SIGEV_|SIGSTKSZ|SIGRT(MIN|MAX))/ {next} + $2 ~ /^(SCM_SRCRT)$/ {next} + $2 ~ /^(MAP_FAILED)$/ {next} + $2 ~ /^ELF_.*$/ {next}# contains ELF_ARCH, etc. + + $2 ~ /^EXTATTR_NAMESPACE_NAMES/ || + $2 ~ /^EXTATTR_NAMESPACE_[A-Z]+_STRING/ {next} + + $2 !~ /^ECCAPBITS/ && + $2 !~ /^ETH_/ && + $2 !~ /^EPROC_/ && + $2 !~ /^EQUIV_/ && + $2 !~ /^EXPR_/ && + $2 !~ /^EVIOC/ && + $2 !~ /^EV_/ && + $2 ~ /^E[A-Z0-9_]+$/ || + $2 ~ /^B[0-9_]+$/ || + $2 ~ /^(OLD|NEW)DEV$/ || + $2 == "BOTHER" || + $2 ~ /^CI?BAUD(EX)?$/ || + $2 == "IBSHIFT" || + $2 ~ /^V[A-Z0-9]+$/ || + $2 ~ /^CS[A-Z0-9]/ || + $2 ~ /^I(SIG|CANON|CRNL|UCLC|EXTEN|MAXBEL|STRIP|UTF8)$/ || + $2 ~ /^IGN/ || + $2 ~ /^IX(ON|ANY|OFF)$/ || + $2 ~ /^IN(LCR|PCK)$/ || + $2 !~ "X86_CR3_PCID_NOFLUSH" && + $2 ~ /(^FLU?SH)|(FLU?SH$)/ || + $2 ~ /^C(LOCAL|READ|MSPAR|RTSCTS)$/ || + $2 == "BRKINT" || + $2 == "HUPCL" || + $2 == "PENDIN" || + $2 == "TOSTOP" || + $2 == "XCASE" || + $2 == "ALTWERASE" || + $2 == "NOKERNINFO" || + $2 == "NFDBITS" || + $2 ~ /^PAR/ || + $2 ~ /^SIG[^_]/ || + $2 ~ /^O[CNPFPL][A-Z]+[^_][A-Z]+$/ || + $2 ~ /^(NL|CR|TAB|BS|VT|FF)DLY$/ || + $2 ~ /^(NL|CR|TAB|BS|VT|FF)[0-9]$/ || + $2 ~ /^O?XTABS$/ || + $2 ~ /^TC[IO](ON|OFF)$/ || + $2 ~ /^IN_/ || + $2 ~ /^LOCK_(SH|EX|NB|UN)$/ || + $2 ~ /^LO_(KEY|NAME)_SIZE$/ || + $2 ~ /^LOOP_(CLR|CTL|GET|SET)_/ || + $2 ~ /^(AF|SOCK|SO|SOL|IPPROTO|IP|IPV6|TCP|MCAST|EVFILT|NOTE|SHUT|PROT|MAP|MFD|T?PACKET|MSG|SCM|MCL|DT|MADV|PR|LOCAL)_/ || + $2 ~ /^NFC_(GENL|PROTO|COMM|RF|SE|DIRECTION|LLCP|SOCKPROTO)_/ || + $2 ~ /^NFC_.*_(MAX)?SIZE$/ || + $2 ~ /^RAW_PAYLOAD_/ || + $2 ~ /^TP_STATUS_/ || + $2 ~ /^FALLOC_/ || + $2 ~ /^ICMPV?6?_(FILTER|SEC)/ || + $2 == "SOMAXCONN" || + $2 == "NAME_MAX" || + $2 == "IFNAMSIZ" || + $2 ~ /^CTL_(HW|KERN|MAXNAME|NET|QUERY)$/ || + $2 ~ /^KERN_(HOSTNAME|OS(RELEASE|TYPE)|VERSION)$/ || + $2 ~ /^HW_MACHINE$/ || + $2 ~ /^SYSCTL_VERS/ || + $2 !~ "MNT_BITS" && + $2 ~ /^(MS|MNT|UMOUNT)_/ || + $2 ~ /^NS_GET_/ || + $2 ~ /^TUN(SET|GET|ATTACH|DETACH)/ || + $2 ~ /^(O|F|[ES]?FD|NAME|S|PTRACE|PT|TFD)_/ || + $2 ~ /^KEXEC_/ || + $2 ~ /^LINUX_REBOOT_CMD_/ || + $2 ~ /^LINUX_REBOOT_MAGIC[12]$/ || + $2 ~ /^MODULE_INIT_/ || + $2 !~ "NLA_TYPE_MASK" && + $2 !~ /^RTC_VL_(ACCURACY|BACKUP|DATA)/ && + $2 ~ /^(NETLINK|NLM|NLMSG|NLA|IFA|IFAN|RT|RTC|RTCF|RTN|RTPROT|RTNH|ARPHRD|ETH_P|NETNSA)_/ || + $2 ~ /^FIORDCHK$/ || + $2 ~ /^SIOC/ || + $2 ~ /^TIOC/ || + $2 ~ /^TCGET/ || + $2 ~ /^TCSET/ || + $2 ~ /^TC(FLSH|SBRKP?|XONC)$/ || + $2 !~ "RTF_BITS" && + $2 ~ /^(IFF|IFT|NET_RT|RTM(GRP)?|RTF|RTV|RTA|RTAX)_/ || + $2 ~ /^BIOC/ || + $2 ~ /^DIOC/ || + $2 ~ /^RUSAGE_(SELF|CHILDREN|THREAD)/ || + $2 ~ /^RLIMIT_(AS|CORE|CPU|DATA|FSIZE|LOCKS|MEMLOCK|MSGQUEUE|NICE|NOFILE|NPROC|RSS|RTPRIO|RTTIME|SIGPENDING|STACK)|RLIM_INFINITY/ || + $2 ~ /^PRIO_(PROCESS|PGRP|USER)/ || + $2 ~ /^CLONE_[A-Z_]+/ || + $2 !~ /^(BPF_TIMEVAL|BPF_FIB_LOOKUP_[A-Z]+)$/ && + $2 ~ /^(BPF|DLT)_/ || + $2 ~ /^(CLOCK|TIMER)_/ || + $2 ~ /^CAN_/ || + $2 ~ /^CAP_/ || + $2 ~ /^CP_/ || + $2 ~ /^CPUSTATES$/ || + $2 ~ /^CTLIOCGINFO$/ || + $2 ~ /^ALG_/ || + $2 ~ /^FI(CLONE|DEDUPERANGE)/ || + $2 ~ /^FS_(POLICY_FLAGS|KEY_DESC|ENCRYPTION_MODE|[A-Z0-9_]+_KEY_SIZE)/ || + $2 ~ /^FS_IOC_.*(ENCRYPTION|VERITY|[GS]ETFLAGS)/ || + $2 ~ /^FS_VERITY_/ || + $2 ~ /^FSCRYPT_/ || + $2 ~ /^DM_/ || + $2 ~ /^GRND_/ || + $2 ~ /^RND/ || + $2 ~ /^KEY_(SPEC|REQKEY_DEFL)_/ || + $2 ~ /^KEYCTL_/ || + $2 ~ /^PERF_/ || + $2 ~ /^SECCOMP_MODE_/ || + $2 ~ /^SEEK_/ || + $2 ~ /^SPLICE_/ || + $2 ~ /^SYNC_FILE_RANGE_/ || + $2 !~ /^AUDIT_RECORD_MAGIC/ && + $2 !~ /IOC_MAGIC/ && + $2 ~ /^[A-Z][A-Z0-9_]+_MAGIC2?$/ || + $2 ~ /^(VM|VMADDR)_/ || + $2 ~ /^IOCTL_VM_SOCKETS_/ || + $2 ~ /^(TASKSTATS|TS)_/ || + $2 ~ /^CGROUPSTATS_/ || + $2 ~ /^GENL_/ || + $2 ~ /^STATX_/ || + $2 ~ /^RENAME/ || + $2 ~ /^UBI_IOC[A-Z]/ || + $2 ~ /^UTIME_/ || + $2 ~ /^XATTR_(CREATE|REPLACE|NO(DEFAULT|FOLLOW|SECURITY)|SHOWCOMPRESSION)/ || + $2 ~ /^ATTR_(BIT_MAP_COUNT|(CMN|VOL|FILE)_)/ || + $2 ~ /^FSOPT_/ || + $2 ~ /^WDIO[CFS]_/ || + $2 ~ /^NFN/ || + $2 ~ /^XDP_/ || + $2 ~ /^RWF_/ || + $2 ~ /^(HDIO|WIN|SMART)_/ || + $2 ~ /^CRYPTO_/ || + $2 ~ /^TIPC_/ || + $2 !~ "DEVLINK_RELOAD_LIMITS_VALID_MASK" && + $2 ~ /^DEVLINK_/ || + $2 ~ /^ETHTOOL_/ || + $2 ~ /^LWTUNNEL_IP/ || + $2 !~ "WMESGLEN" && + $2 ~ /^W[A-Z0-9]+$/ || + $2 ~/^PPPIOC/ || + $2 ~ /^FAN_|FANOTIFY_/ || + $2 == "HID_MAX_DESCRIPTOR_SIZE" || + $2 ~ /^_?HIDIOC/ || + $2 ~ /^BUS_(USB|HIL|BLUETOOTH|VIRTUAL)$/ || + $2 ~ /^MTD/ || + $2 ~ /^OTP/ || + $2 ~ /^MEM/ || + $2 ~ /^BLK[A-Z]*(GET$|SET$|BUF$|PART$|SIZE)/ {printf("\t%s = C.%s\n", $2, $2)} + $2 ~ /^__WCOREFLAG$/ {next} + $2 ~ /^__W[A-Z0-9]+$/ {printf("\t%s = C.%s\n", substr($2,3), $2)} + + {next} + ' | sort + + echo ')' +) >_const.go + +# Pull out the error names for later. +errors=$( + echo '#include ' | $CC -x c - -E -dM $ccflags | + awk '$1=="#define" && $2 ~ /^E[A-Z0-9_]+$/ { print $2 }' | + sort +) + +# Pull out the signal names for later. +signals=$( + echo '#include ' | $CC -x c - -E -dM $ccflags | + awk '$1=="#define" && $2 ~ /^SIG[A-Z0-9]+$/ { print $2 }' | + egrep -v '(SIGSTKSIZE|SIGSTKSZ|SIGRT|SIGMAX64)' | + sort +) + +# Again, writing regexps to a file. +echo '#include ' | $CC -x c - -E -dM $ccflags | + awk '$1=="#define" && $2 ~ /^E[A-Z0-9_]+$/ { print "^\t" $2 "[ \t]*=" }' | + sort >_error.grep +echo '#include ' | $CC -x c - -E -dM $ccflags | + awk '$1=="#define" && $2 ~ /^SIG[A-Z0-9]+$/ { print "^\t" $2 "[ \t]*=" }' | + egrep -v '(SIGSTKSIZE|SIGSTKSZ|SIGRT|SIGMAX64)' | + sort >_signal.grep + +echo '// mkerrors.sh' "$@" +echo '// Code generated by the command above; see README.md. DO NOT EDIT.' +echo +echo "//go:build ${GOARCH} && ${GOOS}" +echo "// +build ${GOARCH},${GOOS}" +echo +go tool cgo -godefs -- "$@" _const.go >_error.out +cat _error.out | grep -vf _error.grep | grep -vf _signal.grep +echo +echo '// Errors' +echo 'const (' +cat _error.out | grep -f _error.grep | sed 's/=\(.*\)/= syscall.Errno(\1)/' +echo ')' + +echo +echo '// Signals' +echo 'const (' +cat _error.out | grep -f _signal.grep | sed 's/=\(.*\)/= syscall.Signal(\1)/' +echo ')' + +# Run C program to print error and syscall strings. +( + echo -E " +#include +#include +#include +#include +#include +#include + +#define nelem(x) (sizeof(x)/sizeof((x)[0])) + +enum { A = 'A', Z = 'Z', a = 'a', z = 'z' }; // avoid need for single quotes below + +struct tuple { + int num; + const char *name; +}; + +struct tuple errors[] = { +" + for i in $errors + do + echo -E ' {'$i', "'$i'" },' + done + + echo -E " +}; + +struct tuple signals[] = { +" + for i in $signals + do + echo -E ' {'$i', "'$i'" },' + done + + # Use -E because on some systems bash builtin interprets \n itself. + echo -E ' +}; + +static int +tuplecmp(const void *a, const void *b) +{ + return ((struct tuple *)a)->num - ((struct tuple *)b)->num; +} + +int +main(void) +{ + int i, e; + char buf[1024], *p; + + printf("\n\n// Error table\n"); + printf("var errorList = [...]struct {\n"); + printf("\tnum syscall.Errno\n"); + printf("\tname string\n"); + printf("\tdesc string\n"); + printf("} {\n"); + qsort(errors, nelem(errors), sizeof errors[0], tuplecmp); + for(i=0; i 0 && errors[i-1].num == e) + continue; + strcpy(buf, strerror(e)); + // lowercase first letter: Bad -> bad, but STREAM -> STREAM. + if(A <= buf[0] && buf[0] <= Z && a <= buf[1] && buf[1] <= z) + buf[0] += a - A; + printf("\t{ %d, \"%s\", \"%s\" },\n", e, errors[i].name, buf); + } + printf("}\n\n"); + + printf("\n\n// Signal table\n"); + printf("var signalList = [...]struct {\n"); + printf("\tnum syscall.Signal\n"); + printf("\tname string\n"); + printf("\tdesc string\n"); + printf("} {\n"); + qsort(signals, nelem(signals), sizeof signals[0], tuplecmp); + for(i=0; i 0 && signals[i-1].num == e) + continue; + strcpy(buf, strsignal(e)); + // lowercase first letter: Bad -> bad, but STREAM -> STREAM. + if(A <= buf[0] && buf[0] <= Z && a <= buf[1] && buf[1] <= z) + buf[0] += a - A; + // cut trailing : number. + p = strrchr(buf, ":"[0]); + if(p) + *p = '\0'; + printf("\t{ %d, \"%s\", \"%s\" },\n", e, signals[i].name, buf); + } + printf("}\n\n"); + + return 0; +} + +' +) >_errors.c + +$CC $ccflags -o _errors _errors.c && $GORUN ./_errors && rm -f _errors.c _errors _const.go _error.grep _signal.grep _error.out diff --git a/mktypes.sh b/mktypes.sh new file mode 100644 index 000000000000..3b722f9a7c60 --- /dev/null +++ b/mktypes.sh @@ -0,0 +1,20 @@ +#!/bin/sh + +PKGS="cpu disk docker host load mem net process" + +GOOS=$(go env GOOS) +GOARCH=$(go env GOARCH) +GOARCH=$(go env GOARCH) + +for DIR in . v3 +do + (cd "$DIR" || exit + for PKG in $PKGS + do + if [ -e "${PKG}/types_${GOOS}.go" ]; then + (echo "// +build $GOOS" + echo "// +build $GOARCH" + go tool cgo -godefs "${PKG}/types_${GOOS}.go") | gofmt > "${PKG}/${PKG}_${GOOS}_${GOARCH}.go" + fi + done) +done diff --git a/package.json b/package.json new file mode 100644 index 000000000000..ae282258f09b --- /dev/null +++ b/package.json @@ -0,0 +1,42 @@ +{ + "name": "is-docker", + "version": "2.2.1", + "description": "Check if the process is running inside a Docker container", + "license": "MIT", + "repository": "sindresorhus/is-docker", + "funding": "https://github.com/sponsors/sindresorhus", + "author": { + "name": "Sindre Sorhus", + "email": "sindresorhus@gmail.com", + "url": "https://sindresorhus.com" + }, + "bin": "cli.js", + "engines": { + "node": ">=8" + }, + "scripts": { + "test": "xo && ava && tsd" + }, + "files": [ + "index.js", + "index.d.ts", + "cli.js" + ], + "keywords": [ + "detect", + "docker", + "dockerized", + "container", + "inside", + "is", + "env", + "environment", + "process" + ], + "devDependencies": { + "ava": "^1.4.1", + "sinon": "^7.3.2", + "tsd": "^0.7.2", + "xo": "^0.24.0" + } +} diff --git a/ppa-build.sh b/ppa-build.sh new file mode 100644 index 000000000000..ca04262a200d --- /dev/null +++ b/ppa-build.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +set -e -x + +# Note: this script is meant to be run in a Debian/Ubuntu docker container, +# as user 'root'. + +# Install the required tools for creating source packages. +apt-get -yq --no-install-suggests --no-install-recommends install\ + devscripts debhelper dput fakeroot + +# Add the SSH key of ppa.launchpad.net to known_hosts. +mkdir -p ~/.ssh +echo '|1|7SiYPr9xl3uctzovOTj4gMwAC1M=|t6ReES75Bo/PxlOPJ6/GsGbTrM0= ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA0aKz5UTUndYgIGG7dQBV+HaeuEZJ2xPHo2DS2iSKvUL4xNMSAY4UguNW+pX56nAQmZKIZZ8MaEvSj6zMEDiq6HFfn5JcTlM80UwlnyKe8B8p7Nk06PPQLrnmQt5fh0HmEcZx+JU9TZsfCHPnX7MNz4ELfZE6cFsclClrKim3BHUIGq//t93DllB+h4O9LHjEUsQ1Sr63irDLSutkLJD6RXchjROXkNirlcNVHH/jwLWR5RcYilNX7S5bIkK8NlWPjsn/8Ua5O7I9/YoE97PpO6i73DTGLh5H9JN/SITwCKBkgSDWUt61uPK3Y11Gty7o2lWsBjhBUm2Y38CBsoGmBw==' >> ~/.ssh/known_hosts + +# Build the source package and upload. +go run build/ci.go debsrc -upload ethereum/ethereum -sftp-user geth-ci -signer "Go Ethereum Linux Builder " diff --git a/readme.md b/readme.md new file mode 100644 index 000000000000..f09b254ff367 --- /dev/null +++ b/readme.md @@ -0,0 +1,27 @@ +# is-docker + +> Check if the process is running inside a Docker container + +## Install + +``` +$ npm install is-docker +``` + +## Usage + +```js +const isDocker = require('is-docker'); + +if (isDocker()) { + console.log('Running inside a Docker container'); +} +``` + +## CLI + +``` +$ is-docker +``` + +Exits with code 0 if inside a Docker container and 2 if not. diff --git a/run_local.sh b/run_local.sh new file mode 100644 index 000000000000..b5c284fa1e16 --- /dev/null +++ b/run_local.sh @@ -0,0 +1,96 @@ +#!/bin/bash -e + +# Copyright 2019 The Go Authors. All rights reserved. +# Use of this source code is governed by a BSD-style +# license that can be found in the LICENSE file. + +# Run govim integration tests against a local gopls. + +usage() { + cat < + make prerelease_snap_image + +Check your work: +- Visit https://hub.docker.com/repository/registry-1.docker.io/sammytheshark/doctl-snap-base/tags?page=1 +- Check the last updated date on the image tagged 'latest' + +### +C. Release a new version of doctl with any changes + +If the only change is a new snap image, fixing a broken snap build, +that's a patch, by the way. :) + +### +D. Rename the prerelease image to the new released version. + +make finalize_snap_image + +###################################################################### +###################################################################### +INSTRUCTIONS +} + +hash docker 2>/dev/null || + { echo >&2 "I require the docker CLI but it's not installed. Please see https://docs.docker.com/install/. Aborting."; exit 1; } + +BUILD=${BUILD:-snap_image} + +case "$BUILD" in + local_snap | pre) + if repo_missing "$LATEST"; then + echo "Could not find ${LATEST}. Did you run 'make snap_image'?" + exit 1 + fi + ;; + + finalize) + if repo_missing "$SAMMY_LATEST"; then + echo "Could not find ${SAMMY_LATEST}. Did you run 'make prerelease_snap_image'?" + exit 1 + fi + ;; +esac + +"build_${BUILD}" diff --git a/swagger.yml b/swagger.yml new file mode 100644 index 000000000000..f359aa1fe2ff --- /dev/null +++ b/swagger.yml @@ -0,0 +1,12077 @@ +openapi: "3.0.0" +info: + title: Influx API Service + version: 0.1.0 +servers: + - url: /api/v2 +paths: + /signin: + post: + operationId: PostSignin + summary: Exchange basic auth credentials for session + security: + - BasicAuth: [] + parameters: + - $ref: "#/components/parameters/TraceSpan" + responses: + "204": + description: Successfully authenticated + "401": + description: Unauthorized access + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + "403": + description: user account is disabled + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + default: + description: Unsuccessful authentication + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + /signout: + post: + operationId: PostSignout + summary: Expire the current session + parameters: + - $ref: "#/components/parameters/TraceSpan" + responses: + "204": + description: Session successfully expired + "401": + description: Unauthorized access + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + default: + description: Unsuccessful session expiry + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + /: + get: + operationId: GetRoutes + summary: Map of all top level routes available + parameters: + - $ref: "#/components/parameters/TraceSpan" + responses: + default: + description: All routes + content: + application/json: + schema: + $ref: "#/components/schemas/Routes" + /setup: + get: + operationId: GetSetup + tags: + - Setup + summary: Check if database has default user, org, bucket + description: Returns `true` if no default user, organization, or bucket has been created. + parameters: + - $ref: "#/components/parameters/TraceSpan" + responses: + "200": + description: allowed true or false + content: + application/json: + schema: + $ref: "#/components/schemas/IsOnboarding" + post: + operationId: PostSetup + tags: + - Setup + summary: Set up initial user, org and bucket + description: Post an onboarding request to set up initial user, org and bucket. + parameters: + - $ref: "#/components/parameters/TraceSpan" + requestBody: + description: Source to create + required: true + content: + application/json: + schema: + $ref: "#/components/schemas/OnboardingRequest" + responses: + "201": + description: Created default user, bucket, org + content: + application/json: + schema: + $ref: "#/components/schemas/OnboardingResponse" + default: + description: Unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + /setup/user: + post: + operationId: PostSetupUser + tags: + - Setup + summary: Set up a new user, org and bucket + description: Post an onboarding request to set up a new user, org and bucket. + parameters: + - $ref: "#/components/parameters/TraceSpan" + requestBody: + description: Source to create + required: true + content: + application/json: + schema: + $ref: "#/components/schemas/OnboardingRequest" + responses: + "201": + description: Created default user, bucket, org + content: + application/json: + schema: + $ref: "#/components/schemas/OnboardingResponse" + default: + description: Unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + /documents/templates: + get: + operationId: GetDocumentsTemplates + tags: + - Templates + parameters: + - $ref: "#/components/parameters/TraceSpan" + - in: query + name: org + description: Specifies the name of the organization of the template. + schema: + type: string + - in: query + name: orgID + description: Specifies the organization ID of the template. + schema: + type: string + responses: + "200": + description: A list of template documents + content: + application/json: + schema: + $ref: "#/components/schemas/Documents" + default: + description: Unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + post: + operationId: PostDocumentsTemplates + tags: + - Templates + summary: Create a template + parameters: + - $ref: "#/components/parameters/TraceSpan" + requestBody: + description: Template that will be created + required: true + content: + application/json: + schema: + $ref: "#/components/schemas/DocumentCreate" + responses: + "201": + description: Template created + content: + application/json: + schema: + $ref: "#/components/schemas/Document" + default: + description: Unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + "/documents/templates/{templateID}": + get: + operationId: GetDocumentsTemplatesID + tags: + - Templates + parameters: + - $ref: "#/components/parameters/TraceSpan" + - in: path + name: templateID + schema: + type: string + required: true + description: The template ID. + responses: + "200": + description: The template requested + content: + application/json: + schema: + $ref: "#/components/schemas/Document" + default: + description: Unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + put: + operationId: PutDocumentsTemplatesID + tags: + - Templates + parameters: + - $ref: "#/components/parameters/TraceSpan" + - in: path + name: templateID + schema: + type: string + required: true + description: The template ID. + requestBody: + description: Template that will be updated + required: true + content: + application/json: + schema: + $ref: "#/components/schemas/DocumentUpdate" + responses: + "200": + description: The newly updated template + content: + application/json: + schema: + $ref: "#/components/schemas/Document" + default: + description: Unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + delete: + operationId: DeleteDocumentsTemplatesID + tags: + - Templates + summary: Delete a template + parameters: + - $ref: "#/components/parameters/TraceSpan" + - in: path + name: templateID + schema: + type: string + required: true + description: The template ID. + responses: + "204": + description: Delete has been accepted + default: + description: Unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + "/documents/templates/{templateID}/labels": + get: + operationId: GetDocumentsTemplatesIDLabels + tags: + - Templates + summary: List all labels for a template + parameters: + - $ref: "#/components/parameters/TraceSpan" + - in: path + name: templateID + schema: + type: string + required: true + description: The template ID. + responses: + "200": + description: A list of all labels for a template + content: + application/json: + schema: + $ref: "#/components/schemas/LabelsResponse" + default: + description: Unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + post: + operationId: PostDocumentsTemplatesIDLabels + tags: + - Templates + summary: Add a label to a template + parameters: + - $ref: "#/components/parameters/TraceSpan" + - in: path + name: templateID + schema: + type: string + required: true + description: The template ID. + requestBody: + description: Label to add + required: true + content: + application/json: + schema: + $ref: "#/components/schemas/LabelMapping" + responses: + "201": + description: The label added to the template + content: + application/json: + schema: + $ref: "#/components/schemas/LabelResponse" + default: + description: Unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + "/documents/templates/{templateID}/labels/{labelID}": + delete: + operationId: DeleteDocumentsTemplatesIDLabelsID + tags: + - Templates + summary: Delete a label from a template + parameters: + - $ref: "#/components/parameters/TraceSpan" + - in: path + name: templateID + schema: + type: string + required: true + description: The template ID. + - in: path + name: labelID + schema: + type: string + required: true + description: The label ID. + responses: + "204": + description: Delete has been accepted + "404": + description: Template not found + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + default: + description: Unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + /dbrps: + get: + operationId: GetDBRPs + tags: + - DBRPs + summary: List all database retention policy mappings + parameters: + - $ref: "#/components/parameters/TraceSpan" + - in: query + name: orgID + required: true + description: Specifies the organization ID to filter on + schema: + type: string + - in: query + name: id + description: Specifies the mapping ID to filter on + schema: + type: string + - in: query + name: bucketID + description: Specifies the bucket ID to filter on + schema: + type: string + - in: query + name: default + description: Specifies filtering on default + schema: + type: boolean + - in: query + name: db + description: Specifies the database to filter on + schema: + type: string + - in: query + name: rp + description: Specifies the retention policy to filter on + schema: + type: string + responses: + "200": + description: A list of all database retention policy mappings + content: + application/json: + schema: + $ref: "#/components/schemas/DBRPs" + "400": + description: if any of the parameter passed is invalid + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + default: + description: Unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + post: + operationId: PostDBRP + tags: + - DBRPs + summary: Add a database retention policy mapping + parameters: + - $ref: "#/components/parameters/TraceSpan" + requestBody: + description: The database retention policy mapping to add + required: true + content: + application/json: + schema: + $ref: "#/components/schemas/DBRP" + responses: + "201": + description: Database retention policy mapping created + content: + application/json: + schema: + $ref: "#/components/schemas/DBRP" + "400": + description: if any of the IDs in the mapping is invalid + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + default: + description: Unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + "/dbrps/{dbrpID}": + get: + operationId: GetDBRPsID + tags: + - DBRPs + summary: Retrieve a database retention policy mapping + parameters: + - $ref: "#/components/parameters/TraceSpan" + - in: query + name: orgID + required: true + description: Specifies the organization ID of the mapping + schema: + type: string + - in: path + name: dbrpID + schema: + type: string + required: true + description: The database retention policy mapping ID + responses: + "200": + description: The database retention policy requested + content: + application/json: + schema: + $ref: "#/components/schemas/DBRP" + "400": + description: if any of the IDs passed is invalid + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + default: + description: Unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + patch: + operationId: PatchDBRPID + tags: + - DBRPs + summary: Update a database retention policy mapping + requestBody: + description: Database retention policy update to apply + required: true + content: + application/json: + schema: + $ref: "#/components/schemas/DBRPUpdate" + parameters: + - $ref: "#/components/parameters/TraceSpan" + - in: query + name: orgID + required: true + description: Specifies the organization ID of the mapping + schema: + type: string + - in: path + name: dbrpID + schema: + type: string + required: true + description: The database retention policy mapping. + responses: + "200": + description: An updated mapping + content: + application/json: + schema: + $ref: "#/components/schemas/DBRP" + "404": + description: The mapping was not found + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + "400": + description: if any of the IDs passed is invalid + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + default: + description: Unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + delete: + operationId: DeleteDBRPID + tags: + - DBRPs + summary: Delete a database retention policy + parameters: + - $ref: "#/components/parameters/TraceSpan" + - in: query + name: orgID + required: true + description: Specifies the organization ID of the mapping + schema: + type: string + - in: path + name: dbrpID + schema: + type: string + required: true + description: The database retention policy mapping + responses: + "204": + description: Delete has been accepted + "400": + description: if any of the IDs passed is invalid + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + default: + description: Unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + /telegraf/plugins: + get: + operationId: GetTelegrafPlugins + parameters: + - $ref: "#/components/parameters/TraceSpan" + - in: query + name: type + description: The type of plugin desired. + schema: + type: string + responses: + "200": + description: A list of Telegraf plugins. + content: + application/json: + schema: + $ref: "#/components/schemas/TelegrafPlugins" + default: + description: Unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + /telegrafs: + get: + operationId: GetTelegrafs + tags: + - Telegrafs + parameters: + - $ref: "#/components/parameters/TraceSpan" + - in: query + name: orgID + description: The organization ID the Telegraf config belongs to. + schema: + type: string + responses: + "200": + description: A list of Telegraf configs + content: + application/json: + schema: + $ref: "#/components/schemas/Telegrafs" + default: + description: Unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + post: + operationId: PostTelegrafs + tags: + - Telegrafs + summary: Create a Telegraf config + parameters: + - $ref: "#/components/parameters/TraceSpan" + requestBody: + description: Telegraf config to create + required: true + content: + application/json: + schema: + $ref: "#/components/schemas/TelegrafRequest" + responses: + "201": + description: Telegraf config created + content: + application/json: + schema: + $ref: "#/components/schemas/Telegraf" + default: + description: Unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + "/telegrafs/{telegrafID}": + get: + operationId: GetTelegrafsID + tags: + - Telegrafs + summary: Retrieve a Telegraf config + parameters: + - $ref: "#/components/parameters/TraceSpan" + - in: path + name: telegrafID + schema: + type: string + required: true + description: The Telegraf config ID. + - in: header + name: Accept + required: false + schema: + type: string + default: application/toml + enum: + - application/toml + - application/json + - application/octet-stream + responses: + "200": + description: Telegraf config details + content: + application/toml: + example: "[agent]\ninterval = \"10s\"" + schema: + type: string + application/json: + schema: + $ref: "#/components/schemas/Telegraf" + application/octet-stream: + example: "[agent]\ninterval = \"10s\"" + schema: + type: string + default: + description: Unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + put: + operationId: PutTelegrafsID + tags: + - Telegrafs + summary: Update a Telegraf config + parameters: + - $ref: "#/components/parameters/TraceSpan" + - in: path + name: telegrafID + schema: + type: string + required: true + description: The Telegraf config ID. + requestBody: + description: Telegraf config update to apply + required: true + content: + application/json: + schema: + $ref: "#/components/schemas/TelegrafRequest" + responses: + "200": + description: An updated Telegraf config + content: + application/json: + schema: + $ref: "#/components/schemas/Telegraf" + default: + description: Unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + delete: + operationId: DeleteTelegrafsID + tags: + - Telegrafs + summary: Delete a Telegraf config + parameters: + - $ref: "#/components/parameters/TraceSpan" + - in: path + name: telegrafID + schema: + type: string + required: true + description: The Telegraf config ID. + responses: + "204": + description: Delete has been accepted + default: + description: Unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + "/telegrafs/{telegrafID}/labels": + get: + operationId: GetTelegrafsIDLabels + tags: + - Telegrafs + summary: List all labels for a Telegraf config + parameters: + - $ref: "#/components/parameters/TraceSpan" + - in: path + name: telegrafID + schema: + type: string + required: true + description: The Telegraf config ID. + responses: + "200": + description: A list of all labels for a Telegraf config + content: + application/json: + schema: + $ref: "#/components/schemas/LabelsResponse" + default: + description: Unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + post: + operationId: PostTelegrafsIDLabels + tags: + - Telegrafs + summary: Add a label to a Telegraf config + parameters: + - $ref: "#/components/parameters/TraceSpan" + - in: path + name: telegrafID + schema: + type: string + required: true + description: The Telegraf config ID. + requestBody: + description: Label to add + required: true + content: + application/json: + schema: + $ref: "#/components/schemas/LabelMapping" + responses: + "201": + description: The label added to the Telegraf config + content: + application/json: + schema: + $ref: "#/components/schemas/LabelResponse" + default: + description: Unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + "/telegrafs/{telegrafID}/labels/{labelID}": + delete: + operationId: DeleteTelegrafsIDLabelsID + tags: + - Telegrafs + summary: Delete a label from a Telegraf config + parameters: + - $ref: "#/components/parameters/TraceSpan" + - in: path + name: telegrafID + schema: + type: string + required: true + description: The Telegraf config ID. + - in: path + name: labelID + schema: + type: string + required: true + description: The label ID. + responses: + "204": + description: Delete has been accepted + "404": + description: Telegraf config not found + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + default: + description: Unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + "/telegrafs/{telegrafID}/members": + get: + operationId: GetTelegrafsIDMembers + tags: + - Users + - Telegrafs + summary: List all users with member privileges for a Telegraf config + parameters: + - $ref: "#/components/parameters/TraceSpan" + - in: path + name: telegrafID + schema: + type: string + required: true + description: The Telegraf config ID. + responses: + "200": + description: A list of Telegraf config members + content: + application/json: + schema: + $ref: "#/components/schemas/ResourceMembers" + default: + description: Unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + post: + operationId: PostTelegrafsIDMembers + tags: + - Users + - Telegrafs + summary: Add a member to a Telegraf config + parameters: + - $ref: "#/components/parameters/TraceSpan" + - in: path + name: telegrafID + schema: + type: string + required: true + description: The Telegraf config ID. + requestBody: + description: User to add as member + required: true + content: + application/json: + schema: + $ref: "#/components/schemas/AddResourceMemberRequestBody" + responses: + "201": + description: Member added to Telegraf config + content: + application/json: + schema: + $ref: "#/components/schemas/ResourceMember" + default: + description: Unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + "/telegrafs/{telegrafID}/members/{userID}": + delete: + operationId: DeleteTelegrafsIDMembersID + tags: + - Users + - Telegrafs + summary: Remove a member from a Telegraf config + parameters: + - $ref: "#/components/parameters/TraceSpan" + - in: path + name: userID + schema: + type: string + required: true + description: The ID of the member to remove. + - in: path + name: telegrafID + schema: + type: string + required: true + description: The Telegraf config ID. + responses: + "204": + description: Member removed + default: + description: Unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + "/telegrafs/{telegrafID}/owners": + get: + operationId: GetTelegrafsIDOwners + tags: + - Users + - Telegrafs + summary: List all owners of a Telegraf config + parameters: + - $ref: "#/components/parameters/TraceSpan" + - in: path + name: telegrafID + schema: + type: string + required: true + description: The Telegraf config ID. + responses: + "200": + description: A list of Telegraf config owners + content: + application/json: + schema: + $ref: "#/components/schemas/ResourceOwners" + default: + description: Unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + post: + operationId: PostTelegrafsIDOwners + tags: + - Users + - Telegrafs + summary: Add an owner to a Telegraf config + parameters: + - $ref: "#/components/parameters/TraceSpan" + - in: path + name: telegrafID + schema: + type: string + required: true + description: The Telegraf config ID. + requestBody: + description: User to add as owner + required: true + content: + application/json: + schema: + $ref: "#/components/schemas/AddResourceMemberRequestBody" + responses: + "201": + description: Telegraf config owner added + content: + application/json: + schema: + $ref: "#/components/schemas/ResourceOwner" + default: + description: Unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + "/telegrafs/{telegrafID}/owners/{userID}": + delete: + operationId: DeleteTelegrafsIDOwnersID + tags: + - Users + - Telegrafs + summary: Remove an owner from a Telegraf config + parameters: + - $ref: "#/components/parameters/TraceSpan" + - in: path + name: userID + schema: + type: string + required: true + description: The ID of the owner to remove. + - in: path + name: telegrafID + schema: + type: string + required: true + description: The Telegraf config ID. + responses: + "204": + description: Owner removed + default: + description: Unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + /scrapers: + get: + operationId: GetScrapers + tags: + - ScraperTargets + summary: Get all scraper targets + parameters: + - $ref: "#/components/parameters/TraceSpan" + - in: query + name: name + description: Specifies the name of the scraper target. + schema: + type: string + - in: query + name: id + description: List of scraper target IDs to return. If both `id` and `owner` are specified, only `id` is used. + schema: + type: array + items: + type: string + - in: query + name: orgID + description: Specifies the organization ID of the scraper target. + schema: + type: string + - in: query + name: org + description: Specifies the organization name of the scraper target. + schema: + type: string + responses: + "200": + description: All scraper targets + content: + application/json: + schema: + $ref: "#/components/schemas/ScraperTargetResponses" + post: + operationId: PostScrapers + summary: Create a scraper target + tags: + - ScraperTargets + parameters: + - $ref: "#/components/parameters/TraceSpan" + requestBody: + description: Scraper target to create + required: true + content: + application/json: + schema: + $ref: "#/components/schemas/ScraperTargetRequest" + responses: + "201": + description: Scraper target created + content: + application/json: + schema: + $ref: "#/components/schemas/ScraperTargetResponse" + default: + description: Internal server error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + "/scrapers/{scraperTargetID}": + get: + operationId: GetScrapersID + tags: + - ScraperTargets + summary: Get a scraper target by ID + parameters: + - $ref: "#/components/parameters/TraceSpan" + - in: path + name: scraperTargetID + required: true + schema: + type: string + description: The scraper target ID. + responses: + "200": + description: Scraper target updated + content: + application/json: + schema: + $ref: "#/components/schemas/ScraperTargetResponse" + default: + description: Internal server error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + delete: + operationId: DeleteScrapersID + tags: + - ScraperTargets + summary: Delete a scraper target + parameters: + - $ref: "#/components/parameters/TraceSpan" + - in: path + name: scraperTargetID + required: true + schema: + type: string + description: The scraper target ID. + responses: + "204": + description: Scraper target deleted + default: + description: Internal server error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + patch: + operationId: PatchScrapersID + summary: Update a scraper target + tags: + - ScraperTargets + parameters: + - $ref: "#/components/parameters/TraceSpan" + - in: path + name: scraperTargetID + required: true + schema: + type: string + description: The scraper target ID. + requestBody: + description: Scraper target update to apply + required: true + content: + application/json: + schema: + $ref: "#/components/schemas/ScraperTargetRequest" + responses: + "200": + description: Scraper target updated + content: + application/json: + schema: + $ref: "#/components/schemas/ScraperTargetResponse" + default: + description: Internal server error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + "/scrapers/{scraperTargetID}/labels": + get: + operationId: GetScrapersIDLabels + tags: + - ScraperTargets + summary: List all labels for a scraper target + parameters: + - $ref: "#/components/parameters/TraceSpan" + - in: path + name: scraperTargetID + schema: + type: string + required: true + description: The scraper target ID. + responses: + "200": + description: A list of all labels for a scraper target + content: + application/json: + schema: + $ref: "#/components/schemas/LabelsResponse" + default: + description: Unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + post: + operationId: PostScrapersIDLabels + tags: + - ScraperTargets + summary: Add a label to a scraper target + parameters: + - $ref: "#/components/parameters/TraceSpan" + - in: path + name: scraperTargetID + schema: + type: string + required: true + description: The scraper target ID. + requestBody: + description: Label to add + required: true + content: + application/json: + schema: + $ref: "#/components/schemas/LabelMapping" + responses: + "201": + description: The newly added label + content: + application/json: + schema: + $ref: "#/components/schemas/LabelResponse" + default: + description: Unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + "/scrapers/{scraperTargetID}/labels/{labelID}": + delete: + operationId: DeleteScrapersIDLabelsID + tags: + - ScraperTargets + summary: Delete a label from a scraper target + parameters: + - $ref: "#/components/parameters/TraceSpan" + - in: path + name: scraperTargetID + schema: + type: string + required: true + description: The scraper target ID. + - in: path + name: labelID + schema: + type: string + required: true + description: The label ID. + responses: + "204": + description: Delete has been accepted + "404": + description: Scraper target not found + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + default: + description: Unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + "/scrapers/{scraperTargetID}/members": + get: + operationId: GetScrapersIDMembers + tags: + - Users + - ScraperTargets + summary: List all users with member privileges for a scraper target + parameters: + - $ref: "#/components/parameters/TraceSpan" + - in: path + name: scraperTargetID + schema: + type: string + required: true + description: The scraper target ID. + responses: + "200": + description: A list of scraper target members + content: + application/json: + schema: + $ref: "#/components/schemas/ResourceMembers" + default: + description: Unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + post: + operationId: PostScrapersIDMembers + tags: + - Users + - ScraperTargets + summary: Add a member to a scraper target + parameters: + - $ref: "#/components/parameters/TraceSpan" + - in: path + name: scraperTargetID + schema: + type: string + required: true + description: The scraper target ID. + requestBody: + description: User to add as member + required: true + content: + application/json: + schema: + $ref: "#/components/schemas/AddResourceMemberRequestBody" + responses: + "201": + description: Member added to scraper targets + content: + application/json: + schema: + $ref: "#/components/schemas/ResourceMember" + default: + description: Unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + "/scrapers/{scraperTargetID}/members/{userID}": + delete: + operationId: DeleteScrapersIDMembersID + tags: + - Users + - ScraperTargets + summary: Remove a member from a scraper target + parameters: + - $ref: "#/components/parameters/TraceSpan" + - in: path + name: userID + schema: + type: string + required: true + description: The ID of member to remove. + - in: path + name: scraperTargetID + schema: + type: string + required: true + description: The scraper target ID. + responses: + "204": + description: Member removed + default: + description: Unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + "/scrapers/{scraperTargetID}/owners": + get: + operationId: GetScrapersIDOwners + tags: + - Users + - ScraperTargets + summary: List all owners of a scraper target + parameters: + - $ref: "#/components/parameters/TraceSpan" + - in: path + name: scraperTargetID + schema: + type: string + required: true + description: The scraper target ID. + responses: + "200": + description: A list of scraper target owners + content: + application/json: + schema: + $ref: "#/components/schemas/ResourceOwners" + default: + description: Unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + post: + operationId: PostScrapersIDOwners + tags: + - Users + - ScraperTargets + summary: Add an owner to a scraper target + parameters: + - $ref: "#/components/parameters/TraceSpan" + - in: path + name: scraperTargetID + schema: + type: string + required: true + description: The scraper target ID. + requestBody: + description: User to add as owner + required: true + content: + application/json: + schema: + $ref: "#/components/schemas/AddResourceMemberRequestBody" + responses: + "201": + description: Scraper target owner added + content: + application/json: + schema: + $ref: "#/components/schemas/ResourceOwner" + default: + description: Unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + "/scrapers/{scraperTargetID}/owners/{userID}": + delete: + operationId: DeleteScrapersIDOwnersID + tags: + - Users + - ScraperTargets + summary: Remove an owner from a scraper target + parameters: + - $ref: "#/components/parameters/TraceSpan" + - in: path + name: userID + schema: + type: string + required: true + description: The ID of owner to remove. + - in: path + name: scraperTargetID + schema: + type: string + required: true + description: The scraper target ID. + responses: + "204": + description: Owner removed + default: + description: Unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + /variables: + get: + operationId: GetVariables + tags: + - Variables + summary: Get all variables + parameters: + - $ref: "#/components/parameters/TraceSpan" + - in: query + name: org + description: The organization name. + schema: + type: string + - in: query + name: orgID + description: The organization ID. + schema: + type: string + responses: + "200": + description: All variables for an organization + content: + application/json: + schema: + $ref: "#/components/schemas/Variables" + "400": + description: Invalid request + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + default: + description: Internal server error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + post: + operationId: PostVariables + summary: Create a variable + tags: + - Variables + parameters: + - $ref: "#/components/parameters/TraceSpan" + requestBody: + description: Variable to create + required: true + content: + application/json: + schema: + $ref: "#/components/schemas/Variable" + responses: + "201": + description: Variable created + content: + application/json: + schema: + $ref: "#/components/schemas/Variable" + default: + description: Internal server error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + "/variables/{variableID}": + get: + operationId: GetVariablesID + tags: + - Variables + summary: Get a variable + parameters: + - $ref: "#/components/parameters/TraceSpan" + - in: path + name: variableID + required: true + schema: + type: string + description: The variable ID. + responses: + "200": + description: Variable found + content: + application/json: + schema: + $ref: "#/components/schemas/Variable" + "404": + description: Variable not found + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + default: + description: Internal server error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + delete: + operationId: DeleteVariablesID + tags: + - Variables + summary: Delete a variable + parameters: + - $ref: "#/components/parameters/TraceSpan" + - in: path + name: variableID + required: true + schema: + type: string + description: The variable ID. + responses: + "204": + description: Variable deleted + default: + description: Internal server error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + patch: + operationId: PatchVariablesID + summary: Update a variable + tags: + - Variables + parameters: + - $ref: "#/components/parameters/TraceSpan" + - in: path + name: variableID + required: true + schema: + type: string + description: The variable ID. + requestBody: + description: Variable update to apply + required: true + content: + application/json: + schema: + $ref: "#/components/schemas/Variable" + responses: + "200": + description: Variable updated + content: + application/json: + schema: + $ref: "#/components/schemas/Variable" + default: + description: Internal server error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + put: + operationId: PutVariablesID + summary: Replace a variable + tags: + - Variables + parameters: + - $ref: "#/components/parameters/TraceSpan" + - in: path + name: variableID + required: true + schema: + type: string + description: The variable ID. + requestBody: + description: Variable to replace + required: true + content: + application/json: + schema: + $ref: "#/components/schemas/Variable" + responses: + "200": + description: Variable updated + content: + application/json: + schema: + $ref: "#/components/schemas/Variable" + default: + description: Internal server error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + "/variables/{variableID}/labels": + get: + operationId: GetVariablesIDLabels + tags: + - Variables + summary: List all labels for a variable + parameters: + - $ref: "#/components/parameters/TraceSpan" + - in: path + name: variableID + schema: + type: string + required: true + description: The variable ID. + responses: + "200": + description: A list of all labels for a variable + content: + application/json: + schema: + $ref: "#/components/schemas/LabelsResponse" + default: + description: Unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + post: + operationId: PostVariablesIDLabels + tags: + - Variables + summary: Add a label to a variable + parameters: + - $ref: "#/components/parameters/TraceSpan" + - in: path + name: variableID + schema: + type: string + required: true + description: The variable ID. + requestBody: + description: Label to add + required: true + content: + application/json: + schema: + $ref: "#/components/schemas/LabelMapping" + responses: + "201": + description: The newly added label + content: + application/json: + schema: + $ref: "#/components/schemas/LabelResponse" + default: + description: Unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + "/variables/{variableID}/labels/{labelID}": + delete: + operationId: DeleteVariablesIDLabelsID + tags: + - Variables + summary: Delete a label from a variable + parameters: + - $ref: "#/components/parameters/TraceSpan" + - in: path + name: variableID + schema: + type: string + required: true + description: The variable ID. + - in: path + name: labelID + schema: + type: string + required: true + description: The label ID to delete. + responses: + "204": + description: Delete has been accepted + "404": + description: Variable not found + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + default: + description: Unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + /write: + post: + operationId: PostWrite + tags: + - Write + summary: Write time series data into InfluxDB + requestBody: + description: Line protocol body + required: true + content: + text/plain: + schema: + type: string + parameters: + - $ref: "#/components/parameters/TraceSpan" + - in: header + name: Content-Encoding + description: When present, its value indicates to the database that compression is applied to the line-protocol body. + schema: + type: string + description: Specifies that the line protocol in the body is encoded with gzip or not encoded with identity. + default: identity + enum: + - gzip + - identity + - in: header + name: Content-Type + description: Content-Type is used to indicate the format of the data sent to the server. + schema: + type: string + description: Text/plain specifies the text line protocol; charset is assumed to be utf-8. + default: text/plain; charset=utf-8 + enum: + - text/plain + - text/plain; charset=utf-8 + - application/vnd.influx.arrow + - in: header + name: Content-Length + description: Content-Length is an entity header is indicating the size of the entity-body, in bytes, sent to the database. If the length is greater than the database max body configuration option, a 413 response is sent. + schema: + type: integer + description: The length in decimal number of octets. + - in: header + name: Accept + description: Specifies the return content format. + schema: + type: string + description: The return format for errors. + default: application/json + enum: + - application/json + - in: query + name: org + description: Specifies the destination organization for writes. Takes either the ID or Name interchangeably. If both `orgID` and `org` are specified, `org` takes precedence. + required: true + schema: + type: string + description: All points within batch are written to this organization. + - in: query + name: orgID + description: Specifies the ID of the destination organization for writes. If both `orgID` and `org` are specified, `org` takes precedence. + schema: + type: string + - in: query + name: bucket + description: The destination bucket for writes. + required: true + schema: + type: string + description: All points within batch are written to this bucket. + - in: query + name: precision + description: The precision for the unix timestamps within the body line-protocol. + schema: + $ref: "#/components/schemas/WritePrecision" + responses: + "204": + description: Write data is correctly formatted and accepted for writing to the bucket. + "400": + description: Line protocol poorly formed and no points were written. Response can be used to determine the first malformed line in the body line-protocol. All data in body was rejected and not written. + content: + application/json: + schema: + $ref: "#/components/schemas/LineProtocolError" + "401": + description: Token does not have sufficient permissions to write to this organization and bucket or the organization and bucket do not exist. + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + "403": + description: No token was sent and they are required. + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + "413": + description: Write has been rejected because the payload is too large. Error message returns max size supported. All data in body was rejected and not written. + content: + application/json: + schema: + $ref: "#/components/schemas/LineProtocolLengthError" + "429": + description: Token is temporarily over quota. The Retry-After header describes when to try the write again. + headers: + Retry-After: + description: A non-negative decimal integer indicating the seconds to delay after the response is received. + schema: + type: integer + format: int32 + "503": + description: Server is temporarily unavailable to accept writes. The Retry-After header describes when to try the write again. + headers: + Retry-After: + description: A non-negative decimal integer indicating the seconds to delay after the response is received. + schema: + type: integer + format: int32 + default: + description: Internal server error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + /delete: + post: + operationId: PostDelete + summary: Delete time series data from InfluxDB + requestBody: + description: Predicate delete request + required: true + content: + application/json: + schema: + $ref: "#/components/schemas/DeletePredicateRequest" + parameters: + - $ref: "#/components/parameters/TraceSpan" + - in: query + name: org + description: Specifies the organization to delete data from. + schema: + type: string + description: Only points from this organization are deleted. + - in: query + name: bucket + description: Specifies the bucket to delete data from. + schema: + type: string + description: Only points from this bucket are deleted. + - in: query + name: orgID + description: Specifies the organization ID of the resource. + schema: + type: string + - in: query + name: bucketID + description: Specifies the bucket ID to delete data from. + schema: + type: string + description: Only points from this bucket ID are deleted. + responses: + "204": + description: delete has been accepted + "400": + description: invalid request. + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + "404": + description: the bucket or organization is not found. + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + "403": + description: no token was sent or does not have sufficient permissions. + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + default: + description: internal server error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + /ready: + servers: + - url: / + get: + operationId: GetReady + tags: + - Ready + summary: Get the readiness of an instance at startup + parameters: + - $ref: "#/components/parameters/TraceSpan" + responses: + "200": + description: The instance is ready + content: + application/json: + schema: + $ref: "#/components/schemas/Ready" + default: + description: Unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + /health: + servers: + - url: / + get: + operationId: GetHealth + tags: + - Health + summary: Get the health of an instance + parameters: + - $ref: "#/components/parameters/TraceSpan" + responses: + "200": + description: The instance is healthy + content: + application/json: + schema: + $ref: "#/components/schemas/HealthCheck" + "503": + description: The instance is unhealthy + content: + application/json: + schema: + $ref: "#/components/schemas/HealthCheck" + default: + description: Unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + /sources: + post: + operationId: PostSources + tags: + - Sources + summary: Create a source + parameters: + - $ref: "#/components/parameters/TraceSpan" + requestBody: + description: Source to create + required: true + content: + application/json: + schema: + $ref: "#/components/schemas/Source" + responses: + "201": + description: Created Source + content: + application/json: + schema: + $ref: "#/components/schemas/Source" + default: + description: Unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + get: + operationId: GetSources + tags: + - Sources + summary: Get all sources + parameters: + - $ref: "#/components/parameters/TraceSpan" + - in: query + name: org + description: The organization name. + schema: + type: string + responses: + "200": + description: All sources + content: + application/json: + schema: + $ref: "#/components/schemas/Sources" + default: + description: Unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + /sources/{sourceID}: + delete: + operationId: DeleteSourcesID + tags: + - Sources + summary: Delete a source + parameters: + - $ref: "#/components/parameters/TraceSpan" + - in: path + name: sourceID + schema: + type: string + required: true + description: The source ID. + responses: + "204": + description: Delete has been accepted + "404": + description: View not found + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + default: + description: Unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + patch: + operationId: PatchSourcesID + tags: + - Sources + summary: Update a Source + parameters: + - $ref: "#/components/parameters/TraceSpan" + - in: path + name: sourceID + schema: + type: string + required: true + description: The source ID. + requestBody: + description: Source update + required: true + content: + application/json: + schema: + $ref: "#/components/schemas/Source" + responses: + "200": + description: Created Source + content: + application/json: + schema: + $ref: "#/components/schemas/Source" + "404": + description: Source not found + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + default: + description: Unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + get: + operationId: GetSourcesID + tags: + - Sources + summary: Get a source + parameters: + - $ref: "#/components/parameters/TraceSpan" + - in: path + name: sourceID + schema: + type: string + required: true + description: The source ID. + responses: + "200": + description: A source + content: + application/json: + schema: + $ref: "#/components/schemas/Source" + "404": + description: Source not found + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + default: + description: Unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + /sources/{sourceID}/health: + get: + operationId: GetSourcesIDHealth + tags: + - Sources + summary: Get the health of a source + parameters: + - $ref: "#/components/parameters/TraceSpan" + - in: path + name: sourceID + schema: + type: string + required: true + description: The source ID. + responses: + "200": + description: The source is healthy + content: + application/json: + schema: + $ref: "#/components/schemas/HealthCheck" + "503": + description: The source is not healthy + content: + application/json: + schema: + $ref: "#/components/schemas/HealthCheck" + default: + description: Unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + /sources/{sourceID}/buckets: + get: + operationId: GetSourcesIDBuckets + tags: + - Sources + - Buckets + summary: Get buckets in a source + parameters: + - $ref: "#/components/parameters/TraceSpan" + - in: path + name: sourceID + schema: + type: string + required: true + description: The source ID. + - in: query + name: org + description: The organization name. + schema: + type: string + responses: + "200": + description: A source + content: + application/json: + schema: + $ref: "#/components/schemas/Buckets" + "404": + description: Source not found + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + default: + description: Unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + /labels: + post: + operationId: PostLabels + tags: + - Labels + summary: Create a label + requestBody: + description: Label to create + required: true + content: + application/json: + schema: + $ref: "#/components/schemas/LabelCreateRequest" + responses: + "201": + description: Added label + content: + application/json: + schema: + $ref: "#/components/schemas/LabelResponse" + default: + description: Unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + get: + operationId: GetLabels + tags: + - Labels + summary: Get all labels + parameters: + - $ref: "#/components/parameters/TraceSpan" + - in: query + name: orgID + description: The organization ID. + schema: + type: string + responses: + "200": + description: All labels + content: + application/json: + schema: + $ref: "#/components/schemas/LabelsResponse" + default: + description: Unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + /labels/{labelID}: + get: + operationId: GetLabelsID + tags: + - Labels + summary: Get a label + parameters: + - $ref: "#/components/parameters/TraceSpan" + - in: path + name: labelID + schema: + type: string + required: true + description: The ID of the label to update. + responses: + "200": + description: A label + content: + application/json: + schema: + $ref: "#/components/schemas/LabelResponse" + default: + description: Unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + patch: + operationId: PatchLabelsID + tags: + - Labels + summary: Update a label + requestBody: + description: Label update + required: true + content: + application/json: + schema: + $ref: "#/components/schemas/LabelUpdate" + parameters: + - $ref: "#/components/parameters/TraceSpan" + - in: path + name: labelID + schema: + type: string + required: true + description: The ID of the label to update. + responses: + "200": + description: Updated label + content: + application/json: + schema: + $ref: "#/components/schemas/LabelResponse" + "404": + description: Label not found + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + default: + description: Unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + delete: + operationId: DeleteLabelsID + tags: + - Labels + summary: Delete a label + parameters: + - $ref: "#/components/parameters/TraceSpan" + - in: path + name: labelID + schema: + type: string + required: true + description: The ID of the label to delete. + responses: + "204": + description: Delete has been accepted + "404": + description: Label not found + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + default: + description: Unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + /dashboards: + post: + operationId: PostDashboards + tags: + - Dashboards + summary: Create a dashboard + parameters: + - $ref: "#/components/parameters/TraceSpan" + requestBody: + description: Dashboard to create + required: true + content: + application/json: + schema: + $ref: "#/components/schemas/CreateDashboardRequest" + responses: + "201": + description: Added dashboard + content: + application/json: + schema: + oneOf: + - $ref: "#/components/schemas/Dashboard" + - $ref: "#/components/schemas/DashboardWithViewProperties" + default: + description: Unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + get: + operationId: GetDashboards + tags: + - Dashboards + summary: Get all dashboards + parameters: + - $ref: "#/components/parameters/TraceSpan" + - $ref: "#/components/parameters/Offset" + - $ref: "#/components/parameters/Limit" + - $ref: "#/components/parameters/Descending" + - in: query + name: owner + description: The owner ID. + schema: + type: string + - in: query + name: sortBy + description: The column to sort by. + schema: + type: string + enum: + - "ID" + - "CreatedAt" + - "UpdatedAt" + - in: query + name: id + description: List of dashboard IDs to return. If both `id` and `owner` are specified, only `id` is used. + schema: + type: array + items: + type: string + - in: query + name: orgID + description: The organization ID. + schema: + type: string + - in: query + name: org + description: The organization name. + schema: + type: string + responses: + "200": + description: All dashboards + content: + application/json: + schema: + $ref: "#/components/schemas/Dashboards" + default: + description: Unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + "/dashboards/{dashboardID}": + get: + operationId: GetDashboardsID + tags: + - Dashboards + summary: Get a Dashboard + parameters: + - $ref: "#/components/parameters/TraceSpan" + - in: path + name: dashboardID + schema: + type: string + required: true + description: The ID of the dashboard to update. + - in: query + name: include + required: false + schema: + type: string + enum: + - properties + description: Includes the cell view properties in the response if set to `properties` + responses: + "200": + description: Get a single dashboard + content: + application/json: + schema: + oneOf: + - $ref: "#/components/schemas/Dashboard" + - $ref: "#/components/schemas/DashboardWithViewProperties" + "404": + description: Dashboard not found + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + default: + description: Unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + patch: + operationId: PatchDashboardsID + tags: + - Dashboards + summary: Update a dashboard + requestBody: + description: Patching of a dashboard + required: true + content: + application/json: + schema: + type: object + properties: + name: + description: optional, when provided will replace the name + type: string + description: + description: optional, when provided will replace the description + type: string + cells: + description: optional, when provided will replace all existing cells with the cells provided + $ref: "#/components/schemas/CellWithViewProperties" + parameters: + - $ref: "#/components/parameters/TraceSpan" + - in: path + name: dashboardID + schema: + type: string + required: true + description: The ID of the dashboard to update. + responses: + "200": + description: Updated dashboard + content: + application/json: + schema: + $ref: "#/components/schemas/Dashboard" + "404": + description: Dashboard not found + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + default: + description: Unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + delete: + operationId: DeleteDashboardsID + tags: + - Dashboards + summary: Delete a dashboard + parameters: + - $ref: "#/components/parameters/TraceSpan" + - in: path + name: dashboardID + schema: + type: string + required: true + description: The ID of the dashboard to update. + responses: + "204": + description: Delete has been accepted + "404": + description: Dashboard not found + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + default: + description: Unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + "/dashboards/{dashboardID}/cells": + put: + operationId: PutDashboardsIDCells + tags: + - Cells + - Dashboards + summary: Replace cells in a dashboard + description: Replaces all cells in a dashboard. This is used primarily to update the positional information of all cells. + requestBody: + required: true + content: + application/json: + schema: + $ref: "#/components/schemas/Cells" + parameters: + - $ref: "#/components/parameters/TraceSpan" + - in: path + name: dashboardID + schema: + type: string + required: true + description: The ID of the dashboard to update. + responses: + "201": + description: Replaced dashboard cells + content: + application/json: + schema: + $ref: "#/components/schemas/Dashboard" + "404": + description: Dashboard not found + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + default: + description: Unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + post: + operationId: PostDashboardsIDCells + tags: + - Cells + - Dashboards + summary: Create a dashboard cell + requestBody: + description: Cell that will be added + required: true + content: + application/json: + schema: + $ref: "#/components/schemas/CreateCell" + parameters: + - $ref: "#/components/parameters/TraceSpan" + - in: path + name: dashboardID + schema: + type: string + required: true + description: The ID of the dashboard to update. + responses: + "201": + description: Cell successfully added + content: + application/json: + schema: + $ref: "#/components/schemas/Cell" + "404": + description: Dashboard not found + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + default: + description: Unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + "/dashboards/{dashboardID}/cells/{cellID}": + patch: + operationId: PatchDashboardsIDCellsID + tags: + - Cells + - Dashboards + summary: Update the non-positional information related to a cell + description: Updates the non positional information related to a cell. Updates to a single cell's positional data could cause grid conflicts. + requestBody: + required: true + content: + application/json: + schema: + $ref: "#/components/schemas/CellUpdate" + parameters: + - $ref: "#/components/parameters/TraceSpan" + - in: path + name: dashboardID + schema: + type: string + required: true + description: The ID of the dashboard to update. + - in: path + name: cellID + schema: + type: string + required: true + description: The ID of the cell to update. + responses: + "200": + description: Updated dashboard cell + content: + application/json: + schema: + $ref: "#/components/schemas/Cell" + "404": + description: Cell or dashboard not found + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + default: + description: Unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + delete: + operationId: DeleteDashboardsIDCellsID + tags: + - Cells + - Dashboards + summary: Delete a dashboard cell + parameters: + - $ref: "#/components/parameters/TraceSpan" + - in: path + name: dashboardID + schema: + type: string + required: true + description: The ID of the dashboard to delete. + - in: path + name: cellID + schema: + type: string + required: true + description: The ID of the cell to delete. + responses: + "204": + description: Cell successfully deleted + "404": + description: Cell or dashboard not found + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + default: + description: Unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + "/dashboards/{dashboardID}/cells/{cellID}/view": + get: + operationId: GetDashboardsIDCellsIDView + tags: + - Cells + - Dashboards + - Views + summary: Retrieve the view for a cell + parameters: + - $ref: "#/components/parameters/TraceSpan" + - in: path + name: dashboardID + schema: + type: string + required: true + description: The dashboard ID. + - in: path + name: cellID + schema: + type: string + required: true + description: The cell ID. + responses: + "200": + description: A dashboard cells view + content: + application/json: + schema: + $ref: "#/components/schemas/View" + "404": + description: Cell or dashboard not found + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + default: + description: Unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + patch: + operationId: PatchDashboardsIDCellsIDView + tags: + - Cells + - Dashboards + - Views + summary: Update the view for a cell + requestBody: + required: true + content: + application/json: + schema: + $ref: "#/components/schemas/View" + parameters: + - $ref: "#/components/parameters/TraceSpan" + - in: path + name: dashboardID + schema: + type: string + required: true + description: The ID of the dashboard to update. + - in: path + name: cellID + schema: + type: string + required: true + description: The ID of the cell to update. + responses: + "200": + description: Updated cell view + content: + application/json: + schema: + $ref: "#/components/schemas/View" + "404": + description: Cell or dashboard not found + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + default: + description: Unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + "/dashboards/{dashboardID}/labels": + get: + operationId: GetDashboardsIDLabels + tags: + - Dashboards + summary: List all labels for a dashboard + parameters: + - $ref: "#/components/parameters/TraceSpan" + - in: path + name: dashboardID + schema: + type: string + required: true + description: The dashboard ID. + responses: + "200": + description: A list of all labels for a dashboard + content: + application/json: + schema: + $ref: "#/components/schemas/LabelsResponse" + default: + description: Unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + post: + operationId: PostDashboardsIDLabels + tags: + - Dashboards + summary: Add a label to a dashboard + parameters: + - $ref: "#/components/parameters/TraceSpan" + - in: path + name: dashboardID + schema: + type: string + required: true + description: The dashboard ID. + requestBody: + description: Label to add + required: true + content: + application/json: + schema: + $ref: "#/components/schemas/LabelMapping" + responses: + "201": + description: The label added to the dashboard + content: + application/json: + schema: + $ref: "#/components/schemas/LabelResponse" + default: + description: Unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + "/dashboards/{dashboardID}/labels/{labelID}": + delete: + operationId: DeleteDashboardsIDLabelsID + tags: + - Dashboards + summary: Delete a label from a dashboard + parameters: + - $ref: "#/components/parameters/TraceSpan" + - in: path + name: dashboardID + schema: + type: string + required: true + description: The dashboard ID. + - in: path + name: labelID + schema: + type: string + required: true + description: The ID of the label to delete. + responses: + "204": + description: Delete has been accepted + "404": + description: Dashboard not found + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + default: + description: Unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + "/dashboards/{dashboardID}/members": + get: + operationId: GetDashboardsIDMembers + tags: + - Users + - Dashboards + summary: List all dashboard members + parameters: + - $ref: "#/components/parameters/TraceSpan" + - in: path + name: dashboardID + schema: + type: string + required: true + description: The dashboard ID. + responses: + "200": + description: A list of users who have member privileges for a dashboard + content: + application/json: + schema: + $ref: "#/components/schemas/ResourceMembers" + default: + description: Unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + post: + operationId: PostDashboardsIDMembers + tags: + - Users + - Dashboards + summary: Add a member to a dashboard + parameters: + - $ref: "#/components/parameters/TraceSpan" + - in: path + name: dashboardID + schema: + type: string + required: true + description: The dashboard ID. + requestBody: + description: User to add as member + required: true + content: + application/json: + schema: + $ref: "#/components/schemas/AddResourceMemberRequestBody" + responses: + "201": + description: Added to dashboard members + content: + application/json: + schema: + $ref: "#/components/schemas/ResourceMember" + default: + description: Unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + "/dashboards/{dashboardID}/members/{userID}": + delete: + operationId: DeleteDashboardsIDMembersID + tags: + - Users + - Dashboards + summary: Remove a member from a dashboard + parameters: + - $ref: "#/components/parameters/TraceSpan" + - in: path + name: userID + schema: + type: string + required: true + description: The ID of the member to remove. + - in: path + name: dashboardID + schema: + type: string + required: true + description: The dashboard ID. + responses: + "204": + description: Member removed + default: + description: Unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + "/dashboards/{dashboardID}/owners": + get: + operationId: GetDashboardsIDOwners + tags: + - Users + - Dashboards + summary: List all dashboard owners + parameters: + - $ref: "#/components/parameters/TraceSpan" + - in: path + name: dashboardID + schema: + type: string + required: true + description: The dashboard ID. + responses: + "200": + description: A list of users who have owner privileges for a dashboard + content: + application/json: + schema: + $ref: "#/components/schemas/ResourceOwners" + default: + description: Unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + post: + operationId: PostDashboardsIDOwners + tags: + - Users + - Dashboards + summary: Add an owner to a dashboard + parameters: + - $ref: "#/components/parameters/TraceSpan" + - in: path + name: dashboardID + schema: + type: string + required: true + description: The dashboard ID. + requestBody: + description: User to add as owner + required: true + content: + application/json: + schema: + $ref: "#/components/schemas/AddResourceMemberRequestBody" + responses: + "201": + description: Added to dashboard owners + content: + application/json: + schema: + $ref: "#/components/schemas/ResourceOwner" + default: + description: Unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + "/dashboards/{dashboardID}/owners/{userID}": + delete: + operationId: DeleteDashboardsIDOwnersID + tags: + - Users + - Dashboards + summary: Remove an owner from a dashboard + parameters: + - $ref: "#/components/parameters/TraceSpan" + - in: path + name: userID + schema: + type: string + required: true + description: The ID of the owner to remove. + - in: path + name: dashboardID + schema: + type: string + required: true + description: The dashboard ID. + responses: + "204": + description: Owner removed + default: + description: Unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + /query/ast: + post: + operationId: PostQueryAst + description: Analyzes flux query and generates a query specification. + tags: + - Query + parameters: + - $ref: "#/components/parameters/TraceSpan" + - in: header + name: Content-Type + schema: + type: string + enum: + - application/json + requestBody: + description: Analyzed Flux query to generate abstract syntax tree. + content: + application/json: + schema: + $ref: "#/components/schemas/LanguageRequest" + responses: + "200": + description: Abstract syntax tree of flux query. + content: + application/json: + schema: + $ref: "#/components/schemas/ASTResponse" + default: + description: Any response other than 200 is an internal server error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + /query/suggestions: + get: + operationId: GetQuerySuggestions + tags: + - Query + parameters: + - $ref: "#/components/parameters/TraceSpan" + responses: + "200": + description: Suggestions for next functions in call chain + content: + application/json: + schema: + $ref: "#/components/schemas/FluxSuggestions" + default: + description: Any response other than 200 is an internal server error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + "/query/suggestions/{name}": + get: + operationId: GetQuerySuggestionsName + tags: + - Query + parameters: + - $ref: "#/components/parameters/TraceSpan" + - in: path + name: name + schema: + type: string + required: true + description: The name of the branching suggestion. + responses: + "200": + description: Suggestions for next functions in call chain + content: + application/json: + schema: + $ref: "#/components/schemas/FluxSuggestion" + default: + description: Any response other than 200 is an internal server error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + /authorizations: + get: + operationId: GetAuthorizations + tags: + - Authorizations + summary: List all authorizations + parameters: + - $ref: "#/components/parameters/TraceSpan" + - in: query + name: userID + schema: + type: string + description: Only show authorizations that belong to a user ID. + - in: query + name: user + schema: + type: string + description: Only show authorizations that belong to a user name. + - in: query + name: orgID + schema: + type: string + description: Only show authorizations that belong to an organization ID. + - in: query + name: org + schema: + type: string + description: Only show authorizations that belong to a organization name. + responses: + "200": + description: A list of authorizations + content: + application/json: + schema: + $ref: "#/components/schemas/Authorizations" + default: + description: Unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + post: + operationId: PostAuthorizations + tags: + - Authorizations + summary: Create an authorization + parameters: + - $ref: "#/components/parameters/TraceSpan" + requestBody: + description: Authorization to create + required: true + content: + application/json: + schema: + $ref: "#/components/schemas/Authorization" + responses: + "201": + description: Authorization created + content: + application/json: + schema: + $ref: "#/components/schemas/Authorization" + "400": + description: Invalid request + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + default: + description: Unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + /authorizations/{authID}: + get: + operationId: GetAuthorizationsID + tags: + - Authorizations + summary: Retrieve an authorization + parameters: + - $ref: "#/components/parameters/TraceSpan" + - in: path + name: authID + schema: + type: string + required: true + description: The ID of the authorization to get. + responses: + "200": + description: Authorization details + content: + application/json: + schema: + $ref: "#/components/schemas/Authorization" + default: + description: Unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + patch: + operationId: PatchAuthorizationsID + tags: + - Authorizations + summary: Update an authorization to be active or inactive + requestBody: + description: Authorization to update + required: true + content: + application/json: + schema: + $ref: "#/components/schemas/AuthorizationUpdateRequest" + parameters: + - $ref: "#/components/parameters/TraceSpan" + - in: path + name: authID + schema: + type: string + required: true + description: The ID of the authorization to update. + responses: + "200": + description: The active or inactie authorization + content: + application/json: + schema: + $ref: "#/components/schemas/Authorization" + default: + description: Unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + delete: + operationId: DeleteAuthorizationsID + tags: + - Authorizations + summary: Delete an authorization + parameters: + - $ref: "#/components/parameters/TraceSpan" + - in: path + name: authID + schema: + type: string + required: true + description: The ID of the authorization to delete. + responses: + "204": + description: Authorization deleted + default: + description: Unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + /query/analyze: + post: + operationId: PostQueryAnalyze + tags: + - Query + summary: Analyze an InfluxQL or Flux query + parameters: + - $ref: "#/components/parameters/TraceSpan" + - in: header + name: Content-Type + schema: + type: string + enum: + - application/json + requestBody: + description: Flux or InfluxQL query to analyze + content: + application/json: + schema: + $ref: "#/components/schemas/Query" + responses: + "200": + description: Query analyze results. Errors will be empty if the query is valid. + content: + application/json: + schema: + $ref: "#/components/schemas/AnalyzeQueryResponse" + default: + description: Internal server error + headers: + X-Influx-Error: + description: Error string describing the problem + schema: + type: string + X-Influx-Reference: + description: Reference code unique to the error type + schema: + type: integer + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + /query: + post: + operationId: PostQuery + tags: + - Query + summary: Query InfluxDB + parameters: + - $ref: "#/components/parameters/TraceSpan" + - in: header + name: Accept-Encoding + description: The Accept-Encoding request HTTP header advertises which content encoding, usually a compression algorithm, the client is able to understand. + schema: + type: string + description: Specifies that the query response in the body should be encoded with gzip or not encoded with identity. + default: identity + enum: + - gzip + - identity + - in: header + name: Content-Type + schema: + type: string + enum: + - application/json + - application/vnd.flux + - in: query + name: org + description: Specifies the name of the organization executing the query. Takes either the ID or Name interchangeably. If both `orgID` and `org` are specified, `org` takes precedence. + schema: + type: string + - in: query + name: orgID + description: Specifies the ID of the organization executing the query. If both `orgID` and `org` are specified, `org` takes precedence. + schema: + type: string + requestBody: + description: Flux query or specification to execute + content: + application/json: + schema: + oneOf: + - $ref: "#/components/schemas/Query" + - $ref: "#/components/schemas/InfluxQLQuery" + application/vnd.flux: + schema: + type: string + responses: + "200": + description: Query results + headers: + Content-Encoding: + description: The Content-Encoding entity header is used to compress the media-type. When present, its value indicates which encodings were applied to the entity-body + schema: + type: string + description: Specifies that the response in the body is encoded with gzip or not encoded with identity. + default: identity + enum: + - gzip + - identity + Trace-Id: + description: The Trace-Id header reports the request's trace ID, if one was generated. + schema: + type: string + description: Specifies the request's trace ID. + content: + text/csv: + schema: + type: string + example: > + result,table,_start,_stop,_time,region,host,_value + mean,0,2018-05-08T20:50:00Z,2018-05-08T20:51:00Z,2018-05-08T20:50:00Z,east,A,15.43 + mean,0,2018-05-08T20:50:00Z,2018-05-08T20:51:00Z,2018-05-08T20:50:20Z,east,B,59.25 + mean,0,2018-05-08T20:50:00Z,2018-05-08T20:51:00Z,2018-05-08T20:50:40Z,east,C,52.62 + application/vnd.influx.arrow: + schema: + type: string + format: binary + "429": + description: Token is temporarily over quota. The Retry-After header describes when to try the read again. + headers: + Retry-After: + description: A non-negative decimal integer indicating the seconds to delay after the response is received. + schema: + type: integer + format: int32 + default: + description: Error processing query + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + /buckets: + get: + operationId: GetBuckets + tags: + - Buckets + summary: List all buckets + parameters: + - $ref: "#/components/parameters/TraceSpan" + - $ref: "#/components/parameters/Offset" + - $ref: "#/components/parameters/Limit" + - $ref: "#/components/parameters/After" + - in: query + name: org + description: The organization name. + schema: + type: string + - in: query + name: orgID + description: The organization ID. + schema: + type: string + - in: query + name: name + description: Only returns buckets with a specific name. + schema: + type: string + responses: + "200": + description: A list of buckets + content: + application/json: + schema: + $ref: "#/components/schemas/Buckets" + default: + description: Unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + post: + operationId: PostBuckets + tags: + - Buckets + summary: Create a bucket + parameters: + - $ref: "#/components/parameters/TraceSpan" + requestBody: + description: Bucket to create + required: true + content: + application/json: + schema: + $ref: "#/components/schemas/PostBucketRequest" + responses: + "201": + description: Bucket created + content: + application/json: + schema: + $ref: "#/components/schemas/Bucket" + 422: + description: Request body failed validation + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + default: + description: Unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + "/buckets/{bucketID}": + get: + operationId: GetBucketsID + tags: + - Buckets + summary: Retrieve a bucket + parameters: + - $ref: "#/components/parameters/TraceSpan" + - in: path + name: bucketID + schema: + type: string + required: true + description: The bucket ID. + responses: + "200": + description: Bucket details + content: + application/json: + schema: + $ref: "#/components/schemas/Bucket" + default: + description: Unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + patch: + operationId: PatchBucketsID + tags: + - Buckets + summary: Update a bucket + requestBody: + description: Bucket update to apply + required: true + content: + application/json: + schema: + $ref: "#/components/schemas/Bucket" + parameters: + - $ref: "#/components/parameters/TraceSpan" + - in: path + name: bucketID + schema: + type: string + required: true + description: The bucket ID. + responses: + "200": + description: An updated bucket + content: + application/json: + schema: + $ref: "#/components/schemas/Bucket" + default: + description: Unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + delete: + operationId: DeleteBucketsID + tags: + - Buckets + summary: Delete a bucket + parameters: + - $ref: "#/components/parameters/TraceSpan" + - in: path + name: bucketID + schema: + type: string + required: true + description: The ID of the bucket to delete. + responses: + "204": + description: Delete has been accepted + "404": + description: Bucket not found + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + default: + description: Unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + "/buckets/{bucketID}/labels": + get: + operationId: GetBucketsIDLabels + tags: + - Buckets + summary: List all labels for a bucket + parameters: + - $ref: "#/components/parameters/TraceSpan" + - in: path + name: bucketID + schema: + type: string + required: true + description: The bucket ID. + responses: + "200": + description: A list of all labels for a bucket + content: + application/json: + schema: + $ref: "#/components/schemas/LabelsResponse" + default: + description: Unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + post: + operationId: PostBucketsIDLabels + tags: + - Buckets + summary: Add a label to a bucket + parameters: + - $ref: "#/components/parameters/TraceSpan" + - in: path + name: bucketID + schema: + type: string + required: true + description: The bucket ID. + requestBody: + description: Label to add + required: true + content: + application/json: + schema: + $ref: "#/components/schemas/LabelMapping" + responses: + "201": + description: The newly added label + content: + application/json: + schema: + $ref: "#/components/schemas/LabelResponse" + default: + description: Unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + "/buckets/{bucketID}/labels/{labelID}": + delete: + operationId: DeleteBucketsIDLabelsID + tags: + - Buckets + summary: Delete a label from a bucket + parameters: + - $ref: "#/components/parameters/TraceSpan" + - in: path + name: bucketID + schema: + type: string + required: true + description: The bucket ID. + - in: path + name: labelID + schema: + type: string + required: true + description: The ID of the label to delete. + responses: + "204": + description: Delete has been accepted + "404": + description: Bucket not found + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + default: + description: Unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + "/buckets/{bucketID}/members": + get: + operationId: GetBucketsIDMembers + tags: + - Users + - Buckets + summary: List all users with member privileges for a bucket + parameters: + - $ref: "#/components/parameters/TraceSpan" + - in: path + name: bucketID + schema: + type: string + required: true + description: The bucket ID. + responses: + "200": + description: A list of bucket members + content: + application/json: + schema: + $ref: "#/components/schemas/ResourceMembers" + default: + description: Unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + post: + operationId: PostBucketsIDMembers + tags: + - Users + - Buckets + summary: Add a member to a bucket + parameters: + - $ref: "#/components/parameters/TraceSpan" + - in: path + name: bucketID + schema: + type: string + required: true + description: The bucket ID. + requestBody: + description: User to add as member + required: true + content: + application/json: + schema: + $ref: "#/components/schemas/AddResourceMemberRequestBody" + responses: + "201": + description: Member added to bucket + content: + application/json: + schema: + $ref: "#/components/schemas/ResourceMember" + default: + description: Unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + "/buckets/{bucketID}/members/{userID}": + delete: + operationId: DeleteBucketsIDMembersID + tags: + - Users + - Buckets + summary: Remove a member from a bucket + parameters: + - $ref: "#/components/parameters/TraceSpan" + - in: path + name: userID + schema: + type: string + required: true + description: The ID of the member to remove. + - in: path + name: bucketID + schema: + type: string + required: true + description: The bucket ID. + responses: + "204": + description: Member removed + default: + description: Unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + "/buckets/{bucketID}/owners": + get: + operationId: GetBucketsIDOwners + tags: + - Users + - Buckets + summary: List all owners of a bucket + parameters: + - $ref: "#/components/parameters/TraceSpan" + - in: path + name: bucketID + schema: + type: string + required: true + description: The bucket ID. + responses: + "200": + description: A list of bucket owners + content: + application/json: + schema: + $ref: "#/components/schemas/ResourceOwners" + default: + description: Unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + post: + operationId: PostBucketsIDOwners + tags: + - Users + - Buckets + summary: Add an owner to a bucket + parameters: + - $ref: "#/components/parameters/TraceSpan" + - in: path + name: bucketID + schema: + type: string + required: true + description: The bucket ID. + requestBody: + description: User to add as owner + required: true + content: + application/json: + schema: + $ref: "#/components/schemas/AddResourceMemberRequestBody" + responses: + "201": + description: Bucket owner added + content: + application/json: + schema: + $ref: "#/components/schemas/ResourceOwner" + default: + description: Unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + "/buckets/{bucketID}/owners/{userID}": + delete: + operationId: DeleteBucketsIDOwnersID + tags: + - Users + - Buckets + summary: Remove an owner from a bucket + parameters: + - $ref: "#/components/parameters/TraceSpan" + - in: path + name: userID + schema: + type: string + required: true + description: The ID of the owner to remove. + - in: path + name: bucketID + schema: + type: string + required: true + description: The bucket ID. + responses: + "204": + description: Owner removed + default: + description: Unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + /orgs: + get: + operationId: GetOrgs + tags: + - Organizations + summary: List all organizations + parameters: + - $ref: "#/components/parameters/TraceSpan" + - $ref: "#/components/parameters/Offset" + - $ref: "#/components/parameters/Limit" + - $ref: "#/components/parameters/Descending" + - in: query + name: org + schema: + type: string + description: Filter organizations to a specific organization name. + - in: query + name: orgID + schema: + type: string + description: Filter organizations to a specific organization ID. + - in: query + name: userID + schema: + type: string + description: Filter organizations to a specific user ID. + responses: + "200": + description: A list of organizations + content: + application/json: + schema: + $ref: "#/components/schemas/Organizations" + default: + description: Unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + post: + operationId: PostOrgs + tags: + - Organizations + summary: Create an organization + parameters: + - $ref: "#/components/parameters/TraceSpan" + requestBody: + description: Organization to create + required: true + content: + application/json: + schema: + $ref: "#/components/schemas/Organization" + responses: + "201": + description: Organization created + content: + application/json: + schema: + $ref: "#/components/schemas/Organization" + default: + description: Unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + "/orgs/{orgID}": + get: + operationId: GetOrgsID + tags: + - Organizations + summary: Retrieve an organization + parameters: + - $ref: "#/components/parameters/TraceSpan" + - in: path + name: orgID + schema: + type: string + required: true + description: The ID of the organization to get. + responses: + "200": + description: Organization details + content: + application/json: + schema: + $ref: "#/components/schemas/Organization" + default: + description: Unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + patch: + operationId: PatchOrgsID + tags: + - Organizations + summary: Update an organization + requestBody: + description: Organization update to apply + required: true + content: + application/json: + schema: + $ref: "#/components/schemas/Organization" + parameters: + - $ref: "#/components/parameters/TraceSpan" + - in: path + name: orgID + schema: + type: string + required: true + description: The ID of the organization to get. + responses: + "200": + description: Organization updated + content: + application/json: + schema: + $ref: "#/components/schemas/Organization" + default: + description: Unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + delete: + operationId: DeleteOrgsID + tags: + - Organizations + summary: Delete an organization + parameters: + - $ref: "#/components/parameters/TraceSpan" + - in: path + name: orgID + schema: + type: string + required: true + description: The ID of the organization to delete. + responses: + "204": + description: Delete has been accepted + "404": + description: Organization not found + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + default: + description: Unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + "/orgs/{orgID}/secrets": + get: + operationId: GetOrgsIDSecrets + tags: + - Secrets + - Organizations + summary: List all secret keys for an organization + parameters: + - $ref: "#/components/parameters/TraceSpan" + - in: path + name: orgID + schema: + type: string + required: true + description: The organization ID. + responses: + "200": + description: A list of all secret keys + content: + application/json: + schema: + $ref: "#/components/schemas/SecretKeysResponse" + default: + description: Unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + patch: + operationId: PatchOrgsIDSecrets + tags: + - Secrets + - Organizations + summary: Update secrets in an organization + parameters: + - $ref: "#/components/parameters/TraceSpan" + - in: path + name: orgID + schema: + type: string + required: true + description: The organization ID. + requestBody: + description: Secret key value pairs to update/add + required: true + content: + application/json: + schema: + $ref: "#/components/schemas/Secrets" + responses: + "204": + description: Keys successfully patched + default: + description: Unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + "/orgs/{orgID}/secrets/delete": # had to make this because swagger wouldn't let me have a request body with a DELETE + post: + operationId: PostOrgsIDSecrets + tags: + - Secrets + - Organizations + summary: Delete secrets from an organization + parameters: + - $ref: "#/components/parameters/TraceSpan" + - in: path + name: orgID + schema: + type: string + required: true + description: The organization ID. + requestBody: + description: Secret key to delete + required: true + content: + application/json: + schema: + $ref: "#/components/schemas/SecretKeys" + responses: + "204": + description: Keys successfully patched + default: + description: Unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + "/orgs/{orgID}/members": + get: + operationId: GetOrgsIDMembers + tags: + - Users + - Organizations + summary: List all members of an organization + parameters: + - $ref: "#/components/parameters/TraceSpan" + - in: path + name: orgID + schema: + type: string + required: true + description: The organization ID. + responses: + "200": + description: A list of organization members + content: + application/json: + schema: + $ref: "#/components/schemas/ResourceMembers" + "404": + description: Organization not found + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + default: + description: Unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + post: + operationId: PostOrgsIDMembers + tags: + - Users + - Organizations + summary: Add a member to an organization + parameters: + - $ref: "#/components/parameters/TraceSpan" + - in: path + name: orgID + schema: + type: string + required: true + description: The organization ID. + requestBody: + description: User to add as member + required: true + content: + application/json: + schema: + $ref: "#/components/schemas/AddResourceMemberRequestBody" + responses: + "201": + description: Added to organization created + content: + application/json: + schema: + $ref: "#/components/schemas/ResourceMember" + default: + description: Unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + "/orgs/{orgID}/members/{userID}": + delete: + operationId: DeleteOrgsIDMembersID + tags: + - Users + - Organizations + summary: Remove a member from an organization + parameters: + - $ref: "#/components/parameters/TraceSpan" + - in: path + name: userID + schema: + type: string + required: true + description: The ID of the member to remove. + - in: path + name: orgID + schema: + type: string + required: true + description: The organization ID. + responses: + "204": + description: Member removed + default: + description: Unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + "/orgs/{orgID}/owners": + get: + operationId: GetOrgsIDOwners + tags: + - Users + - Organizations + summary: List all owners of an organization + parameters: + - $ref: "#/components/parameters/TraceSpan" + - in: path + name: orgID + schema: + type: string + required: true + description: The organization ID. + responses: + "200": + description: A list of organization owners + content: + application/json: + schema: + $ref: "#/components/schemas/ResourceOwners" + "404": + description: Organization not found + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + default: + description: Unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + post: + operationId: PostOrgsIDOwners + tags: + - Users + - Organizations + summary: Add an owner to an organization + parameters: + - $ref: "#/components/parameters/TraceSpan" + - in: path + name: orgID + schema: + type: string + required: true + description: The organization ID. + requestBody: + description: User to add as owner + required: true + content: + application/json: + schema: + $ref: "#/components/schemas/AddResourceMemberRequestBody" + responses: + "201": + description: Organization owner added + content: + application/json: + schema: + $ref: "#/components/schemas/ResourceOwner" + default: + description: Unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + "/orgs/{orgID}/owners/{userID}": + delete: + operationId: DeleteOrgsIDOwnersID + tags: + - Users + - Organizations + summary: Remove an owner from an organization + parameters: + - $ref: "#/components/parameters/TraceSpan" + - in: path + name: userID + schema: + type: string + required: true + description: The ID of the owner to remove. + - in: path + name: orgID + schema: + type: string + required: true + description: The organization ID. + responses: + "204": + description: Owner removed + default: + description: Unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + /stacks: + get: + operationId: ListStacks + tags: + - InfluxDB Templates + summary: Grab a list of installed InfluxDB Templates + parameters: + - in: query + name: orgID + required: true + schema: + type: string + description: The organization id of the stacks + - in: query + name: name + schema: + type: string + description: A collection of names to filter the list by. + - in: query + name: stackID + schema: + type: string + description: A collection of stackIDs to filter the list by. + responses: + "200": + description: Influx stacks found + content: + application/json: + schema: + type: object + properties: + stacks: + type: array + items: + $ref: "#/components/schemas/Stack" + default: + description: Unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + post: + operationId: CreateStack + tags: + - InfluxDB Templates + summary: Create a new stack + requestBody: + description: Stack to create. + required: true + content: + application/json: + schema: + type: object + properties: + orgID: + type: string + name: + type: string + description: + type: string + urls: + type: array + items: + type: string + responses: + "201": + description: InfluxDB Stack created + content: + application/json: + schema: + $ref: "#/components/schemas/Stack" + default: + description: Unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + /stacks/{stack_id}: + get: + operationId: ReadStack + tags: + - InfluxDB Templates + summary: Grab a stack by its ID + parameters: + - in: path + name: stack_id + required: true + schema: + type: string + description: The stack id + responses: + "200": + description: Read an influx stack by ID + content: + application/json: + schema: + $ref: "#/components/schemas/Stack" + default: + description: Unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + patch: + operationId: UpdateStack + tags: + - InfluxDB Templates + summary: Update an InfluxDB Stack + parameters: + - in: path + name: stack_id + required: true + schema: + type: string + description: The stack id + requestBody: + description: Influx stack to update. + required: true + content: + application/json: + schema: + type: object + properties: + name: + type: string + nullable: true + description: + type: string + nullable: true + templateURLs: + type: array + items: + type: string + nullable: true + additionalResources: + type: array + items: + type: object + properties: + resourceID: + type: string + kind: + type: string + templateMetaName: + type: string + required: ["kind", "resourceID"] + responses: + "200": + description: Influx stack updated + content: + application/json: + schema: + $ref: "#/components/schemas/Stack" + default: + description: Unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + delete: + operationId: DeleteStack + tags: + - InfluxDB Templates + summary: Delete a stack and remove all its associated resources + parameters: + - in: path + name: stack_id + required: true + schema: + type: string + description: The stack id + - in: query + name: orgID + required: true + schema: + type: string + description: The organization id of the user + responses: + "204": + description: Stack and all its associated resources are deleted + default: + description: Unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + /stacks/{stack_id}/uninstall: + post: + operationId: UninstallStack + tags: + - InfluxDB Templates + summary: Uninstall an InfluxDB Stack + parameters: + - in: path + name: stack_id + required: true + schema: + type: string + description: The stack id + responses: + "200": + description: Influx stack uninstalled + content: + application/json: + schema: + $ref: "#/components/schemas/Stack" + default: + description: Unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + /templates/apply: + post: + operationId: ApplyTemplate + tags: + - InfluxDB Templates + summary: Apply or dry-run an InfluxDB Template + requestBody: + required: true + content: + application/json: + schema: + $ref: "#/components/schemas/TemplateApply" + application/x-jsonnet: + schema: + $ref: "#/components/schemas/TemplateApply" + text/yml: + schema: + $ref: "#/components/schemas/TemplateApply" + responses: + "200": + description: > + Influx package dry-run successful, no new resources created. + The provided diff and summary will not have IDs for resources + that do not exist at the time of the dry run. + content: + application/json: + schema: + $ref: "#/components/schemas/TemplateSummary" + "201": + description: > + Influx package applied successfully. Newly created resources created + available in summary. The diff compares the state of the world before + the package is applied with the changes the application will impose. + This corresponds to `"dryRun": true` + content: + application/json: + schema: + $ref: "#/components/schemas/TemplateSummary" + default: + description: Unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + /templates/export: + post: + operationId: ExportTemplate + tags: + - InfluxDB Templates + summary: Export a new Influx Template + requestBody: + description: Export resources as an InfluxDB template. + required: false + content: + application/json: + schema: + oneOf: + - $ref: "#/components/schemas/TemplateExportByID" + - $ref: "#/components/schemas/TemplateExportByName" + responses: + "200": + description: InfluxDB template created + content: + application/json: + schema: + $ref: "#/components/schemas/Template" + application/x-yaml: + schema: + $ref: "#/components/schemas/Template" + default: + description: Unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + /tasks: + get: + operationId: GetTasks + tags: + - Tasks + summary: List all tasks + parameters: + - $ref: "#/components/parameters/TraceSpan" + - in: query + name: name + description: Returns task with a specific name. + schema: + type: string + - in: query + name: after + schema: + type: string + description: Return tasks after a specified ID. + - in: query + name: user + schema: + type: string + description: Filter tasks to a specific user ID. + - in: query + name: org + schema: + type: string + description: Filter tasks to a specific organization name. + - in: query + name: orgID + schema: + type: string + description: Filter tasks to a specific organization ID. + - in: query + name: status + schema: + type: string + enum: + - active + - inactive + description: Filter tasks by a status--"inactive" or "active". + - in: query + name: limit + schema: + type: integer + minimum: 1 + maximum: 500 + default: 100 + description: The number of tasks to return + responses: + "200": + description: A list of tasks + content: + application/json: + schema: + $ref: "#/components/schemas/Tasks" + default: + description: Unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + post: + operationId: PostTasks + tags: + - Tasks + summary: Create a new task + parameters: + - $ref: "#/components/parameters/TraceSpan" + requestBody: + description: Task to create + required: true + content: + application/json: + schema: + $ref: "#/components/schemas/TaskCreateRequest" + responses: + "201": + description: Task created + content: + application/json: + schema: + $ref: "#/components/schemas/Task" + default: + description: Unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + "/tasks/{taskID}": + get: + operationId: GetTasksID + tags: + - Tasks + summary: Retrieve a task + parameters: + - $ref: "#/components/parameters/TraceSpan" + - in: path + name: taskID + schema: + type: string + required: true + description: The task ID. + responses: + "200": + description: Task details + content: + application/json: + schema: + $ref: "#/components/schemas/Task" + default: + description: Unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + patch: + operationId: PatchTasksID + tags: + - Tasks + summary: Update a task + description: Update a task. This will cancel all queued runs. + requestBody: + description: Task update to apply + required: true + content: + application/json: + schema: + $ref: "#/components/schemas/TaskUpdateRequest" + parameters: + - $ref: "#/components/parameters/TraceSpan" + - in: path + name: taskID + schema: + type: string + required: true + description: The task ID. + responses: + "200": + description: Task updated + content: + application/json: + schema: + $ref: "#/components/schemas/Task" + default: + description: Unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + delete: + operationId: DeleteTasksID + tags: + - Tasks + summary: Delete a task + description: Deletes a task and all associated records + parameters: + - $ref: "#/components/parameters/TraceSpan" + - in: path + name: taskID + schema: + type: string + required: true + description: The ID of the task to delete. + responses: + "204": + description: Task deleted + default: + description: Unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + "/tasks/{taskID}/runs": + get: + operationId: GetTasksIDRuns + tags: + - Tasks + summary: List runs for a task + parameters: + - $ref: "#/components/parameters/TraceSpan" + - in: path + name: taskID + schema: + type: string + required: true + description: The ID of the task to get runs for. + - in: query + name: after + schema: + type: string + description: Returns runs after a specific ID. + - in: query + name: limit + schema: + type: integer + minimum: 1 + maximum: 500 + default: 100 + description: The number of runs to return + - in: query + name: afterTime + schema: + type: string + format: date-time + description: Filter runs to those scheduled after this time, RFC3339 + - in: query + name: beforeTime + schema: + type: string + format: date-time + description: Filter runs to those scheduled before this time, RFC3339 + responses: + "200": + description: A list of task runs + content: + application/json: + schema: + $ref: "#/components/schemas/Runs" + default: + description: Unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + post: + operationId: PostTasksIDRuns + tags: + - Tasks + summary: Manually start a task run, overriding the current schedule + parameters: + - $ref: "#/components/parameters/TraceSpan" + - in: path + name: taskID + schema: + type: string + required: true + requestBody: + content: + application/json: + schema: + $ref: "#/components/schemas/RunManually" + responses: + "201": + description: Run scheduled to start + content: + application/json: + schema: + $ref: "#/components/schemas/Run" + default: + description: Unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + "/tasks/{taskID}/runs/{runID}": + get: + operationId: GetTasksIDRunsID + tags: + - Tasks + summary: Retrieve a single run for a task + parameters: + - $ref: "#/components/parameters/TraceSpan" + - in: path + name: taskID + schema: + type: string + required: true + description: The task ID. + - in: path + name: runID + schema: + type: string + required: true + description: The run ID. + responses: + "200": + description: The run record + content: + application/json: + schema: + $ref: "#/components/schemas/Run" + default: + description: Unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + delete: + operationId: DeleteTasksIDRunsID + tags: + - Tasks + summary: Cancel a running task + parameters: + - $ref: "#/components/parameters/TraceSpan" + - in: path + name: taskID + schema: + type: string + required: true + description: The task ID. + - in: path + name: runID + schema: + type: string + required: true + description: The run ID. + responses: + "204": + description: Delete has been accepted + default: + description: Unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + "/tasks/{taskID}/runs/{runID}/retry": + post: + operationId: PostTasksIDRunsIDRetry + tags: + - Tasks + summary: Retry a task run + parameters: + - $ref: "#/components/parameters/TraceSpan" + - in: path + name: taskID + schema: + type: string + required: true + description: The task ID. + - in: path + name: runID + schema: + type: string + required: true + description: The run ID. + responses: + "200": + description: Run that has been queued + content: + application/json: + schema: + $ref: "#/components/schemas/Run" + default: + description: Unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + "/tasks/{taskID}/logs": + get: + operationId: GetTasksIDLogs + tags: + - Tasks + summary: Retrieve all logs for a task + parameters: + - $ref: "#/components/parameters/TraceSpan" + - in: path + name: taskID + schema: + type: string + required: true + description: The task ID. + responses: + "200": + description: All logs for a task + content: + application/json: + schema: + $ref: "#/components/schemas/Logs" + default: + description: Unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + "/tasks/{taskID}/runs/{runID}/logs": + get: + operationId: GetTasksIDRunsIDLogs + tags: + - Tasks + summary: Retrieve all logs for a run + parameters: + - $ref: "#/components/parameters/TraceSpan" + - in: path + name: taskID + schema: + type: string + required: true + description: ID of task to get logs for. + - in: path + name: runID + schema: + type: string + required: true + description: ID of run to get logs for. + responses: + "200": + description: All logs for a run + content: + application/json: + schema: + $ref: "#/components/schemas/Logs" + default: + description: Unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + "/tasks/{taskID}/labels": + get: + operationId: GetTasksIDLabels + tags: + - Tasks + summary: List all labels for a task + parameters: + - $ref: "#/components/parameters/TraceSpan" + - in: path + name: taskID + schema: + type: string + required: true + description: The task ID. + responses: + "200": + description: A list of all labels for a task + content: + application/json: + schema: + $ref: "#/components/schemas/LabelsResponse" + default: + description: Unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + post: + operationId: PostTasksIDLabels + tags: + - Tasks + summary: Add a label to a task + parameters: + - $ref: "#/components/parameters/TraceSpan" + - in: path + name: taskID + schema: + type: string + required: true + description: The task ID. + requestBody: + description: Label to add + required: true + content: + application/json: + schema: + $ref: "#/components/schemas/LabelMapping" + responses: + "201": + description: A list of all labels for a task + content: + application/json: + schema: + $ref: "#/components/schemas/LabelResponse" + default: + description: Unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + "/tasks/{taskID}/labels/{labelID}": + delete: + operationId: DeleteTasksIDLabelsID + tags: + - Tasks + summary: Delete a label from a task + parameters: + - $ref: "#/components/parameters/TraceSpan" + - in: path + name: taskID + schema: + type: string + required: true + description: The task ID. + - in: path + name: labelID + schema: + type: string + required: true + description: The label ID. + responses: + "204": + description: Delete has been accepted + "404": + description: Task not found + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + default: + description: Unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + /flags: + get: + operationId: GetFlags + tags: + - Users + summary: Return the feature flags for the currently authenticated user + parameters: + - $ref: "#/components/parameters/TraceSpan" + responses: + "200": + description: Feature flags for the currently authenticated user + content: + application/json: + schema: + $ref: "#/components/schemas/Flags" + default: + description: Unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + /me: + get: + operationId: GetMe + tags: + - Users + summary: Return the current authenticated user + parameters: + - $ref: "#/components/parameters/TraceSpan" + responses: + "200": + description: Currently authenticated user + content: + application/json: + schema: + $ref: "#/components/schemas/User" + default: + description: Unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + /me/password: + put: + operationId: PutMePassword + tags: + - Users + summary: Update a password + security: + - BasicAuth: [] + parameters: + - $ref: "#/components/parameters/TraceSpan" + requestBody: + description: New password + required: true + content: + application/json: + schema: + $ref: "#/components/schemas/PasswordResetBody" + responses: + "204": + description: Password successfully updated + default: + description: Unsuccessful authentication + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + "/tasks/{taskID}/members": + get: + operationId: GetTasksIDMembers + tags: + - Users + - Tasks + summary: List all task members + parameters: + - $ref: "#/components/parameters/TraceSpan" + - in: path + name: taskID + schema: + type: string + required: true + description: The task ID. + responses: + "200": + description: A list of users who have member privileges for a task + content: + application/json: + schema: + $ref: "#/components/schemas/ResourceMembers" + default: + description: Unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + post: + operationId: PostTasksIDMembers + tags: + - Users + - Tasks + summary: Add a member to a task + parameters: + - $ref: "#/components/parameters/TraceSpan" + - in: path + name: taskID + schema: + type: string + required: true + description: The task ID. + requestBody: + description: User to add as member + required: true + content: + application/json: + schema: + $ref: "#/components/schemas/AddResourceMemberRequestBody" + responses: + "201": + description: Added to task members + content: + application/json: + schema: + $ref: "#/components/schemas/ResourceMember" + default: + description: Unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + "/tasks/{taskID}/members/{userID}": + delete: + operationId: DeleteTasksIDMembersID + tags: + - Users + - Tasks + summary: Remove a member from a task + parameters: + - $ref: "#/components/parameters/TraceSpan" + - in: path + name: userID + schema: + type: string + required: true + description: The ID of the member to remove. + - in: path + name: taskID + schema: + type: string + required: true + description: The task ID. + responses: + "204": + description: Member removed + default: + description: Unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + "/tasks/{taskID}/owners": + get: + operationId: GetTasksIDOwners + tags: + - Users + - Tasks + summary: List all owners of a task + parameters: + - $ref: "#/components/parameters/TraceSpan" + - in: path + name: taskID + schema: + type: string + required: true + description: The task ID. + responses: + "200": + description: A list of users who have owner privileges for a task + content: + application/json: + schema: + $ref: "#/components/schemas/ResourceOwners" + default: + description: Unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + post: + operationId: PostTasksIDOwners + tags: + - Users + - Tasks + summary: Add an owner to a task + parameters: + - $ref: "#/components/parameters/TraceSpan" + - in: path + name: taskID + schema: + type: string + required: true + description: The task ID. + requestBody: + description: User to add as owner + required: true + content: + application/json: + schema: + $ref: "#/components/schemas/AddResourceMemberRequestBody" + responses: + "201": + description: Added to task owners + content: + application/json: + schema: + $ref: "#/components/schemas/ResourceOwner" + default: + description: Unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + "/tasks/{taskID}/owners/{userID}": + delete: + operationId: DeleteTasksIDOwnersID + tags: + - Users + - Tasks + summary: Remove an owner from a task + parameters: + - $ref: "#/components/parameters/TraceSpan" + - in: path + name: userID + schema: + type: string + required: true + description: The ID of the owner to remove. + - in: path + name: taskID + schema: + type: string + required: true + description: The task ID. + responses: + "204": + description: Owner removed + default: + description: Unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + /users: + get: + operationId: GetUsers + tags: + - Users + summary: List all users + parameters: + - $ref: "#/components/parameters/TraceSpan" + responses: + "200": + description: A list of users + content: + application/json: + schema: + $ref: "#/components/schemas/Users" + default: + description: Unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + post: + operationId: PostUsers + tags: + - Users + summary: Create a user + parameters: + - $ref: "#/components/parameters/TraceSpan" + requestBody: + description: User to create + required: true + content: + application/json: + schema: + $ref: "#/components/schemas/User" + responses: + "201": + description: User created + content: + application/json: + schema: + $ref: "#/components/schemas/User" + default: + description: Unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + "/users/{userID}": + get: + operationId: GetUsersID + tags: + - Users + summary: Retrieve a user + parameters: + - $ref: "#/components/parameters/TraceSpan" + - in: path + name: userID + schema: + type: string + required: true + description: The user ID. + responses: + "200": + description: User details + content: + application/json: + schema: + $ref: "#/components/schemas/User" + default: + description: Unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + patch: + operationId: PatchUsersID + tags: + - Users + summary: Update a user + requestBody: + description: User update to apply + required: true + content: + application/json: + schema: + $ref: "#/components/schemas/User" + parameters: + - $ref: "#/components/parameters/TraceSpan" + - in: path + name: userID + schema: + type: string + required: true + description: The ID of the user to update. + responses: + "200": + description: User updated + content: + application/json: + schema: + $ref: "#/components/schemas/User" + default: + description: Unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + delete: + operationId: DeleteUsersID + tags: + - Users + summary: Delete a user + parameters: + - $ref: "#/components/parameters/TraceSpan" + - in: path + name: userID + schema: + type: string + required: true + description: The ID of the user to delete. + responses: + "204": + description: User deleted + default: + description: Unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + "/users/{userID}/password": + post: + operationId: PostUsersIDPassword + tags: + - Users + summary: Update a password + security: + - BasicAuth: [] + parameters: + - $ref: "#/components/parameters/TraceSpan" + - in: path + name: userID + schema: + type: string + required: true + description: The user ID. + requestBody: + description: New password + required: true + content: + application/json: + schema: + $ref: "#/components/schemas/PasswordResetBody" + responses: + "204": + description: Password successfully updated + default: + description: Unsuccessful authentication + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + /checks: + get: + operationId: GetChecks + tags: + - Checks + summary: Get all checks + parameters: + - $ref: "#/components/parameters/TraceSpan" + - $ref: "#/components/parameters/Offset" + - $ref: "#/components/parameters/Limit" + - in: query + name: orgID + required: true + description: Only show checks that belong to a specific organization ID. + schema: + type: string + responses: + "200": + description: A list of checks + content: + application/json: + schema: + $ref: "#/components/schemas/Checks" + default: + description: Unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + post: + operationId: CreateCheck + tags: + - Checks + summary: Add new check + requestBody: + description: Check to create + required: true + content: + application/json: + schema: + $ref: "#/components/schemas/PostCheck" + responses: + "201": + description: Check created + content: + application/json: + schema: + $ref: "#/components/schemas/Check" + default: + description: Unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + "/checks/{checkID}": + get: + operationId: GetChecksID + tags: + - Checks + summary: Get a check + parameters: + - $ref: "#/components/parameters/TraceSpan" + - in: path + name: checkID + schema: + type: string + required: true + description: The check ID. + responses: + "200": + description: The check requested + content: + application/json: + schema: + $ref: "#/components/schemas/Check" + default: + description: Unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + put: + operationId: PutChecksID + tags: + - Checks + summary: Update a check + requestBody: + description: Check update to apply + required: true + content: + application/json: + schema: + $ref: "#/components/schemas/Check" + parameters: + - $ref: "#/components/parameters/TraceSpan" + - in: path + name: checkID + schema: + type: string + required: true + description: The check ID. + responses: + "200": + description: An updated check + content: + application/json: + schema: + $ref: "#/components/schemas/Check" + "404": + description: The check was not found + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + default: + description: Unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + patch: + operationId: PatchChecksID + tags: + - Checks + summary: Update a check + requestBody: + description: Check update to apply + required: true + content: + application/json: + schema: + $ref: "#/components/schemas/CheckPatch" + parameters: + - $ref: "#/components/parameters/TraceSpan" + - in: path + name: checkID + schema: + type: string + required: true + description: The check ID. + responses: + "200": + description: An updated check + content: + application/json: + schema: + $ref: "#/components/schemas/Check" + "404": + description: The check was not found + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + default: + description: Unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + delete: + operationId: DeleteChecksID + tags: + - Checks + summary: Delete a check + parameters: + - $ref: "#/components/parameters/TraceSpan" + - in: path + name: checkID + schema: + type: string + required: true + description: The check ID. + responses: + "204": + description: Delete has been accepted + "404": + description: The check was not found + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + default: + description: Unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + "/checks/{checkID}/labels": + get: + operationId: GetChecksIDLabels + tags: + - Checks + summary: List all labels for a check + parameters: + - $ref: "#/components/parameters/TraceSpan" + - in: path + name: checkID + schema: + type: string + required: true + description: The check ID. + responses: + "200": + description: A list of all labels for a check + content: + application/json: + schema: + $ref: "#/components/schemas/LabelsResponse" + default: + description: Unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + post: + operationId: PostChecksIDLabels + tags: + - Checks + summary: Add a label to a check + parameters: + - $ref: "#/components/parameters/TraceSpan" + - in: path + name: checkID + schema: + type: string + required: true + description: The check ID. + requestBody: + description: Label to add + required: true + content: + application/json: + schema: + $ref: "#/components/schemas/LabelMapping" + responses: + "201": + description: The label was added to the check + content: + application/json: + schema: + $ref: "#/components/schemas/LabelResponse" + default: + description: Unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + "/checks/{checkID}/labels/{labelID}": + delete: + operationId: DeleteChecksIDLabelsID + tags: + - Checks + summary: Delete label from a check + parameters: + - $ref: "#/components/parameters/TraceSpan" + - in: path + name: checkID + schema: + type: string + required: true + description: The check ID. + - in: path + name: labelID + schema: + type: string + required: true + description: The ID of the label to delete. + responses: + "204": + description: Delete has been accepted + "404": + description: Check or label not found + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + default: + description: Unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + /notificationRules: + get: + operationId: GetNotificationRules + tags: + - NotificationRules + summary: Get all notification rules + parameters: + - $ref: "#/components/parameters/TraceSpan" + - $ref: "#/components/parameters/Offset" + - $ref: "#/components/parameters/Limit" + - in: query + name: orgID + required: true + description: Only show notification rules that belong to a specific organization ID. + schema: + type: string + - in: query + name: checkID + description: Only show notifications that belong to the specific check ID. + schema: + type: string + - in: query + name: tag + description: Only return notification rules that "would match" statuses which contain the tag key value pairs provided. + schema: + type: string + pattern: ^[a-zA-Z0-9_]+:[a-zA-Z0-9_]+$ + example: env:prod + responses: + "200": + description: A list of notification rules + content: + application/json: + schema: + $ref: "#/components/schemas/NotificationRules" + default: + description: Unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + post: + operationId: CreateNotificationRule + tags: + - NotificationRules + summary: Add a notification rule + requestBody: + description: Notification rule to create + required: true + content: + application/json: + schema: + $ref: "#/components/schemas/PostNotificationRule" + responses: + "201": + description: Notification rule created + content: + application/json: + schema: + $ref: "#/components/schemas/NotificationRule" + default: + description: Unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + "/checks/{checkID}/query": + get: + operationId: GetChecksIDQuery + tags: + - Checks + summary: Get a check query + parameters: + - $ref: "#/components/parameters/TraceSpan" + - in: path + name: checkID + schema: + type: string + required: true + description: The check ID. + responses: + "200": + description: The check query requested + content: + application/json: + schema: + $ref: "#/components/schemas/FluxResponse" + "400": + description: Invalid request + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + "404": + description: Check not found + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + default: + description: Unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + "/notificationRules/{ruleID}": + get: + operationId: GetNotificationRulesID + tags: + - NotificationRules + summary: Get a notification rule + parameters: + - $ref: "#/components/parameters/TraceSpan" + - in: path + name: ruleID + schema: + type: string + required: true + description: The notification rule ID. + responses: + "200": + description: The notification rule requested + content: + application/json: + schema: + $ref: "#/components/schemas/NotificationRule" + default: + description: Unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + put: + operationId: PutNotificationRulesID + tags: + - NotificationRules + summary: Update a notification rule + requestBody: + description: Notification rule update to apply + required: true + content: + application/json: + schema: + $ref: "#/components/schemas/NotificationRule" + parameters: + - $ref: "#/components/parameters/TraceSpan" + - in: path + name: ruleID + schema: + type: string + required: true + description: The notification rule ID. + responses: + "200": + description: An updated notification rule + content: + application/json: + schema: + $ref: "#/components/schemas/NotificationRule" + "404": + description: The notification rule was not found + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + default: + description: Unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + patch: + operationId: PatchNotificationRulesID + tags: + - NotificationRules + summary: Update a notification rule + requestBody: + description: Notification rule update to apply + required: true + content: + application/json: + schema: + $ref: "#/components/schemas/NotificationRuleUpdate" + parameters: + - $ref: "#/components/parameters/TraceSpan" + - in: path + name: ruleID + schema: + type: string + required: true + description: The notification rule ID. + responses: + "200": + description: An updated notification rule + content: + application/json: + schema: + $ref: "#/components/schemas/NotificationRule" + "404": + description: The notification rule was not found + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + default: + description: Unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + delete: + operationId: DeleteNotificationRulesID + tags: + - NotificationRules + summary: Delete a notification rule + parameters: + - $ref: "#/components/parameters/TraceSpan" + - in: path + name: ruleID + schema: + type: string + required: true + description: The notification rule ID. + responses: + "204": + description: Delete has been accepted + "404": + description: The check was not found + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + default: + description: Unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + "/notificationRules/{ruleID}/labels": + get: + operationId: GetNotificationRulesIDLabels + tags: + - NotificationRules + summary: List all labels for a notification rule + parameters: + - $ref: "#/components/parameters/TraceSpan" + - in: path + name: ruleID + schema: + type: string + required: true + description: The notification rule ID. + responses: + "200": + description: A list of all labels for a notification rule + content: + application/json: + schema: + $ref: "#/components/schemas/LabelsResponse" + default: + description: Unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + post: + operationId: PostNotificationRuleIDLabels + tags: + - NotificationRules + summary: Add a label to a notification rule + parameters: + - $ref: "#/components/parameters/TraceSpan" + - in: path + name: ruleID + schema: + type: string + required: true + description: The notification rule ID. + requestBody: + description: Label to add + required: true + content: + application/json: + schema: + $ref: "#/components/schemas/LabelMapping" + responses: + "201": + description: The label was added to the notification rule + content: + application/json: + schema: + $ref: "#/components/schemas/LabelResponse" + default: + description: Unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + "/notificationRules/{ruleID}/labels/{labelID}": + delete: + operationId: DeleteNotificationRulesIDLabelsID + tags: + - NotificationRules + summary: Delete label from a notification rule + parameters: + - $ref: "#/components/parameters/TraceSpan" + - in: path + name: ruleID + schema: + type: string + required: true + description: The notification rule ID. + - in: path + name: labelID + schema: + type: string + required: true + description: The ID of the label to delete. + responses: + "204": + description: Delete has been accepted + "404": + description: Rule or label not found + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + default: + description: Unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + "/notificationRules/{ruleID}/query": + get: + operationId: GetNotificationRulesIDQuery + tags: + - Rules + summary: Get a notification rule query + parameters: + - $ref: "#/components/parameters/TraceSpan" + - in: path + name: ruleID + schema: + type: string + required: true + description: The notification rule ID. + responses: + "200": + description: The notification rule query requested + content: + application/json: + schema: + $ref: "#/components/schemas/FluxResponse" + "400": + description: Invalid request + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + "404": + description: Notification rule not found + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + default: + description: Unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + /notificationEndpoints: + get: + operationId: GetNotificationEndpoints + tags: + - NotificationEndpoints + summary: Get all notification endpoints + parameters: + - $ref: "#/components/parameters/TraceSpan" + - $ref: "#/components/parameters/Offset" + - $ref: "#/components/parameters/Limit" + - in: query + name: orgID + required: true + description: Only show notification endpoints that belong to specific organization ID. + schema: + type: string + responses: + "200": + description: A list of notification endpoints + content: + application/json: + schema: + $ref: "#/components/schemas/NotificationEndpoints" + default: + description: Unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + post: + operationId: CreateNotificationEndpoint + tags: + - NotificationEndpoints + summary: Add a notification endpoint + requestBody: + description: Notification endpoint to create + required: true + content: + application/json: + schema: + $ref: "#/components/schemas/PostNotificationEndpoint" + responses: + "201": + description: Notification endpoint created + content: + application/json: + schema: + $ref: "#/components/schemas/NotificationEndpoint" + default: + description: Unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + "/notificationEndpoints/{endpointID}": + get: + operationId: GetNotificationEndpointsID + tags: + - NotificationEndpoints + summary: Get a notification endpoint + parameters: + - $ref: "#/components/parameters/TraceSpan" + - in: path + name: endpointID + schema: + type: string + required: true + description: The notification endpoint ID. + responses: + "200": + description: The notification endpoint requested + content: + application/json: + schema: + $ref: "#/components/schemas/NotificationEndpoint" + default: + description: Unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + put: + operationId: PutNotificationEndpointsID + tags: + - NotificationEndpoints + summary: Update a notification endpoint + requestBody: + description: A new notification endpoint to replace the existing endpoint with + required: true + content: + application/json: + schema: + $ref: "#/components/schemas/NotificationEndpoint" + parameters: + - $ref: "#/components/parameters/TraceSpan" + - in: path + name: endpointID + schema: + type: string + required: true + description: The notification endpoint ID. + responses: + "200": + description: An updated notification endpoint + content: + application/json: + schema: + $ref: "#/components/schemas/NotificationEndpoint" + "404": + description: The notification endpoint was not found + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + default: + description: Unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + patch: + operationId: PatchNotificationEndpointsID + tags: + - NotificationEndpoints + summary: Update a notification endpoint + requestBody: + description: Check update to apply + required: true + content: + application/json: + schema: + $ref: "#/components/schemas/NotificationEndpointUpdate" + parameters: + - $ref: "#/components/parameters/TraceSpan" + - in: path + name: endpointID + schema: + type: string + required: true + description: The notification endpoint ID. + responses: + "200": + description: An updated notification endpoint + content: + application/json: + schema: + $ref: "#/components/schemas/NotificationEndpoint" + "404": + description: The notification endpoint was not found + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + default: + description: Unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + delete: + operationId: DeleteNotificationEndpointsID + tags: + - NotificationEndpoints + summary: Delete a notification endpoint + parameters: + - $ref: "#/components/parameters/TraceSpan" + - in: path + name: endpointID + schema: + type: string + required: true + description: The notification endpoint ID. + responses: + "204": + description: Delete has been accepted + "404": + description: The endpoint was not found + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + default: + description: Unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + "/notificationEndpoints/{endpointID}/labels": + get: + operationId: GetNotificationEndpointsIDLabels + tags: + - NotificationEndpoints + summary: List all labels for a notification endpoint + parameters: + - $ref: "#/components/parameters/TraceSpan" + - in: path + name: endpointID + schema: + type: string + required: true + description: The notification endpoint ID. + responses: + "200": + description: A list of all labels for a notification endpoint + content: + application/json: + schema: + $ref: "#/components/schemas/LabelsResponse" + default: + description: Unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + post: + operationId: PostNotificationEndpointIDLabels + tags: + - NotificationEndpoints + summary: Add a label to a notification endpoint + parameters: + - $ref: "#/components/parameters/TraceSpan" + - in: path + name: endpointID + schema: + type: string + required: true + description: The notification endpoint ID. + requestBody: + description: Label to add + required: true + content: + application/json: + schema: + $ref: "#/components/schemas/LabelMapping" + responses: + "201": + description: The label was added to the notification endpoint + content: + application/json: + schema: + $ref: "#/components/schemas/LabelResponse" + default: + description: Unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + "/notificationEndpoints/{endpointID}/labels/{labelID}": + delete: + operationId: DeleteNotificationEndpointsIDLabelsID + tags: + - NotificationEndpoints + summary: Delete a label from a notification endpoint + parameters: + - $ref: "#/components/parameters/TraceSpan" + - in: path + name: endpointID + schema: + type: string + required: true + description: The notification endpoint ID. + - in: path + name: labelID + schema: + type: string + required: true + description: The ID of the label to delete. + responses: + "204": + description: Delete has been accepted + "404": + description: Endpoint or label not found + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + default: + description: Unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" +components: + parameters: + Offset: + in: query + name: offset + required: false + schema: + type: integer + minimum: 0 + Limit: + in: query + name: limit + required: false + schema: + type: integer + minimum: 1 + maximum: 100 + default: 20 + Descending: + in: query + name: descending + required: false + schema: + type: boolean + default: false + SortBy: + in: query + name: sortBy + required: false + schema: + type: string + TraceSpan: + in: header + name: Zap-Trace-Span + description: OpenTracing span context + example: + trace_id: "1" + span_id: "1" + baggage: + key: value + required: false + schema: + type: string + After: + in: query + name: after + required: false + schema: + type: string + description: > + The last resource ID from which to seek from (but not including). + This is to be used instead of `offset`. + schemas: + LanguageRequest: + description: Flux query to be analyzed. + type: object + required: + - query + properties: + query: + description: Flux query script to be analyzed + type: string + Query: + description: Query influx using the Flux language + type: object + required: + - query + properties: + extern: + $ref: "#/components/schemas/File" + query: + description: Query script to execute. + type: string + type: + description: The type of query. Must be "flux". + type: string + enum: + - flux + dialect: + $ref: "#/components/schemas/Dialect" + now: + description: Specifies the time that should be reported as "now" in the query. Default is the server's now time. + type: string + format: date-time + InfluxQLQuery: + description: Query influx using the InfluxQL language + type: object + required: + - query + properties: + query: + description: InfluxQL query execute. + type: string + type: + description: The type of query. Must be "influxql". + type: string + enum: + - influxql + bucket: + description: Bucket is to be used instead of the database and retention policy specified in the InfluxQL query. + type: string + Package: + description: Represents a complete package source tree. + type: object + properties: + type: + $ref: "#/components/schemas/NodeType" + path: + description: Package import path + type: string + package: + description: Package name + type: string + files: + description: Package files + type: array + items: + $ref: "#/components/schemas/File" + File: + description: Represents a source from a single file + type: object + properties: + type: + $ref: "#/components/schemas/NodeType" + name: + description: The name of the file. + type: string + package: + $ref: "#/components/schemas/PackageClause" + imports: + description: A list of package imports + type: array + items: + $ref: "#/components/schemas/ImportDeclaration" + body: + description: List of Flux statements + type: array + items: + $ref: "#/components/schemas/Statement" + PackageClause: + description: Defines a package identifier + type: object + properties: + type: + $ref: "#/components/schemas/NodeType" + name: + $ref: "#/components/schemas/Identifier" + ImportDeclaration: + description: Declares a package import + type: object + properties: + type: + $ref: "#/components/schemas/NodeType" + as: + $ref: "#/components/schemas/Identifier" + path: + $ref: "#/components/schemas/StringLiteral" + DeletePredicateRequest: + description: The delete predicate request. + type: object + required: [start, stop] + properties: + start: + description: RFC3339Nano + type: string + format: date-time + stop: + description: RFC3339Nano + type: string + format: date-time + predicate: + description: InfluxQL-like delete statement + example: tag1="value1" and (tag2="value2" and tag3!="value3") + type: string + Node: + oneOf: + - $ref: "#/components/schemas/Expression" + - $ref: "#/components/schemas/Block" + Block: + description: A set of statements + type: object + properties: + type: + $ref: "#/components/schemas/NodeType" + body: + description: Block body + type: array + items: + $ref: "#/components/schemas/Statement" + Statement: + oneOf: + - $ref: "#/components/schemas/BadStatement" + - $ref: "#/components/schemas/VariableAssignment" + - $ref: "#/components/schemas/MemberAssignment" + - $ref: "#/components/schemas/ExpressionStatement" + - $ref: "#/components/schemas/ReturnStatement" + - $ref: "#/components/schemas/OptionStatement" + - $ref: "#/components/schemas/BuiltinStatement" + - $ref: "#/components/schemas/TestStatement" + BadStatement: + description: A placeholder for statements for which no correct statement nodes can be created + type: object + properties: + type: + $ref: "#/components/schemas/NodeType" + text: + description: Raw source text + type: string + VariableAssignment: + description: Represents the declaration of a variable + type: object + properties: + type: + $ref: "#/components/schemas/NodeType" + id: + $ref: "#/components/schemas/Identifier" + init: + $ref: "#/components/schemas/Expression" + MemberAssignment: + description: Object property assignment + type: object + properties: + type: + $ref: "#/components/schemas/NodeType" + member: + $ref: "#/components/schemas/MemberExpression" + init: + $ref: "#/components/schemas/Expression" + ExpressionStatement: + description: May consist of an expression that does not return a value and is executed solely for its side-effects + type: object + properties: + type: + $ref: "#/components/schemas/NodeType" + expression: + $ref: "#/components/schemas/Expression" + ReturnStatement: + description: Defines an expression to return + type: object + properties: + type: + $ref: "#/components/schemas/NodeType" + argument: + $ref: "#/components/schemas/Expression" + OptionStatement: + description: A single variable declaration + type: object + properties: + type: + $ref: "#/components/schemas/NodeType" + assignment: + oneOf: + - $ref: "#/components/schemas/VariableAssignment" + - $ref: "#/components/schemas/MemberAssignment" + BuiltinStatement: + description: Declares a builtin identifier and its type + type: object + properties: + type: + $ref: "#/components/schemas/NodeType" + id: + $ref: "#/components/schemas/Identifier" + TestStatement: + description: Declares a Flux test case + type: object + properties: + type: + $ref: "#/components/schemas/NodeType" + assignment: + $ref: "#/components/schemas/VariableAssignment" + Expression: + oneOf: + - $ref: "#/components/schemas/ArrayExpression" + - $ref: "#/components/schemas/DictExpression" + - $ref: "#/components/schemas/FunctionExpression" + - $ref: "#/components/schemas/BinaryExpression" + - $ref: "#/components/schemas/CallExpression" + - $ref: "#/components/schemas/ConditionalExpression" + - $ref: "#/components/schemas/LogicalExpression" + - $ref: "#/components/schemas/MemberExpression" + - $ref: "#/components/schemas/IndexExpression" + - $ref: "#/components/schemas/ObjectExpression" + - $ref: "#/components/schemas/ParenExpression" + - $ref: "#/components/schemas/PipeExpression" + - $ref: "#/components/schemas/UnaryExpression" + - $ref: "#/components/schemas/BooleanLiteral" + - $ref: "#/components/schemas/DateTimeLiteral" + - $ref: "#/components/schemas/DurationLiteral" + - $ref: "#/components/schemas/FloatLiteral" + - $ref: "#/components/schemas/IntegerLiteral" + - $ref: "#/components/schemas/PipeLiteral" + - $ref: "#/components/schemas/RegexpLiteral" + - $ref: "#/components/schemas/StringLiteral" + - $ref: "#/components/schemas/UnsignedIntegerLiteral" + - $ref: "#/components/schemas/Identifier" + ArrayExpression: + description: Used to create and directly specify the elements of an array object + type: object + properties: + type: + $ref: "#/components/schemas/NodeType" + elements: + description: Elements of the array + type: array + items: + $ref: "#/components/schemas/Expression" + DictExpression: + description: Used to create and directly specify the elements of a dictionary + type: object + properties: + type: + $ref: "#/components/schemas/NodeType" + elements: + description: Elements of the dictionary + type: array + items: + $ref: "#/components/schemas/DictItem" + DictItem: + description: A key/value pair in a dictionary + type: object + properties: + type: + $ref: "#/components/schemas/NodeType" + key: + $ref: "#/components/schemas/Expression" + val: + $ref: "#/components/schemas/Expression" + FunctionExpression: + description: Function expression + type: object + properties: + type: + $ref: "#/components/schemas/NodeType" + params: + description: Function parameters + type: array + items: + $ref: "#/components/schemas/Property" + body: + $ref: "#/components/schemas/Node" + BinaryExpression: + description: uses binary operators to act on two operands in an expression + type: object + properties: + type: + $ref: "#/components/schemas/NodeType" + operator: + type: string + left: + $ref: "#/components/schemas/Expression" + right: + $ref: "#/components/schemas/Expression" + CallExpression: + description: Represents a function call + type: object + properties: + type: + $ref: "#/components/schemas/NodeType" + callee: + $ref: "#/components/schemas/Expression" + arguments: + description: Function arguments + type: array + items: + $ref: "#/components/schemas/Expression" + ConditionalExpression: + description: Selects one of two expressions, `Alternate` or `Consequent`, depending on a third boolean expression, `Test` + type: object + properties: + type: + $ref: "#/components/schemas/NodeType" + test: + $ref: "#/components/schemas/Expression" + alternate: + $ref: "#/components/schemas/Expression" + consequent: + $ref: "#/components/schemas/Expression" + LogicalExpression: + description: Represents the rule conditions that collectively evaluate to either true or false + type: object + properties: + type: + $ref: "#/components/schemas/NodeType" + operator: + type: string + left: + $ref: "#/components/schemas/Expression" + right: + $ref: "#/components/schemas/Expression" + MemberExpression: + description: Represents accessing a property of an object + type: object + properties: + type: + $ref: "#/components/schemas/NodeType" + object: + $ref: "#/components/schemas/Expression" + property: + $ref: "#/components/schemas/PropertyKey" + IndexExpression: + description: Represents indexing into an array + type: object + properties: + type: + $ref: "#/components/schemas/NodeType" + array: + $ref: "#/components/schemas/Expression" + index: + $ref: "#/components/schemas/Expression" + ObjectExpression: + description: Allows the declaration of an anonymous object within a declaration + type: object + properties: + type: + $ref: "#/components/schemas/NodeType" + properties: + description: Object properties + type: array + items: + $ref: "#/components/schemas/Property" + ParenExpression: + description: Represents an expression wrapped in parenthesis + type: object + properties: + type: + $ref: "#/components/schemas/NodeType" + expression: + $ref: "#/components/schemas/Expression" + PipeExpression: + description: Call expression with pipe argument + type: object + properties: + type: + $ref: "#/components/schemas/NodeType" + argument: + $ref: "#/components/schemas/Expression" + call: + $ref: "#/components/schemas/CallExpression" + UnaryExpression: + description: Uses operators to act on a single operand in an expression + type: object + properties: + type: + $ref: "#/components/schemas/NodeType" + operator: + type: string + argument: + $ref: "#/components/schemas/Expression" + BooleanLiteral: + description: Represents boolean values + type: object + properties: + type: + $ref: "#/components/schemas/NodeType" + value: + type: boolean + DateTimeLiteral: + description: Represents an instant in time with nanosecond precision using the syntax of golang's RFC3339 Nanosecond variant + type: object + properties: + type: + $ref: "#/components/schemas/NodeType" + value: + type: string + DurationLiteral: + description: Represents the elapsed time between two instants as an int64 nanosecond count with syntax of golang's time.Duration + type: object + properties: + type: + $ref: "#/components/schemas/NodeType" + values: + description: Duration values + type: array + items: + $ref: "#/components/schemas/Duration" + FloatLiteral: + description: Represents floating point numbers according to the double representations defined by the IEEE-754-1985 + type: object + properties: + type: + $ref: "#/components/schemas/NodeType" + value: + type: number + IntegerLiteral: + description: Represents integer numbers + type: object + properties: + type: + $ref: "#/components/schemas/NodeType" + value: + type: string + PipeLiteral: + description: Represents a specialized literal value, indicating the left hand value of a pipe expression + type: object + properties: + type: + $ref: "#/components/schemas/NodeType" + RegexpLiteral: + description: Expressions begin and end with `/` and are regular expressions with syntax accepted by RE2 + type: object + properties: + type: + $ref: "#/components/schemas/NodeType" + value: + type: string + StringLiteral: + description: Expressions begin and end with double quote marks + type: object + properties: + type: + $ref: "#/components/schemas/NodeType" + value: + type: string + UnsignedIntegerLiteral: + description: Represents integer numbers + type: object + properties: + type: + $ref: "#/components/schemas/NodeType" + value: + type: string + Duration: + description: A pair consisting of length of time and the unit of time measured. It is the atomic unit from which all duration literals are composed. + type: object + properties: + type: + $ref: "#/components/schemas/NodeType" + magnitude: + type: integer + unit: + type: string + Property: + description: The value associated with a key + type: object + properties: + type: + $ref: "#/components/schemas/NodeType" + key: + $ref: "#/components/schemas/PropertyKey" + value: + $ref: "#/components/schemas/Expression" + PropertyKey: + oneOf: + - $ref: "#/components/schemas/Identifier" + - $ref: "#/components/schemas/StringLiteral" + Identifier: + description: A valid Flux identifier + type: object + properties: + type: + $ref: "#/components/schemas/NodeType" + name: + type: string + NodeType: + description: Type of AST node + type: string + Dialect: + description: Dialect are options to change the default CSV output format; https://www.w3.org/TR/2015/REC-tabular-metadata-20151217/#dialect-descriptions + type: object + properties: + header: + description: If true, the results will contain a header row + type: boolean + default: true + delimiter: + description: Separator between cells; the default is , + type: string + default: "," + maxLength: 1 + minLength: 1 + annotations: + description: https://www.w3.org/TR/2015/REC-tabular-data-model-20151217/#columns + type: array + uniqueItems: true + items: + type: string + enum: + - "group" + - "datatype" + - "default" + commentPrefix: + description: Character prefixed to comment strings + type: string + default: "#" + maxLength: 1 + minLength: 0 + dateTimeFormat: + description: Format of timestamps + type: string + default: "RFC3339" + enum: + - RFC3339 + - RFC3339Nano + Permission: + required: [action, resource] + properties: + action: + type: string + enum: + - read + - write + resource: + $ref: "#/components/schemas/Resource" + Resource: + type: object + required: [type] + properties: + type: + type: string + enum: + - authorizations + - buckets + - dashboards + - orgs + - sources + - tasks + - telegrafs + - users + - variables + - scrapers + - secrets + - labels + - views + - documents + - notificationRules + - notificationEndpoints + - checks + - dbrp + id: + type: string + nullable: true + description: If ID is set that is a permission for a specific resource. if it is not set it is a permission for all resources of that resource type. + name: + type: string + nullable: true + description: Optional name of the resource if the resource has a name field. + orgID: + type: string + nullable: true + description: If orgID is set that is a permission for all resources owned my that org. if it is not set it is a permission for all resources of that resource type. + org: + type: string + nullable: true + description: Optional name of the organization of the organization with orgID. + AuthorizationUpdateRequest: + properties: + status: + description: If inactive the token is inactive and requests using the token will be rejected. + default: active + type: string + enum: + - active + - inactive + description: + type: string + description: A description of the token. + Authorization: + required: [orgID, permissions] + allOf: + - $ref: "#/components/schemas/AuthorizationUpdateRequest" + - type: object + properties: + createdAt: + type: string + format: date-time + readOnly: true + updatedAt: + type: string + format: date-time + readOnly: true + orgID: + type: string + description: ID of org that authorization is scoped to. + permissions: + type: array + minItems: 1 + description: List of permissions for an auth. An auth must have at least one Permission. + items: + $ref: "#/components/schemas/Permission" + id: + readOnly: true + type: string + token: + readOnly: true + type: string + description: Passed via the Authorization Header and Token Authentication type. + userID: + readOnly: true + type: string + description: ID of user that created and owns the token. + user: + readOnly: true + type: string + description: Name of user that created and owns the token. + org: + readOnly: true + type: string + description: Name of the org token is scoped to. + links: + type: object + readOnly: true + example: + self: "/api/v2/authorizations/1" + user: "/api/v2/users/12" + properties: + self: + readOnly: true + $ref: "#/components/schemas/Link" + user: + readOnly: true + $ref: "#/components/schemas/Link" + Authorizations: + type: object + properties: + links: + readOnly: true + $ref: "#/components/schemas/Links" + authorizations: + type: array + items: + $ref: "#/components/schemas/Authorization" + PostBucketRequest: + properties: + orgID: + type: string + name: + type: string + description: + type: string + rp: + type: string + retentionRules: + $ref: "#/components/schemas/RetentionRules" + required: [orgID, name, retentionRules] + Bucket: + properties: + links: + type: object + readOnly: true + example: + labels: "/api/v2/buckets/1/labels" + members: "/api/v2/buckets/1/members" + org: "/api/v2/orgs/2" + owners: "/api/v2/buckets/1/owners" + self: "/api/v2/buckets/1" + write: "/api/v2/write?org=2&bucket=1" + properties: + labels: + description: URL to retrieve labels for this bucket + $ref: "#/components/schemas/Link" + members: + description: URL to retrieve members that can read this bucket + $ref: "#/components/schemas/Link" + org: + description: URL to retrieve parent organization for this bucket + $ref: "#/components/schemas/Link" + owners: + description: URL to retrieve owners that can read and write to this bucket. + $ref: "#/components/schemas/Link" + self: + description: URL for this bucket + $ref: "#/components/schemas/Link" + write: + description: URL to write line protocol for this bucket + $ref: "#/components/schemas/Link" + id: + readOnly: true + type: string + type: + readOnly: true + type: string + default: user + enum: + - user + - system + name: + type: string + description: + type: string + orgID: + type: string + rp: + type: string + createdAt: + type: string + format: date-time + readOnly: true + updatedAt: + type: string + format: date-time + readOnly: true + retentionRules: + $ref: "#/components/schemas/RetentionRules" + labels: + $ref: "#/components/schemas/Labels" + required: [name, retentionRules] + Buckets: + type: object + properties: + links: + readOnly: true + $ref: "#/components/schemas/Links" + buckets: + type: array + items: + $ref: "#/components/schemas/Bucket" + RetentionRules: + type: array + description: Rules to expire or retain data. No rules means data never expires. + items: + $ref: "#/components/schemas/RetentionRule" + RetentionRule: + type: object + properties: + type: + type: string + default: expire + enum: + - expire + everySeconds: + type: integer + description: Duration in seconds for how long data will be kept in the database. 0 means infinite. + example: 86400 + minimum: 0 + shardGroupDurationSeconds: + type: integer + format: int64 + description: Shard duration measured in seconds. + required: [type, everySeconds] + Link: + type: string + format: uri + readOnly: true + description: URI of resource. + Links: + type: object + properties: + next: + $ref: "#/components/schemas/Link" + self: + $ref: "#/components/schemas/Link" + prev: + $ref: "#/components/schemas/Link" + required: [self] + Logs: + type: object + properties: + events: + readOnly: true + type: array + items: + $ref: "#/components/schemas/LogEvent" + LogEvent: + type: object + properties: + time: + readOnly: true + description: Time event occurred, RFC3339Nano. + type: string + format: date-time + message: + readOnly: true + description: A description of the event that occurred. + type: string + example: Halt and catch fire + Organization: + properties: + links: + type: object + readOnly: true + example: + self: "/api/v2/orgs/1" + members: "/api/v2/orgs/1/members" + owners: "/api/v2/orgs/1/owners" + labels: "/api/v2/orgs/1/labels" + secrets: "/api/v2/orgs/1/secrets" + buckets: "/api/v2/buckets?org=myorg" + tasks: "/api/v2/tasks?org=myorg" + dashboards: "/api/v2/dashboards?org=myorg" + properties: + self: + $ref: "#/components/schemas/Link" + members: + $ref: "#/components/schemas/Link" + owners: + $ref: "#/components/schemas/Link" + labels: + $ref: "#/components/schemas/Link" + secrets: + $ref: "#/components/schemas/Link" + buckets: + $ref: "#/components/schemas/Link" + tasks: + $ref: "#/components/schemas/Link" + dashboards: + $ref: "#/components/schemas/Link" + id: + readOnly: true + type: string + name: + type: string + description: + type: string + createdAt: + type: string + format: date-time + readOnly: true + updatedAt: + type: string + format: date-time + readOnly: true + status: + description: If inactive the organization is inactive. + default: active + type: string + enum: + - active + - inactive + required: [name] + Organizations: + type: object + properties: + links: + $ref: "#/components/schemas/Links" + orgs: + type: array + items: + $ref: "#/components/schemas/Organization" + TemplateApply: + type: object + properties: + dryRun: + type: boolean + orgID: + type: string + stackID: + type: string + template: + type: object + properties: + contentType: + type: string + sources: + type: array + items: + type: string + contents: + $ref: "#/components/schemas/Template" + templates: + type: array + items: + type: object + properties: + contentType: + type: string + sources: + type: array + items: + type: string + contents: + $ref: "#/components/schemas/Template" + envRefs: + type: object + additionalProperties: + oneOf: + - type: string + - type: integer + - type: number + - type: boolean + secrets: + type: object + additionalProperties: + type: string + remotes: + type: array + items: + type: object + properties: + url: + type: string + contentType: + type: string + required: ["url"] + actions: + type: array + items: + oneOf: + - type: object + properties: + action: + type: string + enum: ["skipKind"] + properties: + type: object + properties: + kind: + $ref: "#/components/schemas/TemplateKind" + required: ["kind"] + - type: object + properties: + action: + type: string + enum: ["skipResource"] + properties: + type: object + properties: + kind: + $ref: "#/components/schemas/TemplateKind" + resourceTemplateName: + type: string + required: ["kind", "resourceTemplateName"] + TemplateKind: + type: string + enum: + - Bucket + - Check + - CheckDeadman + - CheckThreshold + - Dashboard + - Label + - NotificationEndpoint + - NotificationEndpointHTTP + - NotificationEndpointPagerDuty + - NotificationEndpointSlack + - NotificationRule + - Task + - Telegraf + - Variable + TemplateExportByID: + type: object + properties: + stackID: + type: string + orgIDs: + type: array + items: + type: object + properties: + orgID: + type: string + resourceFilters: + type: object + properties: + byLabel: + type: array + items: + type: string + byResourceKind: + type: array + items: + $ref: "#/components/schemas/TemplateKind" + resources: + type: object + properties: + id: + type: string + kind: + $ref: "#/components/schemas/TemplateKind" + name: + type: string + description: "if defined with id, name is used for resource exported by id. if defined independently, resources strictly matching name are exported" + required: [id, kind] + TemplateExportByName: + type: object + properties: + stackID: + type: string + orgIDs: + type: array + items: + type: object + properties: + orgID: + type: string + resourceFilters: + type: object + properties: + byLabel: + type: array + items: + type: string + byResourceKind: + type: array + items: + $ref: "#/components/schemas/TemplateKind" + resources: + type: object + properties: + kind: + $ref: "#/components/schemas/TemplateKind" + name: + type: string + required: [name, kind] + Template: + type: array + items: + type: object + properties: + apiVersion: + type: string + kind: + $ref: "#/components/schemas/TemplateKind" + meta: + type: object + properties: + name: + type: string + spec: + type: object + TemplateEnvReferences: + type: array + items: + type: object + properties: + resourceField: + type: string + description: Field the environment reference corresponds too + envRefKey: + type: string + description: Key identified as environment reference and is the key identified in the template + value: + description: Value provided to fulfill reference + nullable: true + oneOf: + - type: string + - type: integer + - type: number + - type: boolean + defaultValue: + description: Default value that will be provided for the reference when no value is provided + nullable: true + oneOf: + - type: string + - type: integer + - type: number + - type: boolean + required: [resourceField, envRefKey] + TemplateSummary: + type: object + properties: + sources: + type: array + items: + type: string + stackID: + type: string + summary: + type: object + properties: + buckets: + type: array + items: + type: object + properties: + id: + type: string + orgID: + type: string + kind: + $ref: "#/components/schemas/TemplateKind" + templateMetaName: + type: string + name: + type: string + description: + type: string + retentionPeriod: + type: integer + labelAssociations: + type: array + items: + $ref: "#/components/schemas/TemplateSummaryLabel" + envReferences: + $ref: "#/components/schemas/TemplateEnvReferences" + checks: + type: array + items: + allOf: + - $ref: "#/components/schemas/CheckDiscriminator" + - type: object + properties: + kind: + $ref: "#/components/schemas/TemplateKind" + templateMetaName: + type: string + labelAssociations: + type: array + items: + $ref: "#/components/schemas/TemplateSummaryLabel" + envReferences: + $ref: "#/components/schemas/TemplateEnvReferences" + dashboards: + type: array + items: + type: object + properties: + id: + type: "string" + orgID: + type: "string" + kind: + $ref: "#/components/schemas/TemplateKind" + templateMetaName: + type: string + name: + type: "string" + description: + type: "string" + labelAssociations: + type: array + items: + $ref: "#/components/schemas/TemplateSummaryLabel" + charts: + type: array + items: + $ref: "#/components/schemas/TemplateChart" + envReferences: + $ref: "#/components/schemas/TemplateEnvReferences" + labels: + type: array + items: + $ref: "#/components/schemas/TemplateSummaryLabel" + labelMappings: + type: array + items: + type: object + properties: + status: + type: string + resourceTemplateMetaName: + type: string + resourceName: + type: string + resourceID: + type: string + resourceType: + type: string + labelTemplateMetaName: + type: string + labelName: + type: string + labelID: + type: string + missingEnvRefs: + type: array + items: + type: string + missingSecrets: + type: array + items: + type: string + notificationEndpoints: + type: array + items: + allOf: + - $ref: "#/components/schemas/NotificationEndpointDiscrimator" + - type: object + properties: + kind: + $ref: "#/components/schemas/TemplateKind" + templateMetaName: + type: string + labelAssociations: + type: array + items: + $ref: "#/components/schemas/TemplateSummaryLabel" + envReferences: + $ref: "#/components/schemas/TemplateEnvReferences" + notificationRules: + type: array + items: + type: object + properties: + kind: + $ref: "#/components/schemas/TemplateKind" + templateMetaName: + type: string + name: + type: string + description: + type: string + endpointTemplateMetaName: + type: string + endpointID: + type: string + endpointType: + type: string + every: + type: string + offset: + type: string + messageTemplate: + type: string + status: + type: string + statusRules: + type: array + items: + type: object + properties: + currentLevel: + type: string + previousLevel: + type: string + tagRules: + type: array + items: + type: object + properties: + key: + type: string + value: + type: string + operator: + type: string + labelAssociations: + type: array + items: + $ref: "#/components/schemas/TemplateSummaryLabel" + envReferences: + $ref: "#/components/schemas/TemplateEnvReferences" + tasks: + type: array + items: + type: object + properties: + kind: + $ref: "#/components/schemas/TemplateKind" + templateMetaName: + type: string + id: + type: string + name: + type: string + cron: + type: string + description: + type: string + every: + type: string + offset: + type: string + query: + type: string + status: + type: string + envReferences: + $ref: "#/components/schemas/TemplateEnvReferences" + telegrafConfigs: + type: array + items: + allOf: + - $ref: "#/components/schemas/TelegrafRequest" + - type: object + properties: + kind: + $ref: "#/components/schemas/TemplateKind" + templateMetaName: + type: string + labelAssociations: + type: array + items: + $ref: "#/components/schemas/TemplateSummaryLabel" + envReferences: + $ref: "#/components/schemas/TemplateEnvReferences" + variables: + type: array + items: + type: object + properties: + kind: + $ref: "#/components/schemas/TemplateKind" + templateMetaName: + type: string + id: + type: string + orgID: + type: string + name: + type: string + description: + type: string + arguments: + $ref: "#/components/schemas/VariableProperties" + labelAssociations: + type: array + items: + $ref: "#/components/schemas/TemplateSummaryLabel" + envReferences: + $ref: "#/components/schemas/TemplateEnvReferences" + diff: + type: object + properties: + buckets: + type: array + items: + type: object + properties: + kind: + $ref: "#/components/schemas/TemplateKind" + stateStatus: + type: string + id: + type: string + templateMetaName: + type: string + new: + type: object + properties: + name: + type: string + description: + type: string + retentionRules: + $ref: "#/components/schemas/RetentionRules" + old: + type: object + properties: + name: + type: string + description: + type: string + retentionRules: + $ref: "#/components/schemas/RetentionRules" + checks: + type: array + items: + type: object + properties: + kind: + $ref: "#/components/schemas/TemplateKind" + stateStatus: + type: string + id: + type: string + templateMetaName: + type: string + new: + $ref: "#/components/schemas/CheckDiscriminator" + old: + $ref: "#/components/schemas/CheckDiscriminator" + dashboards: + type: array + items: + type: object + properties: + stateStatus: + type: string + id: + type: string + kind: + $ref: "#/components/schemas/TemplateKind" + templateMetaName: + type: string + new: + type: object + properties: + name: + type: string + description: + type: string + charts: + type: array + items: + $ref: "#/components/schemas/TemplateChart" + old: + type: object + properties: + name: + type: string + description: + type: string + charts: + type: array + items: + $ref: "#/components/schemas/TemplateChart" + labels: + type: array + items: + type: object + properties: + stateStatus: + type: string + kind: + $ref: "#/components/schemas/TemplateKind" + id: + type: string + templateMetaName: + type: string + new: + type: object + properties: + name: + type: string + color: + type: string + description: + type: string + old: + type: object + properties: + name: + type: string + color: + type: string + description: + type: string + labelMappings: + type: array + items: + type: object + properties: + status: + type: string + resourceType: + type: string + resourceID: + type: string + resourceTemplateMetaName: + type: string + resourceName: + type: string + labelID: + type: string + labelTemplateMetaName: + type: string + labelName: + type: string + notificationEndpoints: + type: array + items: + type: object + properties: + kind: + $ref: "#/components/schemas/TemplateKind" + stateStatus: + type: string + id: + type: string + templateMetaName: + type: string + new: + $ref: "#/components/schemas/NotificationEndpointDiscrimator" + old: + $ref: "#/components/schemas/NotificationEndpointDiscrimator" + notificationRules: + type: array + items: + type: object + properties: + kind: + $ref: "#/components/schemas/TemplateKind" + stateStatus: + type: string + id: + type: string + templateMetaName: + type: string + new: + type: object + properties: + name: + type: string + description: + type: string + endpointName: + type: string + endpointID: + type: string + endpointType: + type: string + every: + type: string + offset: + type: string + messageTemplate: + type: string + status: + type: string + statusRules: + type: array + items: + type: object + properties: + currentLevel: + type: string + previousLevel: + type: string + tagRules: + type: array + items: + type: object + properties: + key: + type: string + value: + type: string + operator: + type: string + old: + type: object + properties: + name: + type: string + description: + type: string + endpointName: + type: string + endpointID: + type: string + endpointType: + type: string + every: + type: string + offset: + type: string + messageTemplate: + type: string + status: + type: string + statusRules: + type: array + items: + type: object + properties: + currentLevel: + type: string + previousLevel: + type: string + tagRules: + type: array + items: + type: object + properties: + key: + type: string + value: + type: string + operator: + type: string + tasks: + type: array + items: + type: object + properties: + kind: + $ref: "#/components/schemas/TemplateKind" + stateStatus: + type: string + id: + type: string + templateMetaName: + type: string + new: + type: object + properties: + name: + type: string + cron: + type: string + description: + type: string + every: + type: string + offset: + type: string + query: + type: string + status: + type: string + old: + type: object + properties: + name: + type: string + cron: + type: string + description: + type: string + every: + type: string + offset: + type: string + query: + type: string + status: + type: string + telegrafConfigs: + type: array + items: + type: object + properties: + kind: + $ref: "#/components/schemas/TemplateKind" + stateStatus: + type: string + id: + type: string + templateMetaName: + type: string + new: + $ref: "#/components/schemas/TelegrafRequest" + old: + $ref: "#/components/schemas/TelegrafRequest" + variables: + type: array + items: + type: object + properties: + kind: + $ref: "#/components/schemas/TemplateKind" + stateStatus: + type: string + id: + type: string + templateMetaName: + type: string + new: + type: object + properties: + name: + type: string + description: + type: string + args: + $ref: "#/components/schemas/VariableProperties" + old: + type: object + properties: + name: + type: string + description: + type: string + args: + $ref: "#/components/schemas/VariableProperties" + errors: + type: array + items: + type: object + properties: + kind: + $ref: "#/components/schemas/TemplateKind" + reason: + type: string + fields: + type: array + items: + type: string + indexes: + type: array + items: + type: integer + TemplateSummaryLabel: + type: object + properties: + id: + type: string + orgID: + type: string + kind: + $ref: "#/components/schemas/TemplateKind" + templateMetaName: + type: string + name: + type: string + properties: + type: object + properties: + color: + type: string + description: + type: string + envReferences: + $ref: "#/components/schemas/TemplateEnvReferences" + TemplateChart: + type: object + properties: + xPos: + type: integer + yPos: + type: integer + height: + type: integer + width: + type: integer + properties: # field name is properties + $ref: "#/components/schemas/ViewProperties" + Stack: + type: object + properties: + id: + type: string + orgID: + type: string + createdAt: + type: string + format: date-time + readOnly: true + events: + type: array + items: + type: object + properties: + eventType: + type: string + name: + type: string + description: + type: string + sources: + type: array + items: + type: string + resources: + type: array + items: + type: object + properties: + apiVersion: + type: string + resourceID: + type: string + kind: + $ref: "#/components/schemas/TemplateKind" + templateMetaName: + type: string + associations: + type: array + items: + type: object + properties: + kind: + $ref: "#/components/schemas/TemplateKind" + metaName: + type: string + links: + type: object + properties: + self: + type: string + urls: + type: array + items: + type: string + updatedAt: + type: string + format: date-time + readOnly: true + Runs: + type: object + properties: + links: + $ref: "#/components/schemas/Links" + runs: + type: array + items: + $ref: "#/components/schemas/Run" + Run: + properties: + id: + readOnly: true + type: string + taskID: + readOnly: true + type: string + status: + readOnly: true + type: string + enum: + - scheduled + - started + - failed + - success + - canceled + scheduledFor: + description: Time used for run's "now" option, RFC3339. + type: string + format: date-time + log: + description: An array of logs associated with the run. + type: array + readOnly: true + items: + type: object + properties: + runID: + type: string + time: + type: string + message: + type: string + startedAt: + readOnly: true + description: Time run started executing, RFC3339Nano. + type: string + format: date-time + finishedAt: + readOnly: true + description: Time run finished executing, RFC3339Nano. + type: string + format: date-time + requestedAt: + readOnly: true + description: Time run was manually requested, RFC3339Nano. + type: string + format: date-time + links: + type: object + readOnly: true + example: + self: "/api/v2/tasks/1/runs/1" + task: "/api/v2/tasks/1" + retry: "/api/v2/tasks/1/runs/1/retry" + properties: + self: + type: string + format: uri + task: + type: string + format: uri + retry: + type: string + format: uri + RunManually: + properties: + scheduledFor: + nullable: true + description: Time used for run's "now" option, RFC3339. Default is the server's now time. + type: string + format: date-time + Tasks: + type: object + properties: + links: + readOnly: true + $ref: "#/components/schemas/Links" + tasks: + type: array + items: + $ref: "#/components/schemas/Task" + Task: + type: object + properties: + id: + readOnly: true + type: string + type: + description: The type of task, this can be used for filtering tasks on list actions. + type: string + orgID: + description: The ID of the organization that owns this Task. + type: string + org: + description: The name of the organization that owns this Task. + type: string + name: + description: The name of the task. + type: string + description: + description: An optional description of the task. + type: string + status: + $ref: "#/components/schemas/TaskStatusType" + labels: + $ref: "#/components/schemas/Labels" + authorizationID: + description: The ID of the authorization used when this task communicates with the query engine. + type: string + flux: + description: The Flux script to run for this task. + type: string + every: + description: A simple task repetition schedule; parsed from Flux. + type: string + cron: + description: A task repetition schedule in the form '* * * * * *'; parsed from Flux. + type: string + offset: + description: Duration to delay after the schedule, before executing the task; parsed from flux, if set to zero it will remove this option and use 0 as the default. + type: string + latestCompleted: + description: Timestamp of latest scheduled, completed run, RFC3339. + type: string + format: date-time + readOnly: true + lastRunStatus: + readOnly: true + type: string + enum: + - failed + - success + - canceled + lastRunError: + readOnly: true + type: string + createdAt: + type: string + format: date-time + readOnly: true + updatedAt: + type: string + format: date-time + readOnly: true + links: + type: object + readOnly: true + example: + self: "/api/v2/tasks/1" + owners: "/api/v2/tasks/1/owners" + members: "/api/v2/tasks/1/members" + labels: "/api/v2/tasks/1/labels" + runs: "/api/v2/tasks/1/runs" + logs: "/api/v2/tasks/1/logs" + properties: + self: + $ref: "#/components/schemas/Link" + owners: + $ref: "#/components/schemas/Link" + members: + $ref: "#/components/schemas/Link" + runs: + $ref: "#/components/schemas/Link" + logs: + $ref: "#/components/schemas/Link" + labels: + $ref: "#/components/schemas/Link" + required: [id, name, orgID, flux] + TaskStatusType: + type: string + enum: [active, inactive] + User: + properties: + id: + readOnly: true + type: string + oauthID: + type: string + name: + type: string + status: + description: If inactive the user is inactive. + default: active + type: string + enum: + - active + - inactive + links: + type: object + readOnly: true + example: + self: "/api/v2/users/1" + properties: + self: + type: string + format: uri + required: [name] + Users: + type: object + properties: + links: + type: object + properties: + self: + type: string + format: uri + users: + type: array + items: + $ref: "#/components/schemas/User" + Flags: + type: object + additionalProperties: true + ResourceMember: + allOf: + - $ref: "#/components/schemas/User" + - type: object + properties: + role: + type: string + default: member + enum: + - member + ResourceMembers: + type: object + properties: + links: + type: object + properties: + self: + type: string + format: uri + users: + type: array + items: + $ref: "#/components/schemas/ResourceMember" + ResourceOwner: + allOf: + - $ref: "#/components/schemas/User" + - type: object + properties: + role: + type: string + default: owner + enum: + - owner + ResourceOwners: + type: object + properties: + links: + type: object + properties: + self: + type: string + format: uri + users: + type: array + items: + $ref: "#/components/schemas/ResourceOwner" + FluxSuggestions: + type: object + properties: + funcs: + type: array + items: + $ref: "#/components/schemas/FluxSuggestion" + FluxSuggestion: + type: object + properties: + name: + type: string + params: + type: object + additionalProperties: + type: string + Routes: + properties: + authorizations: + type: string + format: uri + buckets: + type: string + format: uri + dashboards: + type: string + format: uri + external: + type: object + properties: + statusFeed: + type: string + format: uri + variables: + type: string + format: uri + me: + type: string + format: uri + flags: + type: string + format: uri + orgs: + type: string + format: uri + query: + type: object + properties: + self: + type: string + format: uri + ast: + type: string + format: uri + analyze: + type: string + format: uri + suggestions: + type: string + format: uri + setup: + type: string + format: uri + signin: + type: string + format: uri + signout: + type: string + format: uri + sources: + type: string + format: uri + system: + type: object + properties: + metrics: + type: string + format: uri + debug: + type: string + format: uri + health: + type: string + format: uri + tasks: + type: string + format: uri + telegrafs: + type: string + format: uri + users: + type: string + format: uri + write: + type: string + format: uri + Error: + properties: + code: + description: Code is the machine-readable error code. + readOnly: true + type: string + # This set of enumerations must remain in sync with the constants defined in errors.go + enum: + - internal error + - not found + - conflict + - invalid + - unprocessable entity + - empty value + - unavailable + - forbidden + - too many requests + - unauthorized + - method not allowed + message: + readOnly: true + description: Message is a human-readable message. + type: string + required: [code, message] + LineProtocolError: + properties: + code: + description: Code is the machine-readable error code. + readOnly: true + type: string + enum: + - internal error + - not found + - conflict + - invalid + - empty value + - unavailable + message: + readOnly: true + description: Message is a human-readable message. + type: string + op: + readOnly: true + description: Op describes the logical code operation during error. Useful for debugging. + type: string + err: + readOnly: true + description: Err is a stack of errors that occurred during processing of the request. Useful for debugging. + type: string + line: + readOnly: true + description: First line within sent body containing malformed data + type: integer + format: int32 + required: [code, message, op, err] + LineProtocolLengthError: + properties: + code: + description: Code is the machine-readable error code. + readOnly: true + type: string + enum: + - invalid + message: + readOnly: true + description: Message is a human-readable message. + type: string + maxLength: + readOnly: true + description: Max length in bytes for a body of line-protocol. + type: integer + format: int32 + required: [code, message, maxLength] + Field: + type: object + properties: + value: + description: >- + value is the value of the field. Meaning of the value is implied by + the `type` key + type: string + type: + description: >- + `type` describes the field type. `func` is a function. `field` is a field reference. + type: string + enum: + - func + - field + - integer + - number + - regex + - wildcard + alias: + description: >- + Alias overrides the field name in the returned response. Applies only + if type is `func` + type: string + args: + description: Args are the arguments to the function + type: array + items: + $ref: "#/components/schemas/Field" + BuilderConfig: + type: object + properties: + buckets: + type: array + items: + type: string + tags: + type: array + items: + $ref: "#/components/schemas/BuilderTagsType" + functions: + type: array + items: + $ref: "#/components/schemas/BuilderFunctionsType" + aggregateWindow: + type: object + properties: + period: + type: string + fillValues: + type: boolean + BuilderTagsType: + type: object + properties: + key: + type: string + values: + type: array + items: + type: string + aggregateFunctionType: + $ref: "#/components/schemas/BuilderAggregateFunctionType" + BuilderAggregateFunctionType: + type: string + enum: ["filter", "group"] + BuilderFunctionsType: + type: object + properties: + name: + type: string + DashboardQuery: + type: object + properties: + text: + type: string + description: The text of the Flux query. + editMode: + $ref: "#/components/schemas/QueryEditMode" + name: + type: string + builderConfig: + $ref: "#/components/schemas/BuilderConfig" + QueryEditMode: + type: string + enum: ["builder", "advanced"] + Axis: + type: object + description: The description of a particular axis for a visualization. + properties: + bounds: + type: array + minItems: 0 + maxItems: 2 + description: >- + The extents of an axis in the form [lower, upper]. Clients determine + whether bounds are to be inclusive or exclusive of their limits + items: + type: string + label: + description: Label is a description of this Axis + type: string + prefix: + description: Prefix represents a label prefix for formatting axis values. + type: string + suffix: + description: Suffix represents a label suffix for formatting axis values. + type: string + base: + description: Base represents the radix for formatting axis values. + type: string + enum: ["", "2", "10"] + scale: + $ref: "#/components/schemas/AxisScale" + AxisScale: + description: 'Scale is the axis formatting scale. Supported: "log", "linear"' + type: string + enum: ["log", "linear"] + DashboardColor: + type: object + description: Defines an encoding of data value into color space. + required: [id, type, hex, name, value] + properties: + id: + description: The unique ID of the view color. + type: string + type: + description: Type is how the color is used. + type: string + enum: + - min + - max + - threshold + - scale + - text + - background + hex: + description: The hex number of the color + type: string + maxLength: 7 + minLength: 7 + name: + description: The user-facing name of the hex color. + type: string + value: + description: The data value mapped to this color. + type: number + format: float + RenamableField: + description: Describes a field that can be renamed and made visible or invisible. + type: object + properties: + internalName: + description: The calculated name of a field. + readOnly: true + type: string + displayName: + description: The name that a field is renamed to by the user. + type: string + visible: + description: Indicates whether this field should be visible on the table. + type: boolean + XYViewProperties: + type: object + required: + - type + - geom + - queries + - shape + - axes + - colors + - legend + - note + - showNoteWhenEmpty + - position + properties: + timeFormat: + type: string + type: + type: string + enum: [xy] + queries: + type: array + items: + $ref: "#/components/schemas/DashboardQuery" + colors: + description: Colors define color encoding of data into a visualization + type: array + items: + $ref: "#/components/schemas/DashboardColor" + shape: + type: string + enum: ["chronograf-v2"] + note: + type: string + showNoteWhenEmpty: + description: If true, will display note when empty + type: boolean + axes: + $ref: "#/components/schemas/Axes" + legend: + $ref: "#/components/schemas/Legend" + xColumn: + type: string + generateXAxisTicks: + type: array + items: + type: string + xTotalTicks: + type: integer + xTickStart: + type: number + format: float + xTickStep: + type: number + format: float + yColumn: + type: string + generateYAxisTicks: + type: array + items: + type: string + yTotalTicks: + type: integer + yTickStart: + type: number + format: float + yTickStep: + type: number + format: float + shadeBelow: + type: boolean + hoverDimension: + type: string + enum: [auto, x, y, xy] + position: + type: string + enum: [overlaid, stacked] + geom: + $ref: "#/components/schemas/XYGeom" + legendColorizeRows: + type: boolean + legendOpacity: + type: number + format: float + legendOrientationThreshold: + type: integer + XYGeom: + type: string + enum: [line, step, stacked, bar, monotoneX] + BandViewProperties: + type: object + required: + - type + - geom + - queries + - shape + - axes + - colors + - legend + - note + - showNoteWhenEmpty + properties: + timeFormat: + type: string + type: + type: string + enum: [band] + queries: + type: array + items: + $ref: "#/components/schemas/DashboardQuery" + colors: + description: Colors define color encoding of data into a visualization + type: array + items: + $ref: "#/components/schemas/DashboardColor" + shape: + type: string + enum: ["chronograf-v2"] + note: + type: string + showNoteWhenEmpty: + description: If true, will display note when empty + type: boolean + axes: + $ref: "#/components/schemas/Axes" + legend: + $ref: "#/components/schemas/Legend" + xColumn: + type: string + generateXAxisTicks: + type: array + items: + type: string + xTotalTicks: + type: integer + xTickStart: + type: number + format: float + xTickStep: + type: number + format: float + yColumn: + type: string + generateYAxisTicks: + type: array + items: + type: string + yTotalTicks: + type: integer + yTickStart: + type: number + format: float + yTickStep: + type: number + format: float + upperColumn: + type: string + mainColumn: + type: string + lowerColumn: + type: string + hoverDimension: + type: string + enum: [auto, x, y, xy] + geom: + $ref: "#/components/schemas/XYGeom" + legendColorizeRows: + type: boolean + legendOpacity: + type: number + format: float + legendOrientationThreshold: + type: integer + LinePlusSingleStatProperties: + type: object + required: + - type + - queries + - shape + - axes + - colors + - legend + - note + - showNoteWhenEmpty + - prefix + - suffix + - decimalPlaces + - position + properties: + timeFormat: + type: string + type: + type: string + enum: [line-plus-single-stat] + queries: + type: array + items: + $ref: "#/components/schemas/DashboardQuery" + colors: + description: Colors define color encoding of data into a visualization + type: array + items: + $ref: "#/components/schemas/DashboardColor" + shape: + type: string + enum: ["chronograf-v2"] + note: + type: string + showNoteWhenEmpty: + description: If true, will display note when empty + type: boolean + axes: + $ref: "#/components/schemas/Axes" + legend: + $ref: "#/components/schemas/Legend" + xColumn: + type: string + generateXAxisTicks: + type: array + items: + type: string + xTotalTicks: + type: integer + xTickStart: + type: number + format: float + xTickStep: + type: number + format: float + yColumn: + type: string + generateYAxisTicks: + type: array + items: + type: string + yTotalTicks: + type: integer + yTickStart: + type: number + format: float + yTickStep: + type: number + format: float + shadeBelow: + type: boolean + hoverDimension: + type: string + enum: [auto, x, y, xy] + position: + type: string + enum: [overlaid, stacked] + prefix: + type: string + suffix: + type: string + decimalPlaces: + $ref: "#/components/schemas/DecimalPlaces" + legendColorizeRows: + type: boolean + legendOpacity: + type: number + format: float + legendOrientationThreshold: + type: integer + MosaicViewProperties: + type: object + required: + - type + - queries + - colors + - shape + - note + - showNoteWhenEmpty + - xColumn + - ySeriesColumns + - fillColumns + - xDomain + - yDomain + - xAxisLabel + - yAxisLabel + - xPrefix + - yPrefix + - xSuffix + - ySuffix + properties: + timeFormat: + type: string + type: + type: string + enum: [mosaic] + queries: + type: array + items: + $ref: "#/components/schemas/DashboardQuery" + colors: + description: Colors define color encoding of data into a visualization + type: array + items: + type: string + shape: + type: string + enum: ["chronograf-v2"] + note: + type: string + showNoteWhenEmpty: + description: If true, will display note when empty + type: boolean + xColumn: + type: string + generateXAxisTicks: + type: array + items: + type: string + xTotalTicks: + type: integer + xTickStart: + type: number + format: float + xTickStep: + type: number + format: float + yLabelColumnSeparator: + type: string + yLabelColumns: + type: array + items: + type: string + ySeriesColumns: + type: array + items: + type: string + fillColumns: + type: array + items: + type: string + xDomain: + type: array + items: + type: number + maxItems: 2 + yDomain: + type: array + items: + type: number + maxItems: 2 + xAxisLabel: + type: string + yAxisLabel: + type: string + xPrefix: + type: string + xSuffix: + type: string + yPrefix: + type: string + ySuffix: + type: string + hoverDimension: + type: string + enum: [auto, x, y, xy] + legendColorizeRows: + type: boolean + legendOpacity: + type: number + format: float + legendOrientationThreshold: + type: integer + ScatterViewProperties: + type: object + required: + - type + - queries + - colors + - shape + - note + - showNoteWhenEmpty + - xColumn + - yColumn + - fillColumns + - symbolColumns + - xDomain + - yDomain + - xAxisLabel + - yAxisLabel + - xPrefix + - yPrefix + - xSuffix + - ySuffix + properties: + timeFormat: + type: string + type: + type: string + enum: [scatter] + queries: + type: array + items: + $ref: "#/components/schemas/DashboardQuery" + colors: + description: Colors define color encoding of data into a visualization + type: array + items: + type: string + shape: + type: string + enum: ["chronograf-v2"] + note: + type: string + showNoteWhenEmpty: + description: If true, will display note when empty + type: boolean + xColumn: + type: string + generateXAxisTicks: + type: array + items: + type: string + xTotalTicks: + type: integer + xTickStart: + type: number + format: float + xTickStep: + type: number + format: float + yColumn: + type: string + generateYAxisTicks: + type: array + items: + type: string + yTotalTicks: + type: integer + yTickStart: + type: number + format: float + yTickStep: + type: number + format: float + fillColumns: + type: array + items: + type: string + symbolColumns: + type: array + items: + type: string + xDomain: + type: array + items: + type: number + maxItems: 2 + yDomain: + type: array + items: + type: number + maxItems: 2 + xAxisLabel: + type: string + yAxisLabel: + type: string + xPrefix: + type: string + xSuffix: + type: string + yPrefix: + type: string + ySuffix: + type: string + legendColorizeRows: + type: boolean + legendOpacity: + type: number + format: float + legendOrientationThreshold: + type: integer + HeatmapViewProperties: + type: object + required: + - type + - queries + - colors + - shape + - note + - showNoteWhenEmpty + - xColumn + - yColumn + - xDomain + - yDomain + - xAxisLabel + - yAxisLabel + - xPrefix + - yPrefix + - xSuffix + - ySuffix + - binSize + properties: + timeFormat: + type: string + type: + type: string + enum: [heatmap] + queries: + type: array + items: + $ref: "#/components/schemas/DashboardQuery" + colors: + description: Colors define color encoding of data into a visualization + type: array + items: + type: string + shape: + type: string + enum: ["chronograf-v2"] + note: + type: string + showNoteWhenEmpty: + description: If true, will display note when empty + type: boolean + xColumn: + type: string + generateXAxisTicks: + type: array + items: + type: string + xTotalTicks: + type: integer + xTickStart: + type: number + format: float + xTickStep: + type: number + format: float + yColumn: + type: string + generateYAxisTicks: + type: array + items: + type: string + yTotalTicks: + type: integer + yTickStart: + type: number + format: float + yTickStep: + type: number + format: float + xDomain: + type: array + items: + type: number + maxItems: 2 + yDomain: + type: array + items: + type: number + maxItems: 2 + xAxisLabel: + type: string + yAxisLabel: + type: string + xPrefix: + type: string + xSuffix: + type: string + yPrefix: + type: string + ySuffix: + type: string + binSize: + type: number + legendColorizeRows: + type: boolean + legendOpacity: + type: number + format: float + legendOrientationThreshold: + type: integer + SingleStatViewProperties: + type: object + required: + - type + - queries + - colors + - shape + - note + - showNoteWhenEmpty + - prefix + - tickPrefix + - suffix + - tickSuffix + - legend + - decimalPlaces + properties: + type: + type: string + enum: [single-stat] + queries: + type: array + items: + $ref: "#/components/schemas/DashboardQuery" + colors: + description: Colors define color encoding of data into a visualization + type: array + items: + $ref: "#/components/schemas/DashboardColor" + shape: + type: string + enum: ["chronograf-v2"] + note: + type: string + showNoteWhenEmpty: + description: If true, will display note when empty + type: boolean + prefix: + type: string + tickPrefix: + type: string + suffix: + type: string + tickSuffix: + type: string + legend: + $ref: "#/components/schemas/Legend" + decimalPlaces: + $ref: "#/components/schemas/DecimalPlaces" + HistogramViewProperties: + type: object + required: + - type + - queries + - colors + - shape + - note + - showNoteWhenEmpty + - xColumn + - fillColumns + - xDomain + - xAxisLabel + - position + - binCount + properties: + type: + type: string + enum: [histogram] + queries: + type: array + items: + $ref: "#/components/schemas/DashboardQuery" + colors: + description: Colors define color encoding of data into a visualization + type: array + items: + $ref: "#/components/schemas/DashboardColor" + shape: + type: string + enum: ["chronograf-v2"] + note: + type: string + showNoteWhenEmpty: + description: If true, will display note when empty + type: boolean + xColumn: + type: string + fillColumns: + type: array + items: + type: string + xDomain: + type: array + items: + type: number + format: float + xAxisLabel: + type: string + position: + type: string + enum: [overlaid, stacked] + binCount: + type: integer + legendColorizeRows: + type: boolean + legendOpacity: + type: number + format: float + legendOrientationThreshold: + type: integer + GaugeViewProperties: + type: object + required: + [ + type, + queries, + colors, + shape, + note, + showNoteWhenEmpty, + prefix, + tickPrefix, + suffix, + tickSuffix, + legend, + decimalPlaces, + ] + properties: + type: + type: string + enum: [gauge] + queries: + type: array + items: + $ref: "#/components/schemas/DashboardQuery" + colors: + description: Colors define color encoding of data into a visualization + type: array + items: + $ref: "#/components/schemas/DashboardColor" + shape: + type: string + enum: ["chronograf-v2"] + note: + type: string + showNoteWhenEmpty: + description: If true, will display note when empty + type: boolean + prefix: + type: string + tickPrefix: + type: string + suffix: + type: string + tickSuffix: + type: string + legend: + $ref: "#/components/schemas/Legend" + decimalPlaces: + $ref: "#/components/schemas/DecimalPlaces" + TableViewProperties: + type: object + required: + - type + - queries + - colors + - shape + - note + - showNoteWhenEmpty + - tableOptions + - fieldOptions + - timeFormat + - decimalPlaces + properties: + type: + type: string + enum: [table] + queries: + type: array + items: + $ref: "#/components/schemas/DashboardQuery" + colors: + description: Colors define color encoding of data into a visualization + type: array + items: + $ref: "#/components/schemas/DashboardColor" + shape: + type: string + enum: ["chronograf-v2"] + note: + type: string + showNoteWhenEmpty: + description: If true, will display note when empty + type: boolean + tableOptions: + properties: + verticalTimeAxis: + description: >- + verticalTimeAxis describes the orientation of the table by + indicating whether the time axis will be displayed vertically + type: boolean + sortBy: + $ref: "#/components/schemas/RenamableField" + wrapping: + description: Wrapping describes the text wrapping style to be used in table views + type: string + enum: + - truncate + - wrap + - single-line + fixFirstColumn: + description: >- + fixFirstColumn indicates whether the first column of the table + should be locked + type: boolean + fieldOptions: + description: >- + fieldOptions represent the fields retrieved by the query with + customization options + type: array + items: + $ref: "#/components/schemas/RenamableField" + timeFormat: + description: >- + timeFormat describes the display format for time values according to + moment.js date formatting + type: string + decimalPlaces: + $ref: "#/components/schemas/DecimalPlaces" + MarkdownViewProperties: + type: object + required: + - type + - shape + - note + properties: + type: + type: string + enum: [markdown] + shape: + type: string + enum: ["chronograf-v2"] + note: + type: string + CheckViewProperties: + type: object + required: + - type + - shape + - checkID + - queries + - colors + properties: + type: + type: string + enum: [check] + shape: + type: string + enum: ["chronograf-v2"] + checkID: + type: string + check: + $ref: "#/components/schemas/Check" + queries: + type: array + items: + $ref: "#/components/schemas/DashboardQuery" + colors: + description: Colors define color encoding of data into a visualization + type: array + items: + $ref: "#/components/schemas/DashboardColor" + legendColorizeRows: + type: boolean + legendOpacity: + type: number + format: float + legendOrientationThreshold: + type: integer + GeoViewLayer: + type: object + oneOf: + - $ref: "#/components/schemas/GeoCircleViewLayer" + - $ref: "#/components/schemas/GeoHeatMapViewLayer" + - $ref: "#/components/schemas/GeoPointMapViewLayer" + - $ref: "#/components/schemas/GeoTrackMapViewLayer" + GeoViewLayerProperties: + type: object + required: [type] + properties: + type: + type: string + enum: [heatmap, circleMap, pointMap, trackMap] + GeoCircleViewLayer: + allOf: + - $ref: "#/components/schemas/GeoViewLayerProperties" + - type: object + required: [radiusField, radiusDimension, colorField, colorDimension, colors] + properties: + radiusField: + type: string + description: Radius field + radiusDimension: + $ref: '#/components/schemas/Axis' + colorField: + type: string + description: Circle color field + colorDimension: + $ref: '#/components/schemas/Axis' + colors: + description: Colors define color encoding of data into a visualization + type: array + items: + $ref: "#/components/schemas/DashboardColor" + radius: + description: Maximum radius size in pixels + type: integer + interpolateColors: + description: Interpolate circle color based on displayed value + type: boolean + GeoPointMapViewLayer: + allOf: + - $ref: "#/components/schemas/GeoViewLayerProperties" + - type: object + required: [colorField, colorDimension, colors] + properties: + colorField: + type: string + description: Marker color field + colorDimension: + $ref: '#/components/schemas/Axis' + colors: + description: Colors define color encoding of data into a visualization + type: array + items: + $ref: "#/components/schemas/DashboardColor" + isClustered: + description: Cluster close markers together + type: boolean + GeoTrackMapViewLayer: + allOf: + - $ref: "#/components/schemas/GeoViewLayerProperties" + - type: object + required: [trackWidth, speed, randomColors, trackPointVisualization] + properties: + trackWidth: + description: Width of the track + type: integer + speed: + description: Speed of the track animation + type: integer + randomColors: + description: Assign different colors to different tracks + type: boolean + colors: + description: Colors define color encoding of data into a visualization + type: array + items: + $ref: "#/components/schemas/DashboardColor" + GeoHeatMapViewLayer: + allOf: + - $ref: "#/components/schemas/GeoViewLayerProperties" + - type: object + required: [intensityField, intensityDimension, radius, blur, colors] + properties: + intensityField: + type: string + description: Intensity field + intensityDimension: + $ref: '#/components/schemas/Axis' + radius: + description: Radius size in pixels + type: integer + blur: + description: Blur for heatmap points + type: integer + colors: + description: Colors define color encoding of data into a visualization + type: array + items: + $ref: "#/components/schemas/DashboardColor" + GeoViewProperties: + type: object + required: [type, shape, queries, note, showNoteWhenEmpty, center, zoom, allowPanAndZoom, detectCoordinateFields, layers] + properties: + type: + type: string + enum: [geo] + queries: + type: array + items: + $ref: "#/components/schemas/DashboardQuery" + shape: + type: string + enum: ['chronograf-v2'] + center: + description: Coordinates of the center of the map + type: object + required: [lat, lon] + properties: + lat: + description: Latitude of the center of the map + type: number + format: double + lon: + description: Longitude of the center of the map + type: number + format: double + zoom: + description: Zoom level used for initial display of the map + type: number + format: double + minimum: 1 + maximum: 28 + allowPanAndZoom: + description: If true, map zoom and pan controls are enabled on the dashboard view + type: boolean + default: true + detectCoordinateFields: + description: If true, search results get automatically regroupped so that lon,lat and value are treated as columns + type: boolean + default: true + mapStyle: + description: Define map type - regular, satellite etc. + type: string + note: + type: string + showNoteWhenEmpty: + description: If true, will display note when empty + type: boolean + colors: + description: Colors define color encoding of data into a visualization + type: array + items: + $ref: "#/components/schemas/DashboardColor" + layers: + description: List of individual layers shown in the map + type: array + items: + $ref: "#/components/schemas/GeoViewLayer" + Axes: + description: The viewport for a View's visualizations + type: object + required: ["x", "y"] + properties: + x: + $ref: "#/components/schemas/Axis" + "y": # Quoted to prevent YAML parser from interpreting y as shorthand for true. + $ref: "#/components/schemas/Axis" + Legend: + description: Legend define encoding of data into a view's legend + type: object + properties: + type: + description: The style of the legend. + type: string + enum: + - static + orientation: + description: >- + orientation is the location of the legend with respect to the view + graph + type: string + enum: + - top + - bottom + - left + - right + DecimalPlaces: + description: Indicates whether decimal places should be enforced, and how many digits it should show. + type: object + properties: + isEnforced: + description: Indicates whether decimal point setting should be enforced + type: boolean + digits: + description: The number of digits after decimal to display + type: integer + format: int32 + ConstantVariableProperties: + properties: + type: + type: string + enum: [constant] + values: + type: array + items: + type: string + MapVariableProperties: + properties: + type: + type: string + enum: [map] + values: + type: object + additionalProperties: + type: string + QueryVariableProperties: + properties: + type: + type: string + enum: [query] + values: + type: object + properties: + query: + type: string + language: + type: string + Variable: + type: object + required: + - name + - orgID + - arguments + properties: + links: + type: object + readOnly: true + properties: + self: + type: string + format: uri + org: + type: string + format: uri + labels: + type: string + format: uri + id: + readOnly: true + type: string + orgID: + type: string + name: + type: string + description: + type: string + selected: + type: array + items: + type: string + labels: + $ref: "#/components/schemas/Labels" + arguments: + $ref: "#/components/schemas/VariableProperties" + createdAt: + type: string + format: date-time + updatedAt: + type: string + format: date-time + Variables: + type: object + example: + variables: + - id: "1221432" + name: ":ok:" + selected: + - hello + arguments: + type: constant + values: + - howdy + - hello + - hi + - yo + - oy + - id: "1221432" + name: ":ok:" + selected: + - c + arguments: + type: map + values: + a: fdjaklfdjkldsfjlkjdsa + b: dfaksjfkljekfajekdljfas + c: fdjksajfdkfeawfeea + - id: "1221432" + name: ":ok:" + selected: + - host + arguments: + type: query + query: 'from(bucket: "foo") |> showMeasurements()' + language: flux + properties: + variables: + type: array + items: + $ref: "#/components/schemas/Variable" + VariableProperties: + type: object + oneOf: + - $ref: "#/components/schemas/QueryVariableProperties" + - $ref: "#/components/schemas/ConstantVariableProperties" + - $ref: "#/components/schemas/MapVariableProperties" + ViewProperties: + oneOf: + - $ref: "#/components/schemas/LinePlusSingleStatProperties" + - $ref: "#/components/schemas/XYViewProperties" + - $ref: "#/components/schemas/SingleStatViewProperties" + - $ref: "#/components/schemas/HistogramViewProperties" + - $ref: "#/components/schemas/GaugeViewProperties" + - $ref: "#/components/schemas/TableViewProperties" + - $ref: "#/components/schemas/MarkdownViewProperties" + - $ref: "#/components/schemas/CheckViewProperties" + - $ref: "#/components/schemas/ScatterViewProperties" + - $ref: "#/components/schemas/HeatmapViewProperties" + - $ref: "#/components/schemas/MosaicViewProperties" + - $ref: "#/components/schemas/BandViewProperties" + - $ref: "#/components/schemas/GeoViewProperties" + View: + required: + - name + - properties + properties: + links: + type: object + readOnly: true + properties: + self: + type: string + id: + readOnly: true + type: string + name: + type: string + properties: + $ref: "#/components/schemas/ViewProperties" + Views: + type: object + properties: + links: + type: object + properties: + self: + type: string + views: + type: array + items: + $ref: "#/components/schemas/View" + CellUpdate: + type: object + properties: + x: + type: integer + format: int32 + "y": # Quoted to prevent YAML parser from interpreting y as shorthand for true. + type: integer + format: int32 + w: + type: integer + format: int32 + h: + type: integer + format: int32 + CreateCell: + type: object + properties: + name: + type: string + x: + type: integer + format: int32 + "y": # Quoted to prevent YAML parser from interpreting y as shorthand for true. + type: integer + format: int32 + w: + type: integer + format: int32 + h: + type: integer + format: int32 + usingView: + type: string + description: Makes a copy of the provided view. + AnalyzeQueryResponse: + type: object + properties: + errors: + type: array + items: + type: object + properties: + line: + type: integer + column: + type: integer + character: + type: integer + message: + type: string + CellWithViewProperties: + type: object + allOf: + - $ref: "#/components/schemas/Cell" + - type: object + properties: + name: + type: string + properties: + $ref: "#/components/schemas/ViewProperties" + Cell: + type: object + properties: + id: + type: string + links: + type: object + properties: + self: + type: string + view: + type: string + x: + type: integer + format: int32 + "y": # Quoted to prevent YAML parser from interpreting y as shorthand for true. + type: integer + format: int32 + w: + type: integer + format: int32 + h: + type: integer + format: int32 + viewID: + type: string + description: The reference to a view from the views API. + CellsWithViewProperties: + type: array + items: + $ref: "#/components/schemas/CellWithViewProperties" + Cells: + type: array + items: + $ref: "#/components/schemas/Cell" + Secrets: + additionalProperties: + type: string + example: + apikey: abc123xyz + SecretKeys: + type: object + properties: + secrets: + type: array + items: + type: string + SecretKeysResponse: + allOf: + - $ref: "#/components/schemas/SecretKeys" + - type: object + properties: + links: + readOnly: true + type: object + properties: + self: + type: string + org: + type: string + CreateDashboardRequest: + properties: + orgID: + type: string + description: The ID of the organization that owns the dashboard. + name: + type: string + description: The user-facing name of the dashboard. + description: + type: string + description: The user-facing description of the dashboard. + required: + - orgID + - name + DashboardWithViewProperties: + type: object + allOf: + - $ref: "#/components/schemas/CreateDashboardRequest" + - type: object + properties: + links: + type: object + example: + self: "/api/v2/dashboards/1" + cells: "/api/v2/dashboards/1/cells" + owners: "/api/v2/dashboards/1/owners" + members: "/api/v2/dashboards/1/members" + labels: "/api/v2/dashboards/1/labels" + org: "/api/v2/labels/1" + properties: + self: + $ref: "#/components/schemas/Link" + cells: + $ref: "#/components/schemas/Link" + members: + $ref: "#/components/schemas/Link" + owners: + $ref: "#/components/schemas/Link" + labels: + $ref: "#/components/schemas/Link" + org: + $ref: "#/components/schemas/Link" + id: + readOnly: true + type: string + meta: + type: object + properties: + createdAt: + type: string + format: date-time + updatedAt: + type: string + format: date-time + cells: + $ref: "#/components/schemas/CellsWithViewProperties" + labels: + $ref: "#/components/schemas/Labels" + Dashboard: + type: object + allOf: + - $ref: "#/components/schemas/CreateDashboardRequest" + - type: object + properties: + links: + type: object + example: + self: "/api/v2/dashboards/1" + cells: "/api/v2/dashboards/1/cells" + owners: "/api/v2/dashboards/1/owners" + members: "/api/v2/dashboards/1/members" + labels: "/api/v2/dashboards/1/labels" + org: "/api/v2/labels/1" + properties: + self: + $ref: "#/components/schemas/Link" + cells: + $ref: "#/components/schemas/Link" + members: + $ref: "#/components/schemas/Link" + owners: + $ref: "#/components/schemas/Link" + labels: + $ref: "#/components/schemas/Link" + org: + $ref: "#/components/schemas/Link" + id: + readOnly: true + type: string + meta: + type: object + properties: + createdAt: + type: string + format: date-time + updatedAt: + type: string + format: date-time + cells: + $ref: "#/components/schemas/Cells" + labels: + $ref: "#/components/schemas/Labels" + Dashboards: + type: object + properties: + links: + $ref: "#/components/schemas/Links" + dashboards: + type: array + items: + $ref: "#/components/schemas/Dashboard" + Source: + type: object + properties: + links: + type: object + properties: + self: + type: string + query: + type: string + health: + type: string + buckets: + type: string + id: + type: string + orgID: + type: string + default: + type: boolean + name: + type: string + type: + type: string + enum: ["v1", "v2", "self"] + url: + type: string + format: uri + insecureSkipVerify: + type: boolean + telegraf: + type: string + token: + type: string + username: + type: string + password: + type: string + sharedSecret: + type: string + metaUrl: + type: string + format: uri + defaultRP: + type: string + languages: + type: array + readOnly: true + items: + type: string + enum: + - flux + - influxql + Sources: + type: object + properties: + links: + type: object + properties: + self: + type: string + format: uri + sources: + type: array + items: + $ref: "#/components/schemas/Source" + ScraperTargetRequest: + type: object + properties: + name: + type: string + description: The name of the scraper target. + type: + type: string + description: The type of the metrics to be parsed. + enum: [prometheus] + url: + type: string + description: The URL of the metrics endpoint. + example: http://localhost:9090/metrics + orgID: + type: string + description: The organization ID. + bucketID: + type: string + description: The ID of the bucket to write to. + allowInsecure: + type: boolean + description: Skip TLS verification on endpoint. + default: false + ScraperTargetResponse: + type: object + allOf: + - $ref: "#/components/schemas/ScraperTargetRequest" + - type: object + properties: + id: + type: string + readOnly: true + org: + type: string + description: The organization name. + bucket: + type: string + description: The bucket name. + links: + type: object + readOnly: true + example: + self: "/api/v2/scrapers/1" + owners: "/api/v2/scrapers/1/owners" + members: "/api/v2/scrapers/1/members" + bucket: "/api/v2/buckets/1" + organization: "/api/v2/orgs/1" + properties: + self: + $ref: "#/components/schemas/Link" + members: + $ref: "#/components/schemas/Link" + owners: + $ref: "#/components/schemas/Link" + bucket: + $ref: "#/components/schemas/Link" + organization: + $ref: "#/components/schemas/Link" + ScraperTargetResponses: + type: object + properties: + configurations: + type: array + items: + $ref: "#/components/schemas/ScraperTargetResponse" + DocumentMeta: + type: object + properties: + name: + type: string + type: + type: string + templateID: + type: string + description: + type: string + version: + type: string + createdAt: + type: string + format: date-time + readOnly: true + updatedAt: + type: string + format: date-time + readOnly: true + required: + - name + - version + Document: + type: object + properties: + id: + type: string + readOnly: true + meta: + $ref: "#/components/schemas/DocumentMeta" + content: + type: object + labels: + $ref: "#/components/schemas/Labels" + links: + type: object + readOnly: true + example: + self: "/api/v2/documents/templates/1" + properties: + self: + description: The document URL. + $ref: "#/components/schemas/Link" + required: + - id + - meta + - content + DocumentCreate: + type: object + properties: + meta: + $ref: "#/components/schemas/DocumentMeta" + content: + type: object + org: + type: string + description: The organization Name. Specify either `orgID` or `org`. + orgID: + type: string + description: The organization Name. Specify either `orgID` or `org`. + labels: + type: array + description: An array of label IDs to be added as labels to the document. + items: + type: string + required: + - meta + - content + DocumentUpdate: + type: object + properties: + meta: + $ref: "#/components/schemas/DocumentMeta" + content: + type: object + DocumentListEntry: + type: object + properties: + id: + type: string + readOnly: true + meta: + $ref: "#/components/schemas/DocumentMeta" + labels: + $ref: "#/components/schemas/Labels" + links: + type: object + readOnly: true + example: + self: "/api/v2/documents/templates/1" + properties: + self: + description: The document URL. + $ref: "#/components/schemas/Link" + required: + - id + - meta + Documents: + type: object + properties: + documents: + type: array + items: + $ref: "#/components/schemas/DocumentListEntry" + TelegrafRequest: + type: object + properties: + name: + type: string + description: + type: string + metadata: + type: object + properties: + buckets: + type: array + items: + type: string + config: + type: string + orgID: + type: string + TelegrafRequestPlugin: + oneOf: + - $ref: "#/components/schemas/TelegrafPluginInputCpu" + - $ref: "#/components/schemas/TelegrafPluginInputDisk" + - $ref: "#/components/schemas/TelegrafPluginInputDiskio" + - $ref: "#/components/schemas/TelegrafPluginInputDocker" + - $ref: "#/components/schemas/TelegrafPluginInputFile" + - $ref: "#/components/schemas/TelegrafPluginInputKubernetes" + - $ref: "#/components/schemas/TelegrafPluginInputLogParser" + - $ref: "#/components/schemas/TelegrafPluginInputProcstat" + - $ref: "#/components/schemas/TelegrafPluginInputPrometheus" + - $ref: "#/components/schemas/TelegrafPluginInputRedis" + - $ref: "#/components/schemas/TelegrafPluginInputSyslog" + - $ref: "#/components/schemas/TelegrafPluginOutputFile" + - $ref: "#/components/schemas/TelegrafPluginOutputInfluxDBV2" + TelegrafPluginInputCpu: + type: object + required: + - name + - type + properties: + name: + type: string + enum: ["cpu"] + type: + type: string + enum: ["input"] + comment: + type: string + TelegrafPluginInputDisk: + type: object + required: + - name + - type + properties: + name: + type: string + enum: ["disk"] + type: + type: string + enum: ["input"] + comment: + type: string + TelegrafPluginInputDiskio: + type: object + required: + - name + - type + properties: + name: + type: string + enum: ["diskio"] + type: + type: string + enum: ["input"] + comment: + type: string + TelegrafPluginInputDocker: + type: object + required: + - name + - type + - config + properties: + name: + type: string + enum: ["docker"] + type: + type: string + enum: ["input"] + comment: + type: string + config: + $ref: "#/components/schemas/TelegrafPluginInputDockerConfig" + TelegrafPluginInputFile: + type: object + required: + - name + - type + - config + properties: + name: + type: string + enum: ["file"] + type: + type: string + enum: [input] + comment: + type: string + config: + $ref: "#/components/schemas/TelegrafPluginInputFileConfig" + TelegrafPluginInputKernel: + type: object + required: + - name + - type + properties: + name: + type: string + enum: ["kernel"] + type: + type: string + enum: ["input"] + comment: + type: string + TelegrafPluginInputKubernetes: + type: object + required: + - name + - type + - config + properties: + name: + type: string + enum: ["kubernetes"] + type: + type: string + enum: ["input"] + comment: + type: string + config: + $ref: "#/components/schemas/TelegrafPluginInputKubernetesConfig" + TelegrafPluginInputLogParser: + type: object + required: + - name + - type + - config + properties: + name: + type: string + enum: ["logparser"] + type: + type: string + enum: ["input"] + comment: + type: string + config: + $ref: "#/components/schemas/TelegrafPluginInputLogParserConfig" + TelegrafPluginInputMem: + type: object + required: + - name + - type + properties: + name: + type: string + enum: ["mem"] + type: + type: string + enum: ["input"] + comment: + type: string + TelegrafPluginInputNetResponse: + type: object + required: + - name + - type + properties: + name: + type: string + enum: ["net_response"] + type: + type: string + enum: ["input"] + comment: + type: string + TelegrafPluginInputNet: + type: object + required: + - name + - type + properties: + name: + type: string + enum: ["net"] + type: + type: string + enum: ["input"] + comment: + type: string + TelegrafPluginInputNginx: + type: object + required: + - name + - type + properties: + name: + type: string + enum: ["nginx"] + type: + type: string + enum: ["input"] + comment: + type: string + TelegrafPluginInputProcesses: + type: object + required: + - name + - type + properties: + name: + type: string + enum: ["processes"] + type: + type: string + enum: ["input"] + comment: + type: string + TelegrafPluginInputProcstat: + type: object + required: + - name + - type + - config + properties: + name: + type: string + enum: ["procstat"] + type: + type: string + enum: ["input"] + comment: + type: string + config: + $ref: "#/components/schemas/TelegrafPluginInputProcstatConfig" + TelegrafPluginInputPrometheus: + type: object + required: + - name + - type + - config + properties: + name: + type: string + enum: ["prometheus"] + type: + type: string + enum: ["input"] + comment: + type: string + config: + $ref: "#/components/schemas/TelegrafPluginInputPrometheusConfig" + TelegrafPluginInputRedis: + type: object + required: + - name + - type + - config + properties: + name: + type: string + enum: ["redis"] + type: + type: string + enum: ["input"] + comment: + type: string + config: + $ref: "#/components/schemas/TelegrafPluginInputRedisConfig" + TelegrafPluginInputSyslog: + type: object + required: + - name + - type + - config + properties: + name: + type: string + enum: ["syslog"] + type: + type: string + enum: ["input"] + comment: + type: string + config: + $ref: "#/components/schemas/TelegrafPluginInputSyslogConfig" + TelegrafPluginInputSwap: + type: object + required: + - name + - type + properties: + name: + type: string + enum: ["swap"] + type: + type: string + enum: ["input"] + comment: + type: string + TelegrafPluginInputSystem: + type: object + required: + - name + - type + properties: + name: + type: string + enum: ["system"] + type: + type: string + enum: ["input"] + comment: + type: string + TelegrafPluginInputTail: + type: object + required: + - name + - type + properties: + name: + type: string + enum: ["tail"] + type: + type: string + enum: ["input"] + comment: + type: string + TelegrafPluginOutputFile: + type: object + required: + - name + - type + - config + properties: + name: + type: string + enum: ["file"] + type: + type: string + enum: ["output"] + comment: + type: string + config: + $ref: "#/components/schemas/TelegrafPluginOutputFileConfig" + TelegrafPluginOutputInfluxDBV2: + type: object + required: + - name + - type + - config + properties: + name: + type: string + enum: ["influxdb_v2"] + type: + type: string + enum: ["output"] + comment: + type: string + config: + $ref: "#/components/schemas/TelegrafPluginOutputInfluxDBV2Config" + Telegraf: + type: object + allOf: + - $ref: "#/components/schemas/TelegrafRequest" + - type: object + properties: + id: + type: string + readOnly: true + links: + type: object + readOnly: true + example: + self: "/api/v2/telegrafs/1" + lables: "/api/v2/telegrafs/1/labels" + owners: "/api/v2/telegrafs/1/owners" + members: "/api/v2/telegrafs/1/members" + properties: + self: + $ref: "#/components/schemas/Link" + labels: + $ref: "#/components/schemas/Link" + members: + $ref: "#/components/schemas/Link" + owners: + $ref: "#/components/schemas/Link" + labels: + readOnly: true + $ref: "#/components/schemas/Labels" + Telegrafs: + type: object + properties: + configurations: + type: array + items: + $ref: "#/components/schemas/Telegraf" + TelegrafPlugin: + type: object + properties: + type: + type: string + name: + type: string + description: + type: string + config: + type: string + TelegrafPlugins: + type: object + properties: + version: + type: string + os: + type: string + plugins: + type: array + items: + $ref: "#/components/schemas/TelegrafPlugin" + TelegrafPluginInputDockerConfig: + type: object + required: + - endpoint + properties: + endpoint: + type: string + TelegrafPluginInputFileConfig: + type: object + properties: + files: + type: array + items: + type: string + TelegrafPluginInputKubernetesConfig: + type: object + properties: + url: + type: string + format: uri + TelegrafPluginInputLogParserConfig: + type: object + properties: + files: + type: array + items: + type: string + TelegrafPluginInputProcstatConfig: + type: object + properties: + exe: + type: string + TelegrafPluginInputPrometheusConfig: + type: object + properties: + urls: + type: array + items: + type: string + format: uri + TelegrafPluginInputRedisConfig: + type: object + properties: + servers: + type: array + items: + type: string + password: + type: string + TelegrafPluginInputSyslogConfig: + type: object + properties: + server: + type: string + TelegrafPluginOutputFileConfig: + type: object + required: + - files + properties: + files: + type: array + items: + type: object + properties: + type: + type: string + enum: [stdout, path] + path: + type: string + TelegrafPluginOutputInfluxDBV2Config: + type: object + required: + - urls + - token + - organization + - bucket + properties: + urls: + type: array + items: + type: string + format: uri + token: + type: string + organization: + type: string + bucket: + type: string + IsOnboarding: + type: object + properties: + allowed: + description: True means that the influxdb instance has NOT had initial setup; false means that the database has been setup. + type: boolean + OnboardingRequest: + type: object + properties: + username: + type: string + password: + type: string + org: + type: string + bucket: + type: string + retentionPeriodSeconds: + type: integer + retentionPeriodHrs: + type: integer + deprecated: true + description: > + Retention period *in nanoseconds* for the new bucket. This key's name has been misleading since OSS 2.0 GA, + please transition to use `retentionPeriodSeconds` + required: + - username + - org + - bucket + OnboardingResponse: + type: object + properties: + user: + $ref: "#/components/schemas/User" + org: + $ref: "#/components/schemas/Organization" + bucket: + $ref: "#/components/schemas/Bucket" + auth: + $ref: "#/components/schemas/Authorization" + PasswordResetBody: + properties: + password: + type: string + required: + - password + AddResourceMemberRequestBody: + type: object + properties: + id: + type: string + name: + type: string + required: + - id + Ready: + type: object + properties: + status: + type: string + enum: + - ready + started: + type: string + format: date-time + example: "2019-03-13T10:09:33.891196-04:00" + up: + type: string + example: "14m45.911966424s" + HealthCheck: + type: object + required: + - name + - status + properties: + name: + type: string + message: + type: string + checks: + type: array + items: + $ref: "#/components/schemas/HealthCheck" + status: + type: string + enum: + - pass + - fail + version: + type: string + commit: + type: string + Labels: + type: array + items: + $ref: "#/components/schemas/Label" + Label: + type: object + properties: + id: + readOnly: true + type: string + orgID: + readOnly: true + type: string + name: + type: string + properties: + type: object + additionalProperties: + type: string + description: Key/Value pairs associated with this label. Keys can be removed by sending an update with an empty value. + example: { "color": "ffb3b3", "description": "this is a description" } + LabelCreateRequest: + type: object + required: [orgID, name] + properties: + orgID: + type: string + name: + type: string + properties: + type: object + additionalProperties: + type: string + description: Key/Value pairs associated with this label. Keys can be removed by sending an update with an empty value. + example: { "color": "ffb3b3", "description": "this is a description" } + LabelUpdate: + type: object + properties: + name: + type: string + properties: + type: object + additionalProperties: + type: string + description: Key/Value pairs associated with this label. Keys can be removed by sending an update with an empty value. + example: { "color": "ffb3b3", "description": "this is a description" } + LabelMapping: + type: object + properties: + labelID: + type: string + LabelsResponse: + type: object + properties: + labels: + $ref: "#/components/schemas/Labels" + links: + $ref: "#/components/schemas/Links" + LabelResponse: + type: object + properties: + label: + $ref: "#/components/schemas/Label" + links: + $ref: "#/components/schemas/Links" + ASTResponse: + description: Contains the AST for the supplied Flux query + type: object + properties: + ast: + $ref: "#/components/schemas/Package" + WritePrecision: + type: string + enum: + - ms + - s + - us + - ns + TaskCreateRequest: + type: object + properties: + orgID: + description: The ID of the organization that owns this Task. + type: string + org: + description: The name of the organization that owns this Task. + type: string + status: + $ref: "#/components/schemas/TaskStatusType" + flux: + description: The Flux script to run for this task. + type: string + description: + description: An optional description of the task. + type: string + required: [flux] + TaskUpdateRequest: + type: object + properties: + status: + $ref: "#/components/schemas/TaskStatusType" + flux: + description: The Flux script to run for this task. + type: string + name: + description: Override the 'name' option in the flux script. + type: string + every: + description: Override the 'every' option in the flux script. + type: string + cron: + description: Override the 'cron' option in the flux script. + type: string + offset: + description: Override the 'offset' option in the flux script. + type: string + description: + description: An optional description of the task. + type: string + FluxResponse: + description: Rendered flux that backs the check or notification. + properties: + flux: + type: string + CheckPatch: + type: object + properties: + name: + type: string + description: + type: string + status: + type: string + enum: + - active + - inactive + CheckDiscriminator: + oneOf: + - $ref: "#/components/schemas/DeadmanCheck" + - $ref: "#/components/schemas/ThresholdCheck" + - $ref: "#/components/schemas/CustomCheck" + discriminator: + propertyName: type + mapping: + deadman: "#/components/schemas/DeadmanCheck" + threshold: "#/components/schemas/ThresholdCheck" + custom: "#/components/schemas/CustomCheck" + Check: + allOf: + - $ref: "#/components/schemas/CheckDiscriminator" + PostCheck: + allOf: + - $ref: "#/components/schemas/CheckDiscriminator" + Checks: + properties: + checks: + type: array + items: + $ref: "#/components/schemas/Check" + links: + $ref: "#/components/schemas/Links" + CheckBase: + properties: + id: + readOnly: true + type: string + name: + type: string + orgID: + description: The ID of the organization that owns this check. + type: string + ownerID: + description: The ID of creator used to create this check. + type: string + readOnly: true + createdAt: + type: string + format: date-time + readOnly: true + updatedAt: + type: string + format: date-time + readOnly: true + query: + $ref: "#/components/schemas/DashboardQuery" + status: + $ref: "#/components/schemas/TaskStatusType" + description: + description: An optional description of the check. + type: string + latestCompleted: + description: Timestamp of latest scheduled, completed run, RFC3339. + type: string + format: date-time + readOnly: true + lastRunStatus: + readOnly: true + type: string + enum: + - failed + - success + - canceled + lastRunError: + readOnly: true + type: string + labels: + $ref: "#/components/schemas/Labels" + links: + type: object + readOnly: true + example: + self: "/api/v2/checks/1" + labels: "/api/v2/checks/1/labels" + members: "/api/v2/checks/1/members" + owners: "/api/v2/checks/1/owners" + query: "/api/v2/checks/1/query" + properties: + self: + description: URL for this check + $ref: "#/components/schemas/Link" + labels: + description: URL to retrieve labels for this check + $ref: "#/components/schemas/Link" + members: + description: URL to retrieve members for this check + $ref: "#/components/schemas/Link" + owners: + description: URL to retrieve owners for this check + $ref: "#/components/schemas/Link" + query: + description: URL to retrieve flux script for this check + $ref: "#/components/schemas/Link" + required: [name, orgID, query] + ThresholdCheck: + allOf: + - $ref: "#/components/schemas/CheckBase" + - type: object + required: [type] + properties: + type: + type: string + enum: [threshold] + thresholds: + type: array + items: + $ref: "#/components/schemas/Threshold" + every: + description: Check repetition interval. + type: string + offset: + description: Duration to delay after the schedule, before executing check. + type: string + tags: + description: List of tags to write to each status. + type: array + items: + type: object + properties: + key: + type: string + value: + type: string + statusMessageTemplate: + description: The template used to generate and write a status message. + type: string + Threshold: + oneOf: + - $ref: "#/components/schemas/GreaterThreshold" + - $ref: "#/components/schemas/LesserThreshold" + - $ref: "#/components/schemas/RangeThreshold" + discriminator: + propertyName: type + mapping: + greater: "#/components/schemas/GreaterThreshold" + lesser: "#/components/schemas/LesserThreshold" + range: "#/components/schemas/RangeThreshold" + DeadmanCheck: + allOf: + - $ref: "#/components/schemas/CheckBase" + - type: object + required: [type] + properties: + type: + type: string + enum: [deadman] + timeSince: + description: String duration before deadman triggers. + type: string + staleTime: + description: String duration for time that a series is considered stale and should not trigger deadman. + type: string + reportZero: + description: If only zero values reported since time, trigger an alert + type: boolean + level: + $ref: "#/components/schemas/CheckStatusLevel" + every: + description: Check repetition interval. + type: string + offset: + description: Duration to delay after the schedule, before executing check. + type: string + tags: + description: List of tags to write to each status. + type: array + items: + type: object + properties: + key: + type: string + value: + type: string + statusMessageTemplate: + description: The template used to generate and write a status message. + type: string + CustomCheck: + allOf: + - $ref: "#/components/schemas/CheckBase" + - type: object + properties: + type: + type: string + enum: [custom] + required: [type] + ThresholdBase: + properties: + level: + $ref: "#/components/schemas/CheckStatusLevel" + allValues: + description: If true, only alert if all values meet threshold. + type: boolean + GreaterThreshold: + allOf: + - $ref: "#/components/schemas/ThresholdBase" + - type: object + required: [type, value] + properties: + type: + type: string + enum: [greater] + value: + type: number + format: float + LesserThreshold: + allOf: + - $ref: "#/components/schemas/ThresholdBase" + - type: object + required: [type, value] + properties: + type: + type: string + enum: [lesser] + value: + type: number + format: float + RangeThreshold: + allOf: + - $ref: "#/components/schemas/ThresholdBase" + - type: object + required: [type, min, max, within] + properties: + type: + type: string + enum: [range] + min: + type: number + format: float + max: + type: number + format: float + within: + type: boolean + CheckStatusLevel: + description: The state to record if check matches a criteria. + type: string + enum: ["UNKNOWN", "OK", "INFO", "CRIT", "WARN"] + RuleStatusLevel: + description: The state to record if check matches a criteria. + type: string + enum: ["UNKNOWN", "OK", "INFO", "CRIT", "WARN", "ANY"] + NotificationRuleUpdate: + type: object + properties: + name: + type: string + description: + type: string + status: + type: string + enum: + - active + - inactive + NotificationRuleDiscriminator: + oneOf: + - $ref: "#/components/schemas/SlackNotificationRule" + - $ref: "#/components/schemas/SMTPNotificationRule" + - $ref: "#/components/schemas/PagerDutyNotificationRule" + - $ref: "#/components/schemas/HTTPNotificationRule" + - $ref: "#/components/schemas/TelegramNotificationRule" + discriminator: + propertyName: type + mapping: + slack: "#/components/schemas/SlackNotificationRule" + smtp: "#/components/schemas/SMTPNotificationRule" + pagerduty: "#/components/schemas/PagerDutyNotificationRule" + http: "#/components/schemas/HTTPNotificationRule" + telegram: "#/components/schemas/TelegramNotificationRule" + NotificationRule: + allOf: + - $ref: "#/components/schemas/NotificationRuleDiscriminator" + PostNotificationRule: + allOf: + - $ref: "#/components/schemas/NotificationRuleDiscriminator" + NotificationRules: + properties: + notificationRules: + type: array + items: + $ref: "#/components/schemas/NotificationRule" + links: + $ref: "#/components/schemas/Links" + NotificationRuleBase: + type: object + required: + - id + - orgID + - status + - name + - tagRules + - statusRules + - endpointID + properties: + latestCompleted: + description: Timestamp of latest scheduled, completed run, RFC3339. + type: string + format: date-time + readOnly: true + lastRunStatus: + readOnly: true + type: string + enum: + - failed + - success + - canceled + lastRunError: + readOnly: true + type: string + id: + readOnly: true + type: string + endpointID: + type: string + orgID: + description: The ID of the organization that owns this notification rule. + type: string + ownerID: + description: The ID of creator used to create this notification rule. + type: string + readOnly: true + createdAt: + type: string + format: date-time + readOnly: true + updatedAt: + type: string + format: date-time + readOnly: true + status: + $ref: "#/components/schemas/TaskStatusType" + name: + description: Human-readable name describing the notification rule. + type: string + sleepUntil: + type: string + every: + description: The notification repetition interval. + type: string + offset: + description: Duration to delay after the schedule, before executing check. + type: string + runbookLink: + type: string + limitEvery: + description: Don't notify me more than times every seconds. If set, limit cannot be empty. + type: integer + limit: + description: Don't notify me more than times every seconds. If set, limitEvery cannot be empty. + type: integer + tagRules: + description: List of tag rules the notification rule attempts to match. + type: array + items: + $ref: "#/components/schemas/TagRule" + description: + description: An optional description of the notification rule. + type: string + statusRules: + description: List of status rules the notification rule attempts to match. + type: array + minItems: 1 + items: + $ref: "#/components/schemas/StatusRule" + labels: + $ref: "#/components/schemas/Labels" + links: + type: object + readOnly: true + example: + self: "/api/v2/notificationRules/1" + labels: "/api/v2/notificationRules/1/labels" + members: "/api/v2/notificationRules/1/members" + owners: "/api/v2/notificationRules/1/owners" + query: "/api/v2/notificationRules/1/query" + properties: + self: + description: URL for this endpoint. + $ref: "#/components/schemas/Link" + labels: + description: URL to retrieve labels for this notification rule. + $ref: "#/components/schemas/Link" + members: + description: URL to retrieve members for this notification rule. + $ref: "#/components/schemas/Link" + owners: + description: URL to retrieve owners for this notification rule. + $ref: "#/components/schemas/Link" + query: + description: URL to retrieve flux script for this notification rule. + $ref: "#/components/schemas/Link" + TagRule: + type: object + properties: + key: + type: string + value: + type: string + operator: + type: string + enum: ["equal", "notequal", "equalregex", "notequalregex"] + StatusRule: + type: object + properties: + currentLevel: + $ref: "#/components/schemas/RuleStatusLevel" + previousLevel: + $ref: "#/components/schemas/RuleStatusLevel" + count: + type: integer + period: + type: string + HTTPNotificationRuleBase: + type: object + required: [type] + properties: + type: + type: string + enum: [http] + url: + type: string + HTTPNotificationRule: + allOf: + - $ref: "#/components/schemas/NotificationRuleBase" + - $ref: "#/components/schemas/HTTPNotificationRuleBase" + SlackNotificationRuleBase: + type: object + required: [type, messageTemplate] + properties: + type: + type: string + enum: [slack] + channel: + type: string + messageTemplate: + type: string + SlackNotificationRule: + allOf: + - $ref: "#/components/schemas/NotificationRuleBase" + - $ref: "#/components/schemas/SlackNotificationRuleBase" + SMTPNotificationRule: + allOf: + - $ref: "#/components/schemas/NotificationRuleBase" + - $ref: "#/components/schemas/SMTPNotificationRuleBase" + SMTPNotificationRuleBase: + type: object + required: [type, subjectTemplate, to] + properties: + type: + type: string + enum: [smtp] + subjectTemplate: + type: string + bodyTemplate: + type: string + to: + type: string + PagerDutyNotificationRule: + allOf: + - $ref: "#/components/schemas/NotificationRuleBase" + - $ref: "#/components/schemas/PagerDutyNotificationRuleBase" + PagerDutyNotificationRuleBase: + type: object + required: [type, messageTemplate] + properties: + type: + type: string + enum: [pagerduty] + messageTemplate: + type: string + TelegramNotificationRule: + allOf: + - $ref: "#/components/schemas/NotificationRuleBase" + - $ref: "#/components/schemas/TelegramNotificationRuleBase" + TelegramNotificationRuleBase: + type: object + required: [type, messageTemplate, channel] + properties: + type: + description: The discriminator between other types of notification rules is "telegram". + type: string + enum: [telegram] + messageTemplate: + description: The message template as a flux interpolated string. + type: string + parseMode: + description: Parse mode of the message text per https://core.telegram.org/bots/api#formatting-options . Defaults to "MarkdownV2" . + type: string + enum: + - MarkdownV2 + - HTML + - Markdown + disableWebPagePreview: + description: Disables preview of web links in the sent messages when "true". Defaults to "false" . + type: boolean + NotificationEndpointUpdate: + type: object + + properties: + name: + type: string + description: + type: string + status: + type: string + enum: + - active + - inactive + NotificationEndpointDiscrimator: + oneOf: + - $ref: "#/components/schemas/SlackNotificationEndpoint" + - $ref: "#/components/schemas/PagerDutyNotificationEndpoint" + - $ref: "#/components/schemas/HTTPNotificationEndpoint" + - $ref: "#/components/schemas/TelegramNotificationEndpoint" + discriminator: + propertyName: type + mapping: + slack: "#/components/schemas/SlackNotificationEndpoint" + pagerduty: "#/components/schemas/PagerDutyNotificationEndpoint" + http: "#/components/schemas/HTTPNotificationEndpoint" + telegram: "#/components/schemas/TelegramNotificationEndpoint" + NotificationEndpoint: + allOf: + - $ref: "#/components/schemas/NotificationEndpointDiscrimator" + PostNotificationEndpoint: + allOf: + - $ref: "#/components/schemas/NotificationEndpointDiscrimator" + NotificationEndpoints: + properties: + notificationEndpoints: + type: array + items: + $ref: "#/components/schemas/NotificationEndpoint" + links: + $ref: "#/components/schemas/Links" + NotificationEndpointBase: + type: object + required: [type, name] + properties: + id: + type: string + orgID: + type: string + userID: + type: string + createdAt: + type: string + format: date-time + readOnly: true + updatedAt: + type: string + format: date-time + readOnly: true + description: + description: An optional description of the notification endpoint. + type: string + name: + type: string + status: + description: The status of the endpoint. + default: active + type: string + enum: ["active", "inactive"] + labels: + $ref: "#/components/schemas/Labels" + links: + type: object + readOnly: true + example: + self: "/api/v2/notificationEndpoints/1" + labels: "/api/v2/notificationEndpoints/1/labels" + members: "/api/v2/notificationEndpoints/1/members" + owners: "/api/v2/notificationEndpoints/1/owners" + properties: + self: + description: URL for this endpoint. + $ref: "#/components/schemas/Link" + labels: + description: URL to retrieve labels for this endpoint. + $ref: "#/components/schemas/Link" + members: + description: URL to retrieve members for this endpoint. + $ref: "#/components/schemas/Link" + owners: + description: URL to retrieve owners for this endpoint. + $ref: "#/components/schemas/Link" + type: + $ref: "#/components/schemas/NotificationEndpointType" + SlackNotificationEndpoint: + type: object + allOf: + - $ref: "#/components/schemas/NotificationEndpointBase" + - type: object + properties: + url: + description: Specifies the URL of the Slack endpoint. Specify either `URL` or `Token`. + type: string + token: + description: Specifies the API token string. Specify either `URL` or `Token`. + type: string + PagerDutyNotificationEndpoint: + type: object + allOf: + - $ref: "#/components/schemas/NotificationEndpointBase" + - type: object + required: [routingKey] + properties: + clientURL: + type: string + routingKey: + type: string + HTTPNotificationEndpoint: + type: object + allOf: + - $ref: "#/components/schemas/NotificationEndpointBase" + - type: object + required: [url, authMethod, method] + properties: + url: + type: string + username: + type: string + password: + type: string + token: + type: string + method: + type: string + enum: ["POST", "GET", "PUT"] + authMethod: + type: string + enum: ["none", "basic", "bearer"] + contentTemplate: + type: string + headers: + type: object + description: Customized headers. + additionalProperties: + type: string + TelegramNotificationEndpoint: + type: object + allOf: + - $ref: "#/components/schemas/NotificationEndpointBase" + - type: object + required: [token, channel] + properties: + token: + description: Specifies the Telegram bot token. See https://core.telegram.org/bots#creating-a-new-bot . + type: string + channel: + description: ID of the telegram channel, a chat_id in https://core.telegram.org/bots/api#sendmessage . + type: string + NotificationEndpointType: + type: string + enum: ["slack", "pagerduty", "http", "telegram"] + DBRP: + type: object + properties: + id: + type: string + description: the mapping identifier + readOnly: true + orgID: + type: string + description: the organization ID that owns this mapping. + org: + type: string + description: the organization that owns this mapping. + bucketID: + type: string + description: the bucket ID used as target for the translation. + database: + type: string + description: InfluxDB v1 database + retention_policy: + type: string + description: InfluxDB v1 retention policy + default: + type: boolean + description: Specify if this mapping represents the default retention policy for the database specificed. + links: + $ref: "#/components/schemas/Links" + oneOf: + - required: + - orgID + - bucketID + - database + - retention_policy + - required: + - org + - bucketID + - database + - retention_policy + DBRPs: + properties: + content: + type: array + items: + $ref: "#/components/schemas/DBRP" + DBRPUpdate: + properties: + database: + type: string + description: InfluxDB v1 database + retention_policy: + type: string + description: InfluxDB v1 retention policy + default: + type: boolean + links: + $ref: "#/components/schemas/Links" + securitySchemes: + BasicAuth: + type: http + scheme: basic diff --git a/test.sh b/test.sh new file mode 100644 index 000000000000..ff237255226e --- /dev/null +++ b/test.sh @@ -0,0 +1,76 @@ +#!/usr/bin/env bash + +# SPDX-FileCopyrightText: 2023 The Pion community +# SPDX-License-Identifier: MIT + +export CURRENT_GO_VERSION=$(echo -n "$(go version)" | grep -o 'go1\.[0-9|\.]*' || true) +CURRENT_GO_VERSION=${CURRENT_GO_VERSION#go} +GO_VERSION=${GO_VERSION:-$CURRENT_GO_VERSION} + +# set golang version from env +export CI_GO_VERSION="${GO_VERSION:-latest}" + +# define some colors to use for output +RED='\033[0;31m' +GREEN='\033[0;32m' +NC='\033[0m' + +printf "${GREEN}Go version \"${CI_GO_VERSION}\"${NC}\n" + +# kill and remove any running containers +cleanup () { + docker stop ci_stun-tcpdump + docker rm -f ci_stun-tcpdump + docker-compose -p ci kill + docker-compose -p ci rm -f + docker network rm stun_e2e_coturn +} + +# catch unexpected failures, do cleanup and output an error message +trap 'cleanup ; printf "${RED}Tests Failed For Unexpected Reasons${NC}\n"'\ + HUP INT QUIT PIPE TERM + +# PREPARING NETWORK CAPTURE +docker network create stun_e2e_coturn --internal +docker build -t pion/tcpdump -f tcpdump.Dockerfile . + +NETWORK_ID=`docker network inspect stun_e2e_coturn -f "{{.Id}}"` +NETWORK_SUBNET=`docker network inspect stun_e2e_coturn -f "{{(index .IPAM.Config 0).Subnet}}"` +CAPTURE_INTERFACE="br-${NETWORK_ID:0:12}" + +echo "will capture traffic on $CAPTURE_INTERFACE$" + +docker run -e INTERFACE=${CAPTURE_INTERFACE} -e SUBNET=${NETWORK_SUBNET} -d \ + -v $(pwd):/root/dump \ + --name ci_stun-tcpdump --net=host pion/tcpdump + + +# build and run the composed services +docker-compose -p ci build && docker-compose -p ci up -d +if [ $? -ne 0 ] ; then + printf "${RED}Docker Compose Failed${NC}\n" + exit -1 +fi + +# wait for the test service to complete and grab the exit code +TEST_EXIT_CODE=`docker wait ci_stun-client_1` + +docker logs ci_stun-client_1 &> log-client.txt +docker logs ci_stun-server_1 &> log-server.txt +docker logs ci_stun-tcpdump &> log-tcpdump.txt + +# output the logs for the test (for clarity) +cat log-client.txt + +# inspect the output of the test and display respective message +if [ -z ${TEST_EXIT_CODE+x} ] || [ "$TEST_EXIT_CODE" -ne 0 ] ; then + printf "${RED}Tests Failed${NC} - Exit Code: $TEST_EXIT_CODE\n" +else + printf "${GREEN}Tests Passed${NC}\n" +fi + +# call the cleanup function +cleanup + +# exit the script with the same code as the test service code +exit ${TEST_EXIT_CODE} diff --git a/test_crosscompile.sh b/test_crosscompile.sh new file mode 100644 index 000000000000..c4b9e3734cfe --- /dev/null +++ b/test_crosscompile.sh @@ -0,0 +1,50 @@ +#!/usr/bin/env sh + +# Test script checking that all expected os/arch compile properly. +# Does not actually test the logic, just the compilation so we make sure we don't break code depending on the lib. + +echo2() { + echo $@ >&2 +} + +trap end 0 +end() { + [ "$?" = 0 ] && echo2 "Pass." || (echo2 "Fail."; exit 1) +} + +cross() { + os=$1 + shift + echo2 "Build for $os." + for arch in $@; do + echo2 " - $os/$arch" + GOOS=$os GOARCH=$arch go build + done + echo2 +} + +set -e + +cross linux amd64 386 arm arm64 ppc64 ppc64le s390x mips mipsle mips64 mips64le +cross darwin amd64 386 arm arm64 +cross freebsd amd64 386 arm +cross netbsd amd64 386 arm +cross openbsd amd64 386 arm arm64 +cross dragonfly amd64 +cross solaris amd64 + +# Not expected to work but should still compile. +cross windows amd64 386 arm + +# TODO: Fix compilation error on openbsd/arm. +# TODO: Merge the solaris PR. + +# Some os/arch require a different compiler. Run in docker. +if ! hash docker; then + # If docker is not present, stop here. + return +fi + +echo2 "Build for linux." +echo2 " - linux/riscv" +docker build -t test -f Dockerfile.riscv . diff --git a/testlimits.sh b/testlimits.sh new file mode 100644 index 000000000000..778348dcc5cb --- /dev/null +++ b/testlimits.sh @@ -0,0 +1,36 @@ +#!/usr/bin/env bash + +#sending changesets every 101ms should not trigger ratelimit +node send_changesets.js http://127.0.0.1:8081/p/BACKEND_TEST_ratelimit_101ms 101 +if [[ $? -ne 0 ]];then + echo "FAILED: ratelimit was triggered when sending every 101 ms" + exit 1 +fi + +#sending changesets every 99ms should trigger ratelimit +node send_changesets.js http://127.0.0.1:8081/p/BACKEND_TEST_ratelimit_99ms 99 +if [[ $? -ne 1 ]];then + echo "FAILED: ratelimit was not triggered when sending every 99 ms" + exit 1 +fi + +#sending changesets every 101ms via proxy +node send_changesets.js http://127.0.0.1:8081/p/BACKEND_TEST_ratelimit_101ms 101 & +pid1=$! + +#sending changesets every 101ms via second IP and proxy +docker exec anotherip node /tmp/send_changesets.js http://172.23.42.1:80/p/BACKEND_TEST_ratelimit_101ms_via_second_ip 101 & +pid2=$! + +wait $pid1 +exit1=$? +wait $pid2 +exit2=$? + +echo "101ms with proxy returned with ${exit1}" +echo "101ms via another ip returned with ${exit2}" + +if [[ $exit1 -eq 1 || $exit2 -eq 1 ]];then + echo "FAILED: ratelimit was triggered during proxy and requests via second ip" + exit 1 +fi diff --git a/v2migration.sh b/v2migration.sh new file mode 100644 index 000000000000..4b266f9d10c0 --- /dev/null +++ b/v2migration.sh @@ -0,0 +1,136 @@ +#!/usr/bin/env bash +# This script is a helper of migration to gopsutil v2 using gorename +# +# go get golang.org/x/tools/cmd/gorename + +IFS=$'\n' + +## Part 1. rename Functions to pass golint. ex) cpu.CPUTimesStat -> cpu.TimesStat + +# +# Note: +# process has IOCounters() for file IO, and also NetIOCounters() for Net IO. +# This scripts replace process.NetIOCounters() to IOCounters(). +# So you need hand-fixing process. + +TARGETS=$(cat < TimesStat +CPUInfoStat -> InfoStat +CPUTimes -> Times +CPUInfo -> Info +CPUCounts -> Counts +CPUPercent -> Percent +DiskUsageStat -> UsageStat +DiskPartitionStat -> PartitionStat +DiskIOCountersStat -> IOCountersStat +DiskPartitions -> Partitions +DiskIOCounters -> IOCounters +DiskUsage -> Usage +HostInfoStat -> InfoStat +HostInfo -> Info +GetVirtualization -> Virtualization +GetPlatformInformation -> PlatformInformation +LoadAvgStat -> AvgStat +LoadAvg -> Avg +NetIOCountersStat -> IOCountersStat +NetConnectionStat -> ConnectionStat +NetProtoCountersStat -> ProtoCountersStat +NetInterfaceAddr -> InterfaceAddr +NetInterfaceStat -> InterfaceStat +NetFilterStat -> FilterStat +NetInterfaces -> Interfaces +getNetIOCountersAll -> getIOCountersAll +NetIOCounters -> IOCounters +NetIOCountersByFile -> IOCountersByFile +NetProtoCounters -> ProtoCounters +NetFilterCounters -> FilterCounters +NetConnections -> Connections +NetConnectionsPid -> ConnectionsPid +Uid -> UID +Id -> ID +convertCpuTimes -> convertCPUTimes +EOF +) + +for T in $TARGETS +do + echo "$T" + gofmt -w -r "$T" ./*.go +done + + +###### Part 2 rename JSON key name +## Google JSOn style +## https://google.github.io/styleguide/jsoncstyleguide.xml + +sed -i "" 's/guest_nice/guestNice/g' cpu/*.go +sed -i "" 's/vendor_id/vendorId/g' cpu/*.go +sed -i "" 's/physical_id/physicalId/g' cpu/*.go +sed -i "" 's/model_name/modelName/g' cpu/*.go +sed -i "" 's/cache_size/cacheSize/g' cpu/*.go +sed -i "" 's/core_id/coreId/g' cpu/*.go + +sed -i "" 's/inodes_total/inodesTotal/g' disk/*.go +sed -i "" 's/inodes_used/inodesUsed/g' disk/*.go +sed -i "" 's/inodes_free/inodesFree/g' disk/*.go +sed -i "" 's/inodes_used_percent/inodesUsedPercent/g' disk/*.go +sed -i "" 's/read_count/readCount/g' disk/*.go +sed -i "" 's/write_count/writeCount/g' disk/*.go +sed -i "" 's/read_bytes/readBytes/g' disk/*.go +sed -i "" 's/write_bytes/writeBytes/g' disk/*.go +sed -i "" 's/read_time/readTime/g' disk/*.go +sed -i "" 's/write_time/writeTime/g' disk/*.go +sed -i "" 's/io_time/ioTime/g' disk/*.go +sed -i "" 's/serial_number/serialNumber/g' disk/*.go +sed -i "" 's/used_percent/usedPercent/g' disk/*.go +sed -i "" 's/inodesUsed_percent/inodesUsedPercent/g' disk/*.go + +sed -i "" 's/total_cache/totalCache/g' docker/*.go +sed -i "" 's/total_rss_huge/totalRssHuge/g' docker/*.go +sed -i "" 's/total_rss/totalRss/g' docker/*.go +sed -i "" 's/total_mapped_file/totalMappedFile/g' docker/*.go +sed -i "" 's/total_pgpgin/totalPgpgin/g' docker/*.go +sed -i "" 's/total_pgpgout/totalPgpgout/g' docker/*.go +sed -i "" 's/total_pgfault/totalPgfault/g' docker/*.go +sed -i "" 's/total_pgmajfault/totalPgmajfault/g' docker/*.go +sed -i "" 's/total_inactive_anon/totalInactiveAnon/g' docker/*.go +sed -i "" 's/total_active_anon/totalActiveAnon/g' docker/*.go +sed -i "" 's/total_inactive_file/totalInactiveFile/g' docker/*.go +sed -i "" 's/total_active_file/totalActiveFile/g' docker/*.go +sed -i "" 's/total_unevictable/totalUnevictable/g' docker/*.go +sed -i "" 's/mem_usage_in_bytes/memUsageInBytes/g' docker/*.go +sed -i "" 's/mem_max_usage_in_bytes/memMaxUsageInBytes/g' docker/*.go +sed -i "" 's/memory.limit_in_bytes/memoryLimitInBbytes/g' docker/*.go +sed -i "" 's/memory.failcnt/memoryFailcnt/g' docker/*.go +sed -i "" 's/mapped_file/mappedFile/g' docker/*.go +sed -i "" 's/container_id/containerID/g' docker/*.go +sed -i "" 's/rss_huge/rssHuge/g' docker/*.go +sed -i "" 's/inactive_anon/inactiveAnon/g' docker/*.go +sed -i "" 's/active_anon/activeAnon/g' docker/*.go +sed -i "" 's/inactive_file/inactiveFile/g' docker/*.go +sed -i "" 's/active_file/activeFile/g' docker/*.go +sed -i "" 's/hierarchical_memory_limit/hierarchicalMemoryLimit/g' docker/*.go + +sed -i "" 's/boot_time/bootTime/g' host/*.go +sed -i "" 's/platform_family/platformFamily/g' host/*.go +sed -i "" 's/platform_version/platformVersion/g' host/*.go +sed -i "" 's/virtualization_system/virtualizationSystem/g' host/*.go +sed -i "" 's/virtualization_role/virtualizationRole/g' host/*.go + +sed -i "" 's/used_percent/usedPercent/g' mem/*.go + +sed -i "" 's/bytes_sent/bytesSent/g' net/*.go +sed -i "" 's/bytes_recv/bytesRecv/g' net/*.go +sed -i "" 's/packets_sent/packetsSent/g' net/*.go +sed -i "" 's/packets_recv/packetsRecv/g' net/*.go +sed -i "" 's/conntrack_count/conntrackCount/g' net/*.go +sed -i "" 's/conntrack_max/conntrackMax/g' net/*.go + +sed -i "" 's/read_count/readCount/g' process/*.go +sed -i "" 's/write_count/writeCount/g' process/*.go +sed -i "" 's/read_bytes/readBytes/g' process/*.go +sed -i "" 's/write_bytes/writeBytes/g' process/*.go +sed -i "" 's/shared_clean/sharedClean/g' process/*.go +sed -i "" 's/shared_dirty/sharedDirty/g' process/*.go +sed -i "" 's/private_clean/privateClean/g' process/*.go +sed -i "" 's/private_dirty/privateDirty/g' process/*.go diff --git a/v3migration.sh b/v3migration.sh new file mode 100644 index 000000000000..39f65e8999f9 --- /dev/null +++ b/v3migration.sh @@ -0,0 +1,171 @@ +#!/usr/bin/env bash + +set -eu + +# this scripts is used when migrating v2 to v3. +# usage: cd ${GOPATH}/src/github.com/shirou/gopsutil && bash tools/v3migration/v3migration.sh + + + +DIR="$(cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd)" +ROOT=$(cd "${DIR}"/../.. && pwd) + + +## 1. refresh +cd "${ROOT}" + +/bin/rm -rf v3 + +## 2. copy directories +# docker is removed, #464 will be fixed +mkdir -p v3 +cp -rp cpu disk docker host internal load mem net process winservices v3 +cp Makefile v3 + +# build migartion tool +go build -o v3/v3migration "${DIR}"/v3migration.go + + +V3DIR=$(cd "${ROOT}"/v3 && pwd) +cd "${V3DIR}" + +## 3. mod +go mod init + +### change import path +find . -name "*.go" -print0 | xargs -0 -I@ sed -i 's|"github.com/shirou/gopsutil/|"github.com/shirou/gopsutil/v3/|g' @ + +############ Issues + +# #429 process.NetIOCounters is pointless on Linux +./v3migration "$(pwd)" 429 +sed -i '/NetIOCounters/d' process/process.go +sed -i "/github.com\/shirou\/gopsutil\/v3\/net/d" process/process_bsd.go + + +# #464 CgroupMem : fix typo and wrong file names +sed -i 's|memoryLimitInBbytes|memoryLimitInBytes|g' docker/docker.go +sed -i 's|memoryLimitInBbytes|memory.limit_in_bytes|g' docker/docker_linux.go +sed -i 's|memoryFailcnt|memory.failcnt|g' docker/docker_linux.go + + +# fix #346 +sed -i 's/Soft int32/Soft uint64/' process/process.go +sed -i 's/Hard int32/Hard uint64/' process/process.go +sed -i 's| //TODO too small. needs to be uint64||' process/process.go +sed -i 's|limitToInt(val string) (int32, error)|limitToUint(val string) (uint64, error)|' process/process_*.go +sed -i 's|limitToInt|limitToUint|' process/process_*.go +sed -i 's|return int32(res), nil|return uint64(res), nil|' process/process_*.go +sed -i 's|math.MaxInt32|math.MaxUint64|' process/process_*.go + +# fix #545 +# variable names +sed -i 's|WritebackTmp|WriteBackTmp|g' mem/*.go +sed -i 's|Writeback|WriteBack|g' mem/*.go +sed -i 's|SReclaimable|Sreclaimable|g' mem/*.go +sed -i 's|SUnreclaim|Sunreclaim|g' mem/*.go +sed -i 's|VMallocTotal|VmallocTotal|g' mem/*.go +sed -i 's|VMallocUsed|VmallocUsed|g' mem/*.go +sed -i 's|VMallocChunk|VmallocChunk|g' mem/*.go + +# json field name +sed -i 's|hostid|hostId|g' host/host.go +sed -i 's|hostid|hostId|g' host/host_test.go +sed -i 's|sensorTemperature|temperature|g' host/host.go +sed -i 's|sensorTemperature|temperature|g' host/host_test.go + +sed -i 's|writeback|writeBack|g' mem/*.go +sed -i 's|writeBacktmp|writeBackTmp|g' mem/*.go +sed -i 's|pagetables|pageTables|g' mem/*.go +sed -i 's|swapcached|swapCached|g' mem/*.go +sed -i 's|commitlimit|commitLimit|g' mem/*.go +sed -i 's|committedas|committedAS|g' mem/*.go +sed -i 's|hightotal|highTotal|g' mem/*.go +sed -i 's|highfree|highFree|g' mem/*.go +sed -i 's|lowtotal|lowTotal|g' mem/*.go +sed -i 's|lowfree|lowFree|g' mem/*.go +sed -i 's|swaptotal|swapTotal|g' mem/*.go +sed -i 's|swapfree|swapFree|g' mem/*.go +sed -i 's|vmalloctotal|vmallocTotal|g' mem/*.go +sed -i 's|vmallocused|vmallocUsed|g' mem/*.go +sed -i 's|vmallocchunk|vmallocChunk|g' mem/*.go +sed -i 's|hugepagestotal|hugePagesTotal|g' mem/*.go +sed -i 's|hugepagesfree|hugePagesFree|g' mem/*.go +sed -i 's|hugepagesize|hugePageSize|g' mem/*.go +sed -i 's|pgin|pgIn|g' mem/*.go +sed -i 's|pgout|pgOut|g' mem/*.go +sed -i 's|pgfault|pgFault|g' mem/*.go +sed -i 's|pgmajfault|pgMajFault|g' mem/*.go + +sed -i 's|hardwareaddr|hardwareAddr|g' net/*.go +sed -i 's|conntrackCount|connTrackCount|g' net/*.go +sed -i 's|conntrackMax|connTrackMax|g' net/*.go +sed -i 's|delete_list|deleteList|g' net/*.go +sed -i 's|insert_failed|insertFailed|g' net/*.go +sed -i 's|early_drop|earlyDrop|g' net/*.go +sed -i 's|expect_create|expectCreate|g' net/*.go +sed -i 's|expect_delete|expectDelete|g' net/*.go +sed -i 's|search_restart|searchRestart|g' net/*.go +sed -i 's|icmp_error|icmpError|g' net/*.go +sed -i 's|expect_new|expectNew|g' net/*.go + + + +# fix no more public API/types/constants defined only for some platforms + +sed -i 's|CTLKern|ctlKern|g' cpu/*.go +sed -i 's|CPNice|cpNice|g' cpu/*.go +sed -i 's|CPSys|cpSys|g' cpu/*.go +sed -i 's|CPIntr|cpIntr|g' cpu/*.go +sed -i 's|CPIdle|cpIdle|g' cpu/*.go +sed -i 's|CPUStates|cpUStates|g' cpu/*.go +sed -i 's|CTLKern|ctlKern|g' cpu/cpu_openbsd.go +sed -i 's|CTLHw|ctlHw|g' cpu/cpu_openbsd.go +sed -i 's|SMT|sMT|g' cpu/cpu_openbsd.go +sed -i 's|KernCptime|kernCptime|g' cpu/cpu_openbsd.go +sed -i 's|KernCptime2|kernCptime2|g' cpu/cpu_openbsd.go +sed -i 's|Win32_Processor|win32Processor|g' cpu/cpu_windows.go + +sed -i 's|DEVSTAT_NO_DATA|devstat_NO_DATA|g' disk/*.go +sed -i 's|DEVSTAT_READ|devstat_READ|g' disk/*.go +sed -i 's|DEVSTAT_WRITE|devstat_WRITE|g' disk/*.go +sed -i 's|DEVSTAT_FREE|devstat_FREE|g' disk/*.go +sed -i 's|Devstat|devstat|g' disk/*.go +sed -i 's|Bintime|bintime|g' disk/*.go +sed -i 's|SectorSize|sectorSize|g' disk/disk_linux.go +sed -i 's|FileFileCompression|fileFileCompression|g' disk/disk_windows.go +sed -i 's|FileReadOnlyVolume|fileReadOnlyVolume|g' disk/disk_windows.go + +sed -i 's|USER_PROCESS|user_PROCESS|g' host/host_*.go +sed -i 's|LSB|lsbStruct|g' host/host_linux* + +sed -i 's| BcacheStats | bcacheStats |g' mem/*.go + +sed -i 's|TCPStatuses|tcpStatuses|g' net/*.go +sed -i 's|CT_ENTRIES|ctENTRIES|g' net/net_linux.go +sed -i 's|CT_SEARCHED|ctSEARCHED|g' net/net_linux.go +sed -i 's|CT_FOUND|ctFOUND|g' net/net_linux.go +sed -i 's|CT_NEW|ctNEW|g' net/net_linux.go +sed -i 's|CT_INVALID|ctINVALID|g' net/net_linux.go +sed -i 's|CT_IGNORE|ctIGNORE|g' net/net_linux.go +sed -i 's|CT_DELETE|ctDELETE|g' net/net_linux.go +sed -i 's|CT_DELETE_LIST|ctDELETE_LIST|g' net/net_linux.go +sed -i 's|CT_INSERT|ctINSERT|g' net/net_linux.go +sed -i 's|CT_INSERT_FAILED|ctINSERT_FAILED|g' net/net_linux.go +sed -i 's|CT_DROP|ctDROP|g' net/net_linux.go +sed -i 's|CT_EARLY_DROP|ctEARLY_DROP|g' net/net_linux.go +sed -i 's|CT_ICMP_ERROR|ctICMP_ERROR|g' net/net_linux.go +sed -i 's|CT_EXPECT_NEW|ctEXPECT_NEW|g' net/net_linux.go +sed -i 's|CT_EXPECT_CREATE|ctEXPECT_CREATE|g' net/net_linux.go +sed -i 's|CT_EXPECT_DELETE|ctEXPECT_DELETE|g' net/net_linux.go +sed -i 's|CT_SEARCH_RESTART|ctSEARCH_RESTART|g' net/net_linux.go + +sed -i 's|PageSize|pageSize|g' process/process_*.go +sed -i 's|PrioProcess|prioProcess|g' process/process_*.go +sed -i 's|ClockTicks|clockTicks|g' process/process_*.go + + +./v3migration "$(pwd)" issueRemoveUnusedValue + + +############ SHOULD BE FIXED BY HAND diff --git a/version.go b/version.go new file mode 100644 index 000000000000..c2cc3e2e0231 --- /dev/null +++ b/version.go @@ -0,0 +1,4 @@ +package credentials + +// Version holds a string describing the current version +const Version = "0.6.3"