Class: SafetyKit::Resources::Data
- Inherits:
-
Object
- Object
- SafetyKit::Resources::Data
- Defined in:
- lib/safety_kit/resources/data.rb,
sig/safety_kit/resources/data.rbs
Overview
Ingest data for fraud detection and risk analysis.
Instance Method Summary collapse
-
#add(namespace, data:, request_options: {}) ⇒ SafetyKit::Models::DataAddResponse
Some parameter documentations has been truncated, see Models::DataAddParams for more details.
-
#create_upload_url(namespace, request_options: {}) ⇒ SafetyKit::Models::DataCreateUploadURLResponse
Request a pre-signed upload URL for large JSONL batches into a namespace.
-
#get_download_url(request_id, namespace:, request_options: {}) ⇒ SafetyKit::Models::DataGetDownloadURLResponse
Retrieve the status of a data ingestion request and, once complete, a temporary S3 URL for the full result file.
-
#get_settings(namespace, request_options: {}) ⇒ SafetyKit::Models::DataGetSettingsResponse
Fetch the stored schema, settings, and configuration version for a namespace.
-
#get_status(request_id, namespace:, request_options: {}) ⇒ SafetyKit::Models::DataGetStatusResponse
Retrieve the status of a data ingestion request and, once complete, return processed objects inline.
-
#initialize(client:) ⇒ Data
constructor
private
A new instance of Data.
-
#update_settings(namespace, previous_version: nil, schema: nil, settings: nil, request_options: {}) ⇒ SafetyKit::Models::DataUpdateSettingsResponse
Some parameter documentations has been truncated, see Models::DataUpdateSettingsParams for more details.
Constructor Details
#initialize(client:) ⇒ Data
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Data.
174 175 176 |
# File 'lib/safety_kit/resources/data.rb', line 174 def initialize(client:) @client = client end |
Instance Method Details
#add(namespace, data:, request_options: {}) ⇒ SafetyKit::Models::DataAddResponse
Some parameter documentations has been truncated, see Models::DataAddParams for more details.
Add data to a namespace, returning immediately. Processing happens asynchronously in the background.
24 25 26 27 28 29 30 31 32 33 |
# File 'lib/safety_kit/resources/data.rb', line 24 def add(namespace, params) parsed, = SafetyKit::DataAddParams.dump_request(params) @client.request( method: :post, path: ["v1/data/%1$s", namespace], body: parsed, model: SafetyKit::Models::DataAddResponse, options: ) end |
#create_upload_url(namespace, request_options: {}) ⇒ SafetyKit::Models::DataCreateUploadURLResponse
Request a pre-signed upload URL for large JSONL batches into a namespace. After
receiving upload_url, upload your JSONL file using PUT {upload_url} with
header Content-Type: application/json; put each JSON object on a new line.
48 49 50 51 52 53 54 55 |
# File 'lib/safety_kit/resources/data.rb', line 48 def create_upload_url(namespace, params = {}) @client.request( method: :post, path: ["v1/data/%1$s/requests/upload-url", namespace], model: SafetyKit::Models::DataCreateUploadURLResponse, options: params[:request_options] ) end |
#get_download_url(request_id, namespace:, request_options: {}) ⇒ SafetyKit::Models::DataGetDownloadURLResponse
Retrieve the status of a data ingestion request and, once complete, a temporary S3 URL for the full result file. This endpoint always uses the URL-based response shape regardless of request size.
72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/safety_kit/resources/data.rb', line 72 def get_download_url(request_id, params) parsed, = SafetyKit::DataGetDownloadURLParams.dump_request(params) namespace = parsed.delete(:namespace) do raise ArgumentError.new("missing required path argument #{_1}") end @client.request( method: :get, path: ["v1/data/%1$s/requests/%2$s/results/download-url", namespace, request_id], model: SafetyKit::Models::DataGetDownloadURLResponse, options: ) end |
#get_settings(namespace, request_options: {}) ⇒ SafetyKit::Models::DataGetSettingsResponse
Fetch the stored schema, settings, and configuration version for a namespace. Use the returned version as previous_version when updating so a stale update is rejected instead of overwriting a newer one.
99 100 101 102 103 104 105 106 |
# File 'lib/safety_kit/resources/data.rb', line 99 def get_settings(namespace, params = {}) @client.request( method: :get, path: ["v1/data/%1$s/settings", namespace], model: SafetyKit::Models::DataGetSettingsResponse, options: params[:request_options] ) end |
#get_status(request_id, namespace:, request_options: {}) ⇒ SafetyKit::Models::DataGetStatusResponse
Retrieve the status of a data ingestion request and, once complete, return processed objects inline. If the processed output exceeds the 5 MiB inline response limit, this endpoint returns an error instructing you to use the download endpoint instead.
124 125 126 127 128 129 130 131 132 133 134 135 136 |
# File 'lib/safety_kit/resources/data.rb', line 124 def get_status(request_id, params) parsed, = SafetyKit::DataGetStatusParams.dump_request(params) namespace = parsed.delete(:namespace) do raise ArgumentError.new("missing required path argument #{_1}") end @client.request( method: :get, path: ["v1/data/%1$s/requests/%2$s", namespace, request_id], model: SafetyKit::Models::DataGetStatusResponse, options: ) end |
#update_settings(namespace, previous_version: nil, schema: nil, settings: nil, request_options: {}) ⇒ SafetyKit::Models::DataUpdateSettingsResponse
Some parameter documentations has been truncated, see Models::DataUpdateSettingsParams for more details.
Update the schema and/or settings for a namespace. Each is replaced in full when provided and left unchanged when omitted. Namespaces whose configuration is managed by SafetyKit cannot be updated through this endpoint.
160 161 162 163 164 165 166 167 168 169 |
# File 'lib/safety_kit/resources/data.rb', line 160 def update_settings(namespace, params = {}) parsed, = SafetyKit::DataUpdateSettingsParams.dump_request(params) @client.request( method: :put, path: ["v1/data/%1$s/settings", namespace], body: parsed, model: SafetyKit::Models::DataUpdateSettingsResponse, options: ) end |