apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
  annotations:
    devices.edge.cattle.io/description: Modbus is a communication protocol developed
      by Modicon system. In short, it is a method for transmitting information between
      electronic devices through a serial line. The Modbus protocol is a master-slave
      architecture protocol. The Modbus adapter can be called a Modbus master station
      and is responsible for connecting and collecting information from Modbus slave
      stations (i.e, devices).
    devices.edge.cattle.io/device-property: '{"name":"string","type":"string","value":"string","updatedAt":"date"}'
    devices.edge.cattle.io/enable: "true"
    devices.edge.cattle.io/icon: https://octopus-assets.oss-cn-beijing.aliyuncs.com/adaptor-icons/modbus.svg
  labels:
    app.kubernetes.io/name: octopus-adaptor-modbus
    app.kubernetes.io/version: master
  name: modbusdevices.devices.edge.cattle.io
spec:
  group: devices.edge.cattle.io
  names:
    kind: ModbusDevice
    listKind: ModbusDeviceList
    plural: modbusdevices
    shortNames:
    - modbus
    singular: modbusdevice
  scope: Namespaced
  versions:
  - additionalPrinterColumns:
    - jsonPath: .spec.protocol..endpoint
      name: ENDPOINT
      type: string
    - jsonPath: .spec.protocol..workerID
      name: WORKER ID
      type: string
    - jsonPath: .metadata.creationTimestamp
      name: AGE
      type: date
    name: v1alpha1
    schema:
      openAPIV3Schema:
        description: ModbusDevice is the schema for the Modbus device API.
        properties:
          apiVersion:
            description: 'APIVersion defines the versioned schema of this representation
              of an object. Servers should convert recognized schemas to the latest
              internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
            type: string
          kind:
            description: 'Kind is a string value representing the REST resource this
              object represents. Servers may infer this from the endpoint the client
              submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
            type: string
          metadata:
            type: object
          spec:
            description: ModbusDeviceSpec defines the desired state of ModbusDevice.
            properties:
              extension:
                description: Specifies the extension of device.
                properties:
                  mqtt:
                    description: Specifies the MQTT settings.
                    properties:
                      client:
                        description: Specifies the client settings.
                        properties:
                          autoReconnect:
                            default: true
                            description: Configures using the automatic reconnection
                              logic. The default value is "true".
                            type: boolean
                          basicAuth:
                            description: Specifies the username and password that
                              the client connects to the MQTT broker. Without the
                              use of TLSConfig, the account information will be sent
                              in plaintext across the wire.
                            properties:
                              password:
                                description: Specifies the password for basic authenication.
                                type: string
                              passwordRef:
                                description: Specifies the relationship of DeviceLink's
                                  references to refer to the value as the password.
                                properties:
                                  item:
                                    description: Specifies the item name of the referred
                                      reference.
                                    type: string
                                  name:
                                    description: Specifies the name of reference.
                                    type: string
                                required:
                                - item
                                - name
                                type: object
                              username:
                                description: Specifies the username for basic authentication.
                                type: string
                              usernameRef:
                                description: Specifies the relationship of DeviceLink's
                                  references to refer to the value as the username.
                                properties:
                                  item:
                                    description: Specifies the item name of the referred
                                      reference.
                                    type: string
                                  name:
                                    description: Specifies the name of reference.
                                    type: string
                                required:
                                - item
                                - name
                                type: object
                            type: object
                          cleanSession:
                            default: true
                            description: Specifies setting the "clean session" flag
                              in the connect message that the MQTT broker should not
                              save it. If the value is "false", the broker stores
                              all missed messages for the client that subscribed with
                              QoS 1 or 2. Any messages that were going to be sent
                              by this client before disconnecting previously but didn't
                              send upon connecting to the broker. The default value
                              is "true".
                            type: boolean
                          connectTimeout:
                            default: 30s
                            description: Specifies the amount of time that the client
                              try to open a connection to an MQTT broker before timing
                              out and getting error. A duration of 0 never times out.
                              The default value is "30s".
                            type: string
                          disconnectQuiesce:
                            description: Specifies the quiesce when the client disconnects.
                              The default value is "5s".
                            type: string
                          httpHeaders:
                            additionalProperties:
                              items:
                                type: string
                              type: array
                            description: Specifies the additional HTTP headers that
                              the client sends in the WebSocket opening handshake.
                            type: object
                            x-kubernetes-map-type: atomic
                          keepAlive:
                            default: 30s
                            description: Specifies the amount of time that the client
                              should wait before sending a PING request to the broker.
                              This will allow the client to know that the connection
                              has not been lost with the server. A duration of 0 never
                              keeps alive. The default keep alive is "30s".
                            type: string
                          maxReconnectInterval:
                            default: 10m
                            description: Specifies the amount of time that the client
                              should wait before reconnecting to the broker. The first
                              reconnect interval is 1 second, and then the interval
                              is incremented by *2 until `MaxReconnectInterval` is
                              reached. This is only valid if `AutoReconnect` is true.
                              A duration of 0 may trigger the reconnection immediately.
                              The default value is "10m".
                            type: string
                          messageChannelDepth:
                            default: 100
                            description: Specifies the size of the internal queue
                              that holds messages while the client is temporarily
                              offline, allowing the application to publish when the
                              client is reconnected. This is only valid if `AutoReconnect`
                              is true. The default value is "100".
                            type: integer
                          order:
                            default: true
                            description: Specifies the message routing to guarantee
                              order within each QoS level. If set to false, the message
                              can be delivered asynchronously from the client to the
                              application and possibly arrive out of order. The default
                              value is "true".
                            type: boolean
                          pingTimeout:
                            default: 10s
                            description: Specifies the amount of time that the client
                              should wait after sending a PING request to the broker.
                              This will allow the client to know that the connection
                              has been lost with the server. A duration of 0 may cause
                              unnecessary timeout error. The default value is "10s".
                            type: string
                          protocolVersion:
                            default: 0
                            description: Specifies the MQTT protocol version that
                              the cluster uses to connect to broker. Legitimate values
                              are currently 3 - MQTT v3.1 or 4 - MQTT v3.1.1. The
                              default value is 0, which means MQTT v3.1.1 identification
                              is preferred.
                            enum:
                            - 0
                            - 3
                            - 4
                            type: integer
                          resumeSubs:
                            default: false
                            description: Specifies to enable resuming of stored (un)subscribe
                              messages when connecting but not reconnecting. This
                              is only valid if `CleanSession` is false. The default
                              value is "false".
                            type: boolean
                          server:
                            description: Specifies the server URI of MQTT broker,
                              the format should be `schema://host:port`. The "schema"
                              is one of the "ws", "wss", "tcp", "unix", "ssl", "tls"
                              or "tcps".
                            pattern: ^(ws|wss|tcp|unix|ssl|tls|tcps)+://[^\s]*$
                            type: string
                          store:
                            description: Specifies to provide message persistence
                              in cases where QoS level is 1 or 2.
                            properties:
                              directoryPrefix:
                                description: Specifies the directory prefix of the
                                  storage, if using file store. The default value
                                  is "/var/run/octopus/mqtt".
                                pattern: ^/.*[^/]$
                                type: string
                              type:
                                default: Memory
                                description: Specifies the type of storage. The default
                                  value is "Memory".
                                enum:
                                - Memory
                                - File
                                type: string
                            type: object
                          tlsConfig:
                            description: Specifies the TLS configuration that the
                              client connects to the MQTT broker.
                            properties:
                              caFilePEM:
                                description: Specifies the PEM format content of the
                                  CA certificate, which is used for validate the server
                                  certificate with.
                                type: string
                              caFilePEMRef:
                                description: Specifies the relationship of DeviceLink's
                                  references to refer to the value as the CA file
                                  PEM content.
                                properties:
                                  item:
                                    description: Specifies the item name of the referred
                                      reference.
                                    type: string
                                  name:
                                    description: Specifies the name of reference.
                                    type: string
                                required:
                                - item
                                - name
                                type: object
                              certFilePEM:
                                description: Specifies the PEM format content of the
                                  certificate(public key), which is used for client
                                  authenticate to the server.
                                type: string
                              certFilePEMRef:
                                description: Specifies the relationship of DeviceLink's
                                  references to refer to the value as the client certificate
                                  file PEM content.
                                properties:
                                  item:
                                    description: Specifies the item name of the referred
                                      reference.
                                    type: string
                                  name:
                                    description: Specifies the name of reference.
                                    type: string
                                required:
                                - item
                                - name
                                type: object
                              insecureSkipVerify:
                                description: Doesn't validate the server certificate.
                                type: boolean
                              keyFilePEM:
                                description: Specifies the PEM format content of the
                                  key(private key), which is used for client authenticate
                                  to the server.
                                type: string
                              keyFilePEMRef:
                                description: Specifies the relationship of DeviceLink's
                                  references to refer to the value as the client key
                                  file PEM content.
                                properties:
                                  item:
                                    description: Specifies the item name of the referred
                                      reference.
                                    type: string
                                  name:
                                    description: Specifies the name of reference.
                                    type: string
                                required:
                                - item
                                - name
                                type: object
                              serverName:
                                description: Indicates the name of the server, ref
                                  to http://tools.ietf.org/html/rfc4366#section-3.1.
                                type: string
                            type: object
                          waitTimeout:
                            description: Specifies the amount of time that the client
                              should timeout after subscribed/published a message.
                              A duration of 0 never times out.
                            type: string
                          writeTimeout:
                            default: 30s
                            description: Specifies the amount of time that the client
                              publish a message successfully before getting a timeout
                              error. A duration of 0 never times out. The default
                              value is "30s".
                            type: string
                        required:
                        - server
                        type: object
                      message:
                        description: Specifies the message settings.
                        properties:
                          operator:
                            description: Specifies the operator for rendering the
                              `:operator` keyword of topic.
                            properties:
                              read:
                                description: Specifies the operator for rendering
                                  the `:operator` keyword of topic during subscribing.
                                type: string
                              write:
                                description: Specifies the operator for rendering
                                  the `:operator` keyword of topic during publishing.
                                type: string
                            type: object
                          path:
                            description: Specifies the path for rendering the `:path`
                              keyword of topic.
                            type: string
                          qos:
                            default: 1
                            description: Specifies the QoS of the message. The default
                              value is "1".
                            enum:
                            - 0
                            - 1
                            - 2
                            type: integer
                          retained:
                            default: true
                            description: Specifies if the last published message to
                              be retained. The default value is "true".
                            type: boolean
                          topic:
                            description: Specifies the topic.
                            pattern: .*[^/]$
                            type: string
                          will:
                            description: Specifies the will message.
                            properties:
                              content:
                                description: Specifies the content of will message.
                                  The serialized form of the content is a base64 encoded
                                  string, representing the arbitrary (possibly non-string)
                                  content value here.
                                type: string
                              topic:
                                description: Specifies the topic of will message.
                                  if not set, the topic will append "$will" to the
                                  topic name specified in parent field as its topic
                                  name.
                                pattern: .*[^/]$
                                type: string
                            required:
                            - content
                            type: object
                        required:
                        - topic
                        type: object
                    required:
                    - client
                    - message
                    type: object
                type: object
              parameters:
                description: Specifies the parameters of device.
                properties:
                  syncInterval:
                    default: 15s
                    description: Specifies the amount of interval that synchronized
                      to limb. The default value is "15s".
                    type: string
                  timeout:
                    default: 10s
                    description: Specifies the amount of timeout. The default value
                      is "10s".
                    type: string
                type: object
              properties:
                description: Specifies the properties of device.
                items:
                  description: ModbusDeviceProperty defines the desired property of
                    ModbusDevice.
                  properties:
                    description:
                      description: Specifies the description of property.
                      type: string
                    name:
                      description: Specifies the name of property.
                      type: string
                    readOnly:
                      description: Specifies if the property is readonly. The default
                        value is "false".
                      type: boolean
                    type:
                      description: Specifies the type of property.
                      enum:
                      - int
                      - float
                      - string
                      - boolean
                      type: string
                    value:
                      description: Specifies the value of property, only available
                        in the writable property.
                      type: string
                    visitor:
                      description: Specifies the visitor of property.
                      properties:
                        offset:
                          description: Specifies the starting offset of register for
                            read/write data.
                          type: integer
                        orderOfOperations:
                          description: Specifies the operations in order if needed.
                          items:
                            description: ModbusDeviceArithmeticOperation defines the
                              arithmetic operation of ModbusDevice.
                            properties:
                              type:
                                description: Specifies the type of arithmetic operation.
                                enum:
                                - Add
                                - Subtract
                                - Multiply
                                - Divide
                                type: string
                              value:
                                description: Specifies the value for arithmetic operation,
                                  which is in form of float string.
                                type: string
                            required:
                            - type
                            - value
                            type: object
                          type: array
                          x-kubernetes-list-type: atomic
                        quantity:
                          description: Specifies the quantity of register.
                          type: integer
                        register:
                          description: Specifies the register to visit.
                          enum:
                          - CoilRegister
                          - DiscreteInputRegister
                          - InputRegister
                          - HoldingRegister
                          type: string
                      required:
                      - offset
                      - quantity
                      - register
                      type: object
                  required:
                  - name
                  - type
                  - visitor
                  type: object
                type: array
                x-kubernetes-list-map-keys:
                - name
                x-kubernetes-list-type: map
              protocol:
                description: Specifies the protocol for accessing the device.
                properties:
                  rtu:
                    description: Specifies the connection protocol as RTU
                    properties:
                      baudRate:
                        default: 19200
                        description: Specifies the baud rate of connection, a measurement
                          of transmission speed. The default value is "19200".
                        type: integer
                      dataBits:
                        default: 8
                        description: Specifies the data bit of connection, selected
                          from [5, 6, 7, 8]. The default value is "8".
                        enum:
                        - 5
                        - 6
                        - 7
                        - 8
                        type: integer
                      endpoint:
                        description: Specifies the serial port of device, which is
                          in form of "/dev/ttyS0".
                        pattern: ^/.*[^/]$
                        type: string
                      parity:
                        default: E
                        description: Specifies the parity of connection, selected
                          from [N - None, E - Even, O - Odd], the use of N(None) parity
                          requires 2 stop bits. The default value is "E".
                        enum:
                        - "N"
                        - E
                        - O
                        type: string
                      stopBits:
                        default: 1
                        description: Specifies the stop bit of connection, selected
                          from [1, 2], the use of N(None) parity requires 2 stop bits.
                          The default value is "1".
                        enum:
                        - 1
                        - 2
                        type: integer
                      workerID:
                        description: Specifies the worker ID of device.
                        type: integer
                    required:
                    - endpoint
                    - workerID
                    type: object
                  tcp:
                    description: Specifies the connection protocol as TCP
                    properties:
                      endpoint:
                        description: Specifies the IP address of device, which is
                          in form of "ip:port".
                        type: string
                      workerID:
                        description: Specifies the worker ID of device.
                        type: integer
                    required:
                    - endpoint
                    - workerID
                    type: object
                type: object
            required:
            - protocol
            type: object
          status:
            description: ModbusDeviceStatus defines the observed state of ModbusDevice.
            properties:
              properties:
                description: Reports the properties of device.
                items:
                  description: ModbusDeviceStatusProperty defines the observed property
                    of ModbusDevice.
                  properties:
                    name:
                      description: Reports the name of property.
                      type: string
                    type:
                      description: Reports the type of property.
                      enum:
                      - int
                      - float
                      - string
                      - boolean
                      type: string
                    updatedAt:
                      description: Reports the updated timestamp of property.
                      format: date-time
                      type: string
                    value:
                      description: Reports the value of property.
                      type: string
                  type: object
                type: array
            type: object
        type: object
    served: true
    storage: true
    subresources:
      status: {}
