openapi: 3.0.1
info:
  title: climate rest
  description: QS climate rest service
  contact:
    name: 'QS Qualität und Sicherheit GmbH '
    url: http://www.q-s.de/
    email: info@q-s.de
  version: 1.0.0
tags:
- name: climate
paths:
  /calculate/{id}:
    post:
      summary: calculates the co2 value
      description: calculates the co2 value
      operationId: calculate
      parameters:
      - name: id
        in: path
        description: id
        required: true
        schema:
          type: integer
          format: int32
      responses:
        "200":
          description: ok
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ClimateData'
        "404":
          description: entry not found
        "401":
          description: unauthorized
  /release_data:
    post:
      summary: releases the co2 data for external use
      description: releases the co2 data for external use
      operationId: release data
      requestBody:
        content:
          application/json:
            schema:
              type: array
              items:
                $ref: '#/components/schemas/Publish'
      responses:
        "200":
          description: ok
        "401":
          description: unauthorized
  /climatedata/{id}:
    get:
      summary: get's the climate by id
      description: get's the climate data by id
      operationId: climatedata
      parameters:
      - name: id
        in: path
        description: id
        required: true
        schema:
          type: integer
          format: int32
      responses:
        "200":
          description: climatedata
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ClimateData'
        "404":
          description: not found
        "401":
          description: unauthorized
  /climatedata/{location_id}/{year}/{husbandry_form}:
    get:
      summary: get's the climate data for a selected location and year
      description: get's the climate data for a selected location and year. can be
        used to generate a new dataset with prefilled data.
      operationId: climatedata_1
      parameters:
      - name: location_id
        in: path
        description: location id
        required: true
        schema:
          type: integer
          format: int32
      - name: year
        in: path
        description: year
        required: true
        schema:
          type: integer
          format: int32
      - name: husbandry_form
        in: path
        description: husbandry form
        required: true
        schema:
          type: integer
          format: int32
      responses:
        "200":
          description: climatedata
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ClimateData'
        "404":
          description: location not found
        "401":
          description: unauthorized
  /climatedata:
    get:
      summary: a list of climate data
      description: a list of climate data
      operationId: climatedata_2
      responses:
        "200":
          description: a list of climatedata
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/ClimateData'
        "401":
          description: unauthorized
    post:
      summary: set's the climate data for a selected location and year
      description: set's climate data for a selected location and year
      operationId: climatedata_3
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ClimateData'
      responses:
        "200":
          description: ok
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ClimateData'
        "404":
          description: location not found
        "422":
          description: functional error
        "401":
          description: unauthorized
  /initial_data:
    get:
      summary: get's the initial data for the form
      description: get's the initial data for the form.
      operationId: initial_data
      responses:
        "200":
          description: initialdata
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/InitialData'
        "401":
          description: unauthorized
  /locations:
    get:
      summary: gets the locations
      description: gets the locations
      operationId: locations
      responses:
        "200":
          description: a list of locations
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/Location'
        "401":
          description: unauthorized
  /access:
    get:
      summary: 'is the access allowed for the access token '
      description: 'checks the access token if the app cann access the climate module '
      operationId: access
      responses:
        "200":
          description: allowed
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Access'
        "403":
          description: not allowed
        "401":
          description: unauthorized
  /release_for_input:
    post:
      summary: releases the input of the climate date for externals
      description: releases the input of the climate date for externals
      operationId: release_for_input
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ReleaseForInput'
      responses:
        "200":
          description: ok
        "404":
          description: already released
        "401":
          description: unauthorized
  /withdraw_release_for_input:
    post:
      summary: withdraws the input for externals
      description: withdraws the input for externals
      operationId: withdraw_release_for_input
      responses:
        "200":
          description: ok
        "404":
          description: not released
        "401":
          description: unauthorized
