Skip to content

Commit b618423

Browse files
committed
Migrating all New* to Create* api
1 parent f214eca commit b618423

14 files changed

Lines changed: 31 additions & 38 deletions

File tree

documents/MIGRATION_GUIDE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -618,7 +618,7 @@ except QOS0 publish packets in the offline queue on disconnect:
618618

619619
```cpp
620620
std::shared_ptr<Aws::Iot::Mqtt5ClientBuilder> builder(
621-
Aws::Iot::Mqtt5ClientBuilder::NewMqtt5ClientBuilderWithMtlsFromPath(/* ... */));
621+
Aws::Iot::Mqtt5ClientBuilder::CreateMqtt5ClientBuilderWithMtlsFromPath(/* ... */));
622622

623623
builder.WithOfflineQueueBehavior(
624624
Mqtt5::ClientOperationQueueBehaviorType::

documents/MQTT5_Userguide.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,7 @@ If your custom authenticator does not use signing, you don't specify anything re
408408
customAuth.WithPassword(<Binary data value of the password field to be passed to the authorizer lambda>);
409409
410410
// Create a Client using Mqtt5ClientBuilder
411-
Aws::Iot::Mqtt5ClientBuilder *builder = Aws::Iot::Mqtt5ClientBuilder::NewMqtt5ClientBuilderWithCustomCustomAuthorizer(
411+
Aws::Iot::Mqtt5ClientBuilder *builder = Aws::Iot::Mqtt5ClientBuilder::CreateMqtt5ClientBuilderWithCustomAuthorizer(
412412
"<clientEndpoint>", customAuth);
413413
414414
/* You can setup other client options and lifecycle event callbacks before call builder->Build().
@@ -439,7 +439,7 @@ If your custom authorizer uses signing, you must specify the three signed token
439439
customAuth.WithTokenSignature("<The signature of the custom authorizer>")
440440

441441
// Create a Client using Mqtt5ClientBuilder
442-
Aws::Iot::Mqtt5ClientBuilder *builder = Aws::Iot::Mqtt5ClientBuilder::NewMqtt5ClientBuilderWithCustomCustomAuthorizer(
442+
Aws::Iot::Mqtt5ClientBuilder *builder = Aws::Iot::Mqtt5ClientBuilder::CreateMqtt5ClientBuilderWithCustomAuthorizer(
443443
"<clientEndpoint>", customAuth);
444444

445445
/* You can setup other client options and lifecycle event callbacks before call builder->Build().
@@ -497,7 +497,7 @@ To create a MQTT5 builder configured for this connection, see the following code
497497
Aws::Iot::WebsocketConfig websocketConfig(<signing region>, provider);
498498
499499
// Create a Client using Mqtt5ClientBuilder
500-
Aws::Iot::Mqtt5ClientBuilder *builder = Aws::Iot::Mqtt5ClientBuilder::NewMqtt5ClientBuilderWithWebsocket(
500+
Aws::Iot::Mqtt5ClientBuilder *builder = Aws::Iot::Mqtt5ClientBuilder::CreateMqtt5ClientBuilderWithWebsocket(
501501
"<clientEndpoint>", websocketConfig);
502502
503503
/* You can setup other client options and lifecycle event callbacks before call builder->Build().
@@ -526,7 +526,7 @@ store, rather than simply being files on disk. To create a MQTT5 builder configu
526526
```cpp
527527
String windowsCertPath = "CurrentUser\\MY\\A11F8A9B5DF5B98BA3508FBCA575D09570E0D2C6";
528528

