swagger: "2.0"
schemes:
  - https
host: ioe2api.ijenko.net
info:
  contact:
    email: contact@ijenko.com
    name: IJENKO
    url: http://developers.ijenko.com/
  title: IoE² IoT API - to create end-user applications
  version: 3.0.0
  x-apisguru-categories:
    - iot
  x-logo:
    backgroundColor: "#383D41"
    url: https://pbs.twimg.com/profile_images/1706275304/_0_logo_carr__fd_gris_400x400.png
  x-origin:
    - format: swagger
      url: http://developers.ijenko.com/swagger.json
      version: "2.0"
  x-providerName: ijenko.net
consumes:
  - application/json
produces:
  - application/json
securityDefinitions:
  Token in Access-Token header:
    description: Token in Access-Token header
    in: header
    name: Access-Token
    type: apiKey
  Token in query:
    description: Token in query
    in: query
    name: token
    type: apiKey
security:
  - Token in query: []
  - Token in Access-Token header: []
parameters:
  accountId:
    description: Unique identifier of an *Account*.
    in: path
    name: accountId
    required: true
    type: string
  action:
    description: Identifier of an *Action* inside a *Functionality*.
    in: path
    name: action
    required: true
    type: string
  attributeName:
    description: Identifier of an *Attribute* inside a *Functionality*.
    in: path
    name: attributeName
    required: true
    type: string
  attributesNames:
    collectionFormat: csv
    description: One or multiple *Attribute* names separated by commas
    in: query
    items:
      type: string
    name: names
    required: false
    type: array
  busId:
    description: Unique identifier of a *Bus*.
    in: path
    name: busId
    required: true
    type: string
  deviceId:
    description: Unique identifier of a *Device*.
    in: path
    name: deviceId
    required: true
    type: string
  devicesSelector.Opt:
    description: Devices selector. Device tags or device classes or device ids or '*' for any. Multiple values are separated by '|' and interpreted as « OR ».
    in: query
    name: devices
    pattern: ^(?:\\*|(?:[A-Z][A-Z0-9]{3}|[a-z][a-z0-9_:]{0,20}|[A-Za-z0-9-_]{22})(?:\\|(?:[A-Z][A-Z0-9]{3}|[a-z][a-z0-9_:]{0,20}|[A-Za-z0-9-_]{22}))*)$
    required: false
    type: string
  devicesSelector.Req:
    description: Devices selector. Device tags or device classes or device ids or '*' for any. Multiple values are separated by '|' and interpreted as « OR ».
    in: query
    name: devices
    pattern: ^(?:\\*|(?:[A-Z][A-Z0-9]{3}|[a-z][a-z0-9_:]{0,20}|[A-Za-z0-9-_]{22})(?:\\|(?:[A-Z][A-Z0-9]{3}|[a-z][a-z0-9_:]{0,20}|[A-Za-z0-9-_]{22}))*)$
    required: true
    type: string
  embedMetadata:
    collectionFormat: csv
    description: |
      Request to include the given keys of metadata in the response. If a key doesn't exist on the resource it is ignored.
      **Note:** This only applies to the top level resources.
    in: query
    items:
      type: string
    name: embed-metadata
    required: false
    type: array
  from.Opt:
    description: Beginning of the time interval.
    format: date-time
    in: query
    name: from
    required: false
    type: string
  from.Req:
    description: Beginning of the time interval.
    format: date-time
    in: query
    name: from
    required: true
    type: string
  functionalitiesSelector.Opt:
    description: |
      Functionality selector: Functionality tags or functionality class (optionally, '@' followed by a endpoint in decimal) or '*' for all. Multiple values are separated by '|' and are interpreted as « OR ».
    in: query
    name: functionalities
    pattern: ^(?:\\*|(?:[A-Z][A-Za-z0-9]+(?:@(?:0|1[0-9]{,2}|[3-9][0-9]?|2(?:[0-4][0-9]?|5[0-5]?|[6-9])?))?|[a-z][a-z0-9_:]{0,20}|[A-Za-z0-9-_]{22})(?:\\|(?:[A-Z][A-Za-z0-9]+(?:@(?:0|1[0-9]{,2}|[3-9][0-9]?|2(?:[0-4][0-9]?|5[0-5]?|[6-9])?))?|[a-z][a-z0-9_:]{0,20}|[A-Za-z0-9-_]{22}))*)$
    required: false
    type: string
  functionalitiesSelector.Req:
    description: |
      Functionality selector: Functionality tags or functionality class (optionally, '@' followed by a endpoint in decimal) or '*' for all. Multiple values are separated by '|' and are interpreted as « OR ».
    in: query
    name: functionalities
    pattern: ^(?:\\*|(?:[A-Z][A-Za-z0-9]+(?:@(?:0|1[0-9]{,2}|[3-9][0-9]?|2(?:[0-4][0-9]?|5[0-5]?|[6-9])?))?|[a-z][a-z0-9_:]{0,20}|[A-Za-z0-9-_]{22})(?:\\|(?:[A-Z][A-Za-z0-9]+(?:@(?:0|1[0-9]{,2}|[3-9][0-9]?|2(?:[0-4][0-9]?|5[0-5]?|[6-9])?))?|[a-z][a-z0-9_:]{0,20}|[A-Za-z0-9-_]{22}))*)$
    required: true
    type: string
  functionalityId:
    description: Unique identifier of a *Functionality*.
    in: path
    name: functionalityId
    required: true
    type: string
  metadataPatch:
    description: |
      Modifications to apply to the metadata of the resource.
    in: body
    name: metadataPatch
    required: true
    schema:
      $ref: "#/definitions/MetadataPatch"
  notificationId:
    description: Unique identifier of a *Notification*.
    in: path
    name: notificationId
    required: true
    type: string
  placeId:
    description: Unique identifier of a *Place*.
    in: path
    name: placeId
    required: true
    type: string
  programId:
    description: Unique identifier of a *Program*.
    in: path
    name: programId
    required: true
    type: string
  span.Req:
    description: "Timespan: H (hour), D (day), Wmo (week starting on Monday), Wsu (week starting on Sunday), M (month), Y (year)"
    enum:
      - H
      - D
      - Wmo
      - Wsu
      - M
      - Y
    in: query
    name: span
    required: true
    type: string
  tagsPatch:
    description: |
      Modifications to apply to the tags list of the resource.
    in: body
    name: tagsPatch
    required: true
    schema:
      $ref: "#/definitions/TagsPatch"
  to:
    description: |
      End of the interval. Default: now.
    format: date-time
    in: query
    name: to
    required: false
    type: string
  tokenId:
    description: Identifier of the token
    in: path
    name: tokenId
    required: true
    type: string
  userId:
    description: Unique identifier of a *User*.
    in: path
    name: userId
    required: true
    type: string
  when.Req:
    description: A time part of the time span.
    format: date-time
    in: query
    name: when
    required: true
    type: string
responses:
  ActionMultiResultOK:
    description: Successful.
    schema:
      $ref: "#/definitions/ActionMultiResult"
  DefaultError:
    description: Other error.
    schema:
      $ref: "#/definitions/DefaultError"
  DeleteOK:
    description: Resource successfully deleted.
  ErrorAccessAccount:
    description: |
      The authentication token doesn't allow to modify the *Account*.
    schema:
      $ref: "#/definitions/ErrorEntity"
  ErrorAccessBus:
    description: |
      *Bus* doesn't exist or the requester doesn't have appropriate access to the *Place*.
    schema:
      $ref: "#/definitions/ErrorSubEntity"
  ErrorAccessDevice:
    description: |
      *Device* doesn't exist or the requester doesn't have appropriate access to the *Place*.
    schema:
      $ref: "#/definitions/ErrorEntity"
  ErrorAccessFunctionality:
    description: |
      *Functionality* doesn't exist or the requester doesn't have appropriate access to the *Place*.
    schema:
      $ref: "#/definitions/ErrorEntity"
  ErrorAccessNotification:
    description: |
      *Notification* doesn't exist or the requester doesn't have appropriate access to the *Place*.
    schema:
      $ref: "#/definitions/ErrorEntity"
  ErrorAccessPlace:
    description: |
      *Place* doesn't exist or the requester doesn't have access.
    schema:
      $ref: "#/definitions/ErrorEntity"
  ErrorAccessProgram:
    description: |
      *Program* doesn't exist or the requester doesn't have appropriate access to the *Place*.
    schema:
      $ref: "#/definitions/ErrorEntity"
  ErrorAccessUser:
    description: |
      *User* doesn't exist in this *Account* or the requester doesn't have access to a *Place* on which this *User* has access.
    schema:
      $ref: "#/definitions/ErrorEntity"
  ErrorGatewayUnreachable:
    description: The gateway of the Place is not reachable.
    schema:
      $ref: "#/definitions/ErrorGatewayUnreachable"
  ErrorWriteAttribute:
    description: |
      *Attribute* is not writable.
    schema:
      $ref: "#/definitions/ErrorSubEntity"
  PatchNotModified:
    description: Successful, but nothing changed.
  PatchOK:
    description: Modification successful.
tags:
  - name: Entry points
  - name: Authentication
  - name: Account
  - name: User
  - name: Place
  - name: Device
  - name: Functionality
  - name: Action
  - name: Program
  - name: Notification
  - name: Electricity
paths:
  /account/change-password:
    post:
      description: |
        Set a new password for the account.

        **Note**: requires full access to the *Account*.
      operationId: Account.changePassword
      parameters:
        - description: Old and new password
          in: body
          name: changePasswordInfo
          required: true
          schema:
            $ref: "#/definitions/AuthChangePassword"
      responses:
        "204":
          description: Change successful.
        "403":
          $ref: "#/responses/ErrorAccessAccount"
        default:
          $ref: "#/responses/DefaultError"
      summary: Change the password
      tags:
        - Account
  /account/places:
    get:
      description: |
        List the *Places* of the account.

        **Note:** requires full access to the *Account*.
      operationId: Account.places
      responses:
        "200":
          description: Successful response
          schema:
            items:
              $ref: "#/definitions/PlaceItem"
            type: array
            uniqueItems: true
        "403":
          $ref: "#/responses/ErrorAccessAccount"
      summary: List Places of the Account
      tags:
        - Account
    parameters: []
    post:
      description: |
        Create a new *Place*.

        A *Device* (`class`: `MINT`, `address`: `0`) is automatically created and attached to the new *Place*.

        **Note:** requires full access to the *Account*.
      operationId: Account.newPlace
      parameters:
        - in: body
          name: place
          schema:
            $ref: "#/definitions/PlaceNew"
      responses:
        "201":
          description: "*Place* successfully created."
          headers:
            Location:
              description: Path of the Place created (`/places/{id}`)
              type: string
          schema:
            $ref: "#/definitions/PlaceCreated"
        "403":
          $ref: "#/responses/ErrorAccessAccount"
        default:
          $ref: "#/responses/DefaultError"
      summary: Create a Place
      tags:
        - Account
  /account/tokens:
    get:
      description: |
        List the active *Tokens* on the account.

        **Note:** requires full access to the *Account*.
      operationId: Account.tokens
      responses:
        "200":
          description: Successful.
          schema:
            items:
              $ref: "#/definitions/UserTokenItem"
            type: array
            uniqueItems: true
        "403":
          $ref: "#/responses/ErrorAccessAccount"
        default:
          $ref: "#/responses/DefaultError"
      summary: List active Tokens of the Account
      tags:
        - Account
    parameters: []
  "/account/tokens/{tokenId}":
    delete:
      description: |
        Revoke the given *Token*.

        **Note:** requires full access to the *Account*.
      operationId: Account.revokeToken
      responses:
        "204":
          $ref: "#/responses/DeleteOK"
        "403":
          $ref: "#/responses/ErrorAccessAccount"
        default:
          $ref: "#/responses/DefaultError"
      summary: Revoke a Token
      tags:
        - Account
    parameters:
      - $ref: "#/parameters/tokenId"
  /account/users:
    get:
      description: Get the list of *Users* of this *Account*.
      operationId: Account.users
      parameters:
        - $ref: "#/parameters/embedMetadata"
      responses:
        "200":
          description: Successful.
          schema:
            items:
              $ref: "#/definitions/UserItem"
            type: array
            uniqueItems: true
      summary: List Users of the Account
      tags:
        - Account
    parameters: []
    post:
      description: |
        Add a *User*.

        **Note**: requires full access to the *Account*.
      operationId: Account.newUser
      parameters:
        - in: body
          name: userInfo
          required: true
          schema:
            $ref: "#/definitions/UserNew"
      responses:
        "201":
          description: "*User* successfully created."
          headers:
            Location:
              description: Path of the User created
              type: string
          schema:
            $ref: "#/definitions/UserCreated"
        "403":
          $ref: "#/responses/ErrorAccessAccount"
        default:
          $ref: "#/responses/DefaultError"
      summary: New User
      tags:
        - Account
  "/account/users/{userId}":
    delete:
      description: |
        Delete a *User* from this *Account*, and revoke all his/her *Tokens*.

        **Note**: requires full access to the *Account*.
      operationId: Account.deleteUser
      responses:
        "204":
          $ref: "#/responses/DeleteOK"
        "403":
          $ref: "#/responses/ErrorAccessAccount"
        default:
          $ref: "#/responses/DefaultError"
      summary: Delete a User
      tags:
        - Account
    get:
      description: Get information about a *User* in the same *Account*.
      operationId: Account.getUser
      responses:
        "200":
          description: |
            *User* information.
          schema:
            $ref: "#/definitions/User"
        default:
          $ref: "#/responses/DefaultError"
      summary: Information about a User
      tags:
        - Account
    parameters:
      - $ref: "#/parameters/userId"
    patch:
      description: |
        Modify a *User*.

        **Note**: requires full access to the *Account*.
      operationId: Account.patchUser
      parameters:
        - in: body
          name: userPatch
          required: true
          schema:
            $ref: "#/definitions/UserPatch"
      responses:
        "204":
          $ref: "#/responses/PatchOK"
        "304":
          $ref: "#/responses/PatchNotModified"
        "403":
          $ref: "#/responses/ErrorAccessAccount"
        default:
          $ref: "#/responses/DefaultError"
      summary: Modify a User
      tags:
        - Account
  "/account/users/{userId}/metadata":
    get:
      description: Get the metadata.
      operationId: User.getMetadata
      responses:
        "200":
          description: Successful.
          schema:
            $ref: "#/definitions/Metadata"
        default:
          $ref: "#/responses/DefaultError"
      summary: List metadata
      tags:
        - Account
    parameters:
      - $ref: "#/parameters/userId"
    patch:
      description: |
        Modify the metadata.
        Keys are limited to the same format as tags (up to 21 characters, [a-z0-9], starting with [a-z]). Values can be any JSON value.
      operationId: User.patchMetadata
      parameters:
        - $ref: "#/parameters/metadataPatch"
      responses:
        "200":
          description: Successful. The new metadata is returned.
          schema:
            $ref: "#/definitions/Metadata"
        "304":
          $ref: "#/responses/PatchNotModified"
        "403":
          $ref: "#/responses/ErrorAccessUser"
        default:
          $ref: "#/responses/DefaultError"
      summary: Modify metadata
      tags:
        - Account
  /auth/login:
    post:
      description: |
        Get an access+refresh tokens pair from login and password information.

        The *access token* obtained with this request can then be used in
        an `Access-Token` HTTP header or in a `token` URL query parameter
        in requests that require authentication.

        The *refresh token* can be used with `/auth/refresh` when the *access
        token* expires to retrieve a new *access token*. The lifetime of the
        refresh token is the maximum lifetime of this authentication request.

        The default lifetime of the *refresh token* is defined by the `appId`
        used. The `ttl` input parameter allows to request a *refresh token*
        with a shorter lifetime.

        To implement *logout*, use `/auth/revoke`.
      operationId: AuthAccountLogin
      parameters:
        - description: Login information.
          in: body
          name: loginInfo
          required: true
          schema:
            $ref: "#/definitions/AuthLogin"
      responses:
        "200":
          description: Login successful. The access token is given to use the API. The refresh token must be stored in a safe place.
          schema:
            $ref: "#/definitions/AuthTokens"
        "401":
          description: Authentication failure.
          schema:
            $ref: "#/definitions/DefaultError"
        default:
          $ref: "#/responses/DefaultError"
      security: []
      summary: Get a token using login+password
      tags:
        - Authentication
        - Entry points
  /auth/refresh:
    post:
      description: |
        Get a new *access token* using a valid *refresh token*.

        This is a **replacement** of the *access token*: if an existing *access
        token* was still not expired, it is invalidated.
      operationId: AuthRefreshToken
      parameters:
        - description: Refresh token information.
          in: body
          name: refreshInfo
          required: true
          schema:
            $ref: "#/definitions/AuthRefresh"
      responses:
        "200":
          description: Refresh successful. A new access token is given to use the API.
          schema:
            $ref: "#/definitions/AuthTokens"
        "401":
          description: Authentication failure.
          schema:
            $ref: "#/definitions/DefaultError"
        default:
          $ref: "#/responses/DefaultError"
      security: []
      summary: Refresh a token
      tags:
        - Authentication
  /auth/reset-password:
    post:
      description: |
        Trigger the request of a new password.

        The account administrator will receive an e-mail with an URL pointing to a form
        to allow him/her to enter a new password.
        The old password is still functional until a new one is submitted.

        Either the login or e-mail of the account must be given.
      operationId: AuthResetPassword
      parameters:
        - description: Account identification information
          in: body
          name: resetPasswordInfo
          required: true
          schema:
            $ref: "#/definitions/AuthResetPassword"
      responses:
        "204":
          description: As this request is not authenticated, response is always successful to not reveal (in)existence of accounts.
        default:
          $ref: "#/responses/DefaultError"
      security: []
      summary: Ask for a new password
      tags:
        - Authentication
  /auth/revoke:
    post:
      description: |
        Invalidate the authentication used for the request. The access token and the refresh token will be invalid after this request.
        This request is typically called to implement logout.
      operationId: AuthRevokeToken
      responses:
        "204":
          description: Revocation successful. The token used for the request is now invalid.
        "401":
          description: Authentication failure.
          schema:
            $ref: "#/definitions/DefaultError"
        default:
          $ref: "#/responses/DefaultError"
      summary: Revoke a token
      tags:
        - Authentication
  "/devices/{deviceId}":
    get:
      description: Get information about a *Device*.
      operationId: Devices.get
      responses:
        "200":
          description: Successful.
          schema:
            $ref: "#/definitions/Device"
        default:
          $ref: "#/responses/DefaultError"
      summary: Information about a Device
      tags:
        - Device
    parameters:
      - $ref: "#/parameters/deviceId"
    patch:
      description: |
        Modify information about a *Device*: its name.
      operationId: Devices.patch
      parameters:
        - in: body
          name: devicePatch
          required: true
          schema:
            $ref: "#/definitions/DevicePatch"
      responses:
        "204":
          $ref: "#/responses/PatchOK"
        "304":
          $ref: "#/responses/PatchNotModified"
        "403":
          $ref: "#/responses/ErrorAccessDevice"
        default:
          $ref: "#/responses/DefaultError"
      summary: Update a Device
      tags:
        - Device
  "/devices/{deviceId}/functionalities":
    post:
      description: |
        Add a *Functionality* to the device.

        Required parameters are :
        - functionality class
        - endpoint

        Each device class has its own restrictions on which Functionality classes can be added and on which endpoints.
        Only a few devices allow to add Functionalities.

        |Device class|Functionality class|Endpoints|
        |------------|-------------------|---------|
        |MINT        |CurrentPeriod      |1,2,3    |
        |MINT        |ElectricityRates   |1,2,3    |
        |MINT        |GenericRate        |1,2,3    |

        **Note**: requires full access to the *Account*.
      operationId: Device.addFunctionality
      parameters:
        - $ref: "#/parameters/deviceId"
        - in: body
          name: functionalityInfo
          required: true
          schema:
            $ref: "#/definitions/FunctionalityNew"
      responses:
        "201":
          description: "*Functionality* successfully created."
          headers:
            Location:
              description: Path of the Functionality created
              type: string
          schema:
            $ref: "#/definitions/FunctionalityCreated"
        "403":
          $ref: "#/responses/ErrorAccessDevice"
        default:
          $ref: "#/responses/DefaultError"
      summary: Add dynamically a functionality
      tags:
        - Device
        - Functionality
  "/devices/{deviceId}/metadata":
    get:
      description: Get the metadata.
      operationId: Device.getMetadata
      responses:
        "200":
          description: Successful.
          schema:
            $ref: "#/definitions/Metadata"
        default:
          $ref: "#/responses/DefaultError"
      summary: List metadata
      tags:
        - Device
    parameters:
      - $ref: "#/parameters/deviceId"
    patch:
      description: |
        Modify the metadata.
        Keys are limited to the same format as tags (up to 21 characters, [a-z0-9], starting with [a-z]). Values can be any JSON value.
      operationId: Device.patchMetadata
      parameters:
        - $ref: "#/parameters/metadataPatch"
      responses:
        "200":
          description: Successful. The new metadata is returned.
          schema:
            $ref: "#/definitions/Metadata"
        "304":
          $ref: "#/responses/PatchNotModified"
        "403":
          $ref: "#/responses/ErrorAccessDevice"
        default:
          $ref: "#/responses/DefaultError"
      summary: Modify metadata
      tags:
        - Device
  "/devices/{deviceId}/run/{action}":
    post:
      description: |
        Run an *Action* on zero, one or multiple Functionalities selected with tags.
      operationId: Device.run
      parameters:
        - $ref: "#/parameters/deviceId"
        - $ref: "#/parameters/action"
        - $ref: "#/parameters/functionalitiesSelector.Req"
        - in: body
          name: arguments
          required: true
          schema:
            $ref: "#/definitions/ActionArgs"
      responses:
        "200":
          $ref: "#/responses/ActionMultiResultOK"
        "450":
          $ref: "#/responses/ErrorGatewayUnreachable"
        default:
          $ref: "#/responses/DefaultError"
      summary: Run actions
      tags:
        - Action
  "/devices/{deviceId}/tags":
    get:
      description: Get the tags of a *Device*.
      operationId: Device.getTags
      responses:
        "200":
          description: Successful.
          schema:
            $ref: "#/definitions/Tags"
        default:
          $ref: "#/responses/DefaultError"
      summary: List tags
      tags:
        - Device
    parameters:
      - $ref: "#/parameters/deviceId"
    patch:
      description: Modify the tags of a *Device*.
      operationId: Device.patchTags
      parameters:
        - $ref: "#/parameters/tagsPatch"
      responses:
        "200":
          description: Successful. The new list of tags is returned.
          schema:
            $ref: "#/definitions/Tags"
        "304":
          $ref: "#/responses/PatchNotModified"
        "403":
          $ref: "#/responses/ErrorAccessDevice"
        default:
          $ref: "#/responses/DefaultError"
      summary: Modify tags
      tags:
        - Device
  "/functionalities/{functionalityId}":
    get:
      description: Get the *Functionality*.
      operationId: Functionalities.get
      responses:
        "200":
          description: Successful.
          schema:
            $ref: "#/definitions/Functionality"
        default:
          $ref: "#/responses/DefaultError"
      summary: Information about a Functionality
      tags:
        - Functionality
    parameters:
      - $ref: "#/parameters/functionalityId"
    patch:
      description: |
        Modify information about a *Functionality*: its name.
      operationId: Functionality.patch
      parameters:
        - in: body
          name: functionalityPatch
          required: true
          schema:
            $ref: "#/definitions/FunctionalityPatch"
      responses:
        "204":
          $ref: "#/responses/PatchOK"
        "304":
          $ref: "#/responses/PatchNotModified"
        "403":
          $ref: "#/responses/ErrorAccessFunctionality"
        default:
          $ref: "#/responses/DefaultError"
      summary: Modify a Functionality
      tags:
        - Functionality
  "/functionalities/{functionalityId}/attributes":
    get:
      description: |
        Get the values of multiple *Attributes* and their history.

        If the `names` parameter is not given, all the attributes of the *Functionality*
        are returned. As the list may be huge, this must be avoided.

        If the `to` parameter is set, `from` must also be set.

        If `from` is not set, only the last value is returned.

        The `surround` parameter allows to ask also for one value beyond each interval boundaries.

        The request may fail if too many values are asked.
      operationId: Functionality.values
      parameters:
        - $ref: "#/parameters/attributesNames"
        - $ref: "#/parameters/from.Opt"
        - $ref: "#/parameters/to"
        - description: If true, return also one value before from and one value after to
          in: query
          name: surround
          required: false
          type: boolean
      responses:
        "200":
          description: Successful.
          schema:
            $ref: "#/definitions/AttributesValues"
        default:
          $ref: "#/responses/DefaultError"
      summary: Get history of multiple attributes
      tags:
        - Functionality
    parameters:
      - $ref: "#/parameters/functionalityId"
  "/functionalities/{functionalityId}/attributes/{attributeName}":
    get:
      description: Get the *Attribute* value and the last time when it changed.
      operationId: Functionality.value
      responses:
        "200":
          description: Successful.
          schema:
            $ref: "#/definitions/AttributeValue"
        "204":
          description: No value has yet been set on this attribute.
        default:
          $ref: "#/responses/DefaultError"
      summary: Get an Attribute value
      tags:
        - Functionality
    parameters:
      - $ref: "#/parameters/functionalityId"
      - $ref: "#/parameters/attributeName"
    put:
      description: Modify the value of the *Attribute*.
      operationId: Functionality.set
      parameters:
        - description: New value for the *Attribute*.
          in: body
          name: value
          required: true
          schema:
            $ref: "#/definitions/AnyJSON"
      responses:
        "204":
          description: Successful.
        "405":
          $ref: "#/responses/ErrorWriteAttribute"
        default:
          $ref: "#/responses/DefaultError"
      summary: Modify an Attribute value
      tags:
        - Functionality
  "/functionalities/{functionalityId}/metadata":
    get:
      description: Get the metadata.
      operationId: Functionality.getMetadata
      responses:
        "200":
          description: Successful.
          schema:
            $ref: "#/definitions/Metadata"
        default:
          $ref: "#/responses/DefaultError"
      summary: List metadata
      tags:
        - Functionality
    parameters:
      - $ref: "#/parameters/functionalityId"
    patch:
      description: |
        Modify the metadata.
        Keys are limited to the same format as tags (up to 21 characters, [a-z0-9], starting with [a-z]). Values can be any JSON value.
      operationId: Functionality.patchMetadata
      parameters:
        - $ref: "#/parameters/metadataPatch"
      responses:
        "200":
          description: Successful. The new metadata is returned.
          schema:
            $ref: "#/definitions/Metadata"
        "304":
          $ref: "#/responses/PatchNotModified"
        "403":
          $ref: "#/responses/ErrorAccessFunctionality"
        default:
          $ref: "#/responses/DefaultError"
      summary: Modify metadata
      tags:
        - Functionality
  "/functionalities/{functionalityId}/run/{action}":
    post:
      description: |
        Run an action on the Functionality.
      operationId: Functionality.run
      parameters:
        - $ref: "#/parameters/functionalityId"
        - $ref: "#/parameters/action"
        - in: body
          name: arguments
          required: true
          schema:
            $ref: "#/definitions/ActionArgs"
      responses:
        "200":
          description: Successful.
          schema:
            $ref: "#/definitions/ActionResult"
        "450":
          $ref: "#/responses/ErrorGatewayUnreachable"
        default:
          $ref: "#/responses/DefaultError"
      summary: Run an action
      tags:
        - Action
  "/functionalities/{functionalityId}/tags":
    get:
      description: Get the tags of a *Functionality*.
      operationId: Functionality.getTags
      responses:
        "200":
          description: Successful.
          schema:
            $ref: "#/definitions/Tags"
        default:
          $ref: "#/responses/DefaultError"
      summary: List tags
      tags:
        - Functionality
    parameters:
      - $ref: "#/parameters/functionalityId"
    patch:
      description: Modify the tags of a *Functionality*.
      operationId: Functionality.patchTags
      parameters:
        - $ref: "#/parameters/tagsPatch"
      responses:
        "200":
          description: Successful. The new list of tags is returned.
          schema:
            $ref: "#/definitions/Tags"
        "304":
          $ref: "#/responses/PatchNotModified"
        "403":
          $ref: "#/responses/ErrorAccessFunctionality"
        default:
          $ref: "#/responses/DefaultError"
      summary: Modify tags
      tags:
        - Functionality
  /me:
    get:
      description: |
        Get information on the authenticated *User* who does the request.

        The *login* property is returned only if the *User* is the administrator of
        the *Account*.
      operationId: Me.get
      responses:
        "200":
          description: Successful response
          schema:
            $ref: "#/definitions/UserMe"
      summary: Information about the User
      tags:
        - Entry points
    patch:
      description: |
        Update *User* information (locale).
      operationId: Me.patch
      parameters:
        - description: Updated user info.
          in: body
          name: userPatch
          required: true
          schema:
            $ref: "#/definitions/UserMePatch"
      responses:
        "204":
          $ref: "#/responses/PatchOK"
        "304":
          $ref: "#/responses/PatchNotModified"
        default:
          $ref: "#/responses/DefaultError"
      summary: Update User information
      tags:
        - Entry points
  "/notifications/{notificationId}":
    delete:
      description: |
        Delete a *Notification*.
      operationId: Notification.delete
      responses:
        "204":
          $ref: "#/responses/DeleteOK"
        "403":
          $ref: "#/responses/ErrorAccessNotification"
        default:
          $ref: "#/responses/DefaultError"
      summary: Delete a Notification
      tags:
        - Notification
    get:
      description: |
        Get information about a *Notification*.
      operationId: Notifications.get
      responses:
        "200":
          description: Successful.
          schema:
            $ref: "#/definitions/Notification"
        "403":
          $ref: "#/responses/ErrorAccessNotification"
        default:
          $ref: "#/responses/DefaultError"
      summary: Information about a Notification
      tags:
        - Notification
    parameters:
      - $ref: "#/parameters/notificationId"
    patch:
      description: |
        Modify a *Notification*.
      operationId: Notification.patch
      parameters:
        - in: body
          name: notificationPatch
          required: true
          schema:
            $ref: "#/definitions/NotificationPatch"
      responses:
        "204":
          $ref: "#/responses/PatchOK"
        "304":
          $ref: "#/responses/PatchNotModified"
        "403":
          $ref: "#/responses/ErrorAccessNotification"
        default:
          $ref: "#/responses/DefaultError"
      summary: Modify a Notification
      tags:
        - Notification
  "/notifications/{notificationId}/metadata":
    get:
      description: Get the metadata of the *Notification*.
      operationId: Notification.getMetadata
      responses:
        "200":
          description: Successful.
          schema:
            $ref: "#/definitions/Metadata"
        default:
          $ref: "#/responses/DefaultError"
      summary: List metadata
      tags:
        - Notification
    parameters:
      - $ref: "#/parameters/notificationId"
    patch:
      description: |
        Modify the metadata of a *Notification*.
        Keys are limited to the same format as tags (up to 21 characters, [a-z0-9], starting with [a-z]). Values can be any JSON value.
      operationId: Notification.patchMetadata
      parameters:
        - $ref: "#/parameters/metadataPatch"
      responses:
        "200":
          description: Successful. The new metadata is returned.
          schema:
            $ref: "#/definitions/Metadata"
        "304":
          $ref: "#/responses/PatchNotModified"
        "403":
          $ref: "#/responses/ErrorAccessNotification"
        default:
          $ref: "#/responses/DefaultError"
      summary: Modify metadata of a Notification
      tags:
        - Notification
  /places:
    get:
      description: List the *Places* to which the *Token* has access.
      operationId: Me.places
      parameters:
        - $ref: "#/parameters/embedMetadata"
      responses:
        "200":
          description: Successful response
          schema:
            items:
              $ref: "#/definitions/PlaceItem"
            type: array
            uniqueItems: true
      summary: List accessible Places
      tags:
        - Entry points
  "/places/{placeId}":
    get:
      description: Get information about a *Place*.
      operationId: Places.get
      responses:
        "200":
          description: Successful response.
          schema:
            $ref: "#/definitions/Place"
        "400":
          $ref: "#/responses/ErrorAccessPlace"
      summary: Information about a Place
      tags:
        - Place
    parameters:
      - $ref: "#/parameters/placeId"
    patch:
      description: |
        Change information about a *Place*.

        **Note**: requires full access to the *Account*.
      operationId: Place.patch
      parameters:
        - in: body
          name: placePatch
          required: true
          schema:
            $ref: "#/definitions/PlacePatch"
      responses:
        "204":
          $ref: "#/responses/PatchOK"
        "304":
          $ref: "#/responses/PatchNotModified"
        "403":
          $ref: "#/responses/ErrorAccessAccount"
        default:
          $ref: "#/responses/DefaultError"
      summary: Update a Place
      tags:
        - Place
  "/places/{placeId}/buses":
    get:
      description: |-
        Get the list of *Buses* available on the gateway of this *Place*.
        If `withPairing` is `true`, return only buses that allow device pairing (see `/places/{placeId}/buses/{busId}/pairing`).
      operationId: Place.buses
      parameters:
        - default: false
          description: Filter out buses that have no pairing window
          in: query
          name: withPairing
          required: false
          type: boolean
      responses:
        "200":
          description: Successful.
          schema:
            items:
              $ref: "#/definitions/BusItem"
            type: array
            uniqueItems: true
        "403":
          $ref: "#/responses/ErrorAccessBus"
      summary: List Buses
      tags:
        - Place
    parameters:
      - $ref: "#/parameters/placeId"
  "/places/{placeId}/buses/{busId}/pairing":
    get:
      description: |
        Get the state of the pairing window of the *Bus*.

        **Note**: requires full access to the *Account*.
      operationId: Place.pairing
      responses:
        "200":
          description: State information.
          schema:
            $ref: "#/definitions/BusPairing"
        "403":
          $ref: "#/responses/ErrorAccessBus"
      summary: State of the pairing window
      tags:
        - Place
    parameters:
      - $ref: "#/parameters/placeId"
      - $ref: "#/parameters/busId"
    put:
      description: |
        Open/Close the pairing window.

        **Note**: requires full access to the *Account*.
      operationId: Place.openPairing
      parameters:
        - in: body
          name: pairing
          required: true
          schema:
            $ref: "#/definitions/BusPairing"
      responses:
        "200":
          description: State information.
          schema:
            $ref: "#/definitions/BusPairing"
        "403":
          $ref: "#/responses/ErrorAccessBus"
        default:
          $ref: "#/responses/DefaultError"
      summary: Open/Close the pairing window
      tags:
        - Place
  "/places/{placeId}/devices":
    get:
      description: Get the list of *Devices* available in this *Place*.
      operationId: Place.devices
      parameters:
        - $ref: "#/parameters/devicesSelector.Opt"
        - $ref: "#/parameters/embedMetadata"
      responses:
        "200":
          description: Successful.
          schema:
            items:
              $ref: "#/definitions/DeviceItem"
            type: array
            uniqueItems: true
        default:
          $ref: "#/responses/DefaultError"
      summary: List of Devices
      tags:
        - Device
    parameters:
      - $ref: "#/parameters/placeId"
  "/places/{placeId}/electricity/autonomy":
    get:
      description: |
        Compute the autonomy rate of the *Place* on a time period.

        `autonomy = 1 - (elec_drawn / elec_total_usage)`
      operationId: Place.Electricity.autonomy
      parameters:
        - $ref: "#/parameters/when.Req"
        - $ref: "#/parameters/span.Req"
      responses:
        "200":
          description: Successful.
          schema:
            $ref: "#/definitions/ElectricityAutonomy"
        default:
          $ref: "#/responses/DefaultError"
      summary: Get autonomy rate of the place
      tags:
        - Electricity
    parameters:
      - $ref: "#/parameters/placeId"
  "/places/{placeId}/electricity/flows":
    get:
      description: |
        Get the mapping of virtual electricity flows to functionalities.

        Some rules are applied to expand the virtual flows using the concrete
        flows available.

        The `factor` tells how each energy value coming from a functionality
        must be added with values from other functionality to compute the
        energy of the virtual flow. Factors are usually `1` or `-1`.

        The `code` property gives the result which may be partial:
        - If all flows are available, `200000` is returned.
        - If no flows are available (indicating that the place has no
          electricity functionality or that no functionality has been attached
          to a flow), the `code` is `200001`. The `missing` property contains
          all the requested flows.
        - If some flows are missing, the `code` is `200002` and the `missing`
          property lists them.
      operationId: Place.Electricity.getFlows
      parameters:
        - collectionFormat: csv
          description: Names of the flows requested
          in: query
          items:
            enum:
              - battery_charge
              - battery_discharge
              - battery_grid
              - elec_total_gen
              - elec_total_usage
              - elec_feed_in
              - elec_drawn
              - elec_local
              - elec_from_household
              - elec_to_pv
              - elec_usage
            type: string
          name: flows
          required: true
          type: array
      responses:
        "200":
          description: Place is available. `code` gives the functional result.
          schema:
            $ref: "#/definitions/ElectricityFlows"
        default:
          $ref: "#/responses/DefaultError"
      summary: Get electricity virtual flows
      tags:
        - Electricity
    parameters:
      - $ref: "#/parameters/placeId"
  "/places/{placeId}/electricity/flows/setup":
    get:
      description: |
        Get the mapping of functionalities to electricity flows.

        A functionality is attached to *at most* one flow.
      operationId: Place.Electricity.getFlowsSetup
      responses:
        "200":
          description: Successful.
          schema:
            $ref: "#/definitions/ElectricityFlowsSetup"
        default:
          $ref: "#/responses/DefaultError"
      summary: Get electricity flows setup
      tags:
        - Electricity
    parameters:
      - $ref: "#/parameters/placeId"
  "/places/{placeId}/electricity/self-consumption":
    get:
      description: |
        Compute the self-consumption rate of the *Place* on a time period.

        `selfConsumption = 1 - (elec_feed_in / elec_total_usage)`
      operationId: Place.Electricity.selfConsumption
      parameters:
        - $ref: "#/parameters/when.Req"
        - $ref: "#/parameters/span.Req"
      responses:
        "200":
          description: Successful.
          schema:
            $ref: "#/definitions/ElectricitySelfConsumption"
        default:
          $ref: "#/responses/DefaultError"
      summary: Get self-consumption rate of the place
      tags:
        - Electricity
    parameters:
      - $ref: "#/parameters/placeId"
  "/places/{placeId}/functionalities":
    get:
      description: Get the list of *Functionalities* available in this *Place*.
      operationId: Place.functionalities
      parameters:
        - $ref: "#/parameters/embedMetadata"
      responses:
        "200":
          description: Successful.
          schema:
            items:
              $ref: "#/definitions/FunctionalityItem"
            type: array
            uniqueItems: true
        default:
          $ref: "#/responses/DefaultError"
      summary: List Functionalities
      tags:
        - Functionality
    parameters:
      - $ref: "#/parameters/placeId"
      - $ref: "#/parameters/devicesSelector.Opt"
      - $ref: "#/parameters/functionalitiesSelector.Opt"
  "/places/{placeId}/metadata":
    get:
      description: Get the metadata.
      operationId: Place.getMetadata
      responses:
        "200":
          description: Successful.
          schema:
            $ref: "#/definitions/Metadata"
        default:
          $ref: "#/responses/DefaultError"
      summary: List metadata
      tags:
        - Place
    parameters:
      - $ref: "#/parameters/placeId"
    patch:
      description: |
        Modify the metadata.
        Keys are limited to the same format as tags (up to 21 characters, [a-z0-9], starting with [a-z]). Values can be any JSON value.
      operationId: Place.patchMetadata
      parameters:
        - $ref: "#/parameters/metadataPatch"
      responses:
        "200":
          description: Successful. The new metadata is returned.
          schema:
            $ref: "#/definitions/Metadata"
        "304":
          $ref: "#/responses/PatchNotModified"
        "403":
          $ref: "#/responses/ErrorAccessPlace"
        default:
          $ref: "#/responses/DefaultError"
      summary: Modify metadata
      tags:
        - Place
  "/places/{placeId}/notifications":
    get:
      description: Get the list of *Notifications* available in this *Place*.
      operationId: Place.notifications
      parameters:
        - $ref: "#/parameters/embedMetadata"
      responses:
        "200":
          description: Successful.
          schema:
            items:
              $ref: "#/definitions/NotificationItem"
            type: array
            uniqueItems: true
        default:
          $ref: "#/responses/DefaultError"
      summary: List Notifications
      tags:
        - Notification
    parameters:
      - $ref: "#/parameters/placeId"
    post:
      description: Create a new *Notification*.
      operationId: Place.newNotification
      parameters:
        - in: body
          name: notification
          required: true
          schema:
            $ref: "#/definitions/NotificationNew"
      responses:
        "201":
          description: "*Notification* successfully created."
          headers:
            Location:
              description: Path of the Notification created (`/notifications/{id}`)
              type: string
          schema:
            $ref: "#/definitions/NotificationCreated"
        "403":
          $ref: "#/responses/ErrorAccessPlace"
        default:
          $ref: "#/responses/DefaultError"
      summary: Create a Notification
      tags:
        - Notification
  "/places/{placeId}/programs":
    get:
      description: Get the list of *Programs* available in this *Place*.
      operationId: Place.programs
      parameters:
        - $ref: "#/parameters/embedMetadata"
      responses:
        "200":
          description: Successful.
          schema:
            items:
              $ref: "#/definitions/ProgramItem"
            type: array
            uniqueItems: true
        default:
          $ref: "#/responses/DefaultError"
      summary: List Programs
      tags:
        - Program
    parameters:
      - $ref: "#/parameters/placeId"
    post:
      description: |
        Create a new *Program*.

        **Note**: requires full access to the *Account*.
      operationId: Place.newProgram
      parameters:
        - in: body
          name: programInfo
          required: true
          schema:
            $ref: "#/definitions/ProgramNew"
      responses:
        "201":
          description: "*Program* successfully created."
          headers:
            Location:
              description: Path of the Program created (`/programs/{id}`)
              type: string
          schema:
            $ref: "#/definitions/ProgramCreated"
        "403":
          $ref: "#/responses/ErrorAccessPlace"
        default:
          $ref: "#/responses/DefaultError"
      summary: Create a Program
      tags:
        - Program
  "/places/{placeId}/run/{action}":
    post:
      description: |
        Run an *Action* on zero, one or multiple *Functionalities* selected with tags.

        *Device* and *Functionality* selection are combined with « AND ».

        If no functionality is matched by the device/functionality selection, an empty array is returned.
      operationId: Place.run
      parameters:
        - $ref: "#/parameters/placeId"
        - $ref: "#/parameters/action"
        - $ref: "#/parameters/devicesSelector.Req"
        - $ref: "#/parameters/functionalitiesSelector.Req"
        - in: body
          name: arguments
          required: true
          schema:
            $ref: "#/definitions/ActionArgs"
      responses:
        "200":
          $ref: "#/responses/ActionMultiResultOK"
        "450":
          $ref: "#/responses/ErrorGatewayUnreachable"
        default:
          $ref: "#/responses/DefaultError"
      summary: Run actions
      tags:
        - Action
  "/programs/{programId}":
    delete:
      description: |
        Delete a *Program*.

        **Note**: requires full access to the *Account*.
      operationId: Program.delete
      responses:
        "204":
          $ref: "#/responses/DeleteOK"
        "403":
          $ref: "#/responses/ErrorAccessProgram"
        default:
          $ref: "#/responses/DefaultError"
      summary: Delete a Program
      tags:
        - Program
    get:
      description: |
        Get information about a *Program*.
      operationId: Programs.get
      responses:
        "200":
          description: Successful.
          schema:
            $ref: "#/definitions/Program"
        "403":
          $ref: "#/responses/ErrorAccessProgram"
        default:
          $ref: "#/responses/DefaultError"
      summary: Information about a Program
      tags:
        - Program
    parameters:
      - $ref: "#/parameters/programId"
    patch:
      description: |
        Modify a *Program*:
        - name
        - status (enabled/disabled)
        - code

        **Note**: requires full access to the *Account*.
      operationId: Program.patch
      parameters:
        - in: body
          name: programPatch
          required: true
          schema:
            $ref: "#/definitions/ProgramPatch"
      responses:
        "204":
          $ref: "#/responses/PatchOK"
        "304":
          $ref: "#/responses/PatchNotModified"
        "403":
          $ref: "#/responses/ErrorAccessProgram"
        default:
          $ref: "#/responses/DefaultError"
      summary: Modify a Program
      tags:
        - Program
  "/programs/{programId}/log":
    get:
      description: Get the execution history list of this *Program*.
      operationId: Program.log
      parameters:
        - $ref: "#/parameters/from.Req"
        - $ref: "#/parameters/to"
      responses:
        "200":
          description: Successful.
          schema:
            items:
              $ref: "#/definitions/ProgramLog"
            type: array
            uniqueItems: true
        "403":
          $ref: "#/responses/ErrorAccessProgram"
        default:
          $ref: "#/responses/DefaultError"
      summary: History of executions of a Program
      tags:
        - Program
    parameters:
      - $ref: "#/parameters/programId"
  "/programs/{programId}/metadata":
    get:
      description: Get the metadata of the *Program*.
      operationId: Program.getMetadata
      responses:
        "200":
          description: Successful.
          schema:
            $ref: "#/definitions/Metadata"
        default:
          $ref: "#/responses/DefaultError"
      summary: List metadata
      tags:
        - Program
    parameters:
      - $ref: "#/parameters/programId"
    patch:
      description: |
        Modify the metadata of a *Program*.
        Keys are limited to the same format as tags (up to 21 characters, [a-z0-9], starting with [a-z]). Values can be any JSON value.
      operationId: Program.patchMetadata
      parameters:
        - $ref: "#/parameters/metadataPatch"
      responses:
        "200":
          description: Successful. The new metadata is returned.
          schema:
            $ref: "#/definitions/Metadata"
        "304":
          $ref: "#/responses/PatchNotModified"
        "403":
          $ref: "#/responses/ErrorAccessProgram"
        default:
          $ref: "#/responses/DefaultError"
      summary: Modify metadata of a Program
      tags:
        - Program
  "/programs/{programId}/run":
    parameters:
      - $ref: "#/parameters/programId"
    post:
      description: |-
        Launch the *Program*.
        The result will be available later in the run history.
      operationId: Program.run
      responses:
        "204":
          description: "*Program* successfully launched."
        "403":
          $ref: "#/responses/ErrorAccessProgram"
        default:
          $ref: "#/responses/DefaultError"
      summary: Run the Program
      tags:
        - Program
