Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Request response workspace pre format #764

Open
wants to merge 34 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
359a793
Checkpoint
bretambrose Sep 16, 2024
aa12ba8
Checkpoint
bretambrose Sep 18, 2024
0327dcf
Updates
bretambrose Sep 19, 2024
f8567cd
Checkpoint pre gen diff
Oct 16, 2024
8f357e1
V2 Codegen Building
Oct 17, 2024
4632528
Shadow tests
Oct 18, 2024
1548624
Fix and refactor tests
Oct 18, 2024
a561ae9
Checkpoint
Oct 21, 2024
b6276dd
Regen
Oct 21, 2024
7f8dac8
Identity tests
bretambrose Oct 21, 2024
c802893
Merge branch 'main' into RequestResponseWorkspace
Oct 29, 2024
ba0ef19
Codegen and format updates
Oct 29, 2024
e519763
V2ServiceError -> V2ErrorResponse
Nov 11, 2024
88889a5
unreferenced params
bretambrose Nov 11, 2024
be267e3
Trivial change to invoke fresh CI
bretambrose Nov 11, 2024
20a9fe2
Will this setup the env variables?
bretambrose Nov 11, 2024
634aea8
Manual test invoke of cli
bretambrose Nov 11, 2024
ec5fb72
Revert "Manual test invoke of cli"
bretambrose Nov 11, 2024
421baab
Does the build have credentials injected?
bretambrose Nov 11, 2024
f04dfd6
Check for session
bretambrose Nov 11, 2024
d799ec9
non-change to trigger CI
bretambrose Nov 11, 2024
bd03d8a
Updated builder to a version that passes session credentials to the c…
bretambrose Nov 11, 2024
3fd6892
Non-change
bretambrose Nov 11, 2024
1799c1a
Non change
bretambrose Nov 11, 2024
5fa7606
Update CI jobs with CI-test credentials
bretambrose Nov 11, 2024
c57dec7
Basic CI Prep
Nov 12, 2024
bc9273e
Skip service tests on macs where keychain access/code-signing is nece…
Nov 12, 2024
2fb685f
Can't have empty test exe
Nov 12, 2024
8876976
Provison second parameter
Nov 12, 2024
278a5e1
Temporarily allow mac service testing
Nov 12, 2024
272cf93
Device location csr
Nov 12, 2024
5881ac3
Builder with fleet provisioning env
Nov 13, 2024
31e556d
Use credentials with smoke tests too
Nov 13, 2024
0e9dc45
Released CRT
bretambrose Nov 14, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions .builder/actions/sdk-ci-prep.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import Builder
import os

class SdkCiPrep(Builder.Action):
def run(self, env):
if os.environ.get('AWS_ACCESS_KEY_ID') != None:
print(f"Local credentials exist")
if os.environ.get('AWS_SESSION_TOKEN') != None:
print(f"Local credentials are session based")
else:
print(f"No Local credentials")


actions = [
Builder.SetupCrossCICrtEnvironment()
]
return Builder.Script(actions, name='sdk-ci-prep')
80 changes: 60 additions & 20 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
- 'docs'

env:
BUILDER_VERSION: v0.9.56
BUILDER_VERSION: v0.9.72
BUILDER_SOURCE: releases
BUILDER_HOST: https://d19elf31gohf1l.cloudfront.net
PACKAGE_NAME: aws-iot-device-sdk-cpp-v2
Expand Down Expand Up @@ -155,6 +155,11 @@ jobs:
permissions:
id-token: write # This is required for requesting the JWT
steps:
- name: configure AWS credentials (containers)
uses: aws-actions/configure-aws-credentials@v2
with:
role-to-assume: ${{ env.CI_IOT_CONTAINERS }}
aws-region: ${{ env.AWS_DEFAULT_REGION }}
- name: Build ${{ env.PACKAGE_NAME }} + consumers
run: |
md ${{ env.CI_FOLDER }}
Expand Down Expand Up @@ -204,6 +209,11 @@ jobs:
permissions:
id-token: write # This is required for requesting the JWT
steps:
- name: configure AWS credentials (containers)
uses: aws-actions/configure-aws-credentials@v2
with:
role-to-assume: ${{ env.CI_IOT_CONTAINERS }}
aws-region: ${{ env.AWS_DEFAULT_REGION }}
- name: Build ${{ env.PACKAGE_NAME }} + consumers
run: |
md ${{ env.CI_FOLDER }}
Expand Down Expand Up @@ -249,6 +259,11 @@ jobs:
permissions:
id-token: write # This is required for requesting the JWT
steps:
- name: configure AWS credentials (containers)
uses: aws-actions/configure-aws-credentials@v2
with:
role-to-assume: ${{ env.CI_IOT_CONTAINERS }}
aws-region: ${{ env.AWS_DEFAULT_REGION }}
- name: Build ${{ env.PACKAGE_NAME }} + consumers
run: |
md ${{ env.CI_FOLDER }}
Expand Down Expand Up @@ -294,30 +309,40 @@ jobs:
permissions:
id-token: write # This is required for requesting the JWT
steps:
- name: Build ${{ env.PACKAGE_NAME }} + consumers
run: |
md ${{ env.CI_FOLDER }}
cd ${{ env.CI_FOLDER }}
python -c "from urllib.request import urlretrieve; urlretrieve('${{ env.BUILDER_HOST }}/${{ env.BUILDER_SOURCE }}/${{ env.BUILDER_VERSION }}/builder.pyz', 'builder.pyz')"
python builder.pyz build -p ${{ env.PACKAGE_NAME }} --cmake-extra=-DUSE_CPU_EXTENSIONS=OFF
- name: Running samples in CI setup
run: |
python -m pip install boto3
- name: configure AWS credentials (CyclePubSub)
uses: aws-actions/configure-aws-credentials@v2
with:
role-to-assume: ${{ env.CI_CYCLEPUBSUB_ROLE }}
aws-region: ${{ env.AWS_DEFAULT_REGION }}
- name: Run and check AppVerifier
run: |
cd ${{ env.CI_FOLDER }}
echo "Starting to run AppVerifier with cycle pub-sub sample"
python ${{ env.CI_UTILS_FOLDER }}/appverifier_launch_sample.py --sample_file ".\aws-iot-device-sdk-cpp-v2\build\samples\pub_sub\cycle_pub_sub\RelWithDebInfo\cycle-pub-sub.exe" --sample_secret_endpoint 'ci/endpoint' --sample_secret_certificate 'ci/CyclePubSub/cert' --sample_secret_private_key 'ci/CyclePubSub/key'
- name: configure AWS credentials (containers)
uses: aws-actions/configure-aws-credentials@v2
with:
role-to-assume: ${{ env.CI_IOT_CONTAINERS }}
aws-region: ${{ env.AWS_DEFAULT_REGION }}
- name: Build ${{ env.PACKAGE_NAME }} + consumers
run: |
md ${{ env.CI_FOLDER }}
cd ${{ env.CI_FOLDER }}
python -c "from urllib.request import urlretrieve; urlretrieve('${{ env.BUILDER_HOST }}/${{ env.BUILDER_SOURCE }}/${{ env.BUILDER_VERSION }}/builder.pyz', 'builder.pyz')"
python builder.pyz build -p ${{ env.PACKAGE_NAME }} --cmake-extra=-DUSE_CPU_EXTENSIONS=OFF
- name: Running samples in CI setup
run: |
python -m pip install boto3
- name: configure AWS credentials (CyclePubSub)
uses: aws-actions/configure-aws-credentials@v2
with:
role-to-assume: ${{ env.CI_CYCLEPUBSUB_ROLE }}
aws-region: ${{ env.AWS_DEFAULT_REGION }}
- name: Run and check AppVerifier
run: |
cd ${{ env.CI_FOLDER }}
echo "Starting to run AppVerifier with cycle pub-sub sample"
python ${{ env.CI_UTILS_FOLDER }}/appverifier_launch_sample.py --sample_file ".\aws-iot-device-sdk-cpp-v2\build\samples\pub_sub\cycle_pub_sub\RelWithDebInfo\cycle-pub-sub.exe" --sample_secret_endpoint 'ci/endpoint' --sample_secret_certificate 'ci/CyclePubSub/cert' --sample_secret_private_key 'ci/CyclePubSub/key'
windows-shared-lib:
runs-on: windows-latest
permissions:
id-token: write # This is required for requesting the JWT
steps:
- name: configure AWS credentials (containers)
uses: aws-actions/configure-aws-credentials@v2
with:
role-to-assume: ${{ env.CI_IOT_CONTAINERS }}
aws-region: ${{ env.AWS_DEFAULT_REGION }}
- name: Build ${{ env.PACKAGE_NAME }} + consumers
run: |
md ${{ env.CI_FOLDER }}
Expand All @@ -336,6 +361,11 @@ jobs:
id-token: write # This is required for requesting the JWT
security-events: write # This is required for pkcs12 sample to sign the key
steps:
- name: configure AWS credentials (containers)
uses: aws-actions/configure-aws-credentials@v2
with:
role-to-assume: ${{ env.CI_IOT_CONTAINERS }}
aws-region: ${{ env.AWS_DEFAULT_REGION }}
- name: Build ${{ env.PACKAGE_NAME }} + consumers
run: |
python3 -c "from urllib.request import urlretrieve; urlretrieve('${{ env.BUILDER_HOST }}/${{ env.BUILDER_SOURCE }}/${{ env.BUILDER_VERSION }}/builder.pyz', 'builder')"
Expand Down Expand Up @@ -400,6 +430,11 @@ jobs:
permissions:
id-token: write # This is required for requesting the JWT
steps:
- name: configure AWS credentials (containers)
uses: aws-actions/configure-aws-credentials@v2
with:
role-to-assume: ${{ env.CI_IOT_CONTAINERS }}
aws-region: ${{ env.AWS_DEFAULT_REGION }}
- name: Build ${{ env.PACKAGE_NAME }} + consumers
run: |
python -c "from urllib.request import urlretrieve; urlretrieve('${{ env.BUILDER_HOST }}/${{ env.BUILDER_SOURCE }}/${{ env.BUILDER_VERSION }}/builder.pyz?run=${{ env.RUN }}', 'builder.pyz')"
Expand Down Expand Up @@ -460,6 +495,11 @@ jobs:
sudo apt install cmake
gcc --version
cmake --version
- name: configure AWS credentials (containers)
uses: aws-actions/configure-aws-credentials@v2
with:
role-to-assume: ${{ env.CI_IOT_CONTAINERS }}
aws-region: ${{ env.AWS_DEFAULT_REGION }}
- name: Build ${{ env.PACKAGE_NAME }} + consumers
run: |
echo "Downloading source"
Expand Down
11 changes: 11 additions & 0 deletions builder.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@
"build",
"build-samples"
],
"test_steps": [
"sdk-ci-prep",
"test"
],
"variants" : {
"skip_sample": {
"!build_steps": [
Expand All @@ -35,5 +39,12 @@
"build-gg-samples"
]
}
},
"targets" : {
"macos" : {
"!test_steps": [
"test"
]
}
}
}
6 changes: 6 additions & 0 deletions identity/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -133,3 +133,9 @@ configure_file("cmake/iotidentity-cpp-config.cmake"
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/iotidentity-cpp-config.cmake"
DESTINATION "${CMAKE_INSTALL_LIBDIR}/IotIdentity-cpp/cmake/"
COMPONENT Development)

if(NOT CMAKE_CROSSCOMPILING)
if (BUILD_TESTING AND NOT BYO_CRYPTO)
add_subdirectory(tests)
endif()
endif()
5 changes: 3 additions & 2 deletions identity/include/aws/iotidentity/Config.h.in
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#pragma once
/**
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
/* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0.
*
* This file is generated
*/

#define AWS_IOT_DEVICE_SDK_CPP_V2_IOTIDENTITY_VERSION "@FULL_VERSION@"
Expand Down
182 changes: 182 additions & 0 deletions identity/include/aws/iotidentity/IotIdentityClientV2.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,182 @@
#pragma once

/* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0.
*
* This file is generated
*/

#include <aws/iotidentity/Exports.h>

#include <aws/crt/StlAllocator.h>
#include <aws/crt/Types.h>
#include <aws/iot/MqttRequestResponseClient.h>

#include <functional>

namespace Aws
{
namespace Crt
{
namespace Mqtt
{
class MqttConnection;
}
namespace Mqtt5
{
class Mqtt5Client;
}
} // namespace Crt
} // namespace Aws

namespace Aws
{
namespace Iotidentity
{

template <typename E> class ServiceErrorV2
{
public:
ServiceErrorV2() = delete;
ServiceErrorV2(const ServiceErrorV2<E> &rhs) = default;
ServiceErrorV2(ServiceErrorV2<E> &&rhs) = default;

explicit ServiceErrorV2(int errorCode) : m_errorCode(errorCode), m_modeledError() {}

ServiceErrorV2(int errorCode, E &&modeledError)
: m_errorCode(errorCode), m_modeledError(std::move(modeledError))
{
}

~ServiceErrorV2() = default;

ServiceErrorV2<E> &operator=(const ServiceErrorV2<E> &rhs) = default;
ServiceErrorV2<E> &operator=(ServiceErrorV2<E> &&rhs) = default;

int GetErrorCode() const { return m_errorCode; }

bool HasModeledError() const { return m_modeledError.has_value(); }
const E &GetModeledError() const { return m_modeledError.value(); }

private:
int m_errorCode;

Aws::Crt::Optional<E> m_modeledError;
};

class CreateCertificateFromCsrRequest;
class CreateCertificateFromCsrResponse;
class CreateKeysAndCertificateRequest;
class CreateKeysAndCertificateResponse;
class RegisterThingRequest;
class RegisterThingResponse;
class V2ErrorResponse;

using CreateCertificateFromCsrResult =
Aws::Iot::RequestResponse::Result<CreateCertificateFromCsrResponse, ServiceErrorV2<V2ErrorResponse>>;
using CreateCertificateFromCsrResultHandler = std::function<void(CreateCertificateFromCsrResult &&)>;

using CreateKeysAndCertificateResult =
Aws::Iot::RequestResponse::Result<CreateKeysAndCertificateResponse, ServiceErrorV2<V2ErrorResponse>>;
using CreateKeysAndCertificateResultHandler = std::function<void(CreateKeysAndCertificateResult &&)>;

using RegisterThingResult =
Aws::Iot::RequestResponse::Result<RegisterThingResponse, ServiceErrorV2<V2ErrorResponse>>;
using RegisterThingResultHandler = std::function<void(RegisterThingResult &&)>;

/**
* An AWS IoT service that assists with provisioning a device and installing unique client certificates on it
*
* https://docs.aws.amazon.com/iot/latest/developerguide/provision-wo-cert.html
*
*/
class AWS_IOTIDENTITY_API IClientV2
{
public:
virtual ~IClientV2() = default;

/**
* Creates a certificate from a certificate signing request (CSR). AWS IoT provides client certificates that
* are signed by the Amazon Root certificate authority (CA). The new certificate has a PENDING_ACTIVATION
* status. When you call RegisterThing to provision a thing with this certificate, the certificate status
* changes to ACTIVE or INACTIVE as described in the template.
*
*
* AWS documentation:
* https://docs.aws.amazon.com/iot/latest/developerguide/provision-wo-cert.html#fleet-provision-api
*
* @param request operation to perform
* @param handler function object to invoke upon operation completion
*
* @returns success/failure
*/
virtual bool CreateCertificateFromCsr(
const CreateCertificateFromCsrRequest &request,
const CreateCertificateFromCsrResultHandler &handler) = 0;

/**
* Creates new keys and a certificate. AWS IoT provides client certificates that are signed by the Amazon
* Root certificate authority (CA). The new certificate has a PENDING_ACTIVATION status. When you call
* RegisterThing to provision a thing with this certificate, the certificate status changes to ACTIVE or
* INACTIVE as described in the template.
*
*
* AWS documentation:
* https://docs.aws.amazon.com/iot/latest/developerguide/provision-wo-cert.html#fleet-provision-api
*
* @param request operation to perform
* @param handler function object to invoke upon operation completion
*
* @returns success/failure
*/
virtual bool CreateKeysAndCertificate(
const CreateKeysAndCertificateRequest &request,
const CreateKeysAndCertificateResultHandler &handler) = 0;

/**
* Provisions an AWS IoT thing using a pre-defined template.
*
*
* AWS documentation:
* https://docs.aws.amazon.com/iot/latest/developerguide/provision-wo-cert.html#fleet-provision-api
*
* @param request operation to perform
* @param handler function object to invoke upon operation completion
*
* @returns success/failure
*/
virtual bool RegisterThing(
const RegisterThingRequest &request,
const RegisterThingResultHandler &handler) = 0;
};

/**
* Creates a new service client that uses an SDK MQTT5 client for transport.
*
* @param protocolClient MQTT client to use as transport
* @param options request-response MQTT client configuration options
* @param allocator memory allocator to use for all client functionality
*
* @return a new service client
*/
AWS_IOTIDENTITY_API std::shared_ptr<IClientV2> NewClientFrom5(
const Aws::Crt::Mqtt5::Mqtt5Client &protocolClient,
const Aws::Iot::RequestResponse::RequestResponseClientOptions &options,
Aws::Crt::Allocator *allocator = Aws::Crt::ApiAllocator());

/**
* Creates a new service client that uses an SDK MQTT311 client for transport.
*
* @param protocolClient MQTT client to use as transport
* @param options request-response MQTT client configuration options
* @param allocator memory allocator to use for all client functionality
*
* @return a new service client
*/
AWS_IOTIDENTITY_API std::shared_ptr<IClientV2> NewClientFrom311(
const Aws::Crt::Mqtt::MqttConnection &protocolClient,
const Aws::Iot::RequestResponse::RequestResponseClientOptions &options,
Aws::Crt::Allocator *allocator = Aws::Crt::ApiAllocator());

} // namespace Iotidentity
} // namespace Aws
Loading
Loading