C++ edjLibrary SDK
Loading...
Searching...
No Matches
storage.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <cstdint>
4#include <map>
5#include <string>
6#include <vector>
7
8#include "stream.hpp"
9#include "error.hpp"
10
11namespace edjx {
12
13// APIs for interacting with the EDJX Object Store.
14namespace storage {
15
21 std::map<std::string, std::string> headers;
24
28 inline StorageResponse() {}
29
38 const std::map<std::string, std::string> & headers,
40 ) : headers(headers),
42
48 const std::map<std::string, std::string> & get_headers() const;
49
58 edjx::error::StreamError read_body(std::vector<uint8_t> & result);
59
66 };
67
74 uint32_t sd;
75
87
96 };
97
105 std::map<std::string, std::string> properties;
109 std::string default_version;
110
114 inline FileAttributes() :
115 properties_present(false),
117
128 const std::map<std::string, std::string> & properties,
130 const std::string & default_version
135 };
136
147 StorageResponse & result,
148 const std::string & bucket_id,
149 const std::string & file_name
150 );
151
164 StorageResponse & result,
165 const std::string & bucket_id,
166 const std::string & file_name,
167 const std::string & properties,
168 const std::vector<uint8_t> contents
169 );
170
191 StorageResponsePending & response_streaming,
192 edjx::stream::WriteStream & write_stream,
193 const std::string & bucket_id,
194 const std::string & file_name,
195 const std::string & properties
196 );
197
208 StorageResponse result,
209 const std::string & bucket_id,
210 const std::string & file_name
211 );
212
224 FileAttributes & result,
225 const std::string & bucket_id,
226 const std::string & file_name
227 );
228
242 StorageResponse & result,
243 const std::string & bucket_id,
244 const std::string & file_name,
245 const FileAttributes & attributes
246 );
247
248}}
Read stream class.
Definition: stream.hpp:120
This class represents a write stream.
Definition: stream.hpp:68
StreamError
Enum that describes values returned by streaming functions.
Definition: error.hpp:243
StorageError
Enum describing return values of functions that correspond to storage modules.
Definition: error.hpp:132
edjx::error::StorageError set_attributes(StorageResponse &result, const std::string &bucket_id, const std::string &file_name, const FileAttributes &attributes)
Sets the attributes associated with the given file.
edjx::error::StorageError get(StorageResponse &result, const std::string &bucket_id, const std::string &file_name)
Returns a file from the EDJX Object Store.
edjx::error::StorageError put(StorageResponse &result, const std::string &bucket_id, const std::string &file_name, const std::string &properties, const std::vector< uint8_t > contents)
Uploads a file to the EDJX Object Store.
edjx::error::StorageError remove(StorageResponse result, const std::string &bucket_id, const std::string &file_name)
Deletes the given file from the EDJX Object Store.
edjx::error::StorageError get_attributes(FileAttributes &result, const std::string &bucket_id, const std::string &file_name)
Returns attributes associated with the given file from the EDJX Object Store.
edjx::error::StorageError put_streaming(StorageResponsePending &response_streaming, edjx::stream::WriteStream &write_stream, const std::string &bucket_id, const std::string &file_name, const std::string &properties)
Starts streaming a file to the EDJX Object Store.
Definition: error.hpp:5
Represents the attributes associated with a stored file.
Definition: storage.hpp:101
bool properties_present
Whether file properties are defined.
Definition: storage.hpp:103
std::map< std::string, std::string > properties
File properties.
Definition: storage.hpp:105
FileAttributes()
Construct an empty file attributes object.
Definition: storage.hpp:114
bool default_version_present
Whether default version is present.
Definition: storage.hpp:107
FileAttributes(bool properties_present, const std::map< std::string, std::string > &properties, bool default_version_present, const std::string &default_version)
Construct a new File Attributes object.
Definition: storage.hpp:126
std::string default_version
Default version.
Definition: storage.hpp:109
Placeholder for storage response used in streaming methods when the response is not available immedia...
Definition: storage.hpp:72
edjx::error::StorageError get_storage_response(StorageResponse &result)
Attempts to retrieve the storage response if it is ready.
uint32_t sd
Stream descriptor.
Definition: storage.hpp:74
StorageResponsePending(uint32_t sd)
Constructs a response holder for a stream identified by the stream descriptor sd.
Definition: storage.hpp:86
StorageResponsePending()
Constructs an uninitialized response holder.
Definition: storage.hpp:79
Response to the [edjx::storage::get] request.
Definition: storage.hpp:19
const edjx::stream::ReadStream & get_read_stream() const
Returns a read stream for the storage object.
StorageResponse(const std::map< std::string, std::string > &headers, const edjx::stream::ReadStream &read_stream)
Constructs a response with headers and body set to the provided values.
Definition: storage.hpp:37
const std::map< std::string, std::string > & get_headers() const
Returns the metadata associated with the storage object.
edjx::error::StreamError read_body(std::vector< uint8_t > &result)
Retrieves the bytes of the storage object.
edjx::stream::ReadStream read_stream
Body of the response as a read stream.
Definition: storage.hpp:23
std::map< std::string, std::string > headers
HTTP headers of the response.
Definition: storage.hpp:21
StorageResponse()
Constructs a response with no headers and an empty body.
Definition: storage.hpp:28