529-
Aws::Iot::Mqtt5ClientBuilder *builder = Aws::Iot::Mqtt5ClientBuilder::NewMqtt5ClientBuilderWithWindowsCertStorePath(
529+
Aws::Iot::Mqtt5ClientBuilder *builder = Aws::Iot::Mqtt5ClientBuilder::CreateMqtt5ClientBuilderWithWindowsCertStorePath(
530530
"<clientEndpoint>", windowsCertPath);
531531

532532
// Build Mqtt5Client
@@ -566,7 +566,7 @@ the private key for mutual TLS is stored on a PKCS#11 compatible smart card or H
566566
pkcs11Options.SetTokenLabel("<pkcs11_tokenLabel>");
567567
pkcs11Options.SetPrivateKeyObjectLabel("<pkcs11_privateKeyLabel>");
568568
569-
Aws::Iot::Mqtt5ClientBuilder *builder = Aws::Iot::Mqtt5ClientBuilder::NewMqtt5ClientBuilderWithMtlsPkcs11(
569+
Aws::Iot::Mqtt5ClientBuilder *builder = Aws::Iot::Mqtt5ClientBuilder::CreateMqtt5ClientBuilderWithMtlsPkcs11(
570570
"<endpoint>", pkcs11Options);
571571
572572
builder->WithPort(8883);
@@ -591,7 +591,7 @@ To create a MQTT5 builder configured for this connection, see the following code
591591
testPkcs12Options.pkcs12_file = "<pkcs12_key>";
592592
testPkcs12Options.pkcs12_password = "<pkcs12_password>";
593593

594-
Aws::Iot::Mqtt5ClientBuilder *builder = Aws::Iot::Mqtt5ClientBuilder::NewMqtt5ClientBuilderWithMtlsPkcs12(
594+
Aws::Iot::Mqtt5ClientBuilder *builder = Aws::Iot::Mqtt5ClientBuilder::CreateMqtt5ClientBuilderWithMtlsPkcs12(
595595
"<endpoint>", testPkcs12Options);
596596

597597
std::shared_ptr<Aws::Crt::Mqtt5::Mqtt5Client> mqtt5Client = builder->Build();
@@ -611,7 +611,7 @@ No matter what your connection transport or authentication method is, you may co
611611
612612
```cpp
613613
// Create a Client using Mqtt5ClientBuilder
614-
Aws::Iot::Mqtt5ClientBuilder *builder = Aws::Iot::Mqtt5ClientBuilder::NewMqtt5ClientBuilderWithXXXXX( ... );
614+
Aws::Iot::Mqtt5ClientBuilder *builder = Aws::Iot::Mqtt5ClientBuilder::CreateMqtt5ClientBuilderWithXXXXX( ... );
615615
616616
Http::HttpClientConnectionProxyOptions proxyOptions;
617617
proxyOptions.HostName = "<proxyHost>";

samples/mqtt/mqtt5_custom_auth_signed/main.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,8 +164,8 @@ int main(int argc, char *argv[])
164164
customAuth.WithTokenKeyName(cmdData.authTokenKeyName.c_str());
165165
customAuth.WithTokenValue(cmdData.authTokenKeyValue.c_str());
166166

167-
auto builder = std::unique_ptr<Aws::Iot::Mqtt5ClientBuilder>(
168-
Aws::Iot::Mqtt5ClientBuilder::NewMqtt5ClientBuilderWithCustomAuthorizer(cmdData.endpoint, customAuth, DefaultAllocatorImplementation()));
167+
auto builder = Aws::Iot::Mqtt5ClientBuilder::CreateMqtt5ClientBuilderWithCustomAuthorizer(
168+
cmdData.endpoint, customAuth, DefaultAllocatorImplementation());
169169

170170
// Check if the builder setup correctly.
171171
if (builder == nullptr)

samples/mqtt/mqtt5_custom_auth_unsigned/main.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,9 +138,8 @@ int main(int argc, char *argv[])
138138
customAuth.WithUsername(cmdData.authUsername.c_str());
139139
customAuth.WithPassword(ByteCursorFromCString(cmdData.authPassword.c_str()));
140140

141-
auto builder = std::unique_ptr<Aws::Iot::Mqtt5ClientBuilder>(
142-
Aws::Iot::Mqtt5ClientBuilder::NewMqtt5ClientBuilderWithCustomAuthorizer(
143-
cmdData.endpoint, customAuth, DefaultAllocatorImplementation()));
141+
auto builder = Aws::Iot::Mqtt5ClientBuilder::CreateMqtt5ClientBuilderWithCustomAuthorizer(
142+
cmdData.endpoint, customAuth, DefaultAllocatorImplementation());
144143

145144
// Check if the builder setup correctly.
146145
if (builder == nullptr)

samples/mqtt/mqtt5_pkcs11/main.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,8 +189,8 @@ int main(int argc, char *argv[])
189189
pkcs11Options.SetSlotId(cmdData.pkcs11SlotId);
190190
}
191191

192-
Aws::Iot::Mqtt5ClientBuilder *builder =
193-
Aws::Iot::Mqtt5ClientBuilder::NewMqtt5ClientBuilderWithMtlsPkcs11(cmdData.endpoint, pkcs11Options);
192+
auto builder = Aws::Iot::Mqtt5ClientBuilder::CreateMqtt5ClientBuilderWithMtlsPkcs11(
193+
cmdData.endpoint, pkcs11Options);
194194
// Check if the builder setup correctly.
195195
if (builder == nullptr)
196196
{

samples/others/device_defender/mqtt5_basic_report/main.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -176,9 +176,9 @@ int main(int argc, char *argv[])
176176
ApiHandle apiHandle;
177177

178178
// Create the MQTT builder and populate it with data from cmdData.
179-
auto clientConfigBuilder = std::unique_ptr<Aws::Iot::Mqtt5ClientBuilder>(
180-
Aws::Iot::Mqtt5ClientBuilder::NewMqtt5ClientBuilderWithMtlsFromPath(
181-
cmdData.endpoint, cmdData.cert.c_str(), cmdData.key.c_str()));
179+
auto clientConfigBuilder = Aws::Iot::Mqtt5ClientBuilder::CreateMqtt5ClientBuilderWithMtlsFromPath(
180+
cmdData.endpoint, cmdData.cert.c_str(), cmdData.key.c_str());
181+
182182
if (clientConfigBuilder == nullptr)
183183
{
184184
fprintf(

samples/service_clients/commands/commands-sandbox/main.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -275,9 +275,8 @@ int main(int argc, char *argv[])
275275
Aws::Crt::ApiHandle apiHandle;
276276

277277
// Create the MQTT5 builder and populate it with data from cmdData.
278-
auto builder = std::unique_ptr<Aws::Iot::Mqtt5ClientBuilder>(
279-
Aws::Iot::Mqtt5ClientBuilder::NewMqtt5ClientBuilderWithMtlsFromPath(
280-
cmdData.endpoint, cmdData.cert.c_str(), cmdData.key.c_str()));
278+
auto builder = Aws::Iot::Mqtt5ClientBuilder::CreateMqtt5ClientBuilderWithMtlsFromPath(
279+
cmdData.endpoint, cmdData.cert.c_str(), cmdData.key.c_str());
281280
// Check if the builder setup correctly.
282281
if (builder == nullptr)
283282
{

samples/service_clients/fleet_provisioning/provision-basic/main.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,9 +137,8 @@ int main(int argc, char *argv[])
137137
ApiHandle apiHandle;
138138

139139
// Create the MQTT5 builder and populate it with data from cmdData.
140-
auto builder = std::unique_ptr<Aws::Iot::Mqtt5ClientBuilder>(
141-
Aws::Iot::Mqtt5ClientBuilder::NewMqtt5ClientBuilderWithMtlsFromPath(
142-
cmdData.endpoint, cmdData.cert.c_str(), cmdData.key.c_str()));
140+
auto builder = Aws::Iot::Mqtt5ClientBuilder::CreateMqtt5ClientBuilderWithMtlsFromPath(
141+
cmdData.endpoint, cmdData.cert.c_str(), cmdData.key.c_str());
143142
// Check if the builder setup correctly.
144143
if (builder == nullptr)
145144
{

samples/service_clients/fleet_provisioning/provision-csr/main.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -142,9 +142,8 @@ int main(int argc, char *argv[])
142142
ApiHandle apiHandle;
143143

144144
// Create the MQTT5 builder and populate it with data from cmdData.
145-
auto builder = std::unique_ptr<Aws::Iot::Mqtt5ClientBuilder>(
146-
Aws::Iot::Mqtt5ClientBuilder::NewMqtt5ClientBuilderWithMtlsFromPath(
147-
cmdData.endpoint, cmdData.cert.c_str(), cmdData.key.c_str()));
145+
auto builder = Aws::Iot::Mqtt5ClientBuilder::CreateMqtt5ClientBuilderWithMtlsFromPath(
146+
cmdData.endpoint, cmdData.cert.c_str(), cmdData.key.c_str());
148147
// Check if the builder setup correctly.
149148
if (builder == nullptr)
150149
{

samples/service_clients/jobs/jobs-sandbox/main.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -462,9 +462,8 @@ int main(int argc, char *argv[])
462462
context.m_thingName = cmdData.thingName;
463463

464464
// Create the MQTT5 builder and populate it with data from cmdData.
465-
auto builder = std::unique_ptr<Aws::Iot::Mqtt5ClientBuilder>(
466-
Aws::Iot::Mqtt5ClientBuilder::NewMqtt5ClientBuilderWithMtlsFromPath(
467-
cmdData.endpoint, cmdData.cert.c_str(), cmdData.key.c_str()));
465+
auto builder = Aws::Iot::Mqtt5ClientBuilder::CreateMqtt5ClientBuilderWithMtlsFromPath(
466+
cmdData.endpoint, cmdData.cert.c_str(), cmdData.key.c_str());
468467
// Check if the builder setup correctly.
469468
if (builder == nullptr)
470469
{

0 commit comments

Comments
 (0)