rename context to cloud

This commit is contained in:
Quaternions 2024-07-03 12:22:39 -07:00
parent f9bdfd0e00
commit c945036d60
3 changed files with 15 additions and 15 deletions

View File

@ -1 +1 @@
pub mod context; pub mod cloud;

View File

@ -2,7 +2,7 @@ use std::{io::Read,path::PathBuf};
use clap::{Args,Parser,Subcommand}; use clap::{Args,Parser,Subcommand};
use anyhow::Result as AResult; use anyhow::Result as AResult;
use futures::StreamExt; use futures::StreamExt;
use rbx_asset::context::{ApiKey, AssetVersion, CloudContext, InventoryItem}; use rbx_asset::cloud::{ApiKey,AssetVersion,CloudContext,InventoryItem};
type AssetID=u64; type AssetID=u64;
type AssetIDFileMap=Vec<(AssetID,PathBuf)>; type AssetIDFileMap=Vec<(AssetID,PathBuf)>;
@ -443,12 +443,12 @@ struct CreateConfig{
///This is hardcoded to create models atm ///This is hardcoded to create models atm
async fn create(config:CreateConfig)->AResult<()>{ async fn create(config:CreateConfig)->AResult<()>{
let resp=CloudContext::new(config.api_key) let resp=CloudContext::new(config.api_key)
.create_asset(rbx_asset::context::CreateAssetRequest{ .create_asset(rbx_asset::cloud::CreateAssetRequest{
assetType:rbx_asset::context::AssetType::Model, assetType:rbx_asset::cloud::AssetType::Model,
displayName:config.model_name, displayName:config.model_name,
description:config.description, description:config.description,
creationContext:rbx_asset::context::CreationContext{ creationContext:rbx_asset::cloud::CreationContext{
creator:rbx_asset::context::Creator{ creator:rbx_asset::cloud::Creator{
userId:config.creator_user_id, userId:config.creator_user_id,
groupId:config.creator_group_id.unwrap_or(0), groupId:config.creator_group_id.unwrap_or(0),
}, },
@ -483,7 +483,7 @@ struct UploadPlaceConfig{
} }
async fn upload_place(config:UploadPlaceConfig)->AResult<()>{ async fn upload_place(config:UploadPlaceConfig)->AResult<()>{
let context=CloudContext::new(config.api_key); 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, placeId:config.place_id,
universeId:config.universe_id, universeId:config.universe_id,
},tokio::fs::read(config.input_file).await?).await?; },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)|{ .map(|(asset_id,file)|{
let context=&context; let context=&context;
async move{ 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) .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 cursor:Option<String>=None;
let mut asset_list=Vec::new(); let mut asset_list=Vec::new();
loop{ 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); asset_list.append(&mut page.data);
if page.nextPageCursor.is_none(){ if page.nextPageCursor.is_none(){
break; 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 cursor:Option<String>=None;
let mut asset_list=Vec::new(); let mut asset_list=Vec::new();
loop{ 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); asset_list.append(&mut page.data);
if page.nextPageCursor.is_none(){ if page.nextPageCursor.is_none(){
break; break;
@ -608,7 +608,7 @@ async fn download_history(mut config:DownloadHistoryConfig)->AResult<()>{
//poll paged list of all asset versions //poll paged list of all asset versions
let mut cursor:Option<String>=None; let mut cursor:Option<String>=None;
loop{ 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 context=&context;
let output_folder=config.output_folder.clone(); let output_folder=config.output_folder.clone();
let data=&page.data; let data=&page.data;
@ -638,7 +638,7 @@ async fn download_history(mut config:DownloadHistoryConfig)->AResult<()>{
let mut path=output_folder.clone(); let mut path=output_folder.clone();
path.push(format!("{}_v{}.rbxl",config.asset_id,version_number)); path.push(format!("{}_v{}.rbxl",config.asset_id,version_number));
join_set.spawn(async move{ 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?; tokio::fs::write(path,file).await?;
@ -744,7 +744,7 @@ struct DownloadDecompileConfig{
async fn download_decompile(config:DownloadDecompileConfig)->AResult<()>{ async fn download_decompile(config:DownloadDecompileConfig)->AResult<()>{
let context=CloudContext::new(config.api_key); 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 dom=load_dom(std::io::Cursor::new(file))?;
let context=rox_compiler::DecompiledContext::from_dom(dom); 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|{ .map(|asset_version|{
let context=context.clone(); let context=context.clone();
tokio::task::spawn(async move{ 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))?; let dom=load_dom(std::io::Cursor::new(file))?;
Ok::<_,anyhow::Error>((asset_version,rox_compiler::DecompiledContext::from_dom(dom))) 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 //upload it
let context=CloudContext::new(config.api_key); 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, universeId:config.universe_id,
placeId:config.place_id, placeId:config.place_id,
},data).await?; },data).await?;