mixpeek 0.6.27__py3-none-any.whl → 0.6.29__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
mixpeek/client.py CHANGED
@@ -19,6 +19,8 @@ class Mixpeek:
19
19
  self.extract = Extract(self.base_url, self.headers)
20
20
  self.embed = Embed(self.base_url, self.headers)
21
21
  self.generate = Generate(self.base_url, self.headers)
22
- self.connections = Connections(self.base_url, self.headers)
22
+
23
+ # we include api_key as well because the header is different for upload
24
+ self.connections = Connections(self.base_url, self.headers, self.api_key)
23
25
  self.tools = Tools(self.base_url, self.headers)
24
26
  self.pipelines = Pipelines(self.base_url, self.headers)
@@ -1,10 +1,13 @@
1
1
  import requests
2
+ import os
2
3
 
3
4
  class Connections:
4
- def __init__(self, base_url, headers):
5
+ def __init__(self, base_url, headers, api_key):
5
6
  self.base_url = base_url
6
7
  self.headers = headers
8
+ self.api_key = api_key
7
9
  self.data = self.Data(self)
10
+ self.storage = self.Storage(self)
8
11
 
9
12
  def create(self, alias: str, engine: str, details: dict):
10
13
  url = f"{self.base_url}connections/"
@@ -32,5 +35,37 @@ class Connections:
32
35
  # mixpeek.connections.data.upsert(connection_id="123", payload={"key": "value"}, filters={"key": "value"})
33
36
  def upsert(self, connection_id: str, payload: dict, filters: dict):
34
37
  pass
38
+
39
+
40
+ class Storage:
41
+ def __init__(self, parent):
42
+ self.base_url = parent.base_url
43
+ self.headers = parent.headers
44
+ self.api_key = parent.api_key
45
+
46
+ def upload(self, connection_id: str, file_path: str, prefix: str = None):
47
+ url = f"{self.base_url}connections/storage?connection_id={connection_id}"
48
+ if prefix:
49
+ url += f"&prefix={prefix}"
50
+
51
+ files=[
52
+ ('file',(os.path.basename(file_path),open(file_path,'rb'),'application/octet-stream'))
53
+ ]
54
+ headers = {
55
+ 'Authorization': f'Bearer {self.api_key}'
56
+ }
57
+
58
+ response = requests.request("POST", url, headers=headers, files=files)
59
+
60
+ return response.json()
61
+
62
+
63
+ # mixpeek.connections.storage.delete(connection_id="123", file_name="example.txt")
64
+ def delete(self, connection_id: str, file_name: str):
65
+ url = f"{self.base_url}storage/{connection_id}/delete/{file_name}"
66
+ response = requests.delete(url, headers=self.headers)
67
+ return response.json()
68
+
69
+
35
70
 
36
71
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: mixpeek
3
- Version: 0.6.27
3
+ Version: 0.6.29
4
4
  Summary: Mixpeek Python SDK
5
5
  Home-page: https://github.com/mixpeek/mixpeek-python
6
6
  Author: Ethan Steininger
@@ -101,6 +101,15 @@ mixpeek.connections.data.delete(
101
101
  )
102
102
  ```
103
103
 
104
+ Upload file
105
+
106
+ ```python
107
+ mixpeek.connections.storage.upload(
108
+ connection_id="conn_321",
109
+ file_path="/my/local/file.mp4"
110
+ )
111
+ ```
112
+
104
113
  ### Tools
105
114
 
106
115
  ```python
@@ -1,14 +1,14 @@
1
1
  mixpeek/__init__.py,sha256=XDdcK7wTEOEcF1cp-GeWmgPJ21Ny1R9pB0PPNrdDTMo,28
2
- mixpeek/client.py,sha256=mrMHTmWX0c1XIxDqgx404ZNOmWRnjnm8Bs_21MYcNS0,897
2
+ mixpeek/client.py,sha256=ifN-rCXtCbitTj6coUquQjpHgd98V3EVwORzNo8tIMY,992
3
3
  mixpeek/exceptions.py,sha256=Orhdo5UFLn3fcWVJtlgkznW8Iy5ndL96h0qTY8zOlDA,235
4
4
  mixpeek/endpoints/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
- mixpeek/endpoints/connections.py,sha256=H0reF7RSmCJzF62eOavF5tj0kQi82XcdxfbpNsGlEvg,1219
5
+ mixpeek/endpoints/connections.py,sha256=S9_328Kk3dXO4icyKPBTlAd7M83lmD4hG2fFtKjfAwQ,2430
6
6
  mixpeek/endpoints/embed.py,sha256=8ds_FinxZRW-ZQyv6LjDAX6Zoek2Cv4OYhwIgSBqwTs,1598
7
7
  mixpeek/endpoints/extract.py,sha256=PRY1ZjPPwJ3xEKNKVdWIm_WZeRNc68oJKcwVXNkv-S8,1706
8
8
  mixpeek/endpoints/generate.py,sha256=SFjVYfgeuIt4wO0I5ItnB4TEHhRkLgZOvQfWlEioye8,594
9
9
  mixpeek/endpoints/pipelines.py,sha256=X2mRsWgOx6FgWbInrAdjLQJbjXjorNqAo9mjFawLpoE,1210
10
10
  mixpeek/endpoints/tools.py,sha256=Ni9AYm2-jpDS1SLUohNLTOkXDUxLPnNLpTlhWJLfofs,791
11
- mixpeek-0.6.27.dist-info/METADATA,sha256=qaT8NfMKJ42gpHGQq0pIVNM1F3lCjQWsvnEKmwX_rxo,1952
12
- mixpeek-0.6.27.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
13
- mixpeek-0.6.27.dist-info/top_level.txt,sha256=EJ8Jc4IhqyUwnUlBwKbs498Ju4O9a-IDh2kXc_lo6Vg,8
14
- mixpeek-0.6.27.dist-info/RECORD,,
11
+ mixpeek-0.6.29.dist-info/METADATA,sha256=nZ9ZirutvyKfp5gg0C_fdUDAOuNbUO09k_TPLg68zaw,2083
12
+ mixpeek-0.6.29.dist-info/WHEEL,sha256=cpQTJ5IWu9CdaPViMhC9YzF8gZuS5-vlfoFihTBC86A,91
13
+ mixpeek-0.6.29.dist-info/top_level.txt,sha256=EJ8Jc4IhqyUwnUlBwKbs498Ju4O9a-IDh2kXc_lo6Vg,8
14
+ mixpeek-0.6.29.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: bdist_wheel (0.43.0)
2
+ Generator: setuptools (70.1.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5