##// END OF EJS Templates
file-store: added delete method
milka -
r4669:8740546d default
parent child Browse files
Show More
@@ -1,184 +1,202 b''
1 .. _store-methods-ref:
1 .. _store-methods-ref:
2
2
3 store methods
3 store methods
4 =============
4 =============
5
5
6 file_store_add (EE only)
6 file_store_add (EE only)
7 ------------------------
7 ------------------------
8
8
9 .. py:function:: file_store_add(apiuser, filename, content, description=<Optional:''>)
9 .. py:function:: file_store_add(apiuser, filename, content, description=<Optional:''>)
10
10
11 Upload API for the file_store
11 Upload API for the file_store
12
12
13 Example usage from CLI::
13 Example usage from CLI::
14 rhodecode-api --instance-name=enterprise-1 upload_file "{"content": "$(cat image.jpg | base64)", "filename":"image.jpg"}"
14 rhodecode-api --instance-name=enterprise-1 upload_file "{"content": "$(cat image.jpg | base64)", "filename":"image.jpg"}"
15
15
16 This command takes the following options:
16 This command takes the following options:
17
17
18 :param apiuser: This is filled automatically from the |authtoken|.
18 :param apiuser: This is filled automatically from the |authtoken|.
19 :type apiuser: AuthUser
19 :type apiuser: AuthUser
20 :param filename: name of the file uploaded
20 :param filename: name of the file uploaded
21 :type filename: str
21 :type filename: str
22 :param description: Optional description for added file
22 :param description: Optional description for added file
23 :type description: str
23 :type description: str
24 :param content: base64 encoded content of the uploaded file
24 :param content: base64 encoded content of the uploaded file
25 :type content: str
25 :type content: str
26
26
27 Example output:
27 Example output:
28
28
29 .. code-block:: bash
29 .. code-block:: bash
30
30
31 id : <id_given_in_input>
31 id : <id_given_in_input>
32 result: {
32 result: {
33 "access_path": "/_file_store/download/84d156f7-8323-4ad3-9fce-4a8e88e1deaf-0.jpg",
33 "access_path": "/_file_store/download/84d156f7-8323-4ad3-9fce-4a8e88e1deaf-0.jpg",
34 "access_path_fqn": "http://server.domain.com/_file_store/download/84d156f7-8323-4ad3-9fce-4a8e88e1deaf-0.jpg",
34 "access_path_fqn": "http://server.domain.com/_file_store/download/84d156f7-8323-4ad3-9fce-4a8e88e1deaf-0.jpg",
35 "store_fid": "84d156f7-8323-4ad3-9fce-4a8e88e1deaf-0.jpg"
35 "store_fid": "84d156f7-8323-4ad3-9fce-4a8e88e1deaf-0.jpg"
36 }
36 }
37 error : null
37 error : null
38
38
39
39
40 file_store_add_with_acl (EE only)
40 file_store_add_with_acl (EE only)
41 ---------------------------------
41 ---------------------------------
42
42
43 .. py:function:: file_store_add_with_acl(apiuser, filename, content, description=<Optional:''>, scope_user_id=<Optional:None>, scope_repo_id=<Optional:None>, scope_repo_group_id=<Optional:None>)
43 .. py:function:: file_store_add_with_acl(apiuser, filename, content, description=<Optional:''>, scope_user_id=<Optional:None>, scope_repo_id=<Optional:None>, scope_repo_group_id=<Optional:None>)
44
44
45 Upload API for the file_store
45 Upload API for the file_store
46
46
47 Example usage from CLI::
47 Example usage from CLI::
48 rhodecode-api --instance-name=enterprise-1 upload_file "{"content": "$(cat image.jpg | base64)", "filename":"image.jpg", "scope_repo_id":101}"
48 rhodecode-api --instance-name=enterprise-1 upload_file "{"content": "$(cat image.jpg | base64)", "filename":"image.jpg", "scope_repo_id":101}"
49
49
50 This command takes the following options:
50 This command takes the following options:
51
51
52 :param apiuser: This is filled automatically from the |authtoken|.
52 :param apiuser: This is filled automatically from the |authtoken|.
53 :type apiuser: AuthUser
53 :type apiuser: AuthUser
54 :param filename: name of the file uploaded
54 :param filename: name of the file uploaded
55 :type filename: str
55 :type filename: str
56 :param description: Optional description for added file
56 :param description: Optional description for added file
57 :type description: str
57 :type description: str
58 :param content: base64 encoded content of the uploaded file
58 :param content: base64 encoded content of the uploaded file
59 :type content: str
59 :type content: str
60
60
61 :param scope_user_id: Optionally bind this file to user.
61 :param scope_user_id: Optionally bind this file to user.
62 This will check ACL in such way only this user can access the file.
62 This will check ACL in such way only this user can access the file.
63 :type scope_user_id: int
63 :type scope_user_id: int
64 :param scope_repo_id: Optionally bind this file to repository.
64 :param scope_repo_id: Optionally bind this file to repository.
65 This will check ACL in such way only user with proper access to such
65 This will check ACL in such way only user with proper access to such
66 repository can access the file.
66 repository can access the file.
67 :type scope_repo_id: int
67 :type scope_repo_id: int
68 :param scope_repo_group_id: Optionally bind this file to repository group.
68 :param scope_repo_group_id: Optionally bind this file to repository group.
69 This will check ACL in such way only user with proper access to such
69 This will check ACL in such way only user with proper access to such
70 repository group can access the file.
70 repository group can access the file.
71 :type scope_repo_group_id: int
71 :type scope_repo_group_id: int
72
72
73 Example output:
73 Example output:
74
74
75 .. code-block:: bash
75 .. code-block:: bash
76
76
77 id : <id_given_in_input>
77 id : <id_given_in_input>
78 result: {
78 result: {
79 "access_path": "/_file_store/download/84d156f7-8323-4ad3-9fce-4a8e88e1deaf-0.jpg",
79 "access_path": "/_file_store/download/84d156f7-8323-4ad3-9fce-4a8e88e1deaf-0.jpg",
80 "access_path_fqn": "http://server.domain.com/_file_store/download/84d156f7-8323-4ad3-9fce-4a8e88e1deaf-0.jpg",
80 "access_path_fqn": "http://server.domain.com/_file_store/download/84d156f7-8323-4ad3-9fce-4a8e88e1deaf-0.jpg",
81 "store_fid": "84d156f7-8323-4ad3-9fce-4a8e88e1deaf-0.jpg"
81 "store_fid": "84d156f7-8323-4ad3-9fce-4a8e88e1deaf-0.jpg"
82 }
82 }
83 error : null
83 error : null
84
84
85
85
86 file_store_get_info (EE only)
86 file_store_get_info (EE only)
87 -----------------------------
87 -----------------------------
88
88
89 .. py:function:: file_store_get_info(apiuser, store_fid)
89 .. py:function:: file_store_get_info(apiuser, store_fid)
90
90
91 Get artifact data.
91 Get artifact data.
92
92
93 Example output:
93 Example output:
94
94
95 .. code-block:: bash
95 .. code-block:: bash
96
96
97 id : <id_given_in_input>
97 id : <id_given_in_input>
98 result: {
98 result: {
99 "artifact": {
99 "artifact": {
100 "access_path_fqn": "https://rhodecode.example.com/_file_store/download/0-031c2aa0-0d56-49a7-9ba3-b570bdd342ab.jpg",
100 "access_path_fqn": "https://rhodecode.example.com/_file_store/download/0-031c2aa0-0d56-49a7-9ba3-b570bdd342ab.jpg",
101 "created_on": "2019-10-15T16:25:35.491",
101 "created_on": "2019-10-15T16:25:35.491",
102 "description": "my upload",
102 "description": "my upload",
103 "downloaded_times": 1,
103 "downloaded_times": 1,
104 "file_uid": "0-031c2aa0-0d56-49a7-9ba3-b570bdd342ab.jpg",
104 "file_uid": "0-031c2aa0-0d56-49a7-9ba3-b570bdd342ab.jpg",
105 "filename": "example.jpg",
105 "filename": "example.jpg",
106 "filename_org": "0-031c2aa0-0d56-49a7-9ba3-b570bdd342ab.jpg",
106 "filename_org": "0-031c2aa0-0d56-49a7-9ba3-b570bdd342ab.jpg",
107 "hidden": false,
107 "hidden": false,
108 "metadata": [
108 "metadata": [
109 {
109 {
110 "artifact": "0-031c2aa0-0d56-49a7-9ba3-b570bdd342ab.jpg",
110 "artifact": "0-031c2aa0-0d56-49a7-9ba3-b570bdd342ab.jpg",
111 "key": "yellow",
111 "key": "yellow",
112 "section": "tags",
112 "section": "tags",
113 "value": "bar"
113 "value": "bar"
114 }
114 }
115 ],
115 ],
116 "sha256": "818dff0f44574dfb6814d38e6bf3c60c5943d1d13653398ecddaedf2f6a5b04d",
116 "sha256": "818dff0f44574dfb6814d38e6bf3c60c5943d1d13653398ecddaedf2f6a5b04d",
117 "size": 18599,
117 "size": 18599,
118 "uploaded_by": {
118 "uploaded_by": {
119 "email": "admin@rhodecode.com",
119 "email": "admin@rhodecode.com",
120 "emails": [
120 "emails": [
121 "admin@rhodecode.com"
121 "admin@rhodecode.com"
122 ],
122 ],
123 "firstname": "Admin",
123 "firstname": "Admin",
124 "lastname": "LastName",
124 "lastname": "LastName",
125 "user_id": 2,
125 "user_id": 2,
126 "username": "admin"
126 "username": "admin"
127 }
127 }
128 }
128 }
129 }
129 }
130 error : null
130 error : null
131
131
132
132
133 file_store_delete (EE only)
134 ---------------------------
135
136 .. py:function:: file_store_delete(apiuser, store_fid)
137
138 Delete an artifact based on the secret uuid.
139
140 Example output:
141
142 .. code-block:: bash
143
144 id : <id_given_in_input>
145 result: {
146 "artifact" : {"uid": "some uid", "removed": true}
147 }
148 error : null
149
150
133 file_store_add_metadata (EE only)
151 file_store_add_metadata (EE only)
134 ---------------------------------
152 ---------------------------------
135
153
136 .. py:function:: file_store_add_metadata(apiuser, store_fid, section, key, value, value_type=<Optional:'unicode'>)
154 .. py:function:: file_store_add_metadata(apiuser, store_fid, section, key, value, value_type=<Optional:'unicode'>)
137
155
138 Add metadata into artifact. The metadata consist of section, key, value. eg.
156 Add metadata into artifact. The metadata consist of section, key, value. eg.
139 section='tags', 'key'='tag_name', value='1'
157 section='tags', 'key'='tag_name', value='1'
140
158
141 :param apiuser: This is filled automatically from the |authtoken|.
159 :param apiuser: This is filled automatically from the |authtoken|.
142 :type apiuser: AuthUser
160 :type apiuser: AuthUser
143
161
144 :param store_fid: file uid, e.g 0-d054cb71-91ab-44e2-9e4b-23fe14b4d74a.mp4
162 :param store_fid: file uid, e.g 0-d054cb71-91ab-44e2-9e4b-23fe14b4d74a.mp4
145 :type store_fid: str
163 :type store_fid: str
146
164
147 :param section: Section name to add metadata
165 :param section: Section name to add metadata
148 :type section: str
166 :type section: str
149
167
150 :param key: Key to add as metadata
168 :param key: Key to add as metadata
151 :type key: str
169 :type key: str
152
170
153 :param value: Value to add as metadata
171 :param value: Value to add as metadata
154 :type value: str
172 :type value: str
155
173
156 :param value_type: Optional type, default is 'unicode' other types are:
174 :param value_type: Optional type, default is 'unicode' other types are:
157 int, list, bool, unicode, str
175 int, list, bool, unicode, str
158
176
159 :type value_type: str
177 :type value_type: str
160
178
161 Example output:
179 Example output:
162
180
163 .. code-block:: bash
181 .. code-block:: bash
164
182
165 id : <id_given_in_input>
183 id : <id_given_in_input>
166 result: {
184 result: {
167 "metadata": [
185 "metadata": [
168 {
186 {
169 "artifact": "0-d054cb71-91ab-44e2-9e4b-23fe14b4d74a.mp4",
187 "artifact": "0-d054cb71-91ab-44e2-9e4b-23fe14b4d74a.mp4",
170 "key": "secret",
188 "key": "secret",
171 "section": "tags",
189 "section": "tags",
172 "value": "1"
190 "value": "1"
173 },
191 },
174 {
192 {
175 "artifact": "0-d054cb71-91ab-44e2-9e4b-23fe14b4d74a.mp4",
193 "artifact": "0-d054cb71-91ab-44e2-9e4b-23fe14b4d74a.mp4",
176 "key": "video",
194 "key": "video",
177 "section": "tags",
195 "section": "tags",
178 "value": "1"
196 "value": "1"
179 }
197 }
180 ]
198 ]
181 }
199 }
182 error : null
200 error : null
183
201
184
202
General Comments 0
You need to be logged in to leave comments. Login now