apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
  annotations:
    devices.edge.cattle.io/description: MQTT is a machine-to-machine (M2M)/"Internet
      of Things" connectivity protocol, which was designed as an extremely lightweight
      publish/subscribe messaging transport. The MQTT adaptor can assess and manage
      the data stored in MQTT broker.
    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: http://mqtt.org/new/wp-content/uploads/2011/08/mqttorg-glow.png
  labels:
    app.kubernetes.io/name: octopus-adaptor-mqtt
    app.kubernetes.io/version: master
  name: mqttdevices.devices.edge.cattle.io
spec:
  group: devices.edge.cattle.io
  names:
    kind: MQTTDevice
    listKind: MQTTDeviceList
    plural: mqttdevices
    shortNames:
    - mqtt
    singular: mqttdevice
  scope: Namespaced
  versions:
  - additionalPrinterColumns:
    - jsonPath: .spec.protocol.pattern
      name: PATTERN
      type: string
    - jsonPath: .spec.protocol.client.server
      name: SERVER
      type: string
    - jsonPath: .spec.protocol.message.topic
      name: TOPIC
      type: string
    - jsonPath: .metadata.creationTimestamp
      name: AGE
      type: date
    name: v1alpha1
    schema:
      openAPIV3Schema:
        description: MQTTDevice is the Schema for the MQTT 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: MQTTDeviceSpec defines the desired state of MQTTDevice.
            properties:
              properties:
                description: Specifies the properties of MQTTDevice.
                items:
                  description: MQTTDeviceProperty defines the specified property of
                    MQTTDevice.
                  properties:
                    annotations:
                      additionalProperties:
                        type: string
                      description: Specifies the annotations of property.
                      type: object
                    contentType:
                      description: Specifies the MIME of property value.
                      type: string
                    description:
                      description: Specifies the description of property.
                      type: string
                    name:
                      description: Specifies the name of property.
                      type: string
                    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
                    readOnly:
                      default: true
                      description: Specifies if the property is read-only. The default
                        value is "true".
                      type: boolean
                    retained:
                      default: true
                      description: Specifies if the last published message to be retained.
                        The default value is "true".
                      type: boolean
                    type:
                      description: Specifies the type of property.
                      enum:
                      - int
                      - string
                      - float
                      - boolean
                      - object
                      - array
                      type: string
                    value:
                      description: Specifies the value of property.
                      x-kubernetes-preserve-unknown-fields: true
                  required:
                  - name
                  type: object
                type: array
                x-kubernetes-list-map-keys:
                - name
                x-kubernetes-list-type: map
              protocol:
                description: Specifies the protocol for accessing the MQTT service.
                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
                  pattern:
                    description: Specifies the pattern of MQTTDevice protocol.
                    enum:
                    - AttributedMessage
                    - AttributedTopic
                    type: string
                  schema:
                    description: Specifies the schema of the pattern.
                    properties:
                      reference:
                        description: Specifies the reference for schema.
                        type: string
                      type:
                        description: Specifies the type of schema.
                        type: string
                    type: object
                required:
                - client
                - message
                - pattern
                type: object
            required:
            - protocol
            type: object
          status:
            description: MQTTDeviceStatus defines the observed state of MQTTDevice.
            properties:
              properties:
                description: Reports the properties of MQTTDevice.
                items:
                  description: MQTTDeviceStatusProperty defines the observed property
                    of MQTTDevice.
                  properties:
                    annotations:
                      additionalProperties:
                        type: string
                      description: Specifies the annotations of property.
                      type: object
                    contentType:
                      description: Specifies the MIME of property value.
                      type: string
                    description:
                      description: Specifies the description of property.
                      type: string
                    name:
                      description: Specifies the name of property.
                      type: string
                    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
                    readOnly:
                      default: true
                      description: Specifies if the property is read-only. The default
                        value is "true".
                      type: boolean
                    retained:
                      default: true
                      description: Specifies if the last published message to be retained.
                        The default value is "true".
                      type: boolean
                    type:
                      description: Specifies the type of property.
                      enum:
                      - int
                      - string
                      - float
                      - boolean
                      - object
                      - array
                      type: string
                    updateAt:
                      description: Reports the updated timestamp of property.
                      format: date-time
                      type: string
                    value:
                      description: Specifies the value of property.
                      x-kubernetes-preserve-unknown-fields: true
                  required:
                  - name
                  type: object
                type: array
            type: object
        type: object
    served: true
    storage: true
    subresources:
      status: {}
