-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
6 changed files
with
207 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,7 +28,7 @@ | |
}, | ||
"extra": { | ||
"branch-alias": { | ||
"dev-master": "2.0-dev" | ||
"dev-master": "2.1-dev" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
<?php | ||
|
||
namespace AsyncAws\Iot\ValueObject; | ||
|
||
/** | ||
* The configuration to add user-defined properties to enrich MQTT 5 messages. | ||
*/ | ||
final class Mqtt5Configuration | ||
{ | ||
/** | ||
* An object that represents the propagating thing attributes and the connection attributes. | ||
* | ||
* @var PropagatingAttribute[]|null | ||
*/ | ||
private $propagatingAttributes; | ||
|
||
/** | ||
* @param array{ | ||
* propagatingAttributes?: null|array<PropagatingAttribute|array>, | ||
* } $input | ||
*/ | ||
public function __construct(array $input) | ||
{ | ||
$this->propagatingAttributes = isset($input['propagatingAttributes']) ? array_map([PropagatingAttribute::class, 'create'], $input['propagatingAttributes']) : null; | ||
} | ||
|
||
/** | ||
* @param array{ | ||
* propagatingAttributes?: null|array<PropagatingAttribute|array>, | ||
* }|Mqtt5Configuration $input | ||
*/ | ||
public static function create($input): self | ||
{ | ||
return $input instanceof self ? $input : new self($input); | ||
} | ||
|
||
/** | ||
* @return PropagatingAttribute[] | ||
*/ | ||
public function getPropagatingAttributes(): array | ||
{ | ||
return $this->propagatingAttributes ?? []; | ||
} | ||
|
||
/** | ||
* @internal | ||
*/ | ||
public function requestBody(): array | ||
{ | ||
$payload = []; | ||
if (null !== $v = $this->propagatingAttributes) { | ||
$index = -1; | ||
$payload['propagatingAttributes'] = []; | ||
foreach ($v as $listValue) { | ||
++$index; | ||
$payload['propagatingAttributes'][$index] = $listValue->requestBody(); | ||
} | ||
} | ||
|
||
return $payload; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
<?php | ||
|
||
namespace AsyncAws\Iot\ValueObject; | ||
|
||
/** | ||
* An object that represents the connection attribute, thing attribute, and the user property key. | ||
*/ | ||
final class PropagatingAttribute | ||
{ | ||
/** | ||
* The key of the user property key-value pair. | ||
* | ||
* @var string|null | ||
*/ | ||
private $userPropertyKey; | ||
|
||
/** | ||
* The user-defined thing attribute that is propagating for MQTT 5 message enrichment. | ||
* | ||
* @var string|null | ||
*/ | ||
private $thingAttribute; | ||
|
||
/** | ||
* The attribute associated with the connection between a device and Amazon Web Services IoT Core. | ||
* | ||
* @var string|null | ||
*/ | ||
private $connectionAttribute; | ||
|
||
/** | ||
* @param array{ | ||
* userPropertyKey?: null|string, | ||
* thingAttribute?: null|string, | ||
* connectionAttribute?: null|string, | ||
* } $input | ||
*/ | ||
public function __construct(array $input) | ||
{ | ||
$this->userPropertyKey = $input['userPropertyKey'] ?? null; | ||
$this->thingAttribute = $input['thingAttribute'] ?? null; | ||
$this->connectionAttribute = $input['connectionAttribute'] ?? null; | ||
} | ||
|
||
/** | ||
* @param array{ | ||
* userPropertyKey?: null|string, | ||
* thingAttribute?: null|string, | ||
* connectionAttribute?: null|string, | ||
* }|PropagatingAttribute $input | ||
*/ | ||
public static function create($input): self | ||
{ | ||
return $input instanceof self ? $input : new self($input); | ||
} | ||
|
||
public function getConnectionAttribute(): ?string | ||
{ | ||
return $this->connectionAttribute; | ||
} | ||
|
||
public function getThingAttribute(): ?string | ||
{ | ||
return $this->thingAttribute; | ||
} | ||
|
||
public function getUserPropertyKey(): ?string | ||
{ | ||
return $this->userPropertyKey; | ||
} | ||
|
||
/** | ||
* @internal | ||
*/ | ||
public function requestBody(): array | ||
{ | ||
$payload = []; | ||
if (null !== $v = $this->userPropertyKey) { | ||
$payload['userPropertyKey'] = $v; | ||
} | ||
if (null !== $v = $this->thingAttribute) { | ||
$payload['thingAttribute'] = $v; | ||
} | ||
if (null !== $v = $this->connectionAttribute) { | ||
$payload['connectionAttribute'] = $v; | ||
} | ||
|
||
return $payload; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters