Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions frameioclient/client.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import re
import sys
import requests
from requests.adapters import HTTPAdapter
Expand All @@ -20,8 +19,8 @@ def __init__(self, token, host='https://api.frame.io'):
self.retry_strategy = Retry(
total=3,
backoff_factor=1,
status_forcelist=[429],
method_whitelist=["POST", "OPTIONS", "GET"]
status_forcelist=[400, 429, 500],
method_whitelist=["POST", "OPTIONS", "GET", "PUT"]
)
self.client_version = ClientVersion.version()
self.headers = Utils.format_headers(self.token, self.client_version)
Expand Down
1 change: 1 addition & 0 deletions frameioclient/service/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
from .logs import AuditLogs
from .comments import Comment
from .projects import Project
from .search import Search
from .links import ReviewLink, PresentationLink
from .helpers import FrameioHelpers
74 changes: 74 additions & 0 deletions frameioclient/service/search.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
from .service import Service

class Search(Service):
def library(self, query, type=None, project_id=None, account_id=None, team_id=None, uploader=None, sort=None, filter=None, page_size=10, page=1):
"""
Search for assets using the library search endpoint, documented here \
https://developer.frame.io/docs/workflows-assets/search-for-assets.

For more information check out https://developer.frame.io/api/reference/operation/librarySearchPost/.

:Args:
query (string): The search keyword you want to search with.
account_id (string): The account ID you want to be searching within. #TODO, confirm that this is required or not, could we use self.me?

:Kwargs:
type (string): The type of frame.io asset you want to search: [file, folder, review_link, presentation].
project_id (uuid): The frame.io project you want to constrain your search to.
account_id (uuid): The frame.io account want you to contrain your search to (you may only have one, but some users have 20+ that they have acces to).
team_id (uuid): The frame.io team you want to constrain your search to.
uploader (string): The name of the uploader, this includes first + last name with a space.
sort (string): The field you want to sort by.
filter (string): This is only necessary if you want to build a fully custom query, the most common functionality is exposed using other kwargs though.
page_size (int): Useful if you want to increase the number of items returned by the search API here.
page (int): The page of results you're requesting.

Example::
client.assets.search(
query="Final",
type="file",
sort="name"
)
"""

# Define base payload
payload = {
"account_id": account_id,
"q": query,
"sort": sort,
"page_size": page_size,
"page": page
}

# Add fully custom filter
if filter is not None:
payload['filter'] = filter

# Add simple filters
if project_id is not None:
payload['filter']['project_id'] = {
"op": "eq",
"value": project_id
}
if team_id is not None:
payload['filter']['team_id'] = {
"op": "eq",
"value": team_id
}
if type is not None:
payload['filter']['type'] = {
"op": "eq",
"value": type
}
if uploader is not None:
payload['filter']['creator.name'] = {
"op": "match",
"value": uploader
}

# Add sorting
if sort is not None:
payload['sort'] = sort

endpoint = '/search/library'
return self.client._api_call('post', endpoint, payload=payload)