forked from StrafesNET/asset-tool
rename context to cloud
This commit is contained in:
parent
f9bdfd0e00
commit
c945036d60
@ -1 +1 @@
|
||||
pub mod context;
|
||||
pub mod cloud;
|
||||
|
28
src/main.rs
28
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)>;
|
||||
@ -443,12 +443,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),
|
||||
},
|
||||
@ -483,7 +483,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?;
|
||||
@ -496,7 +496,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)
|
||||
@ -518,7 +518,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;
|
||||
@ -543,7 +543,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;
|
||||
@ -608,7 +608,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;
|
||||
@ -638,7 +638,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?;
|
||||
|
||||
@ -744,7 +744,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);
|
||||
@ -926,7 +926,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)))
|
||||
})
|
||||
@ -1040,7 +1040,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