Skip to content

Commit

Permalink
1. all done
Browse files Browse the repository at this point in the history
  • Loading branch information
megoRU committed Jan 12, 2023
1 parent 564624b commit 6ca1bcc
Show file tree
Hide file tree
Showing 18 changed files with 96 additions and 98 deletions.
File renamed without changes.
98 changes: 96 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,96 @@
# wg-easy-wrapper
wg easy wrapper
## WG-EASY-WRAPPER

An API wrapper for [wg-easy](https://github.com/WeeJeWel/wg-easy/) written in Java by @megoRU

### Maven

https://jitpack.io/#megoRU/wg-easy-wrapper

```xml

<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>

<dependency>
<groupId>com.github.megoRU</groupId>
<artifactId>wg-easy-wrapper</artifactId>
<version>v1.0</version>
</dependency>
```

## Examples

### Get all Clients (peers)

```java
public class Main {
public static void main(String[] args) {
WgEasyAPI api = new WgEasyAPI.Builder()
.password("password")
.domain("vpn.megoru.ru")
.build();
try {
Clients[] clients = api.getClients();

for (Clients client : clients) {
System.out.println(client.getId()); //139987fc-266a-45bb-b3c4-3e1d8d2e180c
// ...
}
} catch (UnsuccessfulHttpException e) {
System.out.println(e.getMessage());
}
}
}
```

### Disable Client (peer)

```java
public class Main {
public static void main(String[] args) {
WgEasyAPI api = new WgEasyAPI.Builder()
.password("password")
.domain("vpn.megoru.ru")
.build();
try {
Status status = api.disableClient("139987fc-266a-45bb-b3c4-3e1d8d2e180c");
} catch (UnsuccessfulHttpException e) {
System.out.println(e.getMessage());
}
}
}
```

### Create Client (peer)

```java
public class Main {
public static void main(String[] args) {
WgEasyAPI api = new WgEasyAPI.Builder()
.password("password")
.domain("vpn.megoru.ru")
.build();
try {
Create create = api.createClient("mego");
System.out.println(create.getCreatedAt()); //2023-01-12T18:20:12
} catch (UnsuccessfulHttpException e) {
System.out.println(e.getMessage());
}
}
}
```

## Dependencies

1. [Gson](https://github.com/google/gson)
2. [Apache HttpClient](https://github.com/apache/httpcomponents-client)
3. [JSON-java](https://github.com/stleary/JSON-java)
4. [okhttp](https://github.com/square/okhttp)

## Links

* [Contact me](https://megoru.ru)
File renamed without changes.
File renamed without changes.
96 changes: 0 additions & 96 deletions wg-easy-wrapper/README.md

This file was deleted.

0 comments on commit 6ca1bcc

Please sign in to comment.