-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #58 from jackTabsCode/place-api
Support Place API
- Loading branch information
Showing
7 changed files
with
468 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
# Universe API | ||
|
||
## Getting Place Info | ||
``` | ||
Usage: rbxcloud place get [OPTIONS] --universe-id <UNIVERSE_ID> --place-id <PLACE_ID> --api-key <API_KEY> | ||
Options: | ||
-u, --universe-id <UNIVERSE_ID> Universe ID | ||
-p, --place-id <PLACE_ID> Place ID | ||
--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 place get -u 12345 -p 67890 -a MY_KEY | ||
``` | ||
|
||
## Updating Name | ||
``` | ||
Usage: rbxcloud place update-name [OPTIONS] --universe-id <UNIVERSE_ID> --place-id <PLACE_ID> --name <NAME> --api-key <API_KEY> | ||
Options: | ||
-u, --universe-id <UNIVERSE_ID> Universe ID | ||
-p, --place-id <PLACE_ID> Place ID | ||
-n, --name <NAME> New Place name | ||
--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 place update-name -n "Place Name" -u 12345 -p 67890 -a MY_KEY | ||
``` | ||
|
||
## Updating Description | ||
``` | ||
Usage: rbxcloud place update-description [OPTIONS] --universe-id <UNIVERSE_ID> --place-id <PLACE_ID> --description <DESCRIPTION> --api-key <API_KEY> | ||
Options: | ||
-u, --universe-id <UNIVERSE_ID> Universe ID | ||
-p, --place-id <PLACE_ID> Place ID | ||
-d, --description <DESCRIPTION> New Place description | ||
--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 "Place description here." -u 12345 -p 67890 -a MY_KEY | ||
``` | ||
|
||
## Updating Server Size | ||
``` | ||
Usage: rbxcloud place update-server-size [OPTIONS] --universe-id <UNIVERSE_ID> --place-id <PLACE_ID> --server-size <SERVER_SIZE> --api-key <API_KEY> | ||
Options: | ||
-u, --universe-id <UNIVERSE_ID> Universe ID | ||
-p, --place-id <PLACE_ID> Place ID | ||
-s, --server-size <SERVER_SIZE> New Place server size | ||
--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 place update-server-size -s 700 -u 12345 -p 67890 -a MY_KEY | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,236 @@ | ||
use clap::{Args, Subcommand}; | ||
use rbxcloud::rbx::{ | ||
types::{PlaceId, UniverseId}, | ||
v2::{place::UpdatePlaceInfo, Client}, | ||
}; | ||
|
||
#[derive(Debug, Subcommand)] | ||
pub enum PlaceCommands { | ||
/// Get Place information | ||
Get { | ||
/// Universe ID | ||
#[clap(short, long, value_parser)] | ||
universe_id: u64, | ||
|
||
/// Place ID | ||
#[clap(short, long, value_parser)] | ||
place_id: u64, | ||
|
||
/// Pretty-print the JSON response | ||
#[clap(long, value_parser, default_value_t = false)] | ||
pretty: bool, | ||
|
||
/// Roblox Open Cloud API Key | ||
#[clap(short, long, value_parser, env = "RBXCLOUD_API_KEY")] | ||
api_key: String, | ||
}, | ||
|
||
/// Update Place name | ||
UpdateName { | ||
/// Universe ID | ||
#[clap(short, long, value_parser)] | ||
universe_id: u64, | ||
|
||
/// Place ID | ||
#[clap(short, long, value_parser)] | ||
place_id: u64, | ||
|
||
/// New Place name | ||
#[clap(short, long, value_parser)] | ||
name: String, | ||
|
||
/// Pretty-print the JSON response | ||
#[clap(long, value_parser, default_value_t = false)] | ||
pretty: bool, | ||
|
||
/// Roblox Open Cloud API Key | ||
#[clap(short, long, value_parser, env = "RBXCLOUD_API_KEY")] | ||
api_key: String, | ||
}, | ||
|
||
/// Update Place description | ||
UpdateDescription { | ||
/// Universe ID | ||
#[clap(short, long, value_parser)] | ||
universe_id: u64, | ||
|
||
/// Place ID | ||
#[clap(short, long, value_parser)] | ||
place_id: u64, | ||
|
||
/// New Place description | ||
#[clap(short, long, value_parser)] | ||
description: String, | ||
|
||
/// Pretty-print the JSON response | ||
#[clap(long, value_parser, default_value_t = false)] | ||
pretty: bool, | ||
|
||
/// Roblox Open Cloud API Key | ||
#[clap(short, long, value_parser, env = "RBXCLOUD_API_KEY")] | ||
api_key: String, | ||
}, | ||
|
||
/// Update Place server size | ||
UpdateServerSize { | ||
/// Universe ID | ||
#[clap(short, long, value_parser)] | ||
universe_id: u64, | ||
|
||
/// Place ID | ||
#[clap(short, long, value_parser)] | ||
place_id: u64, | ||
|
||
/// New Place server size | ||
#[clap(short, long, value_parser)] | ||
server_size: u32, | ||
|
||
/// Pretty-print the JSON response | ||
#[clap(long, value_parser, default_value_t = false)] | ||
pretty: bool, | ||
|
||
/// Roblox Open Cloud API Key | ||
#[clap(short, long, value_parser, env = "RBXCLOUD_API_KEY")] | ||
api_key: String, | ||
}, | ||
} | ||
|
||
#[derive(Debug, Args)] | ||
pub struct Place { | ||
#[clap(subcommand)] | ||
command: PlaceCommands, | ||
} | ||
|
||
impl Place { | ||
pub async fn run(self) -> anyhow::Result<Option<String>> { | ||
match self.command { | ||
PlaceCommands::Get { | ||
universe_id, | ||
place_id, | ||
pretty, | ||
api_key, | ||
} => { | ||
let client = Client::new(&api_key); | ||
let place_client = client.place(UniverseId(universe_id), PlaceId(place_id)); | ||
let res = place_client.get().await; | ||
match res { | ||
Ok(place_info) => { | ||
let r = if pretty { | ||
serde_json::to_string_pretty(&place_info)? | ||
} else { | ||
serde_json::to_string(&place_info)? | ||
}; | ||
Ok(Some(r)) | ||
} | ||
Err(err) => Err(anyhow::anyhow!(err)), | ||
} | ||
} | ||
|
||
PlaceCommands::UpdateName { | ||
universe_id, | ||
place_id, | ||
name, | ||
pretty, | ||
api_key, | ||
} => { | ||
let client = Client::new(&api_key); | ||
let place_client = client.place(UniverseId(universe_id), PlaceId(place_id)); | ||
let res = place_client | ||
.update( | ||
"displayName".to_string(), | ||
UpdatePlaceInfo { | ||
path: None, | ||
create_time: None, | ||
update_time: None, | ||
display_name: Some(name), | ||
description: None, | ||
server_size: None, | ||
}, | ||
) | ||
.await; | ||
match res { | ||
Ok(place_info) => { | ||
let r = if pretty { | ||
serde_json::to_string_pretty(&place_info)? | ||
} else { | ||
serde_json::to_string(&place_info)? | ||
}; | ||
Ok(Some(r)) | ||
} | ||
Err(err) => Err(anyhow::anyhow!(err)), | ||
} | ||
} | ||
|
||
PlaceCommands::UpdateDescription { | ||
universe_id, | ||
place_id, | ||
description, | ||
pretty, | ||
api_key, | ||
} => { | ||
let client = Client::new(&api_key); | ||
let place_client = client.place(UniverseId(universe_id), PlaceId(place_id)); | ||
let res = place_client | ||
.update( | ||
"description".to_string(), | ||
UpdatePlaceInfo { | ||
path: None, | ||
create_time: None, | ||
update_time: None, | ||
display_name: None, | ||
description: Some(description), | ||
server_size: None, | ||
}, | ||
) | ||
.await; | ||
match res { | ||
Ok(place_info) => { | ||
let r = if pretty { | ||
serde_json::to_string_pretty(&place_info)? | ||
} else { | ||
serde_json::to_string(&place_info)? | ||
}; | ||
Ok(Some(r)) | ||
} | ||
Err(err) => Err(anyhow::anyhow!(err)), | ||
} | ||
} | ||
|
||
PlaceCommands::UpdateServerSize { | ||
universe_id, | ||
place_id, | ||
server_size, | ||
pretty, | ||
api_key, | ||
} => { | ||
let client = Client::new(&api_key); | ||
let place_client = client.place(UniverseId(universe_id), PlaceId(place_id)); | ||
let res = place_client | ||
.update( | ||
"serverSize".to_string(), | ||
UpdatePlaceInfo { | ||
path: None, | ||
create_time: None, | ||
update_time: None, | ||
display_name: None, | ||
description: None, | ||
server_size: Some(server_size), | ||
}, | ||
) | ||
.await; | ||
|
||
match res { | ||
Ok(place_info) => { | ||
let r = if pretty { | ||
serde_json::to_string_pretty(&place_info)? | ||
} else { | ||
serde_json::to_string(&place_info)? | ||
}; | ||
Ok(Some(r)) | ||
} | ||
Err(err) => Err(anyhow::anyhow!(err)), | ||
} | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.