def health(url: str, username: str, password: str):
    """
    Retrieving the Artifactory instance health status.
    """
    client = JfrogAPI(url, username, password)
    typer.echo(get_health_ping(client))
def storage_info(url: str, username: str, password: str):
    """
    Prints the storage info of the Artifactory instance.
    """
    client = JfrogAPI(url, username, password)
    typer.echo(get_storage_info(client))
def delete_user(url: str, username: str, password: str, new_username: str, new_user_password: str, email: str):
    """
    Deletes Artifactory user, using username, password and email.
    """
    client = JfrogAPI(url, username, password)
    typer.echo(user_handling_by_name(client, new_username, email, new_user_password, is_deletion=True))
def create_user(url: str, username: str, password: str, new_username: str, new_user_password: str, email: str):
    """
    Creates Artifactory user, using username, password and email.
    """
    client = JfrogAPI(url, username, password)
    typer.echo(user_handling_by_name(client, new_username, email, new_user_password))
def version(url: str, username: str, password: str):
    """
    Retrieving the Artifactory instance version.
    """
    client = JfrogAPI(url, username, password)
    typer.echo(get_system_version(client))
Beispiel #6
0
from fastapi import Depends, FastAPI
from fastapi.security import OAuth2PasswordBearer

from controllers.artifactory import get_health_ping, get_system_version, user_handling_by_name, get_storage_info
from interfaces.jfrog_api import JfrogAPI
from utils.tokens import set_token_to_client
from configs.envs import ARTIFACTORY_URL

app = FastAPI()
oauth2_scheme = OAuth2PasswordBearer(tokenUrl="token")
client = JfrogAPI(ARTIFACTORY_URL)


@app.get("/")
def read_root():
    return {"Info": "JFrog Artifactory API, feel free to go /docs for more information about the API !"}


@app.get("/artifactory_health")
def artifactory_health(token: str = Depends(oauth2_scheme)):
    tokenized_client = set_token_to_client(client, token)
    return get_health_ping(tokenized_client)


@app.get("/artifactory_version")
def artifactory_version(token: str = Depends(oauth2_scheme)):
    tokenized_client = set_token_to_client(client, token)
    return get_system_version(tokenized_client)


@app.put("/users/{username}")