prefect_census.client
Module containing client for interacting with the Census API
Classes
CensusClient
Client for interacting with the Census API.
Attributes:
Name | Type | Description |
---|---|---|
api_key |
str
|
API key to authenticate with the Census API. |
Source code in prefect_census/client.py
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 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 |
|
Functions
__aenter__
async
Async context manager entry method.
Source code in prefect_census/client.py
116 117 118 119 120 121 122 123 124 125 126 |
|
__aexit__
async
Async context manager exit method.
Source code in prefect_census/client.py
128 129 130 131 |
|
call_endpoint
async
Call an endpoint in the Census API.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
http_method |
str
|
HTTP method to call on the endpoint. |
required |
path |
str
|
The partial path for request (e.g. /syncs/42). Will be appended onto the base URL as determined by the client configuration. |
required |
params |
Optional[Dict[str, Any]]
|
Query parameters to include in the request. |
None
|
json |
Optional[Dict[str, Any]]
|
JSON serializable body to send in the request. |
None
|
Returns:
Type | Description |
---|---|
Response
|
The response from the Census API. |
Example
from prefect import flow
from prefect_census import CensusCredentials
from prefect_census.client import CensusClient
@flow
def my_flow(sync_id):
creds_block = CensusCredentials(api_key="my_api_key")
client = CensusClient(
api_key=creds_block.api_key.get_secret_value()
)
response = client.call_endpoint(
http_method="GET",
path=f"/syncs/{sync_id}"
)
return response
my_flow(42)
Source code in prefect_census/client.py
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 |
|
get_run_info
async
Sends a request to the get sync id info endpoint
Parameters:
Name | Type | Description | Default |
---|---|---|---|
run_id |
int
|
The ID of the sync run to get details for. |
required |
Returns:
Type | Description |
---|---|
Response
|
The response from the Census API. |
Source code in prefect_census/client.py
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
|
trigger_sync_run
async
Sends a request to the trigger sync run endpoint to initiate a sync run.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
sync_id |
int
|
The ID of the sync to trigger. |
required |
force_full_sync |
bool
|
If the sync should perform a full sync. |
False
|
Returns:
Type | Description |
---|---|
Response
|
The response from the Census API. |
Source code in prefect_census/client.py
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 |
|