Reference
GlassFlow Python Client to interact with GlassFlow API
GlassFlowClient ¶
Bases: APIClient
GlassFlow Client to interact with GlassFlow API and manage pipelines and other resources
Attributes:
Name | Type | Description |
---|---|---|
client |
requests.Session object to make HTTP requests to GlassFlow API |
|
glassflow_config |
GlassFlowConfig object to store configuration |
|
organization_id |
Organization ID of the user. If not provided, the default organization will be used |
Parameters:
Name | Type | Description | Default |
---|---|---|---|
personal_access_token |
str
|
GlassFlow Personal Access Token |
None
|
organization_id |
str
|
Organization ID of the user. If not provided, the default organization will be used |
None
|
Source code in src/glassflow/client.py
get_pipeline ¶
get_pipeline(pipeline_id: str) -> Pipeline
Gets a Pipeline object from the GlassFlow API
Parameters:
Name | Type | Description | Default |
---|---|---|---|
pipeline_id |
str
|
UUID of the pipeline |
required |
Returns:
Name | Type | Description |
---|---|---|
Pipeline |
Pipeline
|
Pipeline object from the GlassFlow API |
Raises:
Type | Description |
---|---|
PipelineNotFoundError
|
Pipeline does not exist |
UnauthorizedError
|
User does not have permission to perform the requested operation |
ClientError
|
GlassFlow Client Error |
Source code in src/glassflow/client.py
create_pipeline ¶
create_pipeline(name: str, space_id: str, transformation_file: str = None, requirements: str = None, source_kind: str = None, source_config: dict = None, sink_kind: str = None, sink_config: dict = None, env_vars: list[dict[str, str]] = None, state: PipelineState = 'running', metadata: dict = None) -> Pipeline
Creates a new GlassFlow pipeline
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
str
|
Name of the pipeline |
required |
space_id |
str
|
ID of the GlassFlow Space you want to create the pipeline in |
required |
transformation_file |
str
|
Path to file with transformation function of the pipeline. |
None
|
requirements |
str
|
Requirements.txt of the pipeline |
None
|
source_kind |
str
|
Kind of source for the pipeline. If no source is provided, the default source will be SDK |
None
|
source_config |
dict
|
Configuration of the pipeline's source |
None
|
sink_kind |
str
|
Kind of sink for the pipeline. If no sink is provided, the default sink will be SDK |
None
|
sink_config |
dict
|
Configuration of the pipeline's sink |
None
|
env_vars |
list[dict[str, str]]
|
Environment variables to pass to the pipeline |
None
|
state |
PipelineState
|
State of the pipeline after creation. It can be either "running" or "paused" |
'running'
|
metadata |
dict
|
Metadata of the pipeline |
None
|
Returns:
Name | Type | Description |
---|---|---|
Pipeline |
Pipeline
|
New pipeline |
Raises:
Type | Description |
---|---|
UnauthorizedError
|
User does not have permission to perform the requested operation |
Source code in src/glassflow/client.py
list_pipelines ¶
Lists all pipelines in the GlassFlow API
Parameters:
Name | Type | Description | Default |
---|---|---|---|
space_ids |
list[str] | None
|
List of Space IDs of the pipelines to list. If not specified, all the pipelines will be listed. |
None
|
Returns:
Name | Type | Description |
---|---|---|
ListPipelinesResponse |
ListPipelinesResponse
|
Response object with the pipelines listed |
Raises:
Type | Description |
---|---|
UnauthorizedError
|
User does not have permission to perform the requested operation |
Source code in src/glassflow/client.py
list_spaces ¶
Lists all GlassFlow spaces in the GlassFlow API
Returns:
Name | Type | Description |
---|---|---|
ListSpacesResponse |
ListSpacesResponse
|
Response object with the spaces listed |
Raises:
Type | Description |
---|---|
UnauthorizedError
|
User does not have permission to perform the requested operation |
Source code in src/glassflow/client.py
create_space ¶
create_space(name: str) -> Space
Creates a new Space
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
str
|
Name of the Space |
required |
Returns:
Name | Type | Description |
---|---|---|
Space |
Space
|
New space |
Raises:
Type | Description |
---|---|
UnauthorizedError
|
User does not have permission to perform the requested operation |
Source code in src/glassflow/client.py
Pipeline ¶
Pipeline(personal_access_token: str, name: str | None = None, space_id: str | None = None, id: str | None = None, source_kind: str | None = None, source_config: dict | None = None, sink_kind: str | None = None, sink_config: dict | None = None, requirements: str | None = None, transformation_file: str | None = None, env_vars: list[dict[str, str]] | None = None, state: PipelineState = 'running', organization_id: str | None = None, metadata: dict | None = None, created_at: str | None = None)
Bases: APIClient
Parameters:
Name | Type | Description | Default |
---|---|---|---|
personal_access_token |
str
|
The personal access token to authenticate against GlassFlow |
required |
id |
str | None
|
Pipeline ID |
None
|
name |
str | None
|
Name of the pipeline |
None
|
space_id |
str | None
|
ID of the GlassFlow Space you want to create the pipeline in |
None
|
transformation_file |
str | None
|
Path to file with transformation function of the pipeline. |
None
|
requirements |
str | None
|
Requirements.txt of the pipeline |
None
|
source_kind |
str | None
|
Kind of source for the pipeline. If no source is provided, the default source will be SDK |
None
|
source_config |
dict | None
|
Configuration of the pipeline's source |
None
|
sink_kind |
str | None
|
Kind of sink for the pipeline. If no sink is provided, the default sink will be SDK |
None
|
sink_config |
dict | None
|
Configuration of the pipeline's sink |
None
|
env_vars |
list[dict[str, str]] | None
|
Environment variables to pass to the pipeline |
None
|
state |
PipelineState
|
State of the pipeline after creation. It can be either "running" or "paused" |
'running'
|
metadata |
dict | None
|
Metadata of the pipeline |
None
|
created_at |
str | None
|
Timestamp when the pipeline was created |
None
|
Raises:
Type | Description |
---|---|
FailNotFoundError
|
If the transformation file is provided and does not exist |
Source code in src/glassflow/pipeline.py
fetch ¶
fetch() -> Pipeline
Fetches pipeline information from the GlassFlow API
Returns:
Name | Type | Description |
---|---|---|
self |
Pipeline
|
Pipeline object |
Raises:
Type | Description |
---|---|
ValueError
|
If ID is not provided in the constructor |
PipelineNotFoundError
|
If ID provided does not match any existing pipeline in GlassFlow |
UnauthorizedError
|
If the Personal Access Token is not provider or is invalid |
Source code in src/glassflow/pipeline.py
create ¶
create() -> Pipeline
Creates a new GlassFlow pipeline
Returns:
Name | Type | Description |
---|---|---|
self |
Pipeline
|
Pipeline object |
Raises:
Type | Description |
---|---|
ValueError
|
If name is not provided in the constructor |
ValueError
|
If space_id is not provided in the constructor |
ValueError
|
If transformation_file is not provided in the constructor |
Source code in src/glassflow/pipeline.py
update ¶
update(name: str | None = None, state: PipelineState | None = None, transformation_file: str | None = None, requirements: str | None = None, metadata: dict | None = None, source_kind: str | None = None, source_config: dict | None = None, sink_kind: str | None = None, sink_config: dict | None = None, env_vars: list[dict[str, str]] | None = None) -> Pipeline
Updates a GlassFlow pipeline
Args:
name: Name of the pipeline
state: State of the pipeline after creation.
It can be either "running" or "paused"
transformation_file: Path to file with transformation function of
the pipeline.
requirements: Requirements.txt of the pipeline
source_kind: Kind of source for the pipeline. If no source is
provided, the default source will be SDK
source_config: Configuration of the pipeline's source
sink_kind: Kind of sink for the pipeline. If no sink is provided,
the default sink will be SDK
sink_config: Configuration of the pipeline's sink
env_vars: Environment variables to pass to the pipeline
metadata: Metadata of the pipeline
Returns:
Name | Type | Description |
---|---|---|
self |
Pipeline
|
Updated pipeline |
Source code in src/glassflow/pipeline.py
190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 |
|
delete ¶
Deletes a GlassFlow pipeline
Returns:
Raises:
Type | Description |
---|---|
ValueError
|
If ID is not provided in the constructor |
PipelineNotFoundError
|
If ID provided does not match any existing pipeline in GlassFlow |
UnauthorizedError
|
If the Personal Access Token is not provided or is invalid |
Source code in src/glassflow/pipeline.py
get_logs ¶
get_logs(page_size: int = 50, page_token: str | None = None, severity_code: SeverityCodeInput = api.SeverityCodeInput.integer_100, start_time: str | None = None, end_time: str | None = None) -> GetFunctionLogsResponse
Get the pipeline's logs
Parameters:
Name | Type | Description | Default |
---|---|---|---|
page_size |
int
|
Pagination size |
50
|
page_token |
str | None
|
Page token filter (use for pagination) |
None
|
severity_code |
SeverityCodeInput
|
Severity code filter |
integer_100
|
start_time |
str | None
|
Start time filter |
None
|
end_time |
str | None
|
End time filter |
None
|
Returns:
Name | Type | Description |
---|---|---|
PipelineFunctionsGetLogsResponse |
GetFunctionLogsResponse
|
Response with the logs |
Source code in src/glassflow/pipeline.py
get_source ¶
get_source(pipeline_access_token_name: str | None = None) -> PipelineDataSource
Get source client to publish data to the pipeline
Parameters:
Name | Type | Description | Default |
---|---|---|---|
pipeline_access_token_name |
str | None
|
Name of the pipeline access token to use. If not specified, the default token will be used |
None
|
Returns:
Name | Type | Description |
---|---|---|
PipelineDataSource |
PipelineDataSource
|
Source client to publish data to the pipeline |
Raises:
Type | Description |
---|---|
ValueError
|
If pipeline id is not provided in the constructor |
Source code in src/glassflow/pipeline.py
get_sink ¶
get_sink(pipeline_access_token_name: str | None = None) -> PipelineDataSink
Get sink client to consume data from the pipeline
Parameters:
Name | Type | Description | Default |
---|---|---|---|
pipeline_access_token_name |
str | None
|
Name of the pipeline access token to use. If not specified, the default token will be used |
None
|
Returns:
Name | Type | Description |
---|---|---|
PipelineDataSink |
PipelineDataSink
|
Sink client to consume data from the pipeline |
Raises:
Type | Description |
---|---|
ValueError
|
If pipeline id is not provided in the constructor |
Source code in src/glassflow/pipeline.py
test ¶
Test a pipeline's function with a sample input JSON
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data |
dict
|
Input JSON |
required |
Returns:
Name | Type | Description |
---|---|---|
TestFunctionResponse |
TestFunctionResponse
|
Test function response |
Source code in src/glassflow/pipeline.py
PipelineDataClient ¶
Bases: APIClient
Base Client object to publish and consume events from the given pipeline.
Attributes:
Name | Type | Description |
---|---|---|
glassflow_config |
GlassFlowConfig object to interact with GlassFlow API |
|
pipeline_id |
The pipeline id to interact with |
|
pipeline_access_token |
The access token to access the pipeline |
Source code in src/glassflow/pipeline_data.py
validate_credentials ¶
Check if the pipeline credentials are valid and raise an error if not
Source code in src/glassflow/pipeline_data.py
PipelineDataSource ¶
Bases: PipelineDataClient
Source code in src/glassflow/pipeline_data.py
publish ¶
publish(request_body: dict) -> PublishEventResponse
Push a new message into the pipeline
Parameters:
Name | Type | Description | Default |
---|---|---|---|
request_body |
dict
|
The message to be published into the pipeline |
required |
Returns:
Name | Type | Description |
---|---|---|
PublishEventResponse |
PublishEventResponse
|
Response object containing the status code and the raw response |
Raises:
Type | Description |
---|---|
ClientError
|
If an error occurred while publishing the event |
Source code in src/glassflow/pipeline_data.py
PipelineDataSink ¶
Bases: PipelineDataClient
Source code in src/glassflow/pipeline_data.py
consume ¶
consume() -> ConsumeEventResponse
Consume the last message from the pipeline
Returns:
Name | Type | Description |
---|---|---|
ConsumeEventResponse |
ConsumeEventResponse
|
Response object containing the status code and the raw response |
Raises:
Type | Description |
---|---|
ClientError
|
If an error occurred while consuming the event |
Source code in src/glassflow/pipeline_data.py
consume_failed ¶
consume_failed() -> ConsumeFailedResponse
Consume the failed message from the pipeline
Returns:
Name | Type | Description |
---|---|---|
ConsumeFailedResponse |
ConsumeFailedResponse
|
Response object containing the status code and the raw response |
Raises:
Type | Description |
---|---|
ClientError
|
If an error occurred while consuming the event |
Source code in src/glassflow/pipeline_data.py
Space ¶
Space(personal_access_token: str, name: str | None = None, id: str | None = None, created_at: str | None = None, organization_id: str | None = None)
Bases: APIClient
Parameters:
Name | Type | Description | Default |
---|---|---|---|
personal_access_token |
str
|
The personal access token to authenticate against GlassFlow |
required |
name |
str | None
|
Name of the space |
None
|
id |
str | None
|
ID of the GlassFlow Space you want to create the pipeline in |
None
|
created_at |
str | None
|
Timestamp when the space was created |
None
|
Source code in src/glassflow/space.py
create ¶
create() -> Space
Creates a new GlassFlow space
Returns:
Name | Type | Description |
---|---|---|
self |
Space
|
Space object |
Raises:
Type | Description |
---|---|
ValueError
|
If name is not provided in the constructor |
Source code in src/glassflow/space.py
delete ¶
Deletes a GlassFlow space
Returns:
Raises:
Type | Description |
---|---|
ValueError
|
If ID is not provided in the constructor |
SpaceNotFoundError
|
If ID provided does not match any existing space in GlassFlow |
UnauthorizedError
|
If the Personal Access Token is not provided or is invalid |
Source code in src/glassflow/space.py
GlassFlowConfig
dataclass
¶
GlassFlowConfig(server_url: str = 'https://api.glassflow.dev/v1', sdk_version: str = version('glassflow'), user_agent: str = f'glassflow-python-sdk/{sdk_version}', glassflow_client: str = f'python-sdk/{sdk_version}')
Configuration object for GlassFlowClient
Attributes:
Name | Type | Description |
---|---|---|
server_url |
str
|
The base URL of the GlassFlow API |
sdk_version |
str
|
The version of the GlassFlow Python SDK |
user_agent |
str
|
The user agent to be used in the requests |
ClientError ¶
ClientError(detail: str, status_code: int, body: str, raw_response: Response)
Bases: Exception
Represents an error returned by the API.
Attributes:
Name | Type | Description |
---|---|---|
detail |
str
|
A message describing the error |
status_code |
int
|
The status code of the response |
body |
str
|
The response body |
raw_response |
Response
|
The raw response object |
Parameters:
Name | Type | Description | Default |
---|---|---|---|
detail |
str
|
A message describing the error |
required |
status_code |
int
|
The status code of the response |
required |
body |
str
|
The response body |
required |
raw_response |
Response
|
The raw response object |
required |
Source code in src/glassflow/models/errors/clienterror.py
PipelineAccessTokenInvalidError ¶
PipelineAccessTokenInvalidError(raw_response: Response)
Bases: ClientError
Error caused by invalid access token.
Source code in src/glassflow/models/errors/clienterror.py
PipelineNotFoundError ¶
PipelineNotFoundError(pipeline_id: str, raw_response: Response)
Bases: ClientError
Error caused by a pipeline ID not found.
Source code in src/glassflow/models/errors/clienterror.py
SpaceIsNotEmptyError ¶
SpaceIsNotEmptyError(raw_response: Response)
Bases: ClientError
Error caused by trying to delete a space that is not empty.
Source code in src/glassflow/models/errors/clienterror.py
SpaceNotFoundError ¶
SpaceNotFoundError(space_id: str, raw_response: Response)
Bases: ClientError
Error caused by a pipeline ID not found.
Source code in src/glassflow/models/errors/clienterror.py
UnauthorizedError ¶
UnauthorizedError(raw_response: Response)
Bases: ClientError
Error caused by a user not authorized.
Source code in src/glassflow/models/errors/clienterror.py
UnknownContentTypeError ¶
UnknownContentTypeError(raw_response: Response)
Bases: ClientError
Error caused by an unknown content type response.
Source code in src/glassflow/models/errors/clienterror.py
Error
dataclass
¶
Bases: Exception
Bad request error response
Attributes:
Name | Type | Description |
---|---|---|
message |
A message describing the error |
StatusAccessTokenRequest
dataclass
¶
StatusAccessTokenRequest(pipeline_id: str, organization_id: Optional[str] = None, x_pipeline_access_token: str = None)
Bases: BasePipelineDataRequest
Request check the status of an access token
Attributes:
Name | Type | Description |
---|---|---|
pipeline_id |
The id of the pipeline |
|
organization_id |
The id of the organization |
|
x_pipeline_access_token |
The access token of the pipeline |
ConsumeEventRequest
dataclass
¶
ConsumeEventRequest(pipeline_id: str, organization_id: Optional[str] = None, x_pipeline_access_token: str = None)
Bases: BasePipelineDataRequest
Request to consume an event from a pipeline topic
Attributes:
Name | Type | Description |
---|---|---|
pipeline_id |
The id of the pipeline |
|
organization_id |
The id of the organization |
|
x_pipeline_access_token |
The access token of the pipeline |
ConsumeEventResponse
dataclass
¶
ConsumeEventResponse(content_type: str = dataclasses.field(), status_code: int = dataclasses.field(), raw_response: Response = dataclasses.field(), body: ConsumeEventResponseBody | None = None)
Bases: BaseResponse
Response to consume an event from a pipeline topic
Attributes:
Name | Type | Description |
---|---|---|
content_type |
HTTP response content type for this operation |
|
status_code |
HTTP response status code for this operation |
|
raw_response |
Raw HTTP response; suitable for custom response parsing |
|
body |
ConsumeEventResponseBody | None
|
the response body from the api call |
json ¶
Return the response body as a JSON object. This method is to have compatibility with the requests.Response.json() method
Returns:
Name | Type | Description |
---|---|---|
dict |
dict
|
The transformed event as a JSON object |
Source code in src/glassflow/models/operations/consumeevent.py
ConsumeEventResponseBody
dataclass
¶
ConsumeEventResponseBody(req_id: str = dataclasses.field(), receive_time: str = dataclasses.field(), event: dict)
Event response body after transformation
Attributes:
Name | Type | Description |
---|---|---|
req_id |
str
|
The request id |
receive_time |
str
|
The time when the event was received |
event |
dict
|
The event received |
ConsumeFailedRequest
dataclass
¶
ConsumeFailedRequest(pipeline_id: str, organization_id: Optional[str] = None, x_pipeline_access_token: str = None)
Bases: BasePipelineDataRequest
Request to consume failed events from a pipeline
Attributes:
Name | Type | Description |
---|---|---|
pipeline_id |
The id of the pipeline |
|
organization_id |
The id of the organization |
|
x_pipeline_access_token |
The access token of the pipeline |
ConsumeFailedResponse
dataclass
¶
ConsumeFailedResponse(content_type: str = dataclasses.field(), status_code: int = dataclasses.field(), raw_response: Response = dataclasses.field(), body: ConsumeFailedResponseBody | None = None)
Bases: BaseResponse
Response to consume a failed event from a pipeline
Attributes:
Name | Type | Description |
---|---|---|
content_type |
HTTP response content type for this operation |
|
status_code |
HTTP response status code for this operation |
|
raw_response |
Raw HTTP response; suitable for custom response parsing |
|
body |
ConsumeFailedResponseBody | None
|
the response body from the api call |
json ¶
Return the response body as a JSON object. This method is to have compatibility with the requests.Response.json() method
Returns:
Name | Type | Description |
---|---|---|
dict |
dict
|
The transformed event as a JSON object |
Source code in src/glassflow/models/operations/consumefailed.py
ConsumeFailedResponseBody
dataclass
¶
ConsumeFailedResponseBody(req_id: str = dataclasses.field(), receive_time: str = dataclasses.field(), event: dict)
Event response body after transformation
Attributes:
Name | Type | Description |
---|---|---|
req_id |
str
|
The request id |
receive_time |
str
|
The time when the event was received |
event |
dict
|
The event received |
PublishEventRequest
dataclass
¶
PublishEventRequest(pipeline_id: str, organization_id: Optional[str] = None, x_pipeline_access_token: str = None, request_body: dict = None)
Bases: BasePipelineDataRequest
Request to publish an event to a pipeline topic
Attributes:
Name | Type | Description |
---|---|---|
pipeline_id |
The id of the pipeline |
|
organization_id |
The id of the organization |
|
x_pipeline_access_token |
The access token of the pipeline |
|
request_body |
dict
|
The request body / event that should be published to the pipeline |
PublishEventResponse
dataclass
¶
PublishEventResponse(content_type: str = dataclasses.field(), status_code: int = dataclasses.field(), raw_response: Response = dataclasses.field(), object: PublishEventResponseBody | None = None)
Bases: BaseResponse
Response object for publish event operation
Attributes:
Name | Type | Description |
---|---|---|
content_type |
HTTP response content type for this operation |
|
status_code |
HTTP response status code for this operation |
|
raw_response |
Raw HTTP response; suitable for custom response parsing |
|
object |
PublishEventResponseBody | None
|
Response to the publish operation |