commit d15cf46ac3a8de4734b4b2b95826ce5af6dc3a9d Author: materus Date: Sun Feb 18 12:35:17 2024 +0100 Init commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..c2065bc --- /dev/null +++ b/.gitignore @@ -0,0 +1,37 @@ +HELP.md +.gradle +build/ +!gradle/wrapper/gradle-wrapper.jar +!**/src/main/**/build/ +!**/src/test/**/build/ + +### STS ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache +bin/ +!**/src/main/**/bin/ +!**/src/test/**/bin/ + +### IntelliJ IDEA ### +.idea +*.iws +*.iml +*.ipr +out/ +!**/src/main/**/out/ +!**/src/test/**/out/ + +### NetBeans ### +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ + +### VS Code ### +.vscode/ diff --git a/README.md b/README.md new file mode 100644 index 0000000..cf43a2b --- /dev/null +++ b/README.md @@ -0,0 +1,40 @@ +# GHRepo + + + +## Description + +Recruitment task. +REST API application that retrieves a user's repositories and their branches, returning only those that are not forks. + + +## Build + +Needs Java 21 and Gradle 8.5 +To build clone and run +```bash +./gradlew build +``` + ## Usage + + Program needs to get request with appropriate header `application/json` to enpoint `/{username}` + For example with curl + ```bash + curl -H "Accept: application/json" http://127.0.0.1:8080/materusPL + ``` + + Program will return list of repositories and their branches in format: + ```json + [{ + "name":"", //Repository name + "owner":"", //Owner name + "branches": [{"name":"", "sha":"" }] //List of branches with their name and last commit sha + }] + ``` + On error it will return json in format: + ```json + { + "message":"", + "status":"" + } + ``` diff --git a/build.gradle b/build.gradle new file mode 100644 index 0000000..e9a300e --- /dev/null +++ b/build.gradle @@ -0,0 +1,30 @@ +plugins { + id 'java' + id 'org.springframework.boot' version '3.2.2' + id 'io.spring.dependency-management' version '1.1.4' +} + +group = 'pl.materus' +version = '0.0.1-SNAPSHOT' + +java { + sourceCompatibility = '21' + targetCompatibility = '21' +} + +repositories { + mavenCentral() +} + +dependencies { + implementation 'org.springframework.boot:spring-boot-starter-web' + implementation 'org.springframework.boot:spring-boot-starter-webflux' + + testImplementation 'org.springframework.boot:spring-boot-starter-test' + testImplementation 'org.wiremock:wiremock-standalone:3.3.1' + testImplementation 'io.projectreactor:reactor-test' + +} +tasks.named('test') { + useJUnitPlatform() +} diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000..d64cd49 Binary files /dev/null and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..1af9e09 --- /dev/null +++ b/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,7 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip +networkTimeout=10000 +validateDistributionUrl=true +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew new file mode 100755 index 0000000..1aa94a4 --- /dev/null +++ b/gradlew @@ -0,0 +1,249 @@ +#!/bin/sh + +# +# Copyright © 2015-2021 the original 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. +# + +############################################################################## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# +############################################################################## + +# Attempt to set APP_HOME + +# Resolve links: $0 may be a link +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac +done + +# This is normally unused +# shellcheck disable=SC2034 +APP_BASE_NAME=${0##*/} +# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) +APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD=maximum + +warn () { + echo "$*" +} >&2 + +die () { + echo + echo "$*" + echo + exit 1 +} >&2 + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + + +# Determine the Java command to use to start the JVM. +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 + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD=java + if ! command -v java >/dev/null 2>&1 + then + die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +fi + +# Increase the maximum file descriptors if we can. +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac +fi + +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. + +# For Cygwin or MSYS, switch paths to Windows format before running java +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) + + # Now convert the arguments - kludge to limit ourselves to /bin/sh + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) + fi + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg + done +fi + + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Collect all arguments for the java command: +# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# and any embedded shellness will be escaped. +# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be +# treated as '${Hostname}' itself on the command line. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -classpath "$CLASSPATH" \ + org.gradle.wrapper.GradleWrapperMain \ + "$@" + +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" +fi + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' + +exec "$JAVACMD" "$@" diff --git a/gradlew.bat b/gradlew.bat new file mode 100644 index 0000000..6689b85 --- /dev/null +++ b/gradlew.bat @@ -0,0 +1,92 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem 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, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@if "%DEBUG%"=="" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if %ERRORLEVEL% equ 0 goto execute + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* + +:end +@rem End local scope for the variables with windows NT shell +if %ERRORLEVEL% equ 0 goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/settings.gradle b/settings.gradle new file mode 100644 index 0000000..1c49194 --- /dev/null +++ b/settings.gradle @@ -0,0 +1 @@ +rootProject.name = 'ghrepo' diff --git a/src/main/java/pl/materus/ghrepo/GhrepoApplication.java b/src/main/java/pl/materus/ghrepo/GhrepoApplication.java new file mode 100644 index 0000000..09dc17f --- /dev/null +++ b/src/main/java/pl/materus/ghrepo/GhrepoApplication.java @@ -0,0 +1,13 @@ +package pl.materus.ghrepo; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class GhrepoApplication { + + public static void main(String[] args) { + SpringApplication.run(GhrepoApplication.class, args); + } + +} diff --git a/src/main/java/pl/materus/ghrepo/config/WebClientConfig.java b/src/main/java/pl/materus/ghrepo/config/WebClientConfig.java new file mode 100644 index 0000000..4fe1b3c --- /dev/null +++ b/src/main/java/pl/materus/ghrepo/config/WebClientConfig.java @@ -0,0 +1,34 @@ +package pl.materus.ghrepo.config; + +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.lang.NonNull; +import org.springframework.web.reactive.function.client.WebClient; + +@Configuration +public class WebClientConfig { + + @Value("${github-url}") + @NonNull + private String webclientUrl = "https://api.github.com"; + + @Bean + public WebClient.Builder webClientBuilder() { + return WebClient.builder(); + } + + @Bean + public WebClient githubWebClient(WebClient.Builder webClientBuilder) { + return webClientBuilder.baseUrl(this.getWebclientUrl()).build(); + } + + @NonNull + public String getWebclientUrl() { + return webclientUrl; + } + + public void setWebclientUrl(@NonNull String webclientUrl) { + this.webclientUrl = webclientUrl; + } +} diff --git a/src/main/java/pl/materus/ghrepo/controller/GitHubController.java b/src/main/java/pl/materus/ghrepo/controller/GitHubController.java new file mode 100644 index 0000000..dce0fc9 --- /dev/null +++ b/src/main/java/pl/materus/ghrepo/controller/GitHubController.java @@ -0,0 +1,84 @@ +package pl.materus.ghrepo.controller; + +import pl.materus.ghrepo.exception.WrongHeaderException; +import pl.materus.ghrepo.model.ResponseErrorModel; +import pl.materus.ghrepo.model.ResponseRepositoryModel; +import pl.materus.ghrepo.service.GitHubService; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpHeaders; +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.ExceptionHandler; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestHeader; +import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.reactive.function.client.WebClientResponseException; + +import reactor.core.publisher.Flux; + +@RestController +public class GitHubController { + + private final GitHubService gitHubService; + + @Autowired + public GitHubController(GitHubService gitHubService) { + this.gitHubService = gitHubService; + } + + @GetMapping("/{username}") + public ResponseEntity> getUserRepos( + @RequestHeader(name = HttpHeaders.ACCEPT) String acceptHeader, @PathVariable String username) { + + if (!acceptHeader.contains("application/json")) { + throw new WrongHeaderException("Request does not contain the 'application/json' header."); + } + HttpHeaders httpHeaders= new HttpHeaders(); + httpHeaders.setContentType(MediaType.APPLICATION_JSON); + return ResponseEntity.ok().headers(httpHeaders).body(gitHubService.getUserRepos(username)); + } + + @ExceptionHandler(WebClientResponseException.class) + public ResponseEntity handleResponseException(WebClientResponseException ex) { + ResponseErrorModel responseErrorModel = new ResponseErrorModel(); + HttpStatus status = HttpStatus.INTERNAL_SERVER_ERROR; + HttpHeaders httpHeaders= new HttpHeaders(); + httpHeaders.setContentType(MediaType.APPLICATION_JSON); + + responseErrorModel.setStatus(ex.getStatusCode().value()); + switch (responseErrorModel.getStatus()) { + case 404: + responseErrorModel.setMessage("User not found"); + status = HttpStatus.NOT_FOUND; + break; + + case 403: + responseErrorModel.setMessage("Github API limit"); + status = HttpStatus.FORBIDDEN; + break; + + default: + responseErrorModel.setMessage("Unknown github webclient error"); + break; + + } + + return ResponseEntity.status(status).headers(httpHeaders).body(responseErrorModel); + + } + + @ExceptionHandler(WrongHeaderException.class) + public ResponseEntity handleResponseException(WrongHeaderException ex) { + ResponseErrorModel responseErrorModel = new ResponseErrorModel(); + responseErrorModel.setStatus(HttpStatus.BAD_REQUEST.value()); + responseErrorModel.setMessage(ex.getMessage()); + + HttpHeaders httpHeaders= new HttpHeaders(); + httpHeaders.setContentType(MediaType.APPLICATION_JSON); + + return ResponseEntity.badRequest().headers(httpHeaders).body(responseErrorModel); + } +} diff --git a/src/main/java/pl/materus/ghrepo/exception/WrongHeaderException.java b/src/main/java/pl/materus/ghrepo/exception/WrongHeaderException.java new file mode 100644 index 0000000..37078cb --- /dev/null +++ b/src/main/java/pl/materus/ghrepo/exception/WrongHeaderException.java @@ -0,0 +1,7 @@ +package pl.materus.ghrepo.exception; + +public class WrongHeaderException extends RuntimeException { + public WrongHeaderException(String message) { + super(message); + } +} diff --git a/src/main/java/pl/materus/ghrepo/model/GitHubBranchCommitModel.java b/src/main/java/pl/materus/ghrepo/model/GitHubBranchCommitModel.java new file mode 100644 index 0000000..dce44a5 --- /dev/null +++ b/src/main/java/pl/materus/ghrepo/model/GitHubBranchCommitModel.java @@ -0,0 +1,13 @@ +package pl.materus.ghrepo.model; + +public class GitHubBranchCommitModel { + String sha; + + public String getSha() { + return sha; + } + + public void setSha(String sha) { + this.sha = sha; + } +} diff --git a/src/main/java/pl/materus/ghrepo/model/GitHubBranchModel.java b/src/main/java/pl/materus/ghrepo/model/GitHubBranchModel.java new file mode 100644 index 0000000..3a2c27c --- /dev/null +++ b/src/main/java/pl/materus/ghrepo/model/GitHubBranchModel.java @@ -0,0 +1,24 @@ +package pl.materus.ghrepo.model; + + +public class GitHubBranchModel { + String name; + + GitHubBranchCommitModel commit; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public GitHubBranchCommitModel getCommit() { + return commit; + } + + public void setCommit(GitHubBranchCommitModel commit) { + this.commit = commit; + } +} diff --git a/src/main/java/pl/materus/ghrepo/model/GitHubRepositoryModel.java b/src/main/java/pl/materus/ghrepo/model/GitHubRepositoryModel.java new file mode 100644 index 0000000..6398c39 --- /dev/null +++ b/src/main/java/pl/materus/ghrepo/model/GitHubRepositoryModel.java @@ -0,0 +1,33 @@ +package pl.materus.ghrepo.model; + +public class GitHubRepositoryModel { + String name; + + GitHubRepositoryOwnerModel owner; + + Boolean fork; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public GitHubRepositoryOwnerModel getOwner() { + return owner; + } + + public void setOwner(GitHubRepositoryOwnerModel owner) { + this.owner = owner; + } + + public Boolean getFork() { + return fork; + } + + public void setFork(Boolean fork) { + this.fork = fork; + } +} diff --git a/src/main/java/pl/materus/ghrepo/model/GitHubRepositoryOwnerModel.java b/src/main/java/pl/materus/ghrepo/model/GitHubRepositoryOwnerModel.java new file mode 100644 index 0000000..af9ee62 --- /dev/null +++ b/src/main/java/pl/materus/ghrepo/model/GitHubRepositoryOwnerModel.java @@ -0,0 +1,14 @@ +package pl.materus.ghrepo.model; + +public class GitHubRepositoryOwnerModel { + String login; + + public String getLogin() { + return login; + } + + public void setLogin(String login) { + this.login = login; + } + +} diff --git a/src/main/java/pl/materus/ghrepo/model/ResponseBranchModel.java b/src/main/java/pl/materus/ghrepo/model/ResponseBranchModel.java new file mode 100644 index 0000000..3153400 --- /dev/null +++ b/src/main/java/pl/materus/ghrepo/model/ResponseBranchModel.java @@ -0,0 +1,20 @@ +package pl.materus.ghrepo.model; + +public class ResponseBranchModel{ + String name; + String sha; + + + public String getName() { + return name; + } + public void setName(String name) { + this.name = name; + } + public String getSha() { + return sha; + } + public void setSha(String sha) { + this.sha = sha; + } +} diff --git a/src/main/java/pl/materus/ghrepo/model/ResponseErrorModel.java b/src/main/java/pl/materus/ghrepo/model/ResponseErrorModel.java new file mode 100644 index 0000000..b454bf2 --- /dev/null +++ b/src/main/java/pl/materus/ghrepo/model/ResponseErrorModel.java @@ -0,0 +1,22 @@ +package pl.materus.ghrepo.model; + +public class ResponseErrorModel{ + Integer status; + String message; + + public Integer getStatus() { + return status; + } + + public void setStatus(Integer status) { + this.status = status; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } +} diff --git a/src/main/java/pl/materus/ghrepo/model/ResponseRepositoryModel.java b/src/main/java/pl/materus/ghrepo/model/ResponseRepositoryModel.java new file mode 100644 index 0000000..3742888 --- /dev/null +++ b/src/main/java/pl/materus/ghrepo/model/ResponseRepositoryModel.java @@ -0,0 +1,28 @@ +package pl.materus.ghrepo.model; +import java.util.List; + +public class ResponseRepositoryModel { + + String name; + String owner; + List branches; + + public String getName() { + return name; + } + public void setName(String name) { + this.name = name; + } + public String getOwner() { + return owner; + } + public void setOwner(String owner) { + this.owner = owner; + } + public List getBranches() { + return branches; + } + public void setBranches(List branches) { + this.branches = branches; + } +} diff --git a/src/main/java/pl/materus/ghrepo/service/GitHubService.java b/src/main/java/pl/materus/ghrepo/service/GitHubService.java new file mode 100644 index 0000000..5bc52ad --- /dev/null +++ b/src/main/java/pl/materus/ghrepo/service/GitHubService.java @@ -0,0 +1,66 @@ +package pl.materus.ghrepo.service; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.web.reactive.function.client.WebClient; + +import pl.materus.ghrepo.model.GitHubBranchModel; +import pl.materus.ghrepo.model.GitHubRepositoryModel; +import pl.materus.ghrepo.model.ResponseBranchModel; +import pl.materus.ghrepo.model.ResponseRepositoryModel; + +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; +import reactor.core.scheduler.Schedulers; + +@Service +public class GitHubService { + + private final WebClient githubWebClient; + + @Autowired + public GitHubService(WebClient githubWebClient) { + this.githubWebClient = githubWebClient; + } + + public Flux getUserRepos(String username) { + return githubWebClient.get() + .uri("/users/{username}/repos", username) + .retrieve() + .bodyToFlux(GitHubRepositoryModel.class) + .filter(repo -> !repo.getFork()) + .flatMap(this::createResponse) + .flatMap(repo -> getRepoBranches(repo.getOwner(), repo.getName()) + .collectList() + .map(branches -> { + repo.setBranches(branches); + return repo; + })) + .subscribeOn(Schedulers.boundedElastic()); + + } + + private Flux getRepoBranches(String owner, String repo) { + return githubWebClient.get() + .uri("/repos/{owner}/{repo}/branches", owner, repo) + .retrieve() + .bodyToFlux(GitHubBranchModel.class) + .flatMap(branch -> createResponseBranch(branch)); + + } + + private Mono createResponse(GitHubRepositoryModel repository) { + ResponseRepositoryModel responseRepositoryModel = new ResponseRepositoryModel(); + responseRepositoryModel.setName(repository.getName()); + responseRepositoryModel.setOwner(repository.getOwner().getLogin()); + return Mono.just(responseRepositoryModel); + } + + private Mono createResponseBranch(GitHubBranchModel branch) { + ResponseBranchModel responseBranchModel = new ResponseBranchModel(); + responseBranchModel.setName(branch.getName()); + responseBranchModel.setSha(branch.getCommit().getSha()); + return Mono.just(responseBranchModel); + } + +} \ No newline at end of file diff --git a/src/main/java/pl/materus/ghrepo/util/ResourceReaderUtil.java b/src/main/java/pl/materus/ghrepo/util/ResourceReaderUtil.java new file mode 100644 index 0000000..55a5947 --- /dev/null +++ b/src/main/java/pl/materus/ghrepo/util/ResourceReaderUtil.java @@ -0,0 +1,28 @@ +package pl.materus.ghrepo.util; + +import java.io.IOException; +import java.io.UncheckedIOException; +import java.io.Reader; +import java.io.InputStreamReader; +import java.nio.charset.StandardCharsets; + +import org.springframework.core.io.DefaultResourceLoader; +import org.springframework.core.io.Resource; +import org.springframework.core.io.ResourceLoader; +import org.springframework.lang.NonNull; +import org.springframework.util.FileCopyUtils; + +public class ResourceReaderUtil { + + private static ResourceLoader resourceLoader = new DefaultResourceLoader(); + + public static String asString(@NonNull String resourcePath) { + + Resource resource = resourceLoader.getResource(resourcePath); + try (Reader reader = new InputStreamReader(resource.getInputStream(), StandardCharsets.UTF_8)) { + return FileCopyUtils.copyToString(reader); + } catch (IOException e) { + throw new UncheckedIOException(e); + } + } +} diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties new file mode 100644 index 0000000..fad7684 --- /dev/null +++ b/src/main/resources/application.properties @@ -0,0 +1 @@ +github-url=https://api.github.com diff --git a/src/test/java/pl/materus/ghrepo/GhrepoApplicationTests.java b/src/test/java/pl/materus/ghrepo/GhrepoApplicationTests.java new file mode 100644 index 0000000..1862bac --- /dev/null +++ b/src/test/java/pl/materus/ghrepo/GhrepoApplicationTests.java @@ -0,0 +1,13 @@ +package pl.materus.ghrepo; + +import org.junit.jupiter.api.Test; +import org.springframework.boot.test.context.SpringBootTest; + +@SpringBootTest +class GhrepoApplicationTests { + + @Test + void contextLoads() { + } + +} diff --git a/src/test/java/pl/materus/ghrepo/controller/GitHubControllerTest.java b/src/test/java/pl/materus/ghrepo/controller/GitHubControllerTest.java new file mode 100644 index 0000000..393c094 --- /dev/null +++ b/src/test/java/pl/materus/ghrepo/controller/GitHubControllerTest.java @@ -0,0 +1,88 @@ +package pl.materus.ghrepo.controller; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertThrows; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.http.HttpHeaders; +import org.springframework.http.MediaType; +import org.springframework.test.context.TestPropertySource; +import org.springframework.web.reactive.function.client.WebClientResponseException; + +import com.github.tomakehurst.wiremock.client.WireMock; +import com.github.tomakehurst.wiremock.core.WireMockConfiguration; +import com.github.tomakehurst.wiremock.junit5.WireMockExtension; + +import pl.materus.ghrepo.exception.WrongHeaderException; +import pl.materus.ghrepo.util.ResourceReaderUtil; + +@SpringBootTest +@TestPropertySource(properties = "github-url=http://127.0.0.1:9123") +public class GitHubControllerTest { + @Autowired + GitHubController githubController; + + @RegisterExtension + private static WireMockExtension wireMockExtension = WireMockExtension.newInstance() + .options(WireMockConfiguration.wireMockConfig().port(9123).bindAddress("127.0.0.1")) + .build(); + + @SuppressWarnings("null") + @Test + void testNotFound() { + wireMockExtension.stubFor(WireMock.get(WireMock.urlPathEqualTo("/users/notFound/repos")) + .willReturn(WireMock.aResponse() + .withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE) + .withStatus(404) + .withBody(ResourceReaderUtil.asString("classpath:jsonAnswers/notFound.json")))); + + WebClientResponseException e = assertThrows(WebClientResponseException.class, () -> { + var body = githubController.getUserRepos("application/json", "notFound").getBody(); + if (body != null) + body.collectList().block(); + }); + assertEquals(e.getStatusCode().value(), 404); + + var response = githubController.handleResponseException(e); + assertNotNull(response.getBody()); + assertEquals(404, response.getBody().getStatus()); + assertEquals("User not found", response.getBody().getMessage()); + } + + @SuppressWarnings("null") + @Test + void testNoHeader() { + WrongHeaderException e = assertThrows(WrongHeaderException.class, + () -> githubController.getUserRepos("", "shouldThrow")); + + var response = githubController.handleResponseException(e); + assertNotNull(response.getBody()); + assertEquals(400, response.getBody().getStatus()); + assertEquals("Request does not contain the 'application/json' header.", response.getBody().getMessage()); + } + + @SuppressWarnings("null") + @Test + void testApiLimits() { + wireMockExtension.stubFor(WireMock.get(WireMock.urlPathEqualTo("/users/forbidden/repos")) + .willReturn(WireMock.aResponse() + .withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE) + .withStatus(403) + .withBody(ResourceReaderUtil.asString("classpath:jsonAnswers/rateLimit.json")))); + WebClientResponseException e = assertThrows(WebClientResponseException.class, + () -> { + var body = githubController.getUserRepos("application/json", "forbidden").getBody(); + if (body != null) + body.collectList().block(); + }); + + var response = githubController.handleResponseException(e); + assertNotNull(response.getBody()); + assertEquals(403, response.getBody().getStatus()); + assertEquals("Github API limit", response.getBody().getMessage()); + } +} diff --git a/src/test/java/pl/materus/ghrepo/service/GitHubServiceTest.java b/src/test/java/pl/materus/ghrepo/service/GitHubServiceTest.java new file mode 100644 index 0000000..ece6f9c --- /dev/null +++ b/src/test/java/pl/materus/ghrepo/service/GitHubServiceTest.java @@ -0,0 +1,138 @@ +package pl.materus.ghrepo.service; + +import pl.materus.ghrepo.util.ResourceReaderUtil; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.http.HttpHeaders; +import org.springframework.http.MediaType; +import org.springframework.test.context.TestPropertySource; +import org.springframework.web.reactive.function.client.WebClientResponseException; + +import com.github.tomakehurst.wiremock.client.WireMock; +import com.github.tomakehurst.wiremock.core.WireMockConfiguration; +import com.github.tomakehurst.wiremock.junit5.WireMockExtension; + +@SpringBootTest +@TestPropertySource(properties = "github-url=http://127.0.0.1:9123") +public class GitHubServiceTest { + + @Autowired + GitHubService gitHubService; + + @RegisterExtension + private static WireMockExtension wireMockExtension = WireMockExtension.newInstance() + .options(WireMockConfiguration.wireMockConfig().port(9123).bindAddress("127.0.0.1")) + .build(); + + private void prepareRealUser() { + + wireMockExtension.stubFor(WireMock.get(WireMock.urlPathEqualTo("/users/materusPL/repos")) + .willReturn(WireMock.aResponse() + .withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE) + .withStatus(200) + .withBody(ResourceReaderUtil.asString("classpath:jsonAnswers/RealUser.json")))); + + wireMockExtension.stubFor(WireMock.get(WireMock.urlPathEqualTo("/repos/materusPL/materusPL/branches")) + .willReturn(WireMock.aResponse() + .withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE) + .withStatus(200) + .withBody(ResourceReaderUtil.asString("classpath:jsonAnswers/RealBranch1.json")))); + wireMockExtension.stubFor(WireMock.get(WireMock.urlPathEqualTo("/repos/materusPL/Nixerus/branches")) + .willReturn(WireMock.aResponse() + .withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE) + .withStatus(200) + .withBody(ResourceReaderUtil.asString("classpath:jsonAnswers/RealBranch2.json")))); + + wireMockExtension.stubFor(WireMock.get(WireMock.urlPathEqualTo("/repos/materusPL/nixos-config/branches")) + .willReturn(WireMock.aResponse() + .withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE) + .withStatus(200) + .withBody(ResourceReaderUtil.asString("classpath:jsonAnswers/RealBranch3.json")))); + + wireMockExtension.stubFor(WireMock.get(WireMock.urlPathEqualTo("/repos/materusPL/nixpkgs/branches")) + .willReturn(WireMock.aResponse() + .withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE) + .withStatus(200) + .withBody(ResourceReaderUtil.asString("classpath:jsonAnswers/RealBranch4.json")))); + + wireMockExtension.stubFor(WireMock.get(WireMock.urlPathEqualTo("/repos/materusPL/SNOL/branches")) + .willReturn(WireMock.aResponse() + .withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE) + .withStatus(200) + .withBody(ResourceReaderUtil.asString("classpath:jsonAnswers/RealBranch5.json")))); + } + + @Test + public void testRealUser() { + prepareRealUser(); + + var response = gitHubService.getUserRepos("materusPL").collectList().block(); + response.sort((repo1, repo2) -> { + return repo1.getName().compareTo(repo2.getName()); + }); + + assertEquals("Nixerus", response.get(0).getName()); + assertEquals("SNOL", response.get(1).getName()); + assertEquals("materusPL", response.get(2).getName()); + assertEquals("nixos-config", response.get(3).getName()); + + String owner = "materusPL"; + + assertEquals(owner, response.get(0).getOwner()); + assertEquals(owner, response.get(1).getOwner()); + assertEquals(owner, response.get(2).getOwner()); + assertEquals(owner, response.get(3).getOwner()); + + assertEquals("master", response.get(2).getBranches().get(0).getName()); + assertEquals("fd6867d8963147ba40d3df428045aec82f14dbe3", response.get(2).getBranches().get(0).getSha()); + + assertEquals(3, response.get(0).getBranches().size()); + assertEquals(2, response.get(3).getBranches().size()); + assertEquals(1, response.get(2).getBranches().size()); + + } + + @Test + public void testUserWithoutRepositories() { + wireMockExtension.stubFor(WireMock.get(WireMock.urlPathEqualTo("/users/empty/repos")) + .willReturn(WireMock.aResponse() + .withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE) + .withStatus(200) + .withBody("[]"))); + + var response = gitHubService.getUserRepos("empty").collectList().block(); + assertEquals(0, response.size()); + } + + @Test + public void testForkOnly() { + wireMockExtension.stubFor(WireMock.get(WireMock.urlPathEqualTo("/users/fork/repos")) + .willReturn(WireMock.aResponse() + .withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE) + .withStatus(200) + .withBody(ResourceReaderUtil.asString("classpath:jsonAnswers/forkOnly.json")))); + + var response = gitHubService.getUserRepos("fork").collectList().block(); + assertEquals(0, response.size()); + } + + @Test + public void testNotFound() { + wireMockExtension.stubFor(WireMock.get(WireMock.urlPathEqualTo("/users/notFound/repos")) + .willReturn(WireMock.aResponse() + .withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE) + .withStatus(404) + .withBody(ResourceReaderUtil.asString("classpath:jsonAnswers/notFound.json")))); + + WebClientResponseException e = assertThrows(WebClientResponseException.class, () -> { + gitHubService.getUserRepos("notFound").collectList().block(); + }); + assertEquals(404, e.getStatusCode().value()); + } +} diff --git a/src/test/resources/jsonAnswers/RealBranch1.json b/src/test/resources/jsonAnswers/RealBranch1.json new file mode 100644 index 0000000..f9137d1 --- /dev/null +++ b/src/test/resources/jsonAnswers/RealBranch1.json @@ -0,0 +1,10 @@ +[ + { + "name": "master", + "commit": { + "sha": "fd6867d8963147ba40d3df428045aec82f14dbe3", + "url": "https://api.github.com/repos/materusPL/materusPL/commits/fd6867d8963147ba40d3df428045aec82f14dbe3" + }, + "protected": false + } +] \ No newline at end of file diff --git a/src/test/resources/jsonAnswers/RealBranch2.json b/src/test/resources/jsonAnswers/RealBranch2.json new file mode 100644 index 0000000..554c8a2 --- /dev/null +++ b/src/test/resources/jsonAnswers/RealBranch2.json @@ -0,0 +1,26 @@ +[ + { + "name": "master", + "commit": { + "sha": "1d1741acebdc274af4795f4ca0faf88830a2a010", + "url": "https://api.github.com/repos/materusPL/Nixerus/commits/1d1741acebdc274af4795f4ca0faf88830a2a010" + }, + "protected": false + }, + { + "name": "mock", + "commit": { + "sha": "f07f3e99a7cd8680dd6bb082108a67830857e542", + "url": "https://api.github.com/repos/materusPL/Nixerus/commits/f07f3e99a7cd8680dd6bb082108a67830857e542" + }, + "protected": false + }, + { + "name": "testing", + "commit": { + "sha": "b27a11bb37445c941cb5ad610292358a5d184773", + "url": "https://api.github.com/repos/materusPL/Nixerus/commits/b27a11bb37445c941cb5ad610292358a5d184773" + }, + "protected": false + } +] \ No newline at end of file diff --git a/src/test/resources/jsonAnswers/RealBranch3.json b/src/test/resources/jsonAnswers/RealBranch3.json new file mode 100644 index 0000000..21b0f0d --- /dev/null +++ b/src/test/resources/jsonAnswers/RealBranch3.json @@ -0,0 +1,18 @@ +[ + { + "name": "inputs", + "commit": { + "sha": "06a35210af4b8586a2b3d64815a67e3516ce732a", + "url": "https://api.github.com/repos/materusPL/nixos-config/commits/06a35210af4b8586a2b3d64815a67e3516ce732a" + }, + "protected": false + }, + { + "name": "master", + "commit": { + "sha": "59e69924bb18acd396a15bb166743c037d4df756", + "url": "https://api.github.com/repos/materusPL/nixos-config/commits/59e69924bb18acd396a15bb166743c037d4df756" + }, + "protected": false + } +] \ No newline at end of file diff --git a/src/test/resources/jsonAnswers/RealBranch4.json b/src/test/resources/jsonAnswers/RealBranch4.json new file mode 100644 index 0000000..5e2d565 --- /dev/null +++ b/src/test/resources/jsonAnswers/RealBranch4.json @@ -0,0 +1,26 @@ +[ + { + "name": "master", + "commit": { + "sha": "ed5534ceb6bc94b7bcf00c16a3763f187973343e", + "url": "https://api.github.com/repos/materusPL/nixpkgs/commits/ed5534ceb6bc94b7bcf00c16a3763f187973343e" + }, + "protected": true + }, + { + "name": "materus/obs30", + "commit": { + "sha": "3e3ae27606269b783d873b2bf93aeb66c4f5f92d", + "url": "https://api.github.com/repos/materusPL/nixpkgs/commits/3e3ae27606269b783d873b2bf93aeb66c4f5f92d" + }, + "protected": false + }, + { + "name": "materus/obs-studio-libcef-link", + "commit": { + "sha": "a2a894536e29863fac63c176a3987666c36879c6", + "url": "https://api.github.com/repos/materusPL/nixpkgs/commits/a2a894536e29863fac63c176a3987666c36879c6" + }, + "protected": false + } +] \ No newline at end of file diff --git a/src/test/resources/jsonAnswers/RealBranch5.json b/src/test/resources/jsonAnswers/RealBranch5.json new file mode 100644 index 0000000..6cefdc6 --- /dev/null +++ b/src/test/resources/jsonAnswers/RealBranch5.json @@ -0,0 +1,10 @@ +[ + { + "name": "master", + "commit": { + "sha": "8c5c94c47aa1cf7850a6b0df9495808593a8fdba", + "url": "https://api.github.com/repos/materusPL/SNOL/commits/8c5c94c47aa1cf7850a6b0df9495808593a8fdba" + }, + "protected": false + } +] \ No newline at end of file diff --git a/src/test/resources/jsonAnswers/RealUser.json b/src/test/resources/jsonAnswers/RealUser.json new file mode 100644 index 0000000..5376e4b --- /dev/null +++ b/src/test/resources/jsonAnswers/RealUser.json @@ -0,0 +1,524 @@ +[ + { + "id": 706528419, + "node_id": "R_kgDOKhzEow", + "name": "materusPL", + "full_name": "materusPL/materusPL", + "private": false, + "owner": { + "login": "materusPL", + "id": 28183516, + "node_id": "MDQ6VXNlcjI4MTgzNTE2", + "avatar_url": "https://avatars.githubusercontent.com/u/28183516?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/materusPL", + "html_url": "https://github.com/materusPL", + "followers_url": "https://api.github.com/users/materusPL/followers", + "following_url": "https://api.github.com/users/materusPL/following{/other_user}", + "gists_url": "https://api.github.com/users/materusPL/gists{/gist_id}", + "starred_url": "https://api.github.com/users/materusPL/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/materusPL/subscriptions", + "organizations_url": "https://api.github.com/users/materusPL/orgs", + "repos_url": "https://api.github.com/users/materusPL/repos", + "events_url": "https://api.github.com/users/materusPL/events{/privacy}", + "received_events_url": "https://api.github.com/users/materusPL/received_events", + "type": "User", + "site_admin": false + }, + "html_url": "https://github.com/materusPL/materusPL", + "description": "Me, myself and I", + "fork": false, + "url": "https://api.github.com/repos/materusPL/materusPL", + "forks_url": "https://api.github.com/repos/materusPL/materusPL/forks", + "keys_url": "https://api.github.com/repos/materusPL/materusPL/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/materusPL/materusPL/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/materusPL/materusPL/teams", + "hooks_url": "https://api.github.com/repos/materusPL/materusPL/hooks", + "issue_events_url": "https://api.github.com/repos/materusPL/materusPL/issues/events{/number}", + "events_url": "https://api.github.com/repos/materusPL/materusPL/events", + "assignees_url": "https://api.github.com/repos/materusPL/materusPL/assignees{/user}", + "branches_url": "https://api.github.com/repos/materusPL/materusPL/branches{/branch}", + "tags_url": "https://api.github.com/repos/materusPL/materusPL/tags", + "blobs_url": "https://api.github.com/repos/materusPL/materusPL/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/materusPL/materusPL/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/materusPL/materusPL/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/materusPL/materusPL/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/materusPL/materusPL/statuses/{sha}", + "languages_url": "https://api.github.com/repos/materusPL/materusPL/languages", + "stargazers_url": "https://api.github.com/repos/materusPL/materusPL/stargazers", + "contributors_url": "https://api.github.com/repos/materusPL/materusPL/contributors", + "subscribers_url": "https://api.github.com/repos/materusPL/materusPL/subscribers", + "subscription_url": "https://api.github.com/repos/materusPL/materusPL/subscription", + "commits_url": "https://api.github.com/repos/materusPL/materusPL/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/materusPL/materusPL/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/materusPL/materusPL/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/materusPL/materusPL/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/materusPL/materusPL/contents/{+path}", + "compare_url": "https://api.github.com/repos/materusPL/materusPL/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/materusPL/materusPL/merges", + "archive_url": "https://api.github.com/repos/materusPL/materusPL/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/materusPL/materusPL/downloads", + "issues_url": "https://api.github.com/repos/materusPL/materusPL/issues{/number}", + "pulls_url": "https://api.github.com/repos/materusPL/materusPL/pulls{/number}", + "milestones_url": "https://api.github.com/repos/materusPL/materusPL/milestones{/number}", + "notifications_url": "https://api.github.com/repos/materusPL/materusPL/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/materusPL/materusPL/labels{/name}", + "releases_url": "https://api.github.com/repos/materusPL/materusPL/releases{/id}", + "deployments_url": "https://api.github.com/repos/materusPL/materusPL/deployments", + "created_at": "2023-10-18T06:09:45Z", + "updated_at": "2023-10-27T12:55:23Z", + "pushed_at": "2024-02-17T00:48:32Z", + "git_url": "git://github.com/materusPL/materusPL.git", + "ssh_url": "git@github.com:materusPL/materusPL.git", + "clone_url": "https://github.com/materusPL/materusPL.git", + "svn_url": "https://github.com/materusPL/materusPL", + "homepage": "https://materus.pl", + "size": 340, + "stargazers_count": 0, + "watchers_count": 0, + "language": null, + "has_issues": true, + "has_projects": true, + "has_downloads": true, + "has_wiki": true, + "has_pages": false, + "has_discussions": false, + "forks_count": 0, + "mirror_url": null, + "archived": false, + "disabled": false, + "open_issues_count": 0, + "license": null, + "allow_forking": true, + "is_template": false, + "web_commit_signoff_required": false, + "topics": [ + "about-me" + ], + "visibility": "public", + "forks": 0, + "open_issues": 0, + "watchers": 0, + "default_branch": "master" + }, + { + "id": 637182688, + "node_id": "R_kgDOJfqi4A", + "name": "Nixerus", + "full_name": "materusPL/Nixerus", + "private": false, + "owner": { + "login": "materusPL", + "id": 28183516, + "node_id": "MDQ6VXNlcjI4MTgzNTE2", + "avatar_url": "https://avatars.githubusercontent.com/u/28183516?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/materusPL", + "html_url": "https://github.com/materusPL", + "followers_url": "https://api.github.com/users/materusPL/followers", + "following_url": "https://api.github.com/users/materusPL/following{/other_user}", + "gists_url": "https://api.github.com/users/materusPL/gists{/gist_id}", + "starred_url": "https://api.github.com/users/materusPL/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/materusPL/subscriptions", + "organizations_url": "https://api.github.com/users/materusPL/orgs", + "repos_url": "https://api.github.com/users/materusPL/repos", + "events_url": "https://api.github.com/users/materusPL/events{/privacy}", + "received_events_url": "https://api.github.com/users/materusPL/received_events", + "type": "User", + "site_admin": false + }, + "html_url": "https://github.com/materusPL/Nixerus", + "description": "Random nix packages and modules", + "fork": false, + "url": "https://api.github.com/repos/materusPL/Nixerus", + "forks_url": "https://api.github.com/repos/materusPL/Nixerus/forks", + "keys_url": "https://api.github.com/repos/materusPL/Nixerus/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/materusPL/Nixerus/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/materusPL/Nixerus/teams", + "hooks_url": "https://api.github.com/repos/materusPL/Nixerus/hooks", + "issue_events_url": "https://api.github.com/repos/materusPL/Nixerus/issues/events{/number}", + "events_url": "https://api.github.com/repos/materusPL/Nixerus/events", + "assignees_url": "https://api.github.com/repos/materusPL/Nixerus/assignees{/user}", + "branches_url": "https://api.github.com/repos/materusPL/Nixerus/branches{/branch}", + "tags_url": "https://api.github.com/repos/materusPL/Nixerus/tags", + "blobs_url": "https://api.github.com/repos/materusPL/Nixerus/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/materusPL/Nixerus/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/materusPL/Nixerus/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/materusPL/Nixerus/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/materusPL/Nixerus/statuses/{sha}", + "languages_url": "https://api.github.com/repos/materusPL/Nixerus/languages", + "stargazers_url": "https://api.github.com/repos/materusPL/Nixerus/stargazers", + "contributors_url": "https://api.github.com/repos/materusPL/Nixerus/contributors", + "subscribers_url": "https://api.github.com/repos/materusPL/Nixerus/subscribers", + "subscription_url": "https://api.github.com/repos/materusPL/Nixerus/subscription", + "commits_url": "https://api.github.com/repos/materusPL/Nixerus/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/materusPL/Nixerus/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/materusPL/Nixerus/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/materusPL/Nixerus/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/materusPL/Nixerus/contents/{+path}", + "compare_url": "https://api.github.com/repos/materusPL/Nixerus/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/materusPL/Nixerus/merges", + "archive_url": "https://api.github.com/repos/materusPL/Nixerus/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/materusPL/Nixerus/downloads", + "issues_url": "https://api.github.com/repos/materusPL/Nixerus/issues{/number}", + "pulls_url": "https://api.github.com/repos/materusPL/Nixerus/pulls{/number}", + "milestones_url": "https://api.github.com/repos/materusPL/Nixerus/milestones{/number}", + "notifications_url": "https://api.github.com/repos/materusPL/Nixerus/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/materusPL/Nixerus/labels{/name}", + "releases_url": "https://api.github.com/repos/materusPL/Nixerus/releases{/id}", + "deployments_url": "https://api.github.com/repos/materusPL/Nixerus/deployments", + "created_at": "2023-05-06T19:03:28Z", + "updated_at": "2023-10-27T13:21:48Z", + "pushed_at": "2024-01-27T09:10:41Z", + "git_url": "git://github.com/materusPL/Nixerus.git", + "ssh_url": "git@github.com:materusPL/Nixerus.git", + "clone_url": "https://github.com/materusPL/Nixerus.git", + "svn_url": "https://github.com/materusPL/Nixerus", + "homepage": "", + "size": 393, + "stargazers_count": 1, + "watchers_count": 1, + "language": "Nix", + "has_issues": true, + "has_projects": true, + "has_downloads": true, + "has_wiki": true, + "has_pages": false, + "has_discussions": false, + "forks_count": 0, + "mirror_url": null, + "archived": false, + "disabled": false, + "open_issues_count": 0, + "license": { + "key": "mit", + "name": "MIT License", + "spdx_id": "MIT", + "url": "https://api.github.com/licenses/mit", + "node_id": "MDc6TGljZW5zZTEz" + }, + "allow_forking": true, + "is_template": false, + "web_commit_signoff_required": false, + "topics": [ + "nix", + "nix-user-repository", + "nixos" + ], + "visibility": "public", + "forks": 0, + "open_issues": 0, + "watchers": 1, + "default_branch": "master" + }, + { + "id": 702113472, + "node_id": "R_kgDOKdlmwA", + "name": "nixos-config", + "full_name": "materusPL/nixos-config", + "private": false, + "owner": { + "login": "materusPL", + "id": 28183516, + "node_id": "MDQ6VXNlcjI4MTgzNTE2", + "avatar_url": "https://avatars.githubusercontent.com/u/28183516?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/materusPL", + "html_url": "https://github.com/materusPL", + "followers_url": "https://api.github.com/users/materusPL/followers", + "following_url": "https://api.github.com/users/materusPL/following{/other_user}", + "gists_url": "https://api.github.com/users/materusPL/gists{/gist_id}", + "starred_url": "https://api.github.com/users/materusPL/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/materusPL/subscriptions", + "organizations_url": "https://api.github.com/users/materusPL/orgs", + "repos_url": "https://api.github.com/users/materusPL/repos", + "events_url": "https://api.github.com/users/materusPL/events{/privacy}", + "received_events_url": "https://api.github.com/users/materusPL/received_events", + "type": "User", + "site_admin": false + }, + "html_url": "https://github.com/materusPL/nixos-config", + "description": "My configs for NixOS", + "fork": false, + "url": "https://api.github.com/repos/materusPL/nixos-config", + "forks_url": "https://api.github.com/repos/materusPL/nixos-config/forks", + "keys_url": "https://api.github.com/repos/materusPL/nixos-config/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/materusPL/nixos-config/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/materusPL/nixos-config/teams", + "hooks_url": "https://api.github.com/repos/materusPL/nixos-config/hooks", + "issue_events_url": "https://api.github.com/repos/materusPL/nixos-config/issues/events{/number}", + "events_url": "https://api.github.com/repos/materusPL/nixos-config/events", + "assignees_url": "https://api.github.com/repos/materusPL/nixos-config/assignees{/user}", + "branches_url": "https://api.github.com/repos/materusPL/nixos-config/branches{/branch}", + "tags_url": "https://api.github.com/repos/materusPL/nixos-config/tags", + "blobs_url": "https://api.github.com/repos/materusPL/nixos-config/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/materusPL/nixos-config/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/materusPL/nixos-config/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/materusPL/nixos-config/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/materusPL/nixos-config/statuses/{sha}", + "languages_url": "https://api.github.com/repos/materusPL/nixos-config/languages", + "stargazers_url": "https://api.github.com/repos/materusPL/nixos-config/stargazers", + "contributors_url": "https://api.github.com/repos/materusPL/nixos-config/contributors", + "subscribers_url": "https://api.github.com/repos/materusPL/nixos-config/subscribers", + "subscription_url": "https://api.github.com/repos/materusPL/nixos-config/subscription", + "commits_url": "https://api.github.com/repos/materusPL/nixos-config/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/materusPL/nixos-config/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/materusPL/nixos-config/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/materusPL/nixos-config/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/materusPL/nixos-config/contents/{+path}", + "compare_url": "https://api.github.com/repos/materusPL/nixos-config/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/materusPL/nixos-config/merges", + "archive_url": "https://api.github.com/repos/materusPL/nixos-config/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/materusPL/nixos-config/downloads", + "issues_url": "https://api.github.com/repos/materusPL/nixos-config/issues{/number}", + "pulls_url": "https://api.github.com/repos/materusPL/nixos-config/pulls{/number}", + "milestones_url": "https://api.github.com/repos/materusPL/nixos-config/milestones{/number}", + "notifications_url": "https://api.github.com/repos/materusPL/nixos-config/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/materusPL/nixos-config/labels{/name}", + "releases_url": "https://api.github.com/repos/materusPL/nixos-config/releases{/id}", + "deployments_url": "https://api.github.com/repos/materusPL/nixos-config/deployments", + "created_at": "2023-10-08T14:34:29Z", + "updated_at": "2023-10-27T12:54:35Z", + "pushed_at": "2024-02-10T11:30:20Z", + "git_url": "git://github.com/materusPL/nixos-config.git", + "ssh_url": "git@github.com:materusPL/nixos-config.git", + "clone_url": "https://github.com/materusPL/nixos-config.git", + "svn_url": "https://github.com/materusPL/nixos-config", + "homepage": "", + "size": 775, + "stargazers_count": 0, + "watchers_count": 0, + "language": "Shell", + "has_issues": true, + "has_projects": true, + "has_downloads": true, + "has_wiki": true, + "has_pages": false, + "has_discussions": false, + "forks_count": 0, + "mirror_url": null, + "archived": false, + "disabled": false, + "open_issues_count": 0, + "license": null, + "allow_forking": true, + "is_template": false, + "web_commit_signoff_required": false, + "topics": [ + "nix", + "nixos", + "nixos-configuration" + ], + "visibility": "public", + "forks": 0, + "open_issues": 0, + "watchers": 0, + "default_branch": "master" + }, + { + "id": 635314706, + "node_id": "R_kgDOJd4iEg", + "name": "nixpkgs", + "full_name": "materusPL/nixpkgs", + "private": false, + "owner": { + "login": "materusPL", + "id": 28183516, + "node_id": "MDQ6VXNlcjI4MTgzNTE2", + "avatar_url": "https://avatars.githubusercontent.com/u/28183516?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/materusPL", + "html_url": "https://github.com/materusPL", + "followers_url": "https://api.github.com/users/materusPL/followers", + "following_url": "https://api.github.com/users/materusPL/following{/other_user}", + "gists_url": "https://api.github.com/users/materusPL/gists{/gist_id}", + "starred_url": "https://api.github.com/users/materusPL/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/materusPL/subscriptions", + "organizations_url": "https://api.github.com/users/materusPL/orgs", + "repos_url": "https://api.github.com/users/materusPL/repos", + "events_url": "https://api.github.com/users/materusPL/events{/privacy}", + "received_events_url": "https://api.github.com/users/materusPL/received_events", + "type": "User", + "site_admin": false + }, + "html_url": "https://github.com/materusPL/nixpkgs", + "description": "Nix Packages collection", + "fork": true, + "url": "https://api.github.com/repos/materusPL/nixpkgs", + "forks_url": "https://api.github.com/repos/materusPL/nixpkgs/forks", + "keys_url": "https://api.github.com/repos/materusPL/nixpkgs/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/materusPL/nixpkgs/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/materusPL/nixpkgs/teams", + "hooks_url": "https://api.github.com/repos/materusPL/nixpkgs/hooks", + "issue_events_url": "https://api.github.com/repos/materusPL/nixpkgs/issues/events{/number}", + "events_url": "https://api.github.com/repos/materusPL/nixpkgs/events", + "assignees_url": "https://api.github.com/repos/materusPL/nixpkgs/assignees{/user}", + "branches_url": "https://api.github.com/repos/materusPL/nixpkgs/branches{/branch}", + "tags_url": "https://api.github.com/repos/materusPL/nixpkgs/tags", + "blobs_url": "https://api.github.com/repos/materusPL/nixpkgs/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/materusPL/nixpkgs/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/materusPL/nixpkgs/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/materusPL/nixpkgs/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/materusPL/nixpkgs/statuses/{sha}", + "languages_url": "https://api.github.com/repos/materusPL/nixpkgs/languages", + "stargazers_url": "https://api.github.com/repos/materusPL/nixpkgs/stargazers", + "contributors_url": "https://api.github.com/repos/materusPL/nixpkgs/contributors", + "subscribers_url": "https://api.github.com/repos/materusPL/nixpkgs/subscribers", + "subscription_url": "https://api.github.com/repos/materusPL/nixpkgs/subscription", + "commits_url": "https://api.github.com/repos/materusPL/nixpkgs/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/materusPL/nixpkgs/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/materusPL/nixpkgs/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/materusPL/nixpkgs/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/materusPL/nixpkgs/contents/{+path}", + "compare_url": "https://api.github.com/repos/materusPL/nixpkgs/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/materusPL/nixpkgs/merges", + "archive_url": "https://api.github.com/repos/materusPL/nixpkgs/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/materusPL/nixpkgs/downloads", + "issues_url": "https://api.github.com/repos/materusPL/nixpkgs/issues{/number}", + "pulls_url": "https://api.github.com/repos/materusPL/nixpkgs/pulls{/number}", + "milestones_url": "https://api.github.com/repos/materusPL/nixpkgs/milestones{/number}", + "notifications_url": "https://api.github.com/repos/materusPL/nixpkgs/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/materusPL/nixpkgs/labels{/name}", + "releases_url": "https://api.github.com/repos/materusPL/nixpkgs/releases{/id}", + "deployments_url": "https://api.github.com/repos/materusPL/nixpkgs/deployments", + "created_at": "2023-05-02T12:38:22Z", + "updated_at": "2023-05-02T12:45:06Z", + "pushed_at": "2023-11-21T18:01:10Z", + "git_url": "git://github.com/materusPL/nixpkgs.git", + "ssh_url": "git@github.com:materusPL/nixpkgs.git", + "clone_url": "https://github.com/materusPL/nixpkgs.git", + "svn_url": "https://github.com/materusPL/nixpkgs", + "homepage": "", + "size": 3633849, + "stargazers_count": 0, + "watchers_count": 0, + "language": "Nix", + "has_issues": false, + "has_projects": true, + "has_downloads": true, + "has_wiki": false, + "has_pages": false, + "has_discussions": false, + "forks_count": 0, + "mirror_url": null, + "archived": false, + "disabled": false, + "open_issues_count": 0, + "license": { + "key": "mit", + "name": "MIT License", + "spdx_id": "MIT", + "url": "https://api.github.com/licenses/mit", + "node_id": "MDc6TGljZW5zZTEz" + }, + "allow_forking": true, + "is_template": false, + "web_commit_signoff_required": false, + "topics": [], + "visibility": "public", + "forks": 0, + "open_issues": 0, + "watchers": 0, + "default_branch": "master" + }, + { + "id": 519190837, + "node_id": "R_kgDOHvI5NQ", + "name": "SNOL", + "full_name": "materusPL/SNOL", + "private": false, + "owner": { + "login": "materusPL", + "id": 28183516, + "node_id": "MDQ6VXNlcjI4MTgzNTE2", + "avatar_url": "https://avatars.githubusercontent.com/u/28183516?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/materusPL", + "html_url": "https://github.com/materusPL", + "followers_url": "https://api.github.com/users/materusPL/followers", + "following_url": "https://api.github.com/users/materusPL/following{/other_user}", + "gists_url": "https://api.github.com/users/materusPL/gists{/gist_id}", + "starred_url": "https://api.github.com/users/materusPL/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/materusPL/subscriptions", + "organizations_url": "https://api.github.com/users/materusPL/orgs", + "repos_url": "https://api.github.com/users/materusPL/repos", + "events_url": "https://api.github.com/users/materusPL/events{/privacy}", + "received_events_url": "https://api.github.com/users/materusPL/received_events", + "type": "User", + "site_admin": false + }, + "html_url": "https://github.com/materusPL/SNOL", + "description": null, + "fork": false, + "url": "https://api.github.com/repos/materusPL/SNOL", + "forks_url": "https://api.github.com/repos/materusPL/SNOL/forks", + "keys_url": "https://api.github.com/repos/materusPL/SNOL/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/materusPL/SNOL/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/materusPL/SNOL/teams", + "hooks_url": "https://api.github.com/repos/materusPL/SNOL/hooks", + "issue_events_url": "https://api.github.com/repos/materusPL/SNOL/issues/events{/number}", + "events_url": "https://api.github.com/repos/materusPL/SNOL/events", + "assignees_url": "https://api.github.com/repos/materusPL/SNOL/assignees{/user}", + "branches_url": "https://api.github.com/repos/materusPL/SNOL/branches{/branch}", + "tags_url": "https://api.github.com/repos/materusPL/SNOL/tags", + "blobs_url": "https://api.github.com/repos/materusPL/SNOL/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/materusPL/SNOL/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/materusPL/SNOL/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/materusPL/SNOL/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/materusPL/SNOL/statuses/{sha}", + "languages_url": "https://api.github.com/repos/materusPL/SNOL/languages", + "stargazers_url": "https://api.github.com/repos/materusPL/SNOL/stargazers", + "contributors_url": "https://api.github.com/repos/materusPL/SNOL/contributors", + "subscribers_url": "https://api.github.com/repos/materusPL/SNOL/subscribers", + "subscription_url": "https://api.github.com/repos/materusPL/SNOL/subscription", + "commits_url": "https://api.github.com/repos/materusPL/SNOL/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/materusPL/SNOL/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/materusPL/SNOL/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/materusPL/SNOL/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/materusPL/SNOL/contents/{+path}", + "compare_url": "https://api.github.com/repos/materusPL/SNOL/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/materusPL/SNOL/merges", + "archive_url": "https://api.github.com/repos/materusPL/SNOL/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/materusPL/SNOL/downloads", + "issues_url": "https://api.github.com/repos/materusPL/SNOL/issues{/number}", + "pulls_url": "https://api.github.com/repos/materusPL/SNOL/pulls{/number}", + "milestones_url": "https://api.github.com/repos/materusPL/SNOL/milestones{/number}", + "notifications_url": "https://api.github.com/repos/materusPL/SNOL/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/materusPL/SNOL/labels{/name}", + "releases_url": "https://api.github.com/repos/materusPL/SNOL/releases{/id}", + "deployments_url": "https://api.github.com/repos/materusPL/SNOL/deployments", + "created_at": "2022-07-29T11:31:22Z", + "updated_at": "2023-01-27T22:41:37Z", + "pushed_at": "2022-07-29T11:31:39Z", + "git_url": "git://github.com/materusPL/SNOL.git", + "ssh_url": "git@github.com:materusPL/SNOL.git", + "clone_url": "https://github.com/materusPL/SNOL.git", + "svn_url": "https://github.com/materusPL/SNOL", + "homepage": null, + "size": 13, + "stargazers_count": 0, + "watchers_count": 0, + "language": "D", + "has_issues": true, + "has_projects": true, + "has_downloads": true, + "has_wiki": true, + "has_pages": false, + "has_discussions": false, + "forks_count": 0, + "mirror_url": null, + "archived": true, + "disabled": false, + "open_issues_count": 0, + "license": null, + "allow_forking": true, + "is_template": false, + "web_commit_signoff_required": false, + "topics": [], + "visibility": "public", + "forks": 0, + "open_issues": 0, + "watchers": 0, + "default_branch": "master" + } +] \ No newline at end of file diff --git a/src/test/resources/jsonAnswers/forkOnly.json b/src/test/resources/jsonAnswers/forkOnly.json new file mode 100644 index 0000000..156c2bd --- /dev/null +++ b/src/test/resources/jsonAnswers/forkOnly.json @@ -0,0 +1,108 @@ +[ + { + "id": 635314706, + "node_id": "R_kgDOJd4iEg", + "name": "nixpkgs", + "full_name": "materusPL/nixpkgs", + "private": false, + "owner": { + "login": "materusPL", + "id": 28183516, + "node_id": "MDQ6VXNlcjI4MTgzNTE2", + "avatar_url": "https://avatars.githubusercontent.com/u/28183516?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/materusPL", + "html_url": "https://github.com/materusPL", + "followers_url": "https://api.github.com/users/materusPL/followers", + "following_url": "https://api.github.com/users/materusPL/following{/other_user}", + "gists_url": "https://api.github.com/users/materusPL/gists{/gist_id}", + "starred_url": "https://api.github.com/users/materusPL/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/materusPL/subscriptions", + "organizations_url": "https://api.github.com/users/materusPL/orgs", + "repos_url": "https://api.github.com/users/materusPL/repos", + "events_url": "https://api.github.com/users/materusPL/events{/privacy}", + "received_events_url": "https://api.github.com/users/materusPL/received_events", + "type": "User", + "site_admin": false + }, + "html_url": "https://github.com/materusPL/nixpkgs", + "description": "Nix Packages collection", + "fork": true, + "url": "https://api.github.com/repos/materusPL/nixpkgs", + "forks_url": "https://api.github.com/repos/materusPL/nixpkgs/forks", + "keys_url": "https://api.github.com/repos/materusPL/nixpkgs/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/materusPL/nixpkgs/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/materusPL/nixpkgs/teams", + "hooks_url": "https://api.github.com/repos/materusPL/nixpkgs/hooks", + "issue_events_url": "https://api.github.com/repos/materusPL/nixpkgs/issues/events{/number}", + "events_url": "https://api.github.com/repos/materusPL/nixpkgs/events", + "assignees_url": "https://api.github.com/repos/materusPL/nixpkgs/assignees{/user}", + "branches_url": "https://api.github.com/repos/materusPL/nixpkgs/branches{/branch}", + "tags_url": "https://api.github.com/repos/materusPL/nixpkgs/tags", + "blobs_url": "https://api.github.com/repos/materusPL/nixpkgs/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/materusPL/nixpkgs/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/materusPL/nixpkgs/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/materusPL/nixpkgs/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/materusPL/nixpkgs/statuses/{sha}", + "languages_url": "https://api.github.com/repos/materusPL/nixpkgs/languages", + "stargazers_url": "https://api.github.com/repos/materusPL/nixpkgs/stargazers", + "contributors_url": "https://api.github.com/repos/materusPL/nixpkgs/contributors", + "subscribers_url": "https://api.github.com/repos/materusPL/nixpkgs/subscribers", + "subscription_url": "https://api.github.com/repos/materusPL/nixpkgs/subscription", + "commits_url": "https://api.github.com/repos/materusPL/nixpkgs/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/materusPL/nixpkgs/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/materusPL/nixpkgs/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/materusPL/nixpkgs/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/materusPL/nixpkgs/contents/{+path}", + "compare_url": "https://api.github.com/repos/materusPL/nixpkgs/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/materusPL/nixpkgs/merges", + "archive_url": "https://api.github.com/repos/materusPL/nixpkgs/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/materusPL/nixpkgs/downloads", + "issues_url": "https://api.github.com/repos/materusPL/nixpkgs/issues{/number}", + "pulls_url": "https://api.github.com/repos/materusPL/nixpkgs/pulls{/number}", + "milestones_url": "https://api.github.com/repos/materusPL/nixpkgs/milestones{/number}", + "notifications_url": "https://api.github.com/repos/materusPL/nixpkgs/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/materusPL/nixpkgs/labels{/name}", + "releases_url": "https://api.github.com/repos/materusPL/nixpkgs/releases{/id}", + "deployments_url": "https://api.github.com/repos/materusPL/nixpkgs/deployments", + "created_at": "2023-05-02T12:38:22Z", + "updated_at": "2023-05-02T12:45:06Z", + "pushed_at": "2023-11-21T18:01:10Z", + "git_url": "git://github.com/materusPL/nixpkgs.git", + "ssh_url": "git@github.com:materusPL/nixpkgs.git", + "clone_url": "https://github.com/materusPL/nixpkgs.git", + "svn_url": "https://github.com/materusPL/nixpkgs", + "homepage": "", + "size": 3633849, + "stargazers_count": 0, + "watchers_count": 0, + "language": "Nix", + "has_issues": false, + "has_projects": true, + "has_downloads": true, + "has_wiki": false, + "has_pages": false, + "has_discussions": false, + "forks_count": 0, + "mirror_url": null, + "archived": false, + "disabled": false, + "open_issues_count": 0, + "license": { + "key": "mit", + "name": "MIT License", + "spdx_id": "MIT", + "url": "https://api.github.com/licenses/mit", + "node_id": "MDc6TGljZW5zZTEz" + }, + "allow_forking": true, + "is_template": false, + "web_commit_signoff_required": false, + "topics": [], + "visibility": "public", + "forks": 0, + "open_issues": 0, + "watchers": 0, + "default_branch": "master" + } +] \ No newline at end of file diff --git a/src/test/resources/jsonAnswers/notFound.json b/src/test/resources/jsonAnswers/notFound.json new file mode 100644 index 0000000..4391647 --- /dev/null +++ b/src/test/resources/jsonAnswers/notFound.json @@ -0,0 +1,4 @@ +{ + "message": "Not Found", + "documentation_url": "https://docs.github.com/rest/repos/repos#list-repositories-for-a-user" +} \ No newline at end of file diff --git a/src/test/resources/jsonAnswers/rateLimit.json b/src/test/resources/jsonAnswers/rateLimit.json new file mode 100644 index 0000000..ffb3dd1 --- /dev/null +++ b/src/test/resources/jsonAnswers/rateLimit.json @@ -0,0 +1 @@ +{"message":"API rate limit exceeded for 0.0.0.0. (But here's the good news: Authenticated requests get a higher rate limit. Check out the documentation for more details.)","documentation_url":"https://docs.github.com/rest/overview/resources-in-the-rest-api#rate-limiting"} \ No newline at end of file