Skip to content

Commit

Permalink
Merge pull request #49 from Sleitnick/feature/universe
Browse files Browse the repository at this point in the history
Universe API
  • Loading branch information
Sleitnick authored Jun 6, 2024
2 parents 4618089 + 262a4ba commit 5bb25fd
Show file tree
Hide file tree
Showing 12 changed files with 590 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "rbxcloud"
version = "0.10.0"
version = "0.11.0"
description = "CLI and SDK for the Roblox Open Cloud APIs"
authors = ["Stephen Leitnick"]
license = "MIT"
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Possible use-cases:
| | API v2 (Beta) |
| -- | -- |
| :white_check_mark: | Groups |
| :x: | Universes |
| :white_check_mark: | Universes |
| :x: | Places |
| :x: | Instances |
| :white_check_mark: | Subscriptions |
Expand All @@ -44,7 +44,7 @@ The goal of this project is to support all API endpoints that Roblox provides.
### Aftman
Run the `aftman add` command within your project directory. This will add `rbxcloud` to the project's `aftman.toml` file (or create one if it doesn't yet exist).
```sh
$ aftman add Sleitnick/rbxcloud@0.10.0
$ aftman add Sleitnick/rbxcloud@0.11.0
```

### From Release
Expand All @@ -61,7 +61,7 @@ The library built for the CLI tool is available to use directly in Rust projects
To use `rbxcloud` in a Rust project, simply add `rbxcloud` to the `Cargo.toml` dependency list.
```toml
[dependencies]
rbxcloud = "0.10.0"
rbxcloud = "0.11.0"
```

Alternatively, use `cargo add`.
Expand Down
4 changes: 2 additions & 2 deletions docs/cli/cli-install.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ There are a few different ways to install the `rbxcloud` CLI.
### [Aftman](https://github.com/LPGhatguy/aftman) <small>(Preferred)</small>
Run the `aftman add` command within your project directory. This will add `rbxcloud` to the project's `aftman.toml` file (or create one if it doesn't yet exist).
```sh
$ aftman add Sleitnick/rbxcloud@0.10.0
$ aftman add Sleitnick/rbxcloud@0.11.0
```

Next, run `aftman install` to install `rbxcloud`.
Expand All @@ -17,7 +17,7 @@ Add `rbxcloud` under the `[tools]` section of your `foreman.toml` file.
```toml
# foreman.toml
[tools]
rbxcloud = { github = "Sleitnick/rbxcloud", version = "0.10.0" }
rbxcloud = { github = "Sleitnick/rbxcloud", version = "0.11.0" }
```

Next, run `foreman install` to install `rbxcloud`.
Expand Down
66 changes: 66 additions & 0 deletions docs/cli/cli-universe.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# Universe API

## Getting Universe Info
```
Usage: rbxcloud universe get [OPTIONS] --universe-id <UNIVERSE_ID> --api-key <API_KEY>
Options:
-u, --universe-id <UNIVERSE_ID> Universe ID
-p, --pretty Pretty-print the JSON response
-a, --api-key <API_KEY> Roblox Open Cloud API Key [env: RBXCLOUD_API_KEY=]
-h, --help Print help
```

### Example
```
$ rbxcloud universe get -p -u 12345 -a MY_KEY
```

## Updating Name
```
Usage: rbxcloud universe update-name [OPTIONS] --universe-id <UNIVERSE_ID> --name <NAME> --api-key <API_KEY>
Options:
-u, --universe-id <UNIVERSE_ID> Universe ID
-n, --name <NAME> New Universe name
-p, --pretty Pretty-print the JSON response
-a, --api-key <API_KEY> Roblox Open Cloud API Key [env: RBXCLOUD_API_KEY=]
-h, --help Print help
```

### Example
```
$ rbxcloud universe update-name -n "Experience Name" -p -u 12345 -a MY_KEY
```

## Updating Description
```
Usage: rbxcloud universe update-description [OPTIONS] --universe-id <UNIVERSE_ID> --description <DESCRIPTION> --api-key <API_KEY>
Options:
-u, --universe-id <UNIVERSE_ID> Universe ID
-d, --description <DESCRIPTION> New Universe description
-p, --pretty Pretty-print the JSON response
-a, --api-key <API_KEY> Roblox Open Cloud API Key [env: RBXCLOUD_API_KEY=]
-h, --help Print help
```

### Example
```
$ rbxcloud universe update-description -n "Experience description here." -p -u 12345 -a MY_KEY
```

## Restarting Servers
```
Usage: rbxcloud universe restart --universe-id <UNIVERSE_ID> --api-key <API_KEY>
Options:
-u, --universe-id <UNIVERSE_ID> Universe ID
-a, --api-key <API_KEY> Roblox Open Cloud API Key [env: RBXCLOUD_API_KEY=]
-h, --help Print help
```

### Example
```
$ rbxcloud universe restart -u 12345 -a MY_KEY
```
2 changes: 1 addition & 1 deletion docs/lib/lib-install.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
To use `rbxcloud` in a Rust project, simply add `rbxcloud` to the `Cargo.toml` dependency list.
```toml
[dependencies]
rbxcloud = "0.10.0"
rbxcloud = "0.11.0"
```

Alternatively, use `cargo add`.
Expand Down
26 changes: 26 additions & 0 deletions examples/restart-servers.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
use rbxcloud::rbx::{error::Error, types::UniverseId, v2::Client};

async fn restart_servers() -> Result<(), Error> {
// Inputs:
let api_key = "MY_API_KEY";
let universe_id = 9876543210;

let client = Client::new(api_key);
let universe_client = client.universe(UniverseId(universe_id));

universe_client.restart_servers().await
}

#[tokio::main]
async fn main() {
let restart_result = restart_servers().await;

match restart_result {
Ok(()) => {
println!("Servers restarted");
}
Err(e) => {
eprintln!("{e:?}");
}
}
}
1 change: 1 addition & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ nav:
- Group: cli/cli-group.md
- Subscription: cli/cli-subscription.md
- Notification: cli/cli-notification.md
- Universe: cli/cli-universe.md
- Rust Lib:
- Install: lib/lib-install.md

Expand Down
6 changes: 6 additions & 0 deletions src/cli/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@ mod messaging_cli;
mod notification_cli;
mod ordered_datastore_cli;
mod subscription_cli;
mod universe_cli;

use clap::{Parser, Subcommand};
use universe_cli::Universe;

use self::{
assets_cli::Assets, datastore_cli::DataStore, experience_cli::Experience, group_cli::Group,
Expand Down Expand Up @@ -47,6 +49,9 @@ pub enum Command {

/// Access the Roblox Notification API
Notification(Notification),

/// Access the Roblox Universe API
Universe(Universe),
}

impl Cli {
Expand All @@ -60,6 +65,7 @@ impl Cli {
Command::Group(command) => command.run().await,
Command::Subscription(command) => command.run().await,
Command::Notification(command) => command.run().await,
Command::Universe(command) => command.run().await,
}
}
}
Loading

0 comments on commit 5bb25fd

Please sign in to comment.