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
21 changes: 21 additions & 0 deletions flixpy/flix/extension/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,12 @@ def status(self) -> types.Status:

return status

@property
def selected_panels(self) -> list[types.PanelSelection]:
if self.online and self.project.sequence_revision:
return self.panel_browser_status.revision_status.panel_selection
return []

async def _on_connect(self) -> None:
logger.info("connected to Flix Client, subscribing to events")
events = models.SubscribeRequest(
Expand Down Expand Up @@ -433,6 +439,21 @@ async def get_status(self) -> types.PanelBrowserStatus:

return types.PanelBrowserStatus.from_model(resp)

async def get_current_versions(self) -> types.VersionResponse:
"""Get details about the current status of the Flix Client.

Returns:
An object containing information about the current Flix Client status.
"""
from .extension_api.api.info import info_controller_get

resp = _assert_response(
models.InfoResponse,
await info_controller_get.asyncio_detailed(client=await self._get_registered_client()),
)

return types.VersionResponse.from_model(resp)

async def import_panels(
self,
paths: list[str],
Expand Down
88 changes: 74 additions & 14 deletions flixpy/flix/extension/extension_api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -68,18 +68,24 @@ info:
### Step 5: All done

That's it! You're now ready to interact with the Flix Client and ready to turn “My First Flix Extension” into the best thing ever. Although, maybe come up with a better name first.
version: v1
contact: {}
version: v1.1.0
contact:
url: http://www.foundry.com
email: support@foundry.com
license:
name: Apache 2.0
url: https://www.apache.org/licenses/LICENSE-2.0.html
termsOfService: https://www.foundry.com/eula
servers:
- url: http://localhost:3000
description: Flix Client API
tags:
- name: Health Check
description: |
The health check endpoint is a basic test entrypoint for the Flix Client API and will always return a 200 OK response when the API is available. This endpoint can be used as a sanity check to validate connections to Flix before first connecting or after a disconnect.
- name: Info
description: |
The Info endpoint provides essential information about the supported versions and the current client version. This endpoint consistently returns a 200 OK response when the API is operational.
- name: API Registration
description: |
Most of the Flix Client API is gated behind a simple API registration process. Each API consumer must first register with Flix by sending a POST request to http://localhost:3000/registration. The token in the registration response should be attached as a bearer token in the authorization header with future requests. To validate the registration, do a GET request to the same registration endpoint along with the auth header, and the registered API consumer details should be returned.
Expand Down Expand Up @@ -107,6 +113,9 @@ tags:
- name: Media Object Download
description: |
The download endpoint provides the ability for an extension to request a specific asset from the Flix Server and have the Flix Client download it to a specified location. Before using this endpoint, you will need to figure out the ID of the asset to be downloaded and the type of the media object required, either using the other API endpoints or from the Flix Server API. Requests to the download API endpoint will begin the download immediately and will not complete until the download has finished, which means the request may be long-lived.
- name: Preferences
description: |
The preferences endpoint provides a lookup for the current Flix Client user preferences. A GET request to this endpoint will return the full list of preferences currently set in the client. This can optionally be filtered down by specifying a subset of properties via the `keys` query parameter. This can either be a comma separated string, or be specified multiple times for each desired preference.
paths:
/health:
get:
Expand All @@ -119,6 +128,21 @@ paths:
description: ''
tags:
- Health Check
/info:
get:
operationId: InfoController_get
summary: Flix Client details
description: Provides details of current Flix Client and GRC API. Always returns a 200 response.
parameters: []
responses:
'200':
description: Flix Client details successfully returned
content:
application/json:
schema:
$ref: '#/components/schemas/InfoResponse'
tags:
- Info
/registration:
post:
operationId: RegistrationController_registerClient
Expand Down Expand Up @@ -329,18 +353,18 @@ paths:
security:
- bearer: []
/preferences:
post:
operationId: PreferencesController_post
get:
operationId: PreferencesController_lookupPreferences
summary: Get Flix Preferences Values
parameters: []
requestBody:
required: true
content:
application/json:
schema:
type: array
items:
type: string
parameters:
- name: keys
required: false
in: query
description: A list of keys for which to return the user preference values. Can either be a comma-separated list, or specified multiple times.
schema:
type: array
items:
type: string
responses:
'200':
description: Returns a Config object for a provided list of preferences set in the Flix Client
Expand All @@ -366,6 +390,20 @@ components:
bearerFormat: JWT
type: http
schemas:
InfoResponse:
type: object
properties:
flixVersion:
type: string
description: Current Flix Client version.
supportedApiVersions:
description: Supported GRC API versions.
type: array
items:
type: string
required:
- flixVersion
- supportedApiVersions
SubscribeRequest:
type: object
properties:
Expand Down Expand Up @@ -977,12 +1015,29 @@ components:
- episode
- sequence
- sequenceRevision
PanelSelectionResponse:
type: object
properties:
id:
type: integer
description: The ID of the selected panel.
revisionId:
type: integer
description: The revision of the selected panel.
index:
type: integer
description: The current index in the panel browser of the selected panel.
required:
- id
- revisionId
- index
RevisionStatusResponse:
type: object
properties:
selectedPanels:
type: array
description: A list of the currently selected panels.
description: A list of the currently selected panel IDs.
deprecated: true
items:
type: integer
canSave:
Expand All @@ -994,6 +1049,11 @@ components:
canExport:
type: boolean
description: Whether the user has permission to export files from the current revision.
panelSelection:
description: A list of the currently selected panel details, including ID.
type: array
items:
$ref: '#/components/schemas/PanelSelectionResponse'
required:
- selectedPanels
- canSave
Expand Down
Empty file.
134 changes: 134 additions & 0 deletions flixpy/flix/extension/extension_api/api/info/info_controller_get.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
from http import HTTPStatus
from typing import Any, Dict, Optional, Union

import httpx

from ... import errors
from ...client import AuthenticatedClient, Client
from ...models.info_response import InfoResponse
from ...types import Response


def _get_kwargs() -> Dict[str, Any]:
pass

return {
"method": "get",
"url": "/info",
}


def _parse_response(
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
) -> Optional[InfoResponse]:
if response.status_code == HTTPStatus.OK:
response_200 = InfoResponse.from_dict(response.json())

return response_200
if client.raise_on_unexpected_status:
raise errors.UnexpectedStatus(response.status_code, response.content)
else:
return None


def _build_response(
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
) -> Response[InfoResponse]:
return Response(
status_code=HTTPStatus(response.status_code),
content=response.content,
headers=response.headers,
parsed=_parse_response(client=client, response=response),
)


def sync_detailed(
*,
client: Union[AuthenticatedClient, Client],
) -> Response[InfoResponse]:
"""Flix Client details

Provides details of current Flix Client and GRC API. Always returns a 200 response.

Raises:
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
httpx.TimeoutException: If the request takes longer than Client.timeout.

Returns:
Response[InfoResponse]
"""

kwargs = _get_kwargs()

response = client.get_httpx_client().request(
**kwargs,
)

return _build_response(client=client, response=response)


def sync(
*,
client: Union[AuthenticatedClient, Client],
) -> Optional[InfoResponse]:
"""Flix Client details

Provides details of current Flix Client and GRC API. Always returns a 200 response.

Raises:
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
httpx.TimeoutException: If the request takes longer than Client.timeout.

Returns:
InfoResponse
"""

return sync_detailed(
client=client,
).parsed


async def asyncio_detailed(
*,
client: Union[AuthenticatedClient, Client],
) -> Response[InfoResponse]:
"""Flix Client details

Provides details of current Flix Client and GRC API. Always returns a 200 response.

Raises:
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
httpx.TimeoutException: If the request takes longer than Client.timeout.

Returns:
Response[InfoResponse]
"""

kwargs = _get_kwargs()

response = await client.get_async_httpx_client().request(**kwargs)

return _build_response(client=client, response=response)


async def asyncio(
*,
client: Union[AuthenticatedClient, Client],
) -> Optional[InfoResponse]:
"""Flix Client details

Provides details of current Flix Client and GRC API. Always returns a 200 response.

Raises:
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
httpx.TimeoutException: If the request takes longer than Client.timeout.

Returns:
InfoResponse
"""

return (
await asyncio_detailed(
client=client,
)
).parsed
Loading