Skip to content

Commit

Permalink
Merge pull request #15 from waifuvault/new-buckwet-paths
Browse files Browse the repository at this point in the history
Update bucket api paths, remove wild anys in models, fix readme
  • Loading branch information
nakedmcse authored Aug 20, 2024
2 parents 5f4efe7 + f37b862 commit 2355091
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 16 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ To Upload a file, use the `upload_file` function. This function takes the follow
|-------------------|--------------------|-----------------------------------------------------------------|----------------|----------------------------------|
| `target` | `string or buffer` | The target to upload can be a buffer, URL or filename | true | URL or file path |
| `target_name` | `string` | The filename of the target if it is a buffer | true if buffer | Filename with extension |
| `bucket_token` | 'string' | Token for a bucket to upload the file into | false | Create bucket gives token |
| `bucket_token` | `string` | Token for a bucket to upload the file into | false | Create bucket gives token |
| `expires` | `string` | A string containing a number and a unit (1d = 1day) | false | Valid units are `m`, `h` and `d` |
| `hideFilename` | `boolean` | If true, then the uploaded filename won't appear in the URL | false | Defaults to `false` |
| `password` | `string` | If set, then the uploaded file will be encrypted | false | |
Expand Down Expand Up @@ -206,7 +206,7 @@ Deleting a bucket will delete the bucket and all the files it contains.

> **IMPORTANT:** All contained files will be **DELETED** along with the Bucket!
To delete a bucket, you must call the `deleteBucket` function with the following options as parameters:
To delete a bucket, you must call the `delete_bucket` function with the following options as parameters:

| Option | Type | Description | Required | Extra info |
|-------------|-----------|-----------------------------------|----------|-------------------|
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "waifuvault"
version = "1.4.2"
version = "1.4.3"
authors = [
{ name="Walker Aldridge", email="[email protected]" },
]
Expand Down
18 changes: 9 additions & 9 deletions src/waifuvault/waifumodels.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,23 +31,23 @@ def build_parameters(self):
return parameters


class FileOptions:
def __init__(self, hide_filename: bool = False, one_time_download: bool = False, protected: bool = False):
self.hideFilename = hide_filename
self.oneTimeDownload = one_time_download
self.protected = protected


class FileResponse:
def __init__(self, token: str = None, url: str = None, retention_period: any = None, bucket: str = None, options: any = None):
def __init__(self, token: str = None, url: str = None, retention_period: any = None, bucket: str = None, options: FileOptions = None):
self.token = token
self.url = url
self.retentionPeriod = retention_period
self.bucket = bucket
self.options = options


class FileOptions:
def __init__(self, hide_filename: bool = False, one_time_download: bool = False, protected: bool = False):
self.hideFilename = hide_filename
self.oneTimeDownload = one_time_download
self.protected = protected


class BucketResponse:
def __init__(self, token: str = None, files: any = None):
def __init__(self, token: str = None, files: list[FileResponse] = None):
self.token = token
self.files = files
4 changes: 2 additions & 2 deletions src/waifuvault/waifuvault.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

# Create Bucket
def create_bucket():
url = f"{__base_url__}/bucket/createBucket"
url = f"{__base_url__}/bucket/create"
response = requests.get(url)
__check_error(response, False)
return __bucket_to_obj(json.loads(response.text))
Expand All @@ -28,7 +28,7 @@ def delete_bucket(token: str):

# Get Bucket
def get_bucket(token: str):
url = f"{__base_url__}/bucket"
url = f"{__base_url__}/bucket/get"
data = {"bucket_token": token}
response = requests.post(url, json=data)
__check_error(response, False)
Expand Down
4 changes: 2 additions & 2 deletions tests/test_waifuvault.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ def test_create_bucket(mocker):
bucket = waifuvault.create_bucket()

# Then
mock_create.assert_called_once_with('https://waifuvault.moe/rest/bucket/createBucket')
mock_create.assert_called_once_with('https://waifuvault.moe/rest/bucket/create')
assert (bucket.token == "test-bucket"), "Create Bucket did not return bucket"


Expand All @@ -259,7 +259,7 @@ def test_get_bucket(mocker):
bucket = waifuvault.get_bucket("test-bucket")

# Then
mock_get.assert_called_once_with('https://waifuvault.moe/rest/bucket', json={'bucket_token': 'test-bucket'})
mock_get.assert_called_once_with('https://waifuvault.moe/rest/bucket/get', json={'bucket_token': 'test-bucket'})
assert (bucket.token == "test-bucket"), "Get Bucket did not return bucket"


Expand Down

0 comments on commit 2355091

Please sign in to comment.