Python SDK Docs
GlassFlow Python Client to interact with GlassFlow API
GlassFlowClient
GlassFlow Client to interact with GlassFlow API and manage pipelines and other resources
Attributes:
Name | Type | Description |
---|---|---|
rclient |
requests.Session object to make HTTP requests to GlassFlow API |
|
glassflow_config |
GlassFlowConfig
|
GlassFlowConfig object to store configuration |
organization_id |
Organization ID of the user. If not provided, the default organization will be used |
Source code in src/glassflow/client.py
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
|
__init__(organization_id=None)
Create a new GlassFlowClient object
Parameters:
Name | Type | Description | Default |
---|---|---|---|
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
24 25 26 27 28 29 30 31 32 |
|
pipeline_client(pipeline_id=None, pipeline_access_token=None, space_id=None)
Create a new PipelineClient object to interact with a specific pipeline
Parameters:
Name | Type | Description | Default |
---|---|---|---|
pipeline_id |
Optional[str]
|
The pipeline id to interact with |
None
|
pipeline_access_token |
Optional[str]
|
The access token to access the pipeline |
None
|
Returns:
Name | Type | Description |
---|---|---|
PipelineClient |
PipelineClient
|
Client object to publish and consume events from the given pipeline. |
Source code in src/glassflow/client.py
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
|
PipelineClient
Client object to publish and consume events from the given pipeline.
Attributes:
Name | Type | Description |
---|---|---|
glassflow_client |
GlassFlowClient object to interact with GlassFlow API |
|
pipeline_id |
The pipeline id to interact with |
|
organization_id |
Organization ID of the user. If not provided, the default organization will be used |
|
pipeline_access_token |
The access token to access the pipeline |
Source code in src/glassflow/pipelines.py
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 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 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 |
|
__init__(glassflow_client, pipeline_id, pipeline_access_token)
Create a new PipelineClient object to interact with a specific pipeline
Parameters:
Name | Type | Description | Default |
---|---|---|---|
glassflow_client |
GlassFlowClient object to interact with GlassFlow API |
required | |
pipeline_id |
str
|
The pipeline id to interact with |
required |
pipeline_access_token |
str
|
The access token to access the pipeline |
required |
Source code in src/glassflow/pipelines.py
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
|
consume()
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/pipelines.py
175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 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 |
|
consume_failed()
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/pipelines.py
259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 |
|
is_access_token_valid()
Check if the pipeline access token is valid
Returns:
Name | Type | Description |
---|---|---|
Boolean |
bool
|
True if the pipeline access token is correct, False otherwise |
Source code in src/glassflow/pipelines.py
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
|
is_valid()
Check if the pipeline exists and credentials are valid
Returns:
Name | Type | Description |
---|---|---|
Boolean |
bool
|
True if the pipeline exists and credentials are valid, False otherwise |
Source code in src/glassflow/pipelines.py
91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
|
publish(request_body)
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/pipelines.py
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 |
|
GlassFlowConfig
dataclass
Configuration object for GlassFlowClient
Attributes:
Name | Type | Description |
---|---|---|
client |
Session
|
requests.Session object to interact with the GlassFlow API |
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 |
Source code in src/glassflow/config.py
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
|
ClientError
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 |
Source code in src/glassflow/models/errors/clienterror.py
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
|
__init__(detail, status_code, body, raw_response)
Create a new ClientError 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
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
|
__str__()
Return a string representation of the error
Returns:
Name | Type | Description |
---|---|---|
str |
The string representation of the error |
Source code in src/glassflow/models/errors/clienterror.py
40 41 42 43 44 45 46 47 48 49 50 51 |
|
Error
dataclass
Bases: Exception
Bad request error response
Attributes:
Name | Type | Description |
---|---|---|
message |
A message describing the error |
Source code in src/glassflow/models/errors/error.py
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
|
ConsumeEventRequest
dataclass
Request to consume an event from a pipeline topic
Attributes:
Name | Type | Description |
---|---|---|
pipeline_id |
str
|
The id of the pipeline |
organization_id |
Optional[str]
|
The id of the organization |
x_pipeline_access_token |
str
|
The access token of the pipeline |
Source code in src/glassflow/models/operations/consumeevent.py
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
|
ConsumeEventResponse
dataclass
Response to consume an event from a pipeline topic
Attributes:
Name | Type | Description |
---|---|---|
content_type |
str
|
HTTP response content type for this operation |
status_code |
int
|
HTTP response status code for this operation |
raw_response |
Response
|
Raw HTTP response; suitable for custom response parsing |
body |
Optional[ConsumeEventResponseBody]
|
the response body from the api call |
Source code in src/glassflow/models/operations/consumeevent.py
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
|
json()
Return the response body as a JSON object. This method is to have cmopatibility with the requests.Response.json() method
Returns:
Name | Type | Description |
---|---|---|
dict |
The transformed event as a JSON object |
Source code in src/glassflow/models/operations/consumeevent.py
88 89 90 91 92 93 94 95 |
|
ConsumeEventResponseBody
dataclass
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 |
Source code in src/glassflow/models/operations/consumeevent.py
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
|
ConsumeFailedRequest
dataclass
Request to consume failed events from a pipeline
Attributes:
Name | Type | Description |
---|---|---|
pipeline_id |
str
|
The id of the pipeline |
organization_id |
Optional[str]
|
The id of the organization |
x_pipeline_access_token |
str
|
The access token of the pipeline |
Source code in src/glassflow/models/operations/consumefailed.py
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
|
ConsumeFailedResponse
dataclass
Response to consume an failed event from a pipeline
Attributes:
Name | Type | Description |
---|---|---|
content_type |
str
|
HTTP response content type for this operation |
status_code |
int
|
HTTP response status code for this operation |
raw_response |
Response
|
Raw HTTP response; suitable for custom response parsing |
body |
Optional[ConsumeFailedResponseBody]
|
the response body from the api call |
Source code in src/glassflow/models/operations/consumefailed.py
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
|
json()
Return the response body as a JSON object. This method is to have cmopatibility with the requests.Response.json() method
Returns:
Name | Type | Description |
---|---|---|
dict |
The transformed event as a JSON object |
Source code in src/glassflow/models/operations/consumefailed.py
88 89 90 91 92 93 94 95 |
|
ConsumeFailedResponseBody
dataclass
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 |
Source code in src/glassflow/models/operations/consumefailed.py
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
|
PublishEventRequest
dataclass
Request to publish an event to a pipeline topic
Attributes:
Name | Type | Description |
---|---|---|
pipeline_id |
str
|
The id of the pipeline |
organization_id |
Optional[str]
|
The id of the organization |
x_pipeline_access_token |
str
|
The access token of the pipeline |
request_body |
dict
|
The request body / event that should be published to the pipeline |
Source code in src/glassflow/models/operations/publishevent.py
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
|
PublishEventResponse
dataclass
Response object for publish event operation
Attributes:
Name | Type | Description |
---|---|---|
content_type |
str
|
HTTP response content type for this operation |
status_code |
int
|
HTTP response status code for this operation |
raw_response |
Response
|
Raw HTTP response; suitable for custom response parsing |
object |
Optional[PublishEventResponseBody]
|
Response to the publish operation |
Source code in src/glassflow/models/operations/publishevent.py
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
|
PublishEventResponseBody
dataclass
Message pushed to the pipeline
Source code in src/glassflow/models/operations/publishevent.py
61 62 63 |
|
StatusAccessTokenRequest
dataclass
Request check the status of an access token
Attributes:
Name | Type | Description |
---|---|---|
pipeline_id |
str
|
The id of the pipeline |
x_pipeline_access_token |
str
|
The access token of the pipeline |
Source code in src/glassflow/models/operations/status_access_token.py
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
|