IOSS 2.0
Loading...
Searching...
No Matches
Ios3_AwsHelpers.h
Go to the documentation of this file.
1// Copyright(C) 2025 National Technology & Engineering Solutions
2// of Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with
3// NTESS, the U.S. Government retains certain rights in this software.
4//
5// See packages/seacas/LICENSE for details
6
7#pragma once
8
9#include <aws/core/Aws.h>
10#include <aws/s3/S3Client.h>
11#include <aws/transfer/TransferManager.h>
12
13#include <cstdint>
14#include <memory>
15#include <string>
16#include <vector>
17
18namespace Ioss {
19 class ParallelUtils;
20 class PropertyManager;
21}; // namespace Ioss
22
23namespace Ios3 {
24 namespace helpers {
25
27 {
28 std::string endpoint{""};
29 std::string profile{"default"};
30 std::string ca_file{""};
31 bool use_ca_file{false};
33 bool enable_aws_tracing{false};
35 };
36
38 {
40
41 // The Aws::SDKOptions struct contains SDK configuration options.
42 // An instance of Aws::SDKOptions is passed to the Aws::InitAPI and
43 // Aws::ShutdownAPI methods. The same instance should be sent to both methods.
44 Aws::SDKOptions options;
45
46 std::shared_ptr<Aws::S3::S3Client> client;
47 std::shared_ptr<Aws::Utils::Threading::PooledThreadExecutor> executor;
48 std::shared_ptr<Aws::Transfer::TransferManager> transfer_manager;
49 };
50
51 // From
52 // https://stackoverflow.com/questions/21028299/is-this-behavior-of-vectorresizesize-type-n-under-c11-and-boost-container/21028912#21028912
53 //
54 // Allocator adaptor that interposes construct() calls to
55 // convert value initialization into default initialization.
56 template <typename T, typename A = std::allocator<T>> class default_init_allocator : public A
57 {
58 typedef std::allocator_traits<A> a_t;
59
60 public:
61 template <typename U> struct rebind
62 {
64 };
65
66 using A::A;
67
68 template <typename U>
69 void construct(U *ptr) noexcept(std::is_nothrow_default_constructible<U>::value)
70 {
71 ::new (static_cast<void *>(ptr)) U;
72 }
73 template <typename U, typename... Args> void construct(U *ptr, Args &&...args)
74 {
75 a_t::construct(static_cast<A &>(*this), ptr, std::forward<Args>(args)...);
76 }
77 };
78
79 // A vector that doesn't initialize new elements when resized.
80 template <typename T> using UninitializedVector = std::vector<T, default_init_allocator<T>>;
81
82 void print_params(const HelperParameters &params);
83
84 std::string cleanBucketName(const std::string &name);
85
87 const Ioss::ParallelUtils &utils);
89
90 std::shared_ptr<HelperContext> createContext(const HelperParameters &params);
91
92 void destroyContext(std::shared_ptr<HelperContext> context);
93
94 bool createBucket(std::shared_ptr<HelperContext> context, const std::string &bucket);
95
96 bool waitBucket(std::shared_ptr<HelperContext> context, const std::string &bucket,
97 uint64_t wait_usec);
98
99 bool deleteBucket(std::shared_ptr<HelperContext> context, const std::string &bucket);
100
101 bool listBuckets(std::shared_ptr<HelperContext> context,
102 std::vector<std::string> &bucket_names);
103
104 template <typename T, typename A>
105 bool putValue(std::shared_ptr<HelperContext> context, const std::string &bucket,
106 const std::string &key, const std::vector<T, A> &value);
107
108 template <typename T, typename A>
109 bool getValue(std::shared_ptr<HelperContext> context, const std::string &bucket,
110 const std::string &key, std::vector<T, A> &value);
111
112 bool putValue(std::shared_ptr<HelperContext> context, const std::string &bucket,
113 const std::string &key, const std::string &filename);
114
115 bool getValue(std::shared_ptr<HelperContext> context, const std::string &bucket,
116 const std::string &key, std::string &filename);
117
118 bool deleteValue(std::shared_ptr<HelperContext> context, const std::string &bucket,
119 const std::string &key);
120
121 bool listKeys(std::shared_ptr<HelperContext> context, const std::string &bucket,
122 std::vector<std::string> &keys);
123
124 bool listKeys(std::shared_ptr<HelperContext> context, const std::string &bucket,
125 const std::string &key_prefix, std::vector<std::string> &keys);
126
127 bool putBucketPolicy(std::shared_ptr<HelperContext> context, const std::string &bucket,
128 const std::string &policy);
129
130 bool getBucketPolicy(std::shared_ptr<HelperContext> context, const std::string &bucket,
131 std::string &policy);
132
133 bool deleteBucketPolicy(std::shared_ptr<HelperContext> context, const std::string &bucket);
134
135 } // namespace helpers
136} // namespace Ios3
Definition Ios3_AwsHelpers.h:57
void construct(U *ptr) noexcept(std::is_nothrow_default_constructible< U >::value)
Definition Ios3_AwsHelpers.h:69
std::allocator_traits< A > a_t
Definition Ios3_AwsHelpers.h:58
void construct(U *ptr, Args &&...args)
Definition Ios3_AwsHelpers.h:73
Definition Ioss_ParallelUtils.h:32
A collection of Ioss::Property objects.
Definition Ioss_PropertyManager.h:36
Definition Ios3_AwsHelpers.C:59
bool waitBucket(std::shared_ptr< HelperContext > context, const std::string &bucket, uint64_t wait_usec)
Definition Ios3_AwsHelpers.C:388
bool listBuckets(std::shared_ptr< HelperContext > context, std::vector< std::string > &bucket_names)
Definition Ios3_AwsHelpers.C:432
void getPropertiesFromEnvVars(Ioss::PropertyManager &properties, const Ioss::ParallelUtils &utils)
Definition Ios3_AwsHelpers.C:126
bool getValue(std::shared_ptr< HelperContext > context, const std::string &bucket, const std::string &key, std::vector< T, A > &value)
Definition Ios3_AwsHelpers.C:507
bool deleteBucketPolicy(std::shared_ptr< HelperContext > context, const std::string &bucket)
Definition Ios3_AwsHelpers.C:736
std::shared_ptr< HelperContext > createContext(const HelperParameters &params)
Definition Ios3_AwsHelpers.C:206
std::vector< T, default_init_allocator< T > > UninitializedVector
Definition Ios3_AwsHelpers.h:80
bool putBucketPolicy(std::shared_ptr< HelperContext > context, const std::string &bucket, const std::string &policy)
Definition Ios3_AwsHelpers.C:687
bool deleteBucket(std::shared_ptr< HelperContext > context, const std::string &bucket)
Definition Ios3_AwsHelpers.C:413
bool getBucketPolicy(std::shared_ptr< HelperContext > context, const std::string &bucket, std::string &policy)
Definition Ios3_AwsHelpers.C:712
bool deleteValue(std::shared_ptr< HelperContext > context, const std::string &bucket, const std::string &key)
Definition Ios3_AwsHelpers.C:615
void print_params(const HelperParameters &params)
Definition Ios3_AwsHelpers.C:79
bool putValue(std::shared_ptr< HelperContext > context, const std::string &bucket, const std::string &key, const std::vector< T, A > &value)
Definition Ios3_AwsHelpers.C:453
std::string cleanBucketName(const std::string &name)
Definition Ios3_AwsHelpers.C:302
void getParamsFromProperties(Ioss::PropertyManager &properties, HelperParameters &params)
Definition Ios3_AwsHelpers.C:180
bool listKeys(std::shared_ptr< HelperContext > context, const std::string &bucket, std::vector< std::string > &keys)
Definition Ios3_AwsHelpers.C:636
void destroyContext(std::shared_ptr< HelperContext > context)
Definition Ios3_AwsHelpers.C:263
bool createBucket(std::shared_ptr< HelperContext > context, const std::string &bucket)
Definition Ios3_AwsHelpers.C:369
Definition Ios3_AwsHelpers.C:58
The main namespace for the Ioss library.
Definition Ioad_DatabaseIO.C:40
Definition Ios3_AwsHelpers.h:38
std::shared_ptr< Aws::Utils::Threading::PooledThreadExecutor > executor
Definition Ios3_AwsHelpers.h:47
std::shared_ptr< Aws::Transfer::TransferManager > transfer_manager
Definition Ios3_AwsHelpers.h:48
std::shared_ptr< Aws::S3::S3Client > client
Definition Ios3_AwsHelpers.h:46
bool use_transfer_manager
Definition Ios3_AwsHelpers.h:39
Aws::SDKOptions options
Definition Ios3_AwsHelpers.h:44
Definition Ios3_AwsHelpers.h:27
bool enable_aws_tracing
Definition Ios3_AwsHelpers.h:33
std::string profile
Definition Ios3_AwsHelpers.h:29
std::string endpoint
Definition Ios3_AwsHelpers.h:28
bool use_ca_file
Definition Ios3_AwsHelpers.h:31
std::string ca_file
Definition Ios3_AwsHelpers.h:30
bool disable_ec2_lookup
Definition Ios3_AwsHelpers.h:34
bool use_transfer_manager
Definition Ios3_AwsHelpers.h:32
Definition Ios3_AwsHelpers.h:62
default_init_allocator< U, typename a_t::template rebind_alloc< U > > other
Definition Ios3_AwsHelpers.h:63