mirror of
https://github.com/HangarMC/Hangar.git
synced 2025-03-19 15:40:50 +08:00
initial commit, api done
This commit is contained in:
commit
fea58f60cf
31
.gitignore
vendored
Normal file
31
.gitignore
vendored
Normal file
@ -0,0 +1,31 @@
|
||||
HELP.md
|
||||
target/
|
||||
!.mvn/wrapper/maven-wrapper.jar
|
||||
!**/src/main/**
|
||||
!**/src/test/**
|
||||
|
||||
### STS ###
|
||||
.apt_generated
|
||||
.classpath
|
||||
.factorypath
|
||||
.project
|
||||
.settings
|
||||
.springBeans
|
||||
.sts4-cache
|
||||
|
||||
### IntelliJ IDEA ###
|
||||
.idea
|
||||
*.iws
|
||||
*.iml
|
||||
*.ipr
|
||||
|
||||
### NetBeans ###
|
||||
/nbproject/private/
|
||||
/nbbuild/
|
||||
/dist/
|
||||
/nbdist/
|
||||
/.nb-gradle/
|
||||
build/
|
||||
|
||||
### VS Code ###
|
||||
.vscode/
|
118
.mvn/wrapper/MavenWrapperDownloader.java
vendored
Normal file
118
.mvn/wrapper/MavenWrapperDownloader.java
vendored
Normal file
@ -0,0 +1,118 @@
|
||||
/*
|
||||
* Copyright 2007-present the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import java.net.*;
|
||||
import java.io.*;
|
||||
import java.nio.channels.*;
|
||||
import java.util.Properties;
|
||||
|
||||
public class MavenWrapperDownloader {
|
||||
|
||||
private static final String WRAPPER_VERSION = "0.5.6";
|
||||
/**
|
||||
* Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided.
|
||||
*/
|
||||
private static final String DEFAULT_DOWNLOAD_URL = "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/"
|
||||
+ WRAPPER_VERSION + "/maven-wrapper-" + WRAPPER_VERSION + ".jar";
|
||||
|
||||
/**
|
||||
* Path to the maven-wrapper.properties file, which might contain a downloadUrl property to use instead of the
|
||||
* default one.
|
||||
*/
|
||||
private static final String MAVEN_WRAPPER_PROPERTIES_PATH =
|
||||
".mvn/wrapper/maven-wrapper.properties";
|
||||
|
||||
/**
|
||||
* Path where the maven-wrapper.jar will be saved to.
|
||||
*/
|
||||
private static final String MAVEN_WRAPPER_JAR_PATH =
|
||||
".mvn/wrapper/maven-wrapper.jar";
|
||||
|
||||
/**
|
||||
* Name of the property which should be used to override the default download url for the wrapper.
|
||||
*/
|
||||
private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl";
|
||||
|
||||
public static void main(String args[]) {
|
||||
System.out.println("- Downloader started");
|
||||
File baseDirectory = new File(args[0]);
|
||||
System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath());
|
||||
|
||||
// If the maven-wrapper.properties exists, read it and check if it contains a custom
|
||||
// wrapperUrl parameter.
|
||||
File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH);
|
||||
String url = DEFAULT_DOWNLOAD_URL;
|
||||
if (mavenWrapperPropertyFile.exists()) {
|
||||
FileInputStream mavenWrapperPropertyFileInputStream = null;
|
||||
try {
|
||||
mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile);
|
||||
Properties mavenWrapperProperties = new Properties();
|
||||
mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream);
|
||||
url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url);
|
||||
} catch (IOException e) {
|
||||
System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'");
|
||||
} finally {
|
||||
try {
|
||||
if (mavenWrapperPropertyFileInputStream != null) {
|
||||
mavenWrapperPropertyFileInputStream.close();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
// Ignore ...
|
||||
}
|
||||
}
|
||||
}
|
||||
System.out.println("- Downloading from: " + url);
|
||||
|
||||
File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH);
|
||||
if (!outputFile.getParentFile().exists()) {
|
||||
if (!outputFile.getParentFile().mkdirs()) {
|
||||
System.out.println(
|
||||
"- ERROR creating output directory '" + outputFile.getParentFile().getAbsolutePath() + "'");
|
||||
}
|
||||
}
|
||||
System.out.println("- Downloading to: " + outputFile.getAbsolutePath());
|
||||
try {
|
||||
downloadFileFromURL(url, outputFile);
|
||||
System.out.println("Done");
|
||||
System.exit(0);
|
||||
} catch (Throwable e) {
|
||||
System.out.println("- Error downloading");
|
||||
e.printStackTrace();
|
||||
System.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
private static void downloadFileFromURL(String urlString, File destination) throws Exception {
|
||||
if (System.getenv("MVNW_USERNAME") != null && System.getenv("MVNW_PASSWORD") != null) {
|
||||
String username = System.getenv("MVNW_USERNAME");
|
||||
char[] password = System.getenv("MVNW_PASSWORD").toCharArray();
|
||||
Authenticator.setDefault(new Authenticator() {
|
||||
@Override
|
||||
protected PasswordAuthentication getPasswordAuthentication() {
|
||||
return new PasswordAuthentication(username, password);
|
||||
}
|
||||
});
|
||||
}
|
||||
URL website = new URL(urlString);
|
||||
ReadableByteChannel rbc;
|
||||
rbc = Channels.newChannel(website.openStream());
|
||||
FileOutputStream fos = new FileOutputStream(destination);
|
||||
fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
|
||||
fos.close();
|
||||
rbc.close();
|
||||
}
|
||||
|
||||
}
|
BIN
.mvn/wrapper/maven-wrapper.jar
vendored
Normal file
BIN
.mvn/wrapper/maven-wrapper.jar
vendored
Normal file
Binary file not shown.
2
.mvn/wrapper/maven-wrapper.properties
vendored
Normal file
2
.mvn/wrapper/maven-wrapper.properties
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.3/apache-maven-3.6.3-bin.zip
|
||||
wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar
|
3
README.md
Normal file
3
README.md
Normal file
@ -0,0 +1,3 @@
|
||||
# Hangar2 - Ore, but in spring!
|
||||
|
||||
Nothing to see here yet, move along
|
3
docker-compose.yml
Normal file
3
docker-compose.yml
Normal file
@ -0,0 +1,3 @@
|
||||
|
||||
|
||||
postgres:12-alpine
|
3
docker/db/Dockerfile
Normal file
3
docker/db/Dockerfile
Normal file
@ -0,0 +1,3 @@
|
||||
FROM postgres:12-alpine
|
||||
|
||||
COPY init.sql /docker-entrypoint-initdb.d/
|
3
docker/db/init.sql
Normal file
3
docker/db/init.sql
Normal file
@ -0,0 +1,3 @@
|
||||
create extension hstore;
|
||||
create extension pgcrypto;
|
||||
create role hangar with login password 'hangar';
|
89
docker/docker-compose.yml
Normal file
89
docker/docker-compose.yml
Normal file
@ -0,0 +1,89 @@
|
||||
version: '3.7'
|
||||
|
||||
services:
|
||||
# app:
|
||||
# build: ./hangar
|
||||
# depends_on:
|
||||
# - 'db'
|
||||
# - 'auth'
|
||||
# - 'mail'
|
||||
# stdin_open: true
|
||||
# labels:
|
||||
# - "traefik.enable=true"
|
||||
# - "traefik.http.services.hangar.loadbalancer.server.port=8080"
|
||||
# - "traefik.http.routers.hangar.rule=Host(`hangar.minidigger.me`)"
|
||||
# - "traefik.http.routers.hangar.entrypoints=web-secure"
|
||||
# - "traefik.http.routers.hangar.tls=true"
|
||||
# - "traefik.http.routers.hangar.tls.options=default"
|
||||
# - "traefik.http.routers.hangar.tls.certresolver=default"
|
||||
# - "traefik.http.routers.hangar.tls.domains[0].main=minidigger.me"
|
||||
# - "traefik.http.routers.hangar.tls.domains[0].sans=*.minidigger.me"
|
||||
# networks:
|
||||
# - web
|
||||
db:
|
||||
build: ./db
|
||||
environment:
|
||||
POSTGRES_USER: root
|
||||
POSTGRES_PASSWORD: 'changeme'
|
||||
POSTGRES_DB: hangar
|
||||
ports:
|
||||
- "5432:5432"
|
||||
volumes:
|
||||
- db_data:/var/lib/postgresql/data
|
||||
# networks:
|
||||
# - web
|
||||
mail:
|
||||
image: mailhog/mailhog:latest
|
||||
labels:
|
||||
- "traefik.enable=true"
|
||||
- "traefik.http.services.hangar-mail.loadbalancer.server.port=8025"
|
||||
- "traefik.http.routers.hangar-mail.middlewares=basicauth@file"
|
||||
- "traefik.http.routers.hangar-mail.rule=Host(`hangar-mail.minidigger.me`)"
|
||||
- "traefik.http.routers.hangar-mail.entrypoints=web-secure"
|
||||
- "traefik.http.routers.hangar-mail.tls=true"
|
||||
- "traefik.http.routers.hangar-mail.tls.options=default"
|
||||
- "traefik.http.routers.hangar-mail.tls.certresolver=default"
|
||||
- "traefik.http.routers.hangar-mail.tls.domains[0].main=minidigger.me"
|
||||
- "traefik.http.routers.hangar-mail.tls.domains[0].sans=*.minidigger.me"
|
||||
# networks:
|
||||
# - web
|
||||
# auth:
|
||||
# image: registry.gitlab.com/minidigger/hangarauth
|
||||
# depends_on:
|
||||
# - 'db'
|
||||
# labels:
|
||||
# - "traefik.enable=true"
|
||||
# - "traefik.http.services.hangar-auth.loadbalancer.server.port=8000"
|
||||
# - "traefik.http.routers.hangar-auth.rule=Host(`hangar-auth.minidigger.me`)"
|
||||
# - "traefik.http.routers.hangar-auth.entrypoints=web-secure"
|
||||
# - "traefik.http.routers.hangar-auth.tls=true"
|
||||
# - "traefik.http.routers.hangar-auth.tls.options=default"
|
||||
# - "traefik.http.routers.hangar-auth.tls.certresolver=default"
|
||||
# - "traefik.http.routers.hangar-auth.tls.domains[0].main=minidigger.me"
|
||||
# - "traefik.http.routers.hangar-auth.tls.domains[0].sans=*.minidigger.me"
|
||||
# environment:
|
||||
# SECRET_KEY: "TzNc3RTpfVn1xxNV90PPGEfs7SZhy5"
|
||||
# EMAIL_HOST: "mail"
|
||||
# EMAIL_PORT: "1025"
|
||||
# EMAIL_SSL: "false"
|
||||
# EMAIL_TLS: "false"
|
||||
# EMAIL_HOST_USER: "dum"
|
||||
# EMAIL_HOST_PASSWORD: "dum"
|
||||
# DB_NAME: "spongeauth"
|
||||
# DB_USER: "spongeauth"
|
||||
# DB_PASSWORD: "spongeauth"
|
||||
# DB_HOST: "hangar_db"
|
||||
# SSO_ENDPOINT_ore: "{ 'sync_sso_endpoint': ('http://hangar_app:9000/api/sync_sso'), 'sso_secret': 'changeme', 'api_key': 'changeme' }"
|
||||
# DEBUG: "false"
|
||||
# DJANGO_SETTINGS_MODULE: "spongeauth.settings.prod"
|
||||
# networks:
|
||||
# - web
|
||||
|
||||
#networks:
|
||||
# web:
|
||||
# name: traefik-overlay
|
||||
# external: true
|
||||
|
||||
volumes:
|
||||
db_data:
|
||||
uploads:
|
0
docker/hangar/Dockerfile
Normal file
0
docker/hangar/Dockerfile
Normal file
310
mvnw
vendored
Normal file
310
mvnw
vendored
Normal file
@ -0,0 +1,310 @@
|
||||
#!/bin/sh
|
||||
# ----------------------------------------------------------------------------
|
||||
# Licensed to the Apache Software Foundation (ASF) under one
|
||||
# or more contributor license agreements. See the NOTICE file
|
||||
# distributed with this work for additional information
|
||||
# regarding copyright ownership. The ASF licenses this file
|
||||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
# https://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
# KIND, either express or implied. See the License for the
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
# ----------------------------------------------------------------------------
|
||||
|
||||
# ----------------------------------------------------------------------------
|
||||
# Maven Start Up Batch script
|
||||
#
|
||||
# Required ENV vars:
|
||||
# ------------------
|
||||
# JAVA_HOME - location of a JDK home dir
|
||||
#
|
||||
# Optional ENV vars
|
||||
# -----------------
|
||||
# M2_HOME - location of maven2's installed home dir
|
||||
# MAVEN_OPTS - parameters passed to the Java VM when running Maven
|
||||
# e.g. to debug Maven itself, use
|
||||
# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
|
||||
# MAVEN_SKIP_RC - flag to disable loading of mavenrc files
|
||||
# ----------------------------------------------------------------------------
|
||||
|
||||
if [ -z "$MAVEN_SKIP_RC" ] ; then
|
||||
|
||||
if [ -f /etc/mavenrc ] ; then
|
||||
. /etc/mavenrc
|
||||
fi
|
||||
|
||||
if [ -f "$HOME/.mavenrc" ] ; then
|
||||
. "$HOME/.mavenrc"
|
||||
fi
|
||||
|
||||
fi
|
||||
|
||||
# OS specific support. $var _must_ be set to either true or false.
|
||||
cygwin=false;
|
||||
darwin=false;
|
||||
mingw=false
|
||||
case "`uname`" in
|
||||
CYGWIN*) cygwin=true ;;
|
||||
MINGW*) mingw=true;;
|
||||
Darwin*) darwin=true
|
||||
# Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home
|
||||
# See https://developer.apple.com/library/mac/qa/qa1170/_index.html
|
||||
if [ -z "$JAVA_HOME" ]; then
|
||||
if [ -x "/usr/libexec/java_home" ]; then
|
||||
export JAVA_HOME="`/usr/libexec/java_home`"
|
||||
else
|
||||
export JAVA_HOME="/Library/Java/Home"
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ -z "$JAVA_HOME" ] ; then
|
||||
if [ -r /etc/gentoo-release ] ; then
|
||||
JAVA_HOME=`java-config --jre-home`
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -z "$M2_HOME" ] ; then
|
||||
## resolve links - $0 may be a link to maven's home
|
||||
PRG="$0"
|
||||
|
||||
# need this for relative symlinks
|
||||
while [ -h "$PRG" ] ; do
|
||||
ls=`ls -ld "$PRG"`
|
||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||
if expr "$link" : '/.*' > /dev/null; then
|
||||
PRG="$link"
|
||||
else
|
||||
PRG="`dirname "$PRG"`/$link"
|
||||
fi
|
||||
done
|
||||
|
||||
saveddir=`pwd`
|
||||
|
||||
M2_HOME=`dirname "$PRG"`/..
|
||||
|
||||
# make it fully qualified
|
||||
M2_HOME=`cd "$M2_HOME" && pwd`
|
||||
|
||||
cd "$saveddir"
|
||||
# echo Using m2 at $M2_HOME
|
||||
fi
|
||||
|
||||
# For Cygwin, ensure paths are in UNIX format before anything is touched
|
||||
if $cygwin ; then
|
||||
[ -n "$M2_HOME" ] &&
|
||||
M2_HOME=`cygpath --unix "$M2_HOME"`
|
||||
[ -n "$JAVA_HOME" ] &&
|
||||
JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
|
||||
[ -n "$CLASSPATH" ] &&
|
||||
CLASSPATH=`cygpath --path --unix "$CLASSPATH"`
|
||||
fi
|
||||
|
||||
# For Mingw, ensure paths are in UNIX format before anything is touched
|
||||
if $mingw ; then
|
||||
[ -n "$M2_HOME" ] &&
|
||||
M2_HOME="`(cd "$M2_HOME"; pwd)`"
|
||||
[ -n "$JAVA_HOME" ] &&
|
||||
JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`"
|
||||
fi
|
||||
|
||||
if [ -z "$JAVA_HOME" ]; then
|
||||
javaExecutable="`which javac`"
|
||||
if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then
|
||||
# readlink(1) is not available as standard on Solaris 10.
|
||||
readLink=`which readlink`
|
||||
if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then
|
||||
if $darwin ; then
|
||||
javaHome="`dirname \"$javaExecutable\"`"
|
||||
javaExecutable="`cd \"$javaHome\" && pwd -P`/javac"
|
||||
else
|
||||
javaExecutable="`readlink -f \"$javaExecutable\"`"
|
||||
fi
|
||||
javaHome="`dirname \"$javaExecutable\"`"
|
||||
javaHome=`expr "$javaHome" : '\(.*\)/bin'`
|
||||
JAVA_HOME="$javaHome"
|
||||
export JAVA_HOME
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -z "$JAVACMD" ] ; then
|
||||
if [ -n "$JAVA_HOME" ] ; then
|
||||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||
# IBM's JDK on AIX uses strange locations for the executables
|
||||
JAVACMD="$JAVA_HOME/jre/sh/java"
|
||||
else
|
||||
JAVACMD="$JAVA_HOME/bin/java"
|
||||
fi
|
||||
else
|
||||
JAVACMD="`which java`"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ ! -x "$JAVACMD" ] ; then
|
||||
echo "Error: JAVA_HOME is not defined correctly." >&2
|
||||
echo " We cannot execute $JAVACMD" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -z "$JAVA_HOME" ] ; then
|
||||
echo "Warning: JAVA_HOME environment variable is not set."
|
||||
fi
|
||||
|
||||
CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher
|
||||
|
||||
# traverses directory structure from process work directory to filesystem root
|
||||
# first directory with .mvn subdirectory is considered project base directory
|
||||
find_maven_basedir() {
|
||||
|
||||
if [ -z "$1" ]
|
||||
then
|
||||
echo "Path not specified to find_maven_basedir"
|
||||
return 1
|
||||
fi
|
||||
|
||||
basedir="$1"
|
||||
wdir="$1"
|
||||
while [ "$wdir" != '/' ] ; do
|
||||
if [ -d "$wdir"/.mvn ] ; then
|
||||
basedir=$wdir
|
||||
break
|
||||
fi
|
||||
# workaround for JBEAP-8937 (on Solaris 10/Sparc)
|
||||
if [ -d "${wdir}" ]; then
|
||||
wdir=`cd "$wdir/.."; pwd`
|
||||
fi
|
||||
# end of workaround
|
||||
done
|
||||
echo "${basedir}"
|
||||
}
|
||||
|
||||
# concatenates all lines of a file
|
||||
concat_lines() {
|
||||
if [ -f "$1" ]; then
|
||||
echo "$(tr -s '\n' ' ' < "$1")"
|
||||
fi
|
||||
}
|
||||
|
||||
BASE_DIR=`find_maven_basedir "$(pwd)"`
|
||||
if [ -z "$BASE_DIR" ]; then
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
##########################################################################################
|
||||
# Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
|
||||
# This allows using the maven wrapper in projects that prohibit checking in binary data.
|
||||
##########################################################################################
|
||||
if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then
|
||||
if [ "$MVNW_VERBOSE" = true ]; then
|
||||
echo "Found .mvn/wrapper/maven-wrapper.jar"
|
||||
fi
|
||||
else
|
||||
if [ "$MVNW_VERBOSE" = true ]; then
|
||||
echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..."
|
||||
fi
|
||||
if [ -n "$MVNW_REPOURL" ]; then
|
||||
jarUrl="$MVNW_REPOURL/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar"
|
||||
else
|
||||
jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar"
|
||||
fi
|
||||
while IFS="=" read key value; do
|
||||
case "$key" in (wrapperUrl) jarUrl="$value"; break ;;
|
||||
esac
|
||||
done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties"
|
||||
if [ "$MVNW_VERBOSE" = true ]; then
|
||||
echo "Downloading from: $jarUrl"
|
||||
fi
|
||||
wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar"
|
||||
if $cygwin; then
|
||||
wrapperJarPath=`cygpath --path --windows "$wrapperJarPath"`
|
||||
fi
|
||||
|
||||
if command -v wget > /dev/null; then
|
||||
if [ "$MVNW_VERBOSE" = true ]; then
|
||||
echo "Found wget ... using wget"
|
||||
fi
|
||||
if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then
|
||||
wget "$jarUrl" -O "$wrapperJarPath"
|
||||
else
|
||||
wget --http-user=$MVNW_USERNAME --http-password=$MVNW_PASSWORD "$jarUrl" -O "$wrapperJarPath"
|
||||
fi
|
||||
elif command -v curl > /dev/null; then
|
||||
if [ "$MVNW_VERBOSE" = true ]; then
|
||||
echo "Found curl ... using curl"
|
||||
fi
|
||||
if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then
|
||||
curl -o "$wrapperJarPath" "$jarUrl" -f
|
||||
else
|
||||
curl --user $MVNW_USERNAME:$MVNW_PASSWORD -o "$wrapperJarPath" "$jarUrl" -f
|
||||
fi
|
||||
|
||||
else
|
||||
if [ "$MVNW_VERBOSE" = true ]; then
|
||||
echo "Falling back to using Java to download"
|
||||
fi
|
||||
javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java"
|
||||
# For Cygwin, switch paths to Windows format before running javac
|
||||
if $cygwin; then
|
||||
javaClass=`cygpath --path --windows "$javaClass"`
|
||||
fi
|
||||
if [ -e "$javaClass" ]; then
|
||||
if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then
|
||||
if [ "$MVNW_VERBOSE" = true ]; then
|
||||
echo " - Compiling MavenWrapperDownloader.java ..."
|
||||
fi
|
||||
# Compiling the Java class
|
||||
("$JAVA_HOME/bin/javac" "$javaClass")
|
||||
fi
|
||||
if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then
|
||||
# Running the downloader
|
||||
if [ "$MVNW_VERBOSE" = true ]; then
|
||||
echo " - Running MavenWrapperDownloader.java ..."
|
||||
fi
|
||||
("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR")
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
##########################################################################################
|
||||
# End of extension
|
||||
##########################################################################################
|
||||
|
||||
export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"}
|
||||
if [ "$MVNW_VERBOSE" = true ]; then
|
||||
echo $MAVEN_PROJECTBASEDIR
|
||||
fi
|
||||
MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS"
|
||||
|
||||
# For Cygwin, switch paths to Windows format before running java
|
||||
if $cygwin; then
|
||||
[ -n "$M2_HOME" ] &&
|
||||
M2_HOME=`cygpath --path --windows "$M2_HOME"`
|
||||
[ -n "$JAVA_HOME" ] &&
|
||||
JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"`
|
||||
[ -n "$CLASSPATH" ] &&
|
||||
CLASSPATH=`cygpath --path --windows "$CLASSPATH"`
|
||||
[ -n "$MAVEN_PROJECTBASEDIR" ] &&
|
||||
MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"`
|
||||
fi
|
||||
|
||||
# Provide a "standardized" way to retrieve the CLI args that will
|
||||
# work with both Windows and non-Windows executions.
|
||||
MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@"
|
||||
export MAVEN_CMD_LINE_ARGS
|
||||
|
||||
WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
|
||||
|
||||
exec "$JAVACMD" \
|
||||
$MAVEN_OPTS \
|
||||
-classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \
|
||||
"-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \
|
||||
${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@"
|
182
mvnw.cmd
vendored
Normal file
182
mvnw.cmd
vendored
Normal file
@ -0,0 +1,182 @@
|
||||
@REM ----------------------------------------------------------------------------
|
||||
@REM Licensed to the Apache Software Foundation (ASF) under one
|
||||
@REM or more contributor license agreements. See the NOTICE file
|
||||
@REM distributed with this work for additional information
|
||||
@REM regarding copyright ownership. The ASF licenses this file
|
||||
@REM to you under the Apache License, Version 2.0 (the
|
||||
@REM "License"); you may not use this file except in compliance
|
||||
@REM with the License. You may obtain a copy of the License at
|
||||
@REM
|
||||
@REM https://www.apache.org/licenses/LICENSE-2.0
|
||||
@REM
|
||||
@REM Unless required by applicable law or agreed to in writing,
|
||||
@REM software distributed under the License is distributed on an
|
||||
@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
@REM KIND, either express or implied. See the License for the
|
||||
@REM specific language governing permissions and limitations
|
||||
@REM under the License.
|
||||
@REM ----------------------------------------------------------------------------
|
||||
|
||||
@REM ----------------------------------------------------------------------------
|
||||
@REM Maven Start Up Batch script
|
||||
@REM
|
||||
@REM Required ENV vars:
|
||||
@REM JAVA_HOME - location of a JDK home dir
|
||||
@REM
|
||||
@REM Optional ENV vars
|
||||
@REM M2_HOME - location of maven2's installed home dir
|
||||
@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands
|
||||
@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending
|
||||
@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven
|
||||
@REM e.g. to debug Maven itself, use
|
||||
@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
|
||||
@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files
|
||||
@REM ----------------------------------------------------------------------------
|
||||
|
||||
@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on'
|
||||
@echo off
|
||||
@REM set title of command window
|
||||
title %0
|
||||
@REM enable echoing by setting MAVEN_BATCH_ECHO to 'on'
|
||||
@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO%
|
||||
|
||||
@REM set %HOME% to equivalent of $HOME
|
||||
if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%")
|
||||
|
||||
@REM Execute a user defined script before this one
|
||||
if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre
|
||||
@REM check for pre script, once with legacy .bat ending and once with .cmd ending
|
||||
if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat"
|
||||
if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd"
|
||||
:skipRcPre
|
||||
|
||||
@setlocal
|
||||
|
||||
set ERROR_CODE=0
|
||||
|
||||
@REM To isolate internal variables from possible post scripts, we use another setlocal
|
||||
@setlocal
|
||||
|
||||
@REM ==== START VALIDATION ====
|
||||
if not "%JAVA_HOME%" == "" goto OkJHome
|
||||
|
||||
echo.
|
||||
echo Error: JAVA_HOME not found in your environment. >&2
|
||||
echo Please set the JAVA_HOME variable in your environment to match the >&2
|
||||
echo location of your Java installation. >&2
|
||||
echo.
|
||||
goto error
|
||||
|
||||
:OkJHome
|
||||
if exist "%JAVA_HOME%\bin\java.exe" goto init
|
||||
|
||||
echo.
|
||||
echo Error: JAVA_HOME is set to an invalid directory. >&2
|
||||
echo JAVA_HOME = "%JAVA_HOME%" >&2
|
||||
echo Please set the JAVA_HOME variable in your environment to match the >&2
|
||||
echo location of your Java installation. >&2
|
||||
echo.
|
||||
goto error
|
||||
|
||||
@REM ==== END VALIDATION ====
|
||||
|
||||
:init
|
||||
|
||||
@REM Find the project base dir, i.e. the directory that contains the folder ".mvn".
|
||||
@REM Fallback to current working directory if not found.
|
||||
|
||||
set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR%
|
||||
IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir
|
||||
|
||||
set EXEC_DIR=%CD%
|
||||
set WDIR=%EXEC_DIR%
|
||||
:findBaseDir
|
||||
IF EXIST "%WDIR%"\.mvn goto baseDirFound
|
||||
cd ..
|
||||
IF "%WDIR%"=="%CD%" goto baseDirNotFound
|
||||
set WDIR=%CD%
|
||||
goto findBaseDir
|
||||
|
||||
:baseDirFound
|
||||
set MAVEN_PROJECTBASEDIR=%WDIR%
|
||||
cd "%EXEC_DIR%"
|
||||
goto endDetectBaseDir
|
||||
|
||||
:baseDirNotFound
|
||||
set MAVEN_PROJECTBASEDIR=%EXEC_DIR%
|
||||
cd "%EXEC_DIR%"
|
||||
|
||||
:endDetectBaseDir
|
||||
|
||||
IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig
|
||||
|
||||
@setlocal EnableExtensions EnableDelayedExpansion
|
||||
for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a
|
||||
@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS%
|
||||
|
||||
:endReadAdditionalConfig
|
||||
|
||||
SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe"
|
||||
set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar"
|
||||
set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
|
||||
|
||||
set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar"
|
||||
|
||||
FOR /F "tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO (
|
||||
IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B
|
||||
)
|
||||
|
||||
@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
|
||||
@REM This allows using the maven wrapper in projects that prohibit checking in binary data.
|
||||
if exist %WRAPPER_JAR% (
|
||||
if "%MVNW_VERBOSE%" == "true" (
|
||||
echo Found %WRAPPER_JAR%
|
||||
)
|
||||
) else (
|
||||
if not "%MVNW_REPOURL%" == "" (
|
||||
SET DOWNLOAD_URL="%MVNW_REPOURL%/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar"
|
||||
)
|
||||
if "%MVNW_VERBOSE%" == "true" (
|
||||
echo Couldn't find %WRAPPER_JAR%, downloading it ...
|
||||
echo Downloading from: %DOWNLOAD_URL%
|
||||
)
|
||||
|
||||
powershell -Command "&{"^
|
||||
"$webclient = new-object System.Net.WebClient;"^
|
||||
"if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^
|
||||
"$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^
|
||||
"}"^
|
||||
"[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^
|
||||
"}"
|
||||
if "%MVNW_VERBOSE%" == "true" (
|
||||
echo Finished downloading %WRAPPER_JAR%
|
||||
)
|
||||
)
|
||||
@REM End of extension
|
||||
|
||||
@REM Provide a "standardized" way to retrieve the CLI args that will
|
||||
@REM work with both Windows and non-Windows executions.
|
||||
set MAVEN_CMD_LINE_ARGS=%*
|
||||
|
||||
%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %*
|
||||
if ERRORLEVEL 1 goto error
|
||||
goto end
|
||||
|
||||
:error
|
||||
set ERROR_CODE=1
|
||||
|
||||
:end
|
||||
@endlocal & set ERROR_CODE=%ERROR_CODE%
|
||||
|
||||
if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost
|
||||
@REM check for post script, once with legacy .bat ending and once with .cmd ending
|
||||
if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat"
|
||||
if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd"
|
||||
:skipRcPost
|
||||
|
||||
@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on'
|
||||
if "%MAVEN_BATCH_PAUSE%" == "on" pause
|
||||
|
||||
if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE%
|
||||
|
||||
exit /B %ERROR_CODE%
|
120
pom.xml
Normal file
120
pom.xml
Normal file
@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
<version>2.3.1.RELEASE</version>
|
||||
<relativePath/> <!-- lookup parent from repository -->
|
||||
</parent>
|
||||
<groupId>me.minidigger</groupId>
|
||||
<artifactId>hangar</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<name>hangar</name>
|
||||
<description>Ore, but in Spring</description>
|
||||
|
||||
<properties>
|
||||
<java.version>11</java.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-actuator</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-data-jdbc</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-mail</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-security</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-thymeleaf</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-tomcat</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!--SpringFox dependencies -->
|
||||
<dependency>
|
||||
<groupId>io.springfox</groupId>
|
||||
<artifactId>springfox-swagger2</artifactId>
|
||||
<version>2.9.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.springfox</groupId>
|
||||
<artifactId>springfox-swagger-ui</artifactId>
|
||||
<version>2.9.2</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.github.joschi.jackson</groupId>
|
||||
<artifactId>jackson-datatype-threetenbp</artifactId>
|
||||
<version>2.6.4</version>
|
||||
</dependency>
|
||||
<!-- Bean Validation API support -->
|
||||
<dependency>
|
||||
<groupId>javax.validation</groupId>
|
||||
<artifactId>validation-api</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- runtime -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-devtools</artifactId>
|
||||
<scope>runtime</scope>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.postgresql</groupId>
|
||||
<artifactId>postgresql</artifactId>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-configuration-processor</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
|
||||
<!-- test -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.junit.vintage</groupId>
|
||||
<artifactId>junit-vintage-engine</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.security</groupId>
|
||||
<artifactId>spring-security-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
13
src/main/java/me/minidigger/hangar/HangarApplication.java
Normal file
13
src/main/java/me/minidigger/hangar/HangarApplication.java
Normal file
@ -0,0 +1,13 @@
|
||||
package me.minidigger.hangar;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
@SpringBootApplication
|
||||
public class HangarApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(HangarApplication.class, args);
|
||||
}
|
||||
|
||||
}
|
40
src/main/java/me/minidigger/hangar/api/AuthenticateApi.java
Normal file
40
src/main/java/me/minidigger/hangar/api/AuthenticateApi.java
Normal file
@ -0,0 +1,40 @@
|
||||
package me.minidigger.hangar.api;
|
||||
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
|
||||
import javax.validation.Valid;
|
||||
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import io.swagger.annotations.ApiParam;
|
||||
import io.swagger.annotations.ApiResponse;
|
||||
import io.swagger.annotations.ApiResponses;
|
||||
import io.swagger.annotations.Authorization;
|
||||
import me.minidigger.hangar.model.SessionProperties;
|
||||
import me.minidigger.hangar.model.ApiSession;
|
||||
|
||||
@Api(value = "authenticate", description = "the authenticate API", tags = "Sessions (Authentication)")
|
||||
public interface AuthenticateApi {
|
||||
|
||||
@ApiOperation(value = "Creates an API session", nickname = "authenticate", notes = "Creates a new API session. Pass an API key to create an authenticated session. To create a public session, don't pass an Authorization header. When passing an API key, you should use the scheme `HangarApi`, and parameter `apikey`. An example would be `Authorization: HangarApi apikey=\"foobar\"`. The returned session should be specified in all following request as the parameter `session`. An example would be `Authorization: HangarApi session=\"noisses\"`", response = ApiSession.class, authorizations = {
|
||||
@Authorization(value = "Key")}, tags = "Sessions (Authentication)")
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(code = 200, message = "Ok", response = ApiSession.class),
|
||||
@ApiResponse(code = 400, message = "Sent if the requested expiration can't be used."),
|
||||
@ApiResponse(code = 401, message = "Api key missing or invalid")})
|
||||
@PostMapping(value = "/authenticate",
|
||||
produces = MediaType.APPLICATION_JSON_VALUE,
|
||||
consumes = MediaType.APPLICATION_JSON_VALUE)
|
||||
ResponseEntity<ApiSession> authenticate(@ApiParam(value = "") @Valid @RequestBody SessionProperties body
|
||||
);
|
||||
|
||||
@ApiOperation(value = "authenticateUser", hidden = true)
|
||||
@PostMapping(value = "/authenticate/user",
|
||||
produces = MediaType.APPLICATION_JSON_VALUE,
|
||||
consumes = MediaType.APPLICATION_JSON_VALUE)
|
||||
ResponseEntity<ApiSession> authenticateUser(@ApiParam(value = "") @Valid @RequestBody SessionProperties body
|
||||
);
|
||||
}
|
@ -0,0 +1,62 @@
|
||||
package me.minidigger.hangar.api;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Controller;
|
||||
|
||||
import java.io.IOException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import me.minidigger.hangar.model.ApiSession;
|
||||
import me.minidigger.hangar.model.SessionProperties;
|
||||
|
||||
@Controller
|
||||
public class AuthenticateApiController implements AuthenticateApi {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(AuthenticateApiController.class);
|
||||
|
||||
private final ObjectMapper objectMapper;
|
||||
|
||||
private final HttpServletRequest request;
|
||||
|
||||
@Autowired
|
||||
public AuthenticateApiController(ObjectMapper objectMapper, HttpServletRequest request) {
|
||||
this.objectMapper = objectMapper;
|
||||
this.request = request;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity<ApiSession> authenticate(SessionProperties body) {
|
||||
String accept = request.getHeader("Accept");
|
||||
if (accept != null && accept.contains("application/json")) {
|
||||
try {
|
||||
return new ResponseEntity<>(objectMapper.readValue("{\n \"expires\" : \"2000-01-23T04:56:07.000+00:00\",\n \"session\" : \"session\",\n \"type\" : \"key\"\n}", ApiSession.class), HttpStatus.NOT_IMPLEMENTED);
|
||||
} catch (IOException e) {
|
||||
log.error("Couldn't serialize response for content type application/json", e);
|
||||
return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity<ApiSession> authenticateUser(SessionProperties body) {
|
||||
String accept = request.getHeader("Accept");
|
||||
if (accept != null && accept.contains("application/json")) {
|
||||
try {
|
||||
return new ResponseEntity<>(objectMapper.readValue("{\n \"expires\" : \"2000-01-23T04:56:07.000+00:00\",\n \"session\" : \"session\",\n \"type\" : \"key\"\n}", ApiSession.class), HttpStatus.NOT_IMPLEMENTED);
|
||||
} catch (IOException e) {
|
||||
log.error("Couldn't serialize response for content type application/json", e);
|
||||
return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||
}
|
||||
}
|
48
src/main/java/me/minidigger/hangar/api/KeysApi.java
Normal file
48
src/main/java/me/minidigger/hangar/api/KeysApi.java
Normal file
@ -0,0 +1,48 @@
|
||||
package me.minidigger.hangar.api;
|
||||
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import io.swagger.annotations.ApiParam;
|
||||
import io.swagger.annotations.ApiResponse;
|
||||
import io.swagger.annotations.ApiResponses;
|
||||
import io.swagger.annotations.Authorization;
|
||||
import me.minidigger.hangar.model.ApiKeyResponse;
|
||||
import me.minidigger.hangar.model.ApiKeyRequest;
|
||||
|
||||
@Api(value = "keys", description = "the keys API", tags = "Keys")
|
||||
public interface KeysApi {
|
||||
|
||||
@ApiOperation(value = "Creates an API key", nickname = "createKey", notes = "Creates an API key. Requires the `edit_api_keys` permission.", response = ApiKeyResponse.class, authorizations = {
|
||||
@Authorization(value = "Session")}, tags = "Keys")
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(code = 200, message = "Ok", response = ApiKeyResponse.class),
|
||||
@ApiResponse(code = 401, message = "Api session missing, invalid or expired"),
|
||||
@ApiResponse(code = 403, message = "Not enough permissions to use this endpoint")})
|
||||
@PostMapping(value = "/keys",
|
||||
produces = MediaType.APPLICATION_JSON_VALUE,
|
||||
consumes = MediaType.APPLICATION_JSON_VALUE)
|
||||
ResponseEntity<ApiKeyResponse> createKey(@ApiParam(value = "", required = true) @Valid @RequestBody ApiKeyRequest body
|
||||
);
|
||||
|
||||
|
||||
@ApiOperation(value = "Delete an API key", nickname = "deleteKey", notes = "Delete an API key. Requires the `edit_api_keys` permission.", authorizations = {
|
||||
@Authorization(value = "Session")}, tags = "Keys")
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(code = 204, message = "Key deleted"),
|
||||
@ApiResponse(code = 401, message = "Api session missing, invalid or expired"),
|
||||
@ApiResponse(code = 403, message = "Not enough permissions to use this endpoint")})
|
||||
@DeleteMapping(value = "/keys")
|
||||
ResponseEntity<Void> deleteKey(@NotNull @ApiParam(value = "The name of the key to delete", required = true) @Valid @RequestParam("name") String name
|
||||
);
|
||||
|
||||
}
|
@ -0,0 +1,54 @@
|
||||
package me.minidigger.hangar.api;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Controller;
|
||||
|
||||
import java.io.IOException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import me.minidigger.hangar.model.ApiKeyRequest;
|
||||
import me.minidigger.hangar.model.ApiKeyResponse;
|
||||
|
||||
@Controller
|
||||
public class KeysApiController implements KeysApi {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(KeysApiController.class);
|
||||
|
||||
private final ObjectMapper objectMapper;
|
||||
|
||||
private final HttpServletRequest request;
|
||||
|
||||
@Autowired
|
||||
public KeysApiController(ObjectMapper objectMapper, HttpServletRequest request) {
|
||||
this.objectMapper = objectMapper;
|
||||
this.request = request;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity<ApiKeyResponse> createKey(ApiKeyRequest body) {
|
||||
String accept = request.getHeader("Accept");
|
||||
if (accept != null && accept.contains("application/json")) {
|
||||
try {
|
||||
return new ResponseEntity<>(objectMapper.readValue("{\n \"perms\" : [ \"view_public_info\", \"view_public_info\" ],\n \"key\" : \"key\"\n}", ApiKeyResponse.class), HttpStatus.NOT_IMPLEMENTED);
|
||||
} catch (IOException e) {
|
||||
log.error("Couldn't serialize response for content type application/json", e);
|
||||
return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity<Void> deleteKey(String name) {
|
||||
String accept = request.getHeader("Accept");
|
||||
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
}
|
62
src/main/java/me/minidigger/hangar/api/PermissionsApi.java
Normal file
62
src/main/java/me/minidigger/hangar/api/PermissionsApi.java
Normal file
@ -0,0 +1,62 @@
|
||||
package me.minidigger.hangar.api;
|
||||
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
import java.util.List;
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import io.swagger.annotations.ApiParam;
|
||||
import io.swagger.annotations.ApiResponse;
|
||||
import io.swagger.annotations.ApiResponses;
|
||||
import io.swagger.annotations.Authorization;
|
||||
import me.minidigger.hangar.model.Permissions;
|
||||
import me.minidigger.hangar.model.PermissionCheck;
|
||||
import me.minidigger.hangar.model.NamedPermission;
|
||||
|
||||
@Api(value = "permissions", description = "the permissions API", tags = "Permissions")
|
||||
public interface PermissionsApi {
|
||||
|
||||
@ApiOperation(value = "Do an AND permission check", nickname = "hasAll", notes = "Checks that you have all the permissions passed in with a given session in a given context", response = PermissionCheck.class, authorizations = {
|
||||
@Authorization(value = "Session")}, tags = "Permissions")
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(code = 200, message = "Ok", response = PermissionCheck.class),
|
||||
@ApiResponse(code = 401, message = "Api session missing, invalid or expired")})
|
||||
@GetMapping(value = "/permissions/hasAll",
|
||||
produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
ResponseEntity<PermissionCheck> hasAll(@NotNull @ApiParam(value = "The permissions to check", required = true) @Valid @RequestParam(value = "permissions", required = true) List<NamedPermission> permissions
|
||||
, @ApiParam(value = "The plugin to check permissions in. Must not be used together with `organizationName`") @Valid @RequestParam(value = "pluginId", required = false) String pluginId
|
||||
, @ApiParam(value = "The organization to check permissions in. Must not be used together with `pluginId`") @Valid @RequestParam(value = "organizationName", required = false) String organizationName
|
||||
);
|
||||
|
||||
|
||||
@ApiOperation(value = "Do an OR permission check", nickname = "hasAny", notes = "Checks that you have any of the permissions passed in with a given session in a given context", response = PermissionCheck.class, authorizations = {
|
||||
@Authorization(value = "Session")}, tags = "Permissions")
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(code = 200, message = "Ok", response = PermissionCheck.class),
|
||||
@ApiResponse(code = 401, message = "Api session missing, invalid or expired")})
|
||||
@GetMapping(value = "/permissions/hasAny",
|
||||
produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
ResponseEntity<PermissionCheck> hasAny(@NotNull @ApiParam(value = "The permissions to check", required = true) @Valid @RequestParam(value = "permissions", required = true) List<NamedPermission> permissions
|
||||
, @ApiParam(value = "The plugin to check permissions in. Must not be used together with `organizationName`") @Valid @RequestParam(value = "pluginId", required = false) String pluginId
|
||||
, @ApiParam(value = "The organization to check permissions in. Must not be used together with `pluginId`") @Valid @RequestParam(value = "organizationName", required = false) String organizationName
|
||||
);
|
||||
|
||||
|
||||
@ApiOperation(value = "Checks your permissions", nickname = "showPermissions", notes = "Checks your permissions with a given session in a given context", response = Permissions.class, authorizations = {
|
||||
@Authorization(value = "Session")}, tags = "Permissions")
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(code = 200, message = "Ok", response = Permissions.class),
|
||||
@ApiResponse(code = 401, message = "Api session missing, invalid or expired")})
|
||||
@GetMapping(value = "/permissions",
|
||||
produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
ResponseEntity<Permissions> showPermissions(@ApiParam(value = "The plugin to check permissions in. Must not be used together with `organizationName`") @Valid @RequestParam(value = "pluginId", required = false) String pluginId
|
||||
, @ApiParam(value = "The organization to check permissions in. Must not be used together with `pluginId`") @Valid @RequestParam(value = "organizationName", required = false) String organizationName
|
||||
);
|
||||
|
||||
}
|
@ -0,0 +1,81 @@
|
||||
package me.minidigger.hangar.api;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Controller;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import me.minidigger.hangar.model.NamedPermission;
|
||||
import me.minidigger.hangar.model.PermissionCheck;
|
||||
import me.minidigger.hangar.model.Permissions;
|
||||
|
||||
@Controller
|
||||
public class PermissionsApiController implements PermissionsApi {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(PermissionsApiController.class);
|
||||
|
||||
private final ObjectMapper objectMapper;
|
||||
|
||||
private final HttpServletRequest request;
|
||||
|
||||
@Autowired
|
||||
public PermissionsApiController(ObjectMapper objectMapper, HttpServletRequest request) {
|
||||
this.objectMapper = objectMapper;
|
||||
this.request = request;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity<PermissionCheck> hasAll(List<NamedPermission> permissions, String pluginId, String organizationName
|
||||
) {
|
||||
String accept = request.getHeader("Accept");
|
||||
if (accept != null && accept.contains("application/json")) {
|
||||
try {
|
||||
return new ResponseEntity<>(objectMapper.readValue("{\n \"result\" : true,\n \"type\" : \"global\"\n}", PermissionCheck.class), HttpStatus.NOT_IMPLEMENTED);
|
||||
} catch (IOException e) {
|
||||
log.error("Couldn't serialize response for content type application/json", e);
|
||||
return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity<PermissionCheck> hasAny(List<NamedPermission> permissions, String pluginId, String organizationName) {
|
||||
String accept = request.getHeader("Accept");
|
||||
if (accept != null && accept.contains("application/json")) {
|
||||
try {
|
||||
return new ResponseEntity<>(objectMapper.readValue("{\n \"result\" : true,\n \"type\" : \"global\"\n}", PermissionCheck.class), HttpStatus.NOT_IMPLEMENTED);
|
||||
} catch (IOException e) {
|
||||
log.error("Couldn't serialize response for content type application/json", e);
|
||||
return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity<Permissions> showPermissions(String pluginId, String organizationName) {
|
||||
String accept = request.getHeader("Accept");
|
||||
if (accept != null && accept.contains("application/json")) {
|
||||
try {
|
||||
return new ResponseEntity<>(objectMapper.readValue("{\n \"permissions\" : [ \"view_public_info\", \"view_public_info\" ],\n \"type\" : \"global\"\n}", Permissions.class), HttpStatus.NOT_IMPLEMENTED);
|
||||
} catch (IOException e) {
|
||||
log.error("Couldn't serialize response for content type application/json", e);
|
||||
return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
}
|
85
src/main/java/me/minidigger/hangar/api/ProjectsApi.java
Normal file
85
src/main/java/me/minidigger/hangar/api/ProjectsApi.java
Normal file
@ -0,0 +1,85 @@
|
||||
package me.minidigger.hangar.api;
|
||||
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.threeten.bp.LocalDate;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import io.swagger.annotations.ApiParam;
|
||||
import io.swagger.annotations.ApiResponse;
|
||||
import io.swagger.annotations.ApiResponses;
|
||||
import io.swagger.annotations.Authorization;
|
||||
import me.minidigger.hangar.model.Category;
|
||||
import me.minidigger.hangar.model.PaginatedProjectResult;
|
||||
import me.minidigger.hangar.model.Project;
|
||||
import me.minidigger.hangar.model.ProjectMember;
|
||||
import me.minidigger.hangar.model.ProjectStatsDay;
|
||||
import me.minidigger.hangar.model.ProjectSortingStrategy;
|
||||
|
||||
@Api(value = "projects", description = "the projects API", tags = "Projects")
|
||||
public interface ProjectsApi {
|
||||
|
||||
@ApiOperation(value = "Searches the projects on Ore", nickname = "listProjects", notes = "Searches all the projects on ore, or for a single user. Requires the `view_public_info` permission.", response = PaginatedProjectResult.class, authorizations = {
|
||||
@Authorization(value = "Session")}, tags = "Projects")
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(code = 200, message = "Ok", response = PaginatedProjectResult.class),
|
||||
@ApiResponse(code = 401, message = "Api session missing, invalid or expired"),
|
||||
@ApiResponse(code = 403, message = "Not enough permissions to use this endpoint")})
|
||||
@GetMapping(value = "/projects",
|
||||
produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
ResponseEntity<PaginatedProjectResult> listProjects(@ApiParam(value = "The query to use when searching") @Valid @RequestParam(value = "q", required = false) String q
|
||||
, @ApiParam(value = "Restrict your search to a list of categories") @Valid @RequestParam(value = "categories", required = false) List<Category> categories
|
||||
, @ApiParam(value = "A list of tags all the returned projects should have. Should be formated either as `tagname` or `tagname:tagdata`.") @Valid @RequestParam(value = "tags", required = false) List<String> tags
|
||||
, @ApiParam(value = "Limit the search to a specific user") @Valid @RequestParam(value = "owner", required = false) String owner
|
||||
, @ApiParam(value = "How to sort the projects") @Valid @RequestParam(value = "sort", required = false) ProjectSortingStrategy sort
|
||||
, @ApiParam(value = "If how relevant the project is to the given query should be used when sorting the projects") @Valid @RequestParam(value = "relevance", required = false) Boolean relevance
|
||||
, @ApiParam(value = "The maximum amount of projects to return") @Valid @RequestParam(value = "limit", required = false) Long limit
|
||||
, @ApiParam(value = "Where to start searching", defaultValue = "0") @Valid @RequestParam(value = "offset", required = false, defaultValue = "0") Long offset
|
||||
);
|
||||
|
||||
@ApiOperation(value = "Returns the members of a project", nickname = "showMembers", notes = "Returns the members of a project. Requires the `view_public_info` permission.", response = ProjectMember.class, authorizations = {
|
||||
@Authorization(value = "Session")}, tags = "Projects")
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(code = 200, message = "Ok", response = ProjectMember.class),
|
||||
@ApiResponse(code = 401, message = "Api session missing, invalid or expired"),
|
||||
@ApiResponse(code = 403, message = "Not enough permissions to use this endpoint")})
|
||||
@GetMapping(value = "/projects/{pluginId}/members",
|
||||
produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
ResponseEntity<ProjectMember> showMembers(@ApiParam(value = "The plugin id of the project to return members for", required = true) @PathVariable("pluginId") String pluginId
|
||||
, @ApiParam(value = "The maximum amount of members to return") @Valid @RequestParam(value = "limit", required = false) Long limit
|
||||
, @ApiParam(value = "Where to start returning", defaultValue = "0") @Valid @RequestParam(value = "offset", required = false, defaultValue = "0") Long offset
|
||||
);
|
||||
|
||||
@ApiOperation(value = "Returns info on a specific project", nickname = "showProject", notes = "Returns info on a specific project. Requires the `view_public_info` permission.", response = Project.class, authorizations = {
|
||||
@Authorization(value = "Session")}, tags = "Projects")
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(code = 200, message = "Ok", response = Project.class),
|
||||
@ApiResponse(code = 401, message = "Api session missing, invalid or expired"),
|
||||
@ApiResponse(code = 403, message = "Not enough permissions to use this endpoint")})
|
||||
@GetMapping(value = "/projects/{pluginId}",
|
||||
produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
ResponseEntity<Project> showProject(@ApiParam(value = "The plugin id of the project to return", required = true) @PathVariable("pluginId") String pluginId
|
||||
);
|
||||
|
||||
@ApiOperation(value = "Returns the stats for a project", nickname = "showProjectStats", notes = "Returns the stats(downloads, views) for a project per day for a certain date range. Requires the `is_subject_member` permission.", response = ProjectStatsDay.class, responseContainer = "Map", authorizations = {
|
||||
@Authorization(value = "Session")}, tags = "Projects")
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(code = 200, message = "Ok", response = ProjectStatsDay.class, responseContainer = "Map"),
|
||||
@ApiResponse(code = 401, message = "Api session missing, invalid or expired"),
|
||||
@ApiResponse(code = 403, message = "Not enough permissions to use this endpoint")})
|
||||
@GetMapping(value = "/projects/{pluginId}/stats",
|
||||
produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
ResponseEntity<Map<String, ProjectStatsDay>> showProjectStats(@ApiParam(value = "The plugin id of the project to return the stats for", required = true) @PathVariable("pluginId") String pluginId
|
||||
, @NotNull @ApiParam(value = "The first date to include in the result", required = true) @Valid @RequestParam(value = "fromDate", required = true) LocalDate fromDate
|
||||
, @NotNull @ApiParam(value = "The last date to include in the result", required = true) @Valid @RequestParam(value = "toDate", required = true) LocalDate toDate
|
||||
);
|
||||
}
|
@ -0,0 +1,100 @@
|
||||
package me.minidigger.hangar.api;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.threeten.bp.LocalDate;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import me.minidigger.hangar.model.Category;
|
||||
import me.minidigger.hangar.model.PaginatedProjectResult;
|
||||
import me.minidigger.hangar.model.Project;
|
||||
import me.minidigger.hangar.model.ProjectMember;
|
||||
import me.minidigger.hangar.model.ProjectSortingStrategy;
|
||||
import me.minidigger.hangar.model.ProjectStatsDay;
|
||||
|
||||
@Controller
|
||||
public class ProjectsApiController implements ProjectsApi {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(ProjectsApiController.class);
|
||||
|
||||
private final ObjectMapper objectMapper;
|
||||
|
||||
private final HttpServletRequest request;
|
||||
|
||||
@Autowired
|
||||
public ProjectsApiController(ObjectMapper objectMapper, HttpServletRequest request) {
|
||||
this.objectMapper = objectMapper;
|
||||
this.request = request;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity<PaginatedProjectResult> listProjects(String q, List<Category> categories, List<String> tags, String owner, ProjectSortingStrategy sort, Boolean relevance, Long limit, Long offset) {
|
||||
String accept = request.getHeader("Accept");
|
||||
if (accept != null && accept.contains("application/json")) {
|
||||
try {
|
||||
return new ResponseEntity<>(objectMapper.readValue("{\n \"result\" : [ {\n \"icon_url\" : \"icon_url\",\n \"plugin_id\" : \"plugin_id\",\n \"settings\" : {\n \"license\" : {\n \"name\" : \"name\",\n \"url\" : \"url\"\n },\n \"sources\" : \"sources\",\n \"forum_sync\" : true,\n \"issues\" : \"issues\",\n \"support\" : \"support\",\n \"homepage\" : \"homepage\"\n },\n \"last_updated\" : \"2000-01-23T04:56:07.000+00:00\",\n \"visibility\" : \"public\",\n \"user_actions\" : {\n \"starred\" : true,\n \"watching\" : true\n },\n \"created_at\" : \"2000-01-23T04:56:07.000+00:00\",\n \"description\" : \"description\",\n \"promoted_versions\" : [ {\n \"version\" : \"version\",\n \"tags\" : [ {\n \"data\" : \"data\",\n \"color\" : {\n \"background\" : \"background\",\n \"foreground\" : \"foreground\"\n },\n \"name\" : \"name\",\n \"display_data\" : \"display_data\",\n \"minecraft_version\" : \"minecraft_version\"\n }, {\n \"data\" : \"data\",\n \"color\" : {\n \"background\" : \"background\",\n \"foreground\" : \"foreground\"\n },\n \"name\" : \"name\",\n \"display_data\" : \"display_data\",\n \"minecraft_version\" : \"minecraft_version\"\n } ]\n }, {\n \"version\" : \"version\",\n \"tags\" : [ {\n \"data\" : \"data\",\n \"color\" : {\n \"background\" : \"background\",\n \"foreground\" : \"foreground\"\n },\n \"name\" : \"name\",\n \"display_data\" : \"display_data\",\n \"minecraft_version\" : \"minecraft_version\"\n }, {\n \"data\" : \"data\",\n \"color\" : {\n \"background\" : \"background\",\n \"foreground\" : \"foreground\"\n },\n \"name\" : \"name\",\n \"display_data\" : \"display_data\",\n \"minecraft_version\" : \"minecraft_version\"\n } ]\n } ],\n \"stats\" : {\n \"downloads\" : 5,\n \"recent_downloads\" : 7,\n \"recent_views\" : 2,\n \"watchers\" : 3,\n \"stars\" : 9,\n \"views\" : 5\n },\n \"name\" : \"name\",\n \"namespace\" : {\n \"owner\" : \"owner\",\n \"slug\" : \"slug\"\n },\n \"category\" : \"admin_tools\"\n }, {\n \"icon_url\" : \"icon_url\",\n \"plugin_id\" : \"plugin_id\",\n \"settings\" : {\n \"license\" : {\n \"name\" : \"name\",\n \"url\" : \"url\"\n },\n \"sources\" : \"sources\",\n \"forum_sync\" : true,\n \"issues\" : \"issues\",\n \"support\" : \"support\",\n \"homepage\" : \"homepage\"\n },\n \"last_updated\" : \"2000-01-23T04:56:07.000+00:00\",\n \"visibility\" : \"public\",\n \"user_actions\" : {\n \"starred\" : true,\n \"watching\" : true\n },\n \"created_at\" : \"2000-01-23T04:56:07.000+00:00\",\n \"description\" : \"description\",\n \"promoted_versions\" : [ {\n \"version\" : \"version\",\n \"tags\" : [ {\n \"data\" : \"data\",\n \"color\" : {\n \"background\" : \"background\",\n \"foreground\" : \"foreground\"\n },\n \"name\" : \"name\",\n \"display_data\" : \"display_data\",\n \"minecraft_version\" : \"minecraft_version\"\n }, {\n \"data\" : \"data\",\n \"color\" : {\n \"background\" : \"background\",\n \"foreground\" : \"foreground\"\n },\n \"name\" : \"name\",\n \"display_data\" : \"display_data\",\n \"minecraft_version\" : \"minecraft_version\"\n } ]\n }, {\n \"version\" : \"version\",\n \"tags\" : [ {\n \"data\" : \"data\",\n \"color\" : {\n \"background\" : \"background\",\n \"foreground\" : \"foreground\"\n },\n \"name\" : \"name\",\n \"display_data\" : \"display_data\",\n \"minecraft_version\" : \"minecraft_version\"\n }, {\n \"data\" : \"data\",\n \"color\" : {\n \"background\" : \"background\",\n \"foreground\" : \"foreground\"\n },\n \"name\" : \"name\",\n \"display_data\" : \"display_data\",\n \"minecraft_version\" : \"minecraft_version\"\n } ]\n } ],\n \"stats\" : {\n \"downloads\" : 5,\n \"recent_downloads\" : 7,\n \"recent_views\" : 2,\n \"watchers\" : 3,\n \"stars\" : 9,\n \"views\" : 5\n },\n \"name\" : \"name\",\n \"namespace\" : {\n \"owner\" : \"owner\",\n \"slug\" : \"slug\"\n },\n \"category\" : \"admin_tools\"\n } ],\n \"pagination\" : {\n \"offset\" : 6,\n \"limit\" : 0,\n \"count\" : 1\n }\n}", PaginatedProjectResult.class), HttpStatus.NOT_IMPLEMENTED);
|
||||
} catch (IOException e) {
|
||||
log.error("Couldn't serialize response for content type application/json", e);
|
||||
return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity<ProjectMember> showMembers(String pluginId, Long limit, Long offset) {
|
||||
String accept = request.getHeader("Accept");
|
||||
if (accept != null && accept.contains("application/json")) {
|
||||
try {
|
||||
return new ResponseEntity<>(objectMapper.readValue("{\n \"roles\" : [ {\n \"color\" : \"color\",\n \"name\" : \"name\",\n \"title\" : \"title\"\n }, {\n \"color\" : \"color\",\n \"name\" : \"name\",\n \"title\" : \"title\"\n } ],\n \"user\" : \"user\"\n}", ProjectMember.class), HttpStatus.NOT_IMPLEMENTED);
|
||||
} catch (IOException e) {
|
||||
log.error("Couldn't serialize response for content type application/json", e);
|
||||
return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity<Project> showProject(String pluginId) {
|
||||
String accept = request.getHeader("Accept");
|
||||
if (accept != null && accept.contains("application/json")) {
|
||||
try {
|
||||
return new ResponseEntity<>(objectMapper.readValue("{\n \"icon_url\" : \"icon_url\",\n \"plugin_id\" : \"plugin_id\",\n \"settings\" : {\n \"license\" : {\n \"name\" : \"name\",\n \"url\" : \"url\"\n },\n \"sources\" : \"sources\",\n \"forum_sync\" : true,\n \"issues\" : \"issues\",\n \"support\" : \"support\",\n \"homepage\" : \"homepage\"\n },\n \"last_updated\" : \"2000-01-23T04:56:07.000+00:00\",\n \"visibility\" : \"public\",\n \"user_actions\" : {\n \"starred\" : true,\n \"watching\" : true\n },\n \"created_at\" : \"2000-01-23T04:56:07.000+00:00\",\n \"description\" : \"description\",\n \"promoted_versions\" : [ {\n \"version\" : \"version\",\n \"tags\" : [ {\n \"data\" : \"data\",\n \"color\" : {\n \"background\" : \"background\",\n \"foreground\" : \"foreground\"\n },\n \"name\" : \"name\",\n \"display_data\" : \"display_data\",\n \"minecraft_version\" : \"minecraft_version\"\n }, {\n \"data\" : \"data\",\n \"color\" : {\n \"background\" : \"background\",\n \"foreground\" : \"foreground\"\n },\n \"name\" : \"name\",\n \"display_data\" : \"display_data\",\n \"minecraft_version\" : \"minecraft_version\"\n } ]\n }, {\n \"version\" : \"version\",\n \"tags\" : [ {\n \"data\" : \"data\",\n \"color\" : {\n \"background\" : \"background\",\n \"foreground\" : \"foreground\"\n },\n \"name\" : \"name\",\n \"display_data\" : \"display_data\",\n \"minecraft_version\" : \"minecraft_version\"\n }, {\n \"data\" : \"data\",\n \"color\" : {\n \"background\" : \"background\",\n \"foreground\" : \"foreground\"\n },\n \"name\" : \"name\",\n \"display_data\" : \"display_data\",\n \"minecraft_version\" : \"minecraft_version\"\n } ]\n } ],\n \"stats\" : {\n \"downloads\" : 5,\n \"recent_downloads\" : 7,\n \"recent_views\" : 2,\n \"watchers\" : 3,\n \"stars\" : 9,\n \"views\" : 5\n },\n \"name\" : \"name\",\n \"namespace\" : {\n \"owner\" : \"owner\",\n \"slug\" : \"slug\"\n },\n \"category\" : \"admin_tools\"\n}", Project.class), HttpStatus.NOT_IMPLEMENTED);
|
||||
} catch (IOException e) {
|
||||
log.error("Couldn't serialize response for content type application/json", e);
|
||||
return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity<Map<String, ProjectStatsDay>> showProjectStats(String pluginId, LocalDate fromDate, LocalDate toDate) {
|
||||
String accept = request.getHeader("Accept");
|
||||
if (accept != null && accept.contains("application/json")) {
|
||||
try {
|
||||
return new ResponseEntity<Map<String, ProjectStatsDay>>(objectMapper.readValue("{\n \"key\" : {\n \"downloads\" : 0,\n \"views\" : 6\n }\n}", Map.class), HttpStatus.NOT_IMPLEMENTED);
|
||||
} catch (IOException e) {
|
||||
log.error("Couldn't serialize response for content type application/json", e);
|
||||
return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
}
|
27
src/main/java/me/minidigger/hangar/api/SessionsApi.java
Normal file
27
src/main/java/me/minidigger/hangar/api/SessionsApi.java
Normal file
@ -0,0 +1,27 @@
|
||||
package me.minidigger.hangar.api;
|
||||
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import io.swagger.annotations.ApiResponse;
|
||||
import io.swagger.annotations.ApiResponses;
|
||||
import io.swagger.annotations.Authorization;
|
||||
|
||||
@Api(value = "sessions", description = "the sessions API", tags = "Sessions (Authentication)")
|
||||
public interface SessionsApi {
|
||||
|
||||
@ApiOperation(value = "Invalidates the API session used for the request.", nickname = "deleteSession", notes = "Invalidates the API session used to make this call.", authorizations = {
|
||||
@Authorization(value = "Session")}, tags = {"Sessions (Authentication)",})
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(code = 204, message = "Session invalidated"),
|
||||
@ApiResponse(code = 400, message = "Sent if this request was not made with a session."),
|
||||
@ApiResponse(code = 401, message = "Api session missing, invalid or expired"),
|
||||
@ApiResponse(code = 403, message = "Not enough permissions to use this endpoint")})
|
||||
@RequestMapping(value = "/sessions/current",
|
||||
method = RequestMethod.DELETE)
|
||||
ResponseEntity<Void> deleteSession();
|
||||
|
||||
}
|
@ -0,0 +1,35 @@
|
||||
package me.minidigger.hangar.api;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Controller;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
@Controller
|
||||
public class SessionsApiController implements SessionsApi {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(SessionsApiController.class);
|
||||
|
||||
private final ObjectMapper objectMapper;
|
||||
|
||||
private final HttpServletRequest request;
|
||||
|
||||
@Autowired
|
||||
public SessionsApiController(ObjectMapper objectMapper, HttpServletRequest request) {
|
||||
this.objectMapper = objectMapper;
|
||||
this.request = request;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity<Void> deleteSession() {
|
||||
String accept = request.getHeader("Accept");
|
||||
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
}
|
68
src/main/java/me/minidigger/hangar/api/UsersApi.java
Normal file
68
src/main/java/me/minidigger/hangar/api/UsersApi.java
Normal file
@ -0,0 +1,68 @@
|
||||
package me.minidigger.hangar.api;
|
||||
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
import javax.validation.Valid;
|
||||
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import io.swagger.annotations.ApiParam;
|
||||
import io.swagger.annotations.ApiResponse;
|
||||
import io.swagger.annotations.ApiResponses;
|
||||
import io.swagger.annotations.Authorization;
|
||||
import me.minidigger.hangar.model.PaginatedCompactProjectResult;
|
||||
import me.minidigger.hangar.model.User;
|
||||
import me.minidigger.hangar.model.ProjectSortingStrategy;
|
||||
|
||||
@Api(value = "users", description = "the users API", tags = {"Users"})
|
||||
public interface UsersApi {
|
||||
|
||||
@ApiOperation(value = "Gets the starred projects for a specific user", nickname = "showStarred", notes = "Gets the starred projects for a specific user. Requires the `view_public_info` permission.", response = PaginatedCompactProjectResult.class, authorizations = {
|
||||
@Authorization(value = "Session")}, tags = {"Users",})
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(code = 200, message = "Ok", response = PaginatedCompactProjectResult.class),
|
||||
@ApiResponse(code = 401, message = "Api session missing, invalid or expired"),
|
||||
@ApiResponse(code = 403, message = "Not enough permissions to use this endpoint")})
|
||||
@RequestMapping(value = "/users/{user}/starred",
|
||||
produces = {"application/json"},
|
||||
method = RequestMethod.GET)
|
||||
ResponseEntity<PaginatedCompactProjectResult> showStarred(@ApiParam(value = "The user to return for", required = true) @PathVariable("user") String user
|
||||
, @ApiParam(value = "How to sort the projects") @Valid @RequestParam(value = "sort", required = false) ProjectSortingStrategy sort
|
||||
, @ApiParam(value = "The maximum amount of projects to return") @Valid @RequestParam(value = "limit", required = false) Long limit
|
||||
, @ApiParam(value = "Where to start searching", defaultValue = "0") @Valid @RequestParam(value = "offset", required = false, defaultValue = "0") Long offset
|
||||
);
|
||||
|
||||
|
||||
@ApiOperation(value = "Gets a specific user", nickname = "showUser", notes = "Gets a specific user. Requires the `view_public_info` permission.", response = User.class, authorizations = {
|
||||
@Authorization(value = "Session")}, tags = {"Users",})
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(code = 200, message = "Ok", response = User.class),
|
||||
@ApiResponse(code = 401, message = "Api session missing, invalid or expired"),
|
||||
@ApiResponse(code = 403, message = "Not enough permissions to use this endpoint")})
|
||||
@RequestMapping(value = "/users/{user}",
|
||||
produces = {"application/json"},
|
||||
method = RequestMethod.GET)
|
||||
ResponseEntity<User> showUser(@ApiParam(value = "The user to return", required = true) @PathVariable("user") String user
|
||||
);
|
||||
|
||||
|
||||
@ApiOperation(value = "Gets the watched projects for a specific user", nickname = "showWatching", notes = "Gets the watched projects for a specific user. Requires the `view_public_info` permission.", response = PaginatedCompactProjectResult.class, authorizations = {
|
||||
@Authorization(value = "Session")}, tags = {"Users",})
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(code = 200, message = "Ok", response = PaginatedCompactProjectResult.class),
|
||||
@ApiResponse(code = 401, message = "Api session missing, invalid or expired"),
|
||||
@ApiResponse(code = 403, message = "Not enough permissions to use this endpoint")})
|
||||
@RequestMapping(value = "/users/{user}/watching",
|
||||
produces = {"application/json"},
|
||||
method = RequestMethod.GET)
|
||||
ResponseEntity<PaginatedCompactProjectResult> showWatching(@ApiParam(value = "The user to return for", required = true) @PathVariable("user") String user
|
||||
, @ApiParam(value = "How to sort the projects") @Valid @RequestParam(value = "sort", required = false) ProjectSortingStrategy sort
|
||||
, @ApiParam(value = "The maximum amount of projects to return") @Valid @RequestParam(value = "limit", required = false) Long limit
|
||||
, @ApiParam(value = "Where to start searching", defaultValue = "0") @Valid @RequestParam(value = "offset", required = false, defaultValue = "0") Long offset
|
||||
);
|
||||
|
||||
}
|
@ -0,0 +1,80 @@
|
||||
package me.minidigger.hangar.api;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
|
||||
import java.io.IOException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import me.minidigger.hangar.model.PaginatedCompactProjectResult;
|
||||
import me.minidigger.hangar.model.ProjectSortingStrategy;
|
||||
import me.minidigger.hangar.model.User;
|
||||
|
||||
@Controller
|
||||
public class UsersApiController implements UsersApi {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(UsersApiController.class);
|
||||
|
||||
private final ObjectMapper objectMapper;
|
||||
|
||||
private final HttpServletRequest request;
|
||||
|
||||
@Autowired
|
||||
public UsersApiController(ObjectMapper objectMapper, HttpServletRequest request) {
|
||||
this.objectMapper = objectMapper;
|
||||
this.request = request;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity<PaginatedCompactProjectResult> showStarred(String user, ProjectSortingStrategy sort, Long limit, Long offset) {
|
||||
String accept = request.getHeader("Accept");
|
||||
if (accept != null && accept.contains("application/json")) {
|
||||
try {
|
||||
return new ResponseEntity<>(objectMapper.readValue("{\n \"result\" : [ {\n \"plugin_id\" : \"plugin_id\",\n \"promoted_versions\" : [ {\n \"version\" : \"version\",\n \"tags\" : [ {\n \"data\" : \"data\",\n \"color\" : {\n \"background\" : \"background\",\n \"foreground\" : \"foreground\"\n },\n \"name\" : \"name\",\n \"display_data\" : \"display_data\",\n \"minecraft_version\" : \"minecraft_version\"\n }, {\n \"data\" : \"data\",\n \"color\" : {\n \"background\" : \"background\",\n \"foreground\" : \"foreground\"\n },\n \"name\" : \"name\",\n \"display_data\" : \"display_data\",\n \"minecraft_version\" : \"minecraft_version\"\n } ]\n }, {\n \"version\" : \"version\",\n \"tags\" : [ {\n \"data\" : \"data\",\n \"color\" : {\n \"background\" : \"background\",\n \"foreground\" : \"foreground\"\n },\n \"name\" : \"name\",\n \"display_data\" : \"display_data\",\n \"minecraft_version\" : \"minecraft_version\"\n }, {\n \"data\" : \"data\",\n \"color\" : {\n \"background\" : \"background\",\n \"foreground\" : \"foreground\"\n },\n \"name\" : \"name\",\n \"display_data\" : \"display_data\",\n \"minecraft_version\" : \"minecraft_version\"\n } ]\n } ],\n \"visibility\" : \"public\",\n \"stats\" : {\n \"downloads\" : 5,\n \"recent_downloads\" : 7,\n \"recent_views\" : 2,\n \"watchers\" : 3,\n \"stars\" : 9,\n \"views\" : 5\n },\n \"name\" : \"name\",\n \"namespace\" : {\n \"owner\" : \"owner\",\n \"slug\" : \"slug\"\n },\n \"category\" : \"admin_tools\"\n }, {\n \"plugin_id\" : \"plugin_id\",\n \"promoted_versions\" : [ {\n \"version\" : \"version\",\n \"tags\" : [ {\n \"data\" : \"data\",\n \"color\" : {\n \"background\" : \"background\",\n \"foreground\" : \"foreground\"\n },\n \"name\" : \"name\",\n \"display_data\" : \"display_data\",\n \"minecraft_version\" : \"minecraft_version\"\n }, {\n \"data\" : \"data\",\n \"color\" : {\n \"background\" : \"background\",\n \"foreground\" : \"foreground\"\n },\n \"name\" : \"name\",\n \"display_data\" : \"display_data\",\n \"minecraft_version\" : \"minecraft_version\"\n } ]\n }, {\n \"version\" : \"version\",\n \"tags\" : [ {\n \"data\" : \"data\",\n \"color\" : {\n \"background\" : \"background\",\n \"foreground\" : \"foreground\"\n },\n \"name\" : \"name\",\n \"display_data\" : \"display_data\",\n \"minecraft_version\" : \"minecraft_version\"\n }, {\n \"data\" : \"data\",\n \"color\" : {\n \"background\" : \"background\",\n \"foreground\" : \"foreground\"\n },\n \"name\" : \"name\",\n \"display_data\" : \"display_data\",\n \"minecraft_version\" : \"minecraft_version\"\n } ]\n } ],\n \"visibility\" : \"public\",\n \"stats\" : {\n \"downloads\" : 5,\n \"recent_downloads\" : 7,\n \"recent_views\" : 2,\n \"watchers\" : 3,\n \"stars\" : 9,\n \"views\" : 5\n },\n \"name\" : \"name\",\n \"namespace\" : {\n \"owner\" : \"owner\",\n \"slug\" : \"slug\"\n },\n \"category\" : \"admin_tools\"\n } ],\n \"pagination\" : {\n \"offset\" : 6,\n \"limit\" : 0,\n \"count\" : 1\n }\n}", PaginatedCompactProjectResult.class), HttpStatus.NOT_IMPLEMENTED);
|
||||
} catch (IOException e) {
|
||||
log.error("Couldn't serialize response for content type application/json", e);
|
||||
return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity<User> showUser(String user) {
|
||||
String accept = request.getHeader("Accept");
|
||||
if (accept != null && accept.contains("application/json")) {
|
||||
try {
|
||||
return new ResponseEntity<>(objectMapper.readValue("{\n \"join_date\" : \"2000-01-23T04:56:07.000+00:00\",\n \"roles\" : [ {\n \"color\" : \"color\",\n \"name\" : \"name\",\n \"title\" : \"title\"\n }, {\n \"color\" : \"color\",\n \"name\" : \"name\",\n \"title\" : \"title\"\n } ],\n \"name\" : \"name\",\n \"created_at\" : \"2000-01-23T04:56:07.000+00:00\",\n \"tagline\" : \"tagline\"\n}", User.class), HttpStatus.NOT_IMPLEMENTED);
|
||||
} catch (IOException e) {
|
||||
log.error("Couldn't serialize response for content type application/json", e);
|
||||
return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity<PaginatedCompactProjectResult> showWatching(@PathVariable("user") String user, ProjectSortingStrategy sort, Long limit, Long offset) {
|
||||
String accept = request.getHeader("Accept");
|
||||
if (accept != null && accept.contains("application/json")) {
|
||||
try {
|
||||
return new ResponseEntity<>(objectMapper.readValue("{\n \"result\" : [ {\n \"plugin_id\" : \"plugin_id\",\n \"promoted_versions\" : [ {\n \"version\" : \"version\",\n \"tags\" : [ {\n \"data\" : \"data\",\n \"color\" : {\n \"background\" : \"background\",\n \"foreground\" : \"foreground\"\n },\n \"name\" : \"name\",\n \"display_data\" : \"display_data\",\n \"minecraft_version\" : \"minecraft_version\"\n }, {\n \"data\" : \"data\",\n \"color\" : {\n \"background\" : \"background\",\n \"foreground\" : \"foreground\"\n },\n \"name\" : \"name\",\n \"display_data\" : \"display_data\",\n \"minecraft_version\" : \"minecraft_version\"\n } ]\n }, {\n \"version\" : \"version\",\n \"tags\" : [ {\n \"data\" : \"data\",\n \"color\" : {\n \"background\" : \"background\",\n \"foreground\" : \"foreground\"\n },\n \"name\" : \"name\",\n \"display_data\" : \"display_data\",\n \"minecraft_version\" : \"minecraft_version\"\n }, {\n \"data\" : \"data\",\n \"color\" : {\n \"background\" : \"background\",\n \"foreground\" : \"foreground\"\n },\n \"name\" : \"name\",\n \"display_data\" : \"display_data\",\n \"minecraft_version\" : \"minecraft_version\"\n } ]\n } ],\n \"visibility\" : \"public\",\n \"stats\" : {\n \"downloads\" : 5,\n \"recent_downloads\" : 7,\n \"recent_views\" : 2,\n \"watchers\" : 3,\n \"stars\" : 9,\n \"views\" : 5\n },\n \"name\" : \"name\",\n \"namespace\" : {\n \"owner\" : \"owner\",\n \"slug\" : \"slug\"\n },\n \"category\" : \"admin_tools\"\n }, {\n \"plugin_id\" : \"plugin_id\",\n \"promoted_versions\" : [ {\n \"version\" : \"version\",\n \"tags\" : [ {\n \"data\" : \"data\",\n \"color\" : {\n \"background\" : \"background\",\n \"foreground\" : \"foreground\"\n },\n \"name\" : \"name\",\n \"display_data\" : \"display_data\",\n \"minecraft_version\" : \"minecraft_version\"\n }, {\n \"data\" : \"data\",\n \"color\" : {\n \"background\" : \"background\",\n \"foreground\" : \"foreground\"\n },\n \"name\" : \"name\",\n \"display_data\" : \"display_data\",\n \"minecraft_version\" : \"minecraft_version\"\n } ]\n }, {\n \"version\" : \"version\",\n \"tags\" : [ {\n \"data\" : \"data\",\n \"color\" : {\n \"background\" : \"background\",\n \"foreground\" : \"foreground\"\n },\n \"name\" : \"name\",\n \"display_data\" : \"display_data\",\n \"minecraft_version\" : \"minecraft_version\"\n }, {\n \"data\" : \"data\",\n \"color\" : {\n \"background\" : \"background\",\n \"foreground\" : \"foreground\"\n },\n \"name\" : \"name\",\n \"display_data\" : \"display_data\",\n \"minecraft_version\" : \"minecraft_version\"\n } ]\n } ],\n \"visibility\" : \"public\",\n \"stats\" : {\n \"downloads\" : 5,\n \"recent_downloads\" : 7,\n \"recent_views\" : 2,\n \"watchers\" : 3,\n \"stars\" : 9,\n \"views\" : 5\n },\n \"name\" : \"name\",\n \"namespace\" : {\n \"owner\" : \"owner\",\n \"slug\" : \"slug\"\n },\n \"category\" : \"admin_tools\"\n } ],\n \"pagination\" : {\n \"offset\" : 6,\n \"limit\" : 0,\n \"count\" : 1\n }\n}", PaginatedCompactProjectResult.class), HttpStatus.NOT_IMPLEMENTED);
|
||||
} catch (IOException e) {
|
||||
log.error("Couldn't serialize response for content type application/json", e);
|
||||
return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
}
|
86
src/main/java/me/minidigger/hangar/api/VersionsApi.java
Normal file
86
src/main/java/me/minidigger/hangar/api/VersionsApi.java
Normal file
@ -0,0 +1,86 @@
|
||||
package me.minidigger.hangar.api;
|
||||
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RequestPart;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import org.threeten.bp.LocalDate;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import io.swagger.annotations.ApiParam;
|
||||
import io.swagger.annotations.ApiResponse;
|
||||
import io.swagger.annotations.ApiResponses;
|
||||
import io.swagger.annotations.Authorization;
|
||||
import me.minidigger.hangar.model.PaginatedVersionResult;
|
||||
import me.minidigger.hangar.model.DeployVersionInfo;
|
||||
import me.minidigger.hangar.model.Version;
|
||||
import me.minidigger.hangar.model.VersionStatsDay;
|
||||
|
||||
@Api(value = "versions", description = "the versions API", tags = "Versions")
|
||||
public interface VersionsApi {
|
||||
|
||||
@ApiOperation(value = "Creates a new version", nickname = "deployVersion", notes = "Creates a new version for a project. Requires the `create_version` permission in the project or owning organization.", response = Version.class, authorizations = {
|
||||
@Authorization(value = "Session")}, tags = "Versions")
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(code = 201, message = "Ok", response = Version.class),
|
||||
@ApiResponse(code = 401, message = "Api session missing, invalid or expired"),
|
||||
@ApiResponse(code = 403, message = "Not enough permissions to use this endpoint")})
|
||||
@PostMapping(value = "/projects/{pluginId}/versions",
|
||||
produces = MediaType.APPLICATION_JSON_VALUE,
|
||||
consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
|
||||
ResponseEntity<Version> deployVersion(@ApiParam(value = "", required = true) @RequestParam(value = "plugin-info", required = true) DeployVersionInfo pluginInfo
|
||||
, @ApiParam(value = "file detail") @Valid @RequestPart("file") MultipartFile pluginFile
|
||||
, @ApiParam(value = "The plugin id of the project to create the version for", required = true) @PathVariable("pluginId") String pluginId
|
||||
);
|
||||
|
||||
@ApiOperation(value = "Returns the versions of a project", nickname = "listVersions", notes = "Returns the versions of a project. Requires the `view_public_info` permission in the project or owning organization.", response = PaginatedVersionResult.class, authorizations = {
|
||||
@Authorization(value = "Session")}, tags = "Versions")
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(code = 200, message = "Ok", response = PaginatedVersionResult.class),
|
||||
@ApiResponse(code = 401, message = "Api session missing, invalid or expired"),
|
||||
@ApiResponse(code = 403, message = "Not enough permissions to use this endpoint")})
|
||||
@GetMapping(value = "/projects/{pluginId}/versions",
|
||||
produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
ResponseEntity<PaginatedVersionResult> listVersions(@ApiParam(value = "The plugin id of the project to return versions for", required = true) @PathVariable("pluginId") String pluginId
|
||||
, @ApiParam(value = "A list of tags all the returned versions should have. Should be formated either as `tagname` or `tagname:tagdata`.") @Valid @RequestParam(value = "tags", required = false) List<String> tags
|
||||
, @ApiParam(value = "The maximum amount of versions to return") @Valid @RequestParam(value = "limit", required = false) Long limit
|
||||
, @ApiParam(value = "Where to start returning", defaultValue = "0") @Valid @RequestParam(value = "offset", required = false, defaultValue = "0") Long offset
|
||||
);
|
||||
|
||||
@ApiOperation(value = "Returns a specific version of a project", nickname = "showVersion", notes = "Returns a specific version of a project. Requires the `view_public_info` permission in the project or owning organization.", response = Version.class, authorizations = {
|
||||
@Authorization(value = "Session")}, tags = "Versions")
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(code = 200, message = "Ok", response = Version.class),
|
||||
@ApiResponse(code = 401, message = "Api session missing, invalid or expired"),
|
||||
@ApiResponse(code = 403, message = "Not enough permissions to use this endpoint")})
|
||||
@GetMapping(value = "/projects/{pluginId}/versions/{name}",
|
||||
produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
ResponseEntity<Version> showVersion(@ApiParam(value = "The plugin id of the project to return the version for", required = true) @PathVariable("pluginId") String pluginId
|
||||
, @ApiParam(value = "The name of the version to return", required = true) @PathVariable("name") String name
|
||||
);
|
||||
|
||||
@ApiOperation(value = "Returns the stats for a version", nickname = "showVersionStats", notes = "Returns the stats(downloads) for a version per day for a certain date range. Requires the `is_subject_member` permission.", response = VersionStatsDay.class, responseContainer = "Map", authorizations = {
|
||||
@Authorization(value = "Session")}, tags = "Versions")
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(code = 200, message = "Ok", response = VersionStatsDay.class, responseContainer = "Map"),
|
||||
@ApiResponse(code = 401, message = "Api session missing, invalid or expired"),
|
||||
@ApiResponse(code = 403, message = "Not enough permissions to use this endpoint")})
|
||||
@GetMapping(value = "/projects/{pluginId}/versions/{version}/stats",
|
||||
produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
ResponseEntity<Map<String, VersionStatsDay>> showVersionStats(
|
||||
@ApiParam(value = "The plugin id of the version to return the stats for", required = true) @PathVariable("pluginId") String pluginId,
|
||||
@ApiParam(value = "The version to return the stats for", required = true) @PathVariable("version") String version,
|
||||
@NotNull @ApiParam(value = "The first date to include in the result", required = true) @Valid @RequestParam(value = "fromDate") LocalDate fromDate,
|
||||
@NotNull @ApiParam(value = "The last date to include in the result", required = true) @Valid @RequestParam(value = "toDate") LocalDate toDate
|
||||
);
|
||||
}
|
@ -0,0 +1,99 @@
|
||||
package me.minidigger.hangar.api;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import org.threeten.bp.LocalDate;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import me.minidigger.hangar.model.DeployVersionInfo;
|
||||
import me.minidigger.hangar.model.PaginatedVersionResult;
|
||||
import me.minidigger.hangar.model.Version;
|
||||
import me.minidigger.hangar.model.VersionStatsDay;
|
||||
|
||||
@Controller
|
||||
public class VersionsApiController implements VersionsApi {
|
||||
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(VersionsApiController.class);
|
||||
|
||||
private final ObjectMapper objectMapper;
|
||||
|
||||
private final HttpServletRequest request;
|
||||
|
||||
@Autowired
|
||||
public VersionsApiController(ObjectMapper objectMapper, HttpServletRequest request) {
|
||||
this.objectMapper = objectMapper;
|
||||
this.request = request;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity<Version> deployVersion(DeployVersionInfo pluginInfo, MultipartFile pluginFile, String pluginId) {
|
||||
String accept = request.getHeader("Accept");
|
||||
if (accept != null && accept.contains("application/json")) {
|
||||
try {
|
||||
return new ResponseEntity<>(objectMapper.readValue("{\n \"visibility\" : \"public\",\n \"stats\" : {\n \"downloads\" : 0\n },\n \"author\" : \"author\",\n \"file_info\" : {\n \"size_bytes\" : 6,\n \"md_5_hash\" : \"md_5_hash\",\n \"name\" : \"name\"\n },\n \"name\" : \"name\",\n \"created_at\" : \"2000-01-23T04:56:07.000+00:00\",\n \"description\" : \"description\",\n \"dependencies\" : [ {\n \"plugin_id\" : \"plugin_id\",\n \"version\" : \"version\"\n }, {\n \"plugin_id\" : \"plugin_id\",\n \"version\" : \"version\"\n } ],\n \"review_state\" : \"unreviewed\",\n \"tags\" : [ {\n \"data\" : \"data\",\n \"color\" : {\n \"background\" : \"background\",\n \"foreground\" : \"foreground\"\n },\n \"name\" : \"name\"\n }, {\n \"data\" : \"data\",\n \"color\" : {\n \"background\" : \"background\",\n \"foreground\" : \"foreground\"\n },\n \"name\" : \"name\"\n } ]\n}", Version.class), HttpStatus.NOT_IMPLEMENTED);
|
||||
} catch (IOException e) {
|
||||
log.error("Couldn't serialize response for content type application/json", e);
|
||||
return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity<PaginatedVersionResult> listVersions(String pluginId, List<String> tags, Long limit, Long offset) {
|
||||
String accept = request.getHeader("Accept");
|
||||
if (accept != null && accept.contains("application/json")) {
|
||||
try {
|
||||
return new ResponseEntity<>(objectMapper.readValue("{\n \"result\" : [ {\n \"visibility\" : \"public\",\n \"stats\" : {\n \"downloads\" : 0\n },\n \"author\" : \"author\",\n \"file_info\" : {\n \"size_bytes\" : 6,\n \"md_5_hash\" : \"md_5_hash\",\n \"name\" : \"name\"\n },\n \"name\" : \"name\",\n \"created_at\" : \"2000-01-23T04:56:07.000+00:00\",\n \"description\" : \"description\",\n \"dependencies\" : [ {\n \"plugin_id\" : \"plugin_id\",\n \"version\" : \"version\"\n }, {\n \"plugin_id\" : \"plugin_id\",\n \"version\" : \"version\"\n } ],\n \"review_state\" : \"unreviewed\",\n \"tags\" : [ {\n \"data\" : \"data\",\n \"color\" : {\n \"background\" : \"background\",\n \"foreground\" : \"foreground\"\n },\n \"name\" : \"name\"\n }, {\n \"data\" : \"data\",\n \"color\" : {\n \"background\" : \"background\",\n \"foreground\" : \"foreground\"\n },\n \"name\" : \"name\"\n } ]\n }, {\n \"visibility\" : \"public\",\n \"stats\" : {\n \"downloads\" : 0\n },\n \"author\" : \"author\",\n \"file_info\" : {\n \"size_bytes\" : 6,\n \"md_5_hash\" : \"md_5_hash\",\n \"name\" : \"name\"\n },\n \"name\" : \"name\",\n \"created_at\" : \"2000-01-23T04:56:07.000+00:00\",\n \"description\" : \"description\",\n \"dependencies\" : [ {\n \"plugin_id\" : \"plugin_id\",\n \"version\" : \"version\"\n }, {\n \"plugin_id\" : \"plugin_id\",\n \"version\" : \"version\"\n } ],\n \"review_state\" : \"unreviewed\",\n \"tags\" : [ {\n \"data\" : \"data\",\n \"color\" : {\n \"background\" : \"background\",\n \"foreground\" : \"foreground\"\n },\n \"name\" : \"name\"\n }, {\n \"data\" : \"data\",\n \"color\" : {\n \"background\" : \"background\",\n \"foreground\" : \"foreground\"\n },\n \"name\" : \"name\"\n } ]\n } ],\n \"pagination\" : {\n \"offset\" : 6,\n \"limit\" : 0,\n \"count\" : 1\n }\n}", PaginatedVersionResult.class), HttpStatus.NOT_IMPLEMENTED);
|
||||
} catch (IOException e) {
|
||||
log.error("Couldn't serialize response for content type application/json", e);
|
||||
return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity<Version> showVersion(String pluginId, String name) {
|
||||
String accept = request.getHeader("Accept");
|
||||
if (accept != null && accept.contains("application/json")) {
|
||||
try {
|
||||
return new ResponseEntity<>(objectMapper.readValue("{\n \"visibility\" : \"public\",\n \"stats\" : {\n \"downloads\" : 0\n },\n \"author\" : \"author\",\n \"file_info\" : {\n \"size_bytes\" : 6,\n \"md_5_hash\" : \"md_5_hash\",\n \"name\" : \"name\"\n },\n \"name\" : \"name\",\n \"created_at\" : \"2000-01-23T04:56:07.000+00:00\",\n \"description\" : \"description\",\n \"dependencies\" : [ {\n \"plugin_id\" : \"plugin_id\",\n \"version\" : \"version\"\n }, {\n \"plugin_id\" : \"plugin_id\",\n \"version\" : \"version\"\n } ],\n \"review_state\" : \"unreviewed\",\n \"tags\" : [ {\n \"data\" : \"data\",\n \"color\" : {\n \"background\" : \"background\",\n \"foreground\" : \"foreground\"\n },\n \"name\" : \"name\"\n }, {\n \"data\" : \"data\",\n \"color\" : {\n \"background\" : \"background\",\n \"foreground\" : \"foreground\"\n },\n \"name\" : \"name\"\n } ]\n}", Version.class), HttpStatus.NOT_IMPLEMENTED);
|
||||
} catch (IOException e) {
|
||||
log.error("Couldn't serialize response for content type application/json", e);
|
||||
return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity<Map<String, VersionStatsDay>> showVersionStats(String pluginId, String version, LocalDate fromDate, LocalDate toDate) {
|
||||
String accept = request.getHeader("Accept");
|
||||
if (accept != null && accept.contains("application/json")) {
|
||||
try {
|
||||
return new ResponseEntity<Map<String, VersionStatsDay>>(objectMapper.readValue("{\n \"key\" : {\n \"downloads\" : 0\n }\n}", Map.class), HttpStatus.NOT_IMPLEMENTED);
|
||||
} catch (IOException e) {
|
||||
log.error("Couldn't serialize response for content type application/json", e);
|
||||
return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||
}
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
package me.minidigger.hangar.config;
|
||||
|
||||
import com.fasterxml.jackson.datatype.threetenbp.ThreeTenModule;
|
||||
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.threeten.bp.Instant;
|
||||
import org.threeten.bp.OffsetDateTime;
|
||||
import org.threeten.bp.ZonedDateTime;
|
||||
|
||||
import me.minidigger.hangar.util.CustomInstantDeserializer;
|
||||
|
||||
@Configuration
|
||||
public class JacksonConfiguration {
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean(ThreeTenModule.class)
|
||||
ThreeTenModule threeTenModule() {
|
||||
ThreeTenModule module = new ThreeTenModule();
|
||||
module.addDeserializer(Instant.class, CustomInstantDeserializer.INSTANT);
|
||||
module.addDeserializer(OffsetDateTime.class, CustomInstantDeserializer.OFFSET_DATE_TIME);
|
||||
module.addDeserializer(ZonedDateTime.class, CustomInstantDeserializer.ZONED_DATE_TIME);
|
||||
return module;
|
||||
}
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
package me.minidigger.hangar.config;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
||||
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
|
||||
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
|
||||
import org.springframework.security.core.userdetails.User;
|
||||
import org.springframework.security.core.userdetails.UserDetails;
|
||||
import org.springframework.security.core.userdetails.UserDetailsService;
|
||||
import org.springframework.security.provisioning.InMemoryUserDetailsManager;
|
||||
|
||||
@Configuration
|
||||
@EnableWebSecurity
|
||||
public class SecurityConfig extends WebSecurityConfigurerAdapter {
|
||||
@Override
|
||||
protected void configure(HttpSecurity http) throws Exception {
|
||||
http.csrf().ignoringAntMatchers(
|
||||
"/authenticate", "/sessions/current", "/keys"
|
||||
);
|
||||
|
||||
http
|
||||
.authorizeRequests().anyRequest().permitAll();
|
||||
}
|
||||
|
||||
@Bean
|
||||
@Override
|
||||
public UserDetailsService userDetailsService() {
|
||||
UserDetails user =
|
||||
User.withDefaultPasswordEncoder()
|
||||
.username("user")
|
||||
.password("password")
|
||||
.roles("USER")
|
||||
.build();
|
||||
|
||||
return new InMemoryUserDetailsManager(user);
|
||||
}
|
||||
}
|
61
src/main/java/me/minidigger/hangar/config/SwaggerConfig.java
Normal file
61
src/main/java/me/minidigger/hangar/config/SwaggerConfig.java
Normal file
@ -0,0 +1,61 @@
|
||||
package me.minidigger.hangar.config;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.threeten.bp.LocalDate;
|
||||
import org.threeten.bp.OffsetDateTime;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import springfox.documentation.builders.ApiInfoBuilder;
|
||||
import springfox.documentation.builders.RequestHandlerSelectors;
|
||||
import springfox.documentation.service.ApiInfo;
|
||||
import springfox.documentation.service.Contact;
|
||||
import springfox.documentation.spi.DocumentationType;
|
||||
import springfox.documentation.spring.web.plugins.Docket;
|
||||
import springfox.documentation.swagger2.annotations.EnableSwagger2;
|
||||
|
||||
@Configuration
|
||||
@EnableSwagger2
|
||||
public class SwaggerConfig {
|
||||
|
||||
ApiInfo apiInfo() {
|
||||
return new ApiInfoBuilder()
|
||||
.title("Hangar API")
|
||||
.description(" This page describes the format for the current Hangar REST API, in addition to common questions when using it. " +
|
||||
"Note that anything that starts with `_` should be considered internal, and can change at a moment's notice. Do not use it. " +
|
||||
"## Authentication and authorization There are two ways to consume the API. Keyless, and using an API key. " +
|
||||
"### Keyless When using keyless authentication you only get access to public information, but don't need to worry about creating and storing an API key. " +
|
||||
"### API Keys If you need access to non-public actions, or want to do something programatically, you likely want an API key. " +
|
||||
"These can be created by going to your user page and clicking on the key icon. " +
|
||||
"### Authentication Once you know how you want to authenticate you need to create a session. You can do this by `POST`ing to `/authenticate`. " +
|
||||
"If you're using keyless authentication that's it. If you have an API key, you need to specify it in the Authorization header like so `Authorization: HangarApi apikey=\"foobar\"`. " +
|
||||
"### Authorization Once you do that you should receive an session. This is valid for a pre-defined set of time. When it expires, you need to authenticate again. " +
|
||||
"To use it, set it in the Authorization header like so `Authorization: HangarApi session=\"noisses\"`. For more info about authentication, see [here](#/Authentification/authenticate). " +
|
||||
"## FAQ " +
|
||||
"### Can I just change v1 to v2 and be done with the transition to the new API? " +
|
||||
"No, not at all. The new API is wildly different from the old API. You won't even get out the door. " +
|
||||
"### Why do I need to create a new session when I just want to get some public info? " +
|
||||
"We're working on a session-less authentification for public endpoints. " +
|
||||
"### What format does dates have? " +
|
||||
"Standard ISO types. Where possible we use the OpenAPI format modifier. You can view it's meanings [here](https://swagger.io/docs/specification/data-models/data-types/#format).")
|
||||
.license("Unlicence")
|
||||
.licenseUrl("http://unlicense.org")
|
||||
.termsOfServiceUrl("")
|
||||
.version("2.0")
|
||||
.contact(new Contact("MiniDigger", "https://minidigger.me", "admin@minidigger.me"))
|
||||
.build();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public Docket customImplementation() {
|
||||
return new Docket(DocumentationType.SWAGGER_2)
|
||||
.select()
|
||||
.apis(RequestHandlerSelectors.basePackage("me.minidigger.hangar"))
|
||||
.build()
|
||||
.directModelSubstitute(LocalDate.class, java.sql.Date.class)
|
||||
.directModelSubstitute(OffsetDateTime.class, Date.class)
|
||||
.apiInfo(apiInfo());
|
||||
}
|
||||
|
||||
}
|
113
src/main/java/me/minidigger/hangar/model/ApiKeyRequest.java
Normal file
113
src/main/java/me/minidigger/hangar/model/ApiKeyRequest.java
Normal file
@ -0,0 +1,113 @@
|
||||
package me.minidigger.hangar.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
/**
|
||||
* ControllersApiv2ApiV2ControllerKeyToCreate
|
||||
*/
|
||||
@Validated
|
||||
public class ApiKeyRequest {
|
||||
@JsonProperty("name")
|
||||
private String name = null;
|
||||
|
||||
@JsonProperty("permissions")
|
||||
@Valid
|
||||
private List<String> permissions = new ArrayList<>();
|
||||
|
||||
public ApiKeyRequest name(String name) {
|
||||
this.name = name;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get name
|
||||
*
|
||||
* @return name
|
||||
**/
|
||||
@ApiModelProperty(required = true, value = "")
|
||||
@NotNull
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public ApiKeyRequest permissions(List<String> permissions) {
|
||||
this.permissions = permissions;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ApiKeyRequest addPermissionsItem(String permissionsItem) {
|
||||
this.permissions.add(permissionsItem);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get permissions
|
||||
*
|
||||
* @return permissions
|
||||
**/
|
||||
@ApiModelProperty(required = true, value = "")
|
||||
@NotNull
|
||||
|
||||
public List<String> getPermissions() {
|
||||
return permissions;
|
||||
}
|
||||
|
||||
public void setPermissions(List<String> permissions) {
|
||||
this.permissions = permissions;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
ApiKeyRequest apiKeyRequest = (ApiKeyRequest) o;
|
||||
return Objects.equals(this.name, apiKeyRequest.name) &&
|
||||
Objects.equals(this.permissions, apiKeyRequest.permissions);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(name, permissions);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("class ControllersApiv2ApiV2ControllerKeyToCreate {\n");
|
||||
|
||||
sb.append(" name: ").append(toIndentedString(name)).append("\n");
|
||||
sb.append(" permissions: ").append(toIndentedString(permissions)).append("\n");
|
||||
sb.append("}");
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the given object to string with each line indented by 4 spaces (except the first line).
|
||||
*/
|
||||
private String toIndentedString(Object o) {
|
||||
if (o == null) {
|
||||
return "null";
|
||||
}
|
||||
return o.toString().replace("\n", "\n ");
|
||||
}
|
||||
}
|
113
src/main/java/me/minidigger/hangar/model/ApiKeyResponse.java
Normal file
113
src/main/java/me/minidigger/hangar/model/ApiKeyResponse.java
Normal file
@ -0,0 +1,113 @@
|
||||
package me.minidigger.hangar.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
/**
|
||||
* ControllersApiv2ApiV2ControllerCreatedApiKey
|
||||
*/
|
||||
@Validated
|
||||
public class ApiKeyResponse {
|
||||
@JsonProperty("key")
|
||||
private String key = null;
|
||||
|
||||
@JsonProperty("perms")
|
||||
@Valid
|
||||
private List<NamedPermission> perms = new ArrayList<>();
|
||||
|
||||
public ApiKeyResponse key(String key) {
|
||||
this.key = key;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get key
|
||||
*
|
||||
* @return key
|
||||
**/
|
||||
@ApiModelProperty(required = true, value = "")
|
||||
@NotNull
|
||||
|
||||
public String getKey() {
|
||||
return key;
|
||||
}
|
||||
|
||||
public void setKey(String key) {
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
public ApiKeyResponse perms(List<NamedPermission> perms) {
|
||||
this.perms = perms;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ApiKeyResponse addPermsItem(NamedPermission permsItem) {
|
||||
this.perms.add(permsItem);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get perms
|
||||
*
|
||||
* @return perms
|
||||
**/
|
||||
@ApiModelProperty(required = true, value = "")
|
||||
@NotNull
|
||||
@Valid
|
||||
public List<NamedPermission> getPerms() {
|
||||
return perms;
|
||||
}
|
||||
|
||||
public void setPerms(List<NamedPermission> perms) {
|
||||
this.perms = perms;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
ApiKeyResponse apiKeyResponse = (ApiKeyResponse) o;
|
||||
return Objects.equals(this.key, apiKeyResponse.key) &&
|
||||
Objects.equals(this.perms, apiKeyResponse.perms);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(key, perms);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("class ControllersApiv2ApiV2ControllerCreatedApiKey {\n");
|
||||
|
||||
sb.append(" key: ").append(toIndentedString(key)).append("\n");
|
||||
sb.append(" perms: ").append(toIndentedString(perms)).append("\n");
|
||||
sb.append("}");
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the given object to string with each line indented by 4 spaces (except the first line).
|
||||
*/
|
||||
private String toIndentedString(Object o) {
|
||||
if (o == null) {
|
||||
return "null";
|
||||
}
|
||||
return o.toString().replace("\n", "\n ");
|
||||
}
|
||||
}
|
133
src/main/java/me/minidigger/hangar/model/ApiSession.java
Normal file
133
src/main/java/me/minidigger/hangar/model/ApiSession.java
Normal file
@ -0,0 +1,133 @@
|
||||
package me.minidigger.hangar.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.threeten.bp.OffsetDateTime;
|
||||
|
||||
import java.util.Objects;
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
/**
|
||||
* ControllersApiv2ApiV2ControllerReturnedApiSession
|
||||
*/
|
||||
@Validated
|
||||
public class ApiSession {
|
||||
@JsonProperty("session")
|
||||
private String session = null;
|
||||
|
||||
@JsonProperty("expires")
|
||||
private OffsetDateTime expires = null;
|
||||
|
||||
@JsonProperty("type")
|
||||
private SessionType type = null;
|
||||
|
||||
public ApiSession session(String session) {
|
||||
this.session = session;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get session
|
||||
*
|
||||
* @return session
|
||||
**/
|
||||
@ApiModelProperty(required = true, value = "")
|
||||
@NotNull
|
||||
|
||||
public String getSession() {
|
||||
return session;
|
||||
}
|
||||
|
||||
public void setSession(String session) {
|
||||
this.session = session;
|
||||
}
|
||||
|
||||
public ApiSession expires(OffsetDateTime expires) {
|
||||
this.expires = expires;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get expires
|
||||
*
|
||||
* @return expires
|
||||
**/
|
||||
@ApiModelProperty(required = true, value = "")
|
||||
@NotNull
|
||||
|
||||
@Valid
|
||||
public OffsetDateTime getExpires() {
|
||||
return expires;
|
||||
}
|
||||
|
||||
public void setExpires(OffsetDateTime expires) {
|
||||
this.expires = expires;
|
||||
}
|
||||
|
||||
public ApiSession type(SessionType type) {
|
||||
this.type = type;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get type
|
||||
*
|
||||
* @return type
|
||||
**/
|
||||
@ApiModelProperty(required = true, value = "")
|
||||
@NotNull
|
||||
|
||||
public SessionType getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(SessionType type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
ApiSession apiSession = (ApiSession) o;
|
||||
return Objects.equals(this.session, apiSession.session) &&
|
||||
Objects.equals(this.expires, apiSession.expires) &&
|
||||
Objects.equals(this.type, apiSession.type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(session, expires, type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("class ControllersApiv2ApiV2ControllerReturnedApiSession {\n");
|
||||
|
||||
sb.append(" session: ").append(toIndentedString(session)).append("\n");
|
||||
sb.append(" expires: ").append(toIndentedString(expires)).append("\n");
|
||||
sb.append(" type: ").append(toIndentedString(type)).append("\n");
|
||||
sb.append("}");
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the given object to string with each line indented by 4 spaces (except the first line).
|
||||
*/
|
||||
private String toIndentedString(Object o) {
|
||||
if (o == null) {
|
||||
return "null";
|
||||
}
|
||||
return o.toString().replace("\n", "\n ");
|
||||
}
|
||||
}
|
105
src/main/java/me/minidigger/hangar/model/Body.java
Normal file
105
src/main/java/me/minidigger/hangar/model/Body.java
Normal file
@ -0,0 +1,105 @@
|
||||
package me.minidigger.hangar.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import java.util.Objects;
|
||||
import javax.validation.Valid;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
/**
|
||||
* Body
|
||||
*/
|
||||
@Validated
|
||||
public class Body {
|
||||
@JsonProperty("plugin-info")
|
||||
private DeployVersionInfo pluginInfo = null;
|
||||
|
||||
@JsonProperty("plugin-file")
|
||||
private Resource pluginFile = null;
|
||||
|
||||
public Body pluginInfo(DeployVersionInfo pluginInfo) {
|
||||
this.pluginInfo = pluginInfo;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get pluginInfo
|
||||
*
|
||||
* @return pluginInfo
|
||||
**/
|
||||
@ApiModelProperty(value = "")
|
||||
|
||||
@Valid
|
||||
public DeployVersionInfo getPluginInfo() {
|
||||
return pluginInfo;
|
||||
}
|
||||
|
||||
public void setPluginInfo(DeployVersionInfo pluginInfo) {
|
||||
this.pluginInfo = pluginInfo;
|
||||
}
|
||||
|
||||
public Body pluginFile(Resource pluginFile) {
|
||||
this.pluginFile = pluginFile;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* The jar/zip file to upload
|
||||
*
|
||||
* @return pluginFile
|
||||
**/
|
||||
@ApiModelProperty(value = "The jar/zip file to upload")
|
||||
|
||||
@Valid
|
||||
public Resource getPluginFile() {
|
||||
return pluginFile;
|
||||
}
|
||||
|
||||
public void setPluginFile(Resource pluginFile) {
|
||||
this.pluginFile = pluginFile;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
Body body = (Body) o;
|
||||
return Objects.equals(this.pluginInfo, body.pluginInfo) &&
|
||||
Objects.equals(this.pluginFile, body.pluginFile);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(pluginInfo, pluginFile);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("class Body {\n");
|
||||
|
||||
sb.append(" pluginInfo: ").append(toIndentedString(pluginInfo)).append("\n");
|
||||
sb.append(" pluginFile: ").append(toIndentedString(pluginFile)).append("\n");
|
||||
sb.append("}");
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the given object to string with each line indented by 4 spaces (except the first line).
|
||||
*/
|
||||
private String toIndentedString(Object o) {
|
||||
if (o == null) {
|
||||
return "null";
|
||||
}
|
||||
return o.toString().replace("\n", "\n ");
|
||||
}
|
||||
}
|
42
src/main/java/me/minidigger/hangar/model/Category.java
Normal file
42
src/main/java/me/minidigger/hangar/model/Category.java
Normal file
@ -0,0 +1,42 @@
|
||||
package me.minidigger.hangar.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import com.fasterxml.jackson.annotation.JsonValue;
|
||||
|
||||
/**
|
||||
* Gets or Sets Category
|
||||
*/
|
||||
public enum Category {
|
||||
ADMIN_TOOLS("admin_tools"),
|
||||
CHAT("chat"),
|
||||
DEV_TOOLS("dev_tools"),
|
||||
ECONOMY("economy"),
|
||||
GAMEPLAY("gameplay"),
|
||||
GAMES("games"),
|
||||
PROTECTION("protection"),
|
||||
ROLE_PLAYING("role_playing"),
|
||||
WORLD_MANAGEMENT("world_management"),
|
||||
MISC("misc");
|
||||
|
||||
private final String value;
|
||||
|
||||
Category(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
@JsonValue
|
||||
public String toString() {
|
||||
return String.valueOf(value);
|
||||
}
|
||||
|
||||
@JsonCreator
|
||||
public static Category fromValue(String text) {
|
||||
for (Category b : Category.values()) {
|
||||
if (String.valueOf(b.value).equals(text)) {
|
||||
return b;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
103
src/main/java/me/minidigger/hangar/model/Dependency.java
Normal file
103
src/main/java/me/minidigger/hangar/model/Dependency.java
Normal file
@ -0,0 +1,103 @@
|
||||
package me.minidigger.hangar.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import java.util.Objects;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
/**
|
||||
* ModelsProtocolsAPIV2VersionDependency
|
||||
*/
|
||||
@Validated
|
||||
public class Dependency {
|
||||
@JsonProperty("plugin_id")
|
||||
private String pluginId = null;
|
||||
|
||||
@JsonProperty("version")
|
||||
private String version = null;
|
||||
|
||||
public Dependency pluginId(String pluginId) {
|
||||
this.pluginId = pluginId;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get pluginId
|
||||
*
|
||||
* @return pluginId
|
||||
**/
|
||||
@ApiModelProperty(required = true, value = "")
|
||||
@NotNull
|
||||
|
||||
public String getPluginId() {
|
||||
return pluginId;
|
||||
}
|
||||
|
||||
public void setPluginId(String pluginId) {
|
||||
this.pluginId = pluginId;
|
||||
}
|
||||
|
||||
public Dependency version(String version) {
|
||||
this.version = version;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get version
|
||||
*
|
||||
* @return version
|
||||
**/
|
||||
@ApiModelProperty(value = "")
|
||||
|
||||
public String getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
public void setVersion(String version) {
|
||||
this.version = version;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
Dependency dependency = (Dependency) o;
|
||||
return Objects.equals(this.pluginId, dependency.pluginId) &&
|
||||
Objects.equals(this.version, dependency.version);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(pluginId, version);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("class ModelsProtocolsAPIV2VersionDependency {\n");
|
||||
|
||||
sb.append(" pluginId: ").append(toIndentedString(pluginId)).append("\n");
|
||||
sb.append(" version: ").append(toIndentedString(version)).append("\n");
|
||||
sb.append("}");
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the given object to string with each line indented by 4 spaces (except the first line).
|
||||
*/
|
||||
private String toIndentedString(Object o) {
|
||||
if (o == null) {
|
||||
return "null";
|
||||
}
|
||||
return o.toString().replace("\n", "\n ");
|
||||
}
|
||||
}
|
142
src/main/java/me/minidigger/hangar/model/DeployVersionInfo.java
Normal file
142
src/main/java/me/minidigger/hangar/model/DeployVersionInfo.java
Normal file
@ -0,0 +1,142 @@
|
||||
package me.minidigger.hangar.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import javax.validation.Valid;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
/**
|
||||
* DeployVersionInfo. Information about the version to create. Can be passed either as a file, or a string.
|
||||
*/
|
||||
@ApiModel(description = "DeployVersionInfo. Information about the version to create. Can be passed either as a file, or a string.")
|
||||
@Validated
|
||||
public class DeployVersionInfo {
|
||||
@JsonProperty("create_forum_post")
|
||||
private Boolean createForumPost = null;
|
||||
|
||||
@JsonProperty("description")
|
||||
private String description = null;
|
||||
|
||||
@JsonProperty("tags")
|
||||
@Valid
|
||||
private Map<String, Object> tags = null;
|
||||
|
||||
public DeployVersionInfo createForumPost(Boolean createForumPost) {
|
||||
this.createForumPost = createForumPost;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* If a post should be made on the forums after this version has been published.
|
||||
*
|
||||
* @return createForumPost
|
||||
**/
|
||||
@ApiModelProperty(value = "If a post should be made on the forums after this version has been published.")
|
||||
|
||||
public Boolean isCreateForumPost() {
|
||||
return createForumPost;
|
||||
}
|
||||
|
||||
public void setCreateForumPost(Boolean createForumPost) {
|
||||
this.createForumPost = createForumPost;
|
||||
}
|
||||
|
||||
public DeployVersionInfo description(String description) {
|
||||
this.description = description;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* The version description to post on both the version, and the forum post.
|
||||
*
|
||||
* @return description
|
||||
**/
|
||||
@ApiModelProperty(value = "The version description to post on both the version, and the forum post.")
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public DeployVersionInfo tags(Map<String, Object> tags) {
|
||||
this.tags = tags;
|
||||
return this;
|
||||
}
|
||||
|
||||
public DeployVersionInfo putTagsItem(String key, Object tagsItem) {
|
||||
if (this.tags == null) {
|
||||
this.tags = new HashMap<>();
|
||||
}
|
||||
this.tags.put(key, tagsItem);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Override the default for the tags specified here. If nothing is specified for a tag, Hangar will try to infer
|
||||
* what it should be instead. Most tags only allow one value, but a few allow multiple. In cases where multiple
|
||||
* values are specified for a tag that only allows a single, the first one will be used.
|
||||
*
|
||||
* @return tags
|
||||
**/
|
||||
@ApiModelProperty(value = "Override the default for the tags specified here. If nothing is specified for a tag, Hangar will try to infer what it should be instead. Most tags only allow one value, but a few allow multiple. In cases where multiple values are specified for a tag that only allows a single, the first one will be used.")
|
||||
|
||||
public Map<String, Object> getTags() {
|
||||
return tags;
|
||||
}
|
||||
|
||||
public void setTags(Map<String, Object> tags) {
|
||||
this.tags = tags;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
DeployVersionInfo deployVersionInfo = (DeployVersionInfo) o;
|
||||
return Objects.equals(this.createForumPost, deployVersionInfo.createForumPost) &&
|
||||
Objects.equals(this.description, deployVersionInfo.description) &&
|
||||
Objects.equals(this.tags, deployVersionInfo.tags);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(createForumPost, description, tags);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("class DeployVersionInfo {\n");
|
||||
|
||||
sb.append(" createForumPost: ").append(toIndentedString(createForumPost)).append("\n");
|
||||
sb.append(" description: ").append(toIndentedString(description)).append("\n");
|
||||
sb.append(" tags: ").append(toIndentedString(tags)).append("\n");
|
||||
sb.append("}");
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the given object to string with each line indented by 4 spaces (except the first line).
|
||||
*/
|
||||
private String toIndentedString(Object o) {
|
||||
if (o == null) {
|
||||
return "null";
|
||||
}
|
||||
return o.toString().replace("\n", "\n ");
|
||||
}
|
||||
}
|
130
src/main/java/me/minidigger/hangar/model/FileInfo.java
Normal file
130
src/main/java/me/minidigger/hangar/model/FileInfo.java
Normal file
@ -0,0 +1,130 @@
|
||||
package me.minidigger.hangar.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import java.util.Objects;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
/**
|
||||
* ModelsProtocolsAPIV2FileInfo
|
||||
*/
|
||||
@Validated
|
||||
public class FileInfo {
|
||||
@JsonProperty("name")
|
||||
private String name = null;
|
||||
|
||||
@JsonProperty("size_bytes")
|
||||
private Long sizeBytes = null;
|
||||
|
||||
@JsonProperty("md_5_hash")
|
||||
private String md5Hash = null;
|
||||
|
||||
public FileInfo name(String name) {
|
||||
this.name = name;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get name
|
||||
*
|
||||
* @return name
|
||||
**/
|
||||
@ApiModelProperty(required = true, value = "")
|
||||
@NotNull
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public FileInfo sizeBytes(Long sizeBytes) {
|
||||
this.sizeBytes = sizeBytes;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get sizeBytes
|
||||
*
|
||||
* @return sizeBytes
|
||||
**/
|
||||
@ApiModelProperty(required = true, value = "")
|
||||
@NotNull
|
||||
|
||||
public Long getSizeBytes() {
|
||||
return sizeBytes;
|
||||
}
|
||||
|
||||
public void setSizeBytes(Long sizeBytes) {
|
||||
this.sizeBytes = sizeBytes;
|
||||
}
|
||||
|
||||
public FileInfo md5Hash(String md5Hash) {
|
||||
this.md5Hash = md5Hash;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get md5Hash
|
||||
*
|
||||
* @return md5Hash
|
||||
**/
|
||||
@ApiModelProperty(required = true, value = "")
|
||||
@NotNull
|
||||
|
||||
public String getMd5Hash() {
|
||||
return md5Hash;
|
||||
}
|
||||
|
||||
public void setMd5Hash(String md5Hash) {
|
||||
this.md5Hash = md5Hash;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
FileInfo fileInfo = (FileInfo) o;
|
||||
return Objects.equals(this.name, fileInfo.name) &&
|
||||
Objects.equals(this.sizeBytes, fileInfo.sizeBytes) &&
|
||||
Objects.equals(this.md5Hash, fileInfo.md5Hash);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(name, sizeBytes, md5Hash);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("class ModelsProtocolsAPIV2FileInfo {\n");
|
||||
|
||||
sb.append(" name: ").append(toIndentedString(name)).append("\n");
|
||||
sb.append(" sizeBytes: ").append(toIndentedString(sizeBytes)).append("\n");
|
||||
sb.append(" md5Hash: ").append(toIndentedString(md5Hash)).append("\n");
|
||||
sb.append("}");
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the given object to string with each line indented by 4 spaces (except the first line).
|
||||
*/
|
||||
private String toIndentedString(Object o) {
|
||||
if (o == null) {
|
||||
return "null";
|
||||
}
|
||||
return o.toString().replace("\n", "\n ");
|
||||
}
|
||||
}
|
@ -0,0 +1,59 @@
|
||||
package me.minidigger.hangar.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import com.fasterxml.jackson.annotation.JsonValue;
|
||||
|
||||
/**
|
||||
* Gets or Sets NamedPermission
|
||||
*/
|
||||
public enum NamedPermission {
|
||||
VIEW_PUBLIC_INFO("view_public_info"),
|
||||
EDIT_OWN_USER_SETTINGS("edit_own_user_settings"),
|
||||
EDIT_API_KEYS("edit_api_keys"),
|
||||
EDIT_SUBJECT_SETTINGS("edit_subject_settings"),
|
||||
MANAGE_SUBJECT_MEMBERS("manage_subject_members"),
|
||||
IS_SUBJECT_OWNER("is_subject_owner"),
|
||||
CREATE_PROJECT("create_project"),
|
||||
EDIT_PAGE("edit_page"),
|
||||
DELETE_PROJECT("delete_project"),
|
||||
CREATE_VERSION("create_version"),
|
||||
EDIT_VERSION("edit_version"),
|
||||
DELETE_VERSION("delete_version"),
|
||||
EDIT_TAGS("edit_tags"),
|
||||
CREATE_ORGANIZATION("create_organization"),
|
||||
POST_AS_ORGANIZATION("post_as_organization"),
|
||||
MOD_NOTES_AND_FLAGS("mod_notes_and_flags"),
|
||||
SEE_HIDDEN("see_hidden"),
|
||||
IS_STAFF("is_staff"),
|
||||
REVIEWER("reviewer"),
|
||||
VIEW_HEALTH("view_health"),
|
||||
VIEW_IP("view_ip"),
|
||||
VIEW_STATS("view_stats"),
|
||||
VIEW_LOGS("view_logs"),
|
||||
MANUAL_VALUE_CHANGES("manual_value_changes"),
|
||||
HARD_DELETE_PROJECT("hard_delete_project"),
|
||||
HARD_DELETE_VERSION("hard_delete_version"),
|
||||
EDIT_ALL_USER_SETTINGS("edit_all_user_settings");
|
||||
|
||||
private final String value;
|
||||
|
||||
NamedPermission(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
@JsonValue
|
||||
public String toString() {
|
||||
return String.valueOf(value);
|
||||
}
|
||||
|
||||
@JsonCreator
|
||||
public static NamedPermission fromValue(String text) {
|
||||
for (NamedPermission b : NamedPermission.values()) {
|
||||
if (String.valueOf(b.value).equals(text)) {
|
||||
return b;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
@ -0,0 +1,114 @@
|
||||
package me.minidigger.hangar.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
/**
|
||||
* ControllersApiv2ApiV2ControllerPaginatedCompactProjectResult
|
||||
*/
|
||||
@Validated
|
||||
public class PaginatedCompactProjectResult {
|
||||
@JsonProperty("pagination")
|
||||
private Pagination pagination = null;
|
||||
|
||||
@JsonProperty("result")
|
||||
@Valid
|
||||
private List<ProjectCompact> result = new ArrayList<>();
|
||||
|
||||
public PaginatedCompactProjectResult pagination(Pagination pagination) {
|
||||
this.pagination = pagination;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get pagination
|
||||
*
|
||||
* @return pagination
|
||||
**/
|
||||
@ApiModelProperty(required = true, value = "")
|
||||
@NotNull
|
||||
|
||||
@Valid
|
||||
public Pagination getPagination() {
|
||||
return pagination;
|
||||
}
|
||||
|
||||
public void setPagination(Pagination pagination) {
|
||||
this.pagination = pagination;
|
||||
}
|
||||
|
||||
public PaginatedCompactProjectResult result(List<ProjectCompact> result) {
|
||||
this.result = result;
|
||||
return this;
|
||||
}
|
||||
|
||||
public PaginatedCompactProjectResult addResultItem(ProjectCompact resultItem) {
|
||||
this.result.add(resultItem);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get result
|
||||
*
|
||||
* @return result
|
||||
**/
|
||||
@ApiModelProperty(required = true, value = "")
|
||||
@NotNull
|
||||
@Valid
|
||||
public List<ProjectCompact> getResult() {
|
||||
return result;
|
||||
}
|
||||
|
||||
public void setResult(List<ProjectCompact> result) {
|
||||
this.result = result;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
PaginatedCompactProjectResult controllersApiv2ApiV2ControllerPaginatedCompactProjectResult = (PaginatedCompactProjectResult) o;
|
||||
return Objects.equals(this.pagination, controllersApiv2ApiV2ControllerPaginatedCompactProjectResult.pagination) &&
|
||||
Objects.equals(this.result, controllersApiv2ApiV2ControllerPaginatedCompactProjectResult.result);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(pagination, result);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("class ControllersApiv2ApiV2ControllerPaginatedCompactProjectResult {\n");
|
||||
|
||||
sb.append(" pagination: ").append(toIndentedString(pagination)).append("\n");
|
||||
sb.append(" result: ").append(toIndentedString(result)).append("\n");
|
||||
sb.append("}");
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the given object to string with each line indented by 4 spaces (except the first line).
|
||||
*/
|
||||
private String toIndentedString(Object o) {
|
||||
if (o == null) {
|
||||
return "null";
|
||||
}
|
||||
return o.toString().replace("\n", "\n ");
|
||||
}
|
||||
}
|
@ -0,0 +1,114 @@
|
||||
package me.minidigger.hangar.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
/**
|
||||
* ControllersApiv2ApiV2ControllerPaginatedProjectResult
|
||||
*/
|
||||
@Validated
|
||||
public class PaginatedProjectResult {
|
||||
@JsonProperty("pagination")
|
||||
private Pagination pagination = null;
|
||||
|
||||
@JsonProperty("result")
|
||||
@Valid
|
||||
private List<Project> result = new ArrayList<>();
|
||||
|
||||
public PaginatedProjectResult pagination(Pagination pagination) {
|
||||
this.pagination = pagination;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get pagination
|
||||
*
|
||||
* @return pagination
|
||||
**/
|
||||
@ApiModelProperty(required = true, value = "")
|
||||
@NotNull
|
||||
|
||||
@Valid
|
||||
public Pagination getPagination() {
|
||||
return pagination;
|
||||
}
|
||||
|
||||
public void setPagination(Pagination pagination) {
|
||||
this.pagination = pagination;
|
||||
}
|
||||
|
||||
public PaginatedProjectResult result(List<Project> result) {
|
||||
this.result = result;
|
||||
return this;
|
||||
}
|
||||
|
||||
public PaginatedProjectResult addResultItem(Project resultItem) {
|
||||
this.result.add(resultItem);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get result
|
||||
*
|
||||
* @return result
|
||||
**/
|
||||
@ApiModelProperty(required = true, value = "")
|
||||
@NotNull
|
||||
@Valid
|
||||
public List<Project> getResult() {
|
||||
return result;
|
||||
}
|
||||
|
||||
public void setResult(List<Project> result) {
|
||||
this.result = result;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
PaginatedProjectResult paginatedProjectResult = (PaginatedProjectResult) o;
|
||||
return Objects.equals(this.pagination, paginatedProjectResult.pagination) &&
|
||||
Objects.equals(this.result, paginatedProjectResult.result);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(pagination, result);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("class ControllersApiv2ApiV2ControllerPaginatedProjectResult {\n");
|
||||
|
||||
sb.append(" pagination: ").append(toIndentedString(pagination)).append("\n");
|
||||
sb.append(" result: ").append(toIndentedString(result)).append("\n");
|
||||
sb.append("}");
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the given object to string with each line indented by 4 spaces (except the first line).
|
||||
*/
|
||||
private String toIndentedString(Object o) {
|
||||
if (o == null) {
|
||||
return "null";
|
||||
}
|
||||
return o.toString().replace("\n", "\n ");
|
||||
}
|
||||
}
|
@ -0,0 +1,114 @@
|
||||
package me.minidigger.hangar.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
/**
|
||||
* ControllersApiv2ApiV2ControllerPaginatedVersionResult
|
||||
*/
|
||||
@Validated
|
||||
public class PaginatedVersionResult {
|
||||
@JsonProperty("pagination")
|
||||
private Pagination pagination = null;
|
||||
|
||||
@JsonProperty("result")
|
||||
@Valid
|
||||
private List<Version> result = new ArrayList<>();
|
||||
|
||||
public PaginatedVersionResult pagination(Pagination pagination) {
|
||||
this.pagination = pagination;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get pagination
|
||||
*
|
||||
* @return pagination
|
||||
**/
|
||||
@ApiModelProperty(required = true, value = "")
|
||||
@NotNull
|
||||
|
||||
@Valid
|
||||
public Pagination getPagination() {
|
||||
return pagination;
|
||||
}
|
||||
|
||||
public void setPagination(Pagination pagination) {
|
||||
this.pagination = pagination;
|
||||
}
|
||||
|
||||
public PaginatedVersionResult result(List<Version> result) {
|
||||
this.result = result;
|
||||
return this;
|
||||
}
|
||||
|
||||
public PaginatedVersionResult addResultItem(Version resultItem) {
|
||||
this.result.add(resultItem);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get result
|
||||
*
|
||||
* @return result
|
||||
**/
|
||||
@ApiModelProperty(required = true, value = "")
|
||||
@NotNull
|
||||
@Valid
|
||||
public List<Version> getResult() {
|
||||
return result;
|
||||
}
|
||||
|
||||
public void setResult(List<Version> result) {
|
||||
this.result = result;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
PaginatedVersionResult paginatedVersionResult = (PaginatedVersionResult) o;
|
||||
return Objects.equals(this.pagination, paginatedVersionResult.pagination) &&
|
||||
Objects.equals(this.result, paginatedVersionResult.result);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(pagination, result);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("class ControllersApiv2ApiV2ControllerPaginatedVersionResult {\n");
|
||||
|
||||
sb.append(" pagination: ").append(toIndentedString(pagination)).append("\n");
|
||||
sb.append(" result: ").append(toIndentedString(result)).append("\n");
|
||||
sb.append("}");
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the given object to string with each line indented by 4 spaces (except the first line).
|
||||
*/
|
||||
private String toIndentedString(Object o) {
|
||||
if (o == null) {
|
||||
return "null";
|
||||
}
|
||||
return o.toString().replace("\n", "\n ");
|
||||
}
|
||||
}
|
130
src/main/java/me/minidigger/hangar/model/Pagination.java
Normal file
130
src/main/java/me/minidigger/hangar/model/Pagination.java
Normal file
@ -0,0 +1,130 @@
|
||||
package me.minidigger.hangar.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import java.util.Objects;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
/**
|
||||
* ControllersApiv2ApiV2ControllerPagination
|
||||
*/
|
||||
@Validated
|
||||
public class Pagination {
|
||||
@JsonProperty("limit")
|
||||
private Long limit = null;
|
||||
|
||||
@JsonProperty("offset")
|
||||
private Long offset = null;
|
||||
|
||||
@JsonProperty("count")
|
||||
private Long count = null;
|
||||
|
||||
public Pagination limit(Long limit) {
|
||||
this.limit = limit;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get limit
|
||||
*
|
||||
* @return limit
|
||||
**/
|
||||
@ApiModelProperty(required = true, value = "")
|
||||
@NotNull
|
||||
|
||||
public Long getLimit() {
|
||||
return limit;
|
||||
}
|
||||
|
||||
public void setLimit(Long limit) {
|
||||
this.limit = limit;
|
||||
}
|
||||
|
||||
public Pagination offset(Long offset) {
|
||||
this.offset = offset;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get offset
|
||||
*
|
||||
* @return offset
|
||||
**/
|
||||
@ApiModelProperty(required = true, value = "")
|
||||
@NotNull
|
||||
|
||||
public Long getOffset() {
|
||||
return offset;
|
||||
}
|
||||
|
||||
public void setOffset(Long offset) {
|
||||
this.offset = offset;
|
||||
}
|
||||
|
||||
public Pagination count(Long count) {
|
||||
this.count = count;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get count
|
||||
*
|
||||
* @return count
|
||||
**/
|
||||
@ApiModelProperty(required = true, value = "")
|
||||
@NotNull
|
||||
|
||||
public Long getCount() {
|
||||
return count;
|
||||
}
|
||||
|
||||
public void setCount(Long count) {
|
||||
this.count = count;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
Pagination pagination = (Pagination) o;
|
||||
return Objects.equals(this.limit, pagination.limit) &&
|
||||
Objects.equals(this.offset, pagination.offset) &&
|
||||
Objects.equals(this.count, pagination.count);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(limit, offset, count);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("class ControllersApiv2ApiV2ControllerPagination {\n");
|
||||
|
||||
sb.append(" limit: ").append(toIndentedString(limit)).append("\n");
|
||||
sb.append(" offset: ").append(toIndentedString(offset)).append("\n");
|
||||
sb.append(" count: ").append(toIndentedString(count)).append("\n");
|
||||
sb.append("}");
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the given object to string with each line indented by 4 spaces (except the first line).
|
||||
*/
|
||||
private String toIndentedString(Object o) {
|
||||
if (o == null) {
|
||||
return "null";
|
||||
}
|
||||
return o.toString().replace("\n", "\n ");
|
||||
}
|
||||
}
|
105
src/main/java/me/minidigger/hangar/model/PermissionCheck.java
Normal file
105
src/main/java/me/minidigger/hangar/model/PermissionCheck.java
Normal file
@ -0,0 +1,105 @@
|
||||
package me.minidigger.hangar.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import java.util.Objects;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
/**
|
||||
* ControllersApiv2ApiV2ControllerPermissionCheck
|
||||
*/
|
||||
@Validated
|
||||
public class PermissionCheck {
|
||||
|
||||
@JsonProperty("type")
|
||||
private PermissionType type = null;
|
||||
|
||||
@JsonProperty("result")
|
||||
private Boolean result = null;
|
||||
|
||||
public PermissionCheck type(PermissionType type) {
|
||||
this.type = type;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get type
|
||||
*
|
||||
* @return type
|
||||
**/
|
||||
@ApiModelProperty(required = true, value = "")
|
||||
@NotNull
|
||||
|
||||
public PermissionType getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(PermissionType type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public PermissionCheck result(Boolean result) {
|
||||
this.result = result;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get result
|
||||
*
|
||||
* @return result
|
||||
**/
|
||||
@ApiModelProperty(required = true, value = "")
|
||||
@NotNull
|
||||
|
||||
public Boolean isResult() {
|
||||
return result;
|
||||
}
|
||||
|
||||
public void setResult(Boolean result) {
|
||||
this.result = result;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
PermissionCheck controllersApiv2ApiV2ControllerPermissionCheck = (PermissionCheck) o;
|
||||
return Objects.equals(this.type, controllersApiv2ApiV2ControllerPermissionCheck.type) &&
|
||||
Objects.equals(this.result, controllersApiv2ApiV2ControllerPermissionCheck.result);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(type, result);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("class ControllersApiv2ApiV2ControllerPermissionCheck {\n");
|
||||
|
||||
sb.append(" type: ").append(toIndentedString(type)).append("\n");
|
||||
sb.append(" result: ").append(toIndentedString(result)).append("\n");
|
||||
sb.append("}");
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the given object to string with each line indented by 4 spaces (except the first line).
|
||||
*/
|
||||
private String toIndentedString(Object o) {
|
||||
if (o == null) {
|
||||
return "null";
|
||||
}
|
||||
return o.toString().replace("\n", "\n ");
|
||||
}
|
||||
}
|
37
src/main/java/me/minidigger/hangar/model/PermissionType.java
Normal file
37
src/main/java/me/minidigger/hangar/model/PermissionType.java
Normal file
@ -0,0 +1,37 @@
|
||||
package me.minidigger.hangar.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import com.fasterxml.jackson.annotation.JsonValue;
|
||||
|
||||
/**
|
||||
* Gets or Sets type
|
||||
*/
|
||||
public enum PermissionType {
|
||||
GLOBAL("global"),
|
||||
|
||||
PROJECT("project"),
|
||||
|
||||
ORGANIZATION("organization");
|
||||
|
||||
private final String value;
|
||||
|
||||
PermissionType(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
@JsonValue
|
||||
public String toString() {
|
||||
return String.valueOf(value);
|
||||
}
|
||||
|
||||
@JsonCreator
|
||||
public static PermissionType fromValue(String text) {
|
||||
for (PermissionType b : PermissionType.values()) {
|
||||
if (String.valueOf(b.value).equals(text)) {
|
||||
return b;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
114
src/main/java/me/minidigger/hangar/model/Permissions.java
Normal file
114
src/main/java/me/minidigger/hangar/model/Permissions.java
Normal file
@ -0,0 +1,114 @@
|
||||
package me.minidigger.hangar.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
/**
|
||||
* ControllersApiv2ApiV2ControllerKeyPermissions
|
||||
*/
|
||||
@Validated
|
||||
public class Permissions {
|
||||
|
||||
@JsonProperty("type")
|
||||
private PermissionType type = null;
|
||||
|
||||
@JsonProperty("permissions")
|
||||
@Valid
|
||||
private List<NamedPermission> permissions = new ArrayList<>();
|
||||
|
||||
public Permissions type(PermissionType type) {
|
||||
this.type = type;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get type
|
||||
*
|
||||
* @return type
|
||||
**/
|
||||
@ApiModelProperty(required = true, value = "")
|
||||
@NotNull
|
||||
|
||||
public PermissionType getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(PermissionType type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public Permissions permissions(List<NamedPermission> permissions) {
|
||||
this.permissions = permissions;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Permissions addPermissionsItem(NamedPermission permissionsItem) {
|
||||
this.permissions.add(permissionsItem);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get permissions
|
||||
*
|
||||
* @return permissions
|
||||
**/
|
||||
@ApiModelProperty(required = true, value = "")
|
||||
@NotNull
|
||||
@Valid
|
||||
public List<NamedPermission> getPermissions() {
|
||||
return permissions;
|
||||
}
|
||||
|
||||
public void setPermissions(List<NamedPermission> permissions) {
|
||||
this.permissions = permissions;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
Permissions controllersApiv2ApiV2ControllerKeyPermissions = (Permissions) o;
|
||||
return Objects.equals(this.type, controllersApiv2ApiV2ControllerKeyPermissions.type) &&
|
||||
Objects.equals(this.permissions, controllersApiv2ApiV2ControllerKeyPermissions.permissions);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(type, permissions);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("class ControllersApiv2ApiV2ControllerKeyPermissions {\n");
|
||||
|
||||
sb.append(" type: ").append(toIndentedString(type)).append("\n");
|
||||
sb.append(" permissions: ").append(toIndentedString(permissions)).append("\n");
|
||||
sb.append("}");
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the given object to string with each line indented by 4 spaces (except the first line).
|
||||
*/
|
||||
private String toIndentedString(Object o) {
|
||||
if (o == null) {
|
||||
return "null";
|
||||
}
|
||||
return o.toString().replace("\n", "\n ");
|
||||
}
|
||||
}
|
406
src/main/java/me/minidigger/hangar/model/Project.java
Normal file
406
src/main/java/me/minidigger/hangar/model/Project.java
Normal file
@ -0,0 +1,406 @@
|
||||
package me.minidigger.hangar.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.threeten.bp.OffsetDateTime;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
/**
|
||||
* ModelsProtocolsAPIV2Project
|
||||
*/
|
||||
@Validated
|
||||
public class Project {
|
||||
@JsonProperty("created_at")
|
||||
private OffsetDateTime createdAt = null;
|
||||
|
||||
@JsonProperty("plugin_id")
|
||||
private String pluginId = null;
|
||||
|
||||
@JsonProperty("name")
|
||||
private String name = null;
|
||||
|
||||
@JsonProperty("namespace")
|
||||
private ProjectNamespace namespace = null;
|
||||
|
||||
@JsonProperty("promoted_versions")
|
||||
@Valid
|
||||
private List<PromotedVersion> promotedVersions = new ArrayList<>();
|
||||
|
||||
@JsonProperty("stats")
|
||||
private ProjectStatsAll stats = null;
|
||||
|
||||
@JsonProperty("category")
|
||||
private Category category = null;
|
||||
|
||||
@JsonProperty("description")
|
||||
private String description = null;
|
||||
|
||||
@JsonProperty("last_updated")
|
||||
private OffsetDateTime lastUpdated = null;
|
||||
|
||||
@JsonProperty("visibility")
|
||||
private Visibility visibility = null;
|
||||
|
||||
@JsonProperty("user_actions")
|
||||
private UserActions userActions = null;
|
||||
|
||||
@JsonProperty("settings")
|
||||
private ProjectSettings settings = null;
|
||||
|
||||
@JsonProperty("icon_url")
|
||||
private String iconUrl = null;
|
||||
|
||||
public Project createdAt(OffsetDateTime createdAt) {
|
||||
this.createdAt = createdAt;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get createdAt
|
||||
*
|
||||
* @return createdAt
|
||||
**/
|
||||
@ApiModelProperty(required = true, value = "")
|
||||
@NotNull
|
||||
|
||||
@Valid
|
||||
public OffsetDateTime getCreatedAt() {
|
||||
return createdAt;
|
||||
}
|
||||
|
||||
public void setCreatedAt(OffsetDateTime createdAt) {
|
||||
this.createdAt = createdAt;
|
||||
}
|
||||
|
||||
public Project pluginId(String pluginId) {
|
||||
this.pluginId = pluginId;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get pluginId
|
||||
*
|
||||
* @return pluginId
|
||||
**/
|
||||
@ApiModelProperty(required = true, value = "")
|
||||
@NotNull
|
||||
|
||||
public String getPluginId() {
|
||||
return pluginId;
|
||||
}
|
||||
|
||||
public void setPluginId(String pluginId) {
|
||||
this.pluginId = pluginId;
|
||||
}
|
||||
|
||||
public Project name(String name) {
|
||||
this.name = name;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get name
|
||||
*
|
||||
* @return name
|
||||
**/
|
||||
@ApiModelProperty(required = true, value = "")
|
||||
@NotNull
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public Project namespace(ProjectNamespace namespace) {
|
||||
this.namespace = namespace;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get namespace
|
||||
*
|
||||
* @return namespace
|
||||
**/
|
||||
@ApiModelProperty(required = true, value = "")
|
||||
@NotNull
|
||||
|
||||
@Valid
|
||||
public ProjectNamespace getNamespace() {
|
||||
return namespace;
|
||||
}
|
||||
|
||||
public void setNamespace(ProjectNamespace namespace) {
|
||||
this.namespace = namespace;
|
||||
}
|
||||
|
||||
public Project promotedVersions(List<PromotedVersion> promotedVersions) {
|
||||
this.promotedVersions = promotedVersions;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Project addPromotedVersionsItem(PromotedVersion promotedVersionsItem) {
|
||||
this.promotedVersions.add(promotedVersionsItem);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get promotedVersions
|
||||
*
|
||||
* @return promotedVersions
|
||||
**/
|
||||
@ApiModelProperty(required = true, value = "")
|
||||
@NotNull
|
||||
@Valid
|
||||
public List<PromotedVersion> getPromotedVersions() {
|
||||
return promotedVersions;
|
||||
}
|
||||
|
||||
public void setPromotedVersions(List<PromotedVersion> promotedVersions) {
|
||||
this.promotedVersions = promotedVersions;
|
||||
}
|
||||
|
||||
public Project stats(ProjectStatsAll stats) {
|
||||
this.stats = stats;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get stats
|
||||
*
|
||||
* @return stats
|
||||
**/
|
||||
@ApiModelProperty(required = true, value = "")
|
||||
@NotNull
|
||||
|
||||
@Valid
|
||||
public ProjectStatsAll getStats() {
|
||||
return stats;
|
||||
}
|
||||
|
||||
public void setStats(ProjectStatsAll stats) {
|
||||
this.stats = stats;
|
||||
}
|
||||
|
||||
public Project category(Category category) {
|
||||
this.category = category;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get category
|
||||
*
|
||||
* @return category
|
||||
**/
|
||||
@ApiModelProperty(required = true, value = "")
|
||||
@NotNull
|
||||
|
||||
@Valid
|
||||
public Category getCategory() {
|
||||
return category;
|
||||
}
|
||||
|
||||
public void setCategory(Category category) {
|
||||
this.category = category;
|
||||
}
|
||||
|
||||
public Project description(String description) {
|
||||
this.description = description;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get description
|
||||
*
|
||||
* @return description
|
||||
**/
|
||||
@ApiModelProperty(value = "")
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public Project lastUpdated(OffsetDateTime lastUpdated) {
|
||||
this.lastUpdated = lastUpdated;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get lastUpdated
|
||||
*
|
||||
* @return lastUpdated
|
||||
**/
|
||||
@ApiModelProperty(required = true, value = "")
|
||||
@NotNull
|
||||
|
||||
@Valid
|
||||
public OffsetDateTime getLastUpdated() {
|
||||
return lastUpdated;
|
||||
}
|
||||
|
||||
public void setLastUpdated(OffsetDateTime lastUpdated) {
|
||||
this.lastUpdated = lastUpdated;
|
||||
}
|
||||
|
||||
public Project visibility(Visibility visibility) {
|
||||
this.visibility = visibility;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get visibility
|
||||
*
|
||||
* @return visibility
|
||||
**/
|
||||
@ApiModelProperty(required = true, value = "")
|
||||
@NotNull
|
||||
|
||||
public Visibility getVisibility() {
|
||||
return visibility;
|
||||
}
|
||||
|
||||
public void setVisibility(Visibility visibility) {
|
||||
this.visibility = visibility;
|
||||
}
|
||||
|
||||
public Project userActions(UserActions userActions) {
|
||||
this.userActions = userActions;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get userActions
|
||||
*
|
||||
* @return userActions
|
||||
**/
|
||||
@ApiModelProperty(required = true, value = "")
|
||||
@NotNull
|
||||
|
||||
@Valid
|
||||
public UserActions getUserActions() {
|
||||
return userActions;
|
||||
}
|
||||
|
||||
public void setUserActions(UserActions userActions) {
|
||||
this.userActions = userActions;
|
||||
}
|
||||
|
||||
public Project settings(ProjectSettings settings) {
|
||||
this.settings = settings;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get settings
|
||||
*
|
||||
* @return settings
|
||||
**/
|
||||
@ApiModelProperty(required = true, value = "")
|
||||
@NotNull
|
||||
|
||||
@Valid
|
||||
public ProjectSettings getSettings() {
|
||||
return settings;
|
||||
}
|
||||
|
||||
public void setSettings(ProjectSettings settings) {
|
||||
this.settings = settings;
|
||||
}
|
||||
|
||||
public Project iconUrl(String iconUrl) {
|
||||
this.iconUrl = iconUrl;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get iconUrl
|
||||
*
|
||||
* @return iconUrl
|
||||
**/
|
||||
@ApiModelProperty(required = true, value = "")
|
||||
@NotNull
|
||||
|
||||
public String getIconUrl() {
|
||||
return iconUrl;
|
||||
}
|
||||
|
||||
public void setIconUrl(String iconUrl) {
|
||||
this.iconUrl = iconUrl;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
Project project = (Project) o;
|
||||
return Objects.equals(this.createdAt, project.createdAt) &&
|
||||
Objects.equals(this.pluginId, project.pluginId) &&
|
||||
Objects.equals(this.name, project.name) &&
|
||||
Objects.equals(this.namespace, project.namespace) &&
|
||||
Objects.equals(this.promotedVersions, project.promotedVersions) &&
|
||||
Objects.equals(this.stats, project.stats) &&
|
||||
Objects.equals(this.category, project.category) &&
|
||||
Objects.equals(this.description, project.description) &&
|
||||
Objects.equals(this.lastUpdated, project.lastUpdated) &&
|
||||
Objects.equals(this.visibility, project.visibility) &&
|
||||
Objects.equals(this.userActions, project.userActions) &&
|
||||
Objects.equals(this.settings, project.settings) &&
|
||||
Objects.equals(this.iconUrl, project.iconUrl);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(createdAt, pluginId, name, namespace, promotedVersions, stats, category, description, lastUpdated, visibility, userActions, settings, iconUrl);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("class ModelsProtocolsAPIV2Project {\n");
|
||||
|
||||
sb.append(" createdAt: ").append(toIndentedString(createdAt)).append("\n");
|
||||
sb.append(" pluginId: ").append(toIndentedString(pluginId)).append("\n");
|
||||
sb.append(" name: ").append(toIndentedString(name)).append("\n");
|
||||
sb.append(" namespace: ").append(toIndentedString(namespace)).append("\n");
|
||||
sb.append(" promotedVersions: ").append(toIndentedString(promotedVersions)).append("\n");
|
||||
sb.append(" stats: ").append(toIndentedString(stats)).append("\n");
|
||||
sb.append(" category: ").append(toIndentedString(category)).append("\n");
|
||||
sb.append(" description: ").append(toIndentedString(description)).append("\n");
|
||||
sb.append(" lastUpdated: ").append(toIndentedString(lastUpdated)).append("\n");
|
||||
sb.append(" visibility: ").append(toIndentedString(visibility)).append("\n");
|
||||
sb.append(" userActions: ").append(toIndentedString(userActions)).append("\n");
|
||||
sb.append(" settings: ").append(toIndentedString(settings)).append("\n");
|
||||
sb.append(" iconUrl: ").append(toIndentedString(iconUrl)).append("\n");
|
||||
sb.append("}");
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the given object to string with each line indented by 4 spaces (except the first line).
|
||||
*/
|
||||
private String toIndentedString(Object o) {
|
||||
if (o == null) {
|
||||
return "null";
|
||||
}
|
||||
return o.toString().replace("\n", "\n ");
|
||||
}
|
||||
}
|
285
src/main/java/me/minidigger/hangar/model/ProjectCompact.java
Normal file
285
src/main/java/me/minidigger/hangar/model/ProjectCompact.java
Normal file
@ -0,0 +1,285 @@
|
||||
package me.minidigger.hangar.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonValue;
|
||||
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
/**
|
||||
* ModelsProtocolsAPIV2CompactProject
|
||||
*/
|
||||
@Validated
|
||||
public class ProjectCompact {
|
||||
@JsonProperty("plugin_id")
|
||||
private String pluginId = null;
|
||||
|
||||
@JsonProperty("name")
|
||||
private String name = null;
|
||||
|
||||
@JsonProperty("namespace")
|
||||
private ProjectNamespace namespace = null;
|
||||
|
||||
@JsonProperty("promoted_versions")
|
||||
@Valid
|
||||
private List<PromotedVersion> promotedVersions = new ArrayList<>();
|
||||
|
||||
@JsonProperty("stats")
|
||||
private ProjectStatsAll stats = null;
|
||||
|
||||
@JsonProperty("category")
|
||||
private Category category = null;
|
||||
|
||||
/**
|
||||
* Gets or Sets visibility
|
||||
*/
|
||||
public enum VisibilityEnum {
|
||||
PUBLIC("public"),
|
||||
|
||||
NEW("new"),
|
||||
|
||||
NEEDSCHANGES("needsChanges"),
|
||||
|
||||
NEEDSAPPROVAL("needsApproval"),
|
||||
|
||||
SOFTDELETE("softDelete");
|
||||
|
||||
private final String value;
|
||||
|
||||
VisibilityEnum(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
@JsonValue
|
||||
public String toString() {
|
||||
return String.valueOf(value);
|
||||
}
|
||||
|
||||
@JsonCreator
|
||||
public static VisibilityEnum fromValue(String text) {
|
||||
for (VisibilityEnum b : VisibilityEnum.values()) {
|
||||
if (String.valueOf(b.value).equals(text)) {
|
||||
return b;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@JsonProperty("visibility")
|
||||
private VisibilityEnum visibility = null;
|
||||
|
||||
public ProjectCompact pluginId(String pluginId) {
|
||||
this.pluginId = pluginId;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get pluginId
|
||||
*
|
||||
* @return pluginId
|
||||
**/
|
||||
@ApiModelProperty(required = true, value = "")
|
||||
@NotNull
|
||||
|
||||
public String getPluginId() {
|
||||
return pluginId;
|
||||
}
|
||||
|
||||
public void setPluginId(String pluginId) {
|
||||
this.pluginId = pluginId;
|
||||
}
|
||||
|
||||
public ProjectCompact name(String name) {
|
||||
this.name = name;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get name
|
||||
*
|
||||
* @return name
|
||||
**/
|
||||
@ApiModelProperty(required = true, value = "")
|
||||
@NotNull
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public ProjectCompact namespace(ProjectNamespace namespace) {
|
||||
this.namespace = namespace;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get namespace
|
||||
*
|
||||
* @return namespace
|
||||
**/
|
||||
@ApiModelProperty(required = true, value = "")
|
||||
@NotNull
|
||||
|
||||
@Valid
|
||||
public ProjectNamespace getNamespace() {
|
||||
return namespace;
|
||||
}
|
||||
|
||||
public void setNamespace(ProjectNamespace namespace) {
|
||||
this.namespace = namespace;
|
||||
}
|
||||
|
||||
public ProjectCompact promotedVersions(List<PromotedVersion> promotedVersions) {
|
||||
this.promotedVersions = promotedVersions;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ProjectCompact addPromotedVersionsItem(PromotedVersion promotedVersionsItem) {
|
||||
this.promotedVersions.add(promotedVersionsItem);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get promotedVersions
|
||||
*
|
||||
* @return promotedVersions
|
||||
**/
|
||||
@ApiModelProperty(required = true, value = "")
|
||||
@NotNull
|
||||
@Valid
|
||||
public List<PromotedVersion> getPromotedVersions() {
|
||||
return promotedVersions;
|
||||
}
|
||||
|
||||
public void setPromotedVersions(List<PromotedVersion> promotedVersions) {
|
||||
this.promotedVersions = promotedVersions;
|
||||
}
|
||||
|
||||
public ProjectCompact stats(ProjectStatsAll stats) {
|
||||
this.stats = stats;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get stats
|
||||
*
|
||||
* @return stats
|
||||
**/
|
||||
@ApiModelProperty(required = true, value = "")
|
||||
@NotNull
|
||||
|
||||
@Valid
|
||||
public ProjectStatsAll getStats() {
|
||||
return stats;
|
||||
}
|
||||
|
||||
public void setStats(ProjectStatsAll stats) {
|
||||
this.stats = stats;
|
||||
}
|
||||
|
||||
public ProjectCompact category(Category category) {
|
||||
this.category = category;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get category
|
||||
*
|
||||
* @return category
|
||||
**/
|
||||
@ApiModelProperty(required = true, value = "")
|
||||
@NotNull
|
||||
|
||||
@Valid
|
||||
public Category getCategory() {
|
||||
return category;
|
||||
}
|
||||
|
||||
public void setCategory(Category category) {
|
||||
this.category = category;
|
||||
}
|
||||
|
||||
public ProjectCompact visibility(VisibilityEnum visibility) {
|
||||
this.visibility = visibility;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get visibility
|
||||
*
|
||||
* @return visibility
|
||||
**/
|
||||
@ApiModelProperty(required = true, value = "")
|
||||
@NotNull
|
||||
|
||||
public VisibilityEnum getVisibility() {
|
||||
return visibility;
|
||||
}
|
||||
|
||||
public void setVisibility(VisibilityEnum visibility) {
|
||||
this.visibility = visibility;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
ProjectCompact projectCompact = (ProjectCompact) o;
|
||||
return Objects.equals(this.pluginId, projectCompact.pluginId) &&
|
||||
Objects.equals(this.name, projectCompact.name) &&
|
||||
Objects.equals(this.namespace, projectCompact.namespace) &&
|
||||
Objects.equals(this.promotedVersions, projectCompact.promotedVersions) &&
|
||||
Objects.equals(this.stats, projectCompact.stats) &&
|
||||
Objects.equals(this.category, projectCompact.category) &&
|
||||
Objects.equals(this.visibility, projectCompact.visibility);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(pluginId, name, namespace, promotedVersions, stats, category, visibility);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("class ModelsProtocolsAPIV2CompactProject {\n");
|
||||
|
||||
sb.append(" pluginId: ").append(toIndentedString(pluginId)).append("\n");
|
||||
sb.append(" name: ").append(toIndentedString(name)).append("\n");
|
||||
sb.append(" namespace: ").append(toIndentedString(namespace)).append("\n");
|
||||
sb.append(" promotedVersions: ").append(toIndentedString(promotedVersions)).append("\n");
|
||||
sb.append(" stats: ").append(toIndentedString(stats)).append("\n");
|
||||
sb.append(" category: ").append(toIndentedString(category)).append("\n");
|
||||
sb.append(" visibility: ").append(toIndentedString(visibility)).append("\n");
|
||||
sb.append("}");
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the given object to string with each line indented by 4 spaces (except the first line).
|
||||
*/
|
||||
private String toIndentedString(Object o) {
|
||||
if (o == null) {
|
||||
return "null";
|
||||
}
|
||||
return o.toString().replace("\n", "\n ");
|
||||
}
|
||||
}
|
101
src/main/java/me/minidigger/hangar/model/ProjectLicense.java
Normal file
101
src/main/java/me/minidigger/hangar/model/ProjectLicense.java
Normal file
@ -0,0 +1,101 @@
|
||||
package me.minidigger.hangar.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
/**
|
||||
* ModelsProtocolsAPIV2ProjectLicense
|
||||
*/
|
||||
@Validated
|
||||
public class ProjectLicense {
|
||||
@JsonProperty("name")
|
||||
private String name = null;
|
||||
|
||||
@JsonProperty("url")
|
||||
private String url = null;
|
||||
|
||||
public ProjectLicense name(String name) {
|
||||
this.name = name;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get name
|
||||
*
|
||||
* @return name
|
||||
**/
|
||||
@ApiModelProperty(value = "")
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public ProjectLicense url(String url) {
|
||||
this.url = url;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get url
|
||||
*
|
||||
* @return url
|
||||
**/
|
||||
@ApiModelProperty(value = "")
|
||||
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
|
||||
public void setUrl(String url) {
|
||||
this.url = url;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
ProjectLicense projectLicense = (ProjectLicense) o;
|
||||
return Objects.equals(this.name, projectLicense.name) &&
|
||||
Objects.equals(this.url, projectLicense.url);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(name, url);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("class ModelsProtocolsAPIV2ProjectLicense {\n");
|
||||
|
||||
sb.append(" name: ").append(toIndentedString(name)).append("\n");
|
||||
sb.append(" url: ").append(toIndentedString(url)).append("\n");
|
||||
sb.append("}");
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the given object to string with each line indented by 4 spaces (except the first line).
|
||||
*/
|
||||
private String toIndentedString(Object o) {
|
||||
if (o == null) {
|
||||
return "null";
|
||||
}
|
||||
return o.toString().replace("\n", "\n ");
|
||||
}
|
||||
}
|
113
src/main/java/me/minidigger/hangar/model/ProjectMember.java
Normal file
113
src/main/java/me/minidigger/hangar/model/ProjectMember.java
Normal file
@ -0,0 +1,113 @@
|
||||
package me.minidigger.hangar.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
/**
|
||||
* ModelsProtocolsAPIV2ProjectMember
|
||||
*/
|
||||
@Validated
|
||||
public class ProjectMember {
|
||||
@JsonProperty("user")
|
||||
private String user = null;
|
||||
|
||||
@JsonProperty("roles")
|
||||
@Valid
|
||||
private List<Role> roles = new ArrayList<>();
|
||||
|
||||
public ProjectMember user(String user) {
|
||||
this.user = user;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get user
|
||||
*
|
||||
* @return user
|
||||
**/
|
||||
@ApiModelProperty(required = true, value = "")
|
||||
@NotNull
|
||||
|
||||
public String getUser() {
|
||||
return user;
|
||||
}
|
||||
|
||||
public void setUser(String user) {
|
||||
this.user = user;
|
||||
}
|
||||
|
||||
public ProjectMember roles(List<Role> roles) {
|
||||
this.roles = roles;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ProjectMember addRolesItem(Role rolesItem) {
|
||||
this.roles.add(rolesItem);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get roles
|
||||
*
|
||||
* @return roles
|
||||
**/
|
||||
@ApiModelProperty(required = true, value = "")
|
||||
@NotNull
|
||||
@Valid
|
||||
public List<Role> getRoles() {
|
||||
return roles;
|
||||
}
|
||||
|
||||
public void setRoles(List<Role> roles) {
|
||||
this.roles = roles;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
ProjectMember projectMember = (ProjectMember) o;
|
||||
return Objects.equals(this.user, projectMember.user) &&
|
||||
Objects.equals(this.roles, projectMember.roles);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(user, roles);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("class ModelsProtocolsAPIV2ProjectMember {\n");
|
||||
|
||||
sb.append(" user: ").append(toIndentedString(user)).append("\n");
|
||||
sb.append(" roles: ").append(toIndentedString(roles)).append("\n");
|
||||
sb.append("}");
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the given object to string with each line indented by 4 spaces (except the first line).
|
||||
*/
|
||||
private String toIndentedString(Object o) {
|
||||
if (o == null) {
|
||||
return "null";
|
||||
}
|
||||
return o.toString().replace("\n", "\n ");
|
||||
}
|
||||
}
|
104
src/main/java/me/minidigger/hangar/model/ProjectNamespace.java
Normal file
104
src/main/java/me/minidigger/hangar/model/ProjectNamespace.java
Normal file
@ -0,0 +1,104 @@
|
||||
package me.minidigger.hangar.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import java.util.Objects;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
/**
|
||||
* ModelsProtocolsAPIV2ProjectNamespace
|
||||
*/
|
||||
@Validated
|
||||
public class ProjectNamespace {
|
||||
@JsonProperty("owner")
|
||||
private String owner = null;
|
||||
|
||||
@JsonProperty("slug")
|
||||
private String slug = null;
|
||||
|
||||
public ProjectNamespace owner(String owner) {
|
||||
this.owner = owner;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get owner
|
||||
*
|
||||
* @return owner
|
||||
**/
|
||||
@ApiModelProperty(required = true, value = "")
|
||||
@NotNull
|
||||
|
||||
public String getOwner() {
|
||||
return owner;
|
||||
}
|
||||
|
||||
public void setOwner(String owner) {
|
||||
this.owner = owner;
|
||||
}
|
||||
|
||||
public ProjectNamespace slug(String slug) {
|
||||
this.slug = slug;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get slug
|
||||
*
|
||||
* @return slug
|
||||
**/
|
||||
@ApiModelProperty(required = true, value = "")
|
||||
@NotNull
|
||||
|
||||
public String getSlug() {
|
||||
return slug;
|
||||
}
|
||||
|
||||
public void setSlug(String slug) {
|
||||
this.slug = slug;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
ProjectNamespace projectNamespace = (ProjectNamespace) o;
|
||||
return Objects.equals(this.owner, projectNamespace.owner) &&
|
||||
Objects.equals(this.slug, projectNamespace.slug);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(owner, slug);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("class ModelsProtocolsAPIV2ProjectNamespace {\n");
|
||||
|
||||
sb.append(" owner: ").append(toIndentedString(owner)).append("\n");
|
||||
sb.append(" slug: ").append(toIndentedString(slug)).append("\n");
|
||||
sb.append("}");
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the given object to string with each line indented by 4 spaces (except the first line).
|
||||
*/
|
||||
private String toIndentedString(Object o) {
|
||||
if (o == null) {
|
||||
return "null";
|
||||
}
|
||||
return o.toString().replace("\n", "\n ");
|
||||
}
|
||||
}
|
206
src/main/java/me/minidigger/hangar/model/ProjectSettings.java
Normal file
206
src/main/java/me/minidigger/hangar/model/ProjectSettings.java
Normal file
@ -0,0 +1,206 @@
|
||||
package me.minidigger.hangar.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import java.util.Objects;
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
/**
|
||||
* ModelsProtocolsAPIV2ProjectSettings
|
||||
*/
|
||||
@Validated
|
||||
public class ProjectSettings {
|
||||
@JsonProperty("homepage")
|
||||
private String homepage = null;
|
||||
|
||||
@JsonProperty("issues")
|
||||
private String issues = null;
|
||||
|
||||
@JsonProperty("sources")
|
||||
private String sources = null;
|
||||
|
||||
@JsonProperty("support")
|
||||
private String support = null;
|
||||
|
||||
@JsonProperty("license")
|
||||
private ProjectLicense license = null;
|
||||
|
||||
@JsonProperty("forum_sync")
|
||||
private Boolean forumSync = null;
|
||||
|
||||
public ProjectSettings homepage(String homepage) {
|
||||
this.homepage = homepage;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get homepage
|
||||
*
|
||||
* @return homepage
|
||||
**/
|
||||
@ApiModelProperty(value = "")
|
||||
|
||||
public String getHomepage() {
|
||||
return homepage;
|
||||
}
|
||||
|
||||
public void setHomepage(String homepage) {
|
||||
this.homepage = homepage;
|
||||
}
|
||||
|
||||
public ProjectSettings issues(String issues) {
|
||||
this.issues = issues;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get issues
|
||||
*
|
||||
* @return issues
|
||||
**/
|
||||
@ApiModelProperty(value = "")
|
||||
|
||||
public String getIssues() {
|
||||
return issues;
|
||||
}
|
||||
|
||||
public void setIssues(String issues) {
|
||||
this.issues = issues;
|
||||
}
|
||||
|
||||
public ProjectSettings sources(String sources) {
|
||||
this.sources = sources;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get sources
|
||||
*
|
||||
* @return sources
|
||||
**/
|
||||
@ApiModelProperty(value = "")
|
||||
|
||||
public String getSources() {
|
||||
return sources;
|
||||
}
|
||||
|
||||
public void setSources(String sources) {
|
||||
this.sources = sources;
|
||||
}
|
||||
|
||||
public ProjectSettings support(String support) {
|
||||
this.support = support;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get support
|
||||
*
|
||||
* @return support
|
||||
**/
|
||||
@ApiModelProperty(value = "")
|
||||
|
||||
public String getSupport() {
|
||||
return support;
|
||||
}
|
||||
|
||||
public void setSupport(String support) {
|
||||
this.support = support;
|
||||
}
|
||||
|
||||
public ProjectSettings license(ProjectLicense license) {
|
||||
this.license = license;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get license
|
||||
*
|
||||
* @return license
|
||||
**/
|
||||
@ApiModelProperty(required = true, value = "")
|
||||
@NotNull
|
||||
|
||||
@Valid
|
||||
public ProjectLicense getLicense() {
|
||||
return license;
|
||||
}
|
||||
|
||||
public void setLicense(ProjectLicense license) {
|
||||
this.license = license;
|
||||
}
|
||||
|
||||
public ProjectSettings forumSync(Boolean forumSync) {
|
||||
this.forumSync = forumSync;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get forumSync
|
||||
*
|
||||
* @return forumSync
|
||||
**/
|
||||
@ApiModelProperty(required = true, value = "")
|
||||
@NotNull
|
||||
|
||||
public Boolean isForumSync() {
|
||||
return forumSync;
|
||||
}
|
||||
|
||||
public void setForumSync(Boolean forumSync) {
|
||||
this.forumSync = forumSync;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
ProjectSettings projectSettings = (ProjectSettings) o;
|
||||
return Objects.equals(this.homepage, projectSettings.homepage) &&
|
||||
Objects.equals(this.issues, projectSettings.issues) &&
|
||||
Objects.equals(this.sources, projectSettings.sources) &&
|
||||
Objects.equals(this.support, projectSettings.support) &&
|
||||
Objects.equals(this.license, projectSettings.license) &&
|
||||
Objects.equals(this.forumSync, projectSettings.forumSync);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(homepage, issues, sources, support, license, forumSync);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("class ModelsProtocolsAPIV2ProjectSettings {\n");
|
||||
|
||||
sb.append(" homepage: ").append(toIndentedString(homepage)).append("\n");
|
||||
sb.append(" issues: ").append(toIndentedString(issues)).append("\n");
|
||||
sb.append(" sources: ").append(toIndentedString(sources)).append("\n");
|
||||
sb.append(" support: ").append(toIndentedString(support)).append("\n");
|
||||
sb.append(" license: ").append(toIndentedString(license)).append("\n");
|
||||
sb.append(" forumSync: ").append(toIndentedString(forumSync)).append("\n");
|
||||
sb.append("}");
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the given object to string with each line indented by 4 spaces (except the first line).
|
||||
*/
|
||||
private String toIndentedString(Object o) {
|
||||
if (o == null) {
|
||||
return "null";
|
||||
}
|
||||
return o.toString().replace("\n", "\n ");
|
||||
}
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
package me.minidigger.hangar.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import com.fasterxml.jackson.annotation.JsonValue;
|
||||
|
||||
/**
|
||||
* Gets or Sets ProjectSortingStrategy
|
||||
*/
|
||||
public enum ProjectSortingStrategy {
|
||||
STARS("stars"),
|
||||
DOWNLOADS("downloads"),
|
||||
VIEWS("views"),
|
||||
NEWEST("newest"),
|
||||
UPDATED("updated"),
|
||||
ONLY_RELEVANCE("only_relevance"),
|
||||
RECENT_DOWNLOADS("recent_downloads"),
|
||||
RECENT_VIEWS("recent_views");
|
||||
|
||||
private final String value;
|
||||
|
||||
ProjectSortingStrategy(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
@JsonValue
|
||||
public String toString() {
|
||||
return String.valueOf(value);
|
||||
}
|
||||
|
||||
@JsonCreator
|
||||
public static ProjectSortingStrategy fromValue(String text) {
|
||||
for (ProjectSortingStrategy b : ProjectSortingStrategy.values()) {
|
||||
if (String.valueOf(b.value).equals(text)) {
|
||||
return b;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
208
src/main/java/me/minidigger/hangar/model/ProjectStatsAll.java
Normal file
208
src/main/java/me/minidigger/hangar/model/ProjectStatsAll.java
Normal file
@ -0,0 +1,208 @@
|
||||
package me.minidigger.hangar.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import java.util.Objects;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
/**
|
||||
* ModelsProtocolsAPIV2ProjectStatsAll
|
||||
*/
|
||||
@Validated
|
||||
public class ProjectStatsAll {
|
||||
@JsonProperty("views")
|
||||
private Long views = null;
|
||||
|
||||
@JsonProperty("downloads")
|
||||
private Long downloads = null;
|
||||
|
||||
@JsonProperty("recent_views")
|
||||
private Long recentViews = null;
|
||||
|
||||
@JsonProperty("recent_downloads")
|
||||
private Long recentDownloads = null;
|
||||
|
||||
@JsonProperty("stars")
|
||||
private Long stars = null;
|
||||
|
||||
@JsonProperty("watchers")
|
||||
private Long watchers = null;
|
||||
|
||||
public ProjectStatsAll views(Long views) {
|
||||
this.views = views;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get views
|
||||
*
|
||||
* @return views
|
||||
**/
|
||||
@ApiModelProperty(required = true, value = "")
|
||||
@NotNull
|
||||
|
||||
public Long getViews() {
|
||||
return views;
|
||||
}
|
||||
|
||||
public void setViews(Long views) {
|
||||
this.views = views;
|
||||
}
|
||||
|
||||
public ProjectStatsAll downloads(Long downloads) {
|
||||
this.downloads = downloads;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get downloads
|
||||
*
|
||||
* @return downloads
|
||||
**/
|
||||
@ApiModelProperty(required = true, value = "")
|
||||
@NotNull
|
||||
|
||||
public Long getDownloads() {
|
||||
return downloads;
|
||||
}
|
||||
|
||||
public void setDownloads(Long downloads) {
|
||||
this.downloads = downloads;
|
||||
}
|
||||
|
||||
public ProjectStatsAll recentViews(Long recentViews) {
|
||||
this.recentViews = recentViews;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get recentViews
|
||||
*
|
||||
* @return recentViews
|
||||
**/
|
||||
@ApiModelProperty(required = true, value = "")
|
||||
@NotNull
|
||||
|
||||
public Long getRecentViews() {
|
||||
return recentViews;
|
||||
}
|
||||
|
||||
public void setRecentViews(Long recentViews) {
|
||||
this.recentViews = recentViews;
|
||||
}
|
||||
|
||||
public ProjectStatsAll recentDownloads(Long recentDownloads) {
|
||||
this.recentDownloads = recentDownloads;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get recentDownloads
|
||||
*
|
||||
* @return recentDownloads
|
||||
**/
|
||||
@ApiModelProperty(required = true, value = "")
|
||||
@NotNull
|
||||
|
||||
public Long getRecentDownloads() {
|
||||
return recentDownloads;
|
||||
}
|
||||
|
||||
public void setRecentDownloads(Long recentDownloads) {
|
||||
this.recentDownloads = recentDownloads;
|
||||
}
|
||||
|
||||
public ProjectStatsAll stars(Long stars) {
|
||||
this.stars = stars;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get stars
|
||||
*
|
||||
* @return stars
|
||||
**/
|
||||
@ApiModelProperty(required = true, value = "")
|
||||
@NotNull
|
||||
|
||||
public Long getStars() {
|
||||
return stars;
|
||||
}
|
||||
|
||||
public void setStars(Long stars) {
|
||||
this.stars = stars;
|
||||
}
|
||||
|
||||
public ProjectStatsAll watchers(Long watchers) {
|
||||
this.watchers = watchers;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get watchers
|
||||
*
|
||||
* @return watchers
|
||||
**/
|
||||
@ApiModelProperty(required = true, value = "")
|
||||
@NotNull
|
||||
|
||||
public Long getWatchers() {
|
||||
return watchers;
|
||||
}
|
||||
|
||||
public void setWatchers(Long watchers) {
|
||||
this.watchers = watchers;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
ProjectStatsAll projectStatsAll = (ProjectStatsAll) o;
|
||||
return Objects.equals(this.views, projectStatsAll.views) &&
|
||||
Objects.equals(this.downloads, projectStatsAll.downloads) &&
|
||||
Objects.equals(this.recentViews, projectStatsAll.recentViews) &&
|
||||
Objects.equals(this.recentDownloads, projectStatsAll.recentDownloads) &&
|
||||
Objects.equals(this.stars, projectStatsAll.stars) &&
|
||||
Objects.equals(this.watchers, projectStatsAll.watchers);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(views, downloads, recentViews, recentDownloads, stars, watchers);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("class ModelsProtocolsAPIV2ProjectStatsAll {\n");
|
||||
|
||||
sb.append(" views: ").append(toIndentedString(views)).append("\n");
|
||||
sb.append(" downloads: ").append(toIndentedString(downloads)).append("\n");
|
||||
sb.append(" recentViews: ").append(toIndentedString(recentViews)).append("\n");
|
||||
sb.append(" recentDownloads: ").append(toIndentedString(recentDownloads)).append("\n");
|
||||
sb.append(" stars: ").append(toIndentedString(stars)).append("\n");
|
||||
sb.append(" watchers: ").append(toIndentedString(watchers)).append("\n");
|
||||
sb.append("}");
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the given object to string with each line indented by 4 spaces (except the first line).
|
||||
*/
|
||||
private String toIndentedString(Object o) {
|
||||
if (o == null) {
|
||||
return "null";
|
||||
}
|
||||
return o.toString().replace("\n", "\n ");
|
||||
}
|
||||
}
|
104
src/main/java/me/minidigger/hangar/model/ProjectStatsDay.java
Normal file
104
src/main/java/me/minidigger/hangar/model/ProjectStatsDay.java
Normal file
@ -0,0 +1,104 @@
|
||||
package me.minidigger.hangar.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import java.util.Objects;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
/**
|
||||
* ModelsProtocolsAPIV2ProjectStatsDay
|
||||
*/
|
||||
@Validated
|
||||
public class ProjectStatsDay {
|
||||
@JsonProperty("downloads")
|
||||
private Long downloads = null;
|
||||
|
||||
@JsonProperty("views")
|
||||
private Long views = null;
|
||||
|
||||
public ProjectStatsDay downloads(Long downloads) {
|
||||
this.downloads = downloads;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get downloads
|
||||
*
|
||||
* @return downloads
|
||||
**/
|
||||
@ApiModelProperty(required = true, value = "")
|
||||
@NotNull
|
||||
|
||||
public Long getDownloads() {
|
||||
return downloads;
|
||||
}
|
||||
|
||||
public void setDownloads(Long downloads) {
|
||||
this.downloads = downloads;
|
||||
}
|
||||
|
||||
public ProjectStatsDay views(Long views) {
|
||||
this.views = views;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get views
|
||||
*
|
||||
* @return views
|
||||
**/
|
||||
@ApiModelProperty(required = true, value = "")
|
||||
@NotNull
|
||||
|
||||
public Long getViews() {
|
||||
return views;
|
||||
}
|
||||
|
||||
public void setViews(Long views) {
|
||||
this.views = views;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
ProjectStatsDay projectStatsDay = (ProjectStatsDay) o;
|
||||
return Objects.equals(this.downloads, projectStatsDay.downloads) &&
|
||||
Objects.equals(this.views, projectStatsDay.views);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(downloads, views);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("class ModelsProtocolsAPIV2ProjectStatsDay {\n");
|
||||
|
||||
sb.append(" downloads: ").append(toIndentedString(downloads)).append("\n");
|
||||
sb.append(" views: ").append(toIndentedString(views)).append("\n");
|
||||
sb.append("}");
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the given object to string with each line indented by 4 spaces (except the first line).
|
||||
*/
|
||||
private String toIndentedString(Object o) {
|
||||
if (o == null) {
|
||||
return "null";
|
||||
}
|
||||
return o.toString().replace("\n", "\n ");
|
||||
}
|
||||
}
|
113
src/main/java/me/minidigger/hangar/model/PromotedVersion.java
Normal file
113
src/main/java/me/minidigger/hangar/model/PromotedVersion.java
Normal file
@ -0,0 +1,113 @@
|
||||
package me.minidigger.hangar.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
/**
|
||||
* ModelsProtocolsAPIV2PromotedVersion
|
||||
*/
|
||||
@Validated
|
||||
public class PromotedVersion {
|
||||
@JsonProperty("version")
|
||||
private String version = null;
|
||||
|
||||
@JsonProperty("tags")
|
||||
@Valid
|
||||
private List<PromotedVersionTag> tags = new ArrayList<>();
|
||||
|
||||
public PromotedVersion version(String version) {
|
||||
this.version = version;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get version
|
||||
*
|
||||
* @return version
|
||||
**/
|
||||
@ApiModelProperty(required = true, value = "")
|
||||
@NotNull
|
||||
|
||||
public String getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
public void setVersion(String version) {
|
||||
this.version = version;
|
||||
}
|
||||
|
||||
public PromotedVersion tags(List<PromotedVersionTag> tags) {
|
||||
this.tags = tags;
|
||||
return this;
|
||||
}
|
||||
|
||||
public PromotedVersion addTagsItem(PromotedVersionTag tagsItem) {
|
||||
this.tags.add(tagsItem);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get tags
|
||||
*
|
||||
* @return tags
|
||||
**/
|
||||
@ApiModelProperty(required = true, value = "")
|
||||
@NotNull
|
||||
@Valid
|
||||
public List<PromotedVersionTag> getTags() {
|
||||
return tags;
|
||||
}
|
||||
|
||||
public void setTags(List<PromotedVersionTag> tags) {
|
||||
this.tags = tags;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
PromotedVersion promotedVersion = (PromotedVersion) o;
|
||||
return Objects.equals(this.version, promotedVersion.version) &&
|
||||
Objects.equals(this.tags, promotedVersion.tags);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(version, tags);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("class ModelsProtocolsAPIV2PromotedVersion {\n");
|
||||
|
||||
sb.append(" version: ").append(toIndentedString(version)).append("\n");
|
||||
sb.append(" tags: ").append(toIndentedString(tags)).append("\n");
|
||||
sb.append("}");
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the given object to string with each line indented by 4 spaces (except the first line).
|
||||
*/
|
||||
private String toIndentedString(Object o) {
|
||||
if (o == null) {
|
||||
return "null";
|
||||
}
|
||||
return o.toString().replace("\n", "\n ");
|
||||
}
|
||||
}
|
181
src/main/java/me/minidigger/hangar/model/PromotedVersionTag.java
Normal file
181
src/main/java/me/minidigger/hangar/model/PromotedVersionTag.java
Normal file
@ -0,0 +1,181 @@
|
||||
package me.minidigger.hangar.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import java.util.Objects;
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
/**
|
||||
* ModelsProtocolsAPIV2PromotedVersionTag
|
||||
*/
|
||||
@Validated
|
||||
public class PromotedVersionTag {
|
||||
@JsonProperty("name")
|
||||
private String name = null;
|
||||
|
||||
@JsonProperty("data")
|
||||
private String data = null;
|
||||
|
||||
@JsonProperty("display_data")
|
||||
private String displayData = null;
|
||||
|
||||
@JsonProperty("minecraft_version")
|
||||
private String minecraftVersion = null;
|
||||
|
||||
@JsonProperty("color")
|
||||
private TagColor color = null;
|
||||
|
||||
public PromotedVersionTag name(String name) {
|
||||
this.name = name;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get name
|
||||
*
|
||||
* @return name
|
||||
**/
|
||||
@ApiModelProperty(required = true, value = "")
|
||||
@NotNull
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public PromotedVersionTag data(String data) {
|
||||
this.data = data;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get data
|
||||
*
|
||||
* @return data
|
||||
**/
|
||||
@ApiModelProperty(value = "")
|
||||
|
||||
public String getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
public void setData(String data) {
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
public PromotedVersionTag displayData(String displayData) {
|
||||
this.displayData = displayData;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get displayData
|
||||
*
|
||||
* @return displayData
|
||||
**/
|
||||
@ApiModelProperty(value = "")
|
||||
|
||||
public String getDisplayData() {
|
||||
return displayData;
|
||||
}
|
||||
|
||||
public void setDisplayData(String displayData) {
|
||||
this.displayData = displayData;
|
||||
}
|
||||
|
||||
public PromotedVersionTag minecraftVersion(String minecraftVersion) {
|
||||
this.minecraftVersion = minecraftVersion;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get minecraftVersion
|
||||
*
|
||||
* @return minecraftVersion
|
||||
**/
|
||||
@ApiModelProperty(value = "")
|
||||
|
||||
public String getMinecraftVersion() {
|
||||
return minecraftVersion;
|
||||
}
|
||||
|
||||
public void setMinecraftVersion(String minecraftVersion) {
|
||||
this.minecraftVersion = minecraftVersion;
|
||||
}
|
||||
|
||||
public PromotedVersionTag color(TagColor color) {
|
||||
this.color = color;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get color
|
||||
*
|
||||
* @return color
|
||||
**/
|
||||
@ApiModelProperty(required = true, value = "")
|
||||
@NotNull
|
||||
|
||||
@Valid
|
||||
public TagColor getColor() {
|
||||
return color;
|
||||
}
|
||||
|
||||
public void setColor(TagColor color) {
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
PromotedVersionTag promotedVersionTag = (PromotedVersionTag) o;
|
||||
return Objects.equals(this.name, promotedVersionTag.name) &&
|
||||
Objects.equals(this.data, promotedVersionTag.data) &&
|
||||
Objects.equals(this.displayData, promotedVersionTag.displayData) &&
|
||||
Objects.equals(this.minecraftVersion, promotedVersionTag.minecraftVersion) &&
|
||||
Objects.equals(this.color, promotedVersionTag.color);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(name, data, displayData, minecraftVersion, color);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("class ModelsProtocolsAPIV2PromotedVersionTag {\n");
|
||||
|
||||
sb.append(" name: ").append(toIndentedString(name)).append("\n");
|
||||
sb.append(" data: ").append(toIndentedString(data)).append("\n");
|
||||
sb.append(" displayData: ").append(toIndentedString(displayData)).append("\n");
|
||||
sb.append(" minecraftVersion: ").append(toIndentedString(minecraftVersion)).append("\n");
|
||||
sb.append(" color: ").append(toIndentedString(color)).append("\n");
|
||||
sb.append("}");
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the given object to string with each line indented by 4 spaces (except the first line).
|
||||
*/
|
||||
private String toIndentedString(Object o) {
|
||||
if (o == null) {
|
||||
return "null";
|
||||
}
|
||||
return o.toString().replace("\n", "\n ");
|
||||
}
|
||||
}
|
39
src/main/java/me/minidigger/hangar/model/ReviewState.java
Normal file
39
src/main/java/me/minidigger/hangar/model/ReviewState.java
Normal file
@ -0,0 +1,39 @@
|
||||
package me.minidigger.hangar.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import com.fasterxml.jackson.annotation.JsonValue;
|
||||
|
||||
/**
|
||||
* Gets or Sets reviewState
|
||||
*/
|
||||
public enum ReviewState {
|
||||
UNREVIEWED("unreviewed"),
|
||||
|
||||
REVIEWED("reviewed"),
|
||||
|
||||
BACKLOG("backlog"),
|
||||
|
||||
PARTIALLY_REVIEWED("partially_reviewed");
|
||||
|
||||
private final String value;
|
||||
|
||||
ReviewState(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
@JsonValue
|
||||
public String toString() {
|
||||
return String.valueOf(value);
|
||||
}
|
||||
|
||||
@JsonCreator
|
||||
public static ReviewState fromValue(String text) {
|
||||
for (ReviewState b : ReviewState.values()) {
|
||||
if (String.valueOf(b.value).equals(text)) {
|
||||
return b;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
130
src/main/java/me/minidigger/hangar/model/Role.java
Normal file
130
src/main/java/me/minidigger/hangar/model/Role.java
Normal file
@ -0,0 +1,130 @@
|
||||
package me.minidigger.hangar.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import java.util.Objects;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
/**
|
||||
* ModelsProtocolsAPIV2Role
|
||||
*/
|
||||
@Validated
|
||||
public class Role {
|
||||
@JsonProperty("name")
|
||||
private String name = null;
|
||||
|
||||
@JsonProperty("title")
|
||||
private String title = null;
|
||||
|
||||
@JsonProperty("color")
|
||||
private String color = null;
|
||||
|
||||
public Role name(String name) {
|
||||
this.name = name;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get name
|
||||
*
|
||||
* @return name
|
||||
**/
|
||||
@ApiModelProperty(required = true, value = "")
|
||||
@NotNull
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public Role title(String title) {
|
||||
this.title = title;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get title
|
||||
*
|
||||
* @return title
|
||||
**/
|
||||
@ApiModelProperty(required = true, value = "")
|
||||
@NotNull
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public Role color(String color) {
|
||||
this.color = color;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get color
|
||||
*
|
||||
* @return color
|
||||
**/
|
||||
@ApiModelProperty(required = true, value = "")
|
||||
@NotNull
|
||||
|
||||
public String getColor() {
|
||||
return color;
|
||||
}
|
||||
|
||||
public void setColor(String color) {
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
Role role = (Role) o;
|
||||
return Objects.equals(this.name, role.name) &&
|
||||
Objects.equals(this.title, role.title) &&
|
||||
Objects.equals(this.color, role.color);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(name, title, color);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("class ModelsProtocolsAPIV2Role {\n");
|
||||
|
||||
sb.append(" name: ").append(toIndentedString(name)).append("\n");
|
||||
sb.append(" title: ").append(toIndentedString(title)).append("\n");
|
||||
sb.append(" color: ").append(toIndentedString(color)).append("\n");
|
||||
sb.append("}");
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the given object to string with each line indented by 4 spaces (except the first line).
|
||||
*/
|
||||
private String toIndentedString(Object o) {
|
||||
if (o == null) {
|
||||
return "null";
|
||||
}
|
||||
return o.toString().replace("\n", "\n ");
|
||||
}
|
||||
}
|
101
src/main/java/me/minidigger/hangar/model/SessionProperties.java
Normal file
101
src/main/java/me/minidigger/hangar/model/SessionProperties.java
Normal file
@ -0,0 +1,101 @@
|
||||
package me.minidigger.hangar.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
/**
|
||||
* SessionProperties
|
||||
*/
|
||||
@Validated
|
||||
public class SessionProperties {
|
||||
@JsonProperty("_fake")
|
||||
private Boolean _fake = null;
|
||||
|
||||
@JsonProperty("expires_in")
|
||||
private Long expiresIn = null;
|
||||
|
||||
public SessionProperties _fake(Boolean _fake) {
|
||||
this._fake = _fake;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get _fake
|
||||
*
|
||||
* @return _fake
|
||||
**/
|
||||
@ApiModelProperty(value = "")
|
||||
|
||||
public Boolean isFake() {
|
||||
return _fake;
|
||||
}
|
||||
|
||||
public void setFake(Boolean _fake) {
|
||||
this._fake = _fake;
|
||||
}
|
||||
|
||||
public SessionProperties expiresIn(Long expiresIn) {
|
||||
this.expiresIn = expiresIn;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get expiresIn
|
||||
*
|
||||
* @return expiresIn
|
||||
**/
|
||||
@ApiModelProperty(value = "")
|
||||
|
||||
public Long getExpiresIn() {
|
||||
return expiresIn;
|
||||
}
|
||||
|
||||
public void setExpiresIn(Long expiresIn) {
|
||||
this.expiresIn = expiresIn;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
SessionProperties sessionProperties = (SessionProperties) o;
|
||||
return Objects.equals(this._fake, sessionProperties._fake) &&
|
||||
Objects.equals(this.expiresIn, sessionProperties.expiresIn);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(_fake, expiresIn);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("class SessionProperties {\n");
|
||||
|
||||
sb.append(" _fake: ").append(toIndentedString(_fake)).append("\n");
|
||||
sb.append(" expiresIn: ").append(toIndentedString(expiresIn)).append("\n");
|
||||
sb.append("}");
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the given object to string with each line indented by 4 spaces (except the first line).
|
||||
*/
|
||||
private String toIndentedString(Object o) {
|
||||
if (o == null) {
|
||||
return "null";
|
||||
}
|
||||
return o.toString().replace("\n", "\n ");
|
||||
}
|
||||
}
|
39
src/main/java/me/minidigger/hangar/model/SessionType.java
Normal file
39
src/main/java/me/minidigger/hangar/model/SessionType.java
Normal file
@ -0,0 +1,39 @@
|
||||
package me.minidigger.hangar.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import com.fasterxml.jackson.annotation.JsonValue;
|
||||
|
||||
/**
|
||||
* Gets or Sets type
|
||||
*/
|
||||
public enum SessionType {
|
||||
KEY("key"),
|
||||
|
||||
USER("user"),
|
||||
|
||||
PUBLIC("public"),
|
||||
|
||||
DEV("dev");
|
||||
|
||||
private final String value;
|
||||
|
||||
SessionType(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
@JsonValue
|
||||
public String toString() {
|
||||
return String.valueOf(value);
|
||||
}
|
||||
|
||||
@JsonCreator
|
||||
public static SessionType fromValue(String text) {
|
||||
for (SessionType b : SessionType.values()) {
|
||||
if (String.valueOf(b.value).equals(text)) {
|
||||
return b;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
131
src/main/java/me/minidigger/hangar/model/Tag.java
Normal file
131
src/main/java/me/minidigger/hangar/model/Tag.java
Normal file
@ -0,0 +1,131 @@
|
||||
package me.minidigger.hangar.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import java.util.Objects;
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
/**
|
||||
* ModelsProtocolsAPIV2VersionTag
|
||||
*/
|
||||
@Validated
|
||||
public class Tag {
|
||||
@JsonProperty("name")
|
||||
private String name = null;
|
||||
|
||||
@JsonProperty("data")
|
||||
private String data = null;
|
||||
|
||||
@JsonProperty("color")
|
||||
private TagColor color = null;
|
||||
|
||||
public Tag name(String name) {
|
||||
this.name = name;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get name
|
||||
*
|
||||
* @return name
|
||||
**/
|
||||
@ApiModelProperty(required = true, value = "")
|
||||
@NotNull
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public Tag data(String data) {
|
||||
this.data = data;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get data
|
||||
*
|
||||
* @return data
|
||||
**/
|
||||
@ApiModelProperty(value = "")
|
||||
|
||||
public String getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
public void setData(String data) {
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
public Tag color(TagColor color) {
|
||||
this.color = color;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get color
|
||||
*
|
||||
* @return color
|
||||
**/
|
||||
@ApiModelProperty(required = true, value = "")
|
||||
@NotNull
|
||||
|
||||
@Valid
|
||||
public TagColor getColor() {
|
||||
return color;
|
||||
}
|
||||
|
||||
public void setColor(TagColor color) {
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
Tag tag = (Tag) o;
|
||||
return Objects.equals(this.name, tag.name) &&
|
||||
Objects.equals(this.data, tag.data) &&
|
||||
Objects.equals(this.color, tag.color);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(name, data, color);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("class ModelsProtocolsAPIV2VersionTag {\n");
|
||||
|
||||
sb.append(" name: ").append(toIndentedString(name)).append("\n");
|
||||
sb.append(" data: ").append(toIndentedString(data)).append("\n");
|
||||
sb.append(" color: ").append(toIndentedString(color)).append("\n");
|
||||
sb.append("}");
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the given object to string with each line indented by 4 spaces (except the first line).
|
||||
*/
|
||||
private String toIndentedString(Object o) {
|
||||
if (o == null) {
|
||||
return "null";
|
||||
}
|
||||
return o.toString().replace("\n", "\n ");
|
||||
}
|
||||
}
|
104
src/main/java/me/minidigger/hangar/model/TagColor.java
Normal file
104
src/main/java/me/minidigger/hangar/model/TagColor.java
Normal file
@ -0,0 +1,104 @@
|
||||
package me.minidigger.hangar.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import java.util.Objects;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
/**
|
||||
* ModelsProtocolsAPIV2VersionTagColor
|
||||
*/
|
||||
@Validated
|
||||
public class TagColor {
|
||||
@JsonProperty("foreground")
|
||||
private String foreground = null;
|
||||
|
||||
@JsonProperty("background")
|
||||
private String background = null;
|
||||
|
||||
public TagColor foreground(String foreground) {
|
||||
this.foreground = foreground;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get foreground
|
||||
*
|
||||
* @return foreground
|
||||
**/
|
||||
@ApiModelProperty(required = true, value = "")
|
||||
@NotNull
|
||||
|
||||
public String getForeground() {
|
||||
return foreground;
|
||||
}
|
||||
|
||||
public void setForeground(String foreground) {
|
||||
this.foreground = foreground;
|
||||
}
|
||||
|
||||
public TagColor background(String background) {
|
||||
this.background = background;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get background
|
||||
*
|
||||
* @return background
|
||||
**/
|
||||
@ApiModelProperty(required = true, value = "")
|
||||
@NotNull
|
||||
|
||||
public String getBackground() {
|
||||
return background;
|
||||
}
|
||||
|
||||
public void setBackground(String background) {
|
||||
this.background = background;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
TagColor tagColor = (TagColor) o;
|
||||
return Objects.equals(this.foreground, tagColor.foreground) &&
|
||||
Objects.equals(this.background, tagColor.background);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(foreground, background);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("class ModelsProtocolsAPIV2VersionTagColor {\n");
|
||||
|
||||
sb.append(" foreground: ").append(toIndentedString(foreground)).append("\n");
|
||||
sb.append(" background: ").append(toIndentedString(background)).append("\n");
|
||||
sb.append("}");
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the given object to string with each line indented by 4 spaces (except the first line).
|
||||
*/
|
||||
private String toIndentedString(Object o) {
|
||||
if (o == null) {
|
||||
return "null";
|
||||
}
|
||||
return o.toString().replace("\n", "\n ");
|
||||
}
|
||||
}
|
192
src/main/java/me/minidigger/hangar/model/User.java
Normal file
192
src/main/java/me/minidigger/hangar/model/User.java
Normal file
@ -0,0 +1,192 @@
|
||||
package me.minidigger.hangar.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.threeten.bp.OffsetDateTime;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
/**
|
||||
* ModelsProtocolsAPIV2User
|
||||
*/
|
||||
@Validated
|
||||
public class User {
|
||||
@JsonProperty("created_at")
|
||||
private OffsetDateTime createdAt = null;
|
||||
|
||||
@JsonProperty("name")
|
||||
private String name = null;
|
||||
|
||||
@JsonProperty("tagline")
|
||||
private String tagline = null;
|
||||
|
||||
@JsonProperty("join_date")
|
||||
private OffsetDateTime joinDate = null;
|
||||
|
||||
@JsonProperty("roles")
|
||||
@Valid
|
||||
private List<Role> roles = new ArrayList<>();
|
||||
|
||||
public User createdAt(OffsetDateTime createdAt) {
|
||||
this.createdAt = createdAt;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get createdAt
|
||||
*
|
||||
* @return createdAt
|
||||
**/
|
||||
@ApiModelProperty(required = true, value = "")
|
||||
@NotNull
|
||||
|
||||
@Valid
|
||||
public OffsetDateTime getCreatedAt() {
|
||||
return createdAt;
|
||||
}
|
||||
|
||||
public void setCreatedAt(OffsetDateTime createdAt) {
|
||||
this.createdAt = createdAt;
|
||||
}
|
||||
|
||||
public User name(String name) {
|
||||
this.name = name;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get name
|
||||
*
|
||||
* @return name
|
||||
**/
|
||||
@ApiModelProperty(required = true, value = "")
|
||||
@NotNull
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public User tagline(String tagline) {
|
||||
this.tagline = tagline;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get tagline
|
||||
*
|
||||
* @return tagline
|
||||
**/
|
||||
@ApiModelProperty(value = "")
|
||||
|
||||
public String getTagline() {
|
||||
return tagline;
|
||||
}
|
||||
|
||||
public void setTagline(String tagline) {
|
||||
this.tagline = tagline;
|
||||
}
|
||||
|
||||
public User joinDate(OffsetDateTime joinDate) {
|
||||
this.joinDate = joinDate;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get joinDate
|
||||
*
|
||||
* @return joinDate
|
||||
**/
|
||||
@ApiModelProperty(value = "")
|
||||
|
||||
@Valid
|
||||
public OffsetDateTime getJoinDate() {
|
||||
return joinDate;
|
||||
}
|
||||
|
||||
public void setJoinDate(OffsetDateTime joinDate) {
|
||||
this.joinDate = joinDate;
|
||||
}
|
||||
|
||||
public User roles(List<Role> roles) {
|
||||
this.roles = roles;
|
||||
return this;
|
||||
}
|
||||
|
||||
public User addRolesItem(Role rolesItem) {
|
||||
this.roles.add(rolesItem);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get roles
|
||||
*
|
||||
* @return roles
|
||||
**/
|
||||
@ApiModelProperty(required = true, value = "")
|
||||
@NotNull
|
||||
@Valid
|
||||
public List<Role> getRoles() {
|
||||
return roles;
|
||||
}
|
||||
|
||||
public void setRoles(List<Role> roles) {
|
||||
this.roles = roles;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
User user = (User) o;
|
||||
return Objects.equals(this.createdAt, user.createdAt) &&
|
||||
Objects.equals(this.name, user.name) &&
|
||||
Objects.equals(this.tagline, user.tagline) &&
|
||||
Objects.equals(this.joinDate, user.joinDate) &&
|
||||
Objects.equals(this.roles, user.roles);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(createdAt, name, tagline, joinDate, roles);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("class ModelsProtocolsAPIV2User {\n");
|
||||
|
||||
sb.append(" createdAt: ").append(toIndentedString(createdAt)).append("\n");
|
||||
sb.append(" name: ").append(toIndentedString(name)).append("\n");
|
||||
sb.append(" tagline: ").append(toIndentedString(tagline)).append("\n");
|
||||
sb.append(" joinDate: ").append(toIndentedString(joinDate)).append("\n");
|
||||
sb.append(" roles: ").append(toIndentedString(roles)).append("\n");
|
||||
sb.append("}");
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the given object to string with each line indented by 4 spaces (except the first line).
|
||||
*/
|
||||
private String toIndentedString(Object o) {
|
||||
if (o == null) {
|
||||
return "null";
|
||||
}
|
||||
return o.toString().replace("\n", "\n ");
|
||||
}
|
||||
}
|
104
src/main/java/me/minidigger/hangar/model/UserActions.java
Normal file
104
src/main/java/me/minidigger/hangar/model/UserActions.java
Normal file
@ -0,0 +1,104 @@
|
||||
package me.minidigger.hangar.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import java.util.Objects;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
/**
|
||||
* ModelsProtocolsAPIV2UserActions
|
||||
*/
|
||||
@Validated
|
||||
public class UserActions {
|
||||
@JsonProperty("starred")
|
||||
private Boolean starred = null;
|
||||
|
||||
@JsonProperty("watching")
|
||||
private Boolean watching = null;
|
||||
|
||||
public UserActions starred(Boolean starred) {
|
||||
this.starred = starred;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get starred
|
||||
*
|
||||
* @return starred
|
||||
**/
|
||||
@ApiModelProperty(required = true, value = "")
|
||||
@NotNull
|
||||
|
||||
public Boolean isStarred() {
|
||||
return starred;
|
||||
}
|
||||
|
||||
public void setStarred(Boolean starred) {
|
||||
this.starred = starred;
|
||||
}
|
||||
|
||||
public UserActions watching(Boolean watching) {
|
||||
this.watching = watching;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get watching
|
||||
*
|
||||
* @return watching
|
||||
**/
|
||||
@ApiModelProperty(required = true, value = "")
|
||||
@NotNull
|
||||
|
||||
public Boolean isWatching() {
|
||||
return watching;
|
||||
}
|
||||
|
||||
public void setWatching(Boolean watching) {
|
||||
this.watching = watching;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
UserActions userActions = (UserActions) o;
|
||||
return Objects.equals(this.starred, userActions.starred) &&
|
||||
Objects.equals(this.watching, userActions.watching);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(starred, watching);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("class ModelsProtocolsAPIV2UserActions {\n");
|
||||
|
||||
sb.append(" starred: ").append(toIndentedString(starred)).append("\n");
|
||||
sb.append(" watching: ").append(toIndentedString(watching)).append("\n");
|
||||
sb.append("}");
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the given object to string with each line indented by 4 spaces (except the first line).
|
||||
*/
|
||||
private String toIndentedString(Object o) {
|
||||
if (o == null) {
|
||||
return "null";
|
||||
}
|
||||
return o.toString().replace("\n", "\n ");
|
||||
}
|
||||
}
|
329
src/main/java/me/minidigger/hangar/model/Version.java
Normal file
329
src/main/java/me/minidigger/hangar/model/Version.java
Normal file
@ -0,0 +1,329 @@
|
||||
package me.minidigger.hangar.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.threeten.bp.OffsetDateTime;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
/**
|
||||
* ModelsProtocolsAPIV2Version
|
||||
*/
|
||||
@Validated
|
||||
public class Version {
|
||||
@JsonProperty("created_at")
|
||||
private OffsetDateTime createdAt = null;
|
||||
|
||||
@JsonProperty("name")
|
||||
private String name = null;
|
||||
|
||||
@JsonProperty("dependencies")
|
||||
@Valid
|
||||
private List<Dependency> dependencies = new ArrayList<>();
|
||||
|
||||
@JsonProperty("visibility")
|
||||
private Visibility visibility = null;
|
||||
|
||||
@JsonProperty("description")
|
||||
private String description = null;
|
||||
|
||||
@JsonProperty("stats")
|
||||
private VersionStatsAll stats = null;
|
||||
|
||||
@JsonProperty("file_info")
|
||||
private FileInfo fileInfo = null;
|
||||
|
||||
@JsonProperty("author")
|
||||
private String author = null;
|
||||
|
||||
@JsonProperty("review_state")
|
||||
private ReviewState reviewState = null;
|
||||
|
||||
@JsonProperty("tags")
|
||||
@Valid
|
||||
private List<Tag> tags = new ArrayList<>();
|
||||
|
||||
public Version createdAt(OffsetDateTime createdAt) {
|
||||
this.createdAt = createdAt;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get createdAt
|
||||
*
|
||||
* @return createdAt
|
||||
**/
|
||||
@ApiModelProperty(required = true, value = "")
|
||||
@NotNull
|
||||
|
||||
@Valid
|
||||
public OffsetDateTime getCreatedAt() {
|
||||
return createdAt;
|
||||
}
|
||||
|
||||
public void setCreatedAt(OffsetDateTime createdAt) {
|
||||
this.createdAt = createdAt;
|
||||
}
|
||||
|
||||
public Version name(String name) {
|
||||
this.name = name;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get name
|
||||
*
|
||||
* @return name
|
||||
**/
|
||||
@ApiModelProperty(required = true, value = "")
|
||||
@NotNull
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public Version dependencies(List<Dependency> dependencies) {
|
||||
this.dependencies = dependencies;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Version addDependenciesItem(Dependency dependenciesItem) {
|
||||
this.dependencies.add(dependenciesItem);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get dependencies
|
||||
*
|
||||
* @return dependencies
|
||||
**/
|
||||
@ApiModelProperty(required = true, value = "")
|
||||
@NotNull
|
||||
@Valid
|
||||
public List<Dependency> getDependencies() {
|
||||
return dependencies;
|
||||
}
|
||||
|
||||
public void setDependencies(List<Dependency> dependencies) {
|
||||
this.dependencies = dependencies;
|
||||
}
|
||||
|
||||
public Version visibility(Visibility visibility) {
|
||||
this.visibility = visibility;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get visibility
|
||||
*
|
||||
* @return visibility
|
||||
**/
|
||||
@ApiModelProperty(required = true, value = "")
|
||||
@NotNull
|
||||
|
||||
public Visibility getVisibility() {
|
||||
return visibility;
|
||||
}
|
||||
|
||||
public void setVisibility(Visibility visibility) {
|
||||
this.visibility = visibility;
|
||||
}
|
||||
|
||||
public Version description(String description) {
|
||||
this.description = description;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get description
|
||||
*
|
||||
* @return description
|
||||
**/
|
||||
@ApiModelProperty(value = "")
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public Version stats(VersionStatsAll stats) {
|
||||
this.stats = stats;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get stats
|
||||
*
|
||||
* @return stats
|
||||
**/
|
||||
@ApiModelProperty(required = true, value = "")
|
||||
@NotNull
|
||||
|
||||
@Valid
|
||||
public VersionStatsAll getStats() {
|
||||
return stats;
|
||||
}
|
||||
|
||||
public void setStats(VersionStatsAll stats) {
|
||||
this.stats = stats;
|
||||
}
|
||||
|
||||
public Version fileInfo(FileInfo fileInfo) {
|
||||
this.fileInfo = fileInfo;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get fileInfo
|
||||
*
|
||||
* @return fileInfo
|
||||
**/
|
||||
@ApiModelProperty(required = true, value = "")
|
||||
@NotNull
|
||||
|
||||
@Valid
|
||||
public FileInfo getFileInfo() {
|
||||
return fileInfo;
|
||||
}
|
||||
|
||||
public void setFileInfo(FileInfo fileInfo) {
|
||||
this.fileInfo = fileInfo;
|
||||
}
|
||||
|
||||
public Version author(String author) {
|
||||
this.author = author;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get author
|
||||
*
|
||||
* @return author
|
||||
**/
|
||||
@ApiModelProperty(value = "")
|
||||
|
||||
public String getAuthor() {
|
||||
return author;
|
||||
}
|
||||
|
||||
public void setAuthor(String author) {
|
||||
this.author = author;
|
||||
}
|
||||
|
||||
public Version reviewState(ReviewState reviewState) {
|
||||
this.reviewState = reviewState;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get reviewState
|
||||
*
|
||||
* @return reviewState
|
||||
**/
|
||||
@ApiModelProperty(required = true, value = "")
|
||||
@NotNull
|
||||
|
||||
public ReviewState getReviewState() {
|
||||
return reviewState;
|
||||
}
|
||||
|
||||
public void setReviewState(ReviewState reviewState) {
|
||||
this.reviewState = reviewState;
|
||||
}
|
||||
|
||||
public Version tags(List<Tag> tags) {
|
||||
this.tags = tags;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Version addTagsItem(Tag tagsItem) {
|
||||
this.tags.add(tagsItem);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get tags
|
||||
*
|
||||
* @return tags
|
||||
**/
|
||||
@ApiModelProperty(required = true, value = "")
|
||||
@NotNull
|
||||
@Valid
|
||||
public List<Tag> getTags() {
|
||||
return tags;
|
||||
}
|
||||
|
||||
public void setTags(List<Tag> tags) {
|
||||
this.tags = tags;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
Version version = (Version) o;
|
||||
return Objects.equals(this.createdAt, version.createdAt) &&
|
||||
Objects.equals(this.name, version.name) &&
|
||||
Objects.equals(this.dependencies, version.dependencies) &&
|
||||
Objects.equals(this.visibility, version.visibility) &&
|
||||
Objects.equals(this.description, version.description) &&
|
||||
Objects.equals(this.stats, version.stats) &&
|
||||
Objects.equals(this.fileInfo, version.fileInfo) &&
|
||||
Objects.equals(this.author, version.author) &&
|
||||
Objects.equals(this.reviewState, version.reviewState) &&
|
||||
Objects.equals(this.tags, version.tags);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(createdAt, name, dependencies, visibility, description, stats, fileInfo, author, reviewState, tags);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("class ModelsProtocolsAPIV2Version {\n");
|
||||
|
||||
sb.append(" createdAt: ").append(toIndentedString(createdAt)).append("\n");
|
||||
sb.append(" name: ").append(toIndentedString(name)).append("\n");
|
||||
sb.append(" dependencies: ").append(toIndentedString(dependencies)).append("\n");
|
||||
sb.append(" visibility: ").append(toIndentedString(visibility)).append("\n");
|
||||
sb.append(" description: ").append(toIndentedString(description)).append("\n");
|
||||
sb.append(" stats: ").append(toIndentedString(stats)).append("\n");
|
||||
sb.append(" fileInfo: ").append(toIndentedString(fileInfo)).append("\n");
|
||||
sb.append(" author: ").append(toIndentedString(author)).append("\n");
|
||||
sb.append(" reviewState: ").append(toIndentedString(reviewState)).append("\n");
|
||||
sb.append(" tags: ").append(toIndentedString(tags)).append("\n");
|
||||
sb.append("}");
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the given object to string with each line indented by 4 spaces (except the first line).
|
||||
*/
|
||||
private String toIndentedString(Object o) {
|
||||
if (o == null) {
|
||||
return "null";
|
||||
}
|
||||
return o.toString().replace("\n", "\n ");
|
||||
}
|
||||
}
|
@ -0,0 +1,78 @@
|
||||
package me.minidigger.hangar.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import java.util.Objects;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
/**
|
||||
* ModelsProtocolsAPIV2VersionStatsAll
|
||||
*/
|
||||
@Validated
|
||||
public class VersionStatsAll {
|
||||
@JsonProperty("downloads")
|
||||
private Long downloads = null;
|
||||
|
||||
public VersionStatsAll downloads(Long downloads) {
|
||||
this.downloads = downloads;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get downloads
|
||||
*
|
||||
* @return downloads
|
||||
**/
|
||||
@ApiModelProperty(required = true, value = "")
|
||||
@NotNull
|
||||
|
||||
public Long getDownloads() {
|
||||
return downloads;
|
||||
}
|
||||
|
||||
public void setDownloads(Long downloads) {
|
||||
this.downloads = downloads;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
VersionStatsAll versionStatsAll = (VersionStatsAll) o;
|
||||
return Objects.equals(this.downloads, versionStatsAll.downloads);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(downloads);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("class ModelsProtocolsAPIV2VersionStatsAll {\n");
|
||||
|
||||
sb.append(" downloads: ").append(toIndentedString(downloads)).append("\n");
|
||||
sb.append("}");
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the given object to string with each line indented by 4 spaces (except the first line).
|
||||
*/
|
||||
private String toIndentedString(Object o) {
|
||||
if (o == null) {
|
||||
return "null";
|
||||
}
|
||||
return o.toString().replace("\n", "\n ");
|
||||
}
|
||||
}
|
@ -0,0 +1,78 @@
|
||||
package me.minidigger.hangar.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import java.util.Objects;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
/**
|
||||
* ModelsProtocolsAPIV2VersionStatsDay
|
||||
*/
|
||||
@Validated
|
||||
public class VersionStatsDay {
|
||||
@JsonProperty("downloads")
|
||||
private Long downloads = null;
|
||||
|
||||
public VersionStatsDay downloads(Long downloads) {
|
||||
this.downloads = downloads;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get downloads
|
||||
*
|
||||
* @return downloads
|
||||
**/
|
||||
@ApiModelProperty(required = true, value = "")
|
||||
@NotNull
|
||||
|
||||
public Long getDownloads() {
|
||||
return downloads;
|
||||
}
|
||||
|
||||
public void setDownloads(Long downloads) {
|
||||
this.downloads = downloads;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
VersionStatsDay versionStatsDay = (VersionStatsDay) o;
|
||||
return Objects.equals(this.downloads, versionStatsDay.downloads);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(downloads);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("class ModelsProtocolsAPIV2VersionStatsDay {\n");
|
||||
|
||||
sb.append(" downloads: ").append(toIndentedString(downloads)).append("\n");
|
||||
sb.append("}");
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the given object to string with each line indented by 4 spaces (except the first line).
|
||||
*/
|
||||
private String toIndentedString(Object o) {
|
||||
if (o == null) {
|
||||
return "null";
|
||||
}
|
||||
return o.toString().replace("\n", "\n ");
|
||||
}
|
||||
}
|
41
src/main/java/me/minidigger/hangar/model/Visibility.java
Normal file
41
src/main/java/me/minidigger/hangar/model/Visibility.java
Normal file
@ -0,0 +1,41 @@
|
||||
package me.minidigger.hangar.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import com.fasterxml.jackson.annotation.JsonValue;
|
||||
|
||||
/**
|
||||
* Gets or Sets visibility
|
||||
*/
|
||||
public enum Visibility {
|
||||
PUBLIC("public"),
|
||||
|
||||
NEW("new"),
|
||||
|
||||
NEEDSCHANGES("needsChanges"),
|
||||
|
||||
NEEDSAPPROVAL("needsApproval"),
|
||||
|
||||
SOFTDELETE("softDelete");
|
||||
|
||||
private final String value;
|
||||
|
||||
Visibility(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
@JsonValue
|
||||
public String toString() {
|
||||
return String.valueOf(value);
|
||||
}
|
||||
|
||||
@JsonCreator
|
||||
public static Visibility fromValue(String text) {
|
||||
for (Visibility b : Visibility.values()) {
|
||||
if (String.valueOf(b.value).equals(text)) {
|
||||
return b;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
@ -0,0 +1,233 @@
|
||||
package me.minidigger.hangar.util;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonParser;
|
||||
import com.fasterxml.jackson.core.JsonTokenId;
|
||||
import com.fasterxml.jackson.databind.DeserializationContext;
|
||||
import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||
import com.fasterxml.jackson.databind.JsonDeserializer;
|
||||
import com.fasterxml.jackson.datatype.threetenbp.DateTimeUtils;
|
||||
import com.fasterxml.jackson.datatype.threetenbp.DecimalUtils;
|
||||
import com.fasterxml.jackson.datatype.threetenbp.deser.ThreeTenDateTimeDeserializerBase;
|
||||
import com.fasterxml.jackson.datatype.threetenbp.function.BiFunction;
|
||||
import com.fasterxml.jackson.datatype.threetenbp.function.Function;
|
||||
|
||||
import org.threeten.bp.DateTimeException;
|
||||
import org.threeten.bp.Instant;
|
||||
import org.threeten.bp.OffsetDateTime;
|
||||
import org.threeten.bp.ZoneId;
|
||||
import org.threeten.bp.ZonedDateTime;
|
||||
import org.threeten.bp.format.DateTimeFormatter;
|
||||
import org.threeten.bp.temporal.Temporal;
|
||||
import org.threeten.bp.temporal.TemporalAccessor;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* Deserializer for ThreeTen temporal {@link Instant}s, {@link OffsetDateTime}, and {@link ZonedDateTime}s. Adapted from
|
||||
* the jackson threetenbp InstantDeserializer to add support for deserializing rfc822 format.
|
||||
*
|
||||
* @author Nick Williams
|
||||
*/
|
||||
public class CustomInstantDeserializer<T extends Temporal>
|
||||
extends ThreeTenDateTimeDeserializerBase<T> {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public static final CustomInstantDeserializer<Instant> INSTANT = new CustomInstantDeserializer<>(
|
||||
Instant.class, DateTimeFormatter.ISO_INSTANT,
|
||||
new Function<>() {
|
||||
@Override
|
||||
public Instant apply(TemporalAccessor temporalAccessor) {
|
||||
return Instant.from(temporalAccessor);
|
||||
}
|
||||
},
|
||||
new Function<>() {
|
||||
@Override
|
||||
public Instant apply(FromIntegerArguments a) {
|
||||
return Instant.ofEpochMilli(a.value);
|
||||
}
|
||||
},
|
||||
new Function<>() {
|
||||
@Override
|
||||
public Instant apply(FromDecimalArguments a) {
|
||||
return Instant.ofEpochSecond(a.integer, a.fraction);
|
||||
}
|
||||
},
|
||||
null
|
||||
);
|
||||
|
||||
public static final CustomInstantDeserializer<OffsetDateTime> OFFSET_DATE_TIME = new CustomInstantDeserializer<>(
|
||||
OffsetDateTime.class, DateTimeFormatter.ISO_OFFSET_DATE_TIME,
|
||||
new Function<>() {
|
||||
@Override
|
||||
public OffsetDateTime apply(TemporalAccessor temporalAccessor) {
|
||||
return OffsetDateTime.from(temporalAccessor);
|
||||
}
|
||||
},
|
||||
new Function<>() {
|
||||
@Override
|
||||
public OffsetDateTime apply(FromIntegerArguments a) {
|
||||
return OffsetDateTime.ofInstant(Instant.ofEpochMilli(a.value), a.zoneId);
|
||||
}
|
||||
},
|
||||
new Function<>() {
|
||||
@Override
|
||||
public OffsetDateTime apply(FromDecimalArguments a) {
|
||||
return OffsetDateTime.ofInstant(Instant.ofEpochSecond(a.integer, a.fraction), a.zoneId);
|
||||
}
|
||||
},
|
||||
new BiFunction<>() {
|
||||
@Override
|
||||
public OffsetDateTime apply(OffsetDateTime d, ZoneId z) {
|
||||
return d.withOffsetSameInstant(z.getRules().getOffset(d.toLocalDateTime()));
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
public static final CustomInstantDeserializer<ZonedDateTime> ZONED_DATE_TIME = new CustomInstantDeserializer<>(
|
||||
ZonedDateTime.class, DateTimeFormatter.ISO_ZONED_DATE_TIME,
|
||||
new Function<>() {
|
||||
@Override
|
||||
public ZonedDateTime apply(TemporalAccessor temporalAccessor) {
|
||||
return ZonedDateTime.from(temporalAccessor);
|
||||
}
|
||||
},
|
||||
new Function<>() {
|
||||
@Override
|
||||
public ZonedDateTime apply(FromIntegerArguments a) {
|
||||
return ZonedDateTime.ofInstant(Instant.ofEpochMilli(a.value), a.zoneId);
|
||||
}
|
||||
},
|
||||
new Function<>() {
|
||||
@Override
|
||||
public ZonedDateTime apply(FromDecimalArguments a) {
|
||||
return ZonedDateTime.ofInstant(Instant.ofEpochSecond(a.integer, a.fraction), a.zoneId);
|
||||
}
|
||||
},
|
||||
new BiFunction<>() {
|
||||
@Override
|
||||
public ZonedDateTime apply(ZonedDateTime zonedDateTime, ZoneId zoneId) {
|
||||
return zonedDateTime.withZoneSameInstant(zoneId);
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
protected final Function<FromIntegerArguments, T> fromMilliseconds;
|
||||
|
||||
protected final Function<FromDecimalArguments, T> fromNanoseconds;
|
||||
|
||||
protected final Function<TemporalAccessor, T> parsedToValue;
|
||||
|
||||
protected final BiFunction<T, ZoneId, T> adjust;
|
||||
|
||||
protected CustomInstantDeserializer(Class<T> supportedType,
|
||||
DateTimeFormatter parser,
|
||||
Function<TemporalAccessor, T> parsedToValue,
|
||||
Function<FromIntegerArguments, T> fromMilliseconds,
|
||||
Function<FromDecimalArguments, T> fromNanoseconds,
|
||||
BiFunction<T, ZoneId, T> adjust) {
|
||||
super(supportedType, parser);
|
||||
this.parsedToValue = parsedToValue;
|
||||
this.fromMilliseconds = fromMilliseconds;
|
||||
this.fromNanoseconds = fromNanoseconds;
|
||||
this.adjust = adjust == null ? new BiFunction<>() {
|
||||
@Override
|
||||
public T apply(T t, ZoneId zoneId) {
|
||||
return t;
|
||||
}
|
||||
} : adjust;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
protected CustomInstantDeserializer(CustomInstantDeserializer<T> base, DateTimeFormatter f) {
|
||||
super((Class<T>) base.handledType(), f);
|
||||
parsedToValue = base.parsedToValue;
|
||||
fromMilliseconds = base.fromMilliseconds;
|
||||
fromNanoseconds = base.fromNanoseconds;
|
||||
adjust = base.adjust;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected JsonDeserializer<T> withDateFormat(DateTimeFormatter dtf) {
|
||||
if (dtf == _formatter) {
|
||||
return this;
|
||||
}
|
||||
return new CustomInstantDeserializer<>(this, dtf);
|
||||
}
|
||||
|
||||
@Override
|
||||
public T deserialize(JsonParser parser, DeserializationContext context) throws IOException {
|
||||
//NOTE: Timestamps contain no timezone info, and are always in configured TZ. Only
|
||||
//string values have to be adjusted to the configured TZ.
|
||||
switch (parser.getCurrentTokenId()) {
|
||||
case JsonTokenId.ID_NUMBER_FLOAT: {
|
||||
BigDecimal value = parser.getDecimalValue();
|
||||
long seconds = value.longValue();
|
||||
int nanoseconds = DecimalUtils.extractNanosecondDecimal(value, seconds);
|
||||
return fromNanoseconds.apply(new FromDecimalArguments(
|
||||
seconds, nanoseconds, getZone(context)));
|
||||
}
|
||||
|
||||
case JsonTokenId.ID_NUMBER_INT: {
|
||||
long timestamp = parser.getLongValue();
|
||||
if (context.isEnabled(DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS)) {
|
||||
return this.fromNanoseconds.apply(new FromDecimalArguments(
|
||||
timestamp, 0, this.getZone(context)
|
||||
));
|
||||
}
|
||||
return this.fromMilliseconds.apply(new FromIntegerArguments(
|
||||
timestamp, this.getZone(context)
|
||||
));
|
||||
}
|
||||
|
||||
case JsonTokenId.ID_STRING: {
|
||||
String string = parser.getText().trim();
|
||||
if (string.length() == 0) {
|
||||
return null;
|
||||
}
|
||||
if (string.endsWith("+0000")) {
|
||||
string = string.substring(0, string.length() - 5) + "Z";
|
||||
}
|
||||
T value;
|
||||
try {
|
||||
TemporalAccessor acc = _formatter.parse(string);
|
||||
value = parsedToValue.apply(acc);
|
||||
if (context.isEnabled(DeserializationFeature.ADJUST_DATES_TO_CONTEXT_TIME_ZONE)) {
|
||||
return adjust.apply(value, this.getZone(context));
|
||||
}
|
||||
} catch (DateTimeException e) {
|
||||
throw _peelDTE(e);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
}
|
||||
throw context.mappingException("Expected type float, integer, or string.");
|
||||
}
|
||||
|
||||
private ZoneId getZone(DeserializationContext context) {
|
||||
// Instants are always in UTC, so don't waste compute cycles
|
||||
return (_valueClass == Instant.class) ? null : DateTimeUtils.timeZoneToZoneId(context.getTimeZone());
|
||||
}
|
||||
|
||||
private static class FromIntegerArguments {
|
||||
public final long value;
|
||||
public final ZoneId zoneId;
|
||||
|
||||
private FromIntegerArguments(long value, ZoneId zoneId) {
|
||||
this.value = value;
|
||||
this.zoneId = zoneId;
|
||||
}
|
||||
}
|
||||
|
||||
private static class FromDecimalArguments {
|
||||
public final long integer;
|
||||
public final int fraction;
|
||||
public final ZoneId zoneId;
|
||||
|
||||
private FromDecimalArguments(long integer, int fraction, ZoneId zoneId) {
|
||||
this.integer = integer;
|
||||
this.fraction = fraction;
|
||||
this.zoneId = zoneId;
|
||||
}
|
||||
}
|
||||
}
|
6
src/main/resources/application.properties
Normal file
6
src/main/resources/application.properties
Normal file
@ -0,0 +1,6 @@
|
||||
server.port=8080
|
||||
spring.jpa.database=POSTGRESQL
|
||||
spring.datasource.platform=postgres
|
||||
spring.datasource.url=jdbc:postgresql://localhost:5432/hangar
|
||||
spring.datasource.username=root
|
||||
spring.datasource.password=changeme
|
@ -0,0 +1,13 @@
|
||||
package me.minidigger.hangar;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
@SpringBootTest
|
||||
class HangarApplicationTests {
|
||||
|
||||
@Test
|
||||
void contextLoads() {
|
||||
}
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user