definitions:
  AccountId:
    description: Unique identifier of the *Account*
    example: t1hqYcQITCFX-AObjs_t4Q
    maxLength: 22
    minLength: 22
    pattern: ^[A-Za-z0-9-_]{22}$
    readOnly: true
    type: string
  AccountLogin:
    minLength: 1
    type: string
  ActionArgs:
    example:
      - true
      - 1
      - hello
    items:
      $ref: "#/definitions/AnyJSON"
    type: array
  ActionMultiResult:
    items:
      $ref: "#/definitions/ActionResult"
    type: array
  ActionName:
    minLength: 1
    readOnly: true
    type: string
  ActionResult:
    example:
      functionality: RnVuY3Rpb25hbGl0eTAwMA
      result: []
      status: 200
    properties:
      functionality:
        $ref: "#/definitions/FunctionalityId"
      result:
        items:
          $ref: "#/definitions/AnyJSON"
        type: array
      status:
        description: Return code (HTTP status code)
        example: 200
        maximum: 599
        minimum: 200
        type: integer
    required:
      - status
    type: object
    x-links:
      - href: /functionalities/{functionality}
        rel: functionality
  AnyJSON:
    description: null/boolean/integer/number/string/object/array
    x-type: any
  AppId:
    minLength: 1
    type: string
  AttributeName:
    minLength: 1
    readOnly: true
    type: string
  AttributeValue:
    example:
      value: 0
      when: 2014-02-17T12:31:00Z
    properties:
      value:
        $ref: "#/definitions/AnyJSON"
      when:
        format: date-time
        type: string
    required:
      - when
      - value
    type: object
  AttributesValues:
    additionalProperties:
      items:
        $ref: "#/definitions/AttributeValue"
      type: array
    description: Keys are attribute ids
    example:
      Counter:
        - value: 0
          when: 2014-02-17T12:31:00Z
      Schedule:
        - value:
            - DTSTAMP: 20120101T000000Z
              DTSTART:
                "": 20120101T063000
                TZID: Europe/Paris
              RRULE:
                FREQ: DAILY
              SUMMARY: "2"
              UID: HP-06h30@si.ijenko.net
            - DTSTAMP: 20120101T000000Z
              DTSTART:
                "": 20120101T223000
                TZID: Europe/Paris
              RRULE:
                FREQ: DAILY
              SUMMARY: "3"
              UID: HC-22h30@si.ijenko.net
          when: 2014-02-17T00:00:00Z
    type: object
  AuthChangePassword:
    properties:
      newPassword:
        $ref: "#/definitions/Password"
      oldPassword:
        $ref: "#/definitions/Password"
    required:
      - oldPassword
      - newPassword
    type: object
  AuthLogin:
    properties:
      appId:
        $ref: "#/definitions/AppId"
      login:
        minLength: 1
        type: string
      password:
        $ref: "#/definitions/Password"
      ttl:
        description: Desired maximum life-time in seconds for the refresh token
        example: 1800
        minimum: 0
        type: integer
    required:
      - login
      - password
      - appId
    type: object
  AuthRefresh:
    properties:
      appId:
        $ref: "#/definitions/AppId"
      refreshToken:
        minLength: 1
        type: string
    required:
      - refreshToken
      - appId
    type: object
  AuthResetPassword:
    properties:
      appId:
        $ref: "#/definitions/AppId"
      email:
        $ref: "#/definitions/UserEmail"
      login:
        minLength: 1
        type: string
    required:
      - appId
    type: object
  AuthTokens:
    properties:
      accessToken:
        minLength: 1
        type: string
      accessTokenExpires:
        format: date-time
        type: string
      refreshToken:
        minLength: 1
        type: string
      refreshTokenExpires:
        format: date-time
        type: string
    required:
      - accessToken
      - refreshToken
      - accessTokenExpires
      - refreshTokenExpires
    type: object
  BusId:
    minLength: 3
    type: string
  BusItem:
    properties:
      functionality:
        $ref: "#/definitions/FunctionalityId"
      id:
        $ref: "#/definitions/BusId"
      protocol:
        $ref: "#/definitions/BusProtocol"
    readOnly: true
    required:
      - id
      - functionality
      - protocol
    type: object
  BusPairing:
    properties:
      duration:
        description: Duration of the pairing window.
        type: integer
      enabled:
        type: boolean
    required:
      - enabled
    type: object
  BusProtocol:
    minLength: 1
    type: string
  CountryCode:
    description: Country code (ISO 3166-1 alpha-2)
    example: FR
    maxLength: 2
    minLength: 2
    pattern: ^[A-Z][A-Z]$
    type: string
  DefaultError:
    description: Any error.
    properties:
      code:
        type: integer
      message:
        type: string
    required:
      - code
      - message
    type: object
  Device:
    properties:
      address:
        $ref: "#/definitions/DeviceAddress"
      attributes:
        additionalProperties:
          additionalProperties:
            $ref: "#/definitions/AnyJSON"
          description: Each key is an attribute name
          type: object
        description: Each key is <FunctionalityClass>@<Endpoint>
        type: object
      class:
        $ref: "#/definitions/DeviceClass"
      functionalities:
        items:
          $ref: "#/definitions/FunctionalityItem"
        readOnly: true
        type: array
        uniqueItems: true
      isOnline:
        readOnly: true
        type: boolean
      manufacturer:
        readOnly: true
        type: string
      metadata:
        $ref: "#/definitions/Metadata"
      model:
        readOnly: true
        type: string
      name:
        description: Name of the device. User defined.
        minLength: 2
        type: string
      place:
        $ref: "#/definitions/PlaceId"
      protocol:
        $ref: "#/definitions/BusProtocol"
      tags:
        items:
          $ref: "#/definitions/DeviceTag"
        type: array
        uniqueItems: true
    required:
      - place
      - class
      - address
      - isOnline
      - functionalities
      - tags
    type: object
    x-links:
      - href: /places/{place}
        rel: place
  DeviceAddress:
    minLength: 1
    pattern: ^[A-Z0-9]{1,32}$
    type: string
  DeviceClass:
    maxLength: 4
    minLength: 4
    pattern: ^[A-Z][A-Z0-9]{3}$
    type: string
  DeviceId:
    description: Unique identifier of the *Device*
    example: RGV2aWNlMDAwMDAwMDAwMA
    maxLength: 22
    minLength: 22
    pattern: ^[A-Za-z0-9-_]{22}$
    readOnly: true
    type: string
  DeviceItem:
    properties:
      address:
        $ref: "#/definitions/DeviceAddress"
      class:
        $ref: "#/definitions/DeviceClass"
      id:
        $ref: "#/definitions/DeviceId"
      isOnline:
        type: boolean
      metadata:
        $ref: "#/definitions/MetadataSelected"
      name:
        description: Name of the *Device* as defined by the user. Can be used for user interfaces.
        minLength: 2
        type: string
      place:
        $ref: "#/definitions/PlaceId"
      tags:
        items:
          $ref: "#/definitions/DeviceTag"
        type: array
        uniqueItems: true
    readOnly: true
    required:
      - id
      - place
      - class
      - address
      - isOnline
      - tags
    type: object
    x-links:
      - href: /devices/{id}
        rel: full
      - href: /places/{place}
        rel: place
  DevicePatch:
    properties:
      name:
        description: Name of the *Device* as defined by the user. Can be used for user interfaces.
        minLength: 2
        type: string
    type: object
  DeviceTag:
    maxLength: 21
    minLength: 1
    pattern: ^[a-z](?:[a-z0-9_]{0,20}|[a-z0-9_]:[a-z0-9_]{1,18}|[a-z0-9_]{2}:[a-z0-9_]{1,17}|[a-z0-9_]{3}:[a-z0-9_]{1,16}|[a-z0-9_]{4}:[a-z0-9_]{1,15})$
    type: string
  ElectricityAutonomy:
    example:
      autonomy: 0.4
      code: 200000
      from: 2016-03-02T09:00:00Z
      to: 2016-03-02T10:00:00Z
    properties:
      autonomy:
        description: Average electricity autonomy in % (value in range [0, 1], rounded)
        example: 0.4
        maximum: 1
        minimum: 0
        type: number
      code:
        $ref: "#/definitions/ElectricityStatusCode"
      from:
        format: date-time
        type: string
      message:
        description: Message for cases where computation is not possible (codes 200001, 200002)
        minLength: 1
        type: string
      to:
        format: date-time
        type: string
    required:
      - code
    type: object
  ElectricityFlow:
    items:
      $ref: "#/definitions/ElectricityFunctionality"
    type: array
    uniqueItems: true
  ElectricityFlowFormula:
    items:
      $ref: "#/definitions/ElectricityFlowFunctionality"
    type: array
    uniqueItems: true
  ElectricityFlowFunctionality:
    example:
      class: ElecMetering
      factor: 1
      flow: elec_total_gen
      id: RnVuY3Rpb25hbGl0eTAwMA
    properties:
      class:
        $ref: "#/definitions/FunctionalityClass"
      factor:
        type: integer
      flow:
        $ref: "#/definitions/ElectricityFlowName"
      id:
        $ref: "#/definitions/FunctionalityId"
    required:
      - id
      - class
      - flow
      - factor
    type: object
    x-links:
      - href: /functionalities/{id}
        rel: full
  ElectricityFlowName:
    description: Name of an electricity flow
    enum:
      - battery_charge
      - battery_discharge
      - battery_grid
      - elec_total_gen
      - elec_total_usage
      - elec_feed_in
      - elec_drawn
      - elec_local
      - elec_from_household
      - elec_to_pv
      - elec_usage
    minLength: 1
    type: string
  ElectricityFlows:
    example:
      code: 200000
      flows:
        elec_local:
          - class: ElecMetering
            factor: 1
            id: SF4_y4SoTCpYXgGODJplJQ
        elec_total_usage:
          - class: ElecMetering
            factor: 1
            flow: elec_total_gen
            id: SF4_y4SoTCpYXgGODJplJQ
          - class: ElecSmartMetering
            factor: 1
            flow: elec_drawn
            id: lvxvQ9SqXCpYSqHOJI7tIA
          - class: ElecSmartMetering
            factor: -1
            flow: elec_feed_in
            id: d1xvwdWKWCpYH6GPjovnLg
    properties:
      code:
        $ref: "#/definitions/ElectricityStatusCode"
      flows:
        $ref: "#/definitions/ElectricityVirtualFlows"
      message:
        $ref: "#/definitions/ElectricityStatusMessage"
      missing:
        $ref: "#/definitions/ElectricityMissingFlows"
    required:
      - code
    type: object
  ElectricityFlowsSetup:
    example:
      elec_drawn:
        - class: ElecSmartMetering
          id: lvxvQ9SqXCpYSqHOJI7tIA
      elec_feed_in:
        - class: ElecSmartMetering
          id: d1xvwdWKWCpYH6GPjovnLg
      elec_total_gen:
        - class: ElecMetering
          id: SF4_y4SoTCpYXgGODJplJQ
    properties:
      battery_charge:
        $ref: "#/definitions/ElectricityFlow"
      battery_discharge:
        $ref: "#/definitions/ElectricityFlow"
      battery_grid:
        $ref: "#/definitions/ElectricityFlow"
      elec_drawn:
        $ref: "#/definitions/ElectricityFlow"
      elec_feed_in:
        $ref: "#/definitions/ElectricityFlow"
      elec_from_household:
        $ref: "#/definitions/ElectricityFlow"
      elec_local:
        $ref: "#/definitions/ElectricityFlow"
      elec_to_pv:
        $ref: "#/definitions/ElectricityFlow"
      elec_total_gen:
        $ref: "#/definitions/ElectricityFlow"
      elec_total_usage:
        $ref: "#/definitions/ElectricityFlow"
      elec_usage:
        $ref: "#/definitions/ElectricityFlow"
    type: object
  ElectricityFunctionality:
    example:
      class: ElecMetering
      id: RnVuY3Rpb25hbGl0eTAwMA
    properties:
      class:
        $ref: "#/definitions/FunctionalityClass"
      id:
        $ref: "#/definitions/FunctionalityId"
    required:
      - id
      - class
    type: object
    x-links:
      - href: /functionalities/{id}
        rel: full
  ElectricityMissingFlows:
    description: List of missing flows (not available either directly or indirectly)
    properties:
      battery_charge:
        enum:
          - true
        type: boolean
      battery_discharge:
        enum:
          - true
        type: boolean
      battery_grid:
        enum:
          - true
        type: boolean
      elec_drawn:
        enum:
          - true
        type: boolean
      elec_feed_in:
        enum:
          - true
        type: boolean
      elec_from_household:
        enum:
          - true
        type: boolean
      elec_local:
        enum:
          - true
        type: boolean
      elec_to_pv:
        enum:
          - true
        type: boolean
      elec_total_gen:
        enum:
          - true
        type: boolean
      elec_total_usage:
        enum:
          - true
        type: boolean
      elec_usage:
        enum:
          - true
        type: boolean
    type: object
  ElectricitySelfConsumption:
    example:
      code: 200000
      from: 2016-03-02T10:00:00Z
      selfConsumption: 1
      to: 2016-03-02T11:00:00Z
    properties:
      code:
        $ref: "#/definitions/ElectricityStatusCode"
      from:
        format: date-time
        type: string
      message:
        description: Message for cases where computation is not possible (codes 200001, 200002)
        minLength: 1
        type: string
      selfConsumption:
        description: Average self-consumption rate in % (value in range [0, 1], rounded)
        example: 0.555555
        maximum: 1
        minimum: 0
        type: number
      to:
        format: date-time
        type: string
    required:
      - code
    type: object
  ElectricityStatusCode:
    description: Status code. 200000 means OK. Other codes indicate full or partial failure.
    enum:
      - 200000
      - 200001
      - 200002
    example: 200000
    type: integer
  ElectricityStatusMessage:
    description: Message for cases where computation is not possible (codes 200001, 200002)
    minLength: 1
    type: string
  ElectricityVirtualFlows:
    properties:
      battery_charge:
        $ref: "#/definitions/ElectricityFlowFormula"
      battery_discharge:
        $ref: "#/definitions/ElectricityFlowFormula"
      battery_grid:
        $ref: "#/definitions/ElectricityFlowFormula"
      elec_drawn:
        $ref: "#/definitions/ElectricityFlowFormula"
      elec_feed_in:
        $ref: "#/definitions/ElectricityFlowFormula"
      elec_from_household:
        $ref: "#/definitions/ElectricityFlowFormula"
      elec_local:
        $ref: "#/definitions/ElectricityFlowFormula"
      elec_to_pv:
        $ref: "#/definitions/ElectricityFlowFormula"
      elec_total_gen:
        $ref: "#/definitions/ElectricityFlowFormula"
      elec_total_usage:
        $ref: "#/definitions/ElectricityFlowFormula"
      elec_usage:
        $ref: "#/definitions/ElectricityFlowFormula"
    type: object
  ErrorEntity:
    description: An error related to access to an entity (400, 403, 404, 410)
    properties:
      code:
        type: integer
      message:
        type: string
      resource:
        $ref: "#/definitions/ResourceRef"
    required:
      - code
      - message
      - resource
    type: object
  ErrorGatewayUnreachable:
    description: The gateway of the Place is not reachable.
    properties:
      code:
        enum:
          - "450"
        type: string
      message:
        type: string
    required:
      - code
      - message
    type: object
  ErrorSubEntity:
    description: An error related to access to an sub-entity (400, 403, 404, 410)
    properties:
      code:
        type: integer
      message:
        type: string
      resource:
        properties:
          entity:
            enum:
              - Action
              - Attribute
              - Bus
            type: string
          href:
            minLength: 1
            type: string
          id:
            minLength: 1
            type: string
          parent:
            description: Container resource.
            properties:
              entity:
                enum:
                  - Place
                  - Functionality
                type: string
              id:
                minLength: 1
                type: string
            required:
              - entity
              - id
            type: object
        required:
          - id
          - entity
          - href
        type: object
    required:
      - code
      - message
      - resource
    type: object
  Functionality:
    properties:
      actions:
        items:
          $ref: "#/definitions/ActionName"
        readOnly: true
        type: array
        uniqueItems: true
      attributes:
        items:
          $ref: "#/definitions/AttributeName"
        readOnly: true
        type: array
        uniqueItems: true
      class:
        $ref: "#/definitions/FunctionalityClass"
      device:
        $ref: "#/definitions/DeviceId"
      endpoint:
        $ref: "#/definitions/FunctionalityEndpoint"
      metadata:
        $ref: "#/definitions/Metadata"
      name:
        $ref: "#/definitions/FunctionalityName"
      tags:
        items:
          $ref: "#/definitions/FunctionalityTag"
        type: array
        uniqueItems: true
    required:
      - class
      - endpoint
      - device
      - attributes
      - tags
    type: object
    x-links:
      - href: /devices/{id}
        rel: device
  FunctionalityClass:
    minLength: 2
    pattern: ^[A-Z][A-Za-z0-9]+$
    readOnly: true
    type: string
  FunctionalityCreated:
    description: A resource has been created. The `resource` property gives its reference.
    example:
      code: 201
      message: Functionality created
      resource:
        entity: Functionality
        href: /functionalities/RnVuY3Rpb25hbGl0eTAwMA
        id: RnVuY3Rpb25hbGl0eTAwMA
    properties:
      code:
        enum:
          - 201
        example: 201
        type: integer
      message:
        enum:
          - Functionality created
        type: string
      resource:
        $ref: "#/definitions/FunctionalityResource"
    required:
      - code
      - message
      - resource
    type: object
  FunctionalityEndpoint:
    maximum: 255
    minimum: 0
    readOnly: true
    type: integer
  FunctionalityId:
    description: Unique identifier of the *Functionality*
    example: RnVuY3Rpb25hbGl0eTAwMA
    maxLength: 22
    minLength: 22
    pattern: ^[A-Za-z0-9-_]{22}$
    readOnly: true
    type: string
  FunctionalityItem:
    properties:
      class:
        $ref: "#/definitions/FunctionalityClass"
      device:
        $ref: "#/definitions/DeviceId"
      endpoint:
        $ref: "#/definitions/FunctionalityEndpoint"
      id:
        $ref: "#/definitions/FunctionalityId"
      metadata:
        $ref: "#/definitions/MetadataSelected"
      name:
        $ref: "#/definitions/FunctionalityName"
      tags:
        items:
          $ref: "#/definitions/FunctionalityTag"
        type: array
        uniqueItems: true
    readOnly: true
    required:
      - id
      - device
      - class
      - endpoint
    type: object
    x-links:
      - href: /functionalities/{id}
        rel: full
      - href: /devices/{device}
        rel: device
  FunctionalityName:
    description: Free functionality name
    type: string
  FunctionalityNew:
    properties:
      class:
        $ref: "#/definitions/FunctionalityClass"
      endpoint:
        $ref: "#/definitions/FunctionalityEndpoint"
      metadata:
        $ref: "#/definitions/Metadata"
      name:
        $ref: "#/definitions/FunctionalityName"
      tags:
        items:
          $ref: "#/definitions/FunctionalityTag"
        type: array
        uniqueItems: true
    required:
      - class
      - endpoint
    type: object
  FunctionalityPatch:
    properties:
      name:
        $ref: "#/definitions/FunctionalityName"
    type: object
  FunctionalityResource:
    example:
      entity: Functionality
      href: /functionalities/RnVuY3Rpb25hbGl0eTAwMA
      id: RnVuY3Rpb25hbGl0eTAwMA
    properties:
      entity:
        enum:
          - Functionality
        type: string
      href:
        minLength: 1
        type: string
      id:
        $ref: "#/definitions/FunctionalityId"
    required:
      - id
      - entity
      - href
    type: object
  FunctionalityTag:
    maxLength: 21
    minLength: 1
    pattern: ^[a-z](?:[a-z0-9_]{0,20}|[a-z0-9_]:[a-z0-9_]{1,18}|[a-z0-9_]{2}:[a-z0-9_]{1,17}|[a-z0-9_]{3}:[a-z0-9_]{1,16}|[a-z0-9_]{4}:[a-z0-9_]{1,15})$
    type: string
  Locale:
    description: |
      Locale identifier (language, region). See https://tools.ietf.org/html/rfc5646 and https://www.iana.org/assignments/lang-subtags-templates/lang-subtags-templates.xhtml .
    example: fr-FR
    minLength: 2
    pattern: ^[a-z]{2}[A-Za-z0-9-]*$
    type: string
  Metadata:
    additionalProperties:
      $ref: "#/definitions/AnyJSON"
    description: Keys are limited to the same format as tags (up to 21 characters, [a-z0-9], starting with [a-z]). Values can be any JSON value.
    type: object
  MetadataKey:
    maxLength: 21
    minLength: 1
    pattern: ^[a-z](?:[a-z0-9_]{0,20}|[a-z0-9_]:[a-z0-9_]{1,18}|[a-z0-9_]{2}:[a-z0-9_]{1,17}|[a-z0-9_]{3}:[a-z0-9_]{1,16}|[a-z0-9_]{4}:[a-z0-9_]{1,15})$
    type: string
  MetadataPatch:
    properties:
      add:
        additionalProperties:
          $ref: "#/definitions/AnyJSON"
        description: list of pairs key/value to add/replace
        type: object
      remove:
        description: list of keys to remove
        items:
          $ref: "#/definitions/MetadataKey"
        type: array
        uniqueItems: true
    type: object
  MetadataSelected:
    additionalProperties:
      $ref: "#/definitions/AnyJSON"
    description: Subset of metadata attached to the resource selected using the 'embed-metadata' parameter
    type: object
  Notification:
    properties:
      data:
        type: object
      metadata:
        $ref: "#/definitions/Metadata"
      name:
        minLength: 1
        type: string
      place:
        $ref: "#/definitions/PlaceId"
      routing:
        format: uri
        type: string
    required:
      - name
      - place
    type: object
    x-links:
      - href: /places/{place}
        rel: place
  NotificationCreated:
    description: A resource has been created. The `resource` property gives its reference.
    example:
      code: 201
      message: Notification created
      resource:
        entity: Notification
        href: /notifications/InovwcCIGM5X7KvKrJ7vJw
        id: InovwcCIGM5X7KvKrJ7vJw
    properties:
      code:
        enum:
          - 201
        example: 201
        type: integer
      message:
        enum:
          - Notification created
        type: string
      resource:
        $ref: "#/definitions/NotificationResource"
    required:
      - code
      - message
      - resource
    type: object
  NotificationId:
    description: Unique identifier of the *Notification*
    example: InovwcCIGM5X7KvKrJ7vJw
    maxLength: 22
    minLength: 22
    pattern: ^[A-Za-z0-9-_]{22}$
    readOnly: true
    type: string
  NotificationItem:
    description: Notification
    properties:
      id:
        $ref: "#/definitions/NotificationId"
      metadata:
        $ref: "#/definitions/MetadataSelected"
      name:
        type: string
    readOnly: true
    required:
      - id
      - name
    type: object
    x-links:
      - href: /notifications/{id}
        rel: full
  NotificationNew:
    properties:
      data:
        type: object
      metadata:
        $ref: "#/definitions/Metadata"
      name:
        minLength: 1
        type: string
      routing:
        format: uri
        type: string
    required:
      - name
    type: object
  NotificationPatch:
    properties:
      data:
        type: object
      name:
        minLength: 1
        type: string
      routing:
        format: uri
        type: string
    type: object
  NotificationResource:
    example:
      entity: Notification
      href: /notifications/InovwcCIGM5X7KvKrJ7vJw
      id: InovwcCIGM5X7KvKrJ7vJw
    properties:
      entity:
        enum:
          - Notification
        type: string
      href:
        minLength: 1
        type: string
      id:
        $ref: "#/definitions/NotificationId"
    required:
      - id
      - entity
      - href
    type: object
  Password:
    format: password
    minLength: 5
    type: string
  PhoneNumber:
    description: Phone number of the *User* in international format, for SMS notifications.
    example: "+33177494646"
    minLength: 6
    pattern: ^\+[0-9]{5,}$
    type: string
  Place:
    properties:
      account:
        $ref: "#/definitions/AccountId"
      country:
        $ref: "#/definitions/CountryCode"
      metadata:
        $ref: "#/definitions/Metadata"
      name:
        example: ⌂ Home
        minLength: 1
        type: string
      timeZone:
        $ref: "#/definitions/TimeZone"
      zipCode:
        $ref: "#/definitions/ZipCode"
    required:
      - name
      - zipCode
      - country
      - timeZone
    type: object
  PlaceCreated:
    description: A resource has been created. The `resource` property gives its reference.
    example:
      code: 201
      message: Place created
      resource:
        entity: Place
        href: /places/3HA6YcSCTSFX6SPPrI9PxQ
        id: 3HA6YcSCTSFX6SPPrI9PxQ
    properties:
      code:
        enum:
          - 201
        example: 201
        type: integer
      message:
        enum:
          - Place created
        type: string
      resource:
        $ref: "#/definitions/PlaceResource"
    required:
      - code
      - message
      - resource
    type: object
  PlaceId:
    description: Unique identifier of the *Place*
    example: 3HA6YcSCTSFX6SPPrI9PxQ
    maxLength: 22
    minLength: 22
    pattern: ^[A-Za-z0-9-_]{22}$
    readOnly: true
    type: string
  PlaceItem:
    properties:
      id:
        $ref: "#/definitions/PlaceId"
      name:
        type: string
    readOnly: true
    required:
      - id
      - name
    type: object
    x-links:
      - href: /places/{id}
        rel: full
  PlaceNew:
    properties:
      country:
        $ref: "#/definitions/CountryCode"
      metadata:
        $ref: "#/definitions/Metadata"
      name:
        example: ⌂ Home
        minLength: 1
        type: string
      timeZone:
        $ref: "#/definitions/TimeZone"
      zipCode:
        $ref: "#/definitions/ZipCode"
    required:
      - name
      - zipCode
      - country
      - timeZone
    type: object
  PlacePatch:
    properties:
      country:
        $ref: "#/definitions/CountryCode"
      name:
        example: ⌂ Home
        minLength: 1
        type: string
      timeZone:
        $ref: "#/definitions/TimeZone"
      zipCode:
        $ref: "#/definitions/ZipCode"
    type: object
  PlaceResource:
    example:
      entity: Place
      href: /places/3HA6YcSCTSFX6SPPrI9PxQ
      id: 3HA6YcSCTSFX6SPPrI9PxQ
    properties:
      entity:
        enum:
          - Place
        type: string
      href:
        minLength: 1
        type: string
      id:
        $ref: "#/definitions/PlaceId"
    required:
      - id
      - entity
      - href
    type: object
  Program:
    properties:
      code:
        $ref: "#/definitions/AnyJSON"
      enabled:
        type: boolean
      metadata:
        $ref: "#/definitions/Metadata"
      name:
        minLength: 1
        type: string
      place:
        $ref: "#/definitions/PlaceId"
    required:
      - name
      - enabled
      - code
    type: object
    x-links:
      - href: /places/{place}
        rel: place
  ProgramCreated:
    description: A resource has been created. The `resource` property gives its reference.
    example:
      code: 201
      message: Program created
      resource:
        entity: Program
        href: /programs/3_J_6ZWICc5X_KverorNvw
        id: 3_J_6ZWICc5X_KverorNvw
    properties:
      code:
        enum:
          - 201
        example: 201
        type: integer
      message:
        enum:
          - Program created
        type: string
      resource:
        $ref: "#/definitions/ProgramResource"
    required:
      - code
      - message
      - resource
    type: object
  ProgramId:
    description: Unique identifier of the *Program*
    example: 3_J_6ZWICc5X_KverorNvw
    maxLength: 22
    minLength: 22
    pattern: ^[A-Za-z0-9-_]{22}$
    readOnly: true
    type: string
  ProgramItem:
    properties:
      enabled:
        type: boolean
      id:
        $ref: "#/definitions/ProgramId"
      metadata:
        $ref: "#/definitions/MetadataSelected"
      name:
        type: string
    readOnly: true
    required:
      - id
      - name
      - enabled
    type: object
    x-links:
      - href: /programs/{id}
        rel: full
  ProgramLog:
    properties:
      actions:
        items:
          $ref: "#/definitions/ActionResult"
        type: array
      errors:
        items:
          type: string
        type: array
      notifications:
        items:
          $ref: "#/definitions/NotificationId"
        type: array
        uniqueItems: true
      when:
        format: date-time
        type: string
    required:
      - when
    type: object
  ProgramNew:
    example:
      code: []
      enabled: false
      name: NOOP
    properties:
      code:
        $ref: "#/definitions/AnyJSON"
      enabled:
        default: true
        type: boolean
      metadata:
        $ref: "#/definitions/Metadata"
      name:
        minLength: 1
        type: string
    required:
      - name
      - code
    type: object
  ProgramPatch:
    properties:
      code:
        $ref: "#/definitions/AnyJSON"
      enabled:
        type: boolean
      name:
        minLength: 1
        type: string
    type: object
  ProgramResource:
    example:
      entity: Program
      href: /programs/3_J_6ZWICc5X_KverorNvw
      id: 3_J_6ZWICc5X_KverorNvw
    properties:
      entity:
        enum:
          - Program
        type: string
      href:
        minLength: 1
        type: string
      id:
        $ref: "#/definitions/ProgramId"
    required:
      - id
      - entity
      - href
    type: object
  ResourceRef:
    properties:
      entity:
        enum:
          - Device
          - Functionality
          - Notification
          - Place
          - Program
          - User
          - Account
          - AccountsBase
        type: string
      href:
        minLength: 1
        type: string
      id:
        minLength: 1
        type: string
    required:
      - id
      - entity
      - href
    type: object
  Tag:
    maxLength: 21
    minLength: 1
    pattern: ^[a-z](?:[a-z0-9_]{0,20}|[a-z0-9_]:[a-z0-9_]{1,18}|[a-z0-9_]{2}:[a-z0-9_]{1,17}|[a-z0-9_]{3}:[a-z0-9_]{1,16}|[a-z0-9_]{4}:[a-z0-9_]{1,15})$
    type: string
  Tags:
    items:
      $ref: "#/definitions/Tag"
    type: array
    uniqueItems: true
  TagsPatch:
    properties:
      add:
        description: list of tags to add
        items:
          $ref: "#/definitions/Tag"
        type: array
        uniqueItems: true
      remove:
        description: list of tags to remove
        items:
          $ref: "#/definitions/Tag"
        type: array
        uniqueItems: true
    type: object
  TimeZone:
    description: A time zone name from the Time Zone Database at https://www.iana.org/time-zones
    example: Europe/Paris
    minLength: 2
    pattern: ^[A-Z][A-Za-z0-9-_+]+(?:/[A-Z][A-Za-z0-9-_+]+)*$
    type: string
  TokenId:
    example: dfSDdRcsd
    minLength: 1
    type: string
  User:
    properties:
      account:
        $ref: "#/definitions/AccountId"
      canLogin:
        default: false
        description: true if the user owning the account (can get tokens with /auth/login)
        example: false
        readOnly: true
        type: boolean
      email:
        $ref: "#/definitions/UserEmail"
      locale:
        $ref: "#/definitions/Locale"
      metadata:
        $ref: "#/definitions/Metadata"
      name:
        minLength: 1
        type: string
      phoneNumber:
        $ref: "#/definitions/PhoneNumber"
    required:
      - email
      - name
      - locale
      - canLogin
    type: object
  UserCreated:
    description: A resource has been created. The `resource` property gives its reference.
    example:
      code: 201
      message: User created
      resource:
        entity: User
        href: /users/RGV2aWNlMDAwMDAwMDAwMZ
        id: RGV2aWNlMDAwMDAwMDAwMZ
    properties:
      code:
        enum:
          - 201
        example: 201
        type: integer
      message:
        enum:
          - User created
        type: string
      resource:
        $ref: "#/definitions/UserResource"
    required:
      - code
      - message
      - resource
    type: object
  UserEmail:
    format: email
    minLength: 6
    type: string
  UserId:
    description: Unique identifier of the *User*
    example: RGV2aWNlMDAwMDAwMDAwMZ
    maxLength: 22
    minLength: 22
    pattern: ^[A-Za-z0-9-_]{22}$
    readOnly: true
    type: string
  UserItem:
    properties:
      canLogin:
        default: false
        description: true if the user owning the account (can get tokens with /auth/login)
        example: false
        readOnly: true
        type: boolean
      email:
        $ref: "#/definitions/UserEmail"
      id:
        $ref: "#/definitions/UserId"
      locale:
        $ref: "#/definitions/Locale"
      metadata:
        $ref: "#/definitions/MetadataSelected"
      name:
        minLength: 1
        type: string
      phoneNumber:
        $ref: "#/definitions/PhoneNumber"
    required:
      - email
      - name
      - locale
      - id
    type: object
    x-links:
      - href: /users/{id}
        rel: full
  UserMe:
    properties:
      email:
        $ref: "#/definitions/UserEmail"
      id:
        $ref: "#/definitions/UserId"
      locale:
        $ref: "#/definitions/Locale"
      login:
        $ref: "#/definitions/AccountLogin"
      metadata:
        $ref: "#/definitions/Metadata"
      name:
        minLength: 1
        type: string
      phoneNumber:
        $ref: "#/definitions/PhoneNumber"
    required:
      - email
      - name
      - locale
      - id
    type: object
    x-links:
      - href: /account/users/{id}
        rel: full
  UserMePatch:
    properties:
      locale:
        $ref: "#/definitions/Locale"
    type: object
  UserNew:
    properties:
      email:
        $ref: "#/definitions/UserEmail"
      locale:
        $ref: "#/definitions/Locale"
      metadata:
        $ref: "#/definitions/Metadata"
      name:
        minLength: 1
        type: string
      phoneNumber:
        $ref: "#/definitions/PhoneNumber"
    required:
      - email
      - name
      - locale
    type: object
  UserPatch:
    properties:
      email:
        $ref: "#/definitions/UserEmail"
      locale:
        $ref: "#/definitions/Locale"
      name:
        minLength: 1
        type: string
      phoneNumber:
        $ref: "#/definitions/PhoneNumber"
    type: object
  UserResource:
    example:
      entity: User
      href: /users/RGV2aWNlMDAwMDAwMDAwMZ
      id: RGV2aWNlMDAwMDAwMDAwMZ
    properties:
      entity:
        enum:
          - User
        type: string
      href:
        minLength: 1
        type: string
      id:
        $ref: "#/definitions/UserId"
    required:
      - id
      - entity
      - href
    type: object
  UserTokenItem:
    description: Token for User API access
    properties:
      appName:
        description: Application name
        example: Home Eopath
        type: string
      id:
        $ref: "#/definitions/TokenId"
      lastUse:
        description: Time of last use of the token to access the API. Updated at most every 15 minutes. If absent, the token has never been used.
        format: date-time
        type: string
      places:
        description: List of Places to which the User has access. If absent, it means any Place of the account are allowed.
        items:
          $ref: "#/definitions/PlaceItem"
        type: array
        uniqueItems: true
      refreshTokenExpires:
        description: If absent, infinite validity.
        format: date-time
        type: string
      self:
        description: True if this token is the one used for this API request
        type: boolean
      user:
        $ref: "#/definitions/UserItem"
    required:
      - id
      - appName
      - user
    type: object
  ZipCode:
    description: Postal code
    maxLength: 10
    minLength: 0
    pattern: ^(?:[A-Z0-9](?:[A-Z0-9][- ]?)*[A-Z0-9])?$
    type: string
