Skip to content

Configuration

Vic Shóstak edited this page Jun 18, 2023 · 14 revisions

In this section, we'll take a closer look at how you can quickly and easily set up a configuration file to start implementing any of your tasks. You can use absolutely any format of configuration file:

  • JSON
  • YAML
  • TOML
  • HCL (Terraform)

The main condition is that your config file must contain the sections necessary for csv2api to work.

A configured config.yml file usually looks like this:

save_filtered_pk_to_csv: true

columns_order:
  - id
  - order_id
  - is_paid

csv_separator: ','

api:

  base_url: my-api-server.com
  base_url_schema: https
  auth_method: Bearer
  token: '{{ CONFIG_API_TOKEN }}'
  request_timeout: 0

  update_endpoint:
    endpoint_name: /api/v1/order/%s
    content_type: application/json
    add_pk_to_endpoint_name: true
    http_method: PATCH
    endpoint_body:
      data:
        id: id
        attributes:
          tags: tags

filter_columns:

  - column_name: order_id
    condition: NEQ
    value: ''

update_fields:

  - field_name: tags
    values:
      - paid
    conditions:
      - column_name: is_paid
        condition: EQ
        value: '1'

Let's look at each section in more detail.

save_filtered_pk_to_csv

This section accepts true or false and allows you to specify whether to save the filtered primary keys (PK) to a CSV file.

This is useful when you need to keep track of which PK (IDs) have been filtered, to control how they change in the database or elsewhere.

Clone this wiki locally