├── .gitignore ├── DISCLAIMER.txt ├── Dockerfile ├── LICENSE.txt ├── README.md ├── configurations ├── data │ ├── base │ │ ├── docker-compose.yml │ │ └── kernel-config.json │ └── xodus │ │ ├── docker-compose.yml │ │ └── kernel-config.json └── dto │ ├── base │ ├── docker-compose.yml │ └── kernel-config.json │ ├── mongo │ ├── docker-compose.yml │ └── kernel-config.json │ └── xodus │ ├── docker-compose.yml │ └── kernel-config.json ├── pom.xml └── src └── main ├── java └── com │ └── merakianalytics │ └── kernel │ ├── Kernel.java │ ├── KernelConfiguration.java │ ├── KernelContext.java │ ├── exceptions │ ├── OriannaExceptionMapper.java │ └── QueryValidationExceptionMapper.java │ ├── filters │ ├── CORSFilter.java │ └── NullResponseFilter.java │ ├── producers │ ├── KernelConfigurationProducer.java │ └── KernelContextProducer.java │ ├── providers │ ├── JSONProvider.java │ └── MessagePackProvider.java │ └── riotapi │ ├── RiotAPIService.java │ ├── data │ ├── ChampionAPI.java │ ├── ChampionMasteryAPI.java │ ├── LeagueAPI.java │ ├── MatchAPI.java │ ├── SpectatorAPI.java │ ├── StatusAPI.java │ ├── SummonerAPI.java │ └── ThirdPartyCodeAPI.java │ └── dto │ ├── ChampionAPI.java │ ├── ChampionMasteryAPI.java │ ├── LeagueAPI.java │ ├── MatchAPI.java │ ├── SpectatorAPI.java │ ├── StatusAPI.java │ ├── SummonerAPI.java │ └── ThirdPartyCodeAPI.java └── resources ├── META-INF ├── beans.xml └── services │ └── javax.ws.rs.ext.Providers └── com └── merakianalytics └── kernel └── default-kernel-config.json /.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled class file 2 | *.class 3 | 4 | # Log file 5 | *.log 6 | 7 | # BlueJ files 8 | *.ctxt 9 | 10 | # Mobile Tools for Java (J2ME) 11 | .mtj.tmp/ 12 | 13 | # Package Files # 14 | *.jar 15 | *.war 16 | *.ear 17 | *.zip 18 | *.tar.gz 19 | *.rar 20 | 21 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml 22 | hs_err_pid* 23 | 24 | # Eclipse & build artifacts 25 | *.classpath 26 | *.project 27 | *.settings 28 | *target/ 29 | -------------------------------------------------------------------------------- /DISCLAIMER.txt: -------------------------------------------------------------------------------- 1 | Kernel isn't endorsed by Riot Games and doesn't reflect the views or opinions of Riot Games or anyone officially involved in producing or managing League of Legends. League of Legends and Riot Games are trademarks or registered trademarks of Riot Games, Inc. League of Legends © Riot Games, Inc. 2 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM gcr.io/distroless/java:11 2 | 3 | 4 | # -- SET JAVA OPTS FOR THORNTAIL 5 | ENV JAVA_TOOL_OPTIONS -Djava.net.preferIPv4Stack=true -Djava.net.preferIPv6Stack=true -Djava.awt.headless=true 6 | 7 | 8 | # -- SETUP APPLICATION CONFIGURATION 9 | ENV KERNEL_HOME /opt/meraki 10 | ENV KERNEL_CONFIGURATION_PATH $KERNEL_HOME/kernel-config.json 11 | 12 | 13 | # -- DEPLOY THE APPLICATION 14 | ADD target/kernel-config.json $KERNEL_CONFIGURATION_PATH 15 | ADD target/kernel-thorntail.jar $KERNEL_HOME/kernel.jar 16 | 17 | 18 | # -- START THE APPLICATION 19 | CMD ["/opt/meraki/kernel.jar"] 20 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 Meraki Analytics, LLC 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Kernel - A plug & play Riot API proxy server 2 | Kernel is built on top of [orianna](https://github.com/meraki-analytics/orianna), a Riot API wrapper and framework for working with API data. The API Kernel provides mirrors the [Riot API](https://developer.riotgames.com/api-methods/), and allows users to proxy their API calls through Kernel to avoid "leaking" their Riot API key to end users. 3 | 4 | Kernel is built using the [Thorntail](https://thorntail.io/) application server with [JAX-RS](https://github.com/jax-rs) and [RestEasy](https://github.com/resteasy/Resteasy). 5 | 6 | Kernel is licensed under the [MIT License](https://github.com/meraki-analytics/kernel/blob/master/LICENSE.txt). 7 | 8 | ## Features 9 | Kernel also includes the following built-in features: 10 | - Automatic rate limit handling for the Riot API 11 | - Configurable strategies for handling Riot API errors (retry, expontential backoff, return null, etc) 12 | - A configurable pipeline for automatic caching of API results 13 | - Plug & Play support for several common databases in the works [here](https://github.com/meraki-analytics/orianna-datastores) 14 | - Support for [MessagePack](https://msgpack.org/index.html) serialization in addition to JSON 15 | 16 | ## API Differences from Riot API 17 | Kernel is intended to mirror the Riot API exactly. The Riot API, however, is distributed accross regional platform domains to split computation load and localize content distribution (e.g. na1.api.riotgames.com or euw1.api.riotgames.com). Kernel supports serving _all_ platforms from a single server instance using the `platform` query parameter, which is available for every API endpoint in Kernel. All Riot API platforms are supported by this feature. A default platform can be configured to direct requests without a `platform` query parameter to that platform. 18 | 19 | Example: the Riot API call `https://na1.api.riotgames.com/lol/summoner/v4/summoners/by-name/FatalElement` becomes `http://localhost/lol/summoner/v4/summoners/by-name/FatalElement?platform=NA1` for Kernel. 20 | 21 | ## How to get it 22 | Kernel can be obtained and installed either through [Docker](https://www.docker.com/) or by building the application locally using [Maven](https://maven.apache.org/). 23 | 24 | ### Docker 25 | Kernel docker images are available on [Docker Hub](https://hub.docker.com/r/merakianalytics/kernel/). If you're unfamiliar with docker, here's how to run them on your local machine: 26 | 27 | - Install & Configure Docker 28 | - [Windows 10 Professional](https://docs.docker.com/docker-for-windows/install/) (or other windows version with Hyper-V support) 29 | - [Other Windows](https://docs.docker.com/toolbox/toolbox_install_windows/) 30 | - [Ubuntu](https://docs.docker.com/engine/installation/linux/docker-ce/ubuntu/) 31 | - [Debian](https://docs.docker.com/engine/installation/linux/docker-ce/debian/) 32 | - [CentOS](https://docs.docker.com/engine/installation/linux/docker-ce/centos/) 33 | - [Fedora](https://docs.docker.com/engine/installation/linux/docker-ce/fedora/) 34 | - [Mac](https://docs.docker.com/docker-for-mac/install/) 35 | - Install [Docker Compose](https://docs.docker.com/compose/install/) 36 | - Choose an off-the-shelf configuration of Kernel to use and download the `docker-compose.yml` file associated with it 37 | - [Base Configuration (No Caching Included)](https://github.com/meraki-analytics/kernel/tree/master/configurations/dto/base) 38 | - [JetBrains Xodus Configuration (Filesystem-based Embedded DB)](https://github.com/meraki-analytics/kernel/tree/master/configurations/dto/xodus) 39 | - [MongoDB Configuration](https://github.com/meraki-analytics/kernel/tree/master/configurations/dto/mongo) 40 | - [More configurations forthcoming as support for additional popular databases is completed for orianna](https://github.com/meraki-analytics/orianna-datastores) 41 | - Set your `RIOT_API_KEY` environment variable to your [Riot API Key](https://developer.riotgames.com/) 42 | - Navigate to the directory where you downloaded `docker-compose.yml` on your local machine and open a terminal or command prompt 43 | - Run `docker-compose up -d --force-recreate` to lanch Kernel in the background 44 | - Run `docker-compose down` to shut down Kernel 45 | - The default `docker-compose.yml` files will start Kernel on port 80, as well as launching a [Swagger UI](https://hub.docker.com/r/swaggerapi/swagger-ui/) on port 12357 to explore the API. 46 | 47 | If you want to change some configuration settings in Kernel, you can edit the `kernel-config.json` file from the configuration you chose, then add a volume entry to the `docker-compose.yml` file to load your config into the container. 48 | 49 | Example: [original compose file](https://github.com/meraki-analytics/kernel/blob/master/configurations/dto/base/docker-compose.yml) | [compose file with custom kernel-config.json](https://gist.github.com/robrua/9a89b908e2a6c3848cc4ab3ec5a0638e) 50 | 51 | ### Building Locally with Maven 52 | - Install [JDK 8 or higher](https://openjdk.java.net/install/) 53 | - Install [Maven](https://maven.apache.org/install.html) 54 | - Clone the Kernel source code locally & navigate to the folder 55 | - Run `mvn clean package` to build the application. Some maven profiles are available to bundle datastore dependencies in with the application. Use `mvn clean package -P some,profile,names` to activate them 56 | - [mongo](https://github.com/meraki-analytics/kernel/blob/master/pom.xml#L295-L338) 57 | - [xodus](https://github.com/meraki-analytics/kernel/blob/master/pom.xml#L339-L382) 58 | - [More configurations forthcoming as support for additional popular databases is completed for orianna](https://github.com/meraki-analytics/orianna-datastores) 59 | - From your Kernel source folder, copy `target/kernel-thorntail.jar` wherever you'd like to serve Kernel from 60 | - From your Kernel source folder, copy `target/kernel-config.json` wherever you'd like to serve Kernel from 61 | - Set your `KERNEL_CONFIGURATION_PATH` environment variable to point at your `kernel-config.json` 62 | - Set your `RIOT_API_KEY` environment variable to your [Riot API Key](https://developer.riotgames.com/) 63 | - Run `java -D"swarm.http.port=8080" -D"java.net.preferIPv4Stack=true" -D"java.net.preferIPv6Stack=true" -D"java.awt.headless=true" -jar kernel-thorntail.jar` to launch Kernel. 64 | 65 | ## Questions & Contributions 66 | Feel free to send pull requests or to contact us via GitHub or [Discord](https://discord.gg/JRDk2JU). 67 | 68 | ## Disclaimer 69 | Kernel isn't endorsed by Riot Games and doesn't reflect the views or opinions of Riot Games or anyone officially involved in producing or managing League of Legends. League of Legends and Riot Games are trademarks or registered trademarks of Riot Games, Inc. League of Legends © Riot Games, Inc. 70 | -------------------------------------------------------------------------------- /configurations/data/base/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: "3" 2 | 3 | services: 4 | kernel: 5 | container_name: kernel 6 | image: merakianalytics/kernel:base 7 | ports: 8 | - 80:8080 9 | environment: 10 | - RIOT_API_KEY=${RIOT_API_KEY} 11 | restart: always 12 | networks: 13 | - kernel 14 | swagger: 15 | container_name: kernel_swagger 16 | image: swaggerapi/swagger-ui 17 | ports: 18 | - 12357:8080 19 | environment: 20 | - API_URL=http://localhost/lol/swagger.json 21 | restart: always 22 | networks: 23 | - kernel 24 | depends_on: 25 | - kernel 26 | 27 | networks: 28 | kernel: 29 | driver: bridge 30 | -------------------------------------------------------------------------------- /configurations/data/base/kernel-config.json: -------------------------------------------------------------------------------- 1 | { 2 | "produceCoreData": true, 3 | "defaultPlatform": "NORTH_AMERICA", 4 | "pipeline": { 5 | "elements": [ 6 | { 7 | "className": "com.merakianalytics.orianna.datapipeline.riotapi.RiotAPI", 8 | "config": { 9 | "http404Strategy": { 10 | "type": "THROW_EXCEPTION" 11 | }, 12 | "http429Strategy": { 13 | "backupStrategy": { 14 | "backoff": 1, 15 | "backoffUnit": "SECONDS", 16 | "backupStrategy": { 17 | "type": "THROW_EXCEPTION" 18 | }, 19 | "maxAttempts": 4, 20 | "backoffFactor": 2, 21 | "type": "EXPONENTIAL_BACKOFF" 22 | }, 23 | "type": "RETRY_FROM_HEADERS" 24 | }, 25 | "http500Strategy": { 26 | "backoff": 1, 27 | "backoffUnit": "SECONDS", 28 | "backupStrategy": { 29 | "type": "THROW_EXCEPTION" 30 | }, 31 | "maxAttempts": 4, 32 | "backoffFactor": 2, 33 | "type": "EXPONENTIAL_BACKOFF" 34 | }, 35 | "http503Strategy": { 36 | "backoff": 1, 37 | "backoffUnit": "SECONDS", 38 | "backupStrategy": { 39 | "type": "THROW_EXCEPTION" 40 | }, 41 | "maxAttempts": 4, 42 | "backoffFactor": 2, 43 | "type": "EXPONENTIAL_BACKOFF" 44 | }, 45 | "http504Strategy": { 46 | "backoff": 1, 47 | "backoffUnit": "SECONDS", 48 | "backupStrategy": { 49 | "type": "THROW_EXCEPTION" 50 | }, 51 | "maxAttempts": 4, 52 | "backoffFactor": 2, 53 | "type": "EXPONENTIAL_BACKOFF" 54 | }, 55 | "httpTimeoutStrategy": { 56 | "backoff": 1, 57 | "backoffUnit": "SECONDS", 58 | "backupStrategy": { 59 | "type": "THROW_EXCEPTION" 60 | }, 61 | "maxAttempts": 4, 62 | "backoffFactor": 2, 63 | "type": "EXPONENTIAL_BACKOFF" 64 | }, 65 | "limitingShare": 1.0, 66 | "limitingType": "BURST", 67 | "rateLimiterTimeoutStrategy": { 68 | "type": "THROW_EXCEPTION" 69 | }, 70 | "requests": { 71 | "connectTimeout": 3, 72 | "connectTimeoutUnit": "SECONDS", 73 | "rateLimiterTimeout": 30, 74 | "rateLimiterTimeoutUnit": "SECONDS", 75 | "readTimeout": 3, 76 | "readTimeoutUnit": "SECONDS", 77 | "https": true 78 | }, 79 | "services": [ 80 | "com.merakianalytics.orianna.datapipeline.riotapi.ChampionAPI", 81 | "com.merakianalytics.orianna.datapipeline.riotapi.ChampionMasteryAPI", 82 | "com.merakianalytics.orianna.datapipeline.riotapi.LeagueAPI", 83 | "com.merakianalytics.orianna.datapipeline.riotapi.MatchAPI", 84 | "com.merakianalytics.orianna.datapipeline.riotapi.SpectatorAPI", 85 | "com.merakianalytics.orianna.datapipeline.riotapi.StatusAPI", 86 | "com.merakianalytics.orianna.datapipeline.riotapi.SummonerAPI", 87 | "com.merakianalytics.orianna.datapipeline.riotapi.ThirdPartyCodeAPI" 88 | ] 89 | }, 90 | "configClassName": "com.merakianalytics.orianna.datapipeline.riotapi.RiotAPI$Configuration" 91 | } 92 | ], 93 | "transformers": [ 94 | { 95 | "className": "com.merakianalytics.orianna.datapipeline.transformers.dtodata.ChampionMasteryTransformer" 96 | }, 97 | { 98 | "className": "com.merakianalytics.orianna.datapipeline.transformers.dtodata.ChampionTransformer" 99 | }, 100 | { 101 | "className": "com.merakianalytics.orianna.datapipeline.transformers.dtodata.LeagueTransformer" 102 | }, 103 | { 104 | "className": "com.merakianalytics.orianna.datapipeline.transformers.dtodata.MatchTransformer" 105 | }, 106 | { 107 | "className": "com.merakianalytics.orianna.datapipeline.transformers.dtodata.SpectatorTransformer" 108 | }, 109 | { 110 | "className": "com.merakianalytics.orianna.datapipeline.transformers.dtodata.StaticDataTransformer" 111 | }, 112 | { 113 | "className": "com.merakianalytics.orianna.datapipeline.transformers.dtodata.StatusTransformer" 114 | }, 115 | { 116 | "className": "com.merakianalytics.orianna.datapipeline.transformers.dtodata.SummonerTransformer" 117 | }, 118 | { 119 | "className": "com.merakianalytics.orianna.datapipeline.transformers.dtodata.ThirdPartyCodeTransformer" 120 | } 121 | ] 122 | }, 123 | "cors": { 124 | "allowCredentials": "true", 125 | "allowHeaders": "*", 126 | "allowMethods": "*", 127 | "allowOrigin": "*", 128 | "maxAge": "3600" 129 | }, 130 | "serializationInclusions": "NON_DEFAULT" 131 | } 132 | -------------------------------------------------------------------------------- /configurations/data/xodus/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: "3" 2 | 3 | services: 4 | kernel: 5 | container_name: kernel 6 | image: merakianalytics/kernel:xodus 7 | ports: 8 | - 80:8080 9 | environment: 10 | - RIOT_API_KEY=${RIOT_API_KEY} 11 | restart: always 12 | networks: 13 | - kernel 14 | swagger: 15 | container_name: kernel_swagger 16 | image: swaggerapi/swagger-ui 17 | ports: 18 | - 12357:8080 19 | environment: 20 | - API_URL=http://localhost/lol/swagger.json 21 | restart: always 22 | networks: 23 | - kernel 24 | depends_on: 25 | - kernel 26 | 27 | networks: 28 | kernel: 29 | driver: bridge 30 | -------------------------------------------------------------------------------- /configurations/data/xodus/kernel-config.json: -------------------------------------------------------------------------------- 1 | { 2 | "produceCoreData": true, 3 | "defaultPlatform": "NORTH_AMERICA", 4 | "pipeline": { 5 | "elements": [ 6 | { 7 | "className": "com.merakianalytics.orianna.datastores.xodus.data.XodusDataStore", 8 | "config": { 9 | "dataDirectory": "/var/lib/orianna/data", 10 | "expirationPeriods": { 11 | "com.merakianalytics.orianna.types.data.champion.ChampionRotation": { 12 | "period": 6, 13 | "unit": "HOURS" 14 | }, 15 | "com.merakianalytics.orianna.types.data.championmastery.ChampionMastery": { 16 | "period": 2, 17 | "unit": "HOURS" 18 | }, 19 | "com.merakianalytics.orianna.types.data.championmastery.ChampionMasteries": { 20 | "period": 2, 21 | "unit": "HOURS" 22 | }, 23 | "com.merakianalytics.orianna.types.data.championmastery.ChampionMasteryScore": { 24 | "period": 2, 25 | "unit": "HOURS" 26 | }, 27 | "com.merakianalytics.orianna.types.data.league.League": { 28 | "period": 30, 29 | "unit": "MINUTES" 30 | }, 31 | "com.merakianalytics.orianna.types.data.league.LeaguePositions": { 32 | "period": 2, 33 | "unit": "HOURS" 34 | }, 35 | "com.merakianalytics.orianna.types.data.match.Match": { 36 | "period": -1, 37 | "unit": "DAYS" 38 | }, 39 | "com.merakianalytics.orianna.types.data.match.Timeline": { 40 | "period": -1, 41 | "unit": "DAYS" 42 | }, 43 | "com.merakianalytics.orianna.types.data.match.TournamentMatches": { 44 | "period": -1, 45 | "unit": "DAYS" 46 | }, 47 | "com.merakianalytics.orianna.types.data.spectator.CurrentMatch": { 48 | "period": 5, 49 | "unit": "MINUTES" 50 | }, 51 | "com.merakianalytics.orianna.types.data.spectator.FeaturedMatches": { 52 | "period": 5, 53 | "unit": "MINUTES" 54 | }, 55 | "com.merakianalytics.orianna.types.data.staticdata.Champion": { 56 | "period": -1, 57 | "unit": "DAYS" 58 | }, 59 | "com.merakianalytics.orianna.types.data.staticdata.Champions": { 60 | "period": -1, 61 | "unit": "DAYS" 62 | }, 63 | "com.merakianalytics.orianna.types.data.staticdata.Item": { 64 | "period": -1, 65 | "unit": "DAYS" 66 | }, 67 | "com.merakianalytics.orianna.types.data.staticdata.Items": { 68 | "period": -1, 69 | "unit": "DAYS" 70 | }, 71 | "com.merakianalytics.orianna.types.data.staticdata.Languages": { 72 | "period": 6, 73 | "unit": "HOURS" 74 | }, 75 | "com.merakianalytics.orianna.types.data.staticdata.LanguageStrings": { 76 | "period": -1, 77 | "unit": "DAYS" 78 | }, 79 | "com.merakianalytics.orianna.types.data.staticdata.Maps": { 80 | "period": -1, 81 | "unit": "DAYS" 82 | }, 83 | "com.merakianalytics.orianna.types.data.staticdata.Map": { 84 | "period": -1, 85 | "unit": "DAYS" 86 | }, 87 | "com.merakianalytics.orianna.types.data.staticdata.Mastery": { 88 | "period": -1, 89 | "unit": "DAYS" 90 | }, 91 | "com.merakianalytics.orianna.types.data.staticdata.Masteries": { 92 | "period": -1, 93 | "unit": "DAYS" 94 | }, 95 | "com.merakianalytics.orianna.types.data.staticdata.Patch": { 96 | "period": -1, 97 | "unit": "DAYS" 98 | }, 99 | "com.merakianalytics.orianna.types.data.staticdata.Patches": { 100 | "period": 6, 101 | "unit": "HOURS" 102 | }, 103 | "com.merakianalytics.orianna.types.data.staticdata.ProfileIcons": { 104 | "period": -1, 105 | "unit": "DAYS" 106 | }, 107 | "com.merakianalytics.orianna.types.data.staticdata.ProfileIcon": { 108 | "period": -1, 109 | "unit": "DAYS" 110 | }, 111 | "com.merakianalytics.orianna.types.data.staticdata.Realm": { 112 | "period": 6, 113 | "unit": "HOURS" 114 | }, 115 | "com.merakianalytics.orianna.types.data.staticdata.Rune": { 116 | "period": -1, 117 | "unit": "DAYS" 118 | }, 119 | "com.merakianalytics.orianna.types.data.staticdata.Runes": { 120 | "period": -1, 121 | "unit": "DAYS" 122 | }, 123 | "com.merakianalytics.orianna.types.data.staticdata.SummonerSpell": { 124 | "period": -1, 125 | "unit": "DAYS" 126 | }, 127 | "com.merakianalytics.orianna.types.data.staticdata.SummonerSpells": { 128 | "period": -1, 129 | "unit": "DAYS" 130 | }, 131 | "com.merakianalytics.orianna.types.data.staticdata.Versions": { 132 | "period": 6, 133 | "unit": "HOURS" 134 | }, 135 | "com.merakianalytics.orianna.types.data.status.ShardStatus": { 136 | "period": 15, 137 | "unit": "MINUTES" 138 | }, 139 | "com.merakianalytics.orianna.types.data.summoner.Summoner": { 140 | "period": 1, 141 | "unit": "DAYS" 142 | }, 143 | "com.merakianalytics.orianna.types.data.thirdpartycode.VerificationString": { 144 | "period": 5, 145 | "unit": "MINUTES" 146 | } 147 | } 148 | }, 149 | "configClassName": "com.merakianalytics.orianna.datastores.xodus.data.XodusDataStore$Configuration" 150 | }, 151 | { 152 | "className": "com.merakianalytics.orianna.datapipeline.riotapi.RiotAPI", 153 | "config": { 154 | "http404Strategy": { 155 | "type": "THROW_EXCEPTION" 156 | }, 157 | "http429Strategy": { 158 | "backupStrategy": { 159 | "backoff": 1, 160 | "backoffUnit": "SECONDS", 161 | "backupStrategy": { 162 | "type": "THROW_EXCEPTION" 163 | }, 164 | "maxAttempts": 4, 165 | "backoffFactor": 2, 166 | "type": "EXPONENTIAL_BACKOFF" 167 | }, 168 | "type": "RETRY_FROM_HEADERS" 169 | }, 170 | "http500Strategy": { 171 | "backoff": 1, 172 | "backoffUnit": "SECONDS", 173 | "backupStrategy": { 174 | "type": "THROW_EXCEPTION" 175 | }, 176 | "maxAttempts": 4, 177 | "backoffFactor": 2, 178 | "type": "EXPONENTIAL_BACKOFF" 179 | }, 180 | "http503Strategy": { 181 | "backoff": 1, 182 | "backoffUnit": "SECONDS", 183 | "backupStrategy": { 184 | "type": "THROW_EXCEPTION" 185 | }, 186 | "maxAttempts": 4, 187 | "backoffFactor": 2, 188 | "type": "EXPONENTIAL_BACKOFF" 189 | }, 190 | "http504Strategy": { 191 | "backoff": 1, 192 | "backoffUnit": "SECONDS", 193 | "backupStrategy": { 194 | "type": "THROW_EXCEPTION" 195 | }, 196 | "maxAttempts": 4, 197 | "backoffFactor": 2, 198 | "type": "EXPONENTIAL_BACKOFF" 199 | }, 200 | "httpTimeoutStrategy": { 201 | "backoff": 1, 202 | "backoffUnit": "SECONDS", 203 | "backupStrategy": { 204 | "type": "THROW_EXCEPTION" 205 | }, 206 | "maxAttempts": 4, 207 | "backoffFactor": 2, 208 | "type": "EXPONENTIAL_BACKOFF" 209 | }, 210 | "limitingShare": 1.0, 211 | "limitingType": "BURST", 212 | "rateLimiterTimeoutStrategy": { 213 | "type": "THROW_EXCEPTION" 214 | }, 215 | "requests": { 216 | "connectTimeout": 3, 217 | "connectTimeoutUnit": "SECONDS", 218 | "rateLimiterTimeout": 30, 219 | "rateLimiterTimeoutUnit": "SECONDS", 220 | "readTimeout": 3, 221 | "readTimeoutUnit": "SECONDS", 222 | "https": true 223 | }, 224 | "services": [ 225 | "com.merakianalytics.orianna.datapipeline.riotapi.ChampionAPI", 226 | "com.merakianalytics.orianna.datapipeline.riotapi.ChampionMasteryAPI", 227 | "com.merakianalytics.orianna.datapipeline.riotapi.LeagueAPI", 228 | "com.merakianalytics.orianna.datapipeline.riotapi.MatchAPI", 229 | "com.merakianalytics.orianna.datapipeline.riotapi.SpectatorAPI", 230 | "com.merakianalytics.orianna.datapipeline.riotapi.StatusAPI", 231 | "com.merakianalytics.orianna.datapipeline.riotapi.SummonerAPI", 232 | "com.merakianalytics.orianna.datapipeline.riotapi.ThirdPartyCodeAPI" 233 | ] 234 | }, 235 | "configClassName": "com.merakianalytics.orianna.datapipeline.riotapi.RiotAPI$Configuration" 236 | } 237 | ], 238 | "transformers": [ 239 | { 240 | "className": "com.merakianalytics.orianna.datapipeline.transformers.dtodata.ChampionMasteryTransformer" 241 | }, 242 | { 243 | "className": "com.merakianalytics.orianna.datapipeline.transformers.dtodata.ChampionTransformer" 244 | }, 245 | { 246 | "className": "com.merakianalytics.orianna.datapipeline.transformers.dtodata.LeagueTransformer" 247 | }, 248 | { 249 | "className": "com.merakianalytics.orianna.datapipeline.transformers.dtodata.MatchTransformer" 250 | }, 251 | { 252 | "className": "com.merakianalytics.orianna.datapipeline.transformers.dtodata.SpectatorTransformer" 253 | }, 254 | { 255 | "className": "com.merakianalytics.orianna.datapipeline.transformers.dtodata.StaticDataTransformer" 256 | }, 257 | { 258 | "className": "com.merakianalytics.orianna.datapipeline.transformers.dtodata.StatusTransformer" 259 | }, 260 | { 261 | "className": "com.merakianalytics.orianna.datapipeline.transformers.dtodata.SummonerTransformer" 262 | }, 263 | { 264 | "className": "com.merakianalytics.orianna.datapipeline.transformers.dtodata.ThirdPartyCodeTransformer" 265 | } 266 | ] 267 | }, 268 | "cors": { 269 | "allowCredentials": "true", 270 | "allowHeaders": "*", 271 | "allowMethods": "*", 272 | "allowOrigin": "*", 273 | "maxAge": "3600" 274 | }, 275 | "serializationInclusions": "NON_DEFAULT" 276 | } 277 | -------------------------------------------------------------------------------- /configurations/dto/base/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: "3" 2 | 3 | services: 4 | kernel: 5 | container_name: kernel 6 | image: merakianalytics/kernel:base 7 | ports: 8 | - 80:8080 9 | environment: 10 | - RIOT_API_KEY=${RIOT_API_KEY} 11 | restart: always 12 | networks: 13 | - kernel 14 | swagger: 15 | container_name: kernel_swagger 16 | image: swaggerapi/swagger-ui 17 | ports: 18 | - 12357:8080 19 | environment: 20 | - API_URL=http://localhost/lol/swagger.json 21 | restart: always 22 | networks: 23 | - kernel 24 | depends_on: 25 | - kernel 26 | 27 | networks: 28 | kernel: 29 | driver: bridge 30 | -------------------------------------------------------------------------------- /configurations/dto/base/kernel-config.json: -------------------------------------------------------------------------------- 1 | { 2 | "defaultPlatform": "NORTH_AMERICA", 3 | "pipeline": { 4 | "elements": [ 5 | { 6 | "className": "com.merakianalytics.orianna.datapipeline.riotapi.RiotAPI", 7 | "config": { 8 | "http404Strategy": { 9 | "type": "THROW_EXCEPTION" 10 | }, 11 | "http429Strategy": { 12 | "backupStrategy": { 13 | "backoff": 1, 14 | "backoffUnit": "SECONDS", 15 | "backupStrategy": { 16 | "type": "THROW_EXCEPTION" 17 | }, 18 | "maxAttempts": 4, 19 | "backoffFactor": 2, 20 | "type": "EXPONENTIAL_BACKOFF" 21 | }, 22 | "type": "RETRY_FROM_HEADERS" 23 | }, 24 | "http500Strategy": { 25 | "backoff": 1, 26 | "backoffUnit": "SECONDS", 27 | "backupStrategy": { 28 | "type": "THROW_EXCEPTION" 29 | }, 30 | "maxAttempts": 4, 31 | "backoffFactor": 2, 32 | "type": "EXPONENTIAL_BACKOFF" 33 | }, 34 | "http503Strategy": { 35 | "backoff": 1, 36 | "backoffUnit": "SECONDS", 37 | "backupStrategy": { 38 | "type": "THROW_EXCEPTION" 39 | }, 40 | "maxAttempts": 4, 41 | "backoffFactor": 2, 42 | "type": "EXPONENTIAL_BACKOFF" 43 | }, 44 | "http504Strategy": { 45 | "backoff": 1, 46 | "backoffUnit": "SECONDS", 47 | "backupStrategy": { 48 | "type": "THROW_EXCEPTION" 49 | }, 50 | "maxAttempts": 4, 51 | "backoffFactor": 2, 52 | "type": "EXPONENTIAL_BACKOFF" 53 | }, 54 | "httpTimeoutStrategy": { 55 | "backoff": 1, 56 | "backoffUnit": "SECONDS", 57 | "backupStrategy": { 58 | "type": "THROW_EXCEPTION" 59 | }, 60 | "maxAttempts": 4, 61 | "backoffFactor": 2, 62 | "type": "EXPONENTIAL_BACKOFF" 63 | }, 64 | "limitingShare": 1.0, 65 | "limitingType": "BURST", 66 | "rateLimiterTimeoutStrategy": { 67 | "type": "THROW_EXCEPTION" 68 | }, 69 | "requests": { 70 | "connectTimeout": 3, 71 | "connectTimeoutUnit": "SECONDS", 72 | "rateLimiterTimeout": 30, 73 | "rateLimiterTimeoutUnit": "SECONDS", 74 | "readTimeout": 3, 75 | "readTimeoutUnit": "SECONDS", 76 | "https": true 77 | }, 78 | "services": [ 79 | "com.merakianalytics.orianna.datapipeline.riotapi.ChampionAPI", 80 | "com.merakianalytics.orianna.datapipeline.riotapi.ChampionMasteryAPI", 81 | "com.merakianalytics.orianna.datapipeline.riotapi.LeagueAPI", 82 | "com.merakianalytics.orianna.datapipeline.riotapi.MatchAPI", 83 | "com.merakianalytics.orianna.datapipeline.riotapi.SpectatorAPI", 84 | "com.merakianalytics.orianna.datapipeline.riotapi.StatusAPI", 85 | "com.merakianalytics.orianna.datapipeline.riotapi.SummonerAPI", 86 | "com.merakianalytics.orianna.datapipeline.riotapi.ThirdPartyCodeAPI" 87 | ] 88 | }, 89 | "configClassName": "com.merakianalytics.orianna.datapipeline.riotapi.RiotAPI$Configuration" 90 | } 91 | ] 92 | }, 93 | "cors": { 94 | "allowCredentials": "true", 95 | "allowHeaders": "*", 96 | "allowMethods": "*", 97 | "allowOrigin": "*", 98 | "maxAge": "3600" 99 | }, 100 | "serializationInclusions": "NON_DEFAULT" 101 | } 102 | -------------------------------------------------------------------------------- /configurations/dto/mongo/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: "3" 2 | 3 | services: 4 | kernel: 5 | container_name: kernel 6 | image: merakianalytics/kernel:mongo 7 | ports: 8 | - 80:8080 9 | environment: 10 | - RIOT_API_KEY=${RIOT_API_KEY} 11 | restart: always 12 | networks: 13 | - kernel 14 | depends_on: 15 | - mongo 16 | swagger: 17 | container_name: kernel_swagger 18 | image: swaggerapi/swagger-ui 19 | ports: 20 | - 12357:8080 21 | environment: 22 | - API_URL=http://localhost/lol/swagger.json 23 | restart: always 24 | networks: 25 | - kernel 26 | depends_on: 27 | - kernel 28 | mongo: 29 | container_name: mongo 30 | image: mongo:jessie 31 | restart: always 32 | networks: 33 | - kernel 34 | 35 | networks: 36 | kernel: 37 | driver: bridge 38 | -------------------------------------------------------------------------------- /configurations/dto/mongo/kernel-config.json: -------------------------------------------------------------------------------- 1 | { 2 | "defaultPlatform": "NORTH_AMERICA", 3 | "pipeline": { 4 | "elements": [ 5 | { 6 | "className": "com.merakianalytics.orianna.datastores.mongo.dto.MongoDBDataStore", 7 | "config": { 8 | "database": "orianna", 9 | "host": "mongo", 10 | "port": 27017, 11 | "expirationPeriods": { 12 | "com.merakianalytics.orianna.types.dto.champion.ChampionInfo": { 13 | "period": 6, 14 | "unit": "HOURS" 15 | }, 16 | "com.merakianalytics.orianna.types.dto.championmastery.ChampionMastery": { 17 | "period": 2, 18 | "unit": "HOURS" 19 | }, 20 | "com.merakianalytics.orianna.types.dto.championmastery.ChampionMasteries": { 21 | "period": 2, 22 | "unit": "HOURS" 23 | }, 24 | "com.merakianalytics.orianna.types.dto.championmastery.ChampionMasteryScore": { 25 | "period": 2, 26 | "unit": "HOURS" 27 | }, 28 | "com.merakianalytics.orianna.types.dto.league.LeagueList": { 29 | "period": 30, 30 | "unit": "MINUTES" 31 | }, 32 | "com.merakianalytics.orianna.types.dto.league.LeaguePositions": { 33 | "period": 2, 34 | "unit": "HOURS" 35 | }, 36 | "com.merakianalytics.orianna.types.dto.match.Match": { 37 | "period": -1, 38 | "unit": "DAYS" 39 | }, 40 | "com.merakianalytics.orianna.types.dto.match.MatchTimeline": { 41 | "period": -1, 42 | "unit": "DAYS" 43 | }, 44 | "com.merakianalytics.orianna.types.dto.match.TournamentMatches": { 45 | "period": -1, 46 | "unit": "DAYS" 47 | }, 48 | "com.merakianalytics.orianna.types.dto.spectator.CurrentGameInfo": { 49 | "period": 5, 50 | "unit": "MINUTES" 51 | }, 52 | "com.merakianalytics.orianna.types.dto.spectator.FeaturedGames": { 53 | "period": 5, 54 | "unit": "MINUTES" 55 | }, 56 | "com.merakianalytics.orianna.types.dto.staticdata.Champion": { 57 | "period": -1, 58 | "unit": "DAYS" 59 | }, 60 | "com.merakianalytics.orianna.types.dto.staticdata.ChampionList": { 61 | "period": -1, 62 | "unit": "DAYS" 63 | }, 64 | "com.merakianalytics.orianna.types.dto.staticdata.Item": { 65 | "period": -1, 66 | "unit": "DAYS" 67 | }, 68 | "com.merakianalytics.orianna.types.dto.staticdata.ItemList": { 69 | "period": -1, 70 | "unit": "DAYS" 71 | }, 72 | "com.merakianalytics.orianna.types.dto.staticdata.Languages": { 73 | "period": 6, 74 | "unit": "HOURS" 75 | }, 76 | "com.merakianalytics.orianna.types.dto.staticdata.LanguageStrings": { 77 | "period": -1, 78 | "unit": "DAYS" 79 | }, 80 | "com.merakianalytics.orianna.types.dto.staticdata.MapData": { 81 | "period": -1, 82 | "unit": "DAYS" 83 | }, 84 | "com.merakianalytics.orianna.types.dto.staticdata.MapDetails": { 85 | "period": -1, 86 | "unit": "DAYS" 87 | }, 88 | "com.merakianalytics.orianna.types.dto.staticdata.Mastery": { 89 | "period": -1, 90 | "unit": "DAYS" 91 | }, 92 | "com.merakianalytics.orianna.types.dto.staticdata.MasteryList": { 93 | "period": -1, 94 | "unit": "DAYS" 95 | }, 96 | "com.merakianalytics.orianna.types.dto.staticdata.Patch": { 97 | "period": -1, 98 | "unit": "DAYS" 99 | }, 100 | "com.merakianalytics.orianna.types.dto.staticdata.Patches": { 101 | "period": 6, 102 | "unit": "HOURS" 103 | }, 104 | "com.merakianalytics.orianna.types.dto.staticdata.ProfileIconData": { 105 | "period": -1, 106 | "unit": "DAYS" 107 | }, 108 | "com.merakianalytics.orianna.types.dto.staticdata.ProfileIconDetails": { 109 | "period": -1, 110 | "unit": "DAYS" 111 | }, 112 | "com.merakianalytics.orianna.types.dto.staticdata.Realm": { 113 | "period": 6, 114 | "unit": "HOURS" 115 | }, 116 | "com.merakianalytics.orianna.types.dto.staticdata.Rune": { 117 | "period": -1, 118 | "unit": "DAYS" 119 | }, 120 | "com.merakianalytics.orianna.types.dto.staticdata.RuneList": { 121 | "period": -1, 122 | "unit": "DAYS" 123 | }, 124 | "com.merakianalytics.orianna.types.dto.staticdata.SummonerSpell": { 125 | "period": -1, 126 | "unit": "DAYS" 127 | }, 128 | "com.merakianalytics.orianna.types.dto.staticdata.SummonerSpellList": { 129 | "period": -1, 130 | "unit": "DAYS" 131 | }, 132 | "com.merakianalytics.orianna.types.dto.staticdata.Versions": { 133 | "period": 6, 134 | "unit": "HOURS" 135 | }, 136 | "com.merakianalytics.orianna.types.dto.status.ShardStatus": { 137 | "period": 15, 138 | "unit": "MINUTES" 139 | }, 140 | "com.merakianalytics.orianna.types.dto.summoner.Summoner": { 141 | "period": 1, 142 | "unit": "DAYS" 143 | }, 144 | "com.merakianalytics.orianna.types.dto.thirdpartycode.VerificationString": { 145 | "period": 5, 146 | "unit": "MINUTES" 147 | } 148 | } 149 | }, 150 | "configClassName": "com.merakianalytics.orianna.datastores.mongo.dto.MongoDBDataStore$Configuration" 151 | }, 152 | { 153 | "className": "com.merakianalytics.orianna.datapipeline.riotapi.RiotAPI", 154 | "config": { 155 | "http404Strategy": { 156 | "type": "THROW_EXCEPTION" 157 | }, 158 | "http429Strategy": { 159 | "backupStrategy": { 160 | "backoff": 1, 161 | "backoffUnit": "SECONDS", 162 | "backupStrategy": { 163 | "type": "THROW_EXCEPTION" 164 | }, 165 | "maxAttempts": 4, 166 | "backoffFactor": 2, 167 | "type": "EXPONENTIAL_BACKOFF" 168 | }, 169 | "type": "RETRY_FROM_HEADERS" 170 | }, 171 | "http500Strategy": { 172 | "backoff": 1, 173 | "backoffUnit": "SECONDS", 174 | "backupStrategy": { 175 | "type": "THROW_EXCEPTION" 176 | }, 177 | "maxAttempts": 4, 178 | "backoffFactor": 2, 179 | "type": "EXPONENTIAL_BACKOFF" 180 | }, 181 | "http503Strategy": { 182 | "backoff": 1, 183 | "backoffUnit": "SECONDS", 184 | "backupStrategy": { 185 | "type": "THROW_EXCEPTION" 186 | }, 187 | "maxAttempts": 4, 188 | "backoffFactor": 2, 189 | "type": "EXPONENTIAL_BACKOFF" 190 | }, 191 | "http504Strategy": { 192 | "backoff": 1, 193 | "backoffUnit": "SECONDS", 194 | "backupStrategy": { 195 | "type": "THROW_EXCEPTION" 196 | }, 197 | "maxAttempts": 4, 198 | "backoffFactor": 2, 199 | "type": "EXPONENTIAL_BACKOFF" 200 | }, 201 | "httpTimeoutStrategy": { 202 | "backoff": 1, 203 | "backoffUnit": "SECONDS", 204 | "backupStrategy": { 205 | "type": "THROW_EXCEPTION" 206 | }, 207 | "maxAttempts": 4, 208 | "backoffFactor": 2, 209 | "type": "EXPONENTIAL_BACKOFF" 210 | }, 211 | "limitingShare": 1.0, 212 | "limitingType": "BURST", 213 | "rateLimiterTimeoutStrategy": { 214 | "type": "THROW_EXCEPTION" 215 | }, 216 | "requests": { 217 | "connectTimeout": 3, 218 | "connectTimeoutUnit": "SECONDS", 219 | "rateLimiterTimeout": 30, 220 | "rateLimiterTimeoutUnit": "SECONDS", 221 | "readTimeout": 3, 222 | "readTimeoutUnit": "SECONDS", 223 | "https": true 224 | }, 225 | "services": [ 226 | "com.merakianalytics.orianna.datapipeline.riotapi.ChampionAPI", 227 | "com.merakianalytics.orianna.datapipeline.riotapi.ChampionMasteryAPI", 228 | "com.merakianalytics.orianna.datapipeline.riotapi.LeagueAPI", 229 | "com.merakianalytics.orianna.datapipeline.riotapi.MatchAPI", 230 | "com.merakianalytics.orianna.datapipeline.riotapi.SpectatorAPI", 231 | "com.merakianalytics.orianna.datapipeline.riotapi.StatusAPI", 232 | "com.merakianalytics.orianna.datapipeline.riotapi.SummonerAPI", 233 | "com.merakianalytics.orianna.datapipeline.riotapi.ThirdPartyCodeAPI" 234 | ] 235 | }, 236 | "configClassName": "com.merakianalytics.orianna.datapipeline.riotapi.RiotAPI$Configuration" 237 | } 238 | ] 239 | }, 240 | "cors": { 241 | "allowCredentials": "true", 242 | "allowHeaders": "*", 243 | "allowMethods": "*", 244 | "allowOrigin": "*", 245 | "maxAge": "3600" 246 | }, 247 | "serializationInclusions": "NON_DEFAULT" 248 | } 249 | -------------------------------------------------------------------------------- /configurations/dto/xodus/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: "3" 2 | 3 | services: 4 | kernel: 5 | container_name: kernel 6 | image: merakianalytics/kernel:xodus 7 | ports: 8 | - 80:8080 9 | environment: 10 | - RIOT_API_KEY=${RIOT_API_KEY} 11 | restart: always 12 | networks: 13 | - kernel 14 | swagger: 15 | container_name: kernel_swagger 16 | image: swaggerapi/swagger-ui 17 | ports: 18 | - 12357:8080 19 | environment: 20 | - API_URL=http://localhost/lol/swagger.json 21 | restart: always 22 | networks: 23 | - kernel 24 | depends_on: 25 | - kernel 26 | 27 | networks: 28 | kernel: 29 | driver: bridge 30 | -------------------------------------------------------------------------------- /configurations/dto/xodus/kernel-config.json: -------------------------------------------------------------------------------- 1 | { 2 | "defaultPlatform": "NORTH_AMERICA", 3 | "pipeline": { 4 | "elements": [ 5 | { 6 | "className": "com.merakianalytics.orianna.datastores.xodus.dto.XodusDataStore", 7 | "config": { 8 | "dataDirectory": "/var/lib/orianna/data", 9 | "expirationPeriods": { 10 | "com.merakianalytics.orianna.types.dto.champion.ChampionInfo": { 11 | "period": 6, 12 | "unit": "HOURS" 13 | }, 14 | "com.merakianalytics.orianna.types.dto.championmastery.ChampionMastery": { 15 | "period": 2, 16 | "unit": "HOURS" 17 | }, 18 | "com.merakianalytics.orianna.types.dto.championmastery.ChampionMasteries": { 19 | "period": 2, 20 | "unit": "HOURS" 21 | }, 22 | "com.merakianalytics.orianna.types.dto.championmastery.ChampionMasteryScore": { 23 | "period": 2, 24 | "unit": "HOURS" 25 | }, 26 | "com.merakianalytics.orianna.types.dto.league.LeagueList": { 27 | "period": 30, 28 | "unit": "MINUTES" 29 | }, 30 | "com.merakianalytics.orianna.types.dto.league.LeaguePositions": { 31 | "period": 2, 32 | "unit": "HOURS" 33 | }, 34 | "com.merakianalytics.orianna.types.dto.match.Match": { 35 | "period": -1, 36 | "unit": "DAYS" 37 | }, 38 | "com.merakianalytics.orianna.types.dto.match.MatchTimeline": { 39 | "period": -1, 40 | "unit": "DAYS" 41 | }, 42 | "com.merakianalytics.orianna.types.dto.match.TournamentMatches": { 43 | "period": -1, 44 | "unit": "DAYS" 45 | }, 46 | "com.merakianalytics.orianna.types.dto.spectator.CurrentGameInfo": { 47 | "period": 5, 48 | "unit": "MINUTES" 49 | }, 50 | "com.merakianalytics.orianna.types.dto.spectator.FeaturedGames": { 51 | "period": 5, 52 | "unit": "MINUTES" 53 | }, 54 | "com.merakianalytics.orianna.types.dto.staticdata.Champion": { 55 | "period": -1, 56 | "unit": "DAYS" 57 | }, 58 | "com.merakianalytics.orianna.types.dto.staticdata.ChampionList": { 59 | "period": -1, 60 | "unit": "DAYS" 61 | }, 62 | "com.merakianalytics.orianna.types.dto.staticdata.Item": { 63 | "period": -1, 64 | "unit": "DAYS" 65 | }, 66 | "com.merakianalytics.orianna.types.dto.staticdata.ItemList": { 67 | "period": -1, 68 | "unit": "DAYS" 69 | }, 70 | "com.merakianalytics.orianna.types.dto.staticdata.Languages": { 71 | "period": 6, 72 | "unit": "HOURS" 73 | }, 74 | "com.merakianalytics.orianna.types.dto.staticdata.LanguageStrings": { 75 | "period": -1, 76 | "unit": "DAYS" 77 | }, 78 | "com.merakianalytics.orianna.types.dto.staticdata.MapData": { 79 | "period": -1, 80 | "unit": "DAYS" 81 | }, 82 | "com.merakianalytics.orianna.types.dto.staticdata.MapDetails": { 83 | "period": -1, 84 | "unit": "DAYS" 85 | }, 86 | "com.merakianalytics.orianna.types.dto.staticdata.Mastery": { 87 | "period": -1, 88 | "unit": "DAYS" 89 | }, 90 | "com.merakianalytics.orianna.types.dto.staticdata.MasteryList": { 91 | "period": -1, 92 | "unit": "DAYS" 93 | }, 94 | "com.merakianalytics.orianna.types.dto.staticdata.Patch": { 95 | "period": -1, 96 | "unit": "DAYS" 97 | }, 98 | "com.merakianalytics.orianna.types.dto.staticdata.Patches": { 99 | "period": 6, 100 | "unit": "HOURS" 101 | }, 102 | "com.merakianalytics.orianna.types.dto.staticdata.ProfileIconData": { 103 | "period": -1, 104 | "unit": "DAYS" 105 | }, 106 | "com.merakianalytics.orianna.types.dto.staticdata.ProfileIconDetails": { 107 | "period": -1, 108 | "unit": "DAYS" 109 | }, 110 | "com.merakianalytics.orianna.types.dto.staticdata.Realm": { 111 | "period": 6, 112 | "unit": "HOURS" 113 | }, 114 | "com.merakianalytics.orianna.types.dto.staticdata.Rune": { 115 | "period": -1, 116 | "unit": "DAYS" 117 | }, 118 | "com.merakianalytics.orianna.types.dto.staticdata.RuneList": { 119 | "period": -1, 120 | "unit": "DAYS" 121 | }, 122 | "com.merakianalytics.orianna.types.dto.staticdata.SummonerSpell": { 123 | "period": -1, 124 | "unit": "DAYS" 125 | }, 126 | "com.merakianalytics.orianna.types.dto.staticdata.SummonerSpellList": { 127 | "period": -1, 128 | "unit": "DAYS" 129 | }, 130 | "com.merakianalytics.orianna.types.dto.staticdata.Versions": { 131 | "period": 6, 132 | "unit": "HOURS" 133 | }, 134 | "com.merakianalytics.orianna.types.dto.status.ShardStatus": { 135 | "period": 15, 136 | "unit": "MINUTES" 137 | }, 138 | "com.merakianalytics.orianna.types.dto.summoner.Summoner": { 139 | "period": 1, 140 | "unit": "DAYS" 141 | }, 142 | "com.merakianalytics.orianna.types.dto.thirdpartycode.VerificationString": { 143 | "period": 5, 144 | "unit": "MINUTES" 145 | } 146 | } 147 | }, 148 | "configClassName": "com.merakianalytics.orianna.datastores.xodus.dto.XodusDataStore$Configuration" 149 | }, 150 | { 151 | "className": "com.merakianalytics.orianna.datapipeline.riotapi.RiotAPI", 152 | "config": { 153 | "http404Strategy": { 154 | "type": "THROW_EXCEPTION" 155 | }, 156 | "http429Strategy": { 157 | "backupStrategy": { 158 | "backoff": 1, 159 | "backoffUnit": "SECONDS", 160 | "backupStrategy": { 161 | "type": "THROW_EXCEPTION" 162 | }, 163 | "maxAttempts": 4, 164 | "backoffFactor": 2, 165 | "type": "EXPONENTIAL_BACKOFF" 166 | }, 167 | "type": "RETRY_FROM_HEADERS" 168 | }, 169 | "http500Strategy": { 170 | "backoff": 1, 171 | "backoffUnit": "SECONDS", 172 | "backupStrategy": { 173 | "type": "THROW_EXCEPTION" 174 | }, 175 | "maxAttempts": 4, 176 | "backoffFactor": 2, 177 | "type": "EXPONENTIAL_BACKOFF" 178 | }, 179 | "http503Strategy": { 180 | "backoff": 1, 181 | "backoffUnit": "SECONDS", 182 | "backupStrategy": { 183 | "type": "THROW_EXCEPTION" 184 | }, 185 | "maxAttempts": 4, 186 | "backoffFactor": 2, 187 | "type": "EXPONENTIAL_BACKOFF" 188 | }, 189 | "http504Strategy": { 190 | "backoff": 1, 191 | "backoffUnit": "SECONDS", 192 | "backupStrategy": { 193 | "type": "THROW_EXCEPTION" 194 | }, 195 | "maxAttempts": 4, 196 | "backoffFactor": 2, 197 | "type": "EXPONENTIAL_BACKOFF" 198 | }, 199 | "httpTimeoutStrategy": { 200 | "backoff": 1, 201 | "backoffUnit": "SECONDS", 202 | "backupStrategy": { 203 | "type": "THROW_EXCEPTION" 204 | }, 205 | "maxAttempts": 4, 206 | "backoffFactor": 2, 207 | "type": "EXPONENTIAL_BACKOFF" 208 | }, 209 | "limitingShare": 1.0, 210 | "limitingType": "BURST", 211 | "rateLimiterTimeoutStrategy": { 212 | "type": "THROW_EXCEPTION" 213 | }, 214 | "requests": { 215 | "connectTimeout": 3, 216 | "connectTimeoutUnit": "SECONDS", 217 | "rateLimiterTimeout": 30, 218 | "rateLimiterTimeoutUnit": "SECONDS", 219 | "readTimeout": 3, 220 | "readTimeoutUnit": "SECONDS", 221 | "https": true 222 | }, 223 | "services": [ 224 | "com.merakianalytics.orianna.datapipeline.riotapi.ChampionAPI", 225 | "com.merakianalytics.orianna.datapipeline.riotapi.ChampionMasteryAPI", 226 | "com.merakianalytics.orianna.datapipeline.riotapi.LeagueAPI", 227 | "com.merakianalytics.orianna.datapipeline.riotapi.MatchAPI", 228 | "com.merakianalytics.orianna.datapipeline.riotapi.SpectatorAPI", 229 | "com.merakianalytics.orianna.datapipeline.riotapi.StatusAPI", 230 | "com.merakianalytics.orianna.datapipeline.riotapi.SummonerAPI", 231 | "com.merakianalytics.orianna.datapipeline.riotapi.ThirdPartyCodeAPI" 232 | ] 233 | }, 234 | "configClassName": "com.merakianalytics.orianna.datapipeline.riotapi.RiotAPI$Configuration" 235 | } 236 | ] 237 | }, 238 | "cors": { 239 | "allowCredentials": "true", 240 | "allowHeaders": "*", 241 | "allowMethods": "*", 242 | "allowOrigin": "*", 243 | "maxAge": "3600" 244 | }, 245 | "serializationInclusions": "NON_DEFAULT" 246 | } 247 | -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | com.merakianalytics.kernel 8 | kernel 9 | 4.0.0-SNAPSHOT 10 | war 11 | 12 | kernel 13 | Riot API proxy server 14 | https://github.com/meraki-analytics/kernel 15 | 16 | 17 | 18 | robrua 19 | Rob Rua 20 | robertrua@gmail.com 21 | merakianalytics 22 | https://github.com/meraki-analytics 23 | 24 | 25 | 26 | 27 | 28 | MIT License 29 | https://opensource.org/licenses/MIT 30 | repo 31 | 32 | 33 | 34 | 35 | scm:git:git@github.com:meraki-analytics/kernel.git 36 | scm:git:git@github.com:meraki-analytics/kernel.git 37 | git@github.com:meraki-analytics/kernel.git 38 | 39 | 40 | 41 | 42 | snapshots-repo 43 | https://oss.sonatype.org/content/repositories/snapshots 44 | 45 | false 46 | 47 | 48 | true 49 | 50 | 51 | 52 | 53 | 54 | UTF-8 55 | false 56 | 3.8.0 57 | 3.2.2 58 | 3.1.0 59 | 1.4.10 60 | 2.8.2 61 | 1.16 62 | 5.3.2 63 | 1.3.2 64 | 1.7.25 65 | 2.3.0.Final 66 | 1.9.0 67 | 1.0.5-SNAPSHOT 68 | 4.0.0-SNAPSHOT 69 | 1.1.0-SNAPSHOT 70 | 27.0.1-jre 71 | 2.10.0.pr1 72 | 0.8.16 73 | merakianalytics/kernel 74 | base 75 | 76 | 77 | 78 | 79 | 80 | io.thorntail 81 | bom-all 82 | ${thorntail.version} 83 | import 84 | pom 85 | 86 | 87 | io.thorntail 88 | build-parent 89 | ${thorntail.version} 90 | import 91 | pom 92 | 93 | 94 | org.apache.deltaspike.distribution 95 | distributions-bom 96 | ${deltaspike.version} 97 | pom 98 | import 99 | 100 | 101 | 102 | 103 | 104 | 105 | org.junit.jupiter 106 | junit-jupiter-engine 107 | ${junit.version} 108 | test 109 | 110 | 111 | org.junit.platform 112 | junit-platform-launcher 113 | ${junit.launcher.version} 114 | test 115 | 116 | 117 | org.slf4j 118 | slf4j-api 119 | ${slf4j.version} 120 | 121 | 122 | io.thorntail 123 | jaxrs 124 | 125 | 126 | io.thorntail 127 | cdi 128 | 129 | 130 | io.thorntail 131 | swagger 132 | 133 | 134 | org.jboss.resteasy 135 | resteasy-jaxrs 136 | provided 137 | 138 | 139 | org.apache.deltaspike.core 140 | deltaspike-core-api 141 | compile 142 | 143 | 144 | org.apache.deltaspike.core 145 | deltaspike-core-impl 146 | runtime 147 | 148 | 149 | com.merakianalytics.datapipelines 150 | datapipelines 151 | ${datapipelines.version} 152 | 153 | 154 | com.merakianalytics.orianna 155 | orianna 156 | ${orianna.version} 157 | 158 | 159 | com.google.guava 160 | guava 161 | ${guava.version} 162 | 163 | 164 | com.fasterxml.jackson.core 165 | jackson-databind 166 | ${jackson.version} 167 | compile 168 | 169 | 170 | com.fasterxml.jackson.datatype 171 | jackson-datatype-joda 172 | ${jackson.version} 173 | 174 | 175 | org.msgpack 176 | jackson-dataformat-msgpack 177 | ${msgpack.version} 178 | 179 | 180 | 181 | 182 | ${project.artifactId} 183 | 184 | 185 | 186 | org.apache.maven.plugins 187 | maven-compiler-plugin 188 | ${maven.compiler.version} 189 | 190 | ${project.build.sourceEncoding} 191 | 1.8 192 | 1.8 193 | 194 | 195 | 196 | org.apache.maven.plugins 197 | maven-war-plugin 198 | ${maven.war.version} 199 | 200 | --illegal-access=permit 201 | 202 | 203 | 204 | org.codehaus.mojo 205 | license-maven-plugin 206 | ${maven.license.version} 207 | 208 | system,test 209 | 210 | 211 | 212 | add-third-party 213 | 214 | add-third-party 215 | 216 | 217 | 218 | 219 | 220 | io.thorntail 221 | thorntail-maven-plugin 222 | ${thorntail.version} 223 | 224 | 225 | 226 | package 227 | 228 | 229 | 230 | 231 | 232 | maven-resources-plugin 233 | ${maven.resources.version} 234 | 235 | 236 | process-resources 237 | 238 | copy-resources 239 | 240 | 241 | ${basedir}/target/ 242 | true 243 | 244 | 245 | ${basedir}/configurations/dto/base 246 | 247 | kernel-config.json 248 | 249 | 250 | 251 | 252 | 253 | 254 | 255 | 256 | 257 | 258 | 259 | 260 | docker 261 | 262 | 263 | 264 | 265 | com.spotify 266 | dockerfile-maven-plugin 267 | ${maven.dockerfile.version} 268 | 269 | 270 | default 271 | 272 | build 273 | push 274 | 275 | 276 | 277 | 278 | ${docker.image} 279 | ${docker.tag} 280 | false 281 | true 282 | 283 | 284 | 285 | org.apache.maven.plugins 286 | maven-deploy-plugin 287 | ${maven.deploy.version} 288 | 289 | true 290 | 291 | 292 | 293 | 294 | 295 | 296 | mongo 297 | 298 | 299 | mongo 300 | 301 | 302 | 303 | 304 | com.merakianalytics.orianna.datastores 305 | mongo 306 | ${orianna.datastores.version} 307 | 308 | 309 | 310 | 311 | 312 | 313 | maven-resources-plugin 314 | ${maven.resources.version} 315 | 316 | 317 | process-resources 318 | 319 | copy-resources 320 | 321 | 322 | ${basedir}/target/ 323 | true 324 | 325 | 326 | ${basedir}/configurations/dto/mongo 327 | 328 | kernel-config.json 329 | 330 | 331 | 332 | 333 | 334 | 335 | 336 | 337 | 338 | 339 | 340 | xodus 341 | 342 | 343 | xodus 344 | 345 | 346 | 347 | 348 | com.merakianalytics.orianna.datastores 349 | xodus 350 | ${orianna.datastores.version} 351 | 352 | 353 | 354 | 355 | 356 | 357 | maven-resources-plugin 358 | ${maven.resources.version} 359 | 360 | 361 | process-resources 362 | 363 | copy-resources 364 | 365 | 366 | ${basedir}/target/ 367 | true 368 | 369 | 370 | ${basedir}/configurations/dto/xodus 371 | 372 | kernel-config.json 373 | 374 | 375 | 376 | 377 | 378 | 379 | 380 | 381 | 382 | 383 | 384 | 385 | -------------------------------------------------------------------------------- /src/main/java/com/merakianalytics/kernel/Kernel.java: -------------------------------------------------------------------------------- 1 | package com.merakianalytics.kernel; 2 | 3 | import java.util.HashSet; 4 | import java.util.Set; 5 | 6 | import javax.inject.Inject; 7 | import javax.ws.rs.ApplicationPath; 8 | import javax.ws.rs.core.Application; 9 | 10 | import com.merakianalytics.kernel.exceptions.OriannaExceptionMapper; 11 | import com.merakianalytics.kernel.exceptions.QueryValidationExceptionMapper; 12 | import com.merakianalytics.kernel.filters.CORSFilter; 13 | import com.merakianalytics.kernel.filters.NullResponseFilter; 14 | import com.merakianalytics.kernel.providers.JSONProvider; 15 | import com.merakianalytics.kernel.providers.MessagePackProvider; 16 | 17 | /** 18 | * The jax-rs application definition. This is the "main" of the kernel application. 19 | */ 20 | @ApplicationPath("/lol") 21 | public class Kernel extends Application { 22 | @Inject 23 | private KernelContext context; 24 | 25 | @Override 26 | public Set> getClasses() { 27 | final Set> services = new HashSet<>(); 28 | 29 | // Utilities 30 | services.add(OriannaExceptionMapper.class); 31 | services.add(QueryValidationExceptionMapper.class); 32 | services.add(CORSFilter.class); 33 | services.add(NullResponseFilter.class); 34 | services.add(JSONProvider.class); 35 | services.add(MessagePackProvider.class); 36 | 37 | // Riot API 38 | if(context.isProduceCoreData()) { 39 | services.add(com.merakianalytics.kernel.riotapi.data.ChampionMasteryAPI.class); 40 | services.add(com.merakianalytics.kernel.riotapi.data.ChampionAPI.class); 41 | services.add(com.merakianalytics.kernel.riotapi.data.LeagueAPI.class); 42 | services.add(com.merakianalytics.kernel.riotapi.data.StatusAPI.class); 43 | services.add(com.merakianalytics.kernel.riotapi.data.MatchAPI.class); 44 | services.add(com.merakianalytics.kernel.riotapi.data.SpectatorAPI.class); 45 | services.add(com.merakianalytics.kernel.riotapi.data.SummonerAPI.class); 46 | services.add(com.merakianalytics.kernel.riotapi.data.ThirdPartyCodeAPI.class); 47 | } else { 48 | services.add(com.merakianalytics.kernel.riotapi.dto.ChampionMasteryAPI.class); 49 | services.add(com.merakianalytics.kernel.riotapi.dto.ChampionAPI.class); 50 | services.add(com.merakianalytics.kernel.riotapi.dto.LeagueAPI.class); 51 | services.add(com.merakianalytics.kernel.riotapi.dto.StatusAPI.class); 52 | services.add(com.merakianalytics.kernel.riotapi.dto.MatchAPI.class); 53 | services.add(com.merakianalytics.kernel.riotapi.dto.SpectatorAPI.class); 54 | services.add(com.merakianalytics.kernel.riotapi.dto.SummonerAPI.class); 55 | services.add(com.merakianalytics.kernel.riotapi.dto.ThirdPartyCodeAPI.class); 56 | } 57 | 58 | return services; 59 | } 60 | } -------------------------------------------------------------------------------- /src/main/java/com/merakianalytics/kernel/KernelConfiguration.java: -------------------------------------------------------------------------------- 1 | package com.merakianalytics.kernel; 2 | 3 | import java.io.File; 4 | import java.io.IOException; 5 | import java.io.InputStream; 6 | import java.util.List; 7 | import java.util.Set; 8 | 9 | import org.apache.deltaspike.core.api.exclude.Exclude; 10 | import org.slf4j.Logger; 11 | import org.slf4j.LoggerFactory; 12 | 13 | import com.fasterxml.jackson.annotation.JsonInclude.Include; 14 | import com.fasterxml.jackson.core.JsonParser.Feature; 15 | import com.fasterxml.jackson.databind.ObjectMapper; 16 | import com.fasterxml.jackson.databind.node.ObjectNode; 17 | import com.google.common.collect.ImmutableList; 18 | import com.google.common.collect.ImmutableSet; 19 | import com.merakianalytics.kernel.filters.CORSFilter; 20 | import com.merakianalytics.orianna.datapipeline.PipelineConfiguration; 21 | import com.merakianalytics.orianna.datapipeline.PipelineConfiguration.PipelineElementConfiguration; 22 | import com.merakianalytics.orianna.datapipeline.PipelineConfiguration.TransformerConfiguration; 23 | import com.merakianalytics.orianna.datapipeline.riotapi.RiotAPI; 24 | import com.merakianalytics.orianna.datapipeline.riotapi.RiotAPIService.FailedRequestStrategy; 25 | import com.merakianalytics.orianna.types.common.Platform; 26 | 27 | /** 28 | * The application configuration 29 | */ 30 | @Exclude 31 | public class KernelConfiguration { 32 | private static final String CONFIGURATION_PATH_ENVIRONMENT_VARIABLE = "KERNEL_CONFIGURATION_PATH"; 33 | private static final String DEFAULT_CONFIGURATION_RESOURCE = "com/merakianalytics/kernel/default-kernel-config.json"; 34 | private static final boolean DEFAULT_PRODUCE_CORE_DATA = false; 35 | private static final Include DEFAULT_SERIALIZATION_INCLUSIONS = Include.NON_DEFAULT; 36 | private static final Logger LOGGER = LoggerFactory.getLogger(KernelConfiguration.class); 37 | 38 | private static PipelineConfiguration defaultPipelineConfiguration() { 39 | final PipelineConfiguration config = new PipelineConfiguration(); 40 | 41 | final Set transformers = ImmutableSet.of(); 42 | config.setTransformers(transformers); 43 | 44 | final ObjectMapper mapper = new ObjectMapper().setSerializationInclusion(Include.NON_DEFAULT); 45 | final PipelineElementConfiguration riotAPI = PipelineElementConfiguration.defaultConfiguration(RiotAPI.class); 46 | ((ObjectNode)riotAPI.getConfig()).set("http404Strategy", mapper.valueToTree(new FailedRequestStrategy.ThrowException())); 47 | 48 | final List elements = ImmutableList.of(riotAPI); 49 | config.setElements(elements); 50 | 51 | return config; 52 | } 53 | 54 | /** 55 | * Loads the application configuration from standard resource locations, or falls back on the default configuration 56 | * 57 | * @return the application configuration 58 | */ 59 | public static KernelConfiguration load() { 60 | final ObjectMapper mapper = new ObjectMapper().enable(Feature.ALLOW_COMMENTS); 61 | 62 | KernelConfiguration config = null; 63 | String message = null; 64 | 65 | final String configPath = System.getenv(CONFIGURATION_PATH_ENVIRONMENT_VARIABLE); 66 | if(configPath != null) { 67 | try { 68 | config = mapper.readValue(new File(configPath), KernelConfiguration.class); 69 | message = " from " + configPath + " as specified by " + CONFIGURATION_PATH_ENVIRONMENT_VARIABLE; 70 | } catch(final IOException e) { 71 | LOGGER.error("Failed to load Kernel Configuration! Attempting to load default configuration!", e); 72 | } 73 | } 74 | 75 | if(config == null) { 76 | try(InputStream inputStream = KernelConfiguration.class.getClassLoader().getResourceAsStream(DEFAULT_CONFIGURATION_RESOURCE)) { 77 | config = mapper.readValue(inputStream, KernelConfiguration.class); 78 | message = " from default resource file " + DEFAULT_CONFIGURATION_RESOURCE; 79 | } catch(final IOException e) { 80 | LOGGER.error("Failed to load default Kernel Configuration! Using default constructor instead!", e); 81 | } 82 | } 83 | 84 | if(config == null) { 85 | config = new KernelConfiguration(); 86 | message = " using the default constructor"; 87 | } 88 | 89 | LOGGER.info("Loaded new Kernel Configuration" + message + "!"); 90 | return config; 91 | } 92 | 93 | private CORSFilter.Configuration CORS = new CORSFilter.Configuration(); 94 | private Platform defaultPlatform = Platform.NORTH_AMERICA; 95 | private PipelineConfiguration pipeline = defaultPipelineConfiguration(); 96 | private boolean produceCoreData = DEFAULT_PRODUCE_CORE_DATA; 97 | private Include serializationInclusions = DEFAULT_SERIALIZATION_INCLUSIONS; 98 | 99 | /** 100 | * @return the CORS 101 | */ 102 | public CORSFilter.Configuration getCORS() { 103 | return CORS; 104 | } 105 | 106 | /** 107 | * @return the defaultPlatform 108 | */ 109 | public Platform getDefaultPlatform() { 110 | return defaultPlatform; 111 | } 112 | 113 | /** 114 | * @return the pipeline 115 | */ 116 | public PipelineConfiguration getPipeline() { 117 | return pipeline; 118 | } 119 | 120 | /** 121 | * @return the serializationInclusions 122 | */ 123 | public Include getSerializationInclusions() { 124 | return serializationInclusions; 125 | } 126 | 127 | /** 128 | * @return the produceCoreData 129 | */ 130 | public boolean isProduceCoreData() { 131 | return produceCoreData; 132 | } 133 | 134 | /** 135 | * @param CORS 136 | * the CORS to set 137 | */ 138 | public void setCORS(final CORSFilter.Configuration CORS) { 139 | this.CORS = CORS; 140 | } 141 | 142 | /** 143 | * @param defaultPlatform 144 | * the defaultPlatform to set 145 | */ 146 | public void setDefaultPlatform(final Platform defaultPlatform) { 147 | this.defaultPlatform = defaultPlatform; 148 | } 149 | 150 | /** 151 | * @param pipeline 152 | * the pipeline to set 153 | */ 154 | public void setPipeline(final PipelineConfiguration pipeline) { 155 | this.pipeline = pipeline; 156 | } 157 | 158 | /** 159 | * @param produceCoreData 160 | * the produceCoreData to set 161 | */ 162 | public void setProduceCoreData(final boolean produceCoreData) { 163 | this.produceCoreData = produceCoreData; 164 | } 165 | 166 | /** 167 | * @param serializationInclusions 168 | * the serializationInclusions to set 169 | */ 170 | public void setSerializationInclusions(final Include serializationInclusions) { 171 | this.serializationInclusions = serializationInclusions; 172 | } 173 | } 174 | -------------------------------------------------------------------------------- /src/main/java/com/merakianalytics/kernel/KernelContext.java: -------------------------------------------------------------------------------- 1 | package com.merakianalytics.kernel; 2 | 3 | import org.apache.deltaspike.core.api.exclude.Exclude; 4 | 5 | import com.fasterxml.jackson.annotation.JsonInclude.Include; 6 | import com.merakianalytics.datapipelines.DataPipeline; 7 | import com.merakianalytics.kernel.filters.CORSFilter; 8 | import com.merakianalytics.orianna.datapipeline.PipelineConfiguration; 9 | import com.merakianalytics.orianna.datapipeline.riotapi.RiotAPI; 10 | import com.merakianalytics.orianna.types.common.Platform; 11 | 12 | /** 13 | * Holds the application state 14 | */ 15 | @Exclude 16 | public class KernelContext { 17 | private static final boolean DEFAULT_PRODUCE_CORE_DATA = false; 18 | private static final Include DEFAULT_SERIALIZATION_INCLUSIONS = Include.NON_DEFAULT; 19 | 20 | /** 21 | * Creates a new applications state from a {@link com.merakianalytics.kernel.KernelConfiguration} 22 | * 23 | * @param config 24 | * the configuration 25 | * @return the new application state 26 | */ 27 | public static KernelContext fromConfiguration(final KernelConfiguration config) { 28 | final KernelContext context = new KernelContext(); 29 | context.setCORS(config.getCORS()); 30 | context.setDefaultPlatform(config.getDefaultPlatform()); 31 | context.setPipeline(PipelineConfiguration.toPipeline(config.getPipeline())); 32 | context.setProduceCoreData(config.isProduceCoreData()); 33 | context.setSerializationInclusions(config.getSerializationInclusions()); 34 | return context; 35 | } 36 | 37 | private CORSFilter.Configuration CORS = new CORSFilter.Configuration(); 38 | private Platform defaultPlatform = Platform.NORTH_AMERICA; 39 | private DataPipeline pipeline = new DataPipeline(new RiotAPI()); 40 | private boolean produceCoreData = DEFAULT_PRODUCE_CORE_DATA; 41 | private Include serializationInclusions = DEFAULT_SERIALIZATION_INCLUSIONS; 42 | 43 | /** 44 | * @return the cors 45 | */ 46 | public CORSFilter.Configuration getCORS() { 47 | return CORS; 48 | } 49 | 50 | /** 51 | * @return the defaultPlatform 52 | */ 53 | public Platform getDefaultPlatform() { 54 | return defaultPlatform; 55 | } 56 | 57 | /** 58 | * @return the pipeline 59 | */ 60 | public DataPipeline getPipeline() { 61 | return pipeline; 62 | } 63 | 64 | /** 65 | * @return the serializationInclusions 66 | */ 67 | public Include getSerializationInclusions() { 68 | return serializationInclusions; 69 | } 70 | 71 | /** 72 | * @return the produceCoreData 73 | */ 74 | public boolean isProduceCoreData() { 75 | return produceCoreData; 76 | } 77 | 78 | /** 79 | * @param cors 80 | * the cors to set 81 | */ 82 | public void setCORS(final CORSFilter.Configuration CORS) { 83 | this.CORS = CORS; 84 | } 85 | 86 | /** 87 | * @param defaultPlatform 88 | * the defaultPlatform to set 89 | */ 90 | public void setDefaultPlatform(final Platform defaultPlatform) { 91 | this.defaultPlatform = defaultPlatform; 92 | } 93 | 94 | /** 95 | * @param pipeline 96 | * the pipeline to set 97 | */ 98 | public void setPipeline(final DataPipeline pipeline) { 99 | this.pipeline = pipeline; 100 | } 101 | 102 | /** 103 | * @param produceCoreData 104 | * the produceCoreData to set 105 | */ 106 | public void setProduceCoreData(final boolean produceCoreData) { 107 | this.produceCoreData = produceCoreData; 108 | } 109 | 110 | /** 111 | * @param serializationInclusions 112 | * the serializationInclusions to set 113 | */ 114 | public void setSerializationInclusions(final Include serializationInclusions) { 115 | this.serializationInclusions = serializationInclusions; 116 | } 117 | } 118 | -------------------------------------------------------------------------------- /src/main/java/com/merakianalytics/kernel/exceptions/OriannaExceptionMapper.java: -------------------------------------------------------------------------------- 1 | package com.merakianalytics.kernel.exceptions; 2 | 3 | import javax.ws.rs.core.Response; 4 | import javax.ws.rs.ext.ExceptionMapper; 5 | 6 | import org.slf4j.Logger; 7 | import org.slf4j.LoggerFactory; 8 | 9 | import com.merakianalytics.orianna.datapipeline.common.TimeoutException; 10 | import com.merakianalytics.orianna.datapipeline.riotapi.exceptions.BadRequestException; 11 | import com.merakianalytics.orianna.datapipeline.riotapi.exceptions.ForbiddenException; 12 | import com.merakianalytics.orianna.datapipeline.riotapi.exceptions.InternalServerErrorException; 13 | import com.merakianalytics.orianna.datapipeline.riotapi.exceptions.NotFoundException; 14 | import com.merakianalytics.orianna.datapipeline.riotapi.exceptions.RateLimitExceededException; 15 | import com.merakianalytics.orianna.datapipeline.riotapi.exceptions.ServiceUnavailableException; 16 | import com.merakianalytics.orianna.datapipeline.riotapi.exceptions.UnsupportedMediaTypeException; 17 | import com.merakianalytics.orianna.types.common.OriannaException; 18 | 19 | /** 20 | * Handles forwarding HTTP errors from orianna on to the user and proper HTTP 500 behavior on unhandled 21 | * {@link com.merakianalytics.orianna.types.common.OriannaException}s 22 | * 23 | * @see com.merakianalytics.orianna.types.common.OriannaException 24 | */ 25 | public class OriannaExceptionMapper implements ExceptionMapper { 26 | private static final Logger LOGGER = LoggerFactory.getLogger(OriannaExceptionMapper.class); 27 | 28 | /** 29 | * Handling logic for encountered {@link com.merakianalytics.orianna.types.common.OriannaException}s 30 | * 31 | * @param exception 32 | * the exception 33 | * @return a {@link javax.ws.rs.core.Response} with the proper error code and headers set 34 | * @see com.merakianalytics.orianna.types.common.OriannaException 35 | */ 36 | public static Response handle(final OriannaException exception) { 37 | if(exception instanceof TimeoutException) { 38 | final TimeoutException e = (TimeoutException)exception; 39 | switch(e.getType()) { 40 | case HTTP: 41 | LOGGER.debug("Encountered a TimeoutException from orianna on the HTTP request to Riot!", e); 42 | break; 43 | case RATE_LIMITER: 44 | LOGGER.debug("Encountered a TimeoutException from orianna on acquiring the rate limiter!", e); 45 | break; 46 | default: 47 | LOGGER.debug("Encountered a TimeoutException from orianna!", e); 48 | break; 49 | } 50 | return Response.status(Response.Status.GATEWAY_TIMEOUT).header("X-Timeout-Type", e.getType()).build(); 51 | } 52 | 53 | if(exception instanceof BadRequestException) { 54 | final BadRequestException e = (BadRequestException)exception; 55 | LOGGER.error("Encountered a BadRequestException from orianna!", e); 56 | return Response.status(Response.Status.BAD_REQUEST).build(); 57 | } 58 | 59 | if(exception instanceof ForbiddenException) { 60 | final ForbiddenException e = (ForbiddenException)exception; 61 | LOGGER.error("Encountered a ForbiddenException from orianna!", e); 62 | return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); 63 | } 64 | 65 | if(exception instanceof InternalServerErrorException) { 66 | final InternalServerErrorException e = (InternalServerErrorException)exception; 67 | LOGGER.debug("Encountered an InternalServerErrorException from orianna!", e); 68 | return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); 69 | } 70 | 71 | if(exception instanceof NotFoundException) { 72 | final NotFoundException e = (NotFoundException)exception; 73 | LOGGER.debug("Encountered a NotFoundException from orianna!", e); 74 | return Response.status(Response.Status.NOT_FOUND).build(); 75 | } 76 | 77 | if(exception instanceof RateLimitExceededException) { 78 | final RateLimitExceededException e = (RateLimitExceededException)exception; 79 | LOGGER.error("Encountered a RateLimitExceededException from orianna!", e); 80 | return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); 81 | } 82 | 83 | if(exception instanceof ServiceUnavailableException) { 84 | final ServiceUnavailableException e = (ServiceUnavailableException)exception; 85 | LOGGER.info("Encountered a ServiceUnavailableException from orianna!", e); 86 | return Response.status(Response.Status.SERVICE_UNAVAILABLE).build(); 87 | } 88 | 89 | if(exception instanceof UnsupportedMediaTypeException) { 90 | final UnsupportedMediaTypeException e = (UnsupportedMediaTypeException)exception; 91 | LOGGER.error("Encountered a UnsupportedMediaTypeException from orianna!", e); 92 | return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); 93 | } 94 | 95 | LOGGER.error("Encountered an OriannaException from orianna!", exception); 96 | return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); 97 | } 98 | 99 | @Override 100 | public Response toResponse(final OriannaException exception) { 101 | return handle(exception); 102 | } 103 | } 104 | -------------------------------------------------------------------------------- /src/main/java/com/merakianalytics/kernel/exceptions/QueryValidationExceptionMapper.java: -------------------------------------------------------------------------------- 1 | package com.merakianalytics.kernel.exceptions; 2 | 3 | import javax.ws.rs.core.Response; 4 | import javax.ws.rs.ext.ExceptionMapper; 5 | 6 | import org.slf4j.Logger; 7 | import org.slf4j.LoggerFactory; 8 | 9 | import com.merakianalytics.orianna.datapipeline.common.QueryValidationException; 10 | 11 | /** 12 | * Produces HTTP 400 errors on {@link com.merakianalytics.orianna.datapipeline.common.QueryValidationException}s 13 | * 14 | * @see com.merakianalytics.orianna.datapipeline.common.QueryValidationException 15 | */ 16 | public class QueryValidationExceptionMapper implements ExceptionMapper { 17 | private static final Logger LOGGER = LoggerFactory.getLogger(QueryValidationExceptionMapper.class); 18 | 19 | /** 20 | * Handling logic for encountered {@link com.merakianalytics.orianna.datapipeline.common.QueryValidationException}s 21 | * 22 | * @param exception 23 | * the exception 24 | * @return a {@link javax.ws.rs.core.Response} with the proper error code and headers set 25 | * @see com.merakianalytics.orianna.datapipeline.common.QueryValidationException 26 | */ 27 | public static Response handle(final QueryValidationException exception) { 28 | LOGGER.debug("Encountered an QueryValidationException from orianna!", exception); 29 | return Response.status(Response.Status.BAD_REQUEST).build(); 30 | } 31 | 32 | @Override 33 | public Response toResponse(final QueryValidationException exception) { 34 | return handle(exception); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/com/merakianalytics/kernel/filters/CORSFilter.java: -------------------------------------------------------------------------------- 1 | package com.merakianalytics.kernel.filters; 2 | 3 | import javax.inject.Inject; 4 | import javax.ws.rs.container.ContainerRequestContext; 5 | import javax.ws.rs.container.ContainerResponseContext; 6 | import javax.ws.rs.container.ContainerResponseFilter; 7 | 8 | import com.merakianalytics.kernel.KernelContext; 9 | 10 | /** 11 | * Adds CORS headers to responses from the server 12 | */ 13 | public class CORSFilter implements ContainerResponseFilter { 14 | public static class Configuration { 15 | private String allowCredentials = "true"; 16 | private String allowHeaders = "*"; 17 | private String allowMethods = "*"; 18 | private String allowOrigin = "*"; 19 | private String maxAge = "3600"; 20 | 21 | /** 22 | * @return the allowCredentials 23 | */ 24 | public String getAllowCredentials() { 25 | return allowCredentials; 26 | } 27 | 28 | /** 29 | * @return the allowHeaders 30 | */ 31 | public String getAllowHeaders() { 32 | return allowHeaders; 33 | } 34 | 35 | /** 36 | * @return the allowMethods 37 | */ 38 | public String getAllowMethods() { 39 | return allowMethods; 40 | } 41 | 42 | /** 43 | * @return the allowOrigin 44 | */ 45 | public String getAllowOrigin() { 46 | return allowOrigin; 47 | } 48 | 49 | /** 50 | * @return the maxAge 51 | */ 52 | public String getMaxAge() { 53 | return maxAge; 54 | } 55 | 56 | /** 57 | * @param allowCredentials 58 | * the allowCredentials to set 59 | */ 60 | public void setAllowCredentials(final String allowCredentials) { 61 | this.allowCredentials = allowCredentials; 62 | } 63 | 64 | /** 65 | * @param allowHeaders 66 | * the allowHeaders to set 67 | */ 68 | public void setAllowHeaders(final String allowHeaders) { 69 | this.allowHeaders = allowHeaders; 70 | } 71 | 72 | /** 73 | * @param allowMethods 74 | * the allowMethods to set 75 | */ 76 | public void setAllowMethods(final String allowMethods) { 77 | this.allowMethods = allowMethods; 78 | } 79 | 80 | /** 81 | * @param allowOrigin 82 | * the allowOrigin to set 83 | */ 84 | public void setAllowOrigin(final String allowOrigin) { 85 | this.allowOrigin = allowOrigin; 86 | } 87 | 88 | /** 89 | * @param maxAge 90 | * the maxAge to set 91 | */ 92 | public void setMaxAge(final String maxAge) { 93 | this.maxAge = maxAge; 94 | } 95 | } 96 | 97 | @Inject 98 | private KernelContext context; 99 | 100 | @Override 101 | public void filter(final ContainerRequestContext requestContext, final ContainerResponseContext responseContext) { 102 | responseContext.getHeaders().add("Access-Control-Allow-Origin", context.getCORS().getAllowOrigin()); 103 | responseContext.getHeaders().add("Access-Control-Allow-Headers", context.getCORS().getAllowHeaders()); 104 | responseContext.getHeaders().add("Access-Control-Allow-Credentials", context.getCORS().getAllowCredentials()); 105 | responseContext.getHeaders().add("Access-Control-Allow-Methods", context.getCORS().getAllowMethods()); 106 | responseContext.getHeaders().add("Access-Control-Max-Age", context.getCORS().getMaxAge()); 107 | } 108 | } 109 | -------------------------------------------------------------------------------- /src/main/java/com/merakianalytics/kernel/filters/NullResponseFilter.java: -------------------------------------------------------------------------------- 1 | package com.merakianalytics.kernel.filters; 2 | 3 | import javax.ws.rs.container.ContainerRequestContext; 4 | import javax.ws.rs.container.ContainerResponseContext; 5 | import javax.ws.rs.container.ContainerResponseFilter; 6 | import javax.ws.rs.core.Response; 7 | 8 | /** 9 | * Replaces null returns with HTTP 404 errors instead of empty 204s. 10 | */ 11 | public class NullResponseFilter implements ContainerResponseFilter { 12 | @Override 13 | public void filter(final ContainerRequestContext requestContext, final ContainerResponseContext responseContext) { 14 | if(responseContext.getStatus() == 204 && responseContext.getEntity() == null) { 15 | responseContext.setStatusInfo(Response.Status.NOT_FOUND); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/com/merakianalytics/kernel/producers/KernelConfigurationProducer.java: -------------------------------------------------------------------------------- 1 | package com.merakianalytics.kernel.producers; 2 | 3 | import javax.enterprise.context.ApplicationScoped; 4 | import javax.enterprise.inject.Produces; 5 | 6 | import com.merakianalytics.kernel.KernelConfiguration; 7 | 8 | /** 9 | * Loads the configuration and produces it for the application 10 | */ 11 | public class KernelConfigurationProducer { 12 | @Produces 13 | @ApplicationScoped 14 | public static KernelConfiguration produceKernelConfiguration() { 15 | return KernelConfiguration.load(); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/com/merakianalytics/kernel/producers/KernelContextProducer.java: -------------------------------------------------------------------------------- 1 | package com.merakianalytics.kernel.producers; 2 | 3 | import javax.enterprise.context.ApplicationScoped; 4 | import javax.enterprise.inject.Produces; 5 | import javax.inject.Inject; 6 | 7 | import com.merakianalytics.kernel.KernelConfiguration; 8 | import com.merakianalytics.kernel.KernelContext; 9 | 10 | /** 11 | * Produces the application context 12 | */ 13 | public class KernelContextProducer { 14 | @Inject 15 | private KernelConfiguration config; 16 | 17 | @Produces 18 | @ApplicationScoped 19 | public KernelContext produceKernelContext() { 20 | return KernelContext.fromConfiguration(config); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/com/merakianalytics/kernel/providers/JSONProvider.java: -------------------------------------------------------------------------------- 1 | package com.merakianalytics.kernel.providers; 2 | 3 | import javax.annotation.PostConstruct; 4 | import javax.enterprise.context.Dependent; 5 | import javax.inject.Inject; 6 | import javax.ws.rs.ext.ContextResolver; 7 | import javax.ws.rs.ext.Provider; 8 | 9 | import com.fasterxml.jackson.databind.ObjectMapper; 10 | import com.fasterxml.jackson.datatype.joda.JodaModule; 11 | import com.merakianalytics.kernel.KernelContext; 12 | 13 | /** 14 | * Replaces the default JSON serialization to exclude default values when serializing 15 | */ 16 | @Dependent 17 | @Provider 18 | public class JSONProvider implements ContextResolver { 19 | @Inject 20 | private KernelContext context; 21 | 22 | private ObjectMapper mapper; 23 | 24 | @Override 25 | public ObjectMapper getContext(final Class type) { 26 | return mapper; 27 | } 28 | 29 | /** 30 | * The KernelContext won't be injected until after construction so we initialize the mapper then 31 | */ 32 | @PostConstruct 33 | private void initializeMapper() { 34 | mapper = new ObjectMapper().registerModule(new JodaModule()).setSerializationInclusion(context.getSerializationInclusions()); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/com/merakianalytics/kernel/providers/MessagePackProvider.java: -------------------------------------------------------------------------------- 1 | package com.merakianalytics.kernel.providers; 2 | 3 | import java.io.IOException; 4 | import java.io.InputStream; 5 | import java.io.OutputStream; 6 | import java.lang.annotation.Annotation; 7 | import java.lang.reflect.Type; 8 | 9 | import javax.annotation.PostConstruct; 10 | import javax.enterprise.context.Dependent; 11 | import javax.inject.Inject; 12 | import javax.ws.rs.Consumes; 13 | import javax.ws.rs.Produces; 14 | import javax.ws.rs.WebApplicationException; 15 | import javax.ws.rs.core.MediaType; 16 | import javax.ws.rs.core.MultivaluedMap; 17 | import javax.ws.rs.ext.MessageBodyReader; 18 | import javax.ws.rs.ext.MessageBodyWriter; 19 | import javax.ws.rs.ext.Provider; 20 | 21 | import org.msgpack.jackson.dataformat.MessagePackFactory; 22 | 23 | import com.fasterxml.jackson.databind.ObjectMapper; 24 | import com.fasterxml.jackson.datatype.joda.JodaModule; 25 | import com.merakianalytics.kernel.KernelContext; 26 | 27 | /** 28 | * Allows MsgPack serialization. Excludes default values when serializing. 29 | */ 30 | @Dependent 31 | @Provider 32 | @Produces(MessagePackProvider.APPLICATION_MSGPACK) 33 | @Consumes(MessagePackProvider.APPLICATION_MSGPACK) 34 | public class MessagePackProvider implements MessageBodyWriter, MessageBodyReader { 35 | public static final String APPLICATION_MSGPACK = "application/msgpack"; 36 | public static final MediaType MEDIA_TYPE = MediaType.valueOf(APPLICATION_MSGPACK); 37 | 38 | @Inject 39 | private KernelContext context; 40 | 41 | private ObjectMapper mapper; 42 | 43 | /** 44 | * The KernelContext won't be injected until after construction so we initialize the mapper then 45 | */ 46 | @PostConstruct 47 | private void initializeMapper() { 48 | mapper = new ObjectMapper(new MessagePackFactory()).registerModule(new JodaModule()).setSerializationInclusion(context.getSerializationInclusions()); 49 | } 50 | 51 | @Override 52 | public boolean isReadable(final Class type, final Type genericType, final Annotation[] annotations, final MediaType mediaType) { 53 | return mediaType.isCompatible(MEDIA_TYPE); 54 | } 55 | 56 | @Override 57 | public boolean isWriteable(final Class type, final Type genericType, final Annotation[] annotations, final MediaType mediaType) { 58 | return mediaType.isCompatible(MEDIA_TYPE); 59 | } 60 | 61 | @Override 62 | public T readFrom(final Class type, final Type genericType, final Annotation[] annotations, final MediaType mediaType, 63 | final MultivaluedMap httpHeaders, final InputStream entityStream) throws IOException, WebApplicationException { 64 | return mapper.readValue(entityStream, type); 65 | } 66 | 67 | @Override 68 | public void writeTo(final T object, final Class type, final Type genericType, final Annotation[] annotations, final MediaType mediaType, 69 | final MultivaluedMap httpHeaders, final OutputStream outputStream) throws IOException, WebApplicationException { 70 | outputStream.write(mapper.writeValueAsBytes(object)); 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /src/main/java/com/merakianalytics/kernel/riotapi/RiotAPIService.java: -------------------------------------------------------------------------------- 1 | package com.merakianalytics.kernel.riotapi; 2 | 3 | import javax.inject.Inject; 4 | import javax.ws.rs.Produces; 5 | import javax.ws.rs.core.MediaType; 6 | 7 | import com.merakianalytics.kernel.KernelContext; 8 | import com.merakianalytics.kernel.providers.MessagePackProvider; 9 | 10 | /** 11 | * A proxy service for the Riot API 12 | */ 13 | @Produces({MediaType.APPLICATION_JSON, MessagePackProvider.APPLICATION_MSGPACK}) 14 | public abstract class RiotAPIService { 15 | @Inject 16 | protected KernelContext context; 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/com/merakianalytics/kernel/riotapi/data/ChampionAPI.java: -------------------------------------------------------------------------------- 1 | package com.merakianalytics.kernel.riotapi.data; 2 | 3 | import java.net.HttpURLConnection; 4 | import java.util.Map; 5 | 6 | import javax.ws.rs.GET; 7 | import javax.ws.rs.Path; 8 | import javax.ws.rs.QueryParam; 9 | import javax.ws.rs.WebApplicationException; 10 | 11 | import org.jboss.resteasy.annotations.GZIP; 12 | 13 | import com.google.common.collect.ImmutableMap; 14 | import com.merakianalytics.kernel.riotapi.RiotAPIService; 15 | import com.merakianalytics.orianna.types.common.Platform; 16 | import com.merakianalytics.orianna.types.data.champion.ChampionRotation; 17 | 18 | import io.swagger.annotations.Api; 19 | 20 | /** 21 | * The Champion API proxy for the Riot API 22 | * 23 | * @see https://developer.riotgames.com/api-methods/#champion-v3 24 | */ 25 | @Path("/platform/v3") 26 | @Api("Champion API") 27 | @GZIP 28 | public class ChampionAPI extends RiotAPIService { 29 | /** 30 | * /lol/platform/v3/champion-rotations 31 | * 32 | * @see https://developer.riotgames.com/api-methods/#champion-v3/GET_getChampionInfo 33 | * 34 | * @param platform 35 | * the tag for the {@link com.merakianalytics.orianna.types.common.Platform} to get data from. If null, the default 36 | * {@link com.merakianalytics.orianna.types.common.Platform} will be used. 37 | * @return {@link com.merakianalytics.orianna.types.data.champion.ChampionRotation} 38 | */ 39 | @Path("/champion-rotations") 40 | @GET 41 | public ChampionRotation getChampionRotation(@QueryParam("platform") final String platformTag) { 42 | final Platform platform = platformTag != null ? Platform.withTag(platformTag.toUpperCase()) : context.getDefaultPlatform(); 43 | if(platform == null) { 44 | throw new WebApplicationException(platformTag + " is not a valid platform!", HttpURLConnection.HTTP_BAD_REQUEST); 45 | } 46 | 47 | final Map query = ImmutableMap. builder() 48 | .put("platform", platform) 49 | .build(); 50 | 51 | return context.getPipeline().get(ChampionRotation.class, query); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/main/java/com/merakianalytics/kernel/riotapi/data/ChampionMasteryAPI.java: -------------------------------------------------------------------------------- 1 | package com.merakianalytics.kernel.riotapi.data; 2 | 3 | import java.net.HttpURLConnection; 4 | import java.util.Map; 5 | 6 | import javax.ws.rs.GET; 7 | import javax.ws.rs.Path; 8 | import javax.ws.rs.PathParam; 9 | import javax.ws.rs.QueryParam; 10 | import javax.ws.rs.WebApplicationException; 11 | 12 | import org.jboss.resteasy.annotations.GZIP; 13 | 14 | import com.google.common.collect.ImmutableMap; 15 | import com.merakianalytics.kernel.riotapi.RiotAPIService; 16 | import com.merakianalytics.orianna.types.common.Platform; 17 | import com.merakianalytics.orianna.types.data.championmastery.ChampionMasteries; 18 | import com.merakianalytics.orianna.types.data.championmastery.ChampionMastery; 19 | import com.merakianalytics.orianna.types.data.championmastery.ChampionMasteryScore; 20 | 21 | import io.swagger.annotations.Api; 22 | 23 | /** 24 | * The Champion Mastery API proxy for the Riot API 25 | * 26 | * @see https://developer.riotgames.com/api-methods/#champion-mastery-v4 27 | */ 28 | @Path("/champion-mastery/v4") 29 | @Api("Champion Mastery API") 30 | @GZIP 31 | public class ChampionMasteryAPI extends RiotAPIService { 32 | /** 33 | * /lol/champion-mastery/v4/champion-masteries/by-summoner/{encryptedSummonerId} 34 | * 35 | * @see https://developer.riotgames.com/api-methods/#champion-mastery-v4/GET_getAllChampionMasteries 36 | * 37 | * @param platform 38 | * the tag for the {@link com.merakianalytics.orianna.types.common.Platform} to get data from. If null, the default 39 | * {@link com.merakianalytics.orianna.types.common.Platform} will be used. 40 | * @param encryptedSummonerId 41 | * the summoner's encrypted id 42 | * @return {@link com.merakianalytics.orianna.types.data.championmastery.ChampionMasteries} 43 | */ 44 | @Path("/champion-masteries/by-summoner/{encryptedSummonerId}") 45 | @GET 46 | public ChampionMasteries getAllChampionMasteries(@QueryParam("platform") final String platformTag, 47 | @PathParam("encryptedSummonerId") final String encryptedSummonerId) { 48 | final Platform platform = platformTag != null ? Platform.withTag(platformTag.toUpperCase()) : context.getDefaultPlatform(); 49 | if(platform == null) { 50 | throw new WebApplicationException(platformTag + " is not a valid platform!", HttpURLConnection.HTTP_BAD_REQUEST); 51 | } 52 | 53 | final Map query = ImmutableMap. builder() 54 | .put("platform", platform) 55 | .put("summonerId", encryptedSummonerId) 56 | .build(); 57 | 58 | return context.getPipeline().get(ChampionMasteries.class, query); 59 | } 60 | 61 | /** 62 | * /lol/champion-mastery/v4/champion-masteries/by-summoner/{encryptedSummonerId}/by-champion/{championId} 63 | * 64 | * @see https://developer.riotgames.com/api-methods/#champion-mastery-v4/GET_getChampionMastery 65 | * 66 | * @param platform 67 | * the tag for the {@link com.merakianalytics.orianna.types.common.Platform} to get data from. If null, the default 68 | * {@link com.merakianalytics.orianna.types.common.Platform} will be used. 69 | * @param encryptedSummonerId 70 | * the summoner's encrypted id 71 | * @param championId 72 | * the champion's id 73 | * @return {@link com.merakianalytics.orianna.types.data.championmastery.ChampionMastery} 74 | */ 75 | @Path("/champion-masteries/by-summoner/{encryptedSummonerId}/by-champion/{championId}") 76 | @GET 77 | public ChampionMastery getChampionMastery(@QueryParam("platform") final String platformTag, 78 | @PathParam("encryptedSummonerId") final String encryptedSummonerId, 79 | @PathParam("championId") final int championId) { 80 | final Platform platform = platformTag != null ? Platform.withTag(platformTag.toUpperCase()) : context.getDefaultPlatform(); 81 | if(platform == null) { 82 | throw new WebApplicationException(platformTag + " is not a valid platform!", HttpURLConnection.HTTP_BAD_REQUEST); 83 | } 84 | 85 | final Map query = ImmutableMap. builder() 86 | .put("platform", platform) 87 | .put("summonerId", encryptedSummonerId) 88 | .put("championId", championId) 89 | .build(); 90 | 91 | return context.getPipeline().get(ChampionMastery.class, query); 92 | } 93 | 94 | /** 95 | * /lol/champion-mastery/v4/scores/by-summoner/{encryptedSummonerId} 96 | * 97 | * @see https://developer.riotgames.com/api-methods/#champion-mastery-v4/GET_getChampionMasteryScore 98 | * 99 | * @param platform 100 | * the tag for the {@link com.merakianalytics.orianna.types.common.Platform} to get data from. If null, the default 101 | * {@link com.merakianalytics.orianna.types.common.Platform} will be used. 102 | * @param encryptedSummonerId 103 | * the summoner's encrypted id 104 | * @return {@link com.merakianalytics.orianna.types.data.championmastery.ChampionMasteryScore} 105 | */ 106 | @Path("/scores/by-summoner/{encryptedSummonerId}") 107 | @GET 108 | public ChampionMasteryScore getChampionMasteryScore(@QueryParam("platform") final String platformTag, 109 | @PathParam("encryptedSummonerId") final String encryptedSummonerId) { 110 | final Platform platform = platformTag != null ? Platform.withTag(platformTag.toUpperCase()) : context.getDefaultPlatform(); 111 | if(platform == null) { 112 | throw new WebApplicationException(platformTag + " is not a valid platform!", HttpURLConnection.HTTP_BAD_REQUEST); 113 | } 114 | 115 | final Map query = ImmutableMap. builder() 116 | .put("platform", platform) 117 | .put("summonerId", encryptedSummonerId) 118 | .build(); 119 | 120 | return context.getPipeline().get(ChampionMasteryScore.class, query); 121 | } 122 | } 123 | -------------------------------------------------------------------------------- /src/main/java/com/merakianalytics/kernel/riotapi/data/LeagueAPI.java: -------------------------------------------------------------------------------- 1 | package com.merakianalytics.kernel.riotapi.data; 2 | 3 | import java.net.HttpURLConnection; 4 | import java.util.Map; 5 | 6 | import javax.ws.rs.GET; 7 | import javax.ws.rs.Path; 8 | import javax.ws.rs.PathParam; 9 | import javax.ws.rs.QueryParam; 10 | import javax.ws.rs.WebApplicationException; 11 | 12 | import org.jboss.resteasy.annotations.GZIP; 13 | 14 | import com.google.common.collect.ImmutableMap; 15 | import com.merakianalytics.kernel.riotapi.RiotAPIService; 16 | import com.merakianalytics.orianna.types.common.Platform; 17 | import com.merakianalytics.orianna.types.common.Queue; 18 | import com.merakianalytics.orianna.types.common.Tier; 19 | import com.merakianalytics.orianna.types.data.league.League; 20 | import com.merakianalytics.orianna.types.data.league.LeaguePositions; 21 | 22 | import io.swagger.annotations.Api; 23 | 24 | /** 25 | * The League API proxy for the Riot API 26 | * 27 | * @see https://developer.riotgames.com/api-methods/#league-v4 28 | */ 29 | @Path("/league/v4") 30 | @Api("League API") 31 | @GZIP 32 | public class LeagueAPI extends RiotAPIService { 33 | /** 34 | * /lol/league/v4/challengerleagues/by-queue/{queue} 35 | * 36 | * @see https://developer.riotgames.com/api-methods/#league-v4/GET_getChallengerLeague 37 | * 38 | * @param platform 39 | * the tag for the {@link com.merakianalytics.orianna.types.common.Platform} to get data from. If null, the default 40 | * {@link com.merakianalytics.orianna.types.common.Platform} will be used. 41 | * @param queue 42 | * the {@link com.merakianalytics.orianna.types.common.Queue} 43 | * @return {@link com.merakianalytics.orianna.types.data.league.League} 44 | */ 45 | @Path("/challengerleagues/by-queue/{queue}") 46 | @GET 47 | public League getChallengerLeague(@QueryParam("platform") final String platformTag, @PathParam("queue") final String queueTag) { 48 | final Platform platform = platformTag != null ? Platform.withTag(platformTag.toUpperCase()) : context.getDefaultPlatform(); 49 | if(platform == null) { 50 | throw new WebApplicationException(platformTag + " is not a valid platform!", HttpURLConnection.HTTP_BAD_REQUEST); 51 | } 52 | 53 | final Queue queue = Queue.withTag(queueTag); 54 | if(queue == null) { 55 | throw new WebApplicationException(queueTag + " is not a valid queue!", HttpURLConnection.HTTP_BAD_REQUEST); 56 | } 57 | 58 | final Map query = ImmutableMap. builder() 59 | .put("platform", platform) 60 | .put("queue", queue) 61 | .put("tier", Tier.CHALLENGER) 62 | .build(); 63 | 64 | return context.getPipeline().get(League.class, query); 65 | } 66 | 67 | /** 68 | * /lol/league/v4/grandmasterleagues/by-queue/{queue} 69 | * 70 | * @see https://developer.riotgames.com/api-methods/#league-v4/GET_getGrandmasterLeague 71 | * 72 | * @param platform 73 | * the tag for the {@link com.merakianalytics.orianna.types.common.Platform} to get data from. If null, the default 74 | * {@link com.merakianalytics.orianna.types.common.Platform} will be used. 75 | * @param queue 76 | * the {@link com.merakianalytics.orianna.types.common.Queue} 77 | * @return {@link com.merakianalytics.orianna.types.data.league.League} 78 | */ 79 | @Path("/grandmasterleagues/by-queue/{queue}") 80 | @GET 81 | public League getGrandmasterLeague(@QueryParam("platform") final String platformTag, @PathParam("queue") final String queueTag) { 82 | final Platform platform = platformTag != null ? Platform.withTag(platformTag.toUpperCase()) : context.getDefaultPlatform(); 83 | if(platform == null) { 84 | throw new WebApplicationException(platformTag + " is not a valid platform!", HttpURLConnection.HTTP_BAD_REQUEST); 85 | } 86 | 87 | final Queue queue = Queue.withTag(queueTag); 88 | if(queue == null) { 89 | throw new WebApplicationException(queueTag + " is not a valid queue!", HttpURLConnection.HTTP_BAD_REQUEST); 90 | } 91 | 92 | final Map query = ImmutableMap. builder() 93 | .put("platform", platform) 94 | .put("queue", queue) 95 | .put("tier", Tier.GRANDMASTER) 96 | .build(); 97 | 98 | return context.getPipeline().get(League.class, query); 99 | } 100 | 101 | /** 102 | * /lol/league/v4/leagues/{leagueId} 103 | * 104 | * @see https://developer.riotgames.com/api-methods/#league-v4/GET_getLeagueById 105 | * 106 | * @param platform 107 | * the tag for the {@link com.merakianalytics.orianna.types.common.Platform} to get data from. If null, the default 108 | * {@link com.merakianalytics.orianna.types.common.Platform} will be used. 109 | * @param leagueId 110 | * the league's id 111 | * @return {@link com.merakianalytics.orianna.types.data.league.League} 112 | */ 113 | @Path("/leagues/{leagueId}") 114 | @GET 115 | public League getLeagueById(@QueryParam("platform") final String platformTag, @PathParam("leagueId") final String leagueId) { 116 | final Platform platform = platformTag != null ? Platform.withTag(platformTag.toUpperCase()) : context.getDefaultPlatform(); 117 | if(platform == null) { 118 | throw new WebApplicationException(platformTag + " is not a valid platform!", HttpURLConnection.HTTP_BAD_REQUEST); 119 | } 120 | 121 | final Map query = ImmutableMap. builder() 122 | .put("platform", platform) 123 | .put("leagueId", leagueId) 124 | .build(); 125 | 126 | return context.getPipeline().get(League.class, query); 127 | } 128 | 129 | /** 130 | * /lol/league/v4/entries/by-summoner/{encryptedSummonerId} 131 | * 132 | * @see https://developer.riotgames.com/api-methods/#league-v4/GET_getLeagueEntries 133 | * 134 | * @param platform 135 | * the tag for the {@link com.merakianalytics.orianna.types.common.Platform} to get data from. If null, the default 136 | * {@link com.merakianalytics.orianna.types.common.Platform} will be used. 137 | * @param encryptedSummonerId 138 | * the summoner's encrypted id 139 | * @return {@link com.merakianalytics.orianna.types.data.league.LeaguePositions} 140 | */ 141 | @Path("/entries/by-summoner/{encryptedSummonerId}") 142 | @GET 143 | public LeaguePositions getLeagueEntries(@QueryParam("platform") final String platformTag, 144 | @PathParam("encryptedSummonerId") final String encryptedSummonerId) { 145 | final Platform platform = platformTag != null ? Platform.withTag(platformTag.toUpperCase()) : context.getDefaultPlatform(); 146 | if(platform == null) { 147 | throw new WebApplicationException(platformTag + " is not a valid platform!", HttpURLConnection.HTTP_BAD_REQUEST); 148 | } 149 | 150 | final Map query = ImmutableMap. builder() 151 | .put("platform", platform) 152 | .put("summonerId", encryptedSummonerId) 153 | .build(); 154 | 155 | return context.getPipeline().get(LeaguePositions.class, query); 156 | } 157 | 158 | /** 159 | * /lol/league/v4/masterleagues/by-queue/{queue} 160 | * 161 | * @see https://developer.riotgames.com/api-methods/#league-v4/GET_getMasterLeague 162 | * 163 | * @param platform 164 | * the tag for the {@link com.merakianalytics.orianna.types.common.Platform} to get data from. If null, the default 165 | * {@link com.merakianalytics.orianna.types.common.Platform} will be used. 166 | * @param queue 167 | * the {@link com.merakianalytics.orianna.types.common.Queue} 168 | * @return {@link com.merakianalytics.orianna.types.data.league.League} 169 | */ 170 | @Path("/masterleagues/by-queue/{queue}") 171 | @GET 172 | public League getMasterLeague(@QueryParam("platform") final String platformTag, @PathParam("queue") final String queueTag) { 173 | final Platform platform = platformTag != null ? Platform.withTag(platformTag.toUpperCase()) : context.getDefaultPlatform(); 174 | if(platform == null) { 175 | throw new WebApplicationException(platformTag + " is not a valid platform!", HttpURLConnection.HTTP_BAD_REQUEST); 176 | } 177 | 178 | final Queue queue = Queue.withTag(queueTag); 179 | if(queue == null) { 180 | throw new WebApplicationException(queueTag + " is not a valid queue!", HttpURLConnection.HTTP_BAD_REQUEST); 181 | } 182 | 183 | final Map query = ImmutableMap. builder() 184 | .put("platform", platform) 185 | .put("queue", queue) 186 | .put("tier", Tier.MASTER) 187 | .build(); 188 | 189 | return context.getPipeline().get(League.class, query); 190 | } 191 | } 192 | -------------------------------------------------------------------------------- /src/main/java/com/merakianalytics/kernel/riotapi/data/MatchAPI.java: -------------------------------------------------------------------------------- 1 | package com.merakianalytics.kernel.riotapi.data; 2 | 3 | import java.net.HttpURLConnection; 4 | import java.util.Map; 5 | import java.util.Set; 6 | 7 | import javax.ws.rs.DefaultValue; 8 | import javax.ws.rs.GET; 9 | import javax.ws.rs.Path; 10 | import javax.ws.rs.PathParam; 11 | import javax.ws.rs.QueryParam; 12 | import javax.ws.rs.WebApplicationException; 13 | 14 | import org.jboss.resteasy.annotations.GZIP; 15 | 16 | import com.google.common.collect.ImmutableMap; 17 | import com.merakianalytics.kernel.riotapi.RiotAPIService; 18 | import com.merakianalytics.orianna.types.common.Platform; 19 | import com.merakianalytics.orianna.types.data.match.Match; 20 | import com.merakianalytics.orianna.types.data.match.MatchList; 21 | import com.merakianalytics.orianna.types.data.match.Timeline; 22 | import com.merakianalytics.orianna.types.data.match.TournamentMatches; 23 | 24 | import io.swagger.annotations.Api; 25 | 26 | /** 27 | * The Match API proxy for the Riot API 28 | * 29 | * @see https://developer.riotgames.com/api-methods/#match-v4 30 | */ 31 | @Path("/match/v4") 32 | @Api("Match API") 33 | @GZIP 34 | public class MatchAPI extends RiotAPIService { 35 | /** 36 | * /lol/match/v4/matches/{matchId} 37 | * 38 | * @see https://developer.riotgames.com/api-methods/#match-v4/GET_getMatch 39 | * 40 | * @param platform 41 | * the tag for the {@link com.merakianalytics.orianna.types.common.Platform} to get data from. If null, the default 42 | * {@link com.merakianalytics.orianna.types.common.Platform} will be used. 43 | * @param matchId 44 | * the match's id 45 | * @return {@link com.merakianalytics.orianna.types.data.match.Match} 46 | */ 47 | @Path("/matches/{matchId}") 48 | @GET 49 | public Match getMatch(@QueryParam("platform") final String platformTag, @PathParam("matchId") final long matchId) { 50 | final Platform platform = platformTag != null ? Platform.withTag(platformTag.toUpperCase()) : context.getDefaultPlatform(); 51 | 52 | final Map query = ImmutableMap. builder() 53 | .put("platform", platform) 54 | .put("matchId", matchId) 55 | .build(); 56 | 57 | return context.getPipeline().get(Match.class, query); 58 | } 59 | 60 | /** 61 | * /lol/match/v4/matches/{matchId}/by-tournament-code/{tournamentCode} 62 | * 63 | * @see https://developer.riotgames.com/api-methods/#match-v4/GET_getMatchByTournamentCode 64 | * 65 | * @param platform 66 | * the tag for the {@link com.merakianalytics.orianna.types.common.Platform} to get data from. If null, the default 67 | * {@link com.merakianalytics.orianna.types.common.Platform} will be used. 68 | * @param matchId 69 | * the match's id 70 | * @param tournamentCode 71 | * the tournament code 72 | * @return {@link com.merakianalytics.orianna.types.data.match.Match} 73 | */ 74 | @Path("/matches/{matchId}/by-tournament-code/{tournamentCode}") 75 | @GET 76 | public Match getMatchByTournamentCode(@QueryParam("platform") final String platformTag, @PathParam("matchId") final long matchId, 77 | @PathParam("tournamentCode") final String tournamentCode) { 78 | final Platform platform = platformTag != null ? Platform.withTag(platformTag.toUpperCase()) : context.getDefaultPlatform(); 79 | 80 | final Map query = ImmutableMap. builder() 81 | .put("platform", platform) 82 | .put("matchId", matchId) 83 | .put("tournamentCode", tournamentCode) 84 | .build(); 85 | 86 | return context.getPipeline().get(Match.class, query); 87 | } 88 | 89 | /** 90 | * /lol/match/v4/matches/by-tournament-code/{tournamentCode}/ids 91 | * 92 | * @see https://developer.riotgames.com/api-methods/#match-v4/GET_getMatchIdsByTournamentCode 93 | * 94 | * @param platform 95 | * the tag for the {@link com.merakianalytics.orianna.types.common.Platform} to get data from. If null, the default 96 | * {@link com.merakianalytics.orianna.types.common.Platform} will be used. 97 | * @param tournamentCode 98 | * the tournament code 99 | * @return {@link com.merakianalytics.orianna.types.data.match.TournamentMatches} 100 | */ 101 | @Path("/matches/by-tournament-code/{tournamentCode}/ids") 102 | @GET 103 | public TournamentMatches getMatchIdsByTournamentCode(@QueryParam("platform") final String platformTag, 104 | @PathParam("tournamentCode") final String tournamentCode) { 105 | final Platform platform = platformTag != null ? Platform.withTag(platformTag.toUpperCase()) : context.getDefaultPlatform(); 106 | 107 | final Map query = ImmutableMap. builder() 108 | .put("platform", platform) 109 | .put("tournamentCode", tournamentCode) 110 | .build(); 111 | 112 | return context.getPipeline().get(TournamentMatches.class, query); 113 | } 114 | 115 | /** 116 | * /lol/match/v4/matchlists/by-account/{encryptedAccountId} 117 | * 118 | * @see https://developer.riotgames.com/api-methods/#match-v4/GET_getMatchlist 119 | * 120 | * @param platform 121 | * the tag for the {@link com.merakianalytics.orianna.types.common.Platform} to get data from. If null, the default 122 | * {@link com.merakianalytics.orianna.types.common.Platform} will be used. 123 | * @param encryptedAccountId 124 | * the account's encrpyed id 125 | * @param queue 126 | * the ids of the queues 127 | * @param endTime 128 | * the latest time for the query 129 | * @param beginIndex 130 | * the first result to return 131 | * @param beginTime 132 | * the earliest time for the query 133 | * @param season 134 | * the ids of the seasons 135 | * @param champion 136 | * the ids of the champions 137 | * @param endIndex 138 | * the last result to return 139 | * @return {@link com.merakianalytics.orianna.types.data.match.MatchList} 140 | */ 141 | @Path("/matchlists/by-account/{encryptedAccountId}") 142 | @GET 143 | public MatchList getMatchlist(@QueryParam("platform") final String platformTag, @PathParam("encryptedAccountId") final String encryptedAccountId, 144 | @QueryParam("queue") final Set queue, @QueryParam("endTime") @DefaultValue("-1") final long endTime, 145 | @QueryParam("beginIndex") @DefaultValue("-1") final int beginIndex, @QueryParam("beginTime") @DefaultValue("-1") final long beginTime, 146 | @QueryParam("season") final Set season, @QueryParam("champion") final Set champion, 147 | @QueryParam("endIndex") @DefaultValue("-1") final int endIndex) { 148 | final Platform platform = platformTag != null ? Platform.withTag(platformTag.toUpperCase()) : context.getDefaultPlatform(); 149 | 150 | final ImmutableMap.Builder builder = ImmutableMap.builder(); 151 | builder.put("platform", platform); 152 | builder.put("accountId", encryptedAccountId); 153 | 154 | if(queue != null) { 155 | builder.put("queues", queue); 156 | } 157 | 158 | if(endTime != -1L) { 159 | builder.put("endTime", endTime); 160 | } 161 | 162 | if(beginIndex != -1) { 163 | builder.put("beginIndex", beginIndex); 164 | } 165 | 166 | if(beginTime != -1L) { 167 | builder.put("beginTime", beginTime); 168 | } 169 | 170 | if(season != null) { 171 | builder.put("seasons", season); 172 | } 173 | 174 | if(champion != null) { 175 | builder.put("champions", champion); 176 | } 177 | 178 | if(endIndex != -1) { 179 | builder.put("endIndex", endIndex); 180 | } 181 | 182 | return context.getPipeline().get(MatchList.class, builder.build()); 183 | } 184 | 185 | /** 186 | * /lol/match/v4/timelines/by-match/{matchId} 187 | * 188 | * @see https://developer.riotgames.com/api-methods/#match-v4/GET_getMatchTimeline 189 | * 190 | * @param platform 191 | * the tag for the {@link com.merakianalytics.orianna.types.common.Platform} to get data from. If null, the default 192 | * {@link com.merakianalytics.orianna.types.common.Platform} will be used. 193 | * @param matchId 194 | * the match's id 195 | * @return {@link com.merakianalytics.orianna.types.data.match.Timeline} 196 | */ 197 | @Path("/timelines/by-match/{matchId}") 198 | @GET 199 | public Timeline getMatchTimeline(@QueryParam("platform") final String platformTag, @PathParam("matchId") final long matchId) { 200 | final Platform platform = platformTag != null ? Platform.withTag(platformTag.toUpperCase()) : context.getDefaultPlatform(); 201 | if(platform == null) { 202 | throw new WebApplicationException(platformTag + " is not a valid platform!", HttpURLConnection.HTTP_BAD_REQUEST); 203 | } 204 | 205 | final Map query = ImmutableMap. builder() 206 | .put("platform", platform) 207 | .put("matchId", matchId) 208 | .build(); 209 | 210 | return context.getPipeline().get(Timeline.class, query); 211 | } 212 | } 213 | -------------------------------------------------------------------------------- /src/main/java/com/merakianalytics/kernel/riotapi/data/SpectatorAPI.java: -------------------------------------------------------------------------------- 1 | package com.merakianalytics.kernel.riotapi.data; 2 | 3 | import java.net.HttpURLConnection; 4 | import java.util.Map; 5 | 6 | import javax.ws.rs.GET; 7 | import javax.ws.rs.Path; 8 | import javax.ws.rs.PathParam; 9 | import javax.ws.rs.QueryParam; 10 | import javax.ws.rs.WebApplicationException; 11 | 12 | import org.jboss.resteasy.annotations.GZIP; 13 | 14 | import com.google.common.collect.ImmutableMap; 15 | import com.merakianalytics.kernel.riotapi.RiotAPIService; 16 | import com.merakianalytics.orianna.types.common.Platform; 17 | import com.merakianalytics.orianna.types.data.spectator.CurrentMatch; 18 | import com.merakianalytics.orianna.types.data.spectator.FeaturedMatches; 19 | 20 | import io.swagger.annotations.Api; 21 | 22 | /** 23 | * The Spectator API proxy for the Riot API 24 | * 25 | * @see https://developer.riotgames.com/api-methods/#spectator-v4 26 | */ 27 | @Path("/spectator/v4") 28 | @Api("Spectator API") 29 | @GZIP 30 | public class SpectatorAPI extends RiotAPIService { 31 | /** 32 | * /lol/spectator/v4/active-games/by-summoner/{encrpyedSummonerId} 33 | * 34 | * @see https://developer.riotgames.com/api-methods/#spectator-v4/GET_getCurrentGameInfoBySummoner 35 | * 36 | * @param platform 37 | * the tag for the {@link com.merakianalytics.orianna.types.common.Platform} to get data from. If null, the default 38 | * {@link com.merakianalytics.orianna.types.common.Platform} will be used. 39 | * @param encrpyedSummonerId 40 | * the summoner's encrypted id 41 | * @return {@link com.merakianalytics.orianna.types.data.spectator.CurrentMatch} 42 | */ 43 | @Path("/active-games/by-summoner/{encryptedSummonerId}") 44 | @GET 45 | public CurrentMatch getCurrentGameInfoBySummoner(@QueryParam("platform") final String platformTag, 46 | @PathParam("encryptedSummonerId") final String encryptedSummonerId) { 47 | final Platform platform = platformTag != null ? Platform.withTag(platformTag.toUpperCase()) : context.getDefaultPlatform(); 48 | if(platform == null) { 49 | throw new WebApplicationException(platformTag + " is not a valid platform!", HttpURLConnection.HTTP_BAD_REQUEST); 50 | } 51 | 52 | final Map query = ImmutableMap. builder() 53 | .put("platform", platform) 54 | .put("summonerId", encryptedSummonerId) 55 | .build(); 56 | 57 | return context.getPipeline().get(CurrentMatch.class, query); 58 | } 59 | 60 | /** 61 | * /lol/spectator/v4/featured-games 62 | * 63 | * @see https://developer.riotgames.com/api-methods/#spectator-v4/GET_getFeaturedGames 64 | * 65 | * @param platform 66 | * the tag for the {@link com.merakianalytics.orianna.types.common.Platform} to get data from. If null, the default 67 | * {@link com.merakianalytics.orianna.types.common.Platform} will be used. 68 | * @return {@link com.merakianalytics.orianna.types.data.spectator.FeaturedMatches} 69 | */ 70 | @Path("/featured-games") 71 | @GET 72 | public FeaturedMatches getFeaturedGames(@QueryParam("platform") final String platformTag) { 73 | final Platform platform = platformTag != null ? Platform.withTag(platformTag.toUpperCase()) : context.getDefaultPlatform(); 74 | if(platform == null) { 75 | throw new WebApplicationException(platformTag + " is not a valid platform!", HttpURLConnection.HTTP_BAD_REQUEST); 76 | } 77 | 78 | final Map query = ImmutableMap. builder() 79 | .put("platform", platform) 80 | .build(); 81 | 82 | return context.getPipeline().get(FeaturedMatches.class, query); 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /src/main/java/com/merakianalytics/kernel/riotapi/data/StatusAPI.java: -------------------------------------------------------------------------------- 1 | package com.merakianalytics.kernel.riotapi.data; 2 | 3 | import java.net.HttpURLConnection; 4 | import java.util.Map; 5 | 6 | import javax.ws.rs.GET; 7 | import javax.ws.rs.Path; 8 | import javax.ws.rs.QueryParam; 9 | import javax.ws.rs.WebApplicationException; 10 | 11 | import org.jboss.resteasy.annotations.GZIP; 12 | 13 | import com.google.common.collect.ImmutableMap; 14 | import com.merakianalytics.kernel.riotapi.RiotAPIService; 15 | import com.merakianalytics.orianna.types.common.Platform; 16 | import com.merakianalytics.orianna.types.data.status.ShardStatus; 17 | 18 | import io.swagger.annotations.Api; 19 | 20 | /** 21 | * The Status API proxy for the Riot API 22 | * 23 | * @see https://developer.riotgames.com/api-methods/#spectator-v3 24 | */ 25 | @Path("/status/v3") 26 | @Api("Status API") 27 | @GZIP 28 | public class StatusAPI extends RiotAPIService { 29 | /** 30 | * /lol/status/v3/shard-data 31 | * 32 | * @see https://developer.riotgames.com/api-methods/#lol-status-v3/GET_getShardData 33 | * 34 | * @param platform 35 | * the tag for the {@link com.merakianalytics.orianna.types.common.Platform} to get data from. If null, the default 36 | * {@link com.merakianalytics.orianna.types.common.Platform} will be used. 37 | * @return {@link com.merakianalytics.orianna.types.data.status.ShardStatus} 38 | */ 39 | @Path("/shard-data") 40 | @GET 41 | public ShardStatus getShardData(@QueryParam("platform") final String platformTag) { 42 | final Platform platform = platformTag != null ? Platform.withTag(platformTag.toUpperCase()) : context.getDefaultPlatform(); 43 | if(platform == null) { 44 | throw new WebApplicationException(platformTag + " is not a valid platform!", HttpURLConnection.HTTP_BAD_REQUEST); 45 | } 46 | 47 | final Map query = ImmutableMap. builder() 48 | .put("platform", platform) 49 | .build(); 50 | 51 | return context.getPipeline().get(ShardStatus.class, query); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/main/java/com/merakianalytics/kernel/riotapi/data/SummonerAPI.java: -------------------------------------------------------------------------------- 1 | package com.merakianalytics.kernel.riotapi.data; 2 | 3 | import java.net.HttpURLConnection; 4 | import java.util.Map; 5 | 6 | import javax.ws.rs.GET; 7 | import javax.ws.rs.Path; 8 | import javax.ws.rs.PathParam; 9 | import javax.ws.rs.QueryParam; 10 | import javax.ws.rs.WebApplicationException; 11 | 12 | import org.jboss.resteasy.annotations.GZIP; 13 | 14 | import com.google.common.collect.ImmutableMap; 15 | import com.merakianalytics.kernel.riotapi.RiotAPIService; 16 | import com.merakianalytics.orianna.types.common.Platform; 17 | import com.merakianalytics.orianna.types.data.summoner.Summoner; 18 | 19 | import io.swagger.annotations.Api; 20 | 21 | /** 22 | * The Summoner API proxy for the Riot API 23 | * 24 | * @see https://developer.riotgames.com/api-methods/#summoner-v4 25 | */ 26 | @Path("/summoner/v4") 27 | @Api("Summoner API") 28 | @GZIP 29 | public class SummonerAPI extends RiotAPIService { 30 | /** 31 | * /lol/summoner/v4/summoners/by-account/{encryptedAccountId} 32 | * 33 | * @see https://developer.riotgames.com/api-methods/#summoner-v4/GET_getByAccountId 34 | * 35 | * @param platform 36 | * the tag for the {@link com.merakianalytics.orianna.types.common.Platform} to get data from. If null, the default 37 | * {@link com.merakianalytics.orianna.types.common.Platform} will be used. 38 | * @param encryptedAccountId 39 | * the account's encrypted id 40 | * @return {@link com.merakianalytics.orianna.types.data.summoner.Summoner} 41 | */ 42 | @Path("/summoners/by-account/{encryptedAccountId}") 43 | @GET 44 | public Summoner getByAccountId(@QueryParam("platform") final String platformTag, @PathParam("encryptedAccountId") final String encryptedAccountId) { 45 | final Platform platform = platformTag != null ? Platform.withTag(platformTag.toUpperCase()) : context.getDefaultPlatform(); 46 | if(platform == null) { 47 | throw new WebApplicationException(platformTag + " is not a valid platform!", HttpURLConnection.HTTP_BAD_REQUEST); 48 | } 49 | 50 | final Map query = ImmutableMap. builder() 51 | .put("platform", platform) 52 | .put("accountId", encryptedAccountId) 53 | .build(); 54 | 55 | return context.getPipeline().get(Summoner.class, query); 56 | } 57 | 58 | /** 59 | * /lol/summoner/v4/summoners/{encryptedPUUID} 60 | * 61 | * @see https://developer.riotgames.com/api-methods/#summoner-v4/GET_getByPUUID 62 | * 63 | * @param platform 64 | * the tag for the {@link com.merakianalytics.orianna.types.common.Platform} to get data from. If null, the default 65 | * {@link com.merakianalytics.orianna.types.common.Platform} will be used. 66 | * @param encryptedPUUID 67 | * the person's encrypted id 68 | * @return {@link com.merakianalytics.orianna.types.data.summoner.Summoner} 69 | */ 70 | @Path("/summoners/by-puuid/{encryptedPUUID}") 71 | @GET 72 | public Summoner getByPUUID(@QueryParam("platform") final String platformTag, @PathParam("encryptedPUUID") final String encryptedPUUID) { 73 | final Platform platform = platformTag != null ? Platform.withTag(platformTag.toUpperCase()) : context.getDefaultPlatform(); 74 | if(platform == null) { 75 | throw new WebApplicationException(platformTag + " is not a valid platform!", HttpURLConnection.HTTP_BAD_REQUEST); 76 | } 77 | 78 | final Map query = ImmutableMap. builder() 79 | .put("platform", platform) 80 | .put("puuid", encryptedPUUID) 81 | .build(); 82 | 83 | return context.getPipeline().get(Summoner.class, query); 84 | } 85 | 86 | /** 87 | * /lol/summoner/v4/summoners/{encryptedSummonerId} 88 | * 89 | * @see https://developer.riotgames.com/api-methods/#summoner-v4/GET_getBySummonerId 90 | * 91 | * @param platform 92 | * the tag for the {@link com.merakianalytics.orianna.types.common.Platform} to get data from. If null, the default 93 | * {@link com.merakianalytics.orianna.types.common.Platform} will be used. 94 | * @param encryptedSummonerId 95 | * the summoner's encrypted id 96 | * @return {@link com.merakianalytics.orianna.types.data.summoner.Summoner} 97 | */ 98 | @Path("/summoners/{encryptedSummonerId}") 99 | @GET 100 | public Summoner getBySummonerId(@QueryParam("platform") final String platformTag, @PathParam("encryptedSummonerId") final String encryptedSummonerId) { 101 | final Platform platform = platformTag != null ? Platform.withTag(platformTag.toUpperCase()) : context.getDefaultPlatform(); 102 | if(platform == null) { 103 | throw new WebApplicationException(platformTag + " is not a valid platform!", HttpURLConnection.HTTP_BAD_REQUEST); 104 | } 105 | 106 | final Map query = ImmutableMap. builder() 107 | .put("platform", platform) 108 | .put("id", encryptedSummonerId) 109 | .build(); 110 | 111 | return context.getPipeline().get(Summoner.class, query); 112 | } 113 | 114 | /** 115 | * /lol/summoner/v4/summoners/by-name/{summonerName} 116 | * 117 | * @see https://developer.riotgames.com/api-methods/#summoner-v4/GET_getBySummonerName 118 | * 119 | * @param platform 120 | * the tag for the {@link com.merakianalytics.orianna.types.common.Platform} to get data from. If null, the default 121 | * {@link com.merakianalytics.orianna.types.common.Platform} will be used. 122 | * @param summonerName 123 | * the summoner's name 124 | * @return {@link com.merakianalytics.orianna.types.data.summoner.Summoner} 125 | */ 126 | @Path("/summoners/by-name/{summonerName}") 127 | @GET 128 | public Summoner getBySummonerName(@QueryParam("platform") final String platformTag, @PathParam("summonerName") final String summonerName) { 129 | final Platform platform = platformTag != null ? Platform.withTag(platformTag.toUpperCase()) : context.getDefaultPlatform(); 130 | if(platform == null) { 131 | throw new WebApplicationException(platformTag + " is not a valid platform!", HttpURLConnection.HTTP_BAD_REQUEST); 132 | } 133 | 134 | final Map query = ImmutableMap. builder() 135 | .put("platform", platform) 136 | .put("name", summonerName) 137 | .build(); 138 | 139 | return context.getPipeline().get(Summoner.class, query); 140 | } 141 | } 142 | -------------------------------------------------------------------------------- /src/main/java/com/merakianalytics/kernel/riotapi/data/ThirdPartyCodeAPI.java: -------------------------------------------------------------------------------- 1 | package com.merakianalytics.kernel.riotapi.data; 2 | 3 | import java.net.HttpURLConnection; 4 | 5 | import javax.ws.rs.GET; 6 | import javax.ws.rs.Path; 7 | import javax.ws.rs.PathParam; 8 | import javax.ws.rs.QueryParam; 9 | import javax.ws.rs.WebApplicationException; 10 | 11 | import org.jboss.resteasy.annotations.GZIP; 12 | 13 | import com.google.common.collect.ImmutableMap; 14 | import com.merakianalytics.kernel.riotapi.RiotAPIService; 15 | import com.merakianalytics.orianna.types.common.Platform; 16 | import com.merakianalytics.orianna.types.data.thirdpartycode.VerificationString; 17 | 18 | import io.swagger.annotations.Api; 19 | 20 | /** 21 | * The Third Party Code API proxy for the Riot API 22 | * 23 | * @see https://developer.riotgames.com/api-methods/#third-party-code-v4 24 | */ 25 | @Path("/platform/v4") 26 | @Api("Third Party Code API") 27 | @GZIP 28 | public class ThirdPartyCodeAPI extends RiotAPIService { 29 | /** 30 | * /lol/platform/v4/third-party-code/by-summoner/{encryptedSummonerId} 31 | * 32 | * @see https://developer.riotgames.com/api-methods/#third-party-code-v4/GET_getThirdPartyCodeBySummonerId 33 | * 34 | * @param platform 35 | * platform the tag for the {@link com.merakianalytics.orianna.types.common.Platform} to get data from. If null, the default 36 | * {@link com.merakianalytics.orianna.types.common.Platform} will be used. 37 | * @param encryptedSummonerId 38 | * the summoner's encrypted id 39 | * @return {@link com.merakianalytics.orianna.types.data.thirdpartycode.VerificationString} 40 | */ 41 | @Path("/third-party-code/by-summoner/{encryptedSummonerId}") 42 | @GET 43 | public VerificationString verificationString(@QueryParam("platform") final String platformTag, 44 | @PathParam("encryptedSummonerId") final String encryptedSummonerId) { 45 | final Platform platform = platformTag != null ? Platform.withTag(platformTag.toUpperCase()) : context.getDefaultPlatform(); 46 | if(platform == null) { 47 | throw new WebApplicationException(platformTag + " is not a valid platform!", HttpURLConnection.HTTP_BAD_REQUEST); 48 | } 49 | 50 | final ImmutableMap.Builder builder = ImmutableMap.builder(); 51 | builder.put("platform", platform); 52 | builder.put("summonerId", encryptedSummonerId); 53 | 54 | return context.getPipeline().get(VerificationString.class, builder.build()); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/main/java/com/merakianalytics/kernel/riotapi/dto/ChampionAPI.java: -------------------------------------------------------------------------------- 1 | package com.merakianalytics.kernel.riotapi.dto; 2 | 3 | import java.net.HttpURLConnection; 4 | import java.util.Map; 5 | 6 | import javax.ws.rs.GET; 7 | import javax.ws.rs.Path; 8 | import javax.ws.rs.QueryParam; 9 | import javax.ws.rs.WebApplicationException; 10 | 11 | import org.jboss.resteasy.annotations.GZIP; 12 | 13 | import com.google.common.collect.ImmutableMap; 14 | import com.merakianalytics.kernel.riotapi.RiotAPIService; 15 | import com.merakianalytics.orianna.types.common.Platform; 16 | import com.merakianalytics.orianna.types.dto.champion.ChampionInfo; 17 | 18 | import io.swagger.annotations.Api; 19 | 20 | /** 21 | * The Champion API proxy for the Riot API 22 | * 23 | * @see https://developer.riotgames.com/api-methods/#champion-v3 24 | */ 25 | @Path("/platform/v3") 26 | @Api("Champion API") 27 | @GZIP 28 | public class ChampionAPI extends RiotAPIService { 29 | /** 30 | * /lol/platform/v3/champion-rotations 31 | * 32 | * @see https://developer.riotgames.com/api-methods/#champion-v3/GET_getChampionInfo 33 | * 34 | * @param platform 35 | * the tag for the {@link com.merakianalytics.orianna.types.common.Platform} to get data from. If null, the default 36 | * {@link com.merakianalytics.orianna.types.common.Platform} will be used. 37 | * @return {@link com.merakianalytics.orianna.types.dto.champion.ChampionRotation} 38 | */ 39 | @Path("/champion-rotations") 40 | @GET 41 | public ChampionInfo getChampionInfo(@QueryParam("platform") final String platformTag) { 42 | final Platform platform = platformTag != null ? Platform.withTag(platformTag.toUpperCase()) : context.getDefaultPlatform(); 43 | if(platform == null) { 44 | throw new WebApplicationException(platformTag + " is not a valid platform!", HttpURLConnection.HTTP_BAD_REQUEST); 45 | } 46 | 47 | final Map query = ImmutableMap. builder() 48 | .put("platform", platform) 49 | .build(); 50 | 51 | return context.getPipeline().get(ChampionInfo.class, query); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/main/java/com/merakianalytics/kernel/riotapi/dto/ChampionMasteryAPI.java: -------------------------------------------------------------------------------- 1 | package com.merakianalytics.kernel.riotapi.dto; 2 | 3 | import java.net.HttpURLConnection; 4 | import java.util.Map; 5 | 6 | import javax.ws.rs.GET; 7 | import javax.ws.rs.Path; 8 | import javax.ws.rs.PathParam; 9 | import javax.ws.rs.QueryParam; 10 | import javax.ws.rs.WebApplicationException; 11 | 12 | import org.jboss.resteasy.annotations.GZIP; 13 | 14 | import com.google.common.collect.ImmutableMap; 15 | import com.merakianalytics.kernel.riotapi.RiotAPIService; 16 | import com.merakianalytics.orianna.types.common.Platform; 17 | import com.merakianalytics.orianna.types.dto.championmastery.ChampionMasteries; 18 | import com.merakianalytics.orianna.types.dto.championmastery.ChampionMastery; 19 | import com.merakianalytics.orianna.types.dto.championmastery.ChampionMasteryScore; 20 | 21 | import io.swagger.annotations.Api; 22 | 23 | /** 24 | * The Champion Mastery API proxy for the Riot API 25 | * 26 | * @see https://developer.riotgames.com/api-methods/#champion-mastery-v4 27 | */ 28 | @Path("/champion-mastery/v4") 29 | @Api("Champion Mastery API") 30 | @GZIP 31 | public class ChampionMasteryAPI extends RiotAPIService { 32 | /** 33 | * /lol/champion-mastery/v4/champion-masteries/by-summoner/{encryptedSummonerId} 34 | * 35 | * @see https://developer.riotgames.com/api-methods/#champion-mastery-v4/GET_getAllChampionMasteries 36 | * 37 | * @param platform 38 | * the tag for the {@link com.merakianalytics.orianna.types.common.Platform} to get data from. If null, the default 39 | * {@link com.merakianalytics.orianna.types.common.Platform} will be used. 40 | * @param encryptedSummonerId 41 | * the summoner's encrypted id 42 | * @return {@link com.merakianalytics.orianna.types.dto.championmastery.ChampionMasteries} 43 | */ 44 | @Path("/champion-masteries/by-summoner/{encryptedSummonerId}") 45 | @GET 46 | public ChampionMasteries getAllChampionMasteries(@QueryParam("platform") final String platformTag, 47 | @PathParam("encryptedSummonerId") final String encryptedSummonerId) { 48 | final Platform platform = platformTag != null ? Platform.withTag(platformTag.toUpperCase()) : context.getDefaultPlatform(); 49 | if(platform == null) { 50 | throw new WebApplicationException(platformTag + " is not a valid platform!", HttpURLConnection.HTTP_BAD_REQUEST); 51 | } 52 | 53 | final Map query = ImmutableMap. builder() 54 | .put("platform", platform) 55 | .put("summonerId", encryptedSummonerId) 56 | .build(); 57 | 58 | return context.getPipeline().get(ChampionMasteries.class, query); 59 | } 60 | 61 | /** 62 | * /lol/champion-mastery/v4/champion-masteries/by-summoner/{encryptedSummonerId}/by-champion/{championId} 63 | * 64 | * @see https://developer.riotgames.com/api-methods/#champion-mastery-v4/GET_getChampionMastery 65 | * 66 | * @param platform 67 | * the tag for the {@link com.merakianalytics.orianna.types.common.Platform} to get data from. If null, the default 68 | * {@link com.merakianalytics.orianna.types.common.Platform} will be used. 69 | * @param encryptedSummonerId 70 | * the summoner's encrypted id 71 | * @param championId 72 | * the champion's id 73 | * @return {@link com.merakianalytics.orianna.types.dto.championmastery.ChampionMastery} 74 | */ 75 | @Path("/champion-masteries/by-summoner/{encryptedSummonerId}/by-champion/{championId}") 76 | @GET 77 | public ChampionMastery getChampionMastery(@QueryParam("platform") final String platformTag, 78 | @PathParam("encryptedSummonerId") final String encryptedSummonerId, 79 | @PathParam("championId") final int championId) { 80 | final Platform platform = platformTag != null ? Platform.withTag(platformTag.toUpperCase()) : context.getDefaultPlatform(); 81 | if(platform == null) { 82 | throw new WebApplicationException(platformTag + " is not a valid platform!", HttpURLConnection.HTTP_BAD_REQUEST); 83 | } 84 | 85 | final Map query = ImmutableMap. builder() 86 | .put("platform", platform) 87 | .put("summonerId", encryptedSummonerId) 88 | .put("championId", championId) 89 | .build(); 90 | 91 | return context.getPipeline().get(ChampionMastery.class, query); 92 | } 93 | 94 | /** 95 | * /lol/champion-mastery/v4/scores/by-summoner/{encryptedSummonerId} 96 | * 97 | * @see https://developer.riotgames.com/api-methods/#champion-mastery-v4/GET_getChampionMasteryScore 98 | * 99 | * @param platform 100 | * the tag for the {@link com.merakianalytics.orianna.types.common.Platform} to get data from. If null, the default 101 | * {@link com.merakianalytics.orianna.types.common.Platform} will be used. 102 | * @param encryptedSummonerId 103 | * the summoner's encrypted id 104 | * @return {@link com.merakianalytics.orianna.types.dto.championmastery.ChampionMasteryScore} 105 | */ 106 | @Path("/scores/by-summoner/{encryptedSummonerId}") 107 | @GET 108 | public ChampionMasteryScore getChampionMasteryScore(@QueryParam("platform") final String platformTag, 109 | @PathParam("encryptedSummonerId") final String encryptedSummonerId) { 110 | final Platform platform = platformTag != null ? Platform.withTag(platformTag.toUpperCase()) : context.getDefaultPlatform(); 111 | if(platform == null) { 112 | throw new WebApplicationException(platformTag + " is not a valid platform!", HttpURLConnection.HTTP_BAD_REQUEST); 113 | } 114 | 115 | final Map query = ImmutableMap. builder() 116 | .put("platform", platform) 117 | .put("summonerId", encryptedSummonerId) 118 | .build(); 119 | 120 | return context.getPipeline().get(ChampionMasteryScore.class, query); 121 | } 122 | } 123 | -------------------------------------------------------------------------------- /src/main/java/com/merakianalytics/kernel/riotapi/dto/LeagueAPI.java: -------------------------------------------------------------------------------- 1 | package com.merakianalytics.kernel.riotapi.dto; 2 | 3 | import java.net.HttpURLConnection; 4 | import java.util.Map; 5 | 6 | import javax.ws.rs.GET; 7 | import javax.ws.rs.Path; 8 | import javax.ws.rs.PathParam; 9 | import javax.ws.rs.QueryParam; 10 | import javax.ws.rs.WebApplicationException; 11 | 12 | import org.jboss.resteasy.annotations.GZIP; 13 | 14 | import com.google.common.collect.ImmutableMap; 15 | import com.merakianalytics.kernel.riotapi.RiotAPIService; 16 | import com.merakianalytics.orianna.types.common.Platform; 17 | import com.merakianalytics.orianna.types.common.Queue; 18 | import com.merakianalytics.orianna.types.common.Tier; 19 | import com.merakianalytics.orianna.types.dto.league.LeagueList; 20 | import com.merakianalytics.orianna.types.dto.league.LeaguePositions; 21 | 22 | import io.swagger.annotations.Api; 23 | 24 | /** 25 | * The League API proxy for the Riot API 26 | * 27 | * @see https://developer.riotgames.com/api-methods/#league-v4 28 | */ 29 | @Path("/league/v4") 30 | @Api("League API") 31 | @GZIP 32 | public class LeagueAPI extends RiotAPIService { 33 | /** 34 | * /lol/league/v4/challengerleagues/by-queue/{queue} 35 | * 36 | * @see https://developer.riotgames.com/api-methods/#league-v4/GET_getChallengerLeague 37 | * 38 | * @param platform 39 | * the tag for the {@link com.merakianalytics.orianna.types.common.Platform} to get data from. If null, the default 40 | * {@link com.merakianalytics.orianna.types.common.Platform} will be used. 41 | * @param queue 42 | * the {@link com.merakianalytics.orianna.types.common.Queue} 43 | * @return {@link com.merakianalytics.orianna.types.dto.league.LeagueList} 44 | */ 45 | @Path("/challengerleagues/by-queue/{queue}") 46 | @GET 47 | public LeagueList getChallengerLeague(@QueryParam("platform") final String platformTag, @PathParam("queue") final String queueTag) { 48 | final Platform platform = platformTag != null ? Platform.withTag(platformTag.toUpperCase()) : context.getDefaultPlatform(); 49 | if(platform == null) { 50 | throw new WebApplicationException(platformTag + " is not a valid platform!", HttpURLConnection.HTTP_BAD_REQUEST); 51 | } 52 | 53 | final Queue queue = Queue.withTag(queueTag); 54 | if(queue == null) { 55 | throw new WebApplicationException(queueTag + " is not a valid queue!", HttpURLConnection.HTTP_BAD_REQUEST); 56 | } 57 | 58 | final Map query = ImmutableMap. builder() 59 | .put("platform", platform) 60 | .put("queue", queue) 61 | .put("tier", Tier.CHALLENGER) 62 | .build(); 63 | 64 | return context.getPipeline().get(LeagueList.class, query); 65 | } 66 | 67 | /** 68 | * /lol/league/v4/grandmasterleagues/by-queue/{queue} 69 | * 70 | * @see https://developer.riotgames.com/api-methods/#league-v4/GET_getGrandmasterLeague 71 | * 72 | * @param platform 73 | * the tag for the {@link com.merakianalytics.orianna.types.common.Platform} to get data from. If null, the default 74 | * {@link com.merakianalytics.orianna.types.common.Platform} will be used. 75 | * @param queue 76 | * the {@link com.merakianalytics.orianna.types.common.Queue} 77 | * @return {@link com.merakianalytics.orianna.types.dto.league.LeagueList} 78 | */ 79 | @Path("/grandmasterleagues/by-queue/{queue}") 80 | @GET 81 | public LeagueList getGrandmasterLeague(@QueryParam("platform") final String platformTag, @PathParam("queue") final String queueTag) { 82 | final Platform platform = platformTag != null ? Platform.withTag(platformTag.toUpperCase()) : context.getDefaultPlatform(); 83 | if(platform == null) { 84 | throw new WebApplicationException(platformTag + " is not a valid platform!", HttpURLConnection.HTTP_BAD_REQUEST); 85 | } 86 | 87 | final Queue queue = Queue.withTag(queueTag); 88 | if(queue == null) { 89 | throw new WebApplicationException(queueTag + " is not a valid queue!", HttpURLConnection.HTTP_BAD_REQUEST); 90 | } 91 | 92 | final Map query = ImmutableMap. builder() 93 | .put("platform", platform) 94 | .put("queue", queue) 95 | .put("tier", Tier.GRANDMASTER) 96 | .build(); 97 | 98 | return context.getPipeline().get(LeagueList.class, query); 99 | } 100 | 101 | /** 102 | * /lol/league/v4/leagues/{leagueId} 103 | * 104 | * @see https://developer.riotgames.com/api-methods/#league-v4/GET_getLeagueById 105 | * 106 | * @param platform 107 | * the tag for the {@link com.merakianalytics.orianna.types.common.Platform} to get data from. If null, the default 108 | * {@link com.merakianalytics.orianna.types.common.Platform} will be used. 109 | * @param leagueId 110 | * the league's id 111 | * @return {@link com.merakianalytics.orianna.types.dto.league.LeagueList} 112 | */ 113 | @Path("/leagues/{leagueId}") 114 | @GET 115 | public LeagueList getLeagueById(@QueryParam("platform") final String platformTag, @PathParam("leagueId") final String leagueId) { 116 | final Platform platform = platformTag != null ? Platform.withTag(platformTag.toUpperCase()) : context.getDefaultPlatform(); 117 | if(platform == null) { 118 | throw new WebApplicationException(platformTag + " is not a valid platform!", HttpURLConnection.HTTP_BAD_REQUEST); 119 | } 120 | 121 | final Map query = ImmutableMap. builder() 122 | .put("platform", platform) 123 | .put("leagueId", leagueId) 124 | .build(); 125 | 126 | return context.getPipeline().get(LeagueList.class, query); 127 | } 128 | 129 | /** 130 | * /lol/league/v4/entries/by-summoner/{encryptedSummonerId} 131 | * 132 | * @see https://developer.riotgames.com/api-methods/#league-v4/GET_getLeagueEntries 133 | * 134 | * @param platform 135 | * the tag for the {@link com.merakianalytics.orianna.types.common.Platform} to get data from. If null, the default 136 | * {@link com.merakianalytics.orianna.types.common.Platform} will be used. 137 | * @param encryptedSummonerId 138 | * the summoner's encrypted id 139 | * @return {@link com.merakianalytics.orianna.types.dto.league.SummonerPositions} 140 | */ 141 | @Path("/entries/by-summoner/{encryptedSummonerId}") 142 | @GET 143 | public LeaguePositions getLeagueEntries(@QueryParam("platform") final String platformTag, 144 | @PathParam("encryptedSummonerId") final String encryptedSummonerId) { 145 | final Platform platform = platformTag != null ? Platform.withTag(platformTag.toUpperCase()) : context.getDefaultPlatform(); 146 | if(platform == null) { 147 | throw new WebApplicationException(platformTag + " is not a valid platform!", HttpURLConnection.HTTP_BAD_REQUEST); 148 | } 149 | 150 | final Map query = ImmutableMap. builder() 151 | .put("platform", platform) 152 | .put("summonerId", encryptedSummonerId) 153 | .build(); 154 | 155 | return context.getPipeline().get(LeaguePositions.class, query); 156 | } 157 | 158 | /** 159 | * /lol/league/v4/masterleagues/by-queue/{queue} 160 | * 161 | * @see https://developer.riotgames.com/api-methods/#league-v4/GET_getMasterLeague 162 | * 163 | * @param platform 164 | * the tag for the {@link com.merakianalytics.orianna.types.common.Platform} to get data from. If null, the default 165 | * {@link com.merakianalytics.orianna.types.common.Platform} will be used. 166 | * @param queue 167 | * the {@link com.merakianalytics.orianna.types.common.Queue} 168 | * @return {@link com.merakianalytics.orianna.types.dto.league.LeagueList} 169 | */ 170 | @Path("/masterleagues/by-queue/{queue}") 171 | @GET 172 | public LeagueList getMasterLeague(@QueryParam("platform") final String platformTag, @PathParam("queue") final String queueTag) { 173 | final Platform platform = platformTag != null ? Platform.withTag(platformTag.toUpperCase()) : context.getDefaultPlatform(); 174 | if(platform == null) { 175 | throw new WebApplicationException(platformTag + " is not a valid platform!", HttpURLConnection.HTTP_BAD_REQUEST); 176 | } 177 | 178 | final Queue queue = Queue.withTag(queueTag); 179 | if(queue == null) { 180 | throw new WebApplicationException(queueTag + " is not a valid queue!", HttpURLConnection.HTTP_BAD_REQUEST); 181 | } 182 | 183 | final Map query = ImmutableMap. builder() 184 | .put("platform", platform) 185 | .put("queue", queue) 186 | .put("tier", Tier.MASTER) 187 | .build(); 188 | 189 | return context.getPipeline().get(LeagueList.class, query); 190 | } 191 | } 192 | -------------------------------------------------------------------------------- /src/main/java/com/merakianalytics/kernel/riotapi/dto/MatchAPI.java: -------------------------------------------------------------------------------- 1 | package com.merakianalytics.kernel.riotapi.dto; 2 | 3 | import java.net.HttpURLConnection; 4 | import java.util.Map; 5 | import java.util.Set; 6 | 7 | import javax.ws.rs.DefaultValue; 8 | import javax.ws.rs.GET; 9 | import javax.ws.rs.Path; 10 | import javax.ws.rs.PathParam; 11 | import javax.ws.rs.QueryParam; 12 | import javax.ws.rs.WebApplicationException; 13 | 14 | import org.jboss.resteasy.annotations.GZIP; 15 | 16 | import com.google.common.collect.ImmutableMap; 17 | import com.merakianalytics.kernel.riotapi.RiotAPIService; 18 | import com.merakianalytics.orianna.types.common.Platform; 19 | import com.merakianalytics.orianna.types.dto.match.Match; 20 | import com.merakianalytics.orianna.types.dto.match.MatchTimeline; 21 | import com.merakianalytics.orianna.types.dto.match.Matchlist; 22 | import com.merakianalytics.orianna.types.dto.match.TournamentMatches; 23 | 24 | import io.swagger.annotations.Api; 25 | 26 | /** 27 | * The Match API proxy for the Riot API 28 | * 29 | * @see https://developer.riotgames.com/api-methods/#match-v4 30 | */ 31 | @Path("/match/v4") 32 | @Api("Match API") 33 | @GZIP 34 | public class MatchAPI extends RiotAPIService { 35 | /** 36 | * /lol/match/v4/matches/{matchId} 37 | * 38 | * @see https://developer.riotgames.com/api-methods/#match-v4/GET_getMatch 39 | * 40 | * @param platform 41 | * the tag for the {@link com.merakianalytics.orianna.types.common.Platform} to get data from. If null, the default 42 | * {@link com.merakianalytics.orianna.types.common.Platform} will be used. 43 | * @param matchId 44 | * the match's id 45 | * @return {@link com.merakianalytics.orianna.types.dto.match.Match} 46 | */ 47 | @Path("/matches/{matchId}") 48 | @GET 49 | public Match getMatch(@QueryParam("platform") final String platformTag, @PathParam("matchId") final long matchId) { 50 | final Platform platform = platformTag != null ? Platform.withTag(platformTag.toUpperCase()) : context.getDefaultPlatform(); 51 | 52 | final Map query = ImmutableMap. builder() 53 | .put("platform", platform) 54 | .put("matchId", matchId) 55 | .build(); 56 | 57 | return context.getPipeline().get(Match.class, query); 58 | } 59 | 60 | /** 61 | * /lol/match/v4/matches/{matchId}/by-tournament-code/{tournamentCode} 62 | * 63 | * @see https://developer.riotgames.com/api-methods/#match-v4/GET_getMatchByTournamentCode 64 | * 65 | * @param platform 66 | * the tag for the {@link com.merakianalytics.orianna.types.common.Platform} to get data from. If null, the default 67 | * {@link com.merakianalytics.orianna.types.common.Platform} will be used. 68 | * @param matchId 69 | * the match's id 70 | * @param tournamentCode 71 | * the tournament code 72 | * @return {@link com.merakianalytics.orianna.types.dto.match.Match} 73 | */ 74 | @Path("/matches/{matchId}/by-tournament-code/{tournamentCode}") 75 | @GET 76 | public Match getMatchByTournamentCode(@QueryParam("platform") final String platformTag, @PathParam("matchId") final long matchId, 77 | @PathParam("tournamentCode") final String tournamentCode) { 78 | final Platform platform = platformTag != null ? Platform.withTag(platformTag.toUpperCase()) : context.getDefaultPlatform(); 79 | 80 | final Map query = ImmutableMap. builder() 81 | .put("platform", platform) 82 | .put("matchId", matchId) 83 | .put("tournamentCode", tournamentCode) 84 | .build(); 85 | 86 | return context.getPipeline().get(Match.class, query); 87 | } 88 | 89 | /** 90 | * /lol/match/v4/matches/by-tournament-code/{tournamentCode}/ids 91 | * 92 | * @see https://developer.riotgames.com/api-methods/#match-v4/GET_getMatchIdsByTournamentCode 93 | * 94 | * @param platform 95 | * the tag for the {@link com.merakianalytics.orianna.types.common.Platform} to get data from. If null, the default 96 | * {@link com.merakianalytics.orianna.types.common.Platform} will be used. 97 | * @param tournamentCode 98 | * the tournament code 99 | * @return {@link com.merakianalytics.orianna.types.dto.match.TournamentMatches} 100 | */ 101 | @Path("/matches/by-tournament-code/{tournamentCode}/ids") 102 | @GET 103 | public TournamentMatches getMatchIdsByTournamentCode(@QueryParam("platform") final String platformTag, 104 | @PathParam("tournamentCode") final String tournamentCode) { 105 | final Platform platform = platformTag != null ? Platform.withTag(platformTag.toUpperCase()) : context.getDefaultPlatform(); 106 | 107 | final Map query = ImmutableMap. builder() 108 | .put("platform", platform) 109 | .put("tournamentCode", tournamentCode) 110 | .build(); 111 | 112 | return context.getPipeline().get(TournamentMatches.class, query); 113 | } 114 | 115 | /** 116 | * /lol/match/v4/matchlists/by-account/{encryptedAccountId} 117 | * 118 | * @see https://developer.riotgames.com/api-methods/#match-v4/GET_getMatchlist 119 | * 120 | * @param platform 121 | * the tag for the {@link com.merakianalytics.orianna.types.common.Platform} to get data from. If null, the default 122 | * {@link com.merakianalytics.orianna.types.common.Platform} will be used. 123 | * @param encryptedAccountId 124 | * the account's encrypted id 125 | * @param queue 126 | * the ids of the queues 127 | * @param endTime 128 | * the latest time for the query 129 | * @param beginIndex 130 | * the first result to return 131 | * @param beginTime 132 | * the earliest time for the query 133 | * @param season 134 | * the ids of the seasons 135 | * @param champion 136 | * the ids of the champions 137 | * @param endIndex 138 | * the last result to return 139 | * @return {@link com.merakianalytics.orianna.types.dto.match.Matchlist} 140 | */ 141 | @Path("/matchlists/by-account/{encryptedAccountId}") 142 | @GET 143 | public Matchlist getMatchlist(@QueryParam("platform") final String platformTag, @PathParam("encryptedAccountId") final String encryptedAccountId, 144 | @QueryParam("queue") final Set queue, @QueryParam("endTime") @DefaultValue("-1") final long endTime, 145 | @QueryParam("beginIndex") @DefaultValue("-1") final int beginIndex, @QueryParam("beginTime") @DefaultValue("-1") final long beginTime, 146 | @QueryParam("season") final Set season, @QueryParam("champion") final Set champion, 147 | @QueryParam("endIndex") @DefaultValue("-1") final int endIndex) { 148 | final Platform platform = platformTag != null ? Platform.withTag(platformTag.toUpperCase()) : context.getDefaultPlatform(); 149 | 150 | final ImmutableMap.Builder builder = ImmutableMap.builder(); 151 | builder.put("platform", platform); 152 | builder.put("accountId", encryptedAccountId); 153 | 154 | if(queue != null) { 155 | builder.put("queues", queue); 156 | } 157 | 158 | if(endTime != -1L) { 159 | builder.put("endTime", endTime); 160 | } 161 | 162 | if(beginIndex != -1) { 163 | builder.put("beginIndex", beginIndex); 164 | } 165 | 166 | if(beginTime != -1L) { 167 | builder.put("beginTime", beginTime); 168 | } 169 | 170 | if(season != null) { 171 | builder.put("seasons", season); 172 | } 173 | 174 | if(champion != null) { 175 | builder.put("champions", champion); 176 | } 177 | 178 | if(endIndex != -1) { 179 | builder.put("endIndex", endIndex); 180 | } 181 | 182 | return context.getPipeline().get(Matchlist.class, builder.build()); 183 | } 184 | 185 | /** 186 | * /lol/match/v4/timelines/by-match/{matchId} 187 | * 188 | * @see https://developer.riotgames.com/api-methods/#match-v4/GET_getMatchTimeline 189 | * 190 | * @param platform 191 | * the tag for the {@link com.merakianalytics.orianna.types.common.Platform} to get data from. If null, the default 192 | * {@link com.merakianalytics.orianna.types.common.Platform} will be used. 193 | * @param matchId 194 | * the match's id 195 | * @return {@link com.merakianalytics.orianna.types.dto.match.MatchTimeline} 196 | */ 197 | @Path("/timelines/by-match/{matchId}") 198 | @GET 199 | public MatchTimeline getMatchTimeline(@QueryParam("platform") final String platformTag, @PathParam("matchId") final long matchId) { 200 | final Platform platform = platformTag != null ? Platform.withTag(platformTag.toUpperCase()) : context.getDefaultPlatform(); 201 | if(platform == null) { 202 | throw new WebApplicationException(platformTag + " is not a valid platform!", HttpURLConnection.HTTP_BAD_REQUEST); 203 | } 204 | 205 | final Map query = ImmutableMap. builder() 206 | .put("platform", platform) 207 | .put("matchId", matchId) 208 | .build(); 209 | 210 | return context.getPipeline().get(MatchTimeline.class, query); 211 | } 212 | } 213 | -------------------------------------------------------------------------------- /src/main/java/com/merakianalytics/kernel/riotapi/dto/SpectatorAPI.java: -------------------------------------------------------------------------------- 1 | package com.merakianalytics.kernel.riotapi.dto; 2 | 3 | import java.net.HttpURLConnection; 4 | import java.util.Map; 5 | 6 | import javax.ws.rs.GET; 7 | import javax.ws.rs.Path; 8 | import javax.ws.rs.PathParam; 9 | import javax.ws.rs.QueryParam; 10 | import javax.ws.rs.WebApplicationException; 11 | 12 | import org.jboss.resteasy.annotations.GZIP; 13 | 14 | import com.google.common.collect.ImmutableMap; 15 | import com.merakianalytics.kernel.riotapi.RiotAPIService; 16 | import com.merakianalytics.orianna.types.common.Platform; 17 | import com.merakianalytics.orianna.types.dto.spectator.CurrentGameInfo; 18 | import com.merakianalytics.orianna.types.dto.spectator.FeaturedGames; 19 | 20 | import io.swagger.annotations.Api; 21 | 22 | /** 23 | * The Spectator API proxy for the Riot API 24 | * 25 | * @see https://developer.riotgames.com/api-methods/#spectator-v4 26 | */ 27 | @Path("/spectator/v4") 28 | @Api("Spectator API") 29 | @GZIP 30 | public class SpectatorAPI extends RiotAPIService { 31 | /** 32 | * /lol/spectator/v4/active-games/by-summoner/{encryptedSummonerId} 33 | * 34 | * @see https://developer.riotgames.com/api-methods/#spectator-v4/GET_getCurrentGameInfoBySummoner 35 | * 36 | * @param platform 37 | * the tag for the {@link com.merakianalytics.orianna.types.common.Platform} to get data from. If null, the default 38 | * {@link com.merakianalytics.orianna.types.common.Platform} will be used. 39 | * @param encryptedSummonerId 40 | * the summoner's encrypted id 41 | * @return {@link com.merakianalytics.orianna.types.dto.spectator.CurrentGameInfo} 42 | */ 43 | @Path("/active-games/by-summoner/{encryptedSummonerId}") 44 | @GET 45 | public CurrentGameInfo getCurrentGameInfoBySummoner(@QueryParam("platform") final String platformTag, 46 | @PathParam("encryptedSummonerId") final String encryptedSummonerId) { 47 | final Platform platform = platformTag != null ? Platform.withTag(platformTag.toUpperCase()) : context.getDefaultPlatform(); 48 | if(platform == null) { 49 | throw new WebApplicationException(platformTag + " is not a valid platform!", HttpURLConnection.HTTP_BAD_REQUEST); 50 | } 51 | 52 | final Map query = ImmutableMap. builder() 53 | .put("platform", platform) 54 | .put("summonerId", encryptedSummonerId) 55 | .build(); 56 | 57 | return context.getPipeline().get(CurrentGameInfo.class, query); 58 | } 59 | 60 | /** 61 | * /lol/spectator/v4/featured-games 62 | * 63 | * @see https://developer.riotgames.com/api-methods/#spectator-v4/GET_getFeaturedGames 64 | * 65 | * @param platform 66 | * the tag for the {@link com.merakianalytics.orianna.types.common.Platform} to get data from. If null, the default 67 | * {@link com.merakianalytics.orianna.types.common.Platform} will be used. 68 | * @return {@link com.merakianalytics.orianna.types.dto.spectator.FeaturedGames} 69 | */ 70 | @Path("/featured-games") 71 | @GET 72 | public FeaturedGames getFeaturedGames(@QueryParam("platform") final String platformTag) { 73 | final Platform platform = platformTag != null ? Platform.withTag(platformTag.toUpperCase()) : context.getDefaultPlatform(); 74 | if(platform == null) { 75 | throw new WebApplicationException(platformTag + " is not a valid platform!", HttpURLConnection.HTTP_BAD_REQUEST); 76 | } 77 | 78 | final Map query = ImmutableMap. builder() 79 | .put("platform", platform) 80 | .build(); 81 | 82 | return context.getPipeline().get(FeaturedGames.class, query); 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /src/main/java/com/merakianalytics/kernel/riotapi/dto/StatusAPI.java: -------------------------------------------------------------------------------- 1 | package com.merakianalytics.kernel.riotapi.dto; 2 | 3 | import java.net.HttpURLConnection; 4 | import java.util.Map; 5 | 6 | import javax.ws.rs.GET; 7 | import javax.ws.rs.Path; 8 | import javax.ws.rs.QueryParam; 9 | import javax.ws.rs.WebApplicationException; 10 | 11 | import org.jboss.resteasy.annotations.GZIP; 12 | 13 | import com.google.common.collect.ImmutableMap; 14 | import com.merakianalytics.kernel.riotapi.RiotAPIService; 15 | import com.merakianalytics.orianna.types.common.Platform; 16 | import com.merakianalytics.orianna.types.dto.status.ShardStatus; 17 | 18 | import io.swagger.annotations.Api; 19 | 20 | /** 21 | * The Status API proxy for the Riot API 22 | * 23 | * @see https://developer.riotgames.com/api-methods/#spectator-v3 24 | */ 25 | @Path("/status/v3") 26 | @Api("Status API") 27 | @GZIP 28 | public class StatusAPI extends RiotAPIService { 29 | /** 30 | * /lol/status/v3/shard-data 31 | * 32 | * @see https://developer.riotgames.com/api-methods/#lol-status-v3/GET_getShardData 33 | * 34 | * @param platform 35 | * the tag for the {@link com.merakianalytics.orianna.types.common.Platform} to get data from. If null, the default 36 | * {@link com.merakianalytics.orianna.types.common.Platform} will be used. 37 | * @return {@link com.merakianalytics.orianna.types.dto.status.ShardStatus} 38 | */ 39 | @Path("/shard-data") 40 | @GET 41 | public ShardStatus getShardData(@QueryParam("platform") final String platformTag) { 42 | final Platform platform = platformTag != null ? Platform.withTag(platformTag.toUpperCase()) : context.getDefaultPlatform(); 43 | if(platform == null) { 44 | throw new WebApplicationException(platformTag + " is not a valid platform!", HttpURLConnection.HTTP_BAD_REQUEST); 45 | } 46 | 47 | final Map query = ImmutableMap. builder() 48 | .put("platform", platform) 49 | .build(); 50 | 51 | return context.getPipeline().get(ShardStatus.class, query); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/main/java/com/merakianalytics/kernel/riotapi/dto/SummonerAPI.java: -------------------------------------------------------------------------------- 1 | package com.merakianalytics.kernel.riotapi.dto; 2 | 3 | import java.net.HttpURLConnection; 4 | import java.util.Map; 5 | 6 | import javax.ws.rs.GET; 7 | import javax.ws.rs.Path; 8 | import javax.ws.rs.PathParam; 9 | import javax.ws.rs.QueryParam; 10 | import javax.ws.rs.WebApplicationException; 11 | 12 | import org.jboss.resteasy.annotations.GZIP; 13 | 14 | import com.google.common.collect.ImmutableMap; 15 | import com.merakianalytics.kernel.riotapi.RiotAPIService; 16 | import com.merakianalytics.orianna.types.common.Platform; 17 | import com.merakianalytics.orianna.types.dto.summoner.Summoner; 18 | 19 | import io.swagger.annotations.Api; 20 | 21 | /** 22 | * The Summoner API proxy for the Riot API 23 | * 24 | * @see https://developer.riotgames.com/api-methods/#summoner-v4 25 | */ 26 | @Path("/summoner/v4") 27 | @Api("Summoner API") 28 | @GZIP 29 | public class SummonerAPI extends RiotAPIService { 30 | /** 31 | * /lol/summoner/v4/summoners/by-account/{encryptedAccountId} 32 | * 33 | * @see https://developer.riotgames.com/api-methods/#summoner-v4/GET_getByAccountId 34 | * 35 | * @param platform 36 | * the tag for the {@link com.merakianalytics.orianna.types.common.Platform} to get data from. If null, the default 37 | * {@link com.merakianalytics.orianna.types.common.Platform} will be used. 38 | * @param encryptedAccountId 39 | * the account's encrypted id 40 | * @return {@link com.merakianalytics.orianna.types.dto.summoner.Summoner} 41 | */ 42 | @Path("/summoners/by-account/{encryptedAccountId}") 43 | @GET 44 | public Summoner getByAccountId(@QueryParam("platform") final String platformTag, @PathParam("encryptedAccountId") final String encryptedAccountId) { 45 | final Platform platform = platformTag != null ? Platform.withTag(platformTag.toUpperCase()) : context.getDefaultPlatform(); 46 | if(platform == null) { 47 | throw new WebApplicationException(platformTag + " is not a valid platform!", HttpURLConnection.HTTP_BAD_REQUEST); 48 | } 49 | 50 | final Map query = ImmutableMap. builder() 51 | .put("platform", platform) 52 | .put("accountId", encryptedAccountId) 53 | .build(); 54 | 55 | return context.getPipeline().get(Summoner.class, query); 56 | } 57 | 58 | /** 59 | * /lol/summoner/v4/summoners/{encryptedPUUID} 60 | * 61 | * @see https://developer.riotgames.com/api-methods/#summoner-v4/GET_getByPUUID 62 | * 63 | * @param platform 64 | * the tag for the {@link com.merakianalytics.orianna.types.common.Platform} to get data from. If null, the default 65 | * {@link com.merakianalytics.orianna.types.common.Platform} will be used. 66 | * @param encryptedPUUID 67 | * the person's encrypted id 68 | * @return {@link com.merakianalytics.orianna.types.dto.summoner.Summoner} 69 | */ 70 | @Path("/summoners/by-puuid/{encryptedPUUID}") 71 | @GET 72 | public Summoner getByPUUID(@QueryParam("platform") final String platformTag, @PathParam("encryptedPUUID") final String encryptedPUUID) { 73 | final Platform platform = platformTag != null ? Platform.withTag(platformTag.toUpperCase()) : context.getDefaultPlatform(); 74 | if(platform == null) { 75 | throw new WebApplicationException(platformTag + " is not a valid platform!", HttpURLConnection.HTTP_BAD_REQUEST); 76 | } 77 | 78 | final Map query = ImmutableMap. builder() 79 | .put("platform", platform) 80 | .put("puuid", encryptedPUUID) 81 | .build(); 82 | 83 | return context.getPipeline().get(Summoner.class, query); 84 | } 85 | 86 | /** 87 | * /lol/summoner/v4/summoners/{encryptedSummonerId} 88 | * 89 | * @see https://developer.riotgames.com/api-methods/#summoner-v4/GET_getBySummonerId 90 | * 91 | * @param platform 92 | * the tag for the {@link com.merakianalytics.orianna.types.common.Platform} to get data from. If null, the default 93 | * {@link com.merakianalytics.orianna.types.common.Platform} will be used. 94 | * @param encryptedSummonerId 95 | * the summoner's encrypted id 96 | * @return {@link com.merakianalytics.orianna.types.dto.summoner.Summoner} 97 | */ 98 | @Path("/summoners/{encryptedSummonerId}") 99 | @GET 100 | public Summoner getBySummonerId(@QueryParam("platform") final String platformTag, @PathParam("encryptedSummonerId") final String encryptedSummonerId) { 101 | final Platform platform = platformTag != null ? Platform.withTag(platformTag.toUpperCase()) : context.getDefaultPlatform(); 102 | if(platform == null) { 103 | throw new WebApplicationException(platformTag + " is not a valid platform!", HttpURLConnection.HTTP_BAD_REQUEST); 104 | } 105 | 106 | final Map query = ImmutableMap. builder() 107 | .put("platform", platform) 108 | .put("id", encryptedSummonerId) 109 | .build(); 110 | 111 | return context.getPipeline().get(Summoner.class, query); 112 | } 113 | 114 | /** 115 | * /lol/summoner/v4/summoners/by-name/{summonerName} 116 | * 117 | * @see https://developer.riotgames.com/api-methods/#summoner-v4/GET_getBySummonerName 118 | * 119 | * @param platform 120 | * the tag for the {@link com.merakianalytics.orianna.types.common.Platform} to get data from. If null, the default 121 | * {@link com.merakianalytics.orianna.types.common.Platform} will be used. 122 | * @param summonerName 123 | * the summoner's name 124 | * @return {@link com.merakianalytics.orianna.types.dto.summoner.Summoner} 125 | */ 126 | @Path("/summoners/by-name/{summonerName}") 127 | @GET 128 | public Summoner getBySummonerName(@QueryParam("platform") final String platformTag, @PathParam("summonerName") final String summonerName) { 129 | final Platform platform = platformTag != null ? Platform.withTag(platformTag.toUpperCase()) : context.getDefaultPlatform(); 130 | if(platform == null) { 131 | throw new WebApplicationException(platformTag + " is not a valid platform!", HttpURLConnection.HTTP_BAD_REQUEST); 132 | } 133 | 134 | final Map query = ImmutableMap. builder() 135 | .put("platform", platform) 136 | .put("name", summonerName) 137 | .build(); 138 | 139 | return context.getPipeline().get(Summoner.class, query); 140 | } 141 | } 142 | -------------------------------------------------------------------------------- /src/main/java/com/merakianalytics/kernel/riotapi/dto/ThirdPartyCodeAPI.java: -------------------------------------------------------------------------------- 1 | package com.merakianalytics.kernel.riotapi.dto; 2 | 3 | import java.net.HttpURLConnection; 4 | 5 | import javax.ws.rs.GET; 6 | import javax.ws.rs.Path; 7 | import javax.ws.rs.PathParam; 8 | import javax.ws.rs.QueryParam; 9 | import javax.ws.rs.WebApplicationException; 10 | 11 | import org.jboss.resteasy.annotations.GZIP; 12 | 13 | import com.google.common.collect.ImmutableMap; 14 | import com.merakianalytics.kernel.riotapi.RiotAPIService; 15 | import com.merakianalytics.orianna.types.common.Platform; 16 | import com.merakianalytics.orianna.types.dto.thirdpartycode.VerificationString; 17 | 18 | import io.swagger.annotations.Api; 19 | 20 | /** 21 | * The Third Party Code API proxy for the Riot API 22 | * 23 | * @see https://developer.riotgames.com/api-methods/#third-party-code-v4 24 | */ 25 | @Path("/platform/v4") 26 | @Api("Third Party Code API") 27 | @GZIP 28 | public class ThirdPartyCodeAPI extends RiotAPIService { 29 | /** 30 | * /lol/platform/v4/third-party-code/by-summoner/{encryptedSummonerId} 31 | * 32 | * @see https://developer.riotgames.com/api-methods/#third-party-code-v4/GET_getThirdPartyCodeBySummonerId 33 | * 34 | * @param platform 35 | * platform the tag for the {@link com.merakianalytics.orianna.types.common.Platform} to get data from. If null, the default 36 | * {@link com.merakianalytics.orianna.types.common.Platform} will be used. 37 | * @param encryptedSummonerId 38 | * the summoner's encrypted id 39 | * @return {@link com.merakianalytics.orianna.types.dto.thirdpartycode.VerificationString} 40 | */ 41 | @Path("/third-party-code/by-summoner/{encryptedSummonerId}") 42 | @GET 43 | public VerificationString verificationString(@QueryParam("platform") final String platformTag, 44 | @PathParam("encryptedSummonerId") final String encryptedSummonerId) { 45 | final Platform platform = platformTag != null ? Platform.withTag(platformTag.toUpperCase()) : context.getDefaultPlatform(); 46 | if(platform == null) { 47 | throw new WebApplicationException(platformTag + " is not a valid platform!", HttpURLConnection.HTTP_BAD_REQUEST); 48 | } 49 | 50 | final ImmutableMap.Builder builder = ImmutableMap.builder(); 51 | builder.put("platform", platform); 52 | builder.put("summonerId", encryptedSummonerId); 53 | 54 | return context.getPipeline().get(VerificationString.class, builder.build()); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/main/resources/META-INF/beans.xml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/meraki-analytics/kernel/f76940330ca071bd30dd5221d72321162b7b0522/src/main/resources/META-INF/beans.xml -------------------------------------------------------------------------------- /src/main/resources/META-INF/services/javax.ws.rs.ext.Providers: -------------------------------------------------------------------------------- 1 | org.jboss.resteasy.plugins.interceptors.encoding.GZIPEncodingInterceptor -------------------------------------------------------------------------------- /src/main/resources/com/merakianalytics/kernel/default-kernel-config.json: -------------------------------------------------------------------------------- 1 | { 2 | "defaultPlatform": "NORTH_AMERICA", 3 | "pipeline": { 4 | "elements": [ 5 | { 6 | "className": "com.merakianalytics.orianna.datapipeline.riotapi.RiotAPI", 7 | "config": { 8 | "http404Strategy": { 9 | "type": "THROW_EXCEPTION" 10 | }, 11 | "http429Strategy": { 12 | "backupStrategy": { 13 | "backoff": 1, 14 | "backoffUnit": "SECONDS", 15 | "backupStrategy": { 16 | "type": "THROW_EXCEPTION" 17 | }, 18 | "maxAttempts": 4, 19 | "backoffFactor": 2, 20 | "type": "EXPONENTIAL_BACKOFF" 21 | }, 22 | "type": "RETRY_FROM_HEADERS" 23 | }, 24 | "http500Strategy": { 25 | "backoff": 1, 26 | "backoffUnit": "SECONDS", 27 | "backupStrategy": { 28 | "type": "THROW_EXCEPTION" 29 | }, 30 | "maxAttempts": 4, 31 | "backoffFactor": 2, 32 | "type": "EXPONENTIAL_BACKOFF" 33 | }, 34 | "http503Strategy": { 35 | "backoff": 1, 36 | "backoffUnit": "SECONDS", 37 | "backupStrategy": { 38 | "type": "THROW_EXCEPTION" 39 | }, 40 | "maxAttempts": 4, 41 | "backoffFactor": 2, 42 | "type": "EXPONENTIAL_BACKOFF" 43 | }, 44 | "http504Strategy": { 45 | "backoff": 1, 46 | "backoffUnit": "SECONDS", 47 | "backupStrategy": { 48 | "type": "THROW_EXCEPTION" 49 | }, 50 | "maxAttempts": 4, 51 | "backoffFactor": 2, 52 | "type": "EXPONENTIAL_BACKOFF" 53 | }, 54 | "httpTimeoutStrategy": { 55 | "backoff": 1, 56 | "backoffUnit": "SECONDS", 57 | "backupStrategy": { 58 | "type": "THROW_EXCEPTION" 59 | }, 60 | "maxAttempts": 4, 61 | "backoffFactor": 2, 62 | "type": "EXPONENTIAL_BACKOFF" 63 | }, 64 | "limitingShare": 1.0, 65 | "limitingType": "BURST", 66 | "rateLimiterTimeoutStrategy": { 67 | "type": "THROW_EXCEPTION" 68 | }, 69 | "requests": { 70 | "connectTimeout": 3, 71 | "connectTimeoutUnit": "SECONDS", 72 | "rateLimiterTimeout": 30, 73 | "rateLimiterTimeoutUnit": "SECONDS", 74 | "readTimeout": 3, 75 | "readTimeoutUnit": "SECONDS", 76 | "https": true 77 | }, 78 | "services": [ 79 | "com.merakianalytics.orianna.datapipeline.riotapi.ChampionAPI", 80 | "com.merakianalytics.orianna.datapipeline.riotapi.ChampionMasteryAPI", 81 | "com.merakianalytics.orianna.datapipeline.riotapi.LeagueAPI", 82 | "com.merakianalytics.orianna.datapipeline.riotapi.MatchAPI", 83 | "com.merakianalytics.orianna.datapipeline.riotapi.SpectatorAPI", 84 | "com.merakianalytics.orianna.datapipeline.riotapi.StatusAPI", 85 | "com.merakianalytics.orianna.datapipeline.riotapi.SummonerAPI", 86 | "com.merakianalytics.orianna.datapipeline.riotapi.ThirdPartyCodeAPI" 87 | ] 88 | }, 89 | "configClassName": "com.merakianalytics.orianna.datapipeline.riotapi.RiotAPI$Configuration" 90 | } 91 | ] 92 | }, 93 | "cors": { 94 | "allowCredentials": "true", 95 | "allowHeaders": "*", 96 | "allowMethods": "*", 97 | "allowOrigin": "*", 98 | "maxAge": "3600" 99 | }, 100 | "serializationInclusions": "NON_DEFAULT" 101 | } 102 | --------------------------------------------------------------------------------