components:
  schemas:
    ClimateData:
      required:
      - id
      - location_id
      - yearKey
      type: object
      properties:
        id:
          type: integer
          format: int32
        location_id:
          type: integer
          format: int32
        location_number:
          type: string
        location_name:
          type: string
        production_type:
          type: integer
          format: int32
        yearKeyValue:
          $ref: '#/components/schemas/KeyValue'
        yearKey:
          type: integer
          format: int32
        husbandry_formKeyValue:
          $ref: '#/components/schemas/KeyValue'
        husbandry_formKey:
          type: integer
          format: int32
        fattening_process:
          type: integer
          description: 1.1 Mastverfahren
          format: int32
        initial_stock:
          type: integer
          description: 1.2 Anfangsbestand Tiere Betrachtungszeitraum
          format: int32
        initial_weight:
          type: number
          description: 1.3 Anfangsgewicht
        stabled_stock:
          type: integer
          description: 1.4 Anzahl der eingestallten Tiere
          format: int32
        stabled_weight:
          type: number
          description: 1.5 Gewicht Anfangsbestand
        sold_stock:
          type: integer
          description: 1.6 verkaufte Tiere im Betrachtungszeitraum
          format: int32
        sold_weight:
          type: number
          description: 1.7 Lebendgewicht der verkauften Tiere
        closing_stock:
          type: integer
          description: 1.8 Endbestand der Tiere Betrachtungszeitraum
          format: int32
        closing_weight:
          type: number
          description: 1.9 Gewicht Endbestand
        fattening_period_piglets:
          type: integer
          description: 1.10 Mastdauer von Anfang bis Ende
          format: int32
        loss_stock:
          type: integer
          description: 1.11 Tierverluste
          format: int32
        weight_loss_stock:
          type: number
          description: 1.12 Gewicht der Tierverluste
        husbandry_system_outdoor_climate_deep_litter_barn_straw_based:
          type: integer
          description: "2.1 Außenklima-Tiefstreustall, strohbasiert"
          format: int32
        husbandry_system_outdoor_climate_deep_litter_barn_straw_based_without_outdoor_climate_barn:
          type: integer
          description: "2.1 Außenklima-Tiefstreustall, strohbasiert ohne Außenklimastall"
          format: int32
        husbandry_system_outdoor_climate_slurry_based:
          type: integer
          description: 2.1 Außenklima güllebasiert
          format: int32
        husbandry_system_flat_outer_surface:
          type: integer
          description: 2.1 planbefestigte Außenfläche
          format: int32
        husbandry_system_flat_running_surfaces_thermally_insulated_with_bedding:
          type: integer
          description: "2.1 planbefestigte Laufflächen, wärmegedämmt mit Einstreu"
          format: int32
        husbandry_system_partially_slatted_floor_slurry_based_and_thermally_insulated:
          type: integer
          description: "2.1 Teilspaltenboden, güllebasiert und wärmegedämmt"
          format: int32
        husbandry_system_deep_litter_barn:
          type: integer
          description: 2.1 Tiefstreustall
          format: int32
        husbandry_system_fully_slatted_floor_manure_based:
          type: integer
          description: 2.1 Vollspaltenboden güllebasiert
          format: int32
        fertilizer_store_slurry_open_tank_without_natural_crust:
          type: integer
          description: 2.2 Gülle - Offener Tank (ohne natürliche Kruste)
          format: int32
        fertilizer_store_slurry_fixed_cover_incl_tent_structures:
          type: integer
          description: 2.2 Gülle - Feste Abdeckung (inkl. Zeltstrukturen)
          format: int32
        fertilizer_store_slurry_natural_crust:
          type: integer
          description: 2.2 Gülle - Natürliche Kruste
          format: int32
        fertilizer_store_slurry_floating_cover_chaff:
          type: integer
          description: 2.2 Gülle - Schwimmende Abdeckung (Spreu)
          format: int32
        fertilizer_store_slurry_floating_cover_plastic_film:
          type: integer
          description: 2.2 Gülle - Schwimmende Abdeckung (Plastikfolie)
          format: int32
        fertilizer_store_liquid_manure_below_a_slatted_floor_more_than_one_month:
          type: integer
          description: 2.2 Gülle - Unterhalb eines Spaltenbodens > 1 Monat
          format: int32
        fertilizer_store_deep_litter_solid_manure:
          type: integer
          description: 2.2 Tiefstreufestmist
          format: int32
        fertilizer_store_other_solid_manure_systems:
          type: integer
          description: 2.2 Andere Festmistsysteme
          format: int32
        fertilizer_biogas_plant:
          type: number
          description: 2.3 davon direkt in die Biogasanlage
        power_consumption:
          type: number
          description: 3.1 Stromverbrauch
        share_renewable_electricity:
          type: number
          description: 3.2 Anteil erneuerbarer Energien
        liquefied_gas_consumption:
          type: number
          description: 3.3 Brennstoffverbrauch für Wärme
        natural_gas_consumption:
          type: number
          description: 3.3 Brennstoffverbrauch für Wärme
        oil_consumption:
          type: number
          description: 3.3 Brennstoffverbrauch für Wärme
        wood_chips:
          type: number
          description: 3.3 Brennstoffverbrauch für Wärme
        renewable_energy_consumption:
          type: number
          description: 3.3 Brennstoffverbrauch für Wärme
        diesel_consumption:
          type: number
          description: 3.5 Dieselverbrauch für Stall und Fütterung
        feeding:
          type: array
          description: 4.0 Fütterung
          items:
            $ref: '#/components/schemas/Feed'
        co2_value:
          type: integer
          format: int32
        read_only:
          type: boolean
        published:
          type: array
          items:
            $ref: '#/components/schemas/Published'
        state:
          type: string
          enum:
          - USER_EDITING
          - READY_FOR_CALC
          - CO2_CALCULATED
          - CLOSED
    Feed:
      required:
      - id
      type: object
      properties:
        id:
          type: integer
          format: int32
        description:
          type: string
        number:
          type: string
        group:
          type: string
        group_number:
          type: string
        type:
          type: string
          enum:
          - FEED_MATERIAL
          - COMPOUND_FEED
        amount:
          type: number
      description: 4.0 Fütterung
    KeyValue:
      type: object
      properties:
        key:
          type: integer
          format: int32
        value:
          type: string
    Published:
      type: object
      properties:
        name:
          type: string
        email:
          type: string
        primary:
          type: boolean
        co2:
          type: boolean
        until:
          type: string
          description: ISO yyyy-MM-dd'T'HH:mm:ss.SSSZ
    Publish:
      type: object
      properties:
        datasetID:
          type: integer
          format: int32
        name:
          type: string
        email:
          type: string
        primary:
          type: boolean
        co2:
          type: boolean
        period:
          type: integer
          description: Zeitspanne 0 = Default (48h)
          format: int32
    Dashboard:
      type: object
      properties:
        locations_count:
          type: integer
          format: int32
        open_positions:
          type: integer
          format: int32
        waiting_positions:
          type: integer
          format: int32
        calculated_positions:
          type: integer
          format: int32
        closed_positions:
          type: integer
          format: int32
        days_fiscal_year:
          type: integer
          format: int32
        fiscal_year:
          type: string
        days_calendar_year:
          type: integer
          format: int32
        calendar_year:
          type: string
    InitialData:
      type: object
      properties:
        husbandry_system_values:
          type: array
          items:
            $ref: '#/components/schemas/KeyValue'
        fattening_process_values:
          type: array
          items:
            $ref: '#/components/schemas/KeyValue'
        fattening_process_default:
          type: integer
          format: int32
        initial_stock_default:
          type: integer
          format: int32
        initial_stock_min:
          type: integer
          format: int32
        initial_stock_max:
          type: integer
          format: int32
        initial_weight_default:
          type: number
        initial_weight_min:
          type: number
        initial_weight_max:
          type: number
        stabled_stock_default:
          type: integer
          format: int32
        stabled_stock_min:
          type: integer
          format: int32
        stabled_stock_max:
          type: integer
          format: int32
        stabled_weight_default:
          type: number
        stabled_weight_min:
          type: number
        stabled_weight_max:
          type: number
        sold_stock_default:
          type: integer
          format: int32
        sold_stock_min:
          type: integer
          format: int32
        sold_stock_max:
          type: integer
          format: int32
        sold_weight_default:
          type: number
        sold_weight_min:
          type: number
        sold_weight_max:
          type: number
        closing_stock_default:
          type: integer
          format: int32
        closing_stock_min:
          type: integer
          format: int32
        closing_stock_max:
          type: integer
          format: int32
        closing_weight_default:
          type: number
        closing_weight_min:
          type: number
        closing_weight_max:
          type: number
        fattening_period_piglets_default:
          type: integer
          format: int32
        fattening_period_piglets_min:
          type: integer
          format: int32
        fattening_period_piglets_max:
          type: integer
          format: int32
        weight_loss_stock_default:
          type: number
        weight_loss_stock_min:
          type: number
        weight_loss_stock_max:
          type: number
        litter_consumption_default:
          type: number
        litter_consumption_min:
          type: number
        litter_consumption_max:
          type: number
        grazing_period_default:
          type: integer
          format: int32
        grazing_period_min:
          type: integer
          format: int32
        grazing_period_max:
          type: integer
          format: int32
        fertilizer_biogas_plant_default:
          type: number
        fertilizer_biogas_plant_min:
          type: number
        fertilizer_biogas_plant_max:
          type: number
        power_consumption_default:
          type: number
        power_consumption_min:
          type: number
        power_consumption_max:
          type: number
        share_renewable_electricity_default:
          type: number
        share_renewable_electricity_min:
          type: number
        share_renewable_electricity_max:
          type: number
        fuel_consumption_default:
          type: number
        fuel_consumption_min:
          type: number
        fuel_consumption_max:
          type: number
        diesel_consumption_default:
          type: number
        diesel_consumption_min:
          type: number
        diesel_consumption_max:
          type: number
        husbandry_system_outdoor_climate_deep_litter_barn_straw_based_default:
          type: integer
          format: int32
        husbandry_system_outdoor_climate_deep_litter_barn_straw_based_min:
          type: integer
          format: int32
        husbandry_system_outdoor_climate_deep_litter_barn_straw_based_max:
          type: integer
          format: int32
        husbandry_system_outdoor_climate_deep_litter_barn_straw_based_without_outdoor_climate_barn_default:
          type: integer
          format: int32
        husbandry_system_outdoor_climate_deep_litter_barn_straw_based_without_outdoor_climate_barn_min:
          type: integer
          format: int32
        husbandry_system_outdoor_climate_deep_litter_barn_straw_based_without_outdoor_climate_barn_max:
          type: integer
          format: int32
        husbandry_system_outdoor_climate_slurry_based_default:
          type: integer
          format: int32
        husbandry_system_outdoor_climate_slurry_based_min:
          type: integer
          format: int32
        husbandry_system_outdoor_climate_slurry_based_max:
          type: integer
          format: int32
        husbandry_system_flat_outer_surface_default:
          type: integer
          format: int32
        husbandry_system_flat_outer_surface_min:
          type: integer
          format: int32
        husbandry_system_flat_outer_surface_max:
          type: integer
          format: int32
        husbandry_system_flat_running_surfaces_thermally_insulated_with_bedding_default:
          type: integer
          format: int32
        husbandry_system_flat_running_surfaces_thermally_insulated_with_bedding_min:
          type: integer
          format: int32
        husbandry_system_flat_running_surfaces_thermally_insulated_with_bedding_max:
          type: integer
          format: int32
        husbandry_system_partially_slatted_floor_slurry_based_and_thermally_insulated_default:
          type: integer
          format: int32
        husbandry_system_partially_slatted_floor_slurry_based_and_thermally_insulated_min:
          type: integer
          format: int32
        husbandry_system_partially_slatted_floor_slurry_based_and_thermally_insulated_max:
          type: integer
          format: int32
        husbandry_system_deep_litter_barn_default:
          type: integer
          format: int32
        husbandry_system_deep_litter_barn_min:
          type: integer
          format: int32
        husbandry_system_deep_litter_barn_max:
          type: integer
          format: int32
        husbandry_system_fully_slatted_floor_manure_based_default:
          type: integer
          format: int32
        husbandry_system_fully_slatted_floor_manure_based_min:
          type: integer
          format: int32
        husbandry_system_fully_slatted_floor_manure_based_max:
          type: integer
          format: int32
        fertilizer_store_slurry_open_tank_without_natural_crust_default:
          type: integer
          format: int32
        fertilizer_store_slurry_open_tank_without_natural_crust_min:
          type: integer
          format: int32
        fertilizer_store_slurry_open_tank_without_natural_crust_max:
          type: integer
          format: int32
        fertilizer_store_slurry_fixed_cover_incl_tent_structures_default:
          type: integer
          format: int32
        fertilizer_store_slurry_fixed_cover_incl_tent_structures_min:
          type: integer
          format: int32
        fertilizer_store_slurry_fixed_cover_incl_tent_structures_max:
          type: integer
          format: int32
        fertilizer_store_slurry_natural_crust_default:
          type: integer
          format: int32
        fertilizer_store_slurry_natural_crust_min:
          type: integer
          format: int32
        fertilizer_store_slurry_natural_crust_max:
          type: integer
          format: int32
        fertilizer_store_slurry_floating_cover_chaff_default:
          type: integer
          format: int32
        fertilizer_store_slurry_floating_cover_chaff_min:
          type: integer
          format: int32
        fertilizer_store_slurry_floating_cover_chaff_max:
          type: integer
          format: int32
        fertilizer_store_slurry_floating_cover_plastic_film_default:
          type: integer
          format: int32
        fertilizer_store_slurry_floating_cover_plastic_film_min:
          type: integer
          format: int32
        fertilizer_store_slurry_floating_cover_plastic_film_max:
          type: integer
          format: int32
        fertilizer_store_liquid_manure_below_a_slatted_floor_more_than_one_month_default:
          type: integer
          format: int32
        fertilizer_store_liquid_manure_below_a_slatted_floor_more_than_one_month_min:
          type: integer
          format: int32
        fertilizer_store_liquid_manure_below_a_slatted_floor_more_than_one_month_max:
          type: integer
          format: int32
        fertilizer_store_deep_litter_solid_manure_default:
          type: integer
          format: int32
        fertilizer_store_deep_litter_solid_manure_min:
          type: integer
          format: int32
        fertilizer_store_deep_litter_solid_manure_max:
          type: integer
          format: int32
        fertilizer_store_other_solid_manure_systems_default:
          type: integer
          format: int32
        fertilizer_store_other_solid_manure_systems_min:
          type: integer
          format: int32
        fertilizer_store_other_solid_manure_systems_max:
          type: integer
          format: int32
        dashboard:
          $ref: '#/components/schemas/Dashboard'
    Location:
      type: object
      properties:
        id:
          type: integer
          format: int32
        name:
          type: string
        number:
          type: string
        qsID:
          type: string
        productionType:
          type: integer
          format: int32
        years:
          type: array
          items:
            $ref: '#/components/schemas/Year'
    Year:
      type: object
      properties:
        key:
          type: integer
          format: int32
        value:
          type: string
        husbandry_form:
          type: array
          items:
            $ref: '#/components/schemas/KeyValue'
    Access:
      type: object
      properties:
        canEdit:
          type: boolean
        consultant:
          $ref: '#/components/schemas/Consultant'
        consultantAssignmentPossible:
          type: boolean
    Consultant:
      required:
      - type
      type: object
      properties:
        type:
          type: string
          enum:
          - BUNDLER
          - CONSULTANT
        name:
          type: string
        email:
          type: string
        description:
          type: string
    ReleaseForInput:
      type: object
      properties:
        type:
          type: string
          enum:
          - BUNDLER
          - CONSULTANT
        mail:
          type: string
        name:
          type: string
        description:
          type: string
