forked from StrafesNET/asset-tool
rename context to cloud
This commit is contained in:
parent
08b0c311cb
commit
d4b5e27e73
@ -1 +1 @@
|
||||
pub mod context;
|
||||
pub mod cloud;
|
||||
|
32
src/main.rs
32
src/main.rs
@ -2,7 +2,7 @@ use std::{io::Read,path::PathBuf};
|
||||
use clap::{Args,Parser,Subcommand};
|
||||
use anyhow::Result as AResult;
|
||||
use futures::StreamExt;
|
||||
use rbx_asset::context::{ApiKey, AssetVersion, CloudContext, InventoryItem};
|
||||
use rbx_asset::cloud::{ApiKey,AssetVersion,CloudContext,InventoryItem};
|
||||
|
||||
type AssetID=u64;
|
||||
type AssetIDFileMap=Vec<(AssetID,PathBuf)>;
|
||||
@ -447,12 +447,12 @@ struct CreateConfig{
|
||||
///This is hardcoded to create models atm
|
||||
async fn create(config:CreateConfig)->AResult<()>{
|
||||
let resp=CloudContext::new(config.api_key)
|
||||
.create_asset(rbx_asset::context::CreateAssetRequest{
|
||||
assetType:rbx_asset::context::AssetType::Model,
|
||||
.create_asset(rbx_asset::cloud::CreateAssetRequest{
|
||||
assetType:rbx_asset::cloud::AssetType::Model,
|
||||
displayName:config.model_name,
|
||||
description:config.description,
|
||||
creationContext:rbx_asset::context::CreationContext{
|
||||
creator:rbx_asset::context::Creator{
|
||||
creationContext:rbx_asset::cloud::CreationContext{
|
||||
creator:rbx_asset::cloud::Creator{
|
||||
userId:config.creator_user_id,
|
||||
groupId:config.creator_group_id.unwrap_or(0),
|
||||
},
|
||||
@ -470,7 +470,7 @@ struct UploadAssetConfig{
|
||||
}
|
||||
async fn upload_asset(config:UploadAssetConfig)->AResult<()>{
|
||||
let context=CloudContext::new(config.api_key);
|
||||
context.update_asset(rbx_asset::context::UpdateAssetRequest{
|
||||
context.update_asset(rbx_asset::cloud::UpdateAssetRequest{
|
||||
assetId:config.asset_id,
|
||||
displayName:None,
|
||||
description:None,
|
||||
@ -486,7 +486,7 @@ struct UploadPlaceConfig{
|
||||
}
|
||||
async fn upload_place(config:UploadPlaceConfig)->AResult<()>{
|
||||
let context=CloudContext::new(config.api_key);
|
||||
context.update_place(rbx_asset::context::UpdatePlaceRequest{
|
||||
context.update_place(rbx_asset::cloud::UpdatePlaceRequest{
|
||||
placeId:config.place_id,
|
||||
universeId:config.universe_id,
|
||||
},tokio::fs::read(config.input_file).await?).await?;
|
||||
@ -499,7 +499,7 @@ async fn download_list(api_key:ApiKey,asset_id_file_map:AssetIDFileMap)->AResult
|
||||
.map(|(asset_id,file)|{
|
||||
let context=&context;
|
||||
async move{
|
||||
Ok((file,context.get_asset(rbx_asset::context::GetAssetRequest{asset_id,version:None}).await?))
|
||||
Ok((file,context.get_asset(rbx_asset::cloud::GetAssetRequest{asset_id,version:None}).await?))
|
||||
}
|
||||
}))
|
||||
.buffer_unordered(CONCURRENT_REQUESTS)
|
||||
@ -521,7 +521,7 @@ async fn get_inventory_pages(context:&CloudContext,group:u64)->AResult<Vec<Inven
|
||||
let mut cursor:Option<String>=None;
|
||||
let mut asset_list=Vec::new();
|
||||
loop{
|
||||
let mut page=context.inventory_page(rbx_asset::context::InventoryPageRequest{group,cursor}).await?;
|
||||
let mut page=context.inventory_page(rbx_asset::cloud::InventoryPageRequest{group,cursor}).await?;
|
||||
asset_list.append(&mut page.data);
|
||||
if page.nextPageCursor.is_none(){
|
||||
break;
|
||||
@ -546,7 +546,7 @@ async fn get_version_history(context:&CloudContext,asset_id:AssetID)->AResult<Ve
|
||||
let mut cursor:Option<String>=None;
|
||||
let mut asset_list=Vec::new();
|
||||
loop{
|
||||
let mut page=context.get_asset_versions(rbx_asset::context::AssetVersionsRequest{asset_id,cursor}).await?;
|
||||
let mut page=context.get_asset_versions(rbx_asset::cloud::AssetVersionsRequest{asset_id,cursor}).await?;
|
||||
asset_list.append(&mut page.data);
|
||||
if page.nextPageCursor.is_none(){
|
||||
break;
|
||||
@ -611,7 +611,7 @@ async fn download_history(mut config:DownloadHistoryConfig)->AResult<()>{
|
||||
//poll paged list of all asset versions
|
||||
let mut cursor:Option<String>=None;
|
||||
loop{
|
||||
let mut page=context.get_asset_versions(rbx_asset::context::AssetVersionsRequest{asset_id:config.asset_id,cursor}).await?;
|
||||
let mut page=context.get_asset_versions(rbx_asset::cloud::AssetVersionsRequest{asset_id:config.asset_id,cursor}).await?;
|
||||
let context=&context;
|
||||
let output_folder=config.output_folder.clone();
|
||||
let data=&page.data;
|
||||
@ -641,7 +641,7 @@ async fn download_history(mut config:DownloadHistoryConfig)->AResult<()>{
|
||||
let mut path=output_folder.clone();
|
||||
path.push(format!("{}_v{}.rbxl",config.asset_id,version_number));
|
||||
join_set.spawn(async move{
|
||||
let file=context.get_asset(rbx_asset::context::GetAssetRequest{asset_id:config.asset_id,version:Some(version_number)}).await?;
|
||||
let file=context.get_asset(rbx_asset::cloud::GetAssetRequest{asset_id:config.asset_id,version:Some(version_number)}).await?;
|
||||
|
||||
tokio::fs::write(path,file).await?;
|
||||
|
||||
@ -747,7 +747,7 @@ struct DownloadDecompileConfig{
|
||||
|
||||
async fn download_decompile(config:DownloadDecompileConfig)->AResult<()>{
|
||||
let context=CloudContext::new(config.api_key);
|
||||
let file=context.get_asset(rbx_asset::context::GetAssetRequest{asset_id:config.asset_id,version:None}).await?;
|
||||
let file=context.get_asset(rbx_asset::cloud::GetAssetRequest{asset_id:config.asset_id,version:None}).await?;
|
||||
|
||||
let dom=load_dom(std::io::Cursor::new(file))?;
|
||||
let context=rox_compiler::DecompiledContext::from_dom(dom);
|
||||
@ -929,7 +929,7 @@ async fn download_and_decompile_history_into_git(config:DownloadAndDecompileHist
|
||||
.map(|asset_version|{
|
||||
let context=context.clone();
|
||||
tokio::task::spawn(async move{
|
||||
let file=context.get_asset(rbx_asset::context::GetAssetRequest{asset_id,version:Some(asset_version.assetVersionNumber)}).await?;
|
||||
let file=context.get_asset(rbx_asset::cloud::GetAssetRequest{asset_id,version:Some(asset_version.assetVersionNumber)}).await?;
|
||||
let dom=load_dom(std::io::Cursor::new(file))?;
|
||||
Ok::<_,anyhow::Error>((asset_version,rox_compiler::DecompiledContext::from_dom(dom)))
|
||||
})
|
||||
@ -1008,7 +1008,7 @@ async fn compile_upload_asset(config:CompileUploadAssetConfig)->AResult<()>{
|
||||
|
||||
//upload it
|
||||
let context=CloudContext::new(config.api_key);
|
||||
context.update_asset(rbx_asset::context::UpdateAssetRequest{
|
||||
context.update_asset(rbx_asset::cloud::UpdateAssetRequest{
|
||||
assetId:config.asset_id,
|
||||
displayName:None,
|
||||
description:None,
|
||||
@ -1042,7 +1042,7 @@ async fn compile_upload_place(config:CompileUploadPlaceConfig)->AResult<()>{
|
||||
|
||||
//upload it
|
||||
let context=CloudContext::new(config.api_key);
|
||||
context.update_place(rbx_asset::context::UpdatePlaceRequest{
|
||||
context.update_place(rbx_asset::cloud::UpdatePlaceRequest{
|
||||
universeId:config.universe_id,
|
||||
placeId:config.place_id,
|
||||
},data).await?;
|
||||
|
Loading…
Reference in New Issue
Block a user