Skip to content

Commit

Permalink
Added C++ subscriber sample to list entitled DataSets.
Browse files Browse the repository at this point in the history
  • Loading branch information
dblock committed Mar 6, 2020
1 parent 9874559 commit f93b19e
Show file tree
Hide file tree
Showing 5 changed files with 83 additions and 0 deletions.
4 changes: 4 additions & 0 deletions README.md
Expand Up @@ -37,6 +37,10 @@ Examples of interacting with the AWS Data Exchange API from the data subscriber

* [all-entitled-datasets](subscribers/dotnet/all-entitled-datasets): Lists all data sets one is subscribed to.

### C++

* [all-entitled-datasets](subscribers/cpp/all-entitled-datasets): Lists all data sets one is subscribed to.

## Provider Samples

Examples of interacting with the AWS Data Exchange API from the data provider side can be found in [/providers](providers).
Expand Down
1 change: 1 addition & 0 deletions subscribers/cpp/all-entitled-datasets/.gitignore
@@ -0,0 +1 @@
build
10 changes: 10 additions & 0 deletions subscribers/cpp/all-entitled-datasets/CMakeLists.txt
@@ -0,0 +1,10 @@
cmake_minimum_required(VERSION 3.2)
project(all-entitled-datasets)

option(BUILD_SHARED_LIBS "Build shared libraries" ON)

find_package(AWSSDK REQUIRED COMPONENTS dataexchange)
add_executable(all-entitled-datasets main.cpp)

target_compile_features(all-entitled-datasets PUBLIC cxx_std_11)
target_link_libraries(all-entitled-datasets ${AWSSDK_LINK_LIBRARIES})
29 changes: 29 additions & 0 deletions subscribers/cpp/all-entitled-datasets/README.md
@@ -0,0 +1,29 @@
# All Entitled Data Sets

This sample retrieves a list of all subscriber's entitled data sets.

To build the sample, install the [AWS SDK for C++](https://github.com/aws/aws-sdk-cpp#building-the-sdk) and use [CMake](https://cmake.org/).

```
cpp/all-entitled-datasets $ mkdir build
cpp/all-entitled-datasets $ cd build
cpp/all-entitled-datasets/build $ cmake ..
cpp/all-entitled-datasets/build $ make
```

To run the sample, set `AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY`, `AWS_SESSION_TOKEN` and `AWS_REGION`.

```
$ ./all-entitled-datasets
prod-zg4u6tpyxud5i/7ae12084f47ea658ab62ee90edd513dd: NYC Property Sales 2014
Over 80,000 property sales in New York City in 2014
prod-zg4u6tpyxud5i/05964b659bbcb607d43c0d5845838e7f: NYC Property Sales 2015
Over 80,000 property sales in New York City in 2015
prod-zg4u6tpyxud5i/fc19d00c8780199e4fccd21f4834c905: NYC Property Sales 2018
A table of 80,000+ New York City property sales occurring in 2018, organized by borough, including sale price and sale date.
prod-zg4u6tpyxud5i/7d8f73e3c5acdde79fd2874dd98afdcd: NYC Property Sales 2016
Over 80,000 property sales in New York City in 2016
prod-zg4u6tpyxud5i/50782dc315b94e46fdbd4a12cec6820e: NYC Property Sales 2017
Records of over 80,000 property sales transactions.
```
39 changes: 39 additions & 0 deletions subscribers/cpp/all-entitled-datasets/main.cpp
@@ -0,0 +1,39 @@
#include <iostream>
#include <aws/core/Aws.h>
#include <aws/core/utils/Outcome.h>
#include <aws/dataexchange/DataExchangeClient.h>
#include <aws/dataexchange/model/ListDataSetsRequest.h>

int main(int argc, char** argv)
{
Aws::SDKOptions options;
Aws::InitAPI(options);

{
Aws::DataExchange::DataExchangeClient client;

Aws::DataExchange::Model::ListDataSetsRequest list_data_sets_options;
list_data_sets_options.SetOrigin("ENTITLED");

auto outcome = client.ListDataSets(list_data_sets_options);

if (outcome.IsSuccess()) {
Aws::Vector<Aws::DataExchange::Model::DataSetEntry> data_sets_list = outcome.GetResult().GetDataSets();

for (auto const &data_set: data_sets_list) {
std::cout
<< data_set.GetOriginDetails().GetProductId() << "/"
<< data_set.GetId() << ": "
<< data_set.GetName() << std::endl
<< " " << data_set.GetDescription()
<< std::endl;
}
} else {
std::cerr << "ListDataSets error: "
<< outcome.GetError().GetExceptionName() << " - "
<< outcome.GetError().GetMessage() << std::endl;
}
}

Aws::ShutdownAPI(options);
}

0 comments on commit f93b19e

Please sign in to comment.