Skip to content

Commit

Permalink
feat: add admin_create_bucket API
Browse files Browse the repository at this point in the history
  • Loading branch information
zensh committed Oct 26, 2024
1 parent f895eb4 commit dcc6f91
Show file tree
Hide file tree
Showing 11 changed files with 313 additions and 55 deletions.
12 changes: 6 additions & 6 deletions 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
Expand Up @@ -17,7 +17,7 @@ strip = true
opt-level = 's'

[workspace.package]
version = "0.9.8"
version = "0.9.9"
edition = "2021"
repository = "https://github.com/ldclabs/ic-oss"
keywords = ["file", "storage", "oss", "s3", "icp"]
Expand Down
2 changes: 1 addition & 1 deletion src/ic_oss_bucket/src/api_query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ fn get_bucket_info(_access_token: Option<ByteBuf>) -> Result<BucketInfo, String>
auditors: r.auditors.clone(),
trusted_ecdsa_pub_keys: r.trusted_ecdsa_pub_keys.clone(),
trusted_eddsa_pub_keys: r.trusted_eddsa_pub_keys.clone(),
governance_canister: r.governance_canister.clone(),
governance_canister: r.governance_canister,
}))
}

Expand Down
2 changes: 1 addition & 1 deletion src/ic_oss_bucket/src/store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1351,7 +1351,7 @@ pub mod fs {
let mut folders = r.borrow_mut();
let folder = folders.parent_to_update(id)?;
let files = folder.files.clone();
checker(&folder)?;
checker(folder)?;

FS_METADATA_STORE.with(|r| {
let mut fs_metadata = r.borrow_mut();
Expand Down
61 changes: 46 additions & 15 deletions src/ic_oss_cluster/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,42 +17,57 @@

```shell
access_token : (principal) -> (Result);
admin_add_committers : (vec principal) -> (Result_1);
admin_add_managers : (vec principal) -> (Result_1);
admin_add_wasm : (AddWasmInput, opt blob) -> (Result_1);
admin_attach_policies : (Token) -> (Result_1);
admin_batch_call_buckets : (vec principal, text, opt blob) -> (Result_2);
admin_create_bucket : (opt CanisterSettings, opt blob) -> (Result_3);
admin_deploy_bucket : (DeployWasmInput, opt blob) -> (Result_1);
admin_detach_policies : (Token) -> (Result_1);
admin_ed25519_access_token : (Token) -> (Result);
admin_remove_committers : (vec principal) -> (Result_1);
admin_remove_managers : (vec principal) -> (Result_1);
admin_set_managers : (vec principal) -> (Result_1);
admin_sign_access_token : (Token) -> (Result);
admin_topup_all_buckets : () -> (Result_3);
admin_topup_all_buckets : () -> (Result_4);
admin_update_bucket_canister_settings : (UpdateSettingsArgument) -> (
Result_1,
);
admin_upgrade_all_buckets : (opt blob) -> (Result_1);
admin_weak_access_token : (Token, nat64, nat64) -> (Result) query;
bucket_deployment_logs : (opt nat, opt nat) -> (Result_4) query;
bucket_deployment_logs : (opt nat, opt nat) -> (Result_5) query;
ed25519_access_token : (principal) -> (Result);
get_bucket_wasm : (blob) -> (Result_5) query;
get_buckets : () -> (Result_6) query;
get_cluster_info : () -> (Result_7) query;
get_deployed_buckets : () -> (Result_4) query;
get_subject_policies : (principal) -> (Result_8) query;
get_subject_policies_for : (principal, principal) -> (Result_9) query;
validate2_admin_add_wasm : (AddWasmInput, opt blob) -> (Result_9);
get_bucket_wasm : (blob) -> (Result_6) query;
get_buckets : () -> (Result_7) query;
get_canister_status : (opt principal) -> (Result_8);
get_cluster_info : () -> (Result_9) query;
get_deployed_buckets : () -> (Result_5) query;
get_subject_policies : (principal) -> (Result_10) query;
get_subject_policies_for : (principal, principal) -> (Result_11) query;
validate2_admin_add_wasm : (AddWasmInput, opt blob) -> (Result_11);
validate2_admin_batch_call_buckets : (vec principal, text, opt blob) -> (
Result_9,
Result_11,
);
validate2_admin_deploy_bucket : (DeployWasmInput, opt blob) -> (Result_9);
validate2_admin_set_managers : (vec principal) -> (Result_9);
validate2_admin_upgrade_all_buckets : (opt blob) -> (Result_9);
validate_admin_add_managers : (vec principal) -> (Result_9);
validate2_admin_deploy_bucket : (DeployWasmInput, opt blob) -> (Result_11);
validate2_admin_set_managers : (vec principal) -> (Result_11);
validate2_admin_upgrade_all_buckets : (opt blob) -> (Result_11);
validate_admin_add_committers : (vec principal) -> (Result_11);
validate_admin_add_managers : (vec principal) -> (Result_11);
validate_admin_add_wasm : (AddWasmInput, opt blob) -> (Result_1);
validate_admin_batch_call_buckets : (vec principal, text, opt blob) -> (
Result_2,
);
validate_admin_create_bucket : (opt CanisterSettings, opt blob) -> (
Result_11,
);
validate_admin_deploy_bucket : (DeployWasmInput, opt blob) -> (Result_1);
validate_admin_remove_managers : (vec principal) -> (Result_9);
validate_admin_remove_committers : (vec principal) -> (Result_11);
validate_admin_remove_managers : (vec principal) -> (Result_11);
validate_admin_set_managers : (vec principal) -> (Result_1);
validate_admin_update_bucket_canister_settings : (UpdateSettingsArgument) -> (
Result_11,
);
validate_admin_upgrade_all_buckets : (opt blob) -> (Result_1);
```

Expand Down Expand Up @@ -108,6 +123,22 @@ dfx canister call ic_oss_cluster admin_detach_policies '(record {

# get access token for a audience
dfx canister call ic_oss_cluster access_token '(principal "mmrxu-fqaaa-aaaap-ahhna-cai")'


# Add a wasm file to the cluster:
ic-oss-cli -i debug/uploader.pem cluster-add-wasm -c x5573-nqaaa-aaaap-ahopq-cai --path debug/ic_oss_bucket.wasm.gz --description "ic_oss_bucket v0.9.8"

# get wasm file
shasum -a 256 debug/ic_oss_bucket.wasm.gz
dfx canister call ic_oss_cluster get_bucket_wasm '(blob "\2d\f4\25\d7\ed\ea\ba\3c\27\39\f0\f5\66\73\90\66\69\5c\f1\8c\53\fd\38\cf\9b\ef\cb\14\e9\f6\22\57")'

# create a bucket with default settings
dfx canister call ic_oss_cluster admin_create_bucket '(null, null)'
# (variant { Ok = principal "ctiya-peaaa-aaaaa-qaaja-cai" })

# get canister status
dfx canister call ic_oss_cluster get_canister_status '(null)'
dfx canister call ic_oss_cluster get_canister_status '(opt principal "ctiya-peaaa-aaaaa-qaaja-cai")'
```

## License
Expand Down
102 changes: 80 additions & 22 deletions src/ic_oss_cluster/ic_oss_cluster.did
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,26 @@ type BucketDeploymentInfo = record {
canister : principal;
wasm_hash : blob;
};
type CanisterSettings = record {
freezing_threshold : opt nat;
controllers : opt vec principal;
reserved_cycles_limit : opt nat;
log_visibility : opt LogVisibility;
wasm_memory_limit : opt nat;
memory_allocation : opt nat;
compute_allocation : opt nat;
};
type CanisterStatusResponse = record {
status : CanisterStatusType;
memory_size : nat;
cycles : nat;
settings : DefiniteCanisterSettings;
query_stats : QueryStats;
idle_cycles_burned_per_day : nat;
module_hash : opt blob;
reserved_cycles : nat;
};
type CanisterStatusType = variant { stopped; stopping; running };
type ChainArgs = variant { Upgrade : UpgradeArgs; Init : InitArgs };
type ClusterInfo = record {
ecdsa_token_public_key : text;
Expand All @@ -23,6 +43,16 @@ type ClusterInfo = record {
schnorr_key_name : text;
bucket_deployment_logs : nat64;
subject_authz_total : nat64;
committers : vec principal;
};
type DefiniteCanisterSettings = record {
freezing_threshold : nat;
controllers : vec principal;
reserved_cycles_limit : nat;
log_visibility : LogVisibility;
wasm_memory_limit : nat;
memory_allocation : nat;
compute_allocation : nat;
};
type DeployWasmInput = record { args : opt blob; canister : principal };
type InitArgs = record {
Expand All @@ -34,21 +64,34 @@ type InitArgs = record {
bucket_topup_amount : nat;
schnorr_key_name : text;
};
type LogVisibility = variant { controllers; public };
type QueryStats = record {
response_payload_bytes_total : nat;
num_instructions_total : nat;
num_calls_total : nat;
request_payload_bytes_total : nat;
};
type Result = variant { Ok : blob; Err : text };
type Result_1 = variant { Ok; Err : text };
type Result_10 = variant { Ok : vec record { principal; text }; Err : text };
type Result_11 = variant { Ok : text; Err : text };
type Result_2 = variant { Ok : vec blob; Err : text };
type Result_3 = variant { Ok : nat; Err : text };
type Result_4 = variant { Ok : vec BucketDeploymentInfo; Err : text };
type Result_5 = variant { Ok : WasmInfo; Err : text };
type Result_6 = variant { Ok : vec principal; Err : text };
type Result_7 = variant { Ok : ClusterInfo; Err : text };
type Result_8 = variant { Ok : vec record { principal; text }; Err : text };
type Result_9 = variant { Ok : text; Err : text };
type Result_3 = variant { Ok : principal; Err : text };
type Result_4 = variant { Ok : nat; Err : text };
type Result_5 = variant { Ok : vec BucketDeploymentInfo; Err : text };
type Result_6 = variant { Ok : WasmInfo; Err : text };
type Result_7 = variant { Ok : vec principal; Err : text };
type Result_8 = variant { Ok : CanisterStatusResponse; Err : text };
type Result_9 = variant { Ok : ClusterInfo; Err : text };
type Token = record {
subject : principal;
audience : principal;
policies : text;
};
type UpdateSettingsArgument = record {
canister_id : principal;
settings : CanisterSettings;
};
type UpgradeArgs = record {
governance_canister : opt principal;
name : opt text;
Expand All @@ -65,41 +108,56 @@ type WasmInfo = record {
};
service : (opt ChainArgs) -> {
access_token : (principal) -> (Result);
admin_add_committers : (vec principal) -> (Result_1);
admin_add_managers : (vec principal) -> (Result_1);
admin_add_wasm : (AddWasmInput, opt blob) -> (Result_1);
admin_attach_policies : (Token) -> (Result_1);
admin_batch_call_buckets : (vec principal, text, opt blob) -> (Result_2);
admin_create_bucket : (opt CanisterSettings, opt blob) -> (Result_3);
admin_deploy_bucket : (DeployWasmInput, opt blob) -> (Result_1);
admin_detach_policies : (Token) -> (Result_1);
admin_ed25519_access_token : (Token) -> (Result);
admin_remove_committers : (vec principal) -> (Result_1);
admin_remove_managers : (vec principal) -> (Result_1);
admin_set_managers : (vec principal) -> (Result_1);
admin_sign_access_token : (Token) -> (Result);
admin_topup_all_buckets : () -> (Result_3);
admin_topup_all_buckets : () -> (Result_4);
admin_update_bucket_canister_settings : (UpdateSettingsArgument) -> (
Result_1,
);
admin_upgrade_all_buckets : (opt blob) -> (Result_1);
admin_weak_access_token : (Token, nat64, nat64) -> (Result) query;
bucket_deployment_logs : (opt nat, opt nat) -> (Result_4) query;
bucket_deployment_logs : (opt nat, opt nat) -> (Result_5) query;
ed25519_access_token : (principal) -> (Result);
get_bucket_wasm : (blob) -> (Result_5) query;
get_buckets : () -> (Result_6) query;
get_cluster_info : () -> (Result_7) query;
get_deployed_buckets : () -> (Result_4) query;
get_subject_policies : (principal) -> (Result_8) query;
get_subject_policies_for : (principal, principal) -> (Result_9) query;
validate2_admin_add_wasm : (AddWasmInput, opt blob) -> (Result_9);
get_bucket_wasm : (blob) -> (Result_6) query;
get_buckets : () -> (Result_7) query;
get_canister_status : (opt principal) -> (Result_8);
get_cluster_info : () -> (Result_9) query;
get_deployed_buckets : () -> (Result_5) query;
get_subject_policies : (principal) -> (Result_10) query;
get_subject_policies_for : (principal, principal) -> (Result_11) query;
validate2_admin_add_wasm : (AddWasmInput, opt blob) -> (Result_11);
validate2_admin_batch_call_buckets : (vec principal, text, opt blob) -> (
Result_9,
Result_11,
);
validate2_admin_deploy_bucket : (DeployWasmInput, opt blob) -> (Result_9);
validate2_admin_set_managers : (vec principal) -> (Result_9);
validate2_admin_upgrade_all_buckets : (opt blob) -> (Result_9);
validate_admin_add_managers : (vec principal) -> (Result_9);
validate2_admin_deploy_bucket : (DeployWasmInput, opt blob) -> (Result_11);
validate2_admin_set_managers : (vec principal) -> (Result_11);
validate2_admin_upgrade_all_buckets : (opt blob) -> (Result_11);
validate_admin_add_committers : (vec principal) -> (Result_11);
validate_admin_add_managers : (vec principal) -> (Result_11);
validate_admin_add_wasm : (AddWasmInput, opt blob) -> (Result_1);
validate_admin_batch_call_buckets : (vec principal, text, opt blob) -> (
Result_2,
);
validate_admin_create_bucket : (opt CanisterSettings, opt blob) -> (
Result_11,
);
validate_admin_deploy_bucket : (DeployWasmInput, opt blob) -> (Result_1);
validate_admin_remove_managers : (vec principal) -> (Result_9);
validate_admin_remove_committers : (vec principal) -> (Result_11);
validate_admin_remove_managers : (vec principal) -> (Result_11);
validate_admin_set_managers : (vec principal) -> (Result_1);
validate_admin_update_bucket_canister_settings : (UpdateSettingsArgument) -> (
Result_11,
);
validate_admin_upgrade_all_buckets : (opt blob) -> (Result_1);
}
Loading

0 comments on commit dcc6f91

Please sign in to comment.