Class: SafetyKit::Resources::Data

Inherits:
Object
  • Object
show all
Defined in:
lib/safety_kit/resources/data.rb

Overview

Ingest data for fraud detection and risk analysis.

Instance Method Summary collapse

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.

Parameters:



154
155
156
# File 'lib/safety_kit/resources/data.rb', line 154

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.

Parameters:

Returns:

See Also:



24
25
26
27
28
29
30
31
32
33
# File 'lib/safety_kit/resources/data.rb', line 24

def add(namespace, params)
  parsed, options = SafetyKit::DataAddParams.dump_request(params)
  @client.request(
    method: :post,
    path: ["v1/data/%1$s", namespace],
    body: parsed,
    model: SafetyKit::Models::DataAddResponse,
    options: options
  )
end

#create_upload_url(namespace, schema: nil, request_options: {}) ⇒ SafetyKit::Models::DataCreateUploadURLResponse

Some parameter documentations has been truncated, see Models::DataCreateUploadURLParams for more details.

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.

Parameters:

Returns:

See Also:



53
54
55
56
57
58
59
60
61
62
# File 'lib/safety_kit/resources/data.rb', line 53

def create_upload_url(namespace, params = {})
  parsed, options = SafetyKit::DataCreateUploadURLParams.dump_request(params)
  @client.request(
    method: :post,
    path: ["v1/data/%1$s/requests/upload-url", namespace],
    body: parsed,
    model: SafetyKit::Models::DataCreateUploadURLResponse,
    options: 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.

Parameters:

  • request_id (String)

    The request ID returned when the ingest request was created

  • namespace (String)

    The namespace the data was ingested into

  • request_options (SafetyKit::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



79
80
81
82
83
84
85
86
87
88
89
90
91
# File 'lib/safety_kit/resources/data.rb', line 79

def get_download_url(request_id, params)
  parsed, options = 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: 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.

Parameters:

  • request_id (String)

    The request ID returned when the ingest request was created

  • namespace (String)

    The namespace the data was ingested into

  • request_options (SafetyKit::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



109
110
111
112
113
114
115
116
117
118
119
120
121
# File 'lib/safety_kit/resources/data.rb', line 109

def get_status(request_id, params)
  parsed, options = 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: options
  )
end

#update_settings(namespace, schema:, request_options: {}) ⇒ SafetyKit::Models::DataUpdateSettingsResponse

Some parameter documentations has been truncated, see Models::DataUpdateSettingsParams for more details.

Create or replace settings for a namespace, primarily used to change the schema associated with the namespace.

Parameters:

Returns:

See Also:



140
141
142
143
144
145
146
147
148
149
# File 'lib/safety_kit/resources/data.rb', line 140

def update_settings(namespace, params)
  parsed, options = SafetyKit::DataUpdateSettingsParams.dump_request(params)
  @client.request(
    method: :put,
    path: ["v1/data/%1$s/settings", namespace],
    body: parsed,
    model: SafetyKit::Models::DataUpdateSettingsResponse,
    options: options
  )
end