Class: Schematic::Dataexports::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/schematic/dataexports/client.rb

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ void



9
10
11
# File 'lib/schematic/dataexports/client.rb', line 9

def initialize(client:)
  @client = client
end

Instance Method Details

#create_data_export(request_options: {}, **params) ⇒ Schematic::Dataexports::Types::CreateDataExportResponse

Examples:

client.dataexports.create_data_export(
  export_type: "audit-log",
  output_file_type: "csv"
)

Parameters:

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Returns:



78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# File 'lib/schematic/dataexports/client.rb', line 78

def create_data_export(request_options: {}, **params)
  params = Schematic::Internal::Types::Utils.normalize_keys(params)
  request = Schematic::Internal::JSON::Request.new(
    base_url: request_options[:base_url],
    method: "POST",
    path: "data-exports",
    body: Schematic::Dataexports::Types::CreateDataExportRequestBody.new(params).to_h,
    request_options: request_options
  )
  begin
    response = @client.send(request)
  rescue Net::HTTPRequestTimeout
    raise Schematic::Errors::TimeoutError
  end
  code = response.code.to_i
  if code.between?(200, 299)
    Schematic::Dataexports::Types::CreateDataExportResponse.load(response.body)
  else
    error_class = Schematic::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end

#get_data_export(request_options: {}, **params) ⇒ Schematic::Dataexports::Types::GetDataExportResponse

Examples:

client.dataexports.get_data_export(data_export_id: "data_export_id")

Parameters:

  • request_options (Hash) (defaults to: {})
  • params (Hash)

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Options Hash (**params):

  • :data_export_id (String)

Returns:



114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
# File 'lib/schematic/dataexports/client.rb', line 114

def get_data_export(request_options: {}, **params)
  params = Schematic::Internal::Types::Utils.normalize_keys(params)
  request = Schematic::Internal::JSON::Request.new(
    base_url: request_options[:base_url],
    method: "GET",
    path: "data-exports/#{URI.encode_uri_component(params[:data_export_id].to_s)}",
    request_options: request_options
  )
  begin
    response = @client.send(request)
  rescue Net::HTTPRequestTimeout
    raise Schematic::Errors::TimeoutError
  end
  code = response.code.to_i
  if code.between?(200, 299)
    Schematic::Dataexports::Types::GetDataExportResponse.load(response.body)
  else
    error_class = Schematic::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end

#get_data_export_artifact(request_options: {}, **params) ⇒ untyped

Examples:

client.dataexports.get_data_export_artifact(data_export_id: "data_export_id")

Parameters:

  • request_options (Hash) (defaults to: {})
  • params (Hash)

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Options Hash (**params):

  • :data_export_id (String)

Returns:

  • (untyped)

Raises:

  • (error_class)


149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
# File 'lib/schematic/dataexports/client.rb', line 149

def get_data_export_artifact(request_options: {}, **params)
  params = Schematic::Internal::Types::Utils.normalize_keys(params)
  request = Schematic::Internal::JSON::Request.new(
    base_url: request_options[:base_url],
    method: "GET",
    path: "data-exports/#{URI.encode_uri_component(params[:data_export_id].to_s)}/artifact",
    request_options: request_options
  )
  begin
    response = @client.send(request)
  rescue Net::HTTPRequestTimeout
    raise Schematic::Errors::TimeoutError
  end
  code = response.code.to_i
  return if code.between?(200, 299)

  error_class = Schematic::Errors::ResponseError.subclass_for_code(code)
  raise error_class.new(response.body, code: code)
end

#list_data_exports(request_options: {}, **params) ⇒ Schematic::Dataexports::Types::ListDataExportsResponse

Examples:

client.dataexports.list_data_exports(
  export_type: "audit-log",
  status: "failure",
  limit: 1000000,
  offset: 1000000
)

Parameters:

  • request_options (Hash) (defaults to: {})
  • params (Hash)

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Options Hash (**params):

Returns:



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
# File 'lib/schematic/dataexports/client.rb', line 34

def list_data_exports(request_options: {}, **params)
  params = Schematic::Internal::Types::Utils.normalize_keys(params)
  query_params = {}
  query_params["export_type"] = params[:export_type] if params.key?(:export_type)
  query_params["status"] = params[:status] if params.key?(:status)
  query_params["limit"] = params[:limit] if params.key?(:limit)
  query_params["offset"] = params[:offset] if params.key?(:offset)

  request = Schematic::Internal::JSON::Request.new(
    base_url: request_options[:base_url],
    method: "GET",
    path: "data-exports",
    query: query_params,
    request_options: request_options
  )
  begin
    response = @client.send(request)
  rescue Net::HTTPRequestTimeout
    raise Schematic::Errors::TimeoutError
  end
  code = response.code.to_i
  if code.between?(200, 299)
    Schematic::Dataexports::Types::ListDataExportsResponse.load(response.body)
  else
    error_class = Schematic::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end