diff --git a/src/cloud_storage/CloudStorage.h b/src/cloud_storage/CloudStorage.h index 7a88bb55..64fb0cfc 100644 --- a/src/cloud_storage/CloudStorage.h +++ b/src/cloud_storage/CloudStorage.h @@ -587,8 +587,8 @@ class CloudStorage String name, mime; jut.addObject(name, "name", request.options->parent.getObject(), true, true); jut.addObject(mime, "contentType", request.mime, true, true); - owriter.addMember(request.options->payload, name, "}"); - owriter.addMember(request.options->payload, mime, "}"); + owriter.addMember(request.options->payload, name, false, "}"); + owriter.addMember(request.options->payload, mime, false, "}"); sData->request.file_data.multipart.setOptions(request.options->payload); request.options->payload.remove(0, request.options->payload.length()); request.aClient->setFileContentLength(sData, sData->request.file_data.multipart.getOptions().length() + sData->request.file_data.multipart.getLast().length(), "Content-Length"); diff --git a/src/cloud_storage/DataOptions.h b/src/cloud_storage/DataOptions.h index 7f1cbce1..a68ac4fb 100644 --- a/src/cloud_storage/DataOptions.h +++ b/src/cloud_storage/DataOptions.h @@ -330,27 +330,27 @@ namespace GoogleCloudStorage // https://cloud.google.com/storage/docs/access-control/lists // This value represents the item to add to an array. - InsertProperties &acl(const String &value) { return wr.append(*this, value, buf, bufSize, buf[1], FPSTR(__func__)); } - InsertProperties &cacheControl(const String &value) { return wr.set(*this, value, buf, bufSize, buf[2], FPSTR(__func__)); } - InsertProperties &contentDisposition(const String &value) { return wr.set(*this, value, buf, bufSize, buf[3], FPSTR(__func__)); } - InsertProperties &contentEncoding(const String &value) { return wr.set(*this, value, buf, bufSize, buf[4], FPSTR(__func__)); } - InsertProperties &contentLanguage(const String &value) { return wr.set(*this, value, buf, bufSize, buf[5], FPSTR(__func__)); } - InsertProperties &contentType(const String &value) { return wr.set(*this, value, buf, bufSize, buf[6], FPSTR(__func__)); } - InsertProperties &crc32c(const String &value) { return wr.set(*this, value, buf, bufSize, buf[7], FPSTR(__func__)); } - InsertProperties &customTime(const String &value) { return wr.set(*this, value, buf, bufSize, buf[8], FPSTR(__func__)); } - InsertProperties &eventBasedHold(bool value) { return wr.set(*this, value, buf, bufSize, buf[9], FPSTR(__func__)); } - InsertProperties &md5Hash(const String &value) { return wr.set(*this, value, buf, bufSize, buf[10], FPSTR(__func__)); } + InsertProperties &acl(const String &value) { return wr.append(*this, value, buf, bufSize, 1, FPSTR(__func__)); } + InsertProperties &cacheControl(const String &value) { return wr.set(*this, value, buf, bufSize, 2, FPSTR(__func__)); } + InsertProperties &contentDisposition(const String &value) { return wr.set(*this, value, buf, bufSize, 3, FPSTR(__func__)); } + InsertProperties &contentEncoding(const String &value) { return wr.set(*this, value, buf, bufSize, 4, FPSTR(__func__)); } + InsertProperties &contentLanguage(const String &value) { return wr.set(*this, value, buf, bufSize, 5, FPSTR(__func__)); } + InsertProperties &contentType(const String &value) { return wr.set(*this, value, buf, bufSize, 6, FPSTR(__func__)); } + InsertProperties &crc32c(const String &value) { return wr.set(*this, value, buf, bufSize, 7, FPSTR(__func__)); } + InsertProperties &customTime(const String &value) { return wr.set(*this, value, buf, bufSize, 8, FPSTR(__func__)); } + InsertProperties &eventBasedHold(bool value) { return wr.set(*this, value, buf, bufSize, 9, FPSTR(__func__)); } + InsertProperties &md5Hash(const String &value) { return wr.set(*this, value, buf, bufSize, 10, FPSTR(__func__)); } InsertProperties &metadata(const object_t value) { buf[11] = FPSTR("{\"metadata\":{\"firebaseStorageDownloadTokens\":\"a82781ce-a115-442f-bac6-a52f7f63b3e8\"}}"); if (strlen(value.c_str())) - owriter.addMember(buf[11], value.c_str()); + owriter.addMember(buf[11], value.c_str(), false); owriter.getBuf(buf, bufSize); return *this; } - InsertProperties &retention(const object_t value) { return wr.set(*this, value, buf, bufSize, buf[12], FPSTR(__func__)); } - InsertProperties &storageClass(const String &value) { return wr.set(*this, value, buf, bufSize, buf[13], FPSTR(__func__)); } - InsertProperties &temporaryHold(bool value) { return wr.set(*this, value, buf, bufSize, buf[14], FPSTR(__func__)); } + InsertProperties &retention(const object_t value) { return wr.set(*this, value, buf, bufSize, 12, FPSTR(__func__)); } + InsertProperties &storageClass(const String &value) { return wr.set(*this, value, buf, bufSize, 13, FPSTR(__func__)); } + InsertProperties &temporaryHold(bool value) { return wr.set(*this, value, buf, bufSize, 14, FPSTR(__func__)); } }; class Parent diff --git a/src/core/ObjectWriter.h b/src/core/ObjectWriter.h index d8be7ee7..178031dc 100644 --- a/src/core/ObjectWriter.h +++ b/src/core/ObjectWriter.h @@ -38,7 +38,7 @@ class ObjectWriter JSONUtil jut; public: - void addMember(String &buf, const String &v, const String &token = "}}") + void addMember(String &buf, const String &v, bool isString, const String &token = "}}") { int p = buf.lastIndexOf(token); String str = buf.substring(0, p); @@ -46,12 +46,23 @@ class ObjectWriter // Add to object if (token[0] == '}') { - String tmp = v; + String tmp; + if (isString) + tmp += '"'; + tmp += v; + if (isString) + tmp += '"'; str += tmp.substring(1, tmp.length() - 1); } // Add to array else + { + if (isString) + str += '"'; str += v; + if (isString) + str += '"'; + } str += token; buf = str; } @@ -65,22 +76,25 @@ class ObjectWriter if (buf.length() == 0) buf = object; else - addMember(buf, object, token); + addMember(buf, object, false, token); } } - void addMapArrayMember(String *buf, size_t size, String &buf_n, const String &key, const String &memberValue, bool isString) + void addMapArrayMember(String *buf, size_t size, uint8_t index, const String &key, const String &memberValue, bool isString) { - if (buf_n.length() == 0) + if (index < size) { - String temp; - jut.addArray(temp, memberValue, isString, true); - jut.addObject(buf_n, key, temp, false, true); - } - else - addMember(buf_n, isString ? jut.toString(memberValue) : memberValue, "]}"); + if (buf[index].length() == 0) + { + String temp; + jut.addArray(temp, memberValue, isString, true); + jut.addObject(buf[index], key, temp, false, true); + } + else + addMember(buf[index], memberValue, isString, "]}"); - getBuf(buf, size); + getBuf(buf, size); + } } void getBuf(String *buf, size_t size) @@ -90,14 +104,17 @@ class ObjectWriter addObject(buf[0], buf[i], "}", i == 0); } - void setObject(String *buf, size_t size, String &buf_n, const String &key, const String &value, bool isString, bool last) + void setObject(String *buf, size_t size, uint8_t index, const String &key, const String &value, bool isString, bool last) { - if (key.length()) + if (index < size) { - clear(buf_n); - jut.addObject(buf_n, key, value, isString, last); + if (key.length()) + { + clear(buf[index]); + jut.addObject(buf[index], key, value, isString, last); + } + getBuf(buf, size); } - getBuf(buf, size); } void clearBuf(String *buf, size_t size) @@ -171,9 +188,9 @@ class BufWriter static bool const value = std::is_same::value || std::is_same::value || std::is_same::value; }; - void setObject(String *buf, size_t bufSize, String &buf_n, const String &key, const String &value, bool isString, bool last) + void setObject(String *buf, size_t bufSize, uint8_t index, const String &key, const String &value, bool isString, bool last) { - owriter.setObject(buf, bufSize, buf_n, key, value, isString, last); + owriter.setObject(buf, bufSize, index, key, value, isString, last); } public: @@ -211,58 +228,58 @@ class BufWriter } template - T1 set(T1 ret, bool value, String *buf, size_t bufSize, String &buf_n, const String &name) + T1 set(T1 ret, bool value, String *buf, size_t bufSize, uint8_t index, const String &name) { - setObject(buf, bufSize, buf_n, name, owriter.getBoolStr(value), false, true); + setObject(buf, bufSize, index, name, owriter.getBoolStr(value), false, true); return ret; } template - auto set(T1 ret, const T2 &value, String *buf, size_t bufSize, String &buf_n, const String &name) -> typename std::enable_if::value, T1>::type + auto set(T1 ret, const T2 &value, String *buf, size_t bufSize, uint8_t index, const String &name) -> typename std::enable_if::value, T1>::type { - setObject(buf, bufSize, buf_n, name, String(value), false, true); + setObject(buf, bufSize, index, name, String(value), false, true); return ret; } template - auto set(T1 ret, const T2 &value, String *buf, size_t bufSize, String &buf_n, const String &name) -> typename std::enable_if::value, T1>::type + auto set(T1 ret, const T2 &value, String *buf, size_t bufSize, uint8_t index, const String &name) -> typename std::enable_if::value, T1>::type { - setObject(buf, bufSize, buf_n, name, value, true, true); + setObject(buf, bufSize, index, name, value, true, true); return ret; } template - auto set(T1 ret, const T2 &value, String *buf, size_t bufSize, String &buf_n, const String &name) -> typename std::enable_if<(!v_sring::value && !v_number::value && !std::is_same::value), T1>::type + auto set(T1 ret, const T2 &value, String *buf, size_t bufSize, uint8_t index, const String &name) -> typename std::enable_if<(!v_sring::value && !v_number::value && !std::is_same::value), T1>::type { - setObject(buf, bufSize, buf_n, name, value.c_str(), false, true); + setObject(buf, bufSize, index, name, value.c_str(), false, true); return ret; } template - T1 append(T1 ret, bool value, String *buf, size_t bufSize, String &buf_n, const String &name) + T1 append(T1 ret, bool value, String *buf, size_t bufSize, uint8_t index, const String &name) { - owriter.addMapArrayMember(buf, bufSize, buf_n, name, owriter.getBoolStr(value), false); + owriter.addMapArrayMember(buf, bufSize, index, name, owriter.getBoolStr(value), false); return ret; } template - auto append(T1 ret, const T2 &value, String *buf, size_t bufSize, String &buf_n, const String &name) -> typename std::enable_if::value, T1>::type + auto append(T1 ret, const T2 &value, String *buf, size_t bufSize, uint8_t index, const String &name) -> typename std::enable_if::value, T1>::type { - owriter.addMapArrayMember(buf, bufSize, buf_n, name, String(value), false); + owriter.addMapArrayMember(buf, bufSize, index, name, String(value), false); return ret; } template - auto append(T1 ret, const T2 &value, String *buf, size_t bufSize, String &buf_n, const String &name) -> typename std::enable_if::value, T1>::type + auto append(T1 ret, const T2 &value, String *buf, size_t bufSize, uint8_t index, const String &name) -> typename std::enable_if::value, T1>::type { - owriter.addMapArrayMember(buf, bufSize, buf_n, name, value, true); + owriter.addMapArrayMember(buf, bufSize, index, name, value, true); return ret; } template - auto append(T1 ret, const T2 &value, String *buf, size_t bufSize, String &buf_n, const String &name) -> typename std::enable_if<(!v_sring::value && !v_number::value && !std::is_same::value), T1>::type + auto append(T1 ret, const T2 &value, String *buf, size_t bufSize, uint8_t index, const String &name) -> typename std::enable_if<(!v_sring::value && !v_number::value && !std::is_same::value), T1>::type { - owriter.addMapArrayMember(buf, bufSize, buf_n, name, value.c_str(), false); + owriter.addMapArrayMember(buf, bufSize, index, name, value.c_str(), false); return ret; } void clear(String &buf) { buf.remove(0, buf.length()); } @@ -479,7 +496,7 @@ namespace firebase class UnityRange { - public: + public: UnityRange() {} float val(float value) diff --git a/src/firestore/DataOptions.h b/src/firestore/DataOptions.h index 88913f79..40821e66 100644 --- a/src/firestore/DataOptions.h +++ b/src/firestore/DataOptions.h @@ -79,7 +79,6 @@ class DocumentMask : public BaseO2 friend class Documents; private: - ObjectWriter owriter; String get() @@ -91,7 +90,6 @@ class DocumentMask : public BaseO2 } public: - /** * A set of field paths on a document. * Used to restrict a get or update operation on a document to a subset of its fields. @@ -155,7 +153,6 @@ namespace FieldTransform ObjectWriter owriter; public: - /** * Increment object to use with FieldTransform object class constructor. * @param value Adds the given value to the field's current value. @@ -178,7 +175,6 @@ namespace FieldTransform ObjectWriter owriter; public: - /** * Maximum object to use with FieldTransform object class constructor. * @param value Sets the field to the maximum of its current value and the given value. @@ -201,7 +197,6 @@ namespace FieldTransform ObjectWriter owriter; public: - /** * Mainimum object to use with FieldTransform object class constructor. * @param value Sets the field to the minimum of its current value and the given value. @@ -224,7 +219,6 @@ namespace FieldTransform ObjectWriter owriter; public: - /** * Append the given elements in order if they are not already present in the current field value. * If the field is not an array, or if the field does not yet exist, it is first set to the empty array. @@ -248,7 +242,6 @@ namespace FieldTransform ObjectWriter owriter; public: - /** * Remove all of the given elements from the array in the field. * If the field is not an array, or if the field does not yet exist, it is set to the empty array. @@ -269,7 +262,6 @@ namespace FieldTransform JSONUtil jut; public: - /** * Sets the field to the given server value. * @param enumValue The ServerValue enum @@ -299,7 +291,6 @@ namespace FieldTransform } public: - /** * @param fieldPath The path of the field. * @param object The Increment, Maximum and Minimum objects. @@ -307,15 +298,15 @@ namespace FieldTransform */ template FieldTransform(const String &fieldPath, T object) { set(fieldPath, object); } - + /** * @param fieldPath The path of the field. * @param arrayValue Append the given elements in order if they are not already present in the current field value. * If the field is not an array, or if the field does not yet exist, it is first set to the empty array. */ - + FieldTransform(const String &fieldPath, AppendMissingElements arrayvalue) { set(fieldPath, arrayvalue); } - + /** * @param fieldPath The path of the field. * @param arrayValue Remove all of the given elements from the array in the field. @@ -445,13 +436,12 @@ class Document : public BaseO4 buf[0] = buf[3]; if (buf[2].length()) - owriter.addMember(buf[0], buf[2], "}"); + owriter.addMember(buf[0], buf[2], false, "}"); return *this; } public: - /** * A Firestore document constructor with document resource name. * @param name The resource name of the document. @@ -578,41 +568,40 @@ namespace Firestore friend class Databases; public: - // This value represents the item to add to an array. // Set the concurrency control mode to use for this database (used in database creation). - Database &concurrencyMode(ConcurrencyMode value) { return wr.append(*this, _ConcurrencyMode[value].text, buf, bufSize, buf[1], FPSTR(__func__)); } + Database &concurrencyMode(ConcurrencyMode value) { return wr.append(*this, _ConcurrencyMode[value].text, buf, bufSize, 1, FPSTR(__func__)); } // This value represents the item to add to an array. // Set the App Engine integration mode to use for this database (used in database creation). - Database &appEngineIntegrationMode(AppEngineIntegrationMode value) { return wr.append(*this, _AppEngineIntegrationMode[value].text, buf, bufSize, buf[2], FPSTR(__func__)); } + Database &appEngineIntegrationMode(AppEngineIntegrationMode value) { return wr.append(*this, _AppEngineIntegrationMode[value].text, buf, bufSize, 2, FPSTR(__func__)); } // This value represents the item to add to an array. // Set the state of delete protection for the database (used in database creation). - Database &deleteProtectionState(DeleteProtectionState value) { return wr.append(*this, _DeleteProtectionState[value].text, buf, bufSize, buf[3], FPSTR(__func__)); } + Database &deleteProtectionState(DeleteProtectionState value) { return wr.append(*this, _DeleteProtectionState[value].text, buf, bufSize, 3, FPSTR(__func__)); } // This value represents the item to add to an array. // Set to enable the PITR feature on this database (used in database creation). - Database &pointInTimeRecoveryEnablement(PointInTimeRecoveryEnablement value) { return wr.append(*this, _PointInTimeRecoveryEnablement[value].text, buf, bufSize, buf[4], FPSTR(__func__)); } + Database &pointInTimeRecoveryEnablement(PointInTimeRecoveryEnablement value) { return wr.append(*this, _PointInTimeRecoveryEnablement[value].text, buf, bufSize, 4, FPSTR(__func__)); } // This value represents the item to add to an array. // Set the type of the database (used in database creation). See https://cloud.google.com/datastore/docs/firestore-or-datastore for information about how to choose. - Database &databaseType(DatabaseType value) { return wr.append(*this, _DatabaseType[value].text, buf, bufSize, buf[5], FPSTR(__func__)); } + Database &databaseType(DatabaseType value) { return wr.append(*this, _DatabaseType[value].text, buf, bufSize, 5, FPSTR(__func__)); } // This value represents the item to add to an array. // Set the location of the database (used in database creation). // Available locations are listed at https://cloud.google.com/firestore/docs/locations. - Database &locationId(const String &value) { return wr.append(*this, value, buf, bufSize, buf[6], FPSTR(__func__)); } + Database &locationId(const String &value) { return wr.append(*this, value, buf, bufSize, 6, FPSTR(__func__)); } // This value represents the item to add to an array. // Set the resource name of the Database (used in database creation). // Format: projects/{project}/databases/{database} - Database &name(const String &value) { return wr.append(*this, value, buf, bufSize, buf[7], FPSTR(__func__)); } + Database &name(const String &value) { return wr.append(*this, value, buf, bufSize, 7, FPSTR(__func__)); } // This value represents the item to add to an array. // Set the ETag (used in database update and deletion) // This checksum is computed by the server based on the value of other fields, and may be sent on update and delete requests to ensure the client has an up-to-date value before proceeding. - Database &etag(const String &value) { return wr.append(*this, value, buf, bufSize, buf[8], FPSTR(__func__)); } + Database &etag(const String &value) { return wr.append(*this, value, buf, bufSize, 8, FPSTR(__func__)); } }; } @@ -630,7 +619,6 @@ class DocumentTransform : public BaseO1 JSONUtil jut; public: - /** * A transformation of a document. * @param document The name of the document to transform. @@ -665,7 +653,6 @@ class Write : public BaseO1 bool updateTrans = false; public: - /** * A write on a document. * @param updateMask The fields to update in this write. This field can be set only when the operation is update. @@ -729,7 +716,7 @@ class Write : public BaseO1 jut.addObject(buf, FPSTR("updateTransforms"), owriter.getArrayStr(updateTransforms.c_str()), false, true); } else - owriter.addMember(buf, updateTransforms.c_str(), "]}"); + owriter.addMember(buf, updateTransforms.c_str(), false, "]}"); updateTrans = true; } @@ -747,7 +734,6 @@ class Writes : public BaseO1 ObjectWriter owriter; public: - /** * The writes to apply. * @param write A write on a document. @@ -781,7 +767,7 @@ class Writes : public BaseO1 Writes &add(const Write &write) { ObjectWriter owriter; - owriter.addMember(buf, write.c_str(), "]}"); + owriter.addMember(buf, write.c_str(), false, "]}"); return *this; } }; @@ -795,7 +781,6 @@ class ReadWrite : public BaseO1 JSONUtil jut; public: - /** * @param retryTransaction An optional transaction to retry. * A base64-encoded string. @@ -910,23 +895,23 @@ class BatchGetDocumentOptions : public BaseO4 // This value represents the item to add to an array. // The names of the documents to retrieve. // The item or value will be added to the array or list. - BatchGetDocumentOptions &documents(const String &value) { return wr.append(*this, owriter.makeResourcePath(value, true), buf, bufSize, buf[1], FPSTR(__func__)); } + BatchGetDocumentOptions &documents(const String &value) { return wr.append(*this, owriter.makeResourcePath(value, true), buf, bufSize, 1, FPSTR(__func__)); } // The fields to return. If not set, returns all fields. - BatchGetDocumentOptions &mask(const DocumentMask &value) { return wr.set(*this, value, buf, bufSize, buf[2], FPSTR(__func__)); } + BatchGetDocumentOptions &mask(const DocumentMask &value) { return wr.set(*this, value, buf, bufSize, 2, FPSTR(__func__)); } // Union field consistency_selector // Timestamp Reads documents in a transaction. - BatchGetDocumentOptions &transaction(const String &value) { return wr.set(*this, value, buf, bufSize, buf[3], FPSTR(__func__)); } + BatchGetDocumentOptions &transaction(const String &value) { return wr.set(*this, value, buf, bufSize, 3, FPSTR(__func__)); } // Union field consistency_selector // Starts a new transaction and reads the documents. Defaults to a read-only transaction. // The new transaction ID will be returned as the first response in the stream. - BatchGetDocumentOptions &newTransaction(const TransactionOptions &value) { return wr.set(*this, value, buf, bufSize, buf[3], FPSTR(__func__)); } + BatchGetDocumentOptions &newTransaction(const TransactionOptions &value) { return wr.set(*this, value, buf, bufSize, 3, FPSTR(__func__)); } // Union field consistency_selector // Timestamp. Reads documents as they were at the given time. - BatchGetDocumentOptions &readTime(const String &value) { return wr.set(*this, value, buf, bufSize, buf[3], FPSTR(__func__)); } + BatchGetDocumentOptions &readTime(const String &value) { return wr.set(*this, value, buf, bufSize, 3, FPSTR(__func__)); } }; class PatchDocumentOptions : public BaseO1 @@ -972,24 +957,24 @@ class QueryOptions : public BaseO4 QueryOptions() {} // Optional. Explain options for the query. If set, additional query statistics will be returned. If not, only query results will be returned. - QueryOptions &explainOptions(const ExplainOptions &value) { return wr.set(*this, value, buf, bufSize, buf[1], FPSTR(__func__)); } + QueryOptions &explainOptions(const ExplainOptions &value) { return wr.set(*this, value, buf, bufSize, 1, FPSTR(__func__)); } // A structured query. - QueryOptions &structuredQuery(const StructuredQuery &value) { return wr.set(*this, value, buf, bufSize, buf[2], FPSTR(__func__)); } + QueryOptions &structuredQuery(const StructuredQuery &value) { return wr.set(*this, value, buf, bufSize, 2, FPSTR(__func__)); } // Union field consistency_selector // Run the query within an already active transaction. - QueryOptions &transaction(const String &value) { return wr.set(*this, value, buf, bufSize, buf[3], FPSTR(__func__)); } + QueryOptions &transaction(const String &value) { return wr.set(*this, value, buf, bufSize, 3, FPSTR(__func__)); } // Union field consistency_selector // Starts a new transaction and reads the documents. Defaults to a read-only transaction. // The new transaction ID will be returned as the first response in the stream. - QueryOptions &newTransaction(const TransactionOptions &value) { return wr.set(*this, value, buf, bufSize, buf[3], FPSTR(__func__)); } + QueryOptions &newTransaction(const TransactionOptions &value) { return wr.set(*this, value, buf, bufSize, 3, FPSTR(__func__)); } // Union field consistency_selector // Timestamp. Reads documents as they were at the given time. // This must be a microsecond precision timestamp within the past one hour,or if Point-in-Time Recovery is enabled, can additionally be a whole minute timestamp within the past 7 days. - QueryOptions &readTime(const String &value) { return wr.set(*this, value, buf, bufSize, buf[3], FPSTR(__func__)); } + QueryOptions &readTime(const String &value) { return wr.set(*this, value, buf, bufSize, 3, FPSTR(__func__)); } }; #endif @@ -1105,13 +1090,13 @@ class ListCollectionIdsOptions : public BaseO4 * The maximum number of results to return. * @param value The maximum number of results to return. */ - ListCollectionIdsOptions &pageSize(int value) { return wr.set(*this, value, buf, bufSize, buf[1], FPSTR(__func__)); } + ListCollectionIdsOptions &pageSize(int value) { return wr.set(*this, value, buf, bufSize, 1, FPSTR(__func__)); } /** * A page token. Must be a value from ListCollectionIdsResponse. * @param value A page token. Must be a value from ListCollectionIdsResponse. */ - ListCollectionIdsOptions &pageToken(const String &value) { return wr.set(*this, value, buf, bufSize, buf[2], FPSTR(__func__)); } + ListCollectionIdsOptions &pageToken(const String &value) { return wr.set(*this, value, buf, bufSize, 2, FPSTR(__func__)); } /** * Reads documents as they were at the given time. @@ -1119,7 +1104,7 @@ class ListCollectionIdsOptions : public BaseO4 * or if Point-in-Time Recovery is enabled, can additionally be a whole minute timestamp within the past 7 days. * @param value Timestamp */ - ListCollectionIdsOptions &readTime(const String value) { return wr.set(*this, value, buf, bufSize, buf[3], FPSTR(__func__)); } + ListCollectionIdsOptions &readTime(const String value) { return wr.set(*this, value, buf, bufSize, 3, FPSTR(__func__)); } }; // Ref https://firebase.google.com/docs/firestore/reference/rest/v1beta1/projects.databases.indexes @@ -1153,10 +1138,10 @@ namespace DatabaseIndex IndexField() {} // The path of the field. Must match the field path specification described by [google.firestore.v1beta1.Document.fields][fields]. Special field path __name__ may be used by itself or at the end of a path. __type__ may be used only at the end of path. - IndexField &fieldPath(const String &value) { return wr.set(*this, value, buf, bufSize, buf[1], FPSTR(__func__)); } + IndexField &fieldPath(const String &value) { return wr.set(*this, value, buf, bufSize, 1, FPSTR(__func__)); } // The field's mode. - IndexField &mode(IndexMode::Mode value) { return wr.set(*this, IndexMode::_Mode[value].text, buf, bufSize, buf[2], FPSTR(__func__)); } + IndexField &mode(IndexMode::Mode value) { return wr.set(*this, IndexMode::_Mode[value].text, buf, bufSize, 2, FPSTR(__func__)); } }; /** @@ -1172,11 +1157,11 @@ namespace DatabaseIndex } // The collection ID to which this index applies. Required. - Index &collectionId(const String &value) { return wr.set(*this, value, buf, bufSize, buf[1], FPSTR(__func__)); } + Index &collectionId(const String &value) { return wr.set(*this, value, buf, bufSize, 1, FPSTR(__func__)); } // This value represents the item to add to an array. // The field to index. - Index &fields(const IndexField &value) { return wr.append(*this, value, buf, bufSize, buf[2], FPSTR(__func__)); } + Index &fields(const IndexField &value) { return wr.append(*this, value, buf, bufSize, 2, FPSTR(__func__)); } }; } @@ -1229,17 +1214,16 @@ namespace CollectionGroupsIndex class VectorConfig : public BaseO4 { public: - // Required. The vector dimension this configuration applies to. // The resulting index will only include vectors of this dimension, and can be used for vector search with the same dimension. - VectorConfig &dimension(int value) { return wr.set(*this, value, buf, bufSize, buf[1], FPSTR(__func__)); } - + VectorConfig &dimension(int value) { return wr.set(*this, value, buf, bufSize, 1, FPSTR(__func__)); } + // Indicates the vector index is a flat index. - VectorConfig &flat() { return wr.set(*this, "{}", buf, bufSize, buf[2], FPSTR(__func__)); } + VectorConfig &flat() { return wr.set(*this, "{}", buf, bufSize, 2, FPSTR(__func__)); } }; // Ref https://firebase.google.com/docs/firestore/reference/rest/Shared.Types/FieldOperationMetadata#IndexField - + /** * A field in an index. The fieldPath describes which field is indexed, the value_mode describes how the field value is indexed. */ @@ -1249,19 +1233,19 @@ namespace CollectionGroupsIndex IndexField() {} // Can be name. For single field indexes, this must match the name of the field or may be omitted. - IndexField &fieldPath(const String &value) { return wr.set(*this, value, buf, bufSize, buf[1], FPSTR(__func__)); } - + IndexField &fieldPath(const String &value) { return wr.set(*this, value, buf, bufSize, 1, FPSTR(__func__)); } + // Union field value_mode // Indicates that this field supports ordering by the specified order or comparing using =, !=, <, <=, >, >=. - IndexField &order(const Order &value) { return wr.set(*this, _Order[value].text, buf, bufSize, buf[2], FPSTR(__func__)); } - + IndexField &order(const Order &value) { return wr.set(*this, _Order[value].text, buf, bufSize, 2, FPSTR(__func__)); } + // Union field value_mode // Indicates that this field supports ordering by the specified order or comparing using =, !=, <, <=, >, >=. - IndexField &arrayConfig(const ArrayConfig &value) { return wr.set(*this, _ArrayConfig[value].text, buf, bufSize, buf[2], FPSTR(__func__)); } - + IndexField &arrayConfig(const ArrayConfig &value) { return wr.set(*this, _ArrayConfig[value].text, buf, bufSize, 2, FPSTR(__func__)); } + // Union field value_mode // Indicates that this field supports nearest neighbors and distance operations on vector. - IndexField &vectorConfig(const VectorConfig &value) { return wr.set(*this, value, buf, bufSize, buf[2], FPSTR(__func__)); } + IndexField &vectorConfig(const VectorConfig &value) { return wr.set(*this, value, buf, bufSize, 2, FPSTR(__func__)); } }; /** @@ -1271,17 +1255,17 @@ namespace CollectionGroupsIndex { public: Index() {} - + // Indexes with a collection query scope specified allow queries against a collection that is the child of a specific document, specified at query time, and that has the same collection id. - Index &queryScope(const QueryScope &value) { return wr.set(*this, _QueryScope[value].text, buf, bufSize, buf[1], FPSTR(__func__)); } - + Index &queryScope(const QueryScope &value) { return wr.set(*this, _QueryScope[value].text, buf, bufSize, 1, FPSTR(__func__)); } + // Indexes with a collection query scope specified allow queries against a collection that is the child of a specific document, specified at query time, and that has the same collection id. - Index &apiScope(const ApiScope &value) { return wr.set(*this, _ApiScope[value].text, buf, bufSize, buf[2], FPSTR(__func__)); } - + Index &apiScope(const ApiScope &value) { return wr.set(*this, _ApiScope[value].text, buf, bufSize, 2, FPSTR(__func__)); } + // This value represents the item to add to an array. // Add the field that supported by this index. - Index &fields(const IndexField &value) { return wr.append(*this, value, buf, bufSize, buf[3], FPSTR(__func__)); } - + Index &fields(const IndexField &value) { return wr.append(*this, value, buf, bufSize, 3, FPSTR(__func__)); } + // Obsoleted, use fields instead. Index &addField(const IndexField &value) { return fields(value); } }; diff --git a/src/firestore/Query.cpp b/src/firestore/Query.cpp index 8e886792..b969af53 100644 --- a/src/firestore/Query.cpp +++ b/src/firestore/Query.cpp @@ -37,37 +37,37 @@ namespace FirestoreQuery { StructuredQuery::StructuredQuery() {} - StructuredQuery &StructuredQuery::select(const Projection &value) { return wr.set(*this, value, buf, bufSize, buf[1], FPSTR(__func__)); } - StructuredQuery &StructuredQuery::from(const CollectionSelector &value) { return wr.append(*this, value, buf, bufSize, buf[2], FPSTR(__func__)); } - StructuredQuery &StructuredQuery::where(const Filter &value) { return wr.set(*this, value, buf, bufSize, buf[3], FPSTR(__func__)); } - StructuredQuery &StructuredQuery::orderBy(const Order &value) { return wr.append(*this, value, buf, bufSize, buf[4], FPSTR(__func__)); } - StructuredQuery &StructuredQuery::startAt(const Cursor &value) { return wr.set(*this, value, buf, bufSize, buf[5], FPSTR(__func__)); } - StructuredQuery &StructuredQuery::endAt(const Cursor &value) { return wr.set(*this, value, buf, bufSize, buf[6], FPSTR(__func__)); } - StructuredQuery &StructuredQuery::offset(int value) { return wr.set(*this, value, buf, bufSize, buf[7], FPSTR(__func__)); } - StructuredQuery &StructuredQuery::limit(int value) { return wr.set(*this, value, buf, bufSize, buf[8], FPSTR(__func__)); } + StructuredQuery &StructuredQuery::select(const Projection &value) { return wr.set(*this, value, buf, bufSize, 1, FPSTR(__func__)); } + StructuredQuery &StructuredQuery::from(const CollectionSelector &value) { return wr.append(*this, value, buf, bufSize, 2, FPSTR(__func__)); } + StructuredQuery &StructuredQuery::where(const Filter &value) { return wr.set(*this, value, buf, bufSize, 3, FPSTR(__func__)); } + StructuredQuery &StructuredQuery::orderBy(const Order &value) { return wr.append(*this, value, buf, bufSize, 4, FPSTR(__func__)); } + StructuredQuery &StructuredQuery::startAt(const Cursor &value) { return wr.set(*this, value, buf, bufSize, 5, FPSTR(__func__)); } + StructuredQuery &StructuredQuery::endAt(const Cursor &value) { return wr.set(*this, value, buf, bufSize, 6, FPSTR(__func__)); } + StructuredQuery &StructuredQuery::offset(int value) { return wr.set(*this, value, buf, bufSize, 7, FPSTR(__func__)); } + StructuredQuery &StructuredQuery::limit(int value) { return wr.set(*this, value, buf, bufSize, 8, FPSTR(__func__)); } CompositeFilter::CompositeFilter() {} - CompositeFilter &CompositeFilter::op(CompositFilterOperator::OPERATOR_TYPE value) { return wr.set(*this, CompositFilterOperator::_OPERATOR_TYPE[value].text, buf, bufSize, buf[1], FPSTR(__func__)); } - CompositeFilter &CompositeFilter::filters(const Filter &value) { return wr.append(*this, value, buf, bufSize, buf[2], FPSTR(__func__)); } + CompositeFilter &CompositeFilter::op(CompositFilterOperator::OPERATOR_TYPE value) { return wr.set(*this, CompositFilterOperator::_OPERATOR_TYPE[value].text, buf, bufSize, 1, FPSTR(__func__)); } + CompositeFilter &CompositeFilter::filters(const Filter &value) { return wr.append(*this, value, buf, bufSize, 2, FPSTR(__func__)); } CompositeFilter &CompositeFilter::addFilter(const Filter &value) { return filters(value); } FieldFilter::FieldFilter() {} - FieldFilter &FieldFilter::field(const FieldReference &value) { return wr.set(*this, value, buf, bufSize, buf[1], FPSTR(__func__)); } - FieldFilter &FieldFilter::op(FieldFilterOperator::OPERATOR_TYPE value) { return wr.set(*this, FieldFilterOperator::_OPERATOR_TYPE[value].text, buf, bufSize, buf[2], FPSTR(__func__)); } - FieldFilter &FieldFilter::value(const Values::Value &value) { return wr.set(*this, value, buf, bufSize, buf[3], FPSTR(__func__)); } + FieldFilter &FieldFilter::field(const FieldReference &value) { return wr.set(*this, value, buf, bufSize, 1, FPSTR(__func__)); } + FieldFilter &FieldFilter::op(FieldFilterOperator::OPERATOR_TYPE value) { return wr.set(*this, FieldFilterOperator::_OPERATOR_TYPE[value].text, buf, bufSize, 2, FPSTR(__func__)); } + FieldFilter &FieldFilter::value(const Values::Value &value) { return wr.set(*this, value, buf, bufSize, 3, FPSTR(__func__)); } UnaryFilter::UnaryFilter() {} - UnaryFilter &UnaryFilter::op(UnaryFilterOperator::OPERATOR_TYPE value) { return wr.set(*this, UnaryFilterOperator::_OPERATOR_TYPE[value].text, buf, bufSize, buf[1], FPSTR(__func__)); } - UnaryFilter &UnaryFilter::field(const FieldReference &value) { return wr.set(*this, value, buf, bufSize, buf[2], FPSTR(__func__)); } + UnaryFilter &UnaryFilter::op(UnaryFilterOperator::OPERATOR_TYPE value) { return wr.set(*this, UnaryFilterOperator::_OPERATOR_TYPE[value].text, buf, bufSize, 1, FPSTR(__func__)); } + UnaryFilter &UnaryFilter::field(const FieldReference &value) { return wr.set(*this, value, buf, bufSize, 2, FPSTR(__func__)); } Order::Order(){}; Order::Order(const FieldReference &field, FilterSort::Direction direction) { Order::field(field).direction(direction); } - Order &Order::field(const FieldReference &value) { return wr.set(*this, value, buf, bufSize, buf[1], FPSTR(__func__)); } - Order &Order::direction(FilterSort::Direction value) { return wr.set(*this, FilterSort::_Direction[value].text, buf, bufSize, buf[2], FPSTR(__func__)); } + Order &Order::field(const FieldReference &value) { return wr.set(*this, value, buf, bufSize, 1, FPSTR(__func__)); } + Order &Order::direction(FilterSort::Direction value) { return wr.set(*this, FilterSort::_Direction[value].text, buf, bufSize, 2, FPSTR(__func__)); } - Cursor::Cursor() { wr.set(*this, "[]", buf, bufSize, buf[2], "values"); } - Cursor &Cursor::before(bool value) { return wr.set(*this, value, buf, bufSize, buf[1], FPSTR(__func__)); } - Cursor &Cursor::values(const Values::Value &value) { return wr.append(*this, value, buf, bufSize, buf[2], FPSTR(__func__)); } + Cursor::Cursor() { wr.set(*this, "[]", buf, bufSize, 2, "values"); } + Cursor &Cursor::before(bool value) { return wr.set(*this, value, buf, bufSize, 1, FPSTR(__func__)); } + Cursor &Cursor::values(const Values::Value &value) { return wr.append(*this, value, buf, bufSize, 2, FPSTR(__func__)); } Cursor &Cursor::addValue(const Values::Value &value) { return values(value); } Filter::Filter() {} diff --git a/src/firestore/Query.h b/src/firestore/Query.h index ba42055d..501ba682 100644 --- a/src/firestore/Query.h +++ b/src/firestore/Query.h @@ -115,10 +115,9 @@ namespace FirestoreQuery { public: - // A reference to a field in a document. FieldReference(const String &value) { fieldPath(value); } - + // A reference to a field in a document. FieldReference &fieldPath(const String &value) { return wr.add(*this, value, buf, FPSTR(__func__)); } }; @@ -129,14 +128,13 @@ namespace FirestoreQuery class Projection : public BaseO2 { public: - // A reference to a field in a document. Projection(const FieldReference &value) { Projection::fields(value); } - + // This value represents the item to add to an array. // A reference to a field in a document. - Projection &fields(const FieldReference &value) { return wr.append(*this, value, buf, bufSize, buf[1], FPSTR(__func__)); } - + Projection &fields(const FieldReference &value) { return wr.append(*this, value, buf, bufSize, 1, FPSTR(__func__)); } + // Obsoleted, use fields instead. Projection &add(const FieldReference &value) { return fields(value); } }; @@ -152,10 +150,10 @@ namespace FirestoreQuery public: Order(); Order(const FieldReference &field, FilterSort::Direction direction); - + // The field to order by. Order &field(const FieldReference &value); - + // The direction to order by. Defaults to ASCENDING. Order &direction(FilterSort::Direction value); }; @@ -169,12 +167,12 @@ namespace FirestoreQuery public: CollectionSelector() {} CollectionSelector(const String &collectionId, bool allDescendants) { CollectionSelector::collectionId(collectionId).allDescendants(allDescendants); } - + // The collection ID. When set, selects only collections with this ID. - CollectionSelector &collectionId(const String &value) { return wr.set(*this, value, buf, bufSize, buf[1], FPSTR(__func__)); } - + CollectionSelector &collectionId(const String &value) { return wr.set(*this, value, buf, bufSize, 1, FPSTR(__func__)); } + // When false, selects only collections that are immediate children of the parent specified in the containing RunQueryRequest. When true, selects all descendant collections. - CollectionSelector &allDescendants(bool value) { return wr.set(*this, value, buf, bufSize, buf[2], FPSTR(__func__)); } + CollectionSelector &allDescendants(bool value) { return wr.set(*this, value, buf, bufSize, 2, FPSTR(__func__)); } }; /** @@ -184,16 +182,16 @@ namespace FirestoreQuery { public: Cursor(); - + // The befor option value // If the position is just before or just after the given values, relative to the sort order defined by the query. Cursor &before(bool value); - + // This value represents the item to add to an array. // The value that represent a position, in the order they appear in the order by clause of a query. // Can contain fewer values than specified in the order by clause. Cursor &values(const Values::Value &value); - + // Obsoleted, use values instead. Cursor &addValue(const Values::Value &value); }; @@ -265,7 +263,7 @@ namespace FirestoreQuery // This value represents the item to add to an array. // The Filter. CompositeFilter &filters(const Filter &filter); - + // Obsoleted, use fields instead. CompositeFilter &addFilter(const Filter &filter); }; @@ -295,10 +293,10 @@ namespace FirestoreQuery { public: UnaryFilter(); - + // The unary operator to apply. UnaryFilter &op(UnaryFilterOperator::OPERATOR_TYPE value); - + // The field to which to apply the operator. UnaryFilter &field(const FieldReference &value); }; @@ -310,13 +308,13 @@ namespace FirestoreQuery { public: Filter(); - + // A composite filter. Filter(const CompositeFilter &value); - + // A filter on a document field. Filter(const FieldFilter &fieldFilter); - + // A filter that takes exactly one argument. Filter(const UnaryFilter &unaryFilter); }; diff --git a/src/firestore/Values.h b/src/firestore/Values.h index 449212f4..1e0320bf 100644 --- a/src/firestore/Values.h +++ b/src/firestore/Values.h @@ -79,7 +79,6 @@ namespace Values const char *getVal() { return owriter.setPair(str, firestore_const_key[firestore_const_key_nullValue].text, buf); } public: - /** * A null value. */ @@ -107,7 +106,6 @@ namespace Values const char *getVal() { return owriter.setPair(str, firestore_const_key[firestore_const_key_stringValue].text, buf); } public: - /** * A string value. * @param value The string vakue @@ -135,7 +133,6 @@ namespace Values const char *getVal() { return owriter.setPair(str, firestore_const_key[firestore_const_key_booleanValue].text, buf); } public: - /** * A boolean value. * @param value The boolean value @@ -145,7 +142,7 @@ namespace Values owriter.setBool(buf, value); getVal(); } - const char *c_str() const{ return buf.c_str(); } + const char *c_str() const { return buf.c_str(); } const char *val() { return getVal(); } size_t printTo(Print &p) const { return p.print(str.c_str()); } void clear() @@ -164,7 +161,6 @@ namespace Values const char *getVal() { return owriter.setPair(str, firestore_const_key[firestore_const_key_integerValue].text, buf); } public: - /** * A integer value. * @param value The integer value @@ -174,7 +170,7 @@ namespace Values buf = StringValue(String(value)).c_str(); getVal(); } - const char *c_str() const{ return buf.c_str(); } + const char *c_str() const { return buf.c_str(); } const char *val() { return getVal(); } size_t printTo(Print &p) const { return p.print(str.c_str()); } void clear() @@ -193,7 +189,6 @@ namespace Values const char *getVal() { return owriter.setPair(str, firestore_const_key[firestore_const_key_doubleValue].text, buf); } public: - /** * A double value. * @param value The double value @@ -222,7 +217,6 @@ namespace Values const char *getVal() { return owriter.setPair(str, firestore_const_key[firestore_const_key_timestampValue].text, buf); } public: - /** * A timestamp value. * Precise only to microseconds. When stored, any additional precision is rounded down. @@ -251,7 +245,6 @@ namespace Values const char *getVal() { return owriter.setPair(str, firestore_const_key[firestore_const_key_bytesValue].text, buf); } public: - /** * A bytes value. * Must not exceed 1 MiB - 89 bytes. Only the first 1,500 bytes are considered by queries. @@ -282,7 +275,6 @@ namespace Values const char *getVal() { return owriter.setPair(str, firestore_const_key[firestore_const_key_referenceValue].text, buf); } public: - /** * A reference to a document. * @param value The resource name of document @@ -312,7 +304,6 @@ namespace Values const char *getVal() { return owriter.setPair(str, firestore_const_key[firestore_const_key_geoPointValue].text, buf); } public: - /** * A geo point value representing a point on the surface of Earth. * @param lat The latitude @@ -369,7 +360,6 @@ namespace Values const char *getVal() { return owriter.setPair(str, firestore_const_key[firestore_const_key_arrayValue].text, buf); } public: - /** * An array value. * Cannot directly contain another array value, though can contain an map which contains another array. @@ -395,7 +385,7 @@ namespace Values if (buf.length() == 0) set(value); else - owriter.addMember(buf, value.val(), "]}"); + owriter.addMember(buf, value.val(), false, "]}"); getVal(); } return *this; @@ -455,7 +445,7 @@ namespace Values if (buf.length() == 0) set(key, value); else - owriter.addMember(buf, MAP(key, value, true).c_str()); + owriter.addMember(buf, MAP(key, value, true).c_str(), false); getVal(); return *this; } diff --git a/src/functions/DataOptions.h b/src/functions/DataOptions.h index 975e2e90..280ad515 100644 --- a/src/functions/DataOptions.h +++ b/src/functions/DataOptions.h @@ -56,6 +56,7 @@ namespace GoogleCloudFunctions google_cloud_functions_request_type_set_iam_policy, google_cloud_functions_request_type_test_iam_permission }; + // Severity of the state message. enum Severity { @@ -64,6 +65,7 @@ namespace GoogleCloudFunctions WARNING, // WARNING-level severity. INFO // INFO-level severity. }; + // The environment the function is hosted on. enum Environment { @@ -79,6 +81,7 @@ namespace GoogleCloudFunctions CONTAINER_REGISTRY, // Docker images will be stored in multi-regional Container Registry repositories named gcf. ARTIFACT_REGISTRY // Docker images will be stored in regional Artifact Registry repositories. By default, GCF will create and use repositories named gcf-artifacts in every region in which a function is deployed. But the repository to use can also be specified by the user using the dockerRepository field. }; + // Describes the retry policy in case of function's execution failure. Retried execution is charged as any other execution. enum RetryPolicy { @@ -86,6 +89,7 @@ namespace GoogleCloudFunctions RETRY_POLICY_DO_NOT_RETRY, // Do not retry. RETRY_POLICY_RETRY // Retry on any failure, retry up to 7 days with an exponential backoff (capped at 10 seconds). }; + // This controls what traffic is diverted through the VPC Access Connector resource. By default PRIVATE_RANGES_ONLY will be used. enum VpcConnectorEgressSettings { @@ -93,6 +97,7 @@ namespace GoogleCloudFunctions PRIVATE_RANGES_ONLY, // Use the VPC Access Connector only for private IP space from RFC1918. ALL_TRAFFIC // Force the use of VPC Access Connector for all egress traffic from the function. }; + // Available ingress settings. This controls what traffic can reach the function. // If unspecified, ALLOW_ALL will be used. enum IngressSettings @@ -102,6 +107,7 @@ namespace GoogleCloudFunctions ALLOW_INTERNAL_ONLY, // Allow HTTP traffic from only private VPC sources. ALLOW_INTERNAL_AND_GCLB // Allow HTTP traffic from private VPC sources and through GCLB. }; + // Available security level settings. // This enforces security protocol on function URL. // Security level is only configurable for 1st Gen functions, @@ -127,27 +133,33 @@ namespace GoogleCloudFunctions { public: // ID of the project that owns the Cloud Source Repository. If omitted, the project ID requesting the build is assumed. - RepoSource &projectId(const String &value) { return wr.set(*this, value, buf, bufSize, buf[1], FPSTR(__func__)); } + RepoSource &projectId(const String &value) { return wr.set(*this, value, buf, bufSize, 1, FPSTR(__func__)); } + // Name of the Cloud Source Repository. - RepoSource &repoName(const String &value) { return wr.set(*this, value, buf, bufSize, buf[2], FPSTR(__func__)); } + RepoSource &repoName(const String &value) { return wr.set(*this, value, buf, bufSize, 2, FPSTR(__func__)); } + // Directory, relative to the source root, in which to run the build. // This must be a relative path. If a step's dir is specified and is an absolute path, // this value is ignored for that step's execution. eg. helloworld (no leading slash allowed) - RepoSource &dir(const String &value) { return wr.set(*this, value, buf, bufSize, buf[3], FPSTR(__func__)); } + RepoSource &dir(const String &value) { return wr.set(*this, value, buf, bufSize, 3, FPSTR(__func__)); } + // Union field revision. // Regex matching branches to build. // The syntax of the regular expressions accepted is the syntax accepted by RE2 // and described at https://github.com/google/re2/wiki/Syntax - RepoSource &branchName(const String &value) { return wr.append(*this, value, buf, bufSize, buf[4], FPSTR(__func__)); } + RepoSource &branchName(const String &value) { return wr.append(*this, value, buf, bufSize, 4, FPSTR(__func__)); } + // Union field revision. // Regex matching tags to build. // The syntax of the regular expressions accepted is the syntax accepted by RE2 // and described at https://github.com/google/re2/wiki/Syntax - RepoSource &tagName(const String &value) { return wr.append(*this, value, buf, bufSize, buf[4], FPSTR(__func__)); } + RepoSource &tagName(const String &value) { return wr.append(*this, value, buf, bufSize, 4, FPSTR(__func__)); } + // Union field revision. // Explicit commit SHA to build. - RepoSource &commitSha(const String &value) { return wr.append(*this, value, buf, bufSize, buf[4], FPSTR(__func__)); } + RepoSource &commitSha(const String &value) { return wr.append(*this, value, buf, bufSize, 4, FPSTR(__func__)); } }; + /** * Location of the source in an archive file in Google Cloud Storage. */ @@ -155,13 +167,16 @@ namespace GoogleCloudFunctions { public: // Google Cloud Storage bucket containing the source (see Bucket Name Requirements, https://cloud.google.com/storage/docs/bucket-naming#requirements). - StorageSource &bucket(const String &value) { return wr.set(*this, value, buf, bufSize, buf[1], FPSTR(__func__)); } + StorageSource &bucket(const String &value) { return wr.set(*this, value, buf, bufSize, 1, FPSTR(__func__)); } + // Google Cloud Storage object containing the source. // This object must be a gzipped archive file (.tar.gz) containing source to build. - StorageSource &object(const String &value) { return wr.set(*this, value, buf, bufSize, buf[2], FPSTR(__func__)); } + StorageSource &object(const String &value) { return wr.set(*this, value, buf, bufSize, 2, FPSTR(__func__)); } + // Google Cloud Storage generation (int64 format) for the object. If the generation is omitted, the latest generation will be used. - StorageSource &generation(const String &value) { return wr.set(*this, value, buf, bufSize, buf[3], FPSTR(__func__)); } + StorageSource &generation(const String &value) { return wr.set(*this, value, buf, bufSize, 3, FPSTR(__func__)); } }; + /** * The location of the function source code. */ @@ -171,39 +186,51 @@ namespace GoogleCloudFunctions // Union field source // If provided, get the source from this location in Google Cloud Storage. Source &storageSource(const StorageSource &value) { return wr.add(*this, value, buf, FPSTR(__func__)); } + // Union field source // If provided, get the source from this location in a Cloud Source Repository. Source &repoSource(const RepoSource &value) { return wr.add(*this, value, buf, FPSTR(__func__)); } + // Union field source // If provided, get the source from GitHub repository. This option is valid only for GCF 1st Gen function. Example: https://github.com///blob// Source &gitUri(const String &value) { return wr.add(*this, value, buf, FPSTR(__func__)); } }; + /** * Describes the Build step of the function that builds a container from the given source. */ struct BuildConfig : public BaseO10 { public: + // The runtime in which to run the function. Required when deploying a new function, optional when updating an existing function. For a complete list of possible choices, see the gcloud command reference. - BuildConfig &runtime(const String &value) { return wr.set(*this, value, buf, bufSize, buf[1], FPSTR(__func__)); } + BuildConfig &runtime(const String &value) { return wr.set(*this, value, buf, bufSize, 1, FPSTR(__func__)); } + // The name of the function (as defined in source code) that will be executed. Defaults to the resource name suffix, if not specified. For backward compatibility, if function with given name is not found, then the system will try to use function named "function". For Node.js this is name of a function exported by the module specified in source_location. - BuildConfig &entryPoint(const String &value) { return wr.set(*this, value, buf, bufSize, buf[2], FPSTR(__func__)); } + BuildConfig &entryPoint(const String &value) { return wr.set(*this, value, buf, bufSize, 2, FPSTR(__func__)); } + // The location of the function source code. - BuildConfig &source(Source value) { return wr.set(*this, value, buf, bufSize, buf[3], FPSTR(__func__)); } + BuildConfig &source(Source value) { return wr.set(*this, value, buf, bufSize, 3, FPSTR(__func__)); } + // Name of the Cloud Build Custom Worker Pool that should be used to build the function. The format of this field is projects/{project}/locations/{region}/workerPools/{workerPool} where {project} and {region} are the project id and region respectively where the worker pool is defined and {workerPool} is the short name of the worker pool. - BuildConfig &workerPool(const String &value) { return wr.set(*this, value, buf, bufSize, buf[4], FPSTR(__func__)); } + BuildConfig &workerPool(const String &value) { return wr.set(*this, value, buf, bufSize, 4, FPSTR(__func__)); } + // User-provided build-time environment variables for the function // An object containing a list of "key": value pairs. Example: { "name": "wrench", "mass": "1.3kg", "count": "3" }. - BuildConfig &environmentVariables(const object_t &value) { return wr.set(*this, value, buf, bufSize, buf[5], FPSTR(__func__)); } + BuildConfig &environmentVariables(const object_t &value) { return wr.set(*this, value, buf, bufSize, 5, FPSTR(__func__)); } + // Docker Registry to use for this deployment. This configuration is only applicable to 1st Gen functions, 2nd Gen functions can only use Artifact Registry. // If dockerRepository field is specified, this field will be automatically set as ARTIFACT_REGISTRY. If unspecified, it currently defaults to CONTAINER_REGISTRY. This field may be overridden by the backend for eligible deployments. - BuildConfig &dockerRegistry(DockerRegistry value) { return wr.set(*this, _DockerRegistry[value].text, buf, bufSize, buf[6], FPSTR(__func__)); } + BuildConfig &dockerRegistry(DockerRegistry value) { return wr.set(*this, _DockerRegistry[value].text, buf, bufSize, 6, FPSTR(__func__)); } + // Repository in Artifact Registry to which the function docker image will be pushed after it is built by Cloud Build. If specified by user, it is created and managed by user with a customer managed encryption key. Otherwise, GCF will create and use a repository named 'gcf-artifacts' for every deployed region. - BuildConfig &dockerRepository(const String &value) { return wr.set(*this, value, buf, bufSize, buf[7], FPSTR(__func__)); } + BuildConfig &dockerRepository(const String &value) { return wr.set(*this, value, buf, bufSize, 7, FPSTR(__func__)); } + //[Preview] Service account to be used for building the container - BuildConfig &serviceAccount(const String &value) { return wr.set(*this, value, buf, bufSize, buf[8], FPSTR(__func__)); } + BuildConfig &serviceAccount(const String &value) { return wr.set(*this, value, buf, bufSize, 8, FPSTR(__func__)); } + // An identifier for Firebase function sources. Disclaimer: This field is only supported for Firebase function deployments. - BuildConfig &sourceToken(const String &value) { return wr.set(*this, value, buf, bufSize, buf[9], FPSTR(__func__)); } + BuildConfig &sourceToken(const String &value) { return wr.set(*this, value, buf, bufSize, 9, FPSTR(__func__)); } }; /** * Configuration for a single version. @@ -211,10 +238,12 @@ namespace GoogleCloudFunctions struct SecretVersion : public BaseO4 { public: + // Version of the secret (version number or the string 'latest'). It is preferable to use latest version with secret volumes as secret value changes are reflected immediately. - SecretVersion &version(const String &value) { return wr.set(*this, value, buf, bufSize, buf[1], FPSTR(__func__)); } + SecretVersion &version(const String &value) { return wr.set(*this, value, buf, bufSize, 1, FPSTR(__func__)); } + // Relative path of the file under the mount path where the secret value for this version will be fetched and made available. For example, setting the mountPath as '/etc/secrets' and path as secret_foo would mount the secret value file at /etc/secrets/secret_foo. - SecretVersion &path(const String &value) { return wr.set(*this, value, buf, bufSize, buf[2], FPSTR(__func__)); } + SecretVersion &path(const String &value) { return wr.set(*this, value, buf, bufSize, 2, FPSTR(__func__)); } }; /** * Configuration for a secret volume. It has the information necessary to fetch the secret value from secret manager and make it available as files mounted at the requested paths within the application container. @@ -222,16 +251,20 @@ namespace GoogleCloudFunctions struct SecretVolume : public BaseO6 { public: + // The path within the container to mount the secret volume. For example, setting the mountPath as /etc/secrets would mount the secret value files under the /etc/secrets directory. This directory will also be completely shadowed and unavailable to mount any other secrets. Recommended mount path: /etc/secrets - SecretVolume &mountPath(const String &value) { return wr.set(*this, value, buf, bufSize, buf[1], FPSTR(__func__)); } + SecretVolume &mountPath(const String &value) { return wr.set(*this, value, buf, bufSize, 1, FPSTR(__func__)); } + // Project identifier (preferably project number but can also be the project ID) of the project that contains the secret. If not set, it is assumed that the secret is in the same project as the function. - SecretVolume &projectId(const String &value) { return wr.set(*this, value, buf, bufSize, buf[2], FPSTR(__func__)); } + SecretVolume &projectId(const String &value) { return wr.set(*this, value, buf, bufSize, 2, FPSTR(__func__)); } + // Name of the secret in secret manager (not the full resource name). - SecretVolume &secret(const String &value) { return wr.set(*this, value, buf, bufSize, buf[3], FPSTR(__func__)); } + SecretVolume &secret(const String &value) { return wr.set(*this, value, buf, bufSize, 3, FPSTR(__func__)); } + // List of secret versions to mount for this secret. If empty, the latest version of the secret will be made available in a file named after the secret under the mount point. // The item or value will be added to the array or list. // To add more items, call this function again. - SecretVolume &versions(const SecretVersion &value) { return wr.append(*this, value, buf, bufSize, buf[4], FPSTR(__func__)); } + SecretVolume &versions(const SecretVersion &value) { return wr.append(*this, value, buf, bufSize, 4, FPSTR(__func__)); } }; /** * Configuration for a secret environment variable. It has the information necessary to fetch the secret value from secret manager and expose it as an environment variable. @@ -239,14 +272,18 @@ namespace GoogleCloudFunctions struct SecretEnvVar : public BaseO6 { public: + // Name of the environment variable. - SecretEnvVar &key(const String &value) { return wr.set(*this, value, buf, bufSize, buf[1], FPSTR(__func__)); } + SecretEnvVar &key(const String &value) { return wr.set(*this, value, buf, bufSize, 1, FPSTR(__func__)); } + // Project identifier (preferably project number but can also be the project ID) of the project that contains the secret. If not set, it is assumed that the secret is in the same project as the function. - SecretEnvVar &projectId(const String &value) { return wr.set(*this, value, buf, bufSize, buf[2], FPSTR(__func__)); } + SecretEnvVar &projectId(const String &value) { return wr.set(*this, value, buf, bufSize, 2, FPSTR(__func__)); } + // Name of the secret in secret manager (not the full resource name). - SecretEnvVar &secret(const String &value) { return wr.set(*this, value, buf, bufSize, buf[3], FPSTR(__func__)); } + SecretEnvVar &secret(const String &value) { return wr.set(*this, value, buf, bufSize, 3, FPSTR(__func__)); } + // Version of the secret (version number or the string 'latest'). It is recommended to use a numeric version for secret environment variables as any updates to the secret value is not reflected until new instances start. - SecretEnvVar &version(const String &value) { return wr.set(*this, value, buf, bufSize, buf[4], FPSTR(__func__)); } + SecretEnvVar &version(const String &value) { return wr.set(*this, value, buf, bufSize, 4, FPSTR(__func__)); } }; /** @@ -256,44 +293,59 @@ namespace GoogleCloudFunctions { public: + // The function execution timeout. Execution is considered failed and can be terminated if the function is not completed at the end of the timeout period. Defaults to 60 seconds. - ServiceConfig &timeoutSeconds(uint32_t value) { return wr.set(*this, value, buf, bufSize, buf[1], FPSTR(__func__)); } + ServiceConfig &timeoutSeconds(uint32_t value) { return wr.set(*this, value, buf, bufSize, 1, FPSTR(__func__)); } + // The amount of memory available for a function. Defaults to 256M. Supported units are k, M, G, Mi, Gi. If no unit is supplied the value is interpreted as bytes. See https://github.com/kubernetes/kubernetes/blob/master/staging/src/k8s.io/apimachinery/pkg/api/resource/quantity.go a full description. - ServiceConfig &availableMemory(const String &value) { return wr.set(*this, value, buf, bufSize, buf[2], FPSTR(__func__)); } + ServiceConfig &availableMemory(const String &value) { return wr.set(*this, value, buf, bufSize, 2, FPSTR(__func__)); } + // The number of CPUs used in a single container instance. Default value is calculated from available memory. Supports the same values as Cloud Run, see https://cloud.google.com/run/docs/reference/rest/v1/Container#resourcerequirements Example: "1" indicates 1 vCPU - ServiceConfig &availableCpu(const String &value) { return wr.set(*this, value, buf, bufSize, buf[3], FPSTR(__func__)); } + ServiceConfig &availableCpu(const String &value) { return wr.set(*this, value, buf, bufSize, 3, FPSTR(__func__)); } + // Environment variables that shall be available during function execution. // An object containing a list of "key": value pairs. Example: { "name": "wrench", "mass": "1.3kg", "count": "3" }. - ServiceConfig &environmentVariables(const object_t &value) { return wr.set(*this, value, buf, bufSize, buf[4], FPSTR(__func__)); } + ServiceConfig &environmentVariables(const object_t &value) { return wr.set(*this, value, buf, bufSize, 4, FPSTR(__func__)); } + // The limit on the maximum number of function instances that may coexist at a given time. // In some cases, such as rapid traffic surges, Cloud Functions may, for a short period of time, create more instances than the specified max instances limit. If your function cannot tolerate this temporary behavior, you may want to factor in a safety margin and set a lower max instances value than your function can tolerate. // See the Max Instances (https://cloud.google.com/functions/docs/max-instances) Guide for more details. - ServiceConfig &maxInstanceCount(uint32_t value) { return wr.set(*this, value, buf, bufSize, buf[5], FPSTR(__func__)); } + ServiceConfig &maxInstanceCount(uint32_t value) { return wr.set(*this, value, buf, bufSize, 5, FPSTR(__func__)); } + // The limit on the minimum number of function instances that may coexist at a given time. // Function instances are kept in idle state for a short period after they finished executing the request to reduce cold start time for subsequent requests. Setting a minimum instance count will ensure that the given number of instances are kept running in idle state always. This can help with cold start times when jump in incoming request count occurs after the idle instance would have been stopped in the default case. - ServiceConfig &minInstanceCount(uint32_t value) { return wr.set(*this, value, buf, bufSize, buf[6], FPSTR(__func__)); } + ServiceConfig &minInstanceCount(uint32_t value) { return wr.set(*this, value, buf, bufSize, 6, FPSTR(__func__)); } + // The Serverless VPC Access connector that this cloud function can connect to. The format of this field is projects/*/locations/*/connectors/*. - ServiceConfig &vpcConnector(const String &value) { return wr.set(*this, value, buf, bufSize, buf[7], FPSTR(__func__)); } + ServiceConfig &vpcConnector(const String &value) { return wr.set(*this, value, buf, bufSize, 7, FPSTR(__func__)); } + // The egress settings for the connector, controlling what traffic is diverted through it. - ServiceConfig &vpcConnectorEgressSettings(VpcConnectorEgressSettings value) { return wr.set(*this, _VpcConnectorEgressSettings[value].text, buf, bufSize, buf[8], FPSTR(__func__)); } + ServiceConfig &vpcConnectorEgressSettings(VpcConnectorEgressSettings value) { return wr.set(*this, _VpcConnectorEgressSettings[value].text, buf, bufSize, 8, FPSTR(__func__)); } + // The ingress settings for the function, controlling what traffic can reach it. - ServiceConfig &ingressSettings(IngressSettings value) { return wr.set(*this, _IngressSettings[value].text, buf, bufSize, buf[9], FPSTR(__func__)); } + ServiceConfig &ingressSettings(IngressSettings value) { return wr.set(*this, _IngressSettings[value].text, buf, bufSize, 9, FPSTR(__func__)); } + // The email of the service's service account. If empty, defaults to {project_number}-compute@developer.gserviceaccount.com. - ServiceConfig &serviceAccountEmail(const String &value) { return wr.set(*this, value, buf, bufSize, buf[10], FPSTR(__func__)); } + ServiceConfig &serviceAccountEmail(const String &value) { return wr.set(*this, value, buf, bufSize, 10, FPSTR(__func__)); } + // Whether 100% of traffic is routed to the latest revision. On functions.create and functions.patch, when set to true, the revision being deployed will serve 100% of traffic, ignoring any traffic split settings, if any. On functions.get, true will be returned if the latest revision is serving 100% of traffic. - ServiceConfig &allTrafficOnLatestRevision(bool value) { return wr.set(*this, value, buf, bufSize, buf[11], FPSTR(__func__)); } + ServiceConfig &allTrafficOnLatestRevision(bool value) { return wr.set(*this, value, buf, bufSize, 11, FPSTR(__func__)); } + // Secret environment variables configuration. // The item or value will be added to the array or list. // To add more items, call this function again. - ServiceConfig &secretEnvironmentVariables(const SecretEnvVar &value) { return wr.append(*this, value, buf, bufSize, buf[12], FPSTR(__func__)); } + ServiceConfig &secretEnvironmentVariables(const SecretEnvVar &value) { return wr.append(*this, value, buf, bufSize, 12, FPSTR(__func__)); } + // Secret volumes configuration. // The item or value will be added to the array or list. // To add more items, call this function again. - ServiceConfig &secretVolumes(const SecretVolume &value) { return wr.append(*this, value, buf, bufSize, buf[13], FPSTR(__func__)); } + ServiceConfig &secretVolumes(const SecretVolume &value) { return wr.append(*this, value, buf, bufSize, 13, FPSTR(__func__)); } + // Sets the maximum number of concurrent requests that each instance can receive. Defaults to 1. - ServiceConfig &maxInstanceRequestConcurrency(uint32_t value) { return wr.set(*this, value, buf, bufSize, buf[14], FPSTR(__func__)); } + ServiceConfig &maxInstanceRequestConcurrency(uint32_t value) { return wr.set(*this, value, buf, bufSize, 14, FPSTR(__func__)); } + // Security level configure whether the function only accepts https. This configuration is only applicable to 1st Gen functions with Http trigger. By default https is optional for 1st Gen functions; 2nd Gen functions are https ONLY. - ServiceConfig &securityLevel(SecurityLevel value) { return wr.set(*this, _SecurityLevel[value].text, buf, bufSize, buf[15], FPSTR(__func__)); } + ServiceConfig &securityLevel(SecurityLevel value) { return wr.set(*this, _SecurityLevel[value].text, buf, bufSize, 15, FPSTR(__func__)); } }; /** * Filters events based on exact matches on the CloudEvents attributes. @@ -302,12 +354,15 @@ namespace GoogleCloudFunctions { public: + // Required. The name of a CloudEvents attribute. - EventFilter &attribute(const String &value) { return wr.set(*this, value, buf, bufSize, buf[1], FPSTR(__func__)); } + EventFilter &attribute(const String &value) { return wr.set(*this, value, buf, bufSize, 1, FPSTR(__func__)); } + // Required. The value for the attribute. - EventFilter &value(const String &value) { return wr.set(*this, value, buf, bufSize, buf[2], FPSTR(__func__)); } + EventFilter &value(const String &value) { return wr.set(*this, value, buf, bufSize, 2, FPSTR(__func__)); } + // Optional. The operator used for matching the events with the value of the filter. If not specified, only events that have an exact key-value pair specified in the filter are matched. The only allowed value is match-path-pattern. - EventFilter &Operator(const String &value) { return wr.set(*this, value, buf, bufSize, buf[3], FPSTR(__func__)); } + EventFilter &Operator(const String &value) { return wr.set(*this, value, buf, bufSize, 3, FPSTR(__func__)); } }; /** * Describes EventTrigger, used to request events to be sent from another service. @@ -315,27 +370,35 @@ namespace GoogleCloudFunctions struct EventTrigger : public BaseO10 { public: + // The region that the trigger will be in. The trigger will only receive events originating in this region. It can be the same region as the function, a different region or multi-region, or the global region. If not provided, defaults to the same region as the function. - EventTrigger &triggerRegion(const String &value) { return wr.set(*this, value, buf, bufSize, buf[1], FPSTR(__func__)); } + EventTrigger &triggerRegion(const String &value) { return wr.set(*this, value, buf, bufSize, 1, FPSTR(__func__)); } + // Required. The type of event to observe. For example: google.cloud.audit.log.v1.written or google.cloud.pubsub.topic.v1.messagePublished. - EventTrigger &eventType(const String &value) { return wr.set(*this, value, buf, bufSize, buf[2], FPSTR(__func__)); } + EventTrigger &eventType(const String &value) { return wr.set(*this, value, buf, bufSize, 2, FPSTR(__func__)); } + // Criteria used to filter events. // The item or value will be added to the array or list. // To add more items, call this function again. - EventTrigger &eventFilters(const EventFilter &value) { return wr.append(*this, value, buf, bufSize, buf[3], FPSTR(__func__)); } + EventTrigger &eventFilters(const EventFilter &value) { return wr.append(*this, value, buf, bufSize, 3, FPSTR(__func__)); } + // Optional. The name of a Pub/Sub topic in the same project that will be used as the transport topic for the event delivery. Format: projects/{project}/topics/{topic}. // This is only valid for events of type google.cloud.pubsub.topic.v1.messagePublished. The topic provided here will not be deleted at function deletion. - EventTrigger &pubsubTopic(const String &value) { return wr.set(*this, value, buf, bufSize, buf[4], FPSTR(__func__)); } + EventTrigger &pubsubTopic(const String &value) { return wr.set(*this, value, buf, bufSize, 4, FPSTR(__func__)); } + // Optional. The email of the trigger's service account. The service account must have permission to invoke Cloud Run services, the permission is run.routes.invoke. If empty, defaults to the Compute Engine default service account: {project_number}-compute@developer.gserviceaccount.com. - EventTrigger &serviceAccountEmail(const String &value) { return wr.set(*this, value, buf, bufSize, buf[5], FPSTR(__func__)); } + EventTrigger &serviceAccountEmail(const String &value) { return wr.set(*this, value, buf, bufSize, 5, FPSTR(__func__)); } + // Optional. If unset, then defaults to ignoring failures (i.e. not retrying them). - EventTrigger &retryPolicy(RetryPolicy value) { return wr.set(*this, _RetryPolicy[value].text, buf, bufSize, buf[6], FPSTR(__func__)); } + EventTrigger &retryPolicy(RetryPolicy value) { return wr.set(*this, _RetryPolicy[value].text, buf, bufSize, 6, FPSTR(__func__)); } + // Optional. The name of the channel associated with the trigger in projects/{project}/locations/{location}/channels/{channel} format. You must provide a channel to receive events from Eventarc SaaS partners. - EventTrigger &channel(const String &value) { return wr.set(*this, value, buf, bufSize, buf[7], FPSTR(__func__)); } + EventTrigger &channel(const String &value) { return wr.set(*this, value, buf, bufSize, 7, FPSTR(__func__)); } + // Optional. The hostname of the service that 1st Gen function should be observed. // If no string is provided, the default service implementing the API will be used. For example, storage.googleapis.com is the default for all event types in the google.storage namespace. // The field is only applicable to 1st Gen functions. - EventTrigger &service(const String &value) { return wr.set(*this, value, buf, bufSize, buf[8], FPSTR(__func__)); } + EventTrigger &service(const String &value) { return wr.set(*this, value, buf, bufSize, 8, FPSTR(__func__)); } }; /** * Describes a Cloud Function that contains user computation executed in response to an event. It encapsulates function and trigger configurations. @@ -343,34 +406,44 @@ namespace GoogleCloudFunctions struct Function : public BaseO10 { public: + // A user-defined name of the function. Function names must be unique globally and match pattern projects/*/locations/*/functions/* - Function &name(const String &value) { return wr.set(*this, value, buf, bufSize, buf[1], FPSTR(__func__)); } + Function &name(const String &value) { return wr.set(*this, value, buf, bufSize, 1, FPSTR(__func__)); } + // User-provided description of a function. - Function &description(const String &value) { return wr.set(*this, value, buf, bufSize, buf[2], FPSTR(__func__)); } + Function &description(const String &value) { return wr.set(*this, value, buf, bufSize, 2, FPSTR(__func__)); } + // Describes the Build step of the function that builds a container from the given source. - Function &buildConfig(const BuildConfig &value) { return wr.set(*this, value, buf, bufSize, buf[3], FPSTR(__func__)); } + Function &buildConfig(const BuildConfig &value) { return wr.set(*this, value, buf, bufSize, 3, FPSTR(__func__)); } + // Describes the Service being deployed. Currently deploys services to Cloud Run (fully managed). - Function &serviceConfig(const ServiceConfig &value) { return wr.set(*this, value, buf, bufSize, buf[4], FPSTR(__func__)); } + Function &serviceConfig(const ServiceConfig &value) { return wr.set(*this, value, buf, bufSize, 4, FPSTR(__func__)); } + // An Eventarc trigger managed by Google Cloud Functions that fires events in response to a condition in another service. - Function &eventTrigger(const EventTrigger &value) { return wr.set(*this, value, buf, bufSize, buf[5], FPSTR(__func__)); } + Function &eventTrigger(const EventTrigger &value) { return wr.set(*this, value, buf, bufSize, 5, FPSTR(__func__)); } + // Labels associated with this Cloud Function. // An object containing a list of "key": value pairs. Example: { "name": "wrench", "mass": "1.3kg", "count": "3" }. - Function &labels(const object_t &value) { return wr.set(*this, value, buf, bufSize, buf[6], FPSTR(__func__)); } + Function &labels(const object_t &value) { return wr.set(*this, value, buf, bufSize, 6, FPSTR(__func__)); } + // Describe whether the function is 1st Gen or 2nd Gen. - Function &environment(Environment value) { return wr.set(*this, _Environment[value].text, buf, bufSize, buf[7], FPSTR(__func__)); } + Function &environment(Environment value) { return wr.set(*this, _Environment[value].text, buf, bufSize, 7, FPSTR(__func__)); } + //[Preview] Resource name of a KMS crypto key (managed by the user) used to encrypt/decrypt function resources. // It must match the pattern projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}. - Function &kmsKeyName(const String &value) { return wr.set(*this, value, buf, bufSize, buf[8], FPSTR(__func__)); } + Function &kmsKeyName(const String &value) { return wr.set(*this, value, buf, bufSize, 8, FPSTR(__func__)); } }; struct UploadURLOptions : public BaseO4 { public: + // [Preview] Resource name of a KMS crypto key (managed by the user) used to encrypt/decrypt function source code objects in intermediate Cloud Storage buckets. When you generate an upload url and upload your source code, it gets copied to an intermediate Cloud Storage bucket. The source code is then copied to a versioned directory in the sources bucket in the consumer project during the function deployment. // It must match the pattern projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}. - UploadURLOptions &kmsKeyName(const String &value) { return wr.set(*this, value, buf, bufSize, buf[1], FPSTR(__func__)); } + UploadURLOptions &kmsKeyName(const String &value) { return wr.set(*this, value, buf, bufSize, 1, FPSTR(__func__)); } + // The function environment the generated upload url will be used for. The upload url for 2nd Gen functions can also be used for 1st gen functions, but not vice versa. If not specified, 2nd generation-style upload URLs are generated. - UploadURLOptions &environment(Environment value) { return wr.set(*this, _Environment[value].text, buf, bufSize, buf[2], FPSTR(__func__)); } + UploadURLOptions &environment(Environment value) { return wr.set(*this, _Environment[value].text, buf, bufSize, 2, FPSTR(__func__)); } }; /** @@ -399,24 +472,28 @@ namespace GoogleCloudFunctions } public: + // Maximum number of functions to return per call. The largest allowed pageSize is 1,000, if the pageSize is omitted or specified as greater than 1,000 then it will be replaced as 1,000. The size of the list response can be less than specified when used with filters. ListOptions &pageSize(uint64_t value) { buf[1] = "pageSize=" + sut.u64Str(value); return setBuf(); } + // The value returned by the last ListFunctionsResponse; indicates that this is a continuation of a prior functions.list call, and that the system should return the next page of data. ListOptions &pageToken(const String &value) { buf[2] = "pageToken=" + value; return setBuf(); } + // The filter for Functions that match the filter expression, following the syntax outlined in https://google.aip.dev/160. ListOptions &filter(const String &value) { buf[3] = "filter=" + value; return setBuf(); } + // The sorting order of the resources returned. Value should be a comma separated list of fields. The default sorting oder is ascending. See https://google.aip.dev/132#ordering. ListOptions &orderBy(const String &value) { @@ -435,6 +512,7 @@ namespace GoogleCloudFunctions ObjectWriter owriter; public: + // Optional. The maximum policy version that will be used to format the policy. // Valid values are 0, 1, and 3. Requests specifying an invalid value will be rejected. // Requests for policies with any conditional role bindings must specify version 3. Policies with no conditional role bindings may specify any valid value or leave the field unset. @@ -453,12 +531,14 @@ namespace GoogleCloudFunctions { public: + // REQUIRED: The complete policy to be applied to the resource. The size of the policy is limited to a few 10s of KB. An empty policy is a valid policy but certain Google Cloud services (such as Projects) might reject them. - SetPolicyOptions &policy(const IAMPolicy::Policy &value) { return wr.set(*this, value, buf, bufSize, buf[1], FPSTR(__func__)); } + SetPolicyOptions &policy(const IAMPolicy::Policy &value) { return wr.set(*this, value, buf, bufSize, 1, FPSTR(__func__)); } + // OPTIONAL: A FieldMask specifying which fields of the policy to modify. Only the fields in the mask will be modified. If no mask is provided, the following default mask is used: // paths: "bindings, etag" // This is a comma-separated list of fully qualified names of fields. Example: "user.displayName,photo". - SetPolicyOptions &updateMask(const String &value) { return wr.set(*this, value, buf, bufSize, buf[2], FPSTR(__func__)); } + SetPolicyOptions &updateMask(const String &value) { return wr.set(*this, value, buf, bufSize, 2, FPSTR(__func__)); } }; /** @@ -468,7 +548,7 @@ namespace GoogleCloudFunctions { public: - Permissions &permissions(const String &value) { return wr.set(*this, value, buf, bufSize, buf[1], FPSTR(__func__)); } + Permissions &permissions(const String &value) { return wr.set(*this, value, buf, bufSize, 1, FPSTR(__func__)); } // Obsoleted, use permissions instead. Permissions &add(const String &value) { return permissions(value); } }; diff --git a/src/functions/Policy.h b/src/functions/Policy.h index b728ddab..690f195e 100644 --- a/src/functions/Policy.h +++ b/src/functions/Policy.h @@ -55,13 +55,13 @@ namespace IAMPolicy { public: // Textual representation of an expression in Common Expression Language syntax. - Expr &expression(const String &value) { return wr.set(*this, value, buf, bufSize, buf[1], FPSTR(__func__)); } + Expr &expression(const String &value) { return wr.set(*this, value, buf, bufSize, 1, FPSTR(__func__)); } // Optional. Title for the expression, i.e. a short string describing its purpose. This can be used e.g. in UIs which allow to enter the expression. - Expr &title(const String &value) { return wr.set(*this, value, buf, bufSize, buf[2], FPSTR(__func__)); } + Expr &title(const String &value) { return wr.set(*this, value, buf, bufSize, 2, FPSTR(__func__)); } // Optional. Description of the expression. This is a longer text which describes the expression, e.g. when hovered over it in a UI. - Expr &description(const String &value) { return wr.set(*this, value, buf, bufSize, buf[3], FPSTR(__func__)); } + Expr &description(const String &value) { return wr.set(*this, value, buf, bufSize, 3, FPSTR(__func__)); } // Optional. String indicating the location of the expression for error reporting, e.g. a file name and a position in the file. - Expr &location(const String &value) { return wr.set(*this, value, buf, bufSize, buf[4], FPSTR(__func__)); } + Expr &location(const String &value) { return wr.set(*this, value, buf, bufSize, 4, FPSTR(__func__)); } }; /** * Associates members, or principals, with a role. @@ -73,7 +73,7 @@ namespace IAMPolicy // Role that is assigned to the list of members, or principals. For example, roles/viewer, roles/editor, or roles/owner. // For an overview of the IAM roles and permissions, see the IAM documentation (https://cloud.google.com/iam/docs/roles-overview). // For a list of the available pre-defined roles, see here https://cloud.google.com/iam/docs/understanding-roles. - Binding &role(const String &value) { return wr.set(*this, value, buf, bufSize, buf[1], FPSTR(__func__)); } + Binding &role(const String &value) { return wr.set(*this, value, buf, bufSize, 1, FPSTR(__func__)); } // Specifies the principals requesting access for a Google Cloud resource. members can have the following values: /** * allUsers: A special identifier that represents anyone who is on the internet; with or without a Google account. @@ -96,12 +96,12 @@ namespace IAMPolicy * deleted:group:{emailid}?uid={uniqueid}: An email address (plus unique identifier) representing a Google group that has been recently deleted. For example, admins@example.com?uid=123456789012345678901. If the group is recovered, this value reverts to group:{emailid} and the recovered group retains the role in the binding. * deleted:principal://iam.googleapis.com/locations/global/workforcePools/{pool_id}/subject/{subject_attribute_value}: Deleted single identity in a workforce identity pool. For example, deleted:principal://iam.googleapis.com/locations/global/workforcePools/my-pool-id/subject/my-subject-attribute-value. */ - Binding &members(const String &value) { return wr.append(*this, value, buf, bufSize, buf[2], FPSTR(__func__)); } + Binding &members(const String &value) { return wr.append(*this, value, buf, bufSize, 2, FPSTR(__func__)); } // The condition that is associated with this binding. // If the condition evaluates to true, then this binding applies to the current request. // If the condition evaluates to false, then this binding does not apply to the current request. However, a different role binding might grant the same role to one or more of the principals in this binding. // To learn which resources support conditions in their IAM policies, see the IAM documentation (https://cloud.google.com/iam/help/conditions/resource-policies). - Binding &condition(const Expr &value) { return wr.set(*this, value, buf, bufSize, buf[3], FPSTR(__func__)); } + Binding &condition(const Expr &value) { return wr.set(*this, value, buf, bufSize, 3, FPSTR(__func__)); } }; /** * Provides the configuration for logging a type of permissions. Example: @@ -110,9 +110,9 @@ namespace IAMPolicy { public: // Specifies a service that will be enabled for audit logging. For example, storage.googleapis.com, cloudsql.googleapis.com. allServices is a special value that covers all services. - AuditLogConfig &logType(LogType value) { return wr.set(*this, _LogType[value].text, buf, bufSize, buf[1], FPSTR(__func__)); } + AuditLogConfig &logType(LogType value) { return wr.set(*this, _LogType[value].text, buf, bufSize, 1, FPSTR(__func__)); } // The configuration for logging of each type of permission. - AuditLogConfig &exemptedMembers(const String &value) { return wr.append(*this, value, buf, bufSize, buf[2], FPSTR(__func__)); } + AuditLogConfig &exemptedMembers(const String &value) { return wr.append(*this, value, buf, bufSize, 2, FPSTR(__func__)); } }; /** * Specifies the audit configuration for a service. The configuration determines which permission types are logged, and what identities, if any, are exempted from logging. An AuditConfig must have one or more AuditLogConfigs. @@ -122,9 +122,9 @@ namespace IAMPolicy public: // Specifies a service that will be enabled for audit logging. For example, storage.googleapis.com, cloudsql.googleapis.com. allServices is a special value that covers all services. - AuditConfig &service(const String &value) { return wr.set(*this, value, buf, bufSize, buf[1], FPSTR(__func__)); } + AuditConfig &service(const String &value) { return wr.set(*this, value, buf, bufSize, 1, FPSTR(__func__)); } // The configuration for logging of each type of permission. - AuditConfig &auditLogConfigs(const AuditLogConfig &value) { return wr.append(*this, value, buf, bufSize, buf[2], FPSTR(__func__)); } + AuditConfig &auditLogConfigs(const AuditLogConfig &value) { return wr.append(*this, value, buf, bufSize, 2, FPSTR(__func__)); } }; /** * An Identity and Access Management (IAM) policy, which specifies access controls for Google Cloud resources. @@ -135,13 +135,13 @@ namespace IAMPolicy public: // Specifies the format of the policy. // Valid values are 0, 1, and 3. Requests that specify an invalid value are rejected. - Policy &version(uint32_t value) { return wr.set(*this, value, buf, bufSize, buf[1], FPSTR(__func__)); } + Policy &version(uint32_t value) { return wr.set(*this, value, buf, bufSize, 1, FPSTR(__func__)); } // Associates a list of members, or principals, with a role. Optionally, may specify a condition that determines how and when the bindings are applied. Each of the bindings must contain at least one principal. - Policy &bindings(const Binding &value) { return wr.append(*this, value, buf, bufSize, buf[2], FPSTR(__func__)); } + Policy &bindings(const Binding &value) { return wr.append(*this, value, buf, bufSize, 2, FPSTR(__func__)); } // pecifies cloud audit logging configuration for this policy. - Policy &auditConfigs(const AuditConfig &value) { return wr.append(*this, value, buf, bufSize, buf[3], FPSTR(__func__)); } + Policy &auditConfigs(const AuditConfig &value) { return wr.append(*this, value, buf, bufSize, 3, FPSTR(__func__)); } // etag is used for optimistic concurrency control as a way to help prevent simultaneous updates of a policy from overwriting each other. It is strongly suggested that systems make use of the etag in the read-modify-write cycle to perform policy updates in order to avoid race conditions: An etag is returned in the response to getIamPolicy, and systems are expected to put that etag in the request to setIamPolicy to ensure that their change will be applied to the same version of the policy. - Policy &etag(const String &value) { return wr.set(*this, value, buf, bufSize, buf[4], FPSTR(__func__)); } + Policy &etag(const String &value) { return wr.set(*this, value, buf, bufSize, 4, FPSTR(__func__)); } }; } diff --git a/src/messaging/DataOptions.h b/src/messaging/DataOptions.h index e8acec07..a3e2da43 100644 --- a/src/messaging/DataOptions.h +++ b/src/messaging/DataOptions.h @@ -77,15 +77,14 @@ namespace Messages struct Notification : public BaseO4 { public: - // The notification's title. - Notification &title(const String &value) { return wr.set(*this, value, buf, bufSize, buf[1], FPSTR(__func__)); } + Notification &title(const String &value) { return wr.set(*this, value, buf, bufSize, 1, FPSTR(__func__)); } // The notification's body text. - Notification &body(const String &value) { return wr.set(*this, value, buf, bufSize, buf[2], FPSTR(__func__)); } + Notification &body(const String &value) { return wr.set(*this, value, buf, bufSize, 2, FPSTR(__func__)); } // Contains the URL of an image that is going to be downloaded on the device and displayed in a notification. JPEG, PNG, BMP have full support across platforms. - Notification &image(const String &value) { return wr.set(*this, value, buf, bufSize, buf[3], FPSTR(__func__)); } + Notification &image(const String &value) { return wr.set(*this, value, buf, bufSize, 3, FPSTR(__func__)); } }; /** * Represents a color in the RGBA color space. This representation is designed for simplicity of conversion to/from color representations in various languages over compactness. @@ -94,20 +93,19 @@ namespace Messages { public: - // The amount of red in the color as a value in the interval [0, 1]. - Color &red(float value) { return wr.set(*this, UnityRange().val(value), buf, bufSize, buf[1], FPSTR(__func__)); } - + Color &red(float value) { return wr.set(*this, UnityRange().val(value), buf, bufSize, 1, FPSTR(__func__)); } + // The amount of green in the color as a value in the interval [0, 1]. - Color &green(float value){ return wr.set(*this, UnityRange().val(value), buf, bufSize, buf[2], FPSTR(__func__)); } - + Color &green(float value) { return wr.set(*this, UnityRange().val(value), buf, bufSize, 2, FPSTR(__func__)); } + // The amount of blue in the color as a value in the interval [0, 1]. - Color &blue(float value){ return wr.set(*this, UnityRange().val(value), buf, bufSize, buf[3], FPSTR(__func__)); } - + Color &blue(float value) { return wr.set(*this, UnityRange().val(value), buf, bufSize, 3, FPSTR(__func__)); } + // The fraction of this color that should be applied to the pixel. That is, the final pixel color is defined by the equation: // pixel color = alpha * (this color) + (1.0 - alpha) * (background color) // This means that a value of 1.0 corresponds to a solid color, whereas a value of 0.0 corresponds to a completely transparent color. - Color &alpha(float value){ return wr.set(*this, UnityRange().val(value), buf, bufSize, buf[4], FPSTR(__func__)); } + Color &alpha(float value) { return wr.set(*this, UnityRange().val(value), buf, bufSize, 4, FPSTR(__func__)); } }; /** * Settings to control notification LED. @@ -115,17 +113,16 @@ namespace Messages struct LightSettings : public BaseO4 { public: - // Required. Set color of the LED with google.type.Color. - LightSettings &color(Color value) { return wr.set(*this, value, buf, bufSize, buf[1], FPSTR(__func__)); } - + LightSettings &color(Color value) { return wr.set(*this, value, buf, bufSize, 1, FPSTR(__func__)); } + // Required. Along with light_off_duration, define the blink rate of LED flashes. Resolution defined by proto.Duration // A duration in seconds with up to nine fractional digits, ending with 's'. Example: "3.5s". - LightSettings &light_on_duration(const String &value) { return wr.set(*this, value, buf, bufSize, buf[2], FPSTR(__func__)); } - + LightSettings &light_on_duration(const String &value) { return wr.set(*this, value, buf, bufSize, 2, FPSTR(__func__)); } + // Required. Along with light_on_duration, define the blink rate of LED flashes. Resolution defined by proto.Duration // A duration in seconds with up to nine fractional digits, ending with 's'. Example: "3.5s". - LightSettings &light_off_duration(const String &value) { return wr.set(*this, value, buf, bufSize, buf[3], FPSTR(__func__)); } + LightSettings &light_off_duration(const String &value) { return wr.set(*this, value, buf, bufSize, 3, FPSTR(__func__)); } }; /** @@ -136,90 +133,90 @@ namespace Messages public: // The notification's title. If present, it will override google.firebase.fcm.v1.Notification.title. - AndroidNotification &title(const String &value) { return wr.set(*this, value, buf, bufSize, buf[1], FPSTR(__func__)); } - + AndroidNotification &title(const String &value) { return wr.set(*this, value, buf, bufSize, 1, FPSTR(__func__)); } + // The notification's body text. If present, it will override google.firebase.fcm.v1.Notification.body. - AndroidNotification &body(const String &value) { return wr.set(*this, value, buf, bufSize, buf[2], FPSTR(__func__)); } - + AndroidNotification &body(const String &value) { return wr.set(*this, value, buf, bufSize, 2, FPSTR(__func__)); } + // The notification's icon. Sets the notification icon to myicon for drawable resource myicon. If you don't send this key in the request, FCM displays the launcher icon specified in your app manifest. - AndroidNotification &icon(const String &value) { return wr.set(*this, value, buf, bufSize, buf[3], FPSTR(__func__)); } - + AndroidNotification &icon(const String &value) { return wr.set(*this, value, buf, bufSize, 3, FPSTR(__func__)); } + // The notification's icon color, expressed in #rrggbb format. - AndroidNotification &color(const String &value) { return wr.set(*this, value, buf, bufSize, buf[4], FPSTR(__func__)); } - + AndroidNotification &color(const String &value) { return wr.set(*this, value, buf, bufSize, 4, FPSTR(__func__)); } + // The sound to play when the device receives the notification. Supports "default" or the filename of a sound resource bundled in the app. Sound files must reside in /res/raw/. - AndroidNotification &sound(const String &value) { return wr.set(*this, value, buf, bufSize, buf[5], FPSTR(__func__)); } - + AndroidNotification &sound(const String &value) { return wr.set(*this, value, buf, bufSize, 5, FPSTR(__func__)); } + // Identifier used to replace existing notifications in the notification drawer. If not specified, each request creates a new notification. If specified and a notification with the same tag is already being shown, the new notification replaces the existing one in the notification drawer. - AndroidNotification &tag(const String &value) { return wr.set(*this, value, buf, bufSize, buf[6], FPSTR(__func__)); } - + AndroidNotification &tag(const String &value) { return wr.set(*this, value, buf, bufSize, 6, FPSTR(__func__)); } + // The action associated with a user click on the notification. If specified, an activity with a matching intent filter is launched when a user clicks on the notification. - AndroidNotification &click_action(const String &value) { return wr.set(*this, value, buf, bufSize, buf[7], FPSTR(__func__)); } - + AndroidNotification &click_action(const String &value) { return wr.set(*this, value, buf, bufSize, 7, FPSTR(__func__)); } + // The key to the body string in the app's string resources to use to localize the body text to the user's current localization. See String Resources (https://goo.gl/NdFZGI) for more information. - AndroidNotification &body_loc_key(const String &value) { return wr.set(*this, value, buf, bufSize, buf[8], FPSTR(__func__)); } - + AndroidNotification &body_loc_key(const String &value) { return wr.set(*this, value, buf, bufSize, 8, FPSTR(__func__)); } + // This value represents the item to add to an array. // Variable string values to be used in place of the format specifiers in body_loc_key to use to localize the body text to the user's current localization. See Formatting and Styling (https://goo.gl/MalYE3) for more information. // The item or value will be added to the array or list. // To add more items, call this function again. - AndroidNotification &body_loc_args(const String &value) { return wr.append(*this, value, buf, bufSize, buf[9], FPSTR(__func__)); } - + AndroidNotification &body_loc_args(const String &value) { return wr.append(*this, value, buf, bufSize, 9, FPSTR(__func__)); } + // The key to the title string in the app's string resources to use to localize the title text to the user's current localization. See String Resources (https://goo.gl/NdFZGI) for more information. - AndroidNotification &title_loc_key(const String &value) { return wr.set(*this, value, buf, bufSize, buf[10], FPSTR(__func__)); } - + AndroidNotification &title_loc_key(const String &value) { return wr.set(*this, value, buf, bufSize, 10, FPSTR(__func__)); } + // This value represents the item to add to an array. // Variable string values to be used in place of the format specifiers in title_loc_key to use to localize the title text to the user's current localization. See Formatting and Styling (https://goo.gl/MalYE3) for more information. // The item or value will be added to the array or list. // To add more items, call this function again. - AndroidNotification &title_loc_args(const String &value) { return wr.append(*this, value, buf, bufSize, buf[11], FPSTR(__func__)); } - + AndroidNotification &title_loc_args(const String &value) { return wr.append(*this, value, buf, bufSize, 11, FPSTR(__func__)); } + // The notification's channel id (https://developer.android.com/guide/topics/ui/notifiers/notifications#ManageChannels) (new in Android O). The app must create a channel with this channel ID before any notification with this channel ID is received. If you don't send this channel ID in the request, or if the channel ID provided has not yet been created by the app, FCM uses the channel ID specified in the app manifest. - AndroidNotification &channel_id(const String &value) { return wr.set(*this, value, buf, bufSize, buf[12], FPSTR(__func__)); } - + AndroidNotification &channel_id(const String &value) { return wr.set(*this, value, buf, bufSize, 12, FPSTR(__func__)); } + // Sets the "ticker" text, which is sent to accessibility services. Prior to API level 21 (Lollipop), sets the text that is displayed in the status bar when the notification first arrives. - AndroidNotification &ticker(const String &value) { return wr.set(*this, value, buf, bufSize, buf[13], FPSTR(__func__)); } - + AndroidNotification &ticker(const String &value) { return wr.set(*this, value, buf, bufSize, 13, FPSTR(__func__)); } + // When set to false or unset, the notification is automatically dismissed when the user clicks it in the panel. When set to true, the notification persists even when the user clicks it. - AndroidNotification &sticky(bool value) { return wr.set(*this, value, buf, bufSize, buf[14], FPSTR(__func__)); } - + AndroidNotification &sticky(bool value) { return wr.set(*this, value, buf, bufSize, 14, FPSTR(__func__)); } + // Set the time that the event in the notification occurred. Notifications in the panel are sorted by this time. A point in time is represented using protobuf.Timestamp (https://developers.google.com/protocol-buffers/docs/reference/java/com/google/protobuf/Timestamp). // A timestamp in RFC3339 UTC "Zulu" format, with nanosecond resolution and up to nine fractional digits. Examples: "2014-10-02T15:01:23Z" and "2014-10-02T15:01:23.045123456Z". - AndroidNotification &event_time(const String &value) { return wr.set(*this, value, buf, bufSize, buf[15], FPSTR(__func__)); } - + AndroidNotification &event_time(const String &value) { return wr.set(*this, value, buf, bufSize, 15, FPSTR(__func__)); } + // Set whether or not this notification is relevant only to the current device. Some notifications can be bridged to other devices for remote display, such as a Wear OS watch. This hint can be set to recommend this notification not be bridged. See Wear OS guides (https://developer.android.com/training/wearables/notifications/bridger#existing-method-of-preventing-bridging) - AndroidNotification &local_only(bool value) { return wr.set(*this, value, buf, bufSize, buf[16], FPSTR(__func__)); } - + AndroidNotification &local_only(bool value) { return wr.set(*this, value, buf, bufSize, 16, FPSTR(__func__)); } + // Set the relative priority for this notification. Priority is an indication of how much of the user's attention should be consumed by this notification. Low-priority notifications may be hidden from the user in certain situations, while the user might be interrupted for a higher-priority notification. The effect of setting the same priorities may differ slightly on different platforms. Note this priority differs from AndroidMessagePriority. This priority is processed by the client after the message has been delivered, whereas AndroidMessagePriority (https://firebase.google.com/docs/reference/fcm/rest/v1/projects.messages#androidmessagepriority) is an FCM concept that controls when the message is delivered. - AndroidNotification ¬ification_priority(NotificationPriority value) { return wr.set(*this, _NotificationPriority[value].text, buf, bufSize, buf[17], FPSTR(__func__)); } - + AndroidNotification ¬ification_priority(NotificationPriority value) { return wr.set(*this, _NotificationPriority[value].text, buf, bufSize, 17, FPSTR(__func__)); } + // If set to true, use the Android framework's default sound for the notification. Default values are specified in config.xml (https://android.googlesource.com/platform/frameworks/base/+/master/core/res/res/values/config.xml). - AndroidNotification &default_sound(bool value) { return wr.set(*this, value, buf, bufSize, buf[18], FPSTR(__func__)); } - + AndroidNotification &default_sound(bool value) { return wr.set(*this, value, buf, bufSize, 18, FPSTR(__func__)); } + // If set to true, use the Android framework's default vibrate pattern for the notification. Default values are specified in config.xml (https://android.googlesource.com/platform/frameworks/base/+/master/core/res/res/values/config.xml). If default_vibrate_timings is set to true and vibrate_timings is also set, the default value is used instead of the user-specified vibrate_timings. - AndroidNotification &default_vibrate_timings(bool value) { return wr.set(*this, value, buf, bufSize, buf[19], FPSTR(__func__)); } - + AndroidNotification &default_vibrate_timings(bool value) { return wr.set(*this, value, buf, bufSize, 19, FPSTR(__func__)); } + // If set to true, use the Android framework's default LED light settings for the notification. Default values are specified in config.xml (https://android.googlesource.com/platform/frameworks/base/+/master/core/res/res/values/config.xml). If default_light_settings is set to true and light_settings is also set, the user-specified light_settings is used instead of the default value. - AndroidNotification &default_light_settings(bool value) { return wr.set(*this, value, buf, bufSize, buf[20], FPSTR(__func__)); } - + AndroidNotification &default_light_settings(bool value) { return wr.set(*this, value, buf, bufSize, 20, FPSTR(__func__)); } + // This value represents the item to add to an array. // Set the vibration pattern to use. Pass in an array of protobuf.Duration (https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#google.protobuf.Duration) to turn on or off the vibrator. The first value indicates the Duration to wait before turning the vibrator on. The next value indicates the Duration to keep the vibrator on. Subsequent values alternate between Duration to turn the vibrator off and to turn the vibrator on. If vibrate_timings is set and default_vibrate_timings is set to true, the default value is used instead of the user-specified vibrate_timings. // A duration in seconds with up to nine fractional digits, ending with 's'. Example: "3.5s". // The item or value will be added to the array or list. // To add more items, call this function again. - AndroidNotification &vibrate_timings(const String &value) { return wr.append(*this, value, buf, bufSize, buf[21], FPSTR(__func__)); } - + AndroidNotification &vibrate_timings(const String &value) { return wr.append(*this, value, buf, bufSize, 21, FPSTR(__func__)); } + // Set the Notification.visibility (https://developer.android.com/reference/android/app/Notification.html#visibility) of the notification. - AndroidNotification &visibility(Visibility value) { return wr.set(*this, _Visibility[value].text, buf, bufSize, buf[22], FPSTR(__func__)); } - + AndroidNotification &visibility(Visibility value) { return wr.set(*this, _Visibility[value].text, buf, bufSize, 22, FPSTR(__func__)); } + // Sets the number of items this notification represents. May be displayed as a badge count for launchers that support badging.See Notification Badge (https://developer.android.com/training/notify-user/badges). For example, this might be useful if you're using just one notification to represent multiple new messages but you want the count here to represent the number of total new messages. If zero or unspecified, systems that support badging use the default, which is to increment a number displayed on the long-press menu each time a new notification arrives. - AndroidNotification ¬ification_count(int value) { return wr.set(*this, value, buf, bufSize, buf[23], FPSTR(__func__)); } - + AndroidNotification ¬ification_count(int value) { return wr.set(*this, value, buf, bufSize, 23, FPSTR(__func__)); } + // Settings to control the notification's LED blinking rate and color if LED is available on the device. The total blinking time is controlled by the OS. - AndroidNotification &light_settings(const LightSettings &value) { return wr.set(*this, value, buf, bufSize, buf[24], FPSTR(__func__)); } - + AndroidNotification &light_settings(const LightSettings &value) { return wr.set(*this, value, buf, bufSize, 24, FPSTR(__func__)); } + // Contains the URL of an image that is going to be displayed in a notification. If present, it will override google.firebase.fcm.v1.Notification.image. - AndroidNotification &image(const String &value) { return wr.set(*this, value, buf, bufSize, buf[25], FPSTR(__func__)); } + AndroidNotification &image(const String &value) { return wr.set(*this, value, buf, bufSize, 25, FPSTR(__func__)); } }; /** @@ -228,7 +225,6 @@ namespace Messages struct AndroidFcmOptions : public BaseO1 { public: - // Label associated with the message's analytics data. AndroidFcmOptions &analytics_label(const String &value) { return wr.add(*this, value, buf, FPSTR(__func__)); } }; @@ -240,12 +236,11 @@ namespace Messages { public: - // The link to open when the user clicks on the notification. For all URL values, HTTPS is required. - WebpushFcmOptions &link(const String &value) { return wr.set(*this, value, buf, bufSize, buf[1], FPSTR(__func__)); } - + WebpushFcmOptions &link(const String &value) { return wr.set(*this, value, buf, bufSize, 1, FPSTR(__func__)); } + // Label associated with the message's analytics data. - WebpushFcmOptions &analytics_label(const String &value) { return wr.set(*this, value, buf, bufSize, buf[2], FPSTR(__func__)); } + WebpushFcmOptions &analytics_label(const String &value) { return wr.set(*this, value, buf, bufSize, 2, FPSTR(__func__)); } }; /** @@ -265,20 +260,19 @@ namespace Messages struct WebpushConfig : public BaseO6 { public: - // HTTP headers defined in webpush protocol. Refer to Webpush protocol for supported headers, e.g. "TTL": "15". // An object containing a list of "key": value pairs. Example: { "name": "wrench", "mass": "1.3kg", "count": "3" }. - WebpushConfig &headers(const object_t &value) { return wr.set(*this, value, buf, bufSize, buf[1], FPSTR(__func__)); } - + WebpushConfig &headers(const object_t &value) { return wr.set(*this, value, buf, bufSize, 1, FPSTR(__func__)); } + // Arbitrary key/value payload. If present, it will override google.firebase.fcm.v1.Message.data. // An object containing a list of "key": value pairs. Example: { "name": "wrench", "mass": "1.3kg", "count": "3" }. - WebpushConfig &data(const object_t &value) { return wr.set(*this, value, buf, bufSize, buf[2], FPSTR(__func__)); } - + WebpushConfig &data(const object_t &value) { return wr.set(*this, value, buf, bufSize, 2, FPSTR(__func__)); } + // Web Notification options as a JSON object. Supports Notification instance properties as defined in Web Notification API. If present, "title" and "body" fields override google.firebase.fcm.v1.Notification.title and google.firebase.fcm.v1.Notification.body. - WebpushConfig ¬ification(const object_t &value) { return wr.set(*this, value, buf, bufSize, buf[3], FPSTR(__func__)); } - + WebpushConfig ¬ification(const object_t &value) { return wr.set(*this, value, buf, bufSize, 3, FPSTR(__func__)); } + // Options for features provided by the FCM SDK for Web. - WebpushConfig &fcm_options(const WebpushFcmOptions &value) { return wr.set(*this, value, buf, bufSize, buf[4], FPSTR(__func__)); } + WebpushConfig &fcm_options(const WebpushFcmOptions &value) { return wr.set(*this, value, buf, bufSize, 4, FPSTR(__func__)); } }; /** @@ -288,12 +282,11 @@ namespace Messages { public: - // Label associated with the message's analytics data. - ApnsFcmOptions &analytics_label(const object_t &value) { return wr.set(*this, value, buf, bufSize, buf[1], FPSTR(__func__)); } - + ApnsFcmOptions &analytics_label(const object_t &value) { return wr.set(*this, value, buf, bufSize, 1, FPSTR(__func__)); } + // Contains the URL of an image that is going to be displayed in a notification. If present, it will override google.firebase.fcm.v1.Notification.image. - ApnsFcmOptions &image(const object_t &value) { return wr.set(*this, value, buf, bufSize, buf[2], FPSTR(__func__)); } + ApnsFcmOptions &image(const object_t &value) { return wr.set(*this, value, buf, bufSize, 2, FPSTR(__func__)); } }; /** @@ -303,17 +296,16 @@ namespace Messages { public: - // HTTP request headers defined in Apple Push Notification Service. Refer to APNs request headers for supported headers such as apns-expiration and apns-priority. // The backend sets a default value for apns-expiration of 30 days and a default value for apns-priority of 10 if not explicitly set. // An object containing a list of "key": value pairs. Example: { "name": "wrench", "mass": "1.3kg", "count": "3" }. - ApnsConfig &headers(const object_t &value) { return wr.set(*this, value, buf, bufSize, buf[1], FPSTR(__func__)); } - + ApnsConfig &headers(const object_t &value) { return wr.set(*this, value, buf, bufSize, 1, FPSTR(__func__)); } + // APNs payload as a JSON object, including both aps dictionary and custom payload. See Payload Key Reference. If present, it overrides google.firebase.fcm.v1.Notification.title and google.firebase.fcm.v1.Notification.body. - ApnsConfig &payload(const object_t &value) { return wr.set(*this, value, buf, bufSize, buf[2], FPSTR(__func__)); } - + ApnsConfig &payload(const object_t &value) { return wr.set(*this, value, buf, bufSize, 2, FPSTR(__func__)); } + // Options for features provided by the FCM SDK for iOS. - ApnsConfig &fcm_options(const ApnsFcmOptions &value) { return wr.set(*this, value, buf, bufSize, buf[3], FPSTR(__func__)); } + ApnsConfig &fcm_options(const ApnsFcmOptions &value) { return wr.set(*this, value, buf, bufSize, 3, FPSTR(__func__)); } }; /** @@ -323,32 +315,31 @@ namespace Messages { public: - // An identifier of a group of messages that can be collapsed, so that only the last message gets sent when delivery can be resumed. A maximum of 4 different collapse keys is allowed at any given time. - AndroidConfig &collapse_key(const String &value) { return wr.set(*this, value, buf, bufSize, buf[1], FPSTR(__func__)); } - + AndroidConfig &collapse_key(const String &value) { return wr.set(*this, value, buf, bufSize, 1, FPSTR(__func__)); } + // Message priority. Can take "normal" and "high" values. For more information, see Setting the priority of a message. - AndroidConfig &priority(AndroidMessagePriority value) { return wr.set(*this, _AndroidMessagePriority[value].text, buf, bufSize, buf[2], FPSTR(__func__)); } - + AndroidConfig &priority(AndroidMessagePriority value) { return wr.set(*this, _AndroidMessagePriority[value].text, buf, bufSize, 2, FPSTR(__func__)); } + // How long (in seconds) the message should be kept in FCM storage if the device is offline. The maximum time to live supported is 4 weeks, and the default value is 4 weeks if not set. Set it to 0 if want to send the message immediately. In JSON format, the Duration type is encoded as a string rather than an object, where the string ends in the suffix "s" (indicating seconds) and is preceded by the number of seconds, with nanoseconds expressed as fractional seconds. For example, 3 seconds with 0 nanoseconds should be encoded in JSON format as "3s", while 3 seconds and 1 nanosecond should be expressed in JSON format as "3.000000001s". The ttl will be rounded down to the nearest second. // A duration in seconds with up to nine fractional digits, ending with 's'. Example: "3.5s". - AndroidConfig &ttl(const String &value) { return wr.set(*this, value, buf, bufSize, buf[3], FPSTR(__func__)); } - + AndroidConfig &ttl(const String &value) { return wr.set(*this, value, buf, bufSize, 3, FPSTR(__func__)); } + // Package name of the application where the registration token must match in order to receive the message. - AndroidConfig &restricted_package_name(const String &value) { return wr.set(*this, value, buf, bufSize, buf[4], FPSTR(__func__)); } - + AndroidConfig &restricted_package_name(const String &value) { return wr.set(*this, value, buf, bufSize, 4, FPSTR(__func__)); } + // Arbitrary key/value payload. If present, it will override google.firebase.fcm.v1.Message.data. // An object containing a list of "key": value pairs. Example: { "name": "wrench", "mass": "1.3kg", "count": "3" }. - AndroidConfig &data(const object_t &value) { return wr.set(*this, value, buf, bufSize, buf[5], FPSTR(__func__)); } - + AndroidConfig &data(const object_t &value) { return wr.set(*this, value, buf, bufSize, 5, FPSTR(__func__)); } + // Notification to send to android devices. - AndroidConfig ¬ification(const AndroidNotification &value) { return wr.set(*this, value, buf, bufSize, buf[6], FPSTR(__func__)); } - + AndroidConfig ¬ification(const AndroidNotification &value) { return wr.set(*this, value, buf, bufSize, 6, FPSTR(__func__)); } + // Options for features provided by the FCM SDK for Android. - AndroidConfig &fcm_options(const AndroidFcmOptions &value) { return wr.set(*this, value, buf, bufSize, buf[7], FPSTR(__func__)); } - + AndroidConfig &fcm_options(const AndroidFcmOptions &value) { return wr.set(*this, value, buf, bufSize, 7, FPSTR(__func__)); } + // If set to true, messages will be allowed to be delivered to the app while the device is in direct boot mode. See Support Direct Boot mode (https://developer.android.com/training/articles/direct-boot). - AndroidConfig &direct_boot_ok(bool value) { return wr.set(*this, value, buf, bufSize, buf[8], FPSTR(__func__)); } + AndroidConfig &direct_boot_ok(bool value) { return wr.set(*this, value, buf, bufSize, 8, FPSTR(__func__)); } }; /** @@ -358,37 +349,36 @@ namespace Messages { public: - // Input only. Arbitrary key/value payload, which must be UTF-8 encoded. The key should not be a reserved word ("from", "message_type", or any word starting with "google" or "gcm"). When sending payloads containing only data fields to iOS devices, only normal priority ("apns-priority": "5") is allowed in ApnsConfig. // An object containing a list of "key": value pairs. Example: { "name": "wrench", "mass": "1.3kg", "count": "3" }. - Message &data(const object_t &value) { return wr.set(*this, value, buf, bufSize, buf[1], FPSTR(__func__)); } - + Message &data(const object_t &value) { return wr.set(*this, value, buf, bufSize, 1, FPSTR(__func__)); } + // Input only. Basic notification template to use across all platforms. - Message ¬ification(const Notification &value) { return wr.set(*this, value, buf, bufSize, buf[2], FPSTR(__func__)); } - + Message ¬ification(const Notification &value) { return wr.set(*this, value, buf, bufSize, 2, FPSTR(__func__)); } + // Input only. Android specific options for messages sent through FCM connection server (https://goo.gl/4GLdUl). - Message &android(const AndroidConfig &value) { return wr.set(*this, value, buf, bufSize, buf[3], FPSTR(__func__)); } - + Message &android(const AndroidConfig &value) { return wr.set(*this, value, buf, bufSize, 3, FPSTR(__func__)); } + // Input only. Webpush protocol (https://tools.ietf.org/html/rfc8030) options. - Message &webpush(const WebpushConfig &value) { return wr.set(*this, value, buf, bufSize, buf[4], FPSTR(__func__)); } - + Message &webpush(const WebpushConfig &value) { return wr.set(*this, value, buf, bufSize, 4, FPSTR(__func__)); } + // Input only. Apple Push Notification Service (https://goo.gl/MXRTPa) specific options. - Message &apns(const ApnsConfig &value) { return wr.set(*this, value, buf, bufSize, buf[5], FPSTR(__func__)); } - + Message &apns(const ApnsConfig &value) { return wr.set(*this, value, buf, bufSize, 5, FPSTR(__func__)); } + // Input only. Template for FCM SDK feature options to use across all platforms. - Message &fcm_options(const FcmOptions &value) { return wr.set(*this, value, buf, bufSize, buf[6], FPSTR(__func__)); } - + Message &fcm_options(const FcmOptions &value) { return wr.set(*this, value, buf, bufSize, 6, FPSTR(__func__)); } + // Union field target. // Registration token to send a message to. - Message &token(const String &value) { return wr.set(*this, value, buf, bufSize, buf[7], FPSTR(__func__)); } - + Message &token(const String &value) { return wr.set(*this, value, buf, bufSize, 7, FPSTR(__func__)); } + // Union field target. // Topic name to send a message to, e.g. "weather". Note: "/topics/" prefix should not be provided. - Message &topic(const String &value) { return wr.set(*this, value, buf, bufSize, buf[7], FPSTR(__func__)); } - + Message &topic(const String &value) { return wr.set(*this, value, buf, bufSize, 7, FPSTR(__func__)); } + // Union field target. // Condition to send a message to, e.g. "'foo' in topics && 'bar' in topics". - Message &condition(const String &value) { return wr.set(*this, value, buf, bufSize, buf[7], FPSTR(__func__)); } + Message &condition(const String &value) { return wr.set(*this, value, buf, bufSize, 7, FPSTR(__func__)); } }; class Parent