From 67be77a355787c8c9f1c3fe896d146430176ba2c Mon Sep 17 00:00:00 2001 From: Yoshi Automation Bot <44816363+yoshi-automation@users.noreply.github.com> Date: Fri, 29 Mar 2019 07:12:42 -0700 Subject: [PATCH] Add `value()` and `name()` methods to enum types. (#1769) This PR was generated using Autosynth. :rainbow: Here's the log from Synthtool: ``` synthtool > Executing /tmpfs/src/git/autosynth/working_repo/Bigtable/synth.py. synthtool > Ensuring dependencies. synthtool > Pulling artman image. latest: Pulling from googleapis/artman Digest: sha256:854131ec1af7b3a313253474c24748dc0acd217a58a0b74dbfb559f340a15d78 Status: Image is up to date for googleapis/artman:latest synthtool > Cloning googleapis. synthtool > Running generator for google/bigtable/artman_bigtable.yaml. synthtool > Generated code into /home/kbuilder/.cache/synthtool/googleapis/artman-genfiles/php/google-cloud-bigtable-v2. synthtool > No files in sources /home/kbuilder/.cache/synthtool/googleapis/artman-genfiles/php/google-cloud-bigtable-v2/proto/src/Google/Cloud/BigTable were copied. Does the source contain files? synthtool > Running generator for google/bigtable/admin/artman_bigtableadmin.yaml. synthtool > Generated code into /home/kbuilder/.cache/synthtool/googleapis/artman-genfiles/php/google-cloud-bigtable-admin-v2. synthtool > Replaced 'Copyright \\d{4}' in src/Admin/V2/Gapic/BigtableTableAdminGapicClient.php. synthtool > Replaced 'Copyright \\d{4}' in src/Admin/V2/Gapic/BigtableInstanceAdminGapicClient.php. synthtool > Replaced 'Copyright \\d{4}' in src/V2/Gapic/BigtableGapicClient.php. synthtool > Replaced 'Copyright \\d{4}' in tests/Unit/V2/BigtableClientTest.php. synthtool > Replaced 'Copyright \\d{4}' in tests/Unit/Admin/V2/BigtableTableAdminClientTest.php. synthtool > Replaced 'Copyright \\d{4}' in tests/Unit/Admin/V2/BigtableInstanceAdminClientTest.php. synthtool > Replaced 'Cluster_State' in src/Admin/V2/Gapic/BigtableInstanceAdminGapicClient.php. synthtool > Replaced 'Instance_Type' in src/Admin/V2/Gapic/BigtableInstanceAdminGapicClient.php. synthtool > Replaced 'Instance_State' in src/Admin/V2/Gapic/BigtableInstanceAdminGapicClient.php. synthtool > Replaced 'CreateTableRequest_Split' in src/Admin/V2/Gapic/BigtableTableAdminGapicClient.php. synthtool > Replaced 'ModifyColumnFamiliesRequest_Modification' in src/Admin/V2/Gapic/BigtableTableAdminGapicClient.php. synthtool > Replaced 'Table_View' in src/Admin/V2/Gapic/BigtableTableAdminGapicClient.php. synthtool > Replaced 'MutateRowsRequest_Entry' in src/V2/Gapic/BigtableGapicClient.php. synthtool > Replaced 'namespace\\ Google\\\\Cloud\\\\Bigtable\\\\Admin\\\\Tests\\\\Unit' in tests/Unit/Admin/V2/BigtableTableAdminClientTest.php. synthtool > Replaced 'namespace\\ Google\\\\Cloud\\\\Bigtable\\\\Admin\\\\Tests\\\\Unit' in tests/Unit/Admin/V2/BigtableInstanceAdminClientTest.php. synthtool > Cleaned up 1 temporary directories. synthtool > Wrote metadata to synth.metadata. ``` --- .../Admin/V2/BigtableInstanceAdmin.php | 2 +- .../metadata/Admin/V2/BigtableTableAdmin.php | 2 +- Bigtable/metadata/Admin/V2/Common.php | 2 +- Bigtable/metadata/Admin/V2/Instance.php | 2 +- Bigtable/metadata/Admin/V2/Table.php | 2 +- Bigtable/metadata/V2/Bigtable.php | 2 +- Bigtable/metadata/V2/Data.php | 2 +- Bigtable/src/Admin/V2/Cluster/State.php | 30 +++++++++++++++++++ Bigtable/src/Admin/V2/Instance/State.php | 28 +++++++++++++++++ Bigtable/src/Admin/V2/Instance/Type.php | 28 +++++++++++++++++ Bigtable/src/Admin/V2/Snapshot/State.php | 28 +++++++++++++++++ Bigtable/src/Admin/V2/StorageType.php | 28 +++++++++++++++++ .../Table/ClusterState/ReplicationState.php | 30 +++++++++++++++++++ .../Admin/V2/Table/TimestampGranularity.php | 27 +++++++++++++++++ Bigtable/src/Admin/V2/Table/View.php | 30 +++++++++++++++++++ Bigtable/synth.metadata | 10 +++---- 16 files changed, 241 insertions(+), 12 deletions(-) diff --git a/Bigtable/metadata/Admin/V2/BigtableInstanceAdmin.php b/Bigtable/metadata/Admin/V2/BigtableInstanceAdmin.php index 8f981bfda205..fb4cea7a5052 100644 --- a/Bigtable/metadata/Admin/V2/BigtableInstanceAdmin.php +++ b/Bigtable/metadata/Admin/V2/BigtableInstanceAdmin.php @@ -224,7 +224,7 @@ public static function initOnce() { "6e2f76323b61646d696eaa021e476f6f676c652e436c6f75642e42696774" . "61626c652e41646d696e2e5632ca021e476f6f676c655c436c6f75645c42" . "69677461626c655c41646d696e5c5632620670726f746f33" - )); + ), true); static::$is_initialized = true; } diff --git a/Bigtable/metadata/Admin/V2/BigtableTableAdmin.php b/Bigtable/metadata/Admin/V2/BigtableTableAdmin.php index 1afd0de745f9..dfa756478a28 100644 --- a/Bigtable/metadata/Admin/V2/BigtableTableAdmin.php +++ b/Bigtable/metadata/Admin/V2/BigtableTableAdmin.php @@ -181,7 +181,7 @@ public static function initOnce() { "1e476f6f676c652e436c6f75642e4269677461626c652e41646d696e2e56" . "32ca021e476f6f676c655c436c6f75645c4269677461626c655c41646d69" . "6e5c5632620670726f746f33" - )); + ), true); static::$is_initialized = true; } diff --git a/Bigtable/metadata/Admin/V2/Common.php b/Bigtable/metadata/Admin/V2/Common.php index 88dbc56e910d..e026a2327bb8 100644 --- a/Bigtable/metadata/Admin/V2/Common.php +++ b/Bigtable/metadata/Admin/V2/Common.php @@ -29,7 +29,7 @@ public static function initOnce() { "61646d696eaa021e476f6f676c652e436c6f75642e4269677461626c652e" . "41646d696e2e5632ca021e476f6f676c655c436c6f75645c426967746162" . "6c655c41646d696e5c5632620670726f746f33" - )); + ), true); static::$is_initialized = true; } diff --git a/Bigtable/metadata/Admin/V2/Instance.php b/Bigtable/metadata/Admin/V2/Instance.php index 590ce6a5ff8e..710f133a3e62 100644 --- a/Bigtable/metadata/Admin/V2/Instance.php +++ b/Bigtable/metadata/Admin/V2/Instance.php @@ -62,7 +62,7 @@ public static function initOnce() { "61646d696e2f76323b61646d696eaa021e476f6f676c652e436c6f75642e" . "4269677461626c652e41646d696e2e5632ca021e476f6f676c655c436c6f" . "75645c4269677461626c655c41646d696e5c5632620670726f746f33" - )); + ), true); static::$is_initialized = true; } diff --git a/Bigtable/metadata/Admin/V2/Table.php b/Bigtable/metadata/Admin/V2/Table.php index 2937ee8f522a..c9e0586358b2 100644 --- a/Bigtable/metadata/Admin/V2/Table.php +++ b/Bigtable/metadata/Admin/V2/Table.php @@ -82,7 +82,7 @@ public static function initOnce() { "323b61646d696eaa021e476f6f676c652e436c6f75642e4269677461626c" . "652e41646d696e2e5632ca021e476f6f676c655c436c6f75645c42696774" . "61626c655c41646d696e5c5632620670726f746f33" - )); + ), true); static::$is_initialized = true; } diff --git a/Bigtable/metadata/V2/Bigtable.php b/Bigtable/metadata/V2/Bigtable.php index cf241f8a8511..766a5157dfd3 100644 --- a/Bigtable/metadata/V2/Bigtable.php +++ b/Bigtable/metadata/V2/Bigtable.php @@ -123,7 +123,7 @@ public static function initOnce() { "61626c65aa0218476f6f676c652e436c6f75642e4269677461626c652e56" . "32ca0218476f6f676c655c436c6f75645c4269677461626c655c56326206" . "70726f746f33" - )); + ), true); static::$is_initialized = true; } diff --git a/Bigtable/metadata/V2/Data.php b/Bigtable/metadata/V2/Data.php index 78af833aa089..0a9db851b24c 100644 --- a/Bigtable/metadata/V2/Data.php +++ b/Bigtable/metadata/V2/Data.php @@ -115,7 +115,7 @@ public static function initOnce() { "323b6269677461626c65aa0218476f6f676c652e436c6f75642e42696774" . "61626c652e5632ca0218476f6f676c655c436c6f75645c4269677461626c" . "655c5632620670726f746f33" - )); + ), true); static::$is_initialized = true; } diff --git a/Bigtable/src/Admin/V2/Cluster/State.php b/Bigtable/src/Admin/V2/Cluster/State.php index 09a71ce437bd..fc392006912f 100644 --- a/Bigtable/src/Admin/V2/Cluster/State.php +++ b/Bigtable/src/Admin/V2/Cluster/State.php @@ -4,6 +4,8 @@ namespace Google\Cloud\Bigtable\Admin\V2\Cluster; +use UnexpectedValueException; + /** * Possible states of a cluster. * @@ -48,6 +50,34 @@ class State * Generated from protobuf enum DISABLED = 4; */ const DISABLED = 4; + + private static $valueToName = [ + self::STATE_NOT_KNOWN => 'STATE_NOT_KNOWN', + self::READY => 'READY', + self::CREATING => 'CREATING', + self::RESIZING => 'RESIZING', + self::DISABLED => 'DISABLED', + ]; + + public static function name($value) + { + if (!isset(self::$valueToName[$value])) { + throw new UnexpectedValueException(sprintf( + 'Enum %s has no name defined for value %s', __CLASS__, $value)); + } + return self::$valueToName[$value]; + } + + + public static function value($name) + { + $const = __CLASS__ . '::' . strtoupper($name); + if (!defined($const)) { + throw new UnexpectedValueException(sprintf( + 'Enum %s has no value defined for name %s', __CLASS__, $name)); + } + return constant($const); + } } // Adding a class alias for backwards compatibility with the previous class name. diff --git a/Bigtable/src/Admin/V2/Instance/State.php b/Bigtable/src/Admin/V2/Instance/State.php index 15a9e0f47cec..8442f3728c83 100644 --- a/Bigtable/src/Admin/V2/Instance/State.php +++ b/Bigtable/src/Admin/V2/Instance/State.php @@ -4,6 +4,8 @@ namespace Google\Cloud\Bigtable\Admin\V2\Instance; +use UnexpectedValueException; + /** * Possible states of an instance. * @@ -31,6 +33,32 @@ class State * Generated from protobuf enum CREATING = 2; */ const CREATING = 2; + + private static $valueToName = [ + self::STATE_NOT_KNOWN => 'STATE_NOT_KNOWN', + self::READY => 'READY', + self::CREATING => 'CREATING', + ]; + + public static function name($value) + { + if (!isset(self::$valueToName[$value])) { + throw new UnexpectedValueException(sprintf( + 'Enum %s has no name defined for value %s', __CLASS__, $value)); + } + return self::$valueToName[$value]; + } + + + public static function value($name) + { + $const = __CLASS__ . '::' . strtoupper($name); + if (!defined($const)) { + throw new UnexpectedValueException(sprintf( + 'Enum %s has no value defined for name %s', __CLASS__, $name)); + } + return constant($const); + } } // Adding a class alias for backwards compatibility with the previous class name. diff --git a/Bigtable/src/Admin/V2/Instance/Type.php b/Bigtable/src/Admin/V2/Instance/Type.php index 7e327c9617d6..8e524de65eaa 100644 --- a/Bigtable/src/Admin/V2/Instance/Type.php +++ b/Bigtable/src/Admin/V2/Instance/Type.php @@ -4,6 +4,8 @@ namespace Google\Cloud\Bigtable\Admin\V2\Instance; +use UnexpectedValueException; + /** * The type of the instance. * @@ -38,6 +40,32 @@ class Type * Generated from protobuf enum DEVELOPMENT = 2; */ const DEVELOPMENT = 2; + + private static $valueToName = [ + self::TYPE_UNSPECIFIED => 'TYPE_UNSPECIFIED', + self::PRODUCTION => 'PRODUCTION', + self::DEVELOPMENT => 'DEVELOPMENT', + ]; + + public static function name($value) + { + if (!isset(self::$valueToName[$value])) { + throw new UnexpectedValueException(sprintf( + 'Enum %s has no name defined for value %s', __CLASS__, $value)); + } + return self::$valueToName[$value]; + } + + + public static function value($name) + { + $const = __CLASS__ . '::' . strtoupper($name); + if (!defined($const)) { + throw new UnexpectedValueException(sprintf( + 'Enum %s has no value defined for name %s', __CLASS__, $name)); + } + return constant($const); + } } // Adding a class alias for backwards compatibility with the previous class name. diff --git a/Bigtable/src/Admin/V2/Snapshot/State.php b/Bigtable/src/Admin/V2/Snapshot/State.php index 0891428f3156..07c31a2775e2 100644 --- a/Bigtable/src/Admin/V2/Snapshot/State.php +++ b/Bigtable/src/Admin/V2/Snapshot/State.php @@ -4,6 +4,8 @@ namespace Google\Cloud\Bigtable\Admin\V2\Snapshot; +use UnexpectedValueException; + /** * Possible states of a snapshot. * @@ -31,6 +33,32 @@ class State * Generated from protobuf enum CREATING = 2; */ const CREATING = 2; + + private static $valueToName = [ + self::STATE_NOT_KNOWN => 'STATE_NOT_KNOWN', + self::READY => 'READY', + self::CREATING => 'CREATING', + ]; + + public static function name($value) + { + if (!isset(self::$valueToName[$value])) { + throw new UnexpectedValueException(sprintf( + 'Enum %s has no name defined for value %s', __CLASS__, $value)); + } + return self::$valueToName[$value]; + } + + + public static function value($name) + { + $const = __CLASS__ . '::' . strtoupper($name); + if (!defined($const)) { + throw new UnexpectedValueException(sprintf( + 'Enum %s has no value defined for name %s', __CLASS__, $name)); + } + return constant($const); + } } // Adding a class alias for backwards compatibility with the previous class name. diff --git a/Bigtable/src/Admin/V2/StorageType.php b/Bigtable/src/Admin/V2/StorageType.php index 6a0fb690dc46..9bc95b2df390 100644 --- a/Bigtable/src/Admin/V2/StorageType.php +++ b/Bigtable/src/Admin/V2/StorageType.php @@ -4,6 +4,8 @@ namespace Google\Cloud\Bigtable\Admin\V2; +use UnexpectedValueException; + /** * Storage media types for persisting Bigtable data. * @@ -29,5 +31,31 @@ class StorageType * Generated from protobuf enum HDD = 2; */ const HDD = 2; + + private static $valueToName = [ + self::STORAGE_TYPE_UNSPECIFIED => 'STORAGE_TYPE_UNSPECIFIED', + self::SSD => 'SSD', + self::HDD => 'HDD', + ]; + + public static function name($value) + { + if (!isset(self::$valueToName[$value])) { + throw new UnexpectedValueException(sprintf( + 'Enum %s has no name defined for value %s', __CLASS__, $value)); + } + return self::$valueToName[$value]; + } + + + public static function value($name) + { + $const = __CLASS__ . '::' . strtoupper($name); + if (!defined($const)) { + throw new UnexpectedValueException(sprintf( + 'Enum %s has no value defined for name %s', __CLASS__, $name)); + } + return constant($const); + } } diff --git a/Bigtable/src/Admin/V2/Table/ClusterState/ReplicationState.php b/Bigtable/src/Admin/V2/Table/ClusterState/ReplicationState.php index 3ed78a0f71f1..951277a057be 100644 --- a/Bigtable/src/Admin/V2/Table/ClusterState/ReplicationState.php +++ b/Bigtable/src/Admin/V2/Table/ClusterState/ReplicationState.php @@ -4,6 +4,8 @@ namespace Google\Cloud\Bigtable\Admin\V2\Table\ClusterState; +use UnexpectedValueException; + /** * Table replication states. * @@ -47,6 +49,34 @@ class ReplicationState * Generated from protobuf enum READY = 4; */ const READY = 4; + + private static $valueToName = [ + self::STATE_NOT_KNOWN => 'STATE_NOT_KNOWN', + self::INITIALIZING => 'INITIALIZING', + self::PLANNED_MAINTENANCE => 'PLANNED_MAINTENANCE', + self::UNPLANNED_MAINTENANCE => 'UNPLANNED_MAINTENANCE', + self::READY => 'READY', + ]; + + public static function name($value) + { + if (!isset(self::$valueToName[$value])) { + throw new UnexpectedValueException(sprintf( + 'Enum %s has no name defined for value %s', __CLASS__, $value)); + } + return self::$valueToName[$value]; + } + + + public static function value($name) + { + $const = __CLASS__ . '::' . strtoupper($name); + if (!defined($const)) { + throw new UnexpectedValueException(sprintf( + 'Enum %s has no value defined for name %s', __CLASS__, $name)); + } + return constant($const); + } } // Adding a class alias for backwards compatibility with the previous class name. diff --git a/Bigtable/src/Admin/V2/Table/TimestampGranularity.php b/Bigtable/src/Admin/V2/Table/TimestampGranularity.php index 2264e067fab5..67b1b6d1f95f 100644 --- a/Bigtable/src/Admin/V2/Table/TimestampGranularity.php +++ b/Bigtable/src/Admin/V2/Table/TimestampGranularity.php @@ -4,6 +4,8 @@ namespace Google\Cloud\Bigtable\Admin\V2\Table; +use UnexpectedValueException; + /** * Possible timestamp granularities to use when keeping multiple versions * of data in a table. @@ -25,6 +27,31 @@ class TimestampGranularity * Generated from protobuf enum MILLIS = 1; */ const MILLIS = 1; + + private static $valueToName = [ + self::TIMESTAMP_GRANULARITY_UNSPECIFIED => 'TIMESTAMP_GRANULARITY_UNSPECIFIED', + self::MILLIS => 'MILLIS', + ]; + + public static function name($value) + { + if (!isset(self::$valueToName[$value])) { + throw new UnexpectedValueException(sprintf( + 'Enum %s has no name defined for value %s', __CLASS__, $value)); + } + return self::$valueToName[$value]; + } + + + public static function value($name) + { + $const = __CLASS__ . '::' . strtoupper($name); + if (!defined($const)) { + throw new UnexpectedValueException(sprintf( + 'Enum %s has no value defined for name %s', __CLASS__, $name)); + } + return constant($const); + } } // Adding a class alias for backwards compatibility with the previous class name. diff --git a/Bigtable/src/Admin/V2/Table/View.php b/Bigtable/src/Admin/V2/Table/View.php index 5875146dd170..812ed1e61696 100644 --- a/Bigtable/src/Admin/V2/Table/View.php +++ b/Bigtable/src/Admin/V2/Table/View.php @@ -4,6 +4,8 @@ namespace Google\Cloud\Bigtable\Admin\V2\Table; +use UnexpectedValueException; + /** * Defines a view over a table's fields. * @@ -42,6 +44,34 @@ class View * Generated from protobuf enum FULL = 4; */ const FULL = 4; + + private static $valueToName = [ + self::VIEW_UNSPECIFIED => 'VIEW_UNSPECIFIED', + self::NAME_ONLY => 'NAME_ONLY', + self::SCHEMA_VIEW => 'SCHEMA_VIEW', + self::REPLICATION_VIEW => 'REPLICATION_VIEW', + self::FULL => 'FULL', + ]; + + public static function name($value) + { + if (!isset(self::$valueToName[$value])) { + throw new UnexpectedValueException(sprintf( + 'Enum %s has no name defined for value %s', __CLASS__, $value)); + } + return self::$valueToName[$value]; + } + + + public static function value($name) + { + $const = __CLASS__ . '::' . strtoupper($name); + if (!defined($const)) { + throw new UnexpectedValueException(sprintf( + 'Enum %s has no value defined for name %s', __CLASS__, $name)); + } + return constant($const); + } } // Adding a class alias for backwards compatibility with the previous class name. diff --git a/Bigtable/synth.metadata b/Bigtable/synth.metadata index ad9599d4d2b2..399bda469ffd 100644 --- a/Bigtable/synth.metadata +++ b/Bigtable/synth.metadata @@ -1,19 +1,19 @@ { - "updateTime": "2019-02-05T15:52:21.046173Z", + "updateTime": "2019-03-29T09:58:56.375943Z", "sources": [ { "generator": { "name": "artman", - "version": "0.16.9", - "dockerImage": "googleapis/artman@sha256:80c39fa84e7203c8f355e01bdeef82155013cc39dcaa48fba7a6fe2c253623e3" + "version": "0.16.21", + "dockerImage": "googleapis/artman@sha256:854131ec1af7b3a313253474c24748dc0acd217a58a0b74dbfb559f340a15d78" } }, { "git": { "name": "googleapis", "remote": "https://github.com/googleapis/googleapis.git", - "sha": "f26c727dde5051abefc5ad9e7dee82a2686ad2b0", - "internalRef": "232306662" + "sha": "37386f1ebcaed51bcb7d15d00124d22c38606e45", + "internalRef": "240841842" } } ],