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