@@ -6,6 +6,10 @@ type Time = int;
6
6
type CreateAssetArguments = record {
7
7
key: Key;
8
8
content_type: text;
9
+ max_age: opt nat64;
10
+ headers: opt vec HeaderField;
11
+ enable_aliasing: opt bool;
12
+ allow_raw_access: opt bool;
9
13
};
10
14
11
15
// Add or change content for an asset, by content encoding
@@ -34,19 +38,41 @@ type BatchOperationKind = variant {
34
38
CreateAsset: CreateAssetArguments;
35
39
SetAssetContent: SetAssetContentArguments;
36
40
41
+ SetAssetProperties: SetAssetPropertiesArguments;
42
+
37
43
UnsetAssetContent: UnsetAssetContentArguments;
38
44
DeleteAsset: DeleteAssetArguments;
39
45
40
46
Clear: ClearArguments;
41
47
};
42
48
49
+ type CommitBatchArguments = record {
50
+ batch_id: BatchId;
51
+ operations: vec BatchOperationKind
52
+ };
53
+
54
+ type CommitProposedBatchArguments = record {
55
+ batch_id: BatchId;
56
+ evidence: blob;
57
+ };
58
+
59
+ type ComputeEvidenceArguments = record {
60
+ batch_id: BatchId;
61
+ max_iterations: opt nat16
62
+ };
63
+
64
+ type DeleteBatchArguments = record {
65
+ batch_id: BatchId;
66
+ };
67
+
43
68
type HeaderField = record { text; text; };
44
69
45
70
type HttpRequest = record {
46
71
method: text;
47
72
url: text;
48
73
headers: vec HeaderField;
49
74
body: blob;
75
+ certificate_version: opt nat16;
50
76
};
51
77
52
78
type HttpResponse = record {
@@ -75,7 +101,64 @@ type StreamingStrategy = variant {
75
101
};
76
102
};
77
103
78
- service: {
104
+ type SetAssetPropertiesArguments = record {
105
+ key: Key;
106
+ max_age: opt opt nat64;
107
+ headers: opt opt vec HeaderField;
108
+ allow_raw_access: opt opt bool;
109
+ is_aliased: opt opt bool;
110
+ };
111
+
112
+ type ConfigurationResponse = record {
113
+ max_batches: opt nat64;
114
+ max_chunks: opt nat64;
115
+ max_bytes: opt nat64;
116
+ };
117
+
118
+ type ConfigureArguments = record {
119
+ max_batches: opt opt nat64;
120
+ max_chunks: opt opt nat64;
121
+ max_bytes: opt opt nat64;
122
+ };
123
+
124
+ type Permission = variant {
125
+ Commit;
126
+ ManagePermissions;
127
+ Prepare;
128
+ };
129
+
130
+ type GrantPermission = record {
131
+ to_principal: principal;
132
+ permission: Permission;
133
+ };
134
+ type RevokePermission = record {
135
+ of_principal: principal;
136
+ permission: Permission;
137
+ };
138
+ type ListPermitted = record { permission: Permission };
139
+
140
+ type ValidationResult = variant { Ok : text; Err : text };
141
+
142
+ type AssetCanisterArgs = variant {
143
+ Init: InitArgs;
144
+ Upgrade: UpgradeArgs;
145
+ };
146
+
147
+ type InitArgs = record {};
148
+
149
+ type UpgradeArgs = record {
150
+ set_permissions: opt SetPermissions;
151
+ };
152
+
153
+ /// Sets the list of principals granted each permission.
154
+ type SetPermissions = record {
155
+ prepare: vec principal;
156
+ commit: vec principal;
157
+ manage_permissions: vec principal;
158
+ };
159
+
160
+ service: (asset_canister_args: opt AssetCanisterArgs) -> {
161
+ api_version: () -> (nat16) query;
79
162
80
163
get: (record {
81
164
key: Key;
@@ -108,12 +191,29 @@ service: {
108
191
};
109
192
}) query;
110
193
194
+ certified_tree : (record {}) -> (record {
195
+ certificate: blob;
196
+ tree: blob;
197
+ }) query;
198
+
111
199
create_batch : (record {}) -> (record { batch_id: BatchId });
112
200
113
201
create_chunk: (record { batch_id: BatchId; content: blob }) -> (record { chunk_id: ChunkId });
114
202
115
203
// Perform all operations successfully, or reject
116
- commit_batch: (record { batch_id: BatchId; operations: vec BatchOperationKind }) -> ();
204
+ commit_batch: (CommitBatchArguments) -> ();
205
+
206
+ // Save the batch operations for later commit
207
+ propose_commit_batch: (CommitBatchArguments) -> ();
208
+
209
+ // Given a batch already proposed, perform all operations successfully, or reject
210
+ commit_proposed_batch: (CommitProposedBatchArguments) -> ();
211
+
212
+ // Compute a hash over the CommitBatchArguments. Call until it returns Some(evidence).
213
+ compute_evidence: (ComputeEvidenceArguments) -> (opt blob);
214
+
215
+ // Delete a batch that has been created, or proposed for commit, but not yet committed
216
+ delete_batch: (DeleteBatchArguments) -> ();
117
217
118
218
create_asset: (CreateAssetArguments) -> ();
119
219
set_asset_content: (SetAssetContentArguments) -> ();
@@ -137,4 +237,26 @@ service: {
137
237
http_request_streaming_callback: (token: StreamingCallbackToken) -> (opt StreamingCallbackHttpResponse) query;
138
238
139
239
authorize: (principal) -> ();
240
+ deauthorize: (principal) -> ();
241
+ list_authorized: () -> (vec principal);
242
+ grant_permission: (GrantPermission) -> ();
243
+ revoke_permission: (RevokePermission) -> ();
244
+ list_permitted: (ListPermitted) -> (vec principal);
245
+ take_ownership: () -> ();
246
+
247
+ get_asset_properties : (key: Key) -> (record {
248
+ max_age: opt nat64;
249
+ headers: opt vec HeaderField;
250
+ allow_raw_access: opt bool;
251
+ is_aliased: opt bool; } ) query;
252
+ set_asset_properties: (SetAssetPropertiesArguments) -> ();
253
+
254
+ get_configuration: () -> (ConfigurationResponse);
255
+ configure: (ConfigureArguments) -> ();
256
+
257
+ validate_grant_permission: (GrantPermission) -> (ValidationResult);
258
+ validate_revoke_permission: (RevokePermission) -> (ValidationResult);
259
+ validate_take_ownership: () -> (ValidationResult);
260
+ validate_commit_proposed_batch: (CommitProposedBatchArguments) -> (ValidationResult);
261
+ validate_configure: (ConfigureArguments) -> (ValidationResult);
140
262
}
0 commit comments