Documentation ¶
Index ¶
- Constants
- Variables
- func CreateAzureHubConnection(settings *AzureSettings, connSettings *AzureConnectionSettings, ...) (*connector.MQTTConnection, error)
- func ParseSASTokenValidity(sasTokenValidity string) (time.Duration, error)
- type AzureConnectionSettings
- func CreateAzureSASTokenConnectionSettings(connStringProperties map[string]string, settings *AzureSettings, ...) (*AzureConnectionSettings, error)
- func PrepareAzureCertificateConnectionSettings(connStringProperties map[string]string, certFileReader io.Reader, ...) (*AzureConnectionSettings, error)
- func PrepareAzureConnectionSettings(settings *AzureSettings, idScopeProvider IDScopeProvider, log logger.Logger) (*AzureConnectionSettings, error)
- func PrepareAzureProvisioningConnectionSettings(settings *AzureSettings, idScopeProvider IDScopeProvider, ...) (*AzureConnectionSettings, error)
- type AzureDeviceData
- type AzureDpsDeviceInfoResponse
- type AzureDpsRegisterDeviceRequest
- type AzureDpsRegistrationState
- type AzureSettings
- type IDScopeProvider
- type ProvisioningHTTPClient
- type ProvisioningService
- type RemoteConnectionInfo
- type ResponseError
- type SharedAccessSignature
Constants ¶
const ( // SASTokenValidityFactor represents the default factor of the SAS token validity period. // The token will be refreshed after SASTokenValidityFactor * defaultSASTokenValidity seconds. SASTokenValidityFactor = 0.9 )
Variables ¶
var Now = time.Now
Now represents the current time.
Functions ¶
func CreateAzureHubConnection ¶
func CreateAzureHubConnection( settings *AzureSettings, connSettings *AzureConnectionSettings, logger watermill.LoggerAdapter, ) (*connector.MQTTConnection, error)
CreateAzureHubConnection creates the MQTT connection to the remote Azure Iot Hub MQTT broker.
Types ¶
type AzureConnectionSettings ¶
type AzureConnectionSettings struct { RemoteConnectionInfo DeviceCert string DeviceKey string TokenValidity time.Duration }
AzureConnectionSettings contains the configuration data for establishing connection to the Azure IoT Hub.
func CreateAzureSASTokenConnectionSettings ¶
func CreateAzureSASTokenConnectionSettings( connStringProperties map[string]string, settings *AzureSettings, logger logger.Logger, ) (*AzureConnectionSettings, error)
CreateAzureSASTokenConnectionSettings creates the configuration data for establishing connection to the Azure IoT Hub via SAS token.
func PrepareAzureCertificateConnectionSettings ¶
func PrepareAzureCertificateConnectionSettings( connStringProperties map[string]string, certFileReader io.Reader, keyFileReader io.Reader, ) (*AzureConnectionSettings, error)
PrepareAzureCertificateConnectionSettings prepares the configuration data for establishing connection to the Azure IoT Hub via X.509 certificate.
func PrepareAzureConnectionSettings ¶
func PrepareAzureConnectionSettings(settings *AzureSettings, idScopeProvider IDScopeProvider, log logger.Logger) (*AzureConnectionSettings, error)
PrepareAzureConnectionSettings prepares the configuration data for establishing connection to the Azure IoT Hub, allowing usage of IDScopeProvider.
func PrepareAzureProvisioningConnectionSettings ¶
func PrepareAzureProvisioningConnectionSettings( settings *AzureSettings, idScopeProvider IDScopeProvider, provisioningService ProvisioningService, provisioningFile io.ReadWriter, useProvisioningClient bool, certFileReader io.Reader, keyFileReader io.Reader, ) (*AzureConnectionSettings, error)
PrepareAzureProvisioningConnectionSettings prepares the configuration data for establishing connection to Azure IoT Hub that requires device provisioning, allowing usage of IDScopeProvider.
type AzureDeviceData ¶
type AzureDeviceData struct { // TODO: add support per https://docs.microsoft.com/en-us/azure/iot-dps/concepts-service AssignedHub string `json:"assignedHub,omitempty"` DeviceID string `json:"deviceId,omitempty"` }
AzureDeviceData contains the basic device connection information (assigned hub + device ID), returned by the Azure DPS.
type AzureDpsDeviceInfoResponse ¶
type AzureDpsDeviceInfoResponse struct { OperationID string `json:"operationId,omitempty"` Status string `json:"status,omitempty"` RegistrationState AzureDpsRegistrationState `json:"registrationState,omitempty"` }
AzureDpsDeviceInfoResponse contains the device connection information, returned by the Azure DPS.
type AzureDpsRegisterDeviceRequest ¶
type AzureDpsRegisterDeviceRequest struct {
RegistrationID string `json:"registrationId,omitempty"`
}
AzureDpsRegisterDeviceRequest represents the registration ID for a device in the Azure DPS.
type AzureDpsRegistrationState ¶
type AzureDpsRegistrationState struct { X509 interface{} `json:"x509,omitempty"` RegistrationID string `json:"registrationId,omitempty"` CreatedDateTimeUtc string `json:"createdDateTimeUtc,omitempty"` AssignedHub string `json:"assignedHub,omitempty"` DeviceID string `json:"deviceId,omitempty"` Status string `json:"status,omitempty"` Substatus string `json:"substatus,omitempty"` LastUpdatedDateTimeUtc string `json:"lastUpdatedDateTimeUtc,omitempty"` Etag string `json:"etag,omitempty"` }
AzureDpsRegistrationState represents the device registration state for a registered device in the Azure DPS.
type AzureSettings ¶
type AzureSettings struct { TenantID string `json:"tenantId"` ConnectionString string `json:"connectionString"` SASTokenValidity string `json:"sasTokenValidity"` IDScope string `json:"idScope"` config.LocalConnectionSettings logger.LogSettings config.TLSSettings }
AzureSettings represents all configurable data that is used to setup the azure connector.
func DefaultSettings ¶
func DefaultSettings() *AzureSettings
DefaultSettings returns the Azure connector default settings.
func (*AzureSettings) Validate ¶
func (settings *AzureSettings) Validate() error
Validate validates the settings.
type IDScopeProvider ¶
type IDScopeProvider func(connSettings *AzureConnectionSettings) (string, error)
IDScopeProvider is used as ID scope provider
type ProvisioningHTTPClient ¶
type ProvisioningHTTPClient interface { Get(url string) (*http.Response, error) Post(url string, contentType string, body io.Reader) (*http.Response, error) Do(req *http.Request) (*http.Response, error) }
ProvisioningHTTPClient is used as a wrapper of the HTTP client for accessing the provisioning services (PSS & Azure DPS).
func NewHTTPClient ¶
func NewHTTPClient(client *http.Client) ProvisioningHTTPClient
NewHTTPClient is a creator method for instantiating a provisioning HTTP client.
type ProvisioningService ¶
type ProvisioningService interface { Init(client ProvisioningHTTPClient, provisioningFile io.ReadWriter) GetDeviceData(idScope string, connSettings *AzureConnectionSettings) (*AzureDeviceData, error) }
ProvisioningService abstracts the access to the provisioning services (PSS & Azure DPS).
func NewProvisioningService ¶
func NewProvisioningService(logger logger.Logger) ProvisioningService
NewProvisioningService is a creator method for instantiating a provisioning service instance.
type RemoteConnectionInfo ¶
RemoteConnectionInfo contains properties related to the remote connection that may not be known at the start of the connector.
type ResponseError ¶
type ResponseError struct { Message string `json:"message,omitempty"` Detail string `json:"detail,omitempty"` }
ResponseError represents the error response information from a provisioning service.
type SharedAccessSignature ¶
type SharedAccessSignature struct {}
SharedAccessSignature represents the SAS access signature for generating SAS token for device authentication.
func GenerateSASToken ¶
func GenerateSASToken(connSettings *AzureConnectionSettings) *SharedAccessSignature
GenerateSASToken generates the SAS token for device authentication.