repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
list
docstring
stringlengths
3
47.2k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
91
247
partition
stringclasses
1 value
googleapis/google-cloud-php
Logging/src/LoggingClient.php
LoggingClient.entries
public function entries(array $options = []) { $resultLimit = $this->pluck('resultLimit', $options, false); $resourceNames = ['projects/' . $this->projectId]; if (isset($options['projectIds'])) { foreach ($options['projectIds'] as $projectId) { $resourceNames[] = 'projects/' . $projectId; } unset($options['projectIds']); } if (isset($options['resourceNames'])) { $options['resourceNames'] = array_merge($resourceNames, $options['projectIds']); } else { $options['resourceNames'] = $resourceNames; } return new ItemIterator( new PageIterator( function (array $entry) { return new Entry($entry); }, [$this->connection, 'listEntries'], $options, [ 'itemsKey' => 'entries', 'resultLimit' => $resultLimit ] ) ); }
php
public function entries(array $options = []) { $resultLimit = $this->pluck('resultLimit', $options, false); $resourceNames = ['projects/' . $this->projectId]; if (isset($options['projectIds'])) { foreach ($options['projectIds'] as $projectId) { $resourceNames[] = 'projects/' . $projectId; } unset($options['projectIds']); } if (isset($options['resourceNames'])) { $options['resourceNames'] = array_merge($resourceNames, $options['projectIds']); } else { $options['resourceNames'] = $resourceNames; } return new ItemIterator( new PageIterator( function (array $entry) { return new Entry($entry); }, [$this->connection, 'listEntries'], $options, [ 'itemsKey' => 'entries', 'resultLimit' => $resultLimit ] ) ); }
[ "public", "function", "entries", "(", "array", "$", "options", "=", "[", "]", ")", "{", "$", "resultLimit", "=", "$", "this", "->", "pluck", "(", "'resultLimit'", ",", "$", "options", ",", "false", ")", ";", "$", "resourceNames", "=", "[", "'projects/'", ".", "$", "this", "->", "projectId", "]", ";", "if", "(", "isset", "(", "$", "options", "[", "'projectIds'", "]", ")", ")", "{", "foreach", "(", "$", "options", "[", "'projectIds'", "]", "as", "$", "projectId", ")", "{", "$", "resourceNames", "[", "]", "=", "'projects/'", ".", "$", "projectId", ";", "}", "unset", "(", "$", "options", "[", "'projectIds'", "]", ")", ";", "}", "if", "(", "isset", "(", "$", "options", "[", "'resourceNames'", "]", ")", ")", "{", "$", "options", "[", "'resourceNames'", "]", "=", "array_merge", "(", "$", "resourceNames", ",", "$", "options", "[", "'projectIds'", "]", ")", ";", "}", "else", "{", "$", "options", "[", "'resourceNames'", "]", "=", "$", "resourceNames", ";", "}", "return", "new", "ItemIterator", "(", "new", "PageIterator", "(", "function", "(", "array", "$", "entry", ")", "{", "return", "new", "Entry", "(", "$", "entry", ")", ";", "}", ",", "[", "$", "this", "->", "connection", ",", "'listEntries'", "]", ",", "$", "options", ",", "[", "'itemsKey'", "=>", "'entries'", ",", "'resultLimit'", "=>", "$", "resultLimit", "]", ")", ")", ";", "}" ]
Fetches log entries. Example: ``` $entries = $logging->entries(); foreach ($entries as $entry) { echo $entry->info()['textPayload'] . PHP_EOL; } ``` ``` // Use an advanced logs filter to fetch only entries from a specified log. $entries = $logging->entries([ 'filter' => 'logName = projects/my-project/logs/my-log' ]); foreach ($entries as $entry) { echo $entry->info()['textPayload'] . PHP_EOL; } ``` @codingStandardsIgnoreStart @see https://cloud.google.com/logging/docs/api/reference/rest/v2/entries/list Entries list API documentation. @codingStandardsIgnoreEnd @param array $options [optional] { Configuration options. @type string[] $projectIds A list of projectIds to fetch entries from in addition to entries found in the project bound to this client. @type string[] $resourceNames One or more cloud resources from which to retrieve log entries. Projects listed in projectIds are added to this list. Example: "projects/my-project-1A", "projects/1234567890". @type string $filter An [advanced logs filter](https://cloud.google.com/logging/docs/view/advanced_filters). @type string $orderBy How the results should be sorted. Presently, the only permitted values are `timestamp asc` and `timestamp desc`. **Defaults to** `"timestamp asc"`. @type int $pageSize The maximum number of results to return per request. @type int $resultLimit Limit the number of results returned in total. **Defaults to** `0` (return all results). @type string $pageToken A previously-returned page token used to resume the loading of results from a specific point. } @return ItemIterator<Entry>
[ "Fetches", "log", "entries", "." ]
ff5030ffa1f12904565509a7bc24ecc0bd794a3e
https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Logging/src/LoggingClient.php#L456-L485
train
googleapis/google-cloud-php
Logging/src/LoggingClient.php
LoggingClient.psrLogger
public function psrLogger($name, array $options = []) { $messageKey = null; if (isset($options['messageKey'])) { $messageKey = $options['messageKey']; unset($options['messageKey']); } $psrLoggerOptions = $this->pluckArray([ 'metadataProvider', 'batchEnabled', 'debugOutput', 'batchOptions', 'clientConfig', 'batchRunner', 'closureSerializer', 'debugOutputResource' ], $options); return new PsrLogger( $this->logger($name, $options), $messageKey, $psrLoggerOptions + [ 'clientConfig' => $this->config ] ); }
php
public function psrLogger($name, array $options = []) { $messageKey = null; if (isset($options['messageKey'])) { $messageKey = $options['messageKey']; unset($options['messageKey']); } $psrLoggerOptions = $this->pluckArray([ 'metadataProvider', 'batchEnabled', 'debugOutput', 'batchOptions', 'clientConfig', 'batchRunner', 'closureSerializer', 'debugOutputResource' ], $options); return new PsrLogger( $this->logger($name, $options), $messageKey, $psrLoggerOptions + [ 'clientConfig' => $this->config ] ); }
[ "public", "function", "psrLogger", "(", "$", "name", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "messageKey", "=", "null", ";", "if", "(", "isset", "(", "$", "options", "[", "'messageKey'", "]", ")", ")", "{", "$", "messageKey", "=", "$", "options", "[", "'messageKey'", "]", ";", "unset", "(", "$", "options", "[", "'messageKey'", "]", ")", ";", "}", "$", "psrLoggerOptions", "=", "$", "this", "->", "pluckArray", "(", "[", "'metadataProvider'", ",", "'batchEnabled'", ",", "'debugOutput'", ",", "'batchOptions'", ",", "'clientConfig'", ",", "'batchRunner'", ",", "'closureSerializer'", ",", "'debugOutputResource'", "]", ",", "$", "options", ")", ";", "return", "new", "PsrLogger", "(", "$", "this", "->", "logger", "(", "$", "name", ",", "$", "options", ")", ",", "$", "messageKey", ",", "$", "psrLoggerOptions", "+", "[", "'clientConfig'", "=>", "$", "this", "->", "config", "]", ")", ";", "}" ]
Fetches a logger which will write log entries to Stackdriver Logging and implements the PSR-3 specification. Example: ``` $psrLogger = $logging->psrLogger('my-log'); ``` ``` // Write entries with background batching. $psrLogger = $logging->psrLogger('my-log', [ 'batchEnabled' => true ]); ``` @param string $name The name of the log to write entries to. @param array $options [optional] { Configuration options. @type string $messageKey The key in the `jsonPayload` used to contain the logged message. **Defaults to** `message`. @type array $resource The [monitored resource](https://cloud.google.com/logging/docs/api/reference/rest/v2/MonitoredResource) to associate log entries with. **Defaults to** type global. @type array $labels A set of user-defined (key, value) data that provides additional information about the log entry. @type MetadataProviderInterface $metadataProvider **Defaults to** An automatically chosen provider, based on detected environment settings. @type bool $batchEnabled Determines whether or not to use background batching. **Defaults to** `false`. @type bool $debugOutput Whether or not to output debug information. Please note debug output currently only applies in CLI based applications. **Defaults to** `false`. Applies only when `batchEnabled` is set to `true`. @type resource $debugOutputResource A resource to output debug output to. Applies only when `batchEnabled` is set to `true`. @type array $batchOptions A set of options for a BatchJob. {@see \Google\Cloud\Core\Batch\BatchJob::__construct()} for more details. **Defaults to** ['batchSize' => 1000, 'callPeriod' => 2.0, 'numWorkers' => 2]. Applies only when `batchEnabled` is set to `true`. Note that this option is currently considered **experimental** and is subject to change. @type array $clientConfig Configuration options for the Logging client used to handle processing of batch items. For valid options please see {@see \Google\Cloud\Logging\LoggingClient::__construct()}. **Defaults to** the options provided to the current client. Applies only when `batchEnabled` is set to `true`. @type BatchRunner $batchRunner A BatchRunner object. Mainly used for the tests to inject a mock. **Defaults to** a newly created BatchRunner. Applies only when `batchEnabled` is set to `true`. @type ClosureSerializerInterface $closureSerializer An implementation responsible for serializing closures used in the `$clientConfig`. This is especially important when using the batch daemon. **Defaults to** {@see Google\Cloud\Core\Batch\OpisClosureSerializer} if the `opis/closure` library is installed. } @return PsrLogger
[ "Fetches", "a", "logger", "which", "will", "write", "log", "entries", "to", "Stackdriver", "Logging", "and", "implements", "the", "PSR", "-", "3", "specification", "." ]
ff5030ffa1f12904565509a7bc24ecc0bd794a3e
https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Logging/src/LoggingClient.php#L551-L578
train
googleapis/google-cloud-php
Logging/src/LoggingClient.php
LoggingClient.logger
public function logger($name, array $options = []) { return new Logger( $this->connection, $name, $this->projectId, isset($options['resource']) ? $options['resource'] : null, isset($options['labels']) ? $options['labels'] : null ); }
php
public function logger($name, array $options = []) { return new Logger( $this->connection, $name, $this->projectId, isset($options['resource']) ? $options['resource'] : null, isset($options['labels']) ? $options['labels'] : null ); }
[ "public", "function", "logger", "(", "$", "name", ",", "array", "$", "options", "=", "[", "]", ")", "{", "return", "new", "Logger", "(", "$", "this", "->", "connection", ",", "$", "name", ",", "$", "this", "->", "projectId", ",", "isset", "(", "$", "options", "[", "'resource'", "]", ")", "?", "$", "options", "[", "'resource'", "]", ":", "null", ",", "isset", "(", "$", "options", "[", "'labels'", "]", ")", "?", "$", "options", "[", "'labels'", "]", ":", "null", ")", ";", "}" ]
Fetches a logger which will write log entries to Stackdriver Logging. Example: ``` $logger = $logging->logger('my-log'); ``` @param string $name The name of the log to write entries to. @param array $options [optional] { Configuration options. @type array $resource The [monitored resource](https://cloud.google.com/logging/docs/api/reference/rest/v2/MonitoredResource) to associate log entries with. **Defaults to** type global. @type array $labels A set of user-defined (key, value) data that provides additional information about the log entry. } @return Logger
[ "Fetches", "a", "logger", "which", "will", "write", "log", "entries", "to", "Stackdriver", "Logging", "." ]
ff5030ffa1f12904565509a7bc24ecc0bd794a3e
https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Logging/src/LoggingClient.php#L600-L609
train
googleapis/google-cloud-php
SecurityCenter/src/V1/ListSourcesResponse.php
ListSourcesResponse.setSources
public function setSources($var) { $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\SecurityCenter\V1\Source::class); $this->sources = $arr; return $this; }
php
public function setSources($var) { $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\SecurityCenter\V1\Source::class); $this->sources = $arr; return $this; }
[ "public", "function", "setSources", "(", "$", "var", ")", "{", "$", "arr", "=", "GPBUtil", "::", "checkRepeatedField", "(", "$", "var", ",", "\\", "Google", "\\", "Protobuf", "\\", "Internal", "\\", "GPBType", "::", "MESSAGE", ",", "\\", "Google", "\\", "Cloud", "\\", "SecurityCenter", "\\", "V1", "\\", "Source", "::", "class", ")", ";", "$", "this", "->", "sources", "=", "$", "arr", ";", "return", "$", "this", ";", "}" ]
Sources belonging to the requested parent. Generated from protobuf field <code>repeated .google.cloud.securitycenter.v1.Source sources = 1;</code> @param \Google\Cloud\SecurityCenter\V1\Source[]|\Google\Protobuf\Internal\RepeatedField $var @return $this
[ "Sources", "belonging", "to", "the", "requested", "parent", "." ]
ff5030ffa1f12904565509a7bc24ecc0bd794a3e
https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/SecurityCenter/src/V1/ListSourcesResponse.php#L68-L74
train
googleapis/google-cloud-php
Dataproc/src/V1beta2/ClusterSelector.php
ClusterSelector.setClusterLabels
public function setClusterLabels($var) { $arr = GPBUtil::checkMapField($var, \Google\Protobuf\Internal\GPBType::STRING, \Google\Protobuf\Internal\GPBType::STRING); $this->cluster_labels = $arr; return $this; }
php
public function setClusterLabels($var) { $arr = GPBUtil::checkMapField($var, \Google\Protobuf\Internal\GPBType::STRING, \Google\Protobuf\Internal\GPBType::STRING); $this->cluster_labels = $arr; return $this; }
[ "public", "function", "setClusterLabels", "(", "$", "var", ")", "{", "$", "arr", "=", "GPBUtil", "::", "checkMapField", "(", "$", "var", ",", "\\", "Google", "\\", "Protobuf", "\\", "Internal", "\\", "GPBType", "::", "STRING", ",", "\\", "Google", "\\", "Protobuf", "\\", "Internal", "\\", "GPBType", "::", "STRING", ")", ";", "$", "this", "->", "cluster_labels", "=", "$", "arr", ";", "return", "$", "this", ";", "}" ]
Required. The cluster labels. Cluster must have all labels to match. Generated from protobuf field <code>map<string, string> cluster_labels = 2;</code> @param array|\Google\Protobuf\Internal\MapField $var @return $this
[ "Required", ".", "The", "cluster", "labels", ".", "Cluster", "must", "have", "all", "labels", "to", "match", "." ]
ff5030ffa1f12904565509a7bc24ecc0bd794a3e
https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Dataproc/src/V1beta2/ClusterSelector.php#L108-L114
train
googleapis/google-cloud-php
Storage/src/Bucket.php
Bucket.upload
public function upload($data, array $options = []) { if ($this->isObjectNameRequired($data) && !isset($options['name'])) { throw new \InvalidArgumentException('A name is required when data is of type string or null.'); } $encryptionKey = isset($options['encryptionKey']) ? $options['encryptionKey'] : null; $encryptionKeySHA256 = isset($options['encryptionKeySHA256']) ? $options['encryptionKeySHA256'] : null; $response = $this->connection->insertObject( $this->formatEncryptionHeaders($options) + $this->identity + [ 'data' => $data ] )->upload(); return new StorageObject( $this->connection, $response['name'], $this->identity['bucket'], $response['generation'], $response, $encryptionKey, $encryptionKeySHA256 ); }
php
public function upload($data, array $options = []) { if ($this->isObjectNameRequired($data) && !isset($options['name'])) { throw new \InvalidArgumentException('A name is required when data is of type string or null.'); } $encryptionKey = isset($options['encryptionKey']) ? $options['encryptionKey'] : null; $encryptionKeySHA256 = isset($options['encryptionKeySHA256']) ? $options['encryptionKeySHA256'] : null; $response = $this->connection->insertObject( $this->formatEncryptionHeaders($options) + $this->identity + [ 'data' => $data ] )->upload(); return new StorageObject( $this->connection, $response['name'], $this->identity['bucket'], $response['generation'], $response, $encryptionKey, $encryptionKeySHA256 ); }
[ "public", "function", "upload", "(", "$", "data", ",", "array", "$", "options", "=", "[", "]", ")", "{", "if", "(", "$", "this", "->", "isObjectNameRequired", "(", "$", "data", ")", "&&", "!", "isset", "(", "$", "options", "[", "'name'", "]", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'A name is required when data is of type string or null.'", ")", ";", "}", "$", "encryptionKey", "=", "isset", "(", "$", "options", "[", "'encryptionKey'", "]", ")", "?", "$", "options", "[", "'encryptionKey'", "]", ":", "null", ";", "$", "encryptionKeySHA256", "=", "isset", "(", "$", "options", "[", "'encryptionKeySHA256'", "]", ")", "?", "$", "options", "[", "'encryptionKeySHA256'", "]", ":", "null", ";", "$", "response", "=", "$", "this", "->", "connection", "->", "insertObject", "(", "$", "this", "->", "formatEncryptionHeaders", "(", "$", "options", ")", "+", "$", "this", "->", "identity", "+", "[", "'data'", "=>", "$", "data", "]", ")", "->", "upload", "(", ")", ";", "return", "new", "StorageObject", "(", "$", "this", "->", "connection", ",", "$", "response", "[", "'name'", "]", ",", "$", "this", "->", "identity", "[", "'bucket'", "]", ",", "$", "response", "[", "'generation'", "]", ",", "$", "response", ",", "$", "encryptionKey", ",", "$", "encryptionKeySHA256", ")", ";", "}" ]
Upload your data in a simple fashion. Uploads will default to being resumable if the file size is greater than 5mb. Example: ``` $object = $bucket->upload( fopen(__DIR__ . '/image.jpg', 'r') ); ``` ``` // Upload an object in a resumable fashion while setting a new name for // the object and including the content language. $options = [ 'resumable' => true, 'name' => '/images/new-name.jpg', 'metadata' => [ 'contentLanguage' => 'en' ] ]; $object = $bucket->upload( fopen(__DIR__ . '/image.jpg', 'r'), $options ); ``` ``` // Upload an object with a customer-supplied encryption key. $key = base64_encode(openssl_random_pseudo_bytes(32)); // Make sure to remember your key. $object = $bucket->upload( fopen(__DIR__ . '/image.jpg', 'r'), ['encryptionKey' => $key] ); ``` ``` // Upload an object utilizing an encryption key managed by the Cloud Key Management Service (KMS). $object = $bucket->upload( fopen(__DIR__ . '/image.jpg', 'r'), [ 'metadata' => [ 'kmsKeyName' => 'projects/my-project/locations/kr-location/keyRings/my-kr/cryptoKeys/my-key' ] ] ); ``` @see https://cloud.google.com/storage/docs/json_api/v1/how-tos/upload#resumable Learn more about resumable uploads. @see https://cloud.google.com/storage/docs/json_api/v1/objects/insert Objects insert API documentation. @see https://cloud.google.com/storage/docs/encryption#customer-supplied Customer-supplied encryption keys. @param string|resource|StreamInterface|null $data The data to be uploaded. @param array $options [optional] { Configuration options. @type string $name The name of the destination. Required when data is of type string or null. @type bool $resumable Indicates whether or not the upload will be performed in a resumable fashion. @type bool $validate Indicates whether or not validation will be applied using md5 hashing functionality. If true and the calculated hash does not match that of the upstream server the upload will be rejected. @type int $chunkSize If provided the upload will be done in chunks. The size must be in multiples of 262144 bytes. With chunking you have increased reliability at the risk of higher overhead. It is recommended to not use chunking. @type callable $uploadProgressCallback If provided together with $resumable == true the given callable function/method will be called after each successfully uploaded chunk. The callable function/method will receive the number of uploaded bytes after each uploaded chunk as a parameter to this callable. It's useful if you want to create a progress bar when using resumable upload type together with $chunkSize parameter. If $chunkSize is not set the callable function/method will be called only once after the successful file upload. @type string $predefinedAcl Predefined ACL to apply to the object. Acceptable values include, `"authenticatedRead"`, `"bucketOwnerFullControl"`, `"bucketOwnerRead"`, `"private"`, `"projectPrivate"`, and `"publicRead"`. @type array $metadata The full list of available options are outlined at the [JSON API docs](https://cloud.google.com/storage/docs/json_api/v1/objects/insert#request-body). @type array $metadata.metadata User-provided metadata, in key/value pairs. @type string $encryptionKey A base64 encoded AES-256 customer-supplied encryption key. If you would prefer to manage encryption utilizing the Cloud Key Management Service (KMS) please use the `$metadata.kmsKeyName` setting. Please note if using KMS the key ring must use the same location as the bucket. @type string $encryptionKeySHA256 Base64 encoded SHA256 hash of the customer-supplied encryption key. This value will be calculated from the `encryptionKey` on your behalf if not provided, but for best performance it is recommended to pass in a cached version of the already calculated SHA. } @return StorageObject @throws \InvalidArgumentException
[ "Upload", "your", "data", "in", "a", "simple", "fashion", ".", "Uploads", "will", "default", "to", "being", "resumable", "if", "the", "file", "size", "is", "greater", "than", "5mb", "." ]
ff5030ffa1f12904565509a7bc24ecc0bd794a3e
https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Storage/src/Bucket.php#L272-L296
train
googleapis/google-cloud-php
Storage/src/Bucket.php
Bucket.getResumableUploader
public function getResumableUploader($data, array $options = []) { if ($this->isObjectNameRequired($data) && !isset($options['name'])) { throw new \InvalidArgumentException('A name is required when data is of type string or null.'); } return $this->connection->insertObject( $this->formatEncryptionHeaders($options) + $this->identity + [ 'data' => $data, 'resumable' => true ] ); }
php
public function getResumableUploader($data, array $options = []) { if ($this->isObjectNameRequired($data) && !isset($options['name'])) { throw new \InvalidArgumentException('A name is required when data is of type string or null.'); } return $this->connection->insertObject( $this->formatEncryptionHeaders($options) + $this->identity + [ 'data' => $data, 'resumable' => true ] ); }
[ "public", "function", "getResumableUploader", "(", "$", "data", ",", "array", "$", "options", "=", "[", "]", ")", "{", "if", "(", "$", "this", "->", "isObjectNameRequired", "(", "$", "data", ")", "&&", "!", "isset", "(", "$", "options", "[", "'name'", "]", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'A name is required when data is of type string or null.'", ")", ";", "}", "return", "$", "this", "->", "connection", "->", "insertObject", "(", "$", "this", "->", "formatEncryptionHeaders", "(", "$", "options", ")", "+", "$", "this", "->", "identity", "+", "[", "'data'", "=>", "$", "data", ",", "'resumable'", "=>", "true", "]", ")", ";", "}" ]
Get a resumable uploader which can provide greater control over the upload process. This is recommended when dealing with large files where reliability is key. Example: ``` $uploader = $bucket->getResumableUploader( fopen(__DIR__ . '/image.jpg', 'r') ); try { $object = $uploader->upload(); } catch (GoogleException $ex) { $resumeUri = $uploader->getResumeUri(); $object = $uploader->resume($resumeUri); } ``` @see https://cloud.google.com/storage/docs/json_api/v1/how-tos/upload#resumable Learn more about resumable uploads. @see https://cloud.google.com/storage/docs/json_api/v1/objects/insert Objects insert API documentation. @param string|resource|StreamInterface|null $data The data to be uploaded. @param array $options [optional] { Configuration options. @type string $name The name of the destination. Required when data is of type string or null. @type bool $validate Indicates whether or not validation will be applied using md5 hashing functionality. If true and the calculated hash does not match that of the upstream server the upload will be rejected. @type string $predefinedAcl Predefined ACL to apply to the object. Acceptable values include `"authenticatedRead`", `"bucketOwnerFullControl`", `"bucketOwnerRead`", `"private`", `"projectPrivate`", and `"publicRead"`. @type array $metadata The available options for metadata are outlined at the [JSON API docs](https://cloud.google.com/storage/docs/json_api/v1/objects/insert#request-body). @type string $encryptionKey A base64 encoded AES-256 customer-supplied encryption key. If you would prefer to manage encryption utilizing the Cloud Key Management Service (KMS) please use the $metadata['kmsKeyName'] setting. Please note if using KMS the key ring must use the same location as the bucket. @type string $encryptionKeySHA256 Base64 encoded SHA256 hash of the customer-supplied encryption key. This value will be calculated from the `encryptionKey` on your behalf if not provided, but for best performance it is recommended to pass in a cached version of the already calculated SHA. @type callable $uploadProgressCallback The given callable function/method will be called after each successfully uploaded chunk. The callable function/method will receive the number of uploaded bytes after each uploaded chunk as a parameter to this callable. It's useful if you want to create a progress bar when using resumable upload type together with $chunkSize parameter. If $chunkSize is not set the callable function/method will be called only once after the successful file upload. } @return ResumableUploader @throws \InvalidArgumentException
[ "Get", "a", "resumable", "uploader", "which", "can", "provide", "greater", "control", "over", "the", "upload", "process", ".", "This", "is", "recommended", "when", "dealing", "with", "large", "files", "where", "reliability", "is", "key", "." ]
ff5030ffa1f12904565509a7bc24ecc0bd794a3e
https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Storage/src/Bucket.php#L359-L371
train
googleapis/google-cloud-php
Storage/src/Bucket.php
Bucket.getStreamableUploader
public function getStreamableUploader($data, array $options = []) { if ($this->isObjectNameRequired($data) && !isset($options['name'])) { throw new \InvalidArgumentException('A name is required when data is of type string or null.'); } return $this->connection->insertObject( $this->formatEncryptionHeaders($options) + $this->identity + [ 'data' => $data, 'streamable' => true, 'validate' => false ] ); }
php
public function getStreamableUploader($data, array $options = []) { if ($this->isObjectNameRequired($data) && !isset($options['name'])) { throw new \InvalidArgumentException('A name is required when data is of type string or null.'); } return $this->connection->insertObject( $this->formatEncryptionHeaders($options) + $this->identity + [ 'data' => $data, 'streamable' => true, 'validate' => false ] ); }
[ "public", "function", "getStreamableUploader", "(", "$", "data", ",", "array", "$", "options", "=", "[", "]", ")", "{", "if", "(", "$", "this", "->", "isObjectNameRequired", "(", "$", "data", ")", "&&", "!", "isset", "(", "$", "options", "[", "'name'", "]", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'A name is required when data is of type string or null.'", ")", ";", "}", "return", "$", "this", "->", "connection", "->", "insertObject", "(", "$", "this", "->", "formatEncryptionHeaders", "(", "$", "options", ")", "+", "$", "this", "->", "identity", "+", "[", "'data'", "=>", "$", "data", ",", "'streamable'", "=>", "true", ",", "'validate'", "=>", "false", "]", ")", ";", "}" ]
Get a streamable uploader which can provide greater control over the upload process. This is useful for generating large files and uploading the contents in chunks. Example: ``` $uploader = $bucket->getStreamableUploader( 'initial contents', ['name' => 'data.txt'] ); // finish uploading the item $uploader->upload(); ``` @see https://cloud.google.com/storage/docs/json_api/v1/how-tos/upload#resumable Learn more about resumable uploads. @see https://cloud.google.com/storage/docs/json_api/v1/objects/insert Objects insert API documentation. @param string|resource|StreamInterface $data The data to be uploaded. @param array $options [optional] { Configuration options. @type string $name The name of the destination. Required when data is of type string or null. @type bool $validate Indicates whether or not validation will be applied using md5 hashing functionality. If true and the calculated hash does not match that of the upstream server the upload will be rejected. @type int $chunkSize If provided the upload will be done in chunks. The size must be in multiples of 262144 bytes. With chunking you have increased reliability at the risk of higher overhead. It is recommended to not use chunking. @type string $predefinedAcl Predefined ACL to apply to the object. Acceptable values include, `"authenticatedRead"`, `"bucketOwnerFullControl"`, `"bucketOwnerRead"`, `"private"`, `"projectPrivate"`, and `"publicRead"`. @type array $metadata The available options for metadata are outlined at the [JSON API docs](https://cloud.google.com/storage/docs/json_api/v1/objects/insert#request-body). @type string $encryptionKey A base64 encoded AES-256 customer-supplied encryption key. If you would prefer to manage encryption utilizing the Cloud Key Management Service (KMS) please use the $metadata['kmsKeyName'] setting. Please note if using KMS the key ring must use the same location as the bucket. @type string $encryptionKeySHA256 Base64 encoded SHA256 hash of the customer-supplied encryption key. This value will be calculated from the `encryptionKey` on your behalf if not provided, but for best performance it is recommended to pass in a cached version of the already calculated SHA. } @return StreamableUploader @throws \InvalidArgumentException
[ "Get", "a", "streamable", "uploader", "which", "can", "provide", "greater", "control", "over", "the", "upload", "process", ".", "This", "is", "useful", "for", "generating", "large", "files", "and", "uploading", "the", "contents", "in", "chunks", "." ]
ff5030ffa1f12904565509a7bc24ecc0bd794a3e
https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Storage/src/Bucket.php#L427-L440
train
googleapis/google-cloud-php
Storage/src/Bucket.php
Bucket.objects
public function objects(array $options = []) { $resultLimit = $this->pluck('resultLimit', $options, false); return new ObjectIterator( new ObjectPageIterator( function (array $object) { return new StorageObject( $this->connection, $object['name'], $this->identity['bucket'], isset($object['generation']) ? $object['generation'] : null, $object + array_filter([ 'requesterProjectId' => $this->identity['userProject'] ]) ); }, [$this->connection, 'listObjects'], $options + $this->identity, ['resultLimit' => $resultLimit] ) ); }
php
public function objects(array $options = []) { $resultLimit = $this->pluck('resultLimit', $options, false); return new ObjectIterator( new ObjectPageIterator( function (array $object) { return new StorageObject( $this->connection, $object['name'], $this->identity['bucket'], isset($object['generation']) ? $object['generation'] : null, $object + array_filter([ 'requesterProjectId' => $this->identity['userProject'] ]) ); }, [$this->connection, 'listObjects'], $options + $this->identity, ['resultLimit' => $resultLimit] ) ); }
[ "public", "function", "objects", "(", "array", "$", "options", "=", "[", "]", ")", "{", "$", "resultLimit", "=", "$", "this", "->", "pluck", "(", "'resultLimit'", ",", "$", "options", ",", "false", ")", ";", "return", "new", "ObjectIterator", "(", "new", "ObjectPageIterator", "(", "function", "(", "array", "$", "object", ")", "{", "return", "new", "StorageObject", "(", "$", "this", "->", "connection", ",", "$", "object", "[", "'name'", "]", ",", "$", "this", "->", "identity", "[", "'bucket'", "]", ",", "isset", "(", "$", "object", "[", "'generation'", "]", ")", "?", "$", "object", "[", "'generation'", "]", ":", "null", ",", "$", "object", "+", "array_filter", "(", "[", "'requesterProjectId'", "=>", "$", "this", "->", "identity", "[", "'userProject'", "]", "]", ")", ")", ";", "}", ",", "[", "$", "this", "->", "connection", ",", "'listObjects'", "]", ",", "$", "options", "+", "$", "this", "->", "identity", ",", "[", "'resultLimit'", "=>", "$", "resultLimit", "]", ")", ")", ";", "}" ]
Fetches all objects in the bucket. Example: ``` // Get all objects beginning with the prefix 'photo' $objects = $bucket->objects([ 'prefix' => 'photo', 'fields' => 'items/name,nextPageToken' ]); foreach ($objects as $object) { echo $object->name() . PHP_EOL; } ``` @see https://cloud.google.com/storage/docs/json_api/v1/objects/list Objects list API documentation. @param array $options [optional] { Configuration options. @type string $delimiter Returns results in a directory-like mode. Results will contain only objects whose names, aside from the prefix, do not contain delimiter. Objects whose names, aside from the prefix, contain delimiter will have their name, truncated after the delimiter, returned in prefixes. Duplicate prefixes are omitted. @type int $maxResults Maximum number of results to return per request. **Defaults to** `1000`. @type int $resultLimit Limit the number of results returned in total. **Defaults to** `0` (return all results). @type string $pageToken A previously-returned page token used to resume the loading of results from a specific point. @type string $prefix Filter results with this prefix. @type string $projection Determines which properties to return. May be either `"full"` or `"noAcl"`. @type bool $versions If true, lists all versions of an object as distinct results. **Defaults to** `false`. @type string $fields Selector which will cause the response to only return the specified fields. } @return ObjectIterator<StorageObject>
[ "Fetches", "all", "objects", "in", "the", "bucket", "." ]
ff5030ffa1f12904565509a7bc24ecc0bd794a3e
https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Storage/src/Bucket.php#L530-L552
train
googleapis/google-cloud-php
Storage/src/Bucket.php
Bucket.createNotification
public function createNotification($topic, array $options = []) { $res = $this->connection->insertNotification($options + $this->identity + [ 'topic' => $this->getFormattedTopic($topic), 'payload_format' => 'JSON_API_V1' ]); return new Notification( $this->connection, $res['id'], $this->identity['bucket'], $res + [ 'requesterProjectId' => $this->identity['userProject'] ] ); }
php
public function createNotification($topic, array $options = []) { $res = $this->connection->insertNotification($options + $this->identity + [ 'topic' => $this->getFormattedTopic($topic), 'payload_format' => 'JSON_API_V1' ]); return new Notification( $this->connection, $res['id'], $this->identity['bucket'], $res + [ 'requesterProjectId' => $this->identity['userProject'] ] ); }
[ "public", "function", "createNotification", "(", "$", "topic", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "res", "=", "$", "this", "->", "connection", "->", "insertNotification", "(", "$", "options", "+", "$", "this", "->", "identity", "+", "[", "'topic'", "=>", "$", "this", "->", "getFormattedTopic", "(", "$", "topic", ")", ",", "'payload_format'", "=>", "'JSON_API_V1'", "]", ")", ";", "return", "new", "Notification", "(", "$", "this", "->", "connection", ",", "$", "res", "[", "'id'", "]", ",", "$", "this", "->", "identity", "[", "'bucket'", "]", ",", "$", "res", "+", "[", "'requesterProjectId'", "=>", "$", "this", "->", "identity", "[", "'userProject'", "]", "]", ")", ";", "}" ]
Create a Cloud PubSub notification. Please note, the desired topic must be given the IAM role of "pubsub.publisher" from the service account associated with the project which contains the bucket you would like to receive notifications from. Please see the example below for a programmatic example of achieving this. Example: ``` // Update the permissions on the desired topic prior to creating the // notification. use Google\Cloud\Core\Iam\PolicyBuilder; use Google\Cloud\PubSub\PubSubClient; $pubSub = new PubSubClient(); $topicName = 'my-topic'; $serviceAccountEmail = $storage->getServiceAccount(); $topic = $pubSub->topic($topicName); $iam = $topic->iam(); $updatedPolicy = (new PolicyBuilder($iam->policy())) ->addBinding('roles/pubsub.publisher', [ "serviceAccount:$serviceAccountEmail" ]) ->result(); $iam->setPolicy($updatedPolicy); $notification = $bucket->createNotification($topicName); ``` ``` // Use a fully qualified topic name. $notification = $bucket->createNotification('projects/my-project/topics/my-topic'); ``` ``` // Provide a Topic object from the Cloud PubSub component. use Google\Cloud\PubSub\PubSubClient; $pubSub = new PubSubClient(); $topic = $pubSub->topic('my-topic'); $notification = $bucket->createNotification($topic); ``` ``` // Supplying event types to trigger the notifications. $notification = $bucket->createNotification('my-topic', [ 'event_types' => [ 'OBJECT_DELETE', 'OBJECT_METADATA_UPDATE' ] ]); ``` @codingStandardsIgnoreStart @see https://cloud.google.com/storage/docs/pubsub-notifications Cloud PubSub Notifications. @see https://cloud.google.com/storage/docs/json_api/v1/notifications/insert Notifications insert API documentation. @see https://cloud.google.com/storage/docs/reporting-changes Registering Object Changes. @codingStandardsIgnoreEnd @param string|Topic $topic The topic used to publish notifications. @param array $options [optional] { Configuration options. @type array $custom_attributes An optional list of additional attributes to attach to each Cloud PubSub message published for this notification subscription. @type array $event_types If present, only send notifications about listed event types. If empty, sent notifications for all event types. Acceptablue values include `"OBJECT_FINALIZE"`, `"OBJECT_METADATA_UPDATE"`, `"OBJECT_DELETE"` , `"OBJECT_ARCHIVE"`. @type string $object_name_prefix If present, only apply this notification configuration to object names that begin with this prefix. @type string $payload_format The desired content of the Payload. Acceptable values include `"JSON_API_V1"`, `"NONE"`. **Defaults to** `"JSON_API_V1"`. } @return Notification @throws \InvalidArgumentException When providing a type other than string or {@see Google\Cloud\PubSub\Topic} as $topic. @throws GoogleException When a project ID has not been detected. @experimental The experimental flag means that while we believe this method or class is ready for use, it may change before release in backwards-incompatible ways. Please use with caution, and test thoroughly when upgrading.
[ "Create", "a", "Cloud", "PubSub", "notification", "." ]
ff5030ffa1f12904565509a7bc24ecc0bd794a3e
https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Storage/src/Bucket.php#L643-L658
train
googleapis/google-cloud-php
Storage/src/Bucket.php
Bucket.notifications
public function notifications(array $options = []) { $resultLimit = $this->pluck('resultLimit', $options, false); return new ItemIterator( new PageIterator( function (array $notification) { return new Notification( $this->connection, $notification['id'], $this->identity['bucket'], $notification + [ 'requesterProjectId' => $this->identity['userProject'] ] ); }, [$this->connection, 'listNotifications'], $options + $this->identity, ['resultLimit' => $resultLimit] ) ); }
php
public function notifications(array $options = []) { $resultLimit = $this->pluck('resultLimit', $options, false); return new ItemIterator( new PageIterator( function (array $notification) { return new Notification( $this->connection, $notification['id'], $this->identity['bucket'], $notification + [ 'requesterProjectId' => $this->identity['userProject'] ] ); }, [$this->connection, 'listNotifications'], $options + $this->identity, ['resultLimit' => $resultLimit] ) ); }
[ "public", "function", "notifications", "(", "array", "$", "options", "=", "[", "]", ")", "{", "$", "resultLimit", "=", "$", "this", "->", "pluck", "(", "'resultLimit'", ",", "$", "options", ",", "false", ")", ";", "return", "new", "ItemIterator", "(", "new", "PageIterator", "(", "function", "(", "array", "$", "notification", ")", "{", "return", "new", "Notification", "(", "$", "this", "->", "connection", ",", "$", "notification", "[", "'id'", "]", ",", "$", "this", "->", "identity", "[", "'bucket'", "]", ",", "$", "notification", "+", "[", "'requesterProjectId'", "=>", "$", "this", "->", "identity", "[", "'userProject'", "]", "]", ")", ";", "}", ",", "[", "$", "this", "->", "connection", ",", "'listNotifications'", "]", ",", "$", "options", "+", "$", "this", "->", "identity", ",", "[", "'resultLimit'", "=>", "$", "resultLimit", "]", ")", ")", ";", "}" ]
Fetches all notifications associated with this bucket. Example: ``` $notifications = $bucket->notifications(); foreach ($notifications as $notification) { echo $notification->id() . PHP_EOL; } ``` @codingStandardsIgnoreStart @see https://cloud.google.com/storage/docs/json_api/v1/notifications/list Notifications list API documentation. @codingStandardsIgnoreEnd @param array $options [optional] { Configuration options. @type int $resultLimit Limit the number of results returned in total. **Defaults to** `0` (return all results). } @return ItemIterator<Notification> @experimental The experimental flag means that while we believe this method or class is ready for use, it may change before release in backwards-incompatible ways. Please use with caution, and test thoroughly when upgrading.
[ "Fetches", "all", "notifications", "associated", "with", "this", "bucket", "." ]
ff5030ffa1f12904565509a7bc24ecc0bd794a3e
https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Storage/src/Bucket.php#L717-L738
train
googleapis/google-cloud-php
Storage/src/Bucket.php
Bucket.update
public function update(array $options = []) { if (isset($options['lifecycle']) && $options['lifecycle'] instanceof Lifecycle) { $options['lifecycle'] = $options['lifecycle']->toArray(); } return $this->info = $this->connection->patchBucket($options + $this->identity); }
php
public function update(array $options = []) { if (isset($options['lifecycle']) && $options['lifecycle'] instanceof Lifecycle) { $options['lifecycle'] = $options['lifecycle']->toArray(); } return $this->info = $this->connection->patchBucket($options + $this->identity); }
[ "public", "function", "update", "(", "array", "$", "options", "=", "[", "]", ")", "{", "if", "(", "isset", "(", "$", "options", "[", "'lifecycle'", "]", ")", "&&", "$", "options", "[", "'lifecycle'", "]", "instanceof", "Lifecycle", ")", "{", "$", "options", "[", "'lifecycle'", "]", "=", "$", "options", "[", "'lifecycle'", "]", "->", "toArray", "(", ")", ";", "}", "return", "$", "this", "->", "info", "=", "$", "this", "->", "connection", "->", "patchBucket", "(", "$", "options", "+", "$", "this", "->", "identity", ")", ";", "}" ]
Update the bucket. Upon receiving a result the local bucket's data will be updated. Example: ``` // Enable logging on an existing bucket. $bucket->update([ 'logging' => [ 'logBucket' => 'myBucket', 'logObjectPrefix' => 'prefix' ] ]); ``` @see https://cloud.google.com/storage/docs/json_api/v1/buckets/patch Buckets patch API documentation. @see https://cloud.google.com/storage/docs/key-terms#bucket-labels Bucket Labels @codingStandardsIgnoreStart @param array $options [optional] { Configuration options. @type string $ifMetagenerationMatch Makes the return of the bucket metadata conditional on whether the bucket's current metageneration matches the given value. @type string $ifMetagenerationNotMatch Makes the return of the bucket metadata conditional on whether the bucket's current metageneration does not match the given value. @type string $predefinedAcl Predefined ACL to apply to the bucket. Acceptable values include, `"authenticatedRead"`, `"bucketOwnerFullControl"`, `"bucketOwnerRead"`, `"private"`, `"projectPrivate"`, and `"publicRead"`. @type string $predefinedDefaultObjectAcl Apply a predefined set of default object access controls to this bucket. Acceptable values include, `"authenticatedRead"`, `"bucketOwnerFullControl"`, `"bucketOwnerRead"`, `"private"`, `"projectPrivate"`, and `"publicRead"`. @type string $projection Determines which properties to return. May be either `"full"` or `"noAcl"`. @type string $fields Selector which will cause the response to only return the specified fields. @type array $acl Access controls on the bucket. @type array $cors The bucket's Cross-Origin Resource Sharing (CORS) configuration. @type array $defaultObjectAcl Default access controls to apply to new objects when no ACL is provided. @type array|Lifecycle $lifecycle The bucket's lifecycle configuration. @type array $logging The bucket's logging configuration, which defines the destination bucket and optional name prefix for the current bucket's logs. @type string $storageClass The bucket's storage class. This defines how objects in the bucket are stored and determines the SLA and the cost of storage. Acceptable values include `"MULTI_REGIONAL"`, `"REGIONAL"`, `"NEARLINE"`, `"COLDLINE"`, `"STANDARD"` and `"DURABLE_REDUCED_AVAILABILITY"`. @type array $versioning The bucket's versioning configuration. @type array $website The bucket's website configuration. @type array $billing The bucket's billing configuration. @type bool $billing.requesterPays When `true`, requests to this bucket and objects within it must provide a project ID to which the request will be billed. @type array $labels The Bucket labels. Labels are represented as an array of keys and values. To remove an existing label, set its value to `null`. @type array $encryption Encryption configuration used by default for newly inserted objects. @type string $encryption.defaultKmsKeyName A Cloud KMS Key used to encrypt objects uploaded into this bucket. Should be in the format `projects/my-project/locations/kr-location/keyRings/my-kr/cryptoKeys/my-key`. Please note the KMS key ring must use the same location as the bucket. @type bool $defaultEventBasedHold When `true`, newly created objects in this bucket will be retained indefinitely until an event occurs, signified by the hold's release. @type array $retentionPolicy Defines the retention policy for a bucket. In order to lock a retention policy, please see {@see Google\Cloud\Storage\Bucket::lockRetentionPolicy()}. @type int $retentionPolicy.retentionPeriod Specifies the duration that objects need to be retained, in seconds. Retention duration must be greater than zero and less than 100 years. @type array $iamConfiguration The bucket's IAM configuration. @type bool $iamConfiguration.bucketPolicyOnly.enabled If set and true, access checks only use bucket-level IAM policies or above. When enabled, requests attempting to view or manipulate ACLs will fail with error code 400. **NOTE**: Before using Bucket Policy Only, please review the [feature documentation](https://cloud.google.com/storage/docs/bucket-policy-only), as well as [Should You Use Bucket Policy Only](https://cloud.google.com/storage/docs/bucket-policy-only#should-you-use) } @codingStandardsIgnoreEnd @return array
[ "Update", "the", "bucket", ".", "Upon", "receiving", "a", "result", "the", "local", "bucket", "s", "data", "will", "be", "updated", "." ]
ff5030ffa1f12904565509a7bc24ecc0bd794a3e
https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Storage/src/Bucket.php#L858-L865
train
googleapis/google-cloud-php
Storage/src/Bucket.php
Bucket.compose
public function compose(array $sourceObjects, $name, array $options = []) { if (count($sourceObjects) < 2) { throw new \InvalidArgumentException('Must provide at least two objects to compose.'); } $options += [ 'destinationBucket' => $this->name(), 'destinationObject' => $name, 'destinationPredefinedAcl' => isset($options['predefinedAcl']) ? $options['predefinedAcl'] : null, 'destination' => isset($options['metadata']) ? $options['metadata'] : null, 'userProject' => $this->identity['userProject'], 'sourceObjects' => array_map(function ($sourceObject) { $name = null; $generation = null; if ($sourceObject instanceof StorageObject) { $name = $sourceObject->name(); $generation = isset($sourceObject->identity()['generation']) ? $sourceObject->identity()['generation'] : null; } return array_filter([ 'name' => $name ?: $sourceObject, 'generation' => $generation ]); }, $sourceObjects) ]; if (!isset($options['destination']['contentType'])) { $options['destination']['contentType'] = Psr7\mimetype_from_filename($name); } if ($options['destination']['contentType'] === null) { throw new \InvalidArgumentException('A content type could not be detected and must be provided manually.'); } unset($options['metadata']); unset($options['predefinedAcl']); $response = $this->connection->composeObject(array_filter($options)); return new StorageObject( $this->connection, $response['name'], $this->identity['bucket'], $response['generation'], $response + array_filter([ 'requesterProjectId' => $this->identity['userProject'] ]) ); }
php
public function compose(array $sourceObjects, $name, array $options = []) { if (count($sourceObjects) < 2) { throw new \InvalidArgumentException('Must provide at least two objects to compose.'); } $options += [ 'destinationBucket' => $this->name(), 'destinationObject' => $name, 'destinationPredefinedAcl' => isset($options['predefinedAcl']) ? $options['predefinedAcl'] : null, 'destination' => isset($options['metadata']) ? $options['metadata'] : null, 'userProject' => $this->identity['userProject'], 'sourceObjects' => array_map(function ($sourceObject) { $name = null; $generation = null; if ($sourceObject instanceof StorageObject) { $name = $sourceObject->name(); $generation = isset($sourceObject->identity()['generation']) ? $sourceObject->identity()['generation'] : null; } return array_filter([ 'name' => $name ?: $sourceObject, 'generation' => $generation ]); }, $sourceObjects) ]; if (!isset($options['destination']['contentType'])) { $options['destination']['contentType'] = Psr7\mimetype_from_filename($name); } if ($options['destination']['contentType'] === null) { throw new \InvalidArgumentException('A content type could not be detected and must be provided manually.'); } unset($options['metadata']); unset($options['predefinedAcl']); $response = $this->connection->composeObject(array_filter($options)); return new StorageObject( $this->connection, $response['name'], $this->identity['bucket'], $response['generation'], $response + array_filter([ 'requesterProjectId' => $this->identity['userProject'] ]) ); }
[ "public", "function", "compose", "(", "array", "$", "sourceObjects", ",", "$", "name", ",", "array", "$", "options", "=", "[", "]", ")", "{", "if", "(", "count", "(", "$", "sourceObjects", ")", "<", "2", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'Must provide at least two objects to compose.'", ")", ";", "}", "$", "options", "+=", "[", "'destinationBucket'", "=>", "$", "this", "->", "name", "(", ")", ",", "'destinationObject'", "=>", "$", "name", ",", "'destinationPredefinedAcl'", "=>", "isset", "(", "$", "options", "[", "'predefinedAcl'", "]", ")", "?", "$", "options", "[", "'predefinedAcl'", "]", ":", "null", ",", "'destination'", "=>", "isset", "(", "$", "options", "[", "'metadata'", "]", ")", "?", "$", "options", "[", "'metadata'", "]", ":", "null", ",", "'userProject'", "=>", "$", "this", "->", "identity", "[", "'userProject'", "]", ",", "'sourceObjects'", "=>", "array_map", "(", "function", "(", "$", "sourceObject", ")", "{", "$", "name", "=", "null", ";", "$", "generation", "=", "null", ";", "if", "(", "$", "sourceObject", "instanceof", "StorageObject", ")", "{", "$", "name", "=", "$", "sourceObject", "->", "name", "(", ")", ";", "$", "generation", "=", "isset", "(", "$", "sourceObject", "->", "identity", "(", ")", "[", "'generation'", "]", ")", "?", "$", "sourceObject", "->", "identity", "(", ")", "[", "'generation'", "]", ":", "null", ";", "}", "return", "array_filter", "(", "[", "'name'", "=>", "$", "name", "?", ":", "$", "sourceObject", ",", "'generation'", "=>", "$", "generation", "]", ")", ";", "}", ",", "$", "sourceObjects", ")", "]", ";", "if", "(", "!", "isset", "(", "$", "options", "[", "'destination'", "]", "[", "'contentType'", "]", ")", ")", "{", "$", "options", "[", "'destination'", "]", "[", "'contentType'", "]", "=", "Psr7", "\\", "mimetype_from_filename", "(", "$", "name", ")", ";", "}", "if", "(", "$", "options", "[", "'destination'", "]", "[", "'contentType'", "]", "===", "null", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'A content type could not be detected and must be provided manually.'", ")", ";", "}", "unset", "(", "$", "options", "[", "'metadata'", "]", ")", ";", "unset", "(", "$", "options", "[", "'predefinedAcl'", "]", ")", ";", "$", "response", "=", "$", "this", "->", "connection", "->", "composeObject", "(", "array_filter", "(", "$", "options", ")", ")", ";", "return", "new", "StorageObject", "(", "$", "this", "->", "connection", ",", "$", "response", "[", "'name'", "]", ",", "$", "this", "->", "identity", "[", "'bucket'", "]", ",", "$", "response", "[", "'generation'", "]", ",", "$", "response", "+", "array_filter", "(", "[", "'requesterProjectId'", "=>", "$", "this", "->", "identity", "[", "'userProject'", "]", "]", ")", ")", ";", "}" ]
Composes a set of objects into a single object. Please note that all objects to be composed must come from the same bucket. Example: ``` $sourceObjects = ['log1.txt', 'log2.txt']; $singleObject = $bucket->compose($sourceObjects, 'combined-logs.txt'); ``` ``` // Use an instance of StorageObject. $sourceObjects = [ $bucket->object('log1.txt'), $bucket->object('log2.txt') ]; $singleObject = $bucket->compose($sourceObjects, 'combined-logs.txt'); ``` @see https://cloud.google.com/storage/docs/json_api/v1/objects/compose Objects compose API documentation @param string[]|StorageObject[] $sourceObjects The objects to compose. @param string $name The name of the composed object. @param array $options [optional] { Configuration options. @type string $predefinedAcl Predefined ACL to apply to the composed object. Acceptable values include, `"authenticatedRead"`, `"bucketOwnerFullControl"`, `"bucketOwnerRead"`, `"private"`, `"projectPrivate"`, and `"publicRead"`. @type array $metadata Metadata to apply to the composed object. The available options for metadata are outlined at the [JSON API docs](https://cloud.google.com/storage/docs/json_api/v1/objects/insert#request-body). @type string $ifGenerationMatch Makes the operation conditional on whether the object's current generation matches the given value. @type string $ifMetagenerationMatch Makes the operation conditional on whether the object's current metageneration matches the given value. } @return StorageObject @throws \InvalidArgumentException
[ "Composes", "a", "set", "of", "objects", "into", "a", "single", "object", "." ]
ff5030ffa1f12904565509a7bc24ecc0bd794a3e
https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Storage/src/Bucket.php#L911-L963
train
googleapis/google-cloud-php
Storage/src/Bucket.php
Bucket.reload
public function reload(array $options = []) { return $this->info = $this->connection->getBucket($options + $this->identity); }
php
public function reload(array $options = []) { return $this->info = $this->connection->getBucket($options + $this->identity); }
[ "public", "function", "reload", "(", "array", "$", "options", "=", "[", "]", ")", "{", "return", "$", "this", "->", "info", "=", "$", "this", "->", "connection", "->", "getBucket", "(", "$", "options", "+", "$", "this", "->", "identity", ")", ";", "}" ]
Triggers a network request to reload the bucket's details. Example: ``` $bucket->reload(); $info = $bucket->info(); echo $info['location']; ``` @see https://cloud.google.com/storage/docs/json_api/v1/buckets/get Buckets get API documentation. @param array $options [optional] { Configuration options. @type string $ifMetagenerationMatch Makes the return of the bucket metadata conditional on whether the bucket's current metageneration matches the given value. @type string $ifMetagenerationNotMatch Makes the return of the bucket metadata conditional on whether the bucket's current metageneration does not match the given value. @type string $projection Determines which properties to return. May be either `"full"` or `"noAcl"`. } @return array
[ "Triggers", "a", "network", "request", "to", "reload", "the", "bucket", "s", "details", "." ]
ff5030ffa1f12904565509a7bc24ecc0bd794a3e
https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Storage/src/Bucket.php#L1022-L1025
train
googleapis/google-cloud-php
Storage/src/Bucket.php
Bucket.iam
public function iam() { if (!$this->iam) { $this->iam = new Iam( new IamBucket($this->connection), $this->identity['bucket'], [ 'parent' => null, 'args' => $this->identity ] ); } return $this->iam; }
php
public function iam() { if (!$this->iam) { $this->iam = new Iam( new IamBucket($this->connection), $this->identity['bucket'], [ 'parent' => null, 'args' => $this->identity ] ); } return $this->iam; }
[ "public", "function", "iam", "(", ")", "{", "if", "(", "!", "$", "this", "->", "iam", ")", "{", "$", "this", "->", "iam", "=", "new", "Iam", "(", "new", "IamBucket", "(", "$", "this", "->", "connection", ")", ",", "$", "this", "->", "identity", "[", "'bucket'", "]", ",", "[", "'parent'", "=>", "null", ",", "'args'", "=>", "$", "this", "->", "identity", "]", ")", ";", "}", "return", "$", "this", "->", "iam", ";", "}" ]
Manage the IAM policy for the current Bucket. Please note that this method may not yet be available in your project. Example: ``` $iam = $bucket->iam(); ``` @codingStandardsIgnoreStart @see https://cloud.google.com/storage/docs/access-control/iam-with-json-and-xml Storage Access Control Documentation @see https://cloud.google.com/storage/docs/json_api/v1/buckets/getIamPolicy Get Bucket IAM Policy @see https://cloud.google.com/storage/docs/json_api/v1/buckets/setIamPolicy Set Bucket IAM Policy @see https://cloud.google.com/storage/docs/json_api/v1/buckets/testIamPermissions Test Bucket Permissions @codingStandardsIgnoreEnd @return Iam
[ "Manage", "the", "IAM", "policy", "for", "the", "current", "Bucket", "." ]
ff5030ffa1f12904565509a7bc24ecc0bd794a3e
https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Storage/src/Bucket.php#L1174-L1188
train
googleapis/google-cloud-php
Storage/src/Bucket.php
Bucket.lockRetentionPolicy
public function lockRetentionPolicy(array $options = []) { if (!isset($options['ifMetagenerationMatch'])) { if (!isset($this->info['metageneration'])) { throw new \BadMethodCallException( 'No metageneration value was detected. Please either provide ' . 'a value explicitly or ensure metadata is loaded through a ' . 'call such as Bucket::reload().' ); } $options['ifMetagenerationMatch'] = $this->info['metageneration']; } return $this->info = $this->connection->lockRetentionPolicy( $options + $this->identity ); }
php
public function lockRetentionPolicy(array $options = []) { if (!isset($options['ifMetagenerationMatch'])) { if (!isset($this->info['metageneration'])) { throw new \BadMethodCallException( 'No metageneration value was detected. Please either provide ' . 'a value explicitly or ensure metadata is loaded through a ' . 'call such as Bucket::reload().' ); } $options['ifMetagenerationMatch'] = $this->info['metageneration']; } return $this->info = $this->connection->lockRetentionPolicy( $options + $this->identity ); }
[ "public", "function", "lockRetentionPolicy", "(", "array", "$", "options", "=", "[", "]", ")", "{", "if", "(", "!", "isset", "(", "$", "options", "[", "'ifMetagenerationMatch'", "]", ")", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "info", "[", "'metageneration'", "]", ")", ")", "{", "throw", "new", "\\", "BadMethodCallException", "(", "'No metageneration value was detected. Please either provide '", ".", "'a value explicitly or ensure metadata is loaded through a '", ".", "'call such as Bucket::reload().'", ")", ";", "}", "$", "options", "[", "'ifMetagenerationMatch'", "]", "=", "$", "this", "->", "info", "[", "'metageneration'", "]", ";", "}", "return", "$", "this", "->", "info", "=", "$", "this", "->", "connection", "->", "lockRetentionPolicy", "(", "$", "options", "+", "$", "this", "->", "identity", ")", ";", "}" ]
Locks a provided retention policy on this bucket. Upon receiving a result, the local bucket's data will be updated. Please note that in order for this call to succeed, the applicable metageneration value will need to be available. It can either be supplied explicitly through the `ifMetagenerationMatch` option or detected for you by ensuring a value is cached locally (by calling {@see Google\Cloud\Storage\Bucket::reload()} or {@see Google\Cloud\Storage\Bucket::info()}, for example). Example: ``` // Set a retention policy. $bucket->update([ 'retentionPolicy' => [ 'retentionPeriod' => 604800 // One week in seconds. ] ]); // Lock in the policy. $info = $bucket->lockRetentionPolicy(); $retentionPolicy = $info['retentionPolicy']; // View the time from which the policy was enforced and effective. (RFC 3339 format) echo $retentionPolicy['effectiveTime'] . PHP_EOL; // View whether or not the retention policy is locked. This will be // `true` after a successful call to `lockRetentionPolicy`. echo $retentionPolicy['isLocked']; ``` @see https://cloud.google.com/storage/docs/bucket-lock Bucket Lock Documentation @param array $options [optional] { Configuration options. @type string $ifMetagenerationMatch Only locks the retention policy if the bucket's metageneration matches this value. If not provided the locally cached metageneration value will be used, otherwise an exception will be thrown. } @throws \BadMethodCallException If no metageneration value is available. @return array
[ "Locks", "a", "provided", "retention", "policy", "on", "this", "bucket", ".", "Upon", "receiving", "a", "result", "the", "local", "bucket", "s", "data", "will", "be", "updated", "." ]
ff5030ffa1f12904565509a7bc24ecc0bd794a3e
https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Storage/src/Bucket.php#L1234-L1251
train
googleapis/google-cloud-php
Storage/src/Bucket.php
Bucket.signedUrl
public function signedUrl($expires, array $options = []) { // May be overridden for testing. $signingHelper = $this->pluck('helper', $options, false) ?: SigningHelper::getHelper(); $resource = sprintf( '/%s', $this->identity['bucket'] ); return $signingHelper->sign( $this->connection, $expires, $resource, null, $options ); }
php
public function signedUrl($expires, array $options = []) { // May be overridden for testing. $signingHelper = $this->pluck('helper', $options, false) ?: SigningHelper::getHelper(); $resource = sprintf( '/%s', $this->identity['bucket'] ); return $signingHelper->sign( $this->connection, $expires, $resource, null, $options ); }
[ "public", "function", "signedUrl", "(", "$", "expires", ",", "array", "$", "options", "=", "[", "]", ")", "{", "// May be overridden for testing.", "$", "signingHelper", "=", "$", "this", "->", "pluck", "(", "'helper'", ",", "$", "options", ",", "false", ")", "?", ":", "SigningHelper", "::", "getHelper", "(", ")", ";", "$", "resource", "=", "sprintf", "(", "'/%s'", ",", "$", "this", "->", "identity", "[", "'bucket'", "]", ")", ";", "return", "$", "signingHelper", "->", "sign", "(", "$", "this", "->", "connection", ",", "$", "expires", ",", "$", "resource", ",", "null", ",", "$", "options", ")", ";", "}" ]
Create a Signed URL listing objects in this bucket. Example: ``` $url = $bucket->signedUrl(time() + 3600); ``` ``` // Use V4 Signing $url = $bucket->signedUrl(time() + 3600, [ 'version' => 'v4' ]); ``` @see https://cloud.google.com/storage/docs/access-control/signed-urls Signed URLs @param Timestamp|\DateTimeInterface|int $expires Specifies when the URL will expire. May provide an instance of {@see Google\Cloud\Core\Timestamp}, [http://php.net/datetimeimmutable](`\DateTimeImmutable`), or a UNIX timestamp as an integer. @param array $options { Configuration Options. @type string $cname The CNAME for the bucket, for instance `https://cdn.example.com`. **Defaults to** `https://storage.googleapis.com`. @type string $contentMd5 The MD5 digest value in base64. If you provide this, the client must provide this HTTP header with this same value in its request. If provided, take care to always provide this value as a base64 encoded string. @type string $contentType If you provide this value, the client must provide this HTTP header set to the same value. @type bool $forceOpenssl If true, OpenSSL will be used regardless of whether phpseclib is available. **Defaults to** `false`. @type array $headers If additional headers are provided, the server will check to make sure that the client provides matching values. Provide headers as a key/value array, where the key is the header name, and the value is an array of header values. Headers with multiple values may provide values as a simple array, or a comma-separated string. For a reference of allowed headers, see [Reference Headers](https://cloud.google.com/storage/docs/xml-api/reference-headers). Header values will be trimmed of leading and trailing spaces, multiple spaces within values will be collapsed to a single space, and line breaks will be replaced by an empty string. V2 Signed URLs may not provide `x-goog-encryption-key` or `x-goog-encryption-key-sha256` headers. @type array $keyFile Keyfile data to use in place of the keyfile with which the client was constructed. If `$options.keyFilePath` is set, this option is ignored. @type string $keyFilePath A path to a valid keyfile to use in place of the keyfile with which the client was constructed. @type string|array $scopes One or more authentication scopes to be used with a key file. This option is ignored unless `$options.keyFile` or `$options.keyFilePath` is set. @type array $queryParams Additional query parameters to be included as part of the signed URL query string. For allowed values, see [Reference Headers](https://cloud.google.com/storage/docs/xml-api/reference-headers#query). @type string $version One of "v2" or "v4". *Defaults to** `"v2"`. } @return string @throws \InvalidArgumentException If the given expiration is invalid or in the past. @throws \InvalidArgumentException If the given `$options.method` is not valid. @throws \InvalidArgumentException If the given `$options.keyFilePath` is not valid. @throws \InvalidArgumentException If the given custom headers are invalid. @throws \RuntimeException If the keyfile does not contain the required information.
[ "Create", "a", "Signed", "URL", "listing", "objects", "in", "this", "bucket", "." ]
ff5030ffa1f12904565509a7bc24ecc0bd794a3e
https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Storage/src/Bucket.php#L1320-L1338
train
googleapis/google-cloud-php
Storage/src/Bucket.php
Bucket.getFormattedTopic
private function getFormattedTopic($topic) { if ($topic instanceof Topic) { return sprintf(self::NOTIFICATION_TEMPLATE, $topic->name()); } if (!is_string($topic)) { throw new \InvalidArgumentException( '$topic may only be a string or instance of Google\Cloud\PubSub\Topic' ); } if (preg_match('/projects\/[^\/]*\/topics\/(.*)/', $topic) === 1) { return sprintf(self::NOTIFICATION_TEMPLATE, $topic); } if (!$this->projectId) { throw new GoogleException( 'No project ID was provided, ' . 'and we were unable to detect a default project ID.' ); } return sprintf( self::NOTIFICATION_TEMPLATE, sprintf(self::TOPIC_TEMPLATE, $this->projectId, $topic) ); }
php
private function getFormattedTopic($topic) { if ($topic instanceof Topic) { return sprintf(self::NOTIFICATION_TEMPLATE, $topic->name()); } if (!is_string($topic)) { throw new \InvalidArgumentException( '$topic may only be a string or instance of Google\Cloud\PubSub\Topic' ); } if (preg_match('/projects\/[^\/]*\/topics\/(.*)/', $topic) === 1) { return sprintf(self::NOTIFICATION_TEMPLATE, $topic); } if (!$this->projectId) { throw new GoogleException( 'No project ID was provided, ' . 'and we were unable to detect a default project ID.' ); } return sprintf( self::NOTIFICATION_TEMPLATE, sprintf(self::TOPIC_TEMPLATE, $this->projectId, $topic) ); }
[ "private", "function", "getFormattedTopic", "(", "$", "topic", ")", "{", "if", "(", "$", "topic", "instanceof", "Topic", ")", "{", "return", "sprintf", "(", "self", "::", "NOTIFICATION_TEMPLATE", ",", "$", "topic", "->", "name", "(", ")", ")", ";", "}", "if", "(", "!", "is_string", "(", "$", "topic", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'$topic may only be a string or instance of Google\\Cloud\\PubSub\\Topic'", ")", ";", "}", "if", "(", "preg_match", "(", "'/projects\\/[^\\/]*\\/topics\\/(.*)/'", ",", "$", "topic", ")", "===", "1", ")", "{", "return", "sprintf", "(", "self", "::", "NOTIFICATION_TEMPLATE", ",", "$", "topic", ")", ";", "}", "if", "(", "!", "$", "this", "->", "projectId", ")", "{", "throw", "new", "GoogleException", "(", "'No project ID was provided, '", ".", "'and we were unable to detect a default project ID.'", ")", ";", "}", "return", "sprintf", "(", "self", "::", "NOTIFICATION_TEMPLATE", ",", "sprintf", "(", "self", "::", "TOPIC_TEMPLATE", ",", "$", "this", "->", "projectId", ",", "$", "topic", ")", ")", ";", "}" ]
Return a topic name in its fully qualified format. @param Topic|string $topic @return string @throws \InvalidArgumentException @throws GoogleException
[ "Return", "a", "topic", "name", "in", "its", "fully", "qualified", "format", "." ]
ff5030ffa1f12904565509a7bc24ecc0bd794a3e
https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Storage/src/Bucket.php#L1359-L1386
train
googleapis/google-cloud-php
Dlp/src/V2/JobTrigger/Trigger.php
Trigger.setSchedule
public function setSchedule($var) { GPBUtil::checkMessage($var, \Google\Cloud\Dlp\V2\Schedule::class); $this->writeOneof(1, $var); return $this; }
php
public function setSchedule($var) { GPBUtil::checkMessage($var, \Google\Cloud\Dlp\V2\Schedule::class); $this->writeOneof(1, $var); return $this; }
[ "public", "function", "setSchedule", "(", "$", "var", ")", "{", "GPBUtil", "::", "checkMessage", "(", "$", "var", ",", "\\", "Google", "\\", "Cloud", "\\", "Dlp", "\\", "V2", "\\", "Schedule", "::", "class", ")", ";", "$", "this", "->", "writeOneof", "(", "1", ",", "$", "var", ")", ";", "return", "$", "this", ";", "}" ]
Create a job on a repeating basis based on the elapse of time. Generated from protobuf field <code>.google.privacy.dlp.v2.Schedule schedule = 1;</code> @param \Google\Cloud\Dlp\V2\Schedule $var @return $this
[ "Create", "a", "job", "on", "a", "repeating", "basis", "based", "on", "the", "elapse", "of", "time", "." ]
ff5030ffa1f12904565509a7bc24ecc0bd794a3e
https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Dlp/src/V2/JobTrigger/Trigger.php#L53-L59
train
googleapis/google-cloud-php
Firestore/src/V1beta1/DocumentTransform.php
DocumentTransform.setFieldTransforms
public function setFieldTransforms($var) { $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Firestore\V1beta1\DocumentTransform\FieldTransform::class); $this->field_transforms = $arr; return $this; }
php
public function setFieldTransforms($var) { $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Firestore\V1beta1\DocumentTransform\FieldTransform::class); $this->field_transforms = $arr; return $this; }
[ "public", "function", "setFieldTransforms", "(", "$", "var", ")", "{", "$", "arr", "=", "GPBUtil", "::", "checkRepeatedField", "(", "$", "var", ",", "\\", "Google", "\\", "Protobuf", "\\", "Internal", "\\", "GPBType", "::", "MESSAGE", ",", "\\", "Google", "\\", "Cloud", "\\", "Firestore", "\\", "V1beta1", "\\", "DocumentTransform", "\\", "FieldTransform", "::", "class", ")", ";", "$", "this", "->", "field_transforms", "=", "$", "arr", ";", "return", "$", "this", ";", "}" ]
The list of transformations to apply to the fields of the document, in order. This must not be empty. Generated from protobuf field <code>repeated .google.firestore.v1beta1.DocumentTransform.FieldTransform field_transforms = 2;</code> @param \Google\Cloud\Firestore\V1beta1\DocumentTransform\FieldTransform[]|\Google\Protobuf\Internal\RepeatedField $var @return $this
[ "The", "list", "of", "transformations", "to", "apply", "to", "the", "fields", "of", "the", "document", "in", "order", ".", "This", "must", "not", "be", "empty", "." ]
ff5030ffa1f12904565509a7bc24ecc0bd794a3e
https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Firestore/src/V1beta1/DocumentTransform.php#L100-L106
train
googleapis/google-cloud-php
AutoMl/src/V1beta1/PredictResponse.php
PredictResponse.setPayload
public function setPayload($var) { $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\AutoMl\V1beta1\AnnotationPayload::class); $this->payload = $arr; return $this; }
php
public function setPayload($var) { $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\AutoMl\V1beta1\AnnotationPayload::class); $this->payload = $arr; return $this; }
[ "public", "function", "setPayload", "(", "$", "var", ")", "{", "$", "arr", "=", "GPBUtil", "::", "checkRepeatedField", "(", "$", "var", ",", "\\", "Google", "\\", "Protobuf", "\\", "Internal", "\\", "GPBType", "::", "MESSAGE", ",", "\\", "Google", "\\", "Cloud", "\\", "AutoMl", "\\", "V1beta1", "\\", "AnnotationPayload", "::", "class", ")", ";", "$", "this", "->", "payload", "=", "$", "arr", ";", "return", "$", "this", ";", "}" ]
Prediction result. Generated from protobuf field <code>repeated .google.cloud.automl.v1beta1.AnnotationPayload payload = 1;</code> @param \Google\Cloud\AutoMl\V1beta1\AnnotationPayload[]|\Google\Protobuf\Internal\RepeatedField $var @return $this
[ "Prediction", "result", "." ]
ff5030ffa1f12904565509a7bc24ecc0bd794a3e
https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/AutoMl/src/V1beta1/PredictResponse.php#L69-L75
train
googleapis/google-cloud-php
Monitoring/src/V3/ListTimeSeriesRequest.php
ListTimeSeriesRequest.setInterval
public function setInterval($var) { GPBUtil::checkMessage($var, \Google\Cloud\Monitoring\V3\TimeInterval::class); $this->interval = $var; return $this; }
php
public function setInterval($var) { GPBUtil::checkMessage($var, \Google\Cloud\Monitoring\V3\TimeInterval::class); $this->interval = $var; return $this; }
[ "public", "function", "setInterval", "(", "$", "var", ")", "{", "GPBUtil", "::", "checkMessage", "(", "$", "var", ",", "\\", "Google", "\\", "Cloud", "\\", "Monitoring", "\\", "V3", "\\", "TimeInterval", "::", "class", ")", ";", "$", "this", "->", "interval", "=", "$", "var", ";", "return", "$", "this", ";", "}" ]
The time interval for which results should be returned. Only time series that contain data points in the specified interval are included in the response. Generated from protobuf field <code>.google.monitoring.v3.TimeInterval interval = 4;</code> @param \Google\Cloud\Monitoring\V3\TimeInterval $var @return $this
[ "The", "time", "interval", "for", "which", "results", "should", "be", "returned", ".", "Only", "time", "series", "that", "contain", "data", "points", "in", "the", "specified", "interval", "are", "included", "in", "the", "response", "." ]
ff5030ffa1f12904565509a7bc24ecc0bd794a3e
https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Monitoring/src/V3/ListTimeSeriesRequest.php#L216-L222
train
googleapis/google-cloud-php
Monitoring/src/V3/ListTimeSeriesRequest.php
ListTimeSeriesRequest.setAggregation
public function setAggregation($var) { GPBUtil::checkMessage($var, \Google\Cloud\Monitoring\V3\Aggregation::class); $this->aggregation = $var; return $this; }
php
public function setAggregation($var) { GPBUtil::checkMessage($var, \Google\Cloud\Monitoring\V3\Aggregation::class); $this->aggregation = $var; return $this; }
[ "public", "function", "setAggregation", "(", "$", "var", ")", "{", "GPBUtil", "::", "checkMessage", "(", "$", "var", ",", "\\", "Google", "\\", "Cloud", "\\", "Monitoring", "\\", "V3", "\\", "Aggregation", "::", "class", ")", ";", "$", "this", "->", "aggregation", "=", "$", "var", ";", "return", "$", "this", ";", "}" ]
By default, the raw time series data is returned. Use this field to combine multiple time series for different views of the data. Generated from protobuf field <code>.google.monitoring.v3.Aggregation aggregation = 5;</code> @param \Google\Cloud\Monitoring\V3\Aggregation $var @return $this
[ "By", "default", "the", "raw", "time", "series", "data", "is", "returned", ".", "Use", "this", "field", "to", "combine", "multiple", "time", "series", "for", "different", "views", "of", "the", "data", "." ]
ff5030ffa1f12904565509a7bc24ecc0bd794a3e
https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Monitoring/src/V3/ListTimeSeriesRequest.php#L246-L252
train
googleapis/google-cloud-php
Monitoring/src/V3/ListTimeSeriesRequest.php
ListTimeSeriesRequest.setView
public function setView($var) { GPBUtil::checkEnum($var, \Google\Cloud\Monitoring\V3\ListTimeSeriesRequest_TimeSeriesView::class); $this->view = $var; return $this; }
php
public function setView($var) { GPBUtil::checkEnum($var, \Google\Cloud\Monitoring\V3\ListTimeSeriesRequest_TimeSeriesView::class); $this->view = $var; return $this; }
[ "public", "function", "setView", "(", "$", "var", ")", "{", "GPBUtil", "::", "checkEnum", "(", "$", "var", ",", "\\", "Google", "\\", "Cloud", "\\", "Monitoring", "\\", "V3", "\\", "ListTimeSeriesRequest_TimeSeriesView", "::", "class", ")", ";", "$", "this", "->", "view", "=", "$", "var", ";", "return", "$", "this", ";", "}" ]
Specifies which information is returned about the time series. Generated from protobuf field <code>.google.monitoring.v3.ListTimeSeriesRequest.TimeSeriesView view = 7;</code> @param int $var @return $this
[ "Specifies", "which", "information", "is", "returned", "about", "the", "time", "series", "." ]
ff5030ffa1f12904565509a7bc24ecc0bd794a3e
https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Monitoring/src/V3/ListTimeSeriesRequest.php#L300-L306
train
googleapis/google-cloud-php
VideoIntelligence/src/V1/FaceFrame.php
FaceFrame.setNormalizedBoundingBoxes
public function setNormalizedBoundingBoxes($var) { $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\VideoIntelligence\V1\NormalizedBoundingBox::class); $this->normalized_bounding_boxes = $arr; return $this; }
php
public function setNormalizedBoundingBoxes($var) { $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\VideoIntelligence\V1\NormalizedBoundingBox::class); $this->normalized_bounding_boxes = $arr; return $this; }
[ "public", "function", "setNormalizedBoundingBoxes", "(", "$", "var", ")", "{", "$", "arr", "=", "GPBUtil", "::", "checkRepeatedField", "(", "$", "var", ",", "\\", "Google", "\\", "Protobuf", "\\", "Internal", "\\", "GPBType", "::", "MESSAGE", ",", "\\", "Google", "\\", "Cloud", "\\", "VideoIntelligence", "\\", "V1", "\\", "NormalizedBoundingBox", "::", "class", ")", ";", "$", "this", "->", "normalized_bounding_boxes", "=", "$", "arr", ";", "return", "$", "this", ";", "}" ]
Normalized Bounding boxes in a frame. There can be more than one boxes if the same face is detected in multiple locations within the current frame. Generated from protobuf field <code>repeated .google.cloud.videointelligence.v1.NormalizedBoundingBox normalized_bounding_boxes = 1;</code> @param \Google\Cloud\VideoIntelligence\V1\NormalizedBoundingBox[]|\Google\Protobuf\Internal\RepeatedField $var @return $this
[ "Normalized", "Bounding", "boxes", "in", "a", "frame", ".", "There", "can", "be", "more", "than", "one", "boxes", "if", "the", "same", "face", "is", "detected", "in", "multiple", "locations", "within", "the", "current", "frame", "." ]
ff5030ffa1f12904565509a7bc24ecc0bd794a3e
https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/VideoIntelligence/src/V1/FaceFrame.php#L76-L82
train
googleapis/google-cloud-php
CommonProtos/src/Audit/AuditLog.php
AuditLog.setAuthenticationInfo
public function setAuthenticationInfo($var) { GPBUtil::checkMessage($var, \Google\Cloud\Audit\AuthenticationInfo::class); $this->authentication_info = $var; return $this; }
php
public function setAuthenticationInfo($var) { GPBUtil::checkMessage($var, \Google\Cloud\Audit\AuthenticationInfo::class); $this->authentication_info = $var; return $this; }
[ "public", "function", "setAuthenticationInfo", "(", "$", "var", ")", "{", "GPBUtil", "::", "checkMessage", "(", "$", "var", ",", "\\", "Google", "\\", "Cloud", "\\", "Audit", "\\", "AuthenticationInfo", "::", "class", ")", ";", "$", "this", "->", "authentication_info", "=", "$", "var", ";", "return", "$", "this", ";", "}" ]
Authentication information. Generated from protobuf field <code>.google.cloud.audit.AuthenticationInfo authentication_info = 3;</code> @param \Google\Cloud\Audit\AuthenticationInfo $var @return $this
[ "Authentication", "information", "." ]
ff5030ffa1f12904565509a7bc24ecc0bd794a3e
https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/CommonProtos/src/Audit/AuditLog.php#L334-L340
train
googleapis/google-cloud-php
CommonProtos/src/Audit/AuditLog.php
AuditLog.setRequestMetadata
public function setRequestMetadata($var) { GPBUtil::checkMessage($var, \Google\Cloud\Audit\RequestMetadata::class); $this->request_metadata = $var; return $this; }
php
public function setRequestMetadata($var) { GPBUtil::checkMessage($var, \Google\Cloud\Audit\RequestMetadata::class); $this->request_metadata = $var; return $this; }
[ "public", "function", "setRequestMetadata", "(", "$", "var", ")", "{", "GPBUtil", "::", "checkMessage", "(", "$", "var", ",", "\\", "Google", "\\", "Cloud", "\\", "Audit", "\\", "RequestMetadata", "::", "class", ")", ";", "$", "this", "->", "request_metadata", "=", "$", "var", ";", "return", "$", "this", ";", "}" ]
Metadata about the operation. Generated from protobuf field <code>.google.cloud.audit.RequestMetadata request_metadata = 4;</code> @param \Google\Cloud\Audit\RequestMetadata $var @return $this
[ "Metadata", "about", "the", "operation", "." ]
ff5030ffa1f12904565509a7bc24ecc0bd794a3e
https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/CommonProtos/src/Audit/AuditLog.php#L390-L396
train
googleapis/google-cloud-php
Container/src/V1/NodePool.php
NodePool.setConfig
public function setConfig($var) { GPBUtil::checkMessage($var, \Google\Cloud\Container\V1\NodeConfig::class); $this->config = $var; return $this; }
php
public function setConfig($var) { GPBUtil::checkMessage($var, \Google\Cloud\Container\V1\NodeConfig::class); $this->config = $var; return $this; }
[ "public", "function", "setConfig", "(", "$", "var", ")", "{", "GPBUtil", "::", "checkMessage", "(", "$", "var", ",", "\\", "Google", "\\", "Cloud", "\\", "Container", "\\", "V1", "\\", "NodeConfig", "::", "class", ")", ";", "$", "this", "->", "config", "=", "$", "var", ";", "return", "$", "this", ";", "}" ]
The node configuration of the pool. Generated from protobuf field <code>.google.container.v1.NodeConfig config = 2;</code> @param \Google\Cloud\Container\V1\NodeConfig $var @return $this
[ "The", "node", "configuration", "of", "the", "pool", "." ]
ff5030ffa1f12904565509a7bc24ecc0bd794a3e
https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Container/src/V1/NodePool.php#L175-L181
train
googleapis/google-cloud-php
Container/src/V1/NodePool.php
NodePool.setAutoscaling
public function setAutoscaling($var) { GPBUtil::checkMessage($var, \Google\Cloud\Container\V1\NodePoolAutoscaling::class); $this->autoscaling = $var; return $this; }
php
public function setAutoscaling($var) { GPBUtil::checkMessage($var, \Google\Cloud\Container\V1\NodePoolAutoscaling::class); $this->autoscaling = $var; return $this; }
[ "public", "function", "setAutoscaling", "(", "$", "var", ")", "{", "GPBUtil", "::", "checkMessage", "(", "$", "var", ",", "\\", "Google", "\\", "Cloud", "\\", "Container", "\\", "V1", "\\", "NodePoolAutoscaling", "::", "class", ")", ";", "$", "this", "->", "autoscaling", "=", "$", "var", ";", "return", "$", "this", ";", "}" ]
Autoscaler configuration for this NodePool. Autoscaler is enabled only if a valid configuration is present. Generated from protobuf field <code>.google.container.v1.NodePoolAutoscaling autoscaling = 4;</code> @param \Google\Cloud\Container\V1\NodePoolAutoscaling $var @return $this
[ "Autoscaler", "configuration", "for", "this", "NodePool", ".", "Autoscaler", "is", "enabled", "only", "if", "a", "valid", "configuration", "is", "present", "." ]
ff5030ffa1f12904565509a7bc24ecc0bd794a3e
https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Container/src/V1/NodePool.php#L371-L377
train
googleapis/google-cloud-php
Container/src/V1/NodePool.php
NodePool.setManagement
public function setManagement($var) { GPBUtil::checkMessage($var, \Google\Cloud\Container\V1\NodeManagement::class); $this->management = $var; return $this; }
php
public function setManagement($var) { GPBUtil::checkMessage($var, \Google\Cloud\Container\V1\NodeManagement::class); $this->management = $var; return $this; }
[ "public", "function", "setManagement", "(", "$", "var", ")", "{", "GPBUtil", "::", "checkMessage", "(", "$", "var", ",", "\\", "Google", "\\", "Cloud", "\\", "Container", "\\", "V1", "\\", "NodeManagement", "::", "class", ")", ";", "$", "this", "->", "management", "=", "$", "var", ";", "return", "$", "this", ";", "}" ]
NodeManagement configuration for this NodePool. Generated from protobuf field <code>.google.container.v1.NodeManagement management = 5;</code> @param \Google\Cloud\Container\V1\NodeManagement $var @return $this
[ "NodeManagement", "configuration", "for", "this", "NodePool", "." ]
ff5030ffa1f12904565509a7bc24ecc0bd794a3e
https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Container/src/V1/NodePool.php#L397-L403
train
googleapis/google-cloud-php
Monitoring/src/V3/ListUptimeCheckConfigsResponse.php
ListUptimeCheckConfigsResponse.setUptimeCheckConfigs
public function setUptimeCheckConfigs($var) { $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Monitoring\V3\UptimeCheckConfig::class); $this->uptime_check_configs = $arr; return $this; }
php
public function setUptimeCheckConfigs($var) { $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Monitoring\V3\UptimeCheckConfig::class); $this->uptime_check_configs = $arr; return $this; }
[ "public", "function", "setUptimeCheckConfigs", "(", "$", "var", ")", "{", "$", "arr", "=", "GPBUtil", "::", "checkRepeatedField", "(", "$", "var", ",", "\\", "Google", "\\", "Protobuf", "\\", "Internal", "\\", "GPBType", "::", "MESSAGE", ",", "\\", "Google", "\\", "Cloud", "\\", "Monitoring", "\\", "V3", "\\", "UptimeCheckConfig", "::", "class", ")", ";", "$", "this", "->", "uptime_check_configs", "=", "$", "arr", ";", "return", "$", "this", ";", "}" ]
The returned uptime check configurations. Generated from protobuf field <code>repeated .google.monitoring.v3.UptimeCheckConfig uptime_check_configs = 1;</code> @param \Google\Cloud\Monitoring\V3\UptimeCheckConfig[]|\Google\Protobuf\Internal\RepeatedField $var @return $this
[ "The", "returned", "uptime", "check", "configurations", "." ]
ff5030ffa1f12904565509a7bc24ecc0bd794a3e
https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Monitoring/src/V3/ListUptimeCheckConfigsResponse.php#L84-L90
train
googleapis/google-cloud-php
Redis/src/V1/LocationMetadata.php
LocationMetadata.setAvailableZones
public function setAvailableZones($var) { $arr = GPBUtil::checkMapField($var, \Google\Protobuf\Internal\GPBType::STRING, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Redis\V1\ZoneMetadata::class); $this->available_zones = $arr; return $this; }
php
public function setAvailableZones($var) { $arr = GPBUtil::checkMapField($var, \Google\Protobuf\Internal\GPBType::STRING, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Redis\V1\ZoneMetadata::class); $this->available_zones = $arr; return $this; }
[ "public", "function", "setAvailableZones", "(", "$", "var", ")", "{", "$", "arr", "=", "GPBUtil", "::", "checkMapField", "(", "$", "var", ",", "\\", "Google", "\\", "Protobuf", "\\", "Internal", "\\", "GPBType", "::", "STRING", ",", "\\", "Google", "\\", "Protobuf", "\\", "Internal", "\\", "GPBType", "::", "MESSAGE", ",", "\\", "Google", "\\", "Cloud", "\\", "Redis", "\\", "V1", "\\", "ZoneMetadata", "::", "class", ")", ";", "$", "this", "->", "available_zones", "=", "$", "arr", ";", "return", "$", "this", ";", "}" ]
Output only. The set of available zones in the location. The map is keyed by the lowercase ID of each zone, as defined by GCE. These keys can be specified in `location_id` or `alternative_location_id` fields when creating a Redis instance. Generated from protobuf field <code>map<string, .google.cloud.redis.v1.ZoneMetadata> available_zones = 1;</code> @param array|\Google\Protobuf\Internal\MapField $var @return $this
[ "Output", "only", ".", "The", "set", "of", "available", "zones", "in", "the", "location", ".", "The", "map", "is", "keyed", "by", "the", "lowercase", "ID", "of", "each", "zone", "as", "defined", "by", "GCE", ".", "These", "keys", "can", "be", "specified", "in", "location_id", "or", "alternative_location_id", "fields", "when", "creating", "a", "Redis", "instance", "." ]
ff5030ffa1f12904565509a7bc24ecc0bd794a3e
https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Redis/src/V1/LocationMetadata.php#L73-L79
train
googleapis/google-cloud-php
Spanner/src/StructType.php
StructType.add
public function add($name, $type) { $invalidIntTypes = [ Database::TYPE_STRUCT, Database::TYPE_ARRAY ]; if (is_int($type) && in_array($type, $invalidIntTypes)) { throw new \InvalidArgumentException( '`Database::TYPE_ARRAY` and `Database::TYPE_STRUCT` are not valid as struct types. ' . 'Instead provide `Google\Cloud\Spanner\ArrayType` or `Google\Cloud\Spanner\StructType`.' ); } $child = null; if ($type instanceof StructType) { $child = $type; $type = Database::TYPE_STRUCT; } elseif ($type instanceof ArrayType) { $child = $type; $type = Database::TYPE_ARRAY; } if (!in_array($type, ValueMapper::$allowedTypes)) { throw new \InvalidArgumentException(sprintf( 'Field type `%s` is not valid.', $type )); } $this->fields[] = [ 'name' => $name, 'type' => $type, 'child' => $child ]; return $this; }
php
public function add($name, $type) { $invalidIntTypes = [ Database::TYPE_STRUCT, Database::TYPE_ARRAY ]; if (is_int($type) && in_array($type, $invalidIntTypes)) { throw new \InvalidArgumentException( '`Database::TYPE_ARRAY` and `Database::TYPE_STRUCT` are not valid as struct types. ' . 'Instead provide `Google\Cloud\Spanner\ArrayType` or `Google\Cloud\Spanner\StructType`.' ); } $child = null; if ($type instanceof StructType) { $child = $type; $type = Database::TYPE_STRUCT; } elseif ($type instanceof ArrayType) { $child = $type; $type = Database::TYPE_ARRAY; } if (!in_array($type, ValueMapper::$allowedTypes)) { throw new \InvalidArgumentException(sprintf( 'Field type `%s` is not valid.', $type )); } $this->fields[] = [ 'name' => $name, 'type' => $type, 'child' => $child ]; return $this; }
[ "public", "function", "add", "(", "$", "name", ",", "$", "type", ")", "{", "$", "invalidIntTypes", "=", "[", "Database", "::", "TYPE_STRUCT", ",", "Database", "::", "TYPE_ARRAY", "]", ";", "if", "(", "is_int", "(", "$", "type", ")", "&&", "in_array", "(", "$", "type", ",", "$", "invalidIntTypes", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'`Database::TYPE_ARRAY` and `Database::TYPE_STRUCT` are not valid as struct types. '", ".", "'Instead provide `Google\\Cloud\\Spanner\\ArrayType` or `Google\\Cloud\\Spanner\\StructType`.'", ")", ";", "}", "$", "child", "=", "null", ";", "if", "(", "$", "type", "instanceof", "StructType", ")", "{", "$", "child", "=", "$", "type", ";", "$", "type", "=", "Database", "::", "TYPE_STRUCT", ";", "}", "elseif", "(", "$", "type", "instanceof", "ArrayType", ")", "{", "$", "child", "=", "$", "type", ";", "$", "type", "=", "Database", "::", "TYPE_ARRAY", ";", "}", "if", "(", "!", "in_array", "(", "$", "type", ",", "ValueMapper", "::", "$", "allowedTypes", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "sprintf", "(", "'Field type `%s` is not valid.'", ",", "$", "type", ")", ")", ";", "}", "$", "this", "->", "fields", "[", "]", "=", "[", "'name'", "=>", "$", "name", ",", "'type'", "=>", "$", "type", ",", "'child'", "=>", "$", "child", "]", ";", "return", "$", "this", ";", "}" ]
Add a struct field definition. Unnamed struct fields may be defined by providing `null` as the first argument value, however you may find it more convenient to use the provided {@see Google\Cloud\Spanner\StructType::addUnnamed()} method. Example: ``` $structType->add('firstName', Database::TYPE_STRING); ``` ``` // If a field is a struct or array, it must be explicitly defined. use Google\Cloud\Spanner\ArrayType; use Google\Cloud\Spanner\Database; use Google\Cloud\Spanner\StructType; // Create a struct which will be nested later. $customer = (new StructType) ->add('name', Database::TYPE_STRING) ->add('phone', Database::TYPE_STRING) ->add('email', Database::TYPE_STRING) ->add('lastOrderDate', Database::TYPE_DATE); // Create an array to nest within the customer type definition. $orderIds = new ArrayType(Database::TYPE_INT64); $customer->add('orderIds', $orderIds); // Add the customer definition to the parameter definition. $structType->add('customer', $customer); ``` @param string|null $name The field name. @param int|ArrayType|StructType $type $type A value type code or nested struct or array definition. Accepted integer values are defined as constants on {@see Google\Cloud\Spanner\Database}, and are as follows: `Database::TYPE_BOOL`, `Database::TYPE_INT64`, `Database::TYPE_FLOAT64`, `Database::TYPE_TIMESTAMP`, `Database::TYPE_DATE`, `Database::TYPE_STRING` and `Database::TYPE_BYTES` @return StructType The current instance, for chaining additional field definitions. @throws \InvalidArgumentException If an invalid type is provided.
[ "Add", "a", "struct", "field", "definition", "." ]
ff5030ffa1f12904565509a7bc24ecc0bd794a3e
https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Spanner/src/StructType.php#L141-L178
train
googleapis/google-cloud-php
Bigtable/src/Admin/V2/CreateAppProfileRequest.php
CreateAppProfileRequest.setAppProfile
public function setAppProfile($var) { GPBUtil::checkMessage($var, \Google\Cloud\Bigtable\Admin\V2\AppProfile::class); $this->app_profile = $var; return $this; }
php
public function setAppProfile($var) { GPBUtil::checkMessage($var, \Google\Cloud\Bigtable\Admin\V2\AppProfile::class); $this->app_profile = $var; return $this; }
[ "public", "function", "setAppProfile", "(", "$", "var", ")", "{", "GPBUtil", "::", "checkMessage", "(", "$", "var", ",", "\\", "Google", "\\", "Cloud", "\\", "Bigtable", "\\", "Admin", "\\", "V2", "\\", "AppProfile", "::", "class", ")", ";", "$", "this", "->", "app_profile", "=", "$", "var", ";", "return", "$", "this", ";", "}" ]
The app profile to be created. Fields marked `OutputOnly` will be ignored. Generated from protobuf field <code>.google.bigtable.admin.v2.AppProfile app_profile = 3;</code> @param \Google\Cloud\Bigtable\Admin\V2\AppProfile $var @return $this
[ "The", "app", "profile", "to", "be", "created", ".", "Fields", "marked", "OutputOnly", "will", "be", "ignored", "." ]
ff5030ffa1f12904565509a7bc24ecc0bd794a3e
https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Bigtable/src/Admin/V2/CreateAppProfileRequest.php#L154-L160
train
googleapis/google-cloud-php
Logging/src/V2/UpdateExclusionRequest.php
UpdateExclusionRequest.setExclusion
public function setExclusion($var) { GPBUtil::checkMessage($var, \Google\Cloud\Logging\V2\LogExclusion::class); $this->exclusion = $var; return $this; }
php
public function setExclusion($var) { GPBUtil::checkMessage($var, \Google\Cloud\Logging\V2\LogExclusion::class); $this->exclusion = $var; return $this; }
[ "public", "function", "setExclusion", "(", "$", "var", ")", "{", "GPBUtil", "::", "checkMessage", "(", "$", "var", ",", "\\", "Google", "\\", "Cloud", "\\", "Logging", "\\", "V2", "\\", "LogExclusion", "::", "class", ")", ";", "$", "this", "->", "exclusion", "=", "$", "var", ";", "return", "$", "this", ";", "}" ]
Required. New values for the existing exclusion. Only the fields specified in `update_mask` are relevant. Generated from protobuf field <code>.google.logging.v2.LogExclusion exclusion = 2;</code> @param \Google\Cloud\Logging\V2\LogExclusion $var @return $this
[ "Required", ".", "New", "values", "for", "the", "existing", "exclusion", ".", "Only", "the", "fields", "specified", "in", "update_mask", "are", "relevant", "." ]
ff5030ffa1f12904565509a7bc24ecc0bd794a3e
https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Logging/src/V2/UpdateExclusionRequest.php#L136-L142
train
googleapis/google-cloud-php
Trace/src/V2/Gapic/TraceServiceGapicClient.php
TraceServiceGapicClient.spanName
public static function spanName($project, $trace, $span) { return self::getSpanNameTemplate()->render([ 'project' => $project, 'trace' => $trace, 'span' => $span, ]); }
php
public static function spanName($project, $trace, $span) { return self::getSpanNameTemplate()->render([ 'project' => $project, 'trace' => $trace, 'span' => $span, ]); }
[ "public", "static", "function", "spanName", "(", "$", "project", ",", "$", "trace", ",", "$", "span", ")", "{", "return", "self", "::", "getSpanNameTemplate", "(", ")", "->", "render", "(", "[", "'project'", "=>", "$", "project", ",", "'trace'", "=>", "$", "trace", ",", "'span'", "=>", "$", "span", ",", "]", ")", ";", "}" ]
Formats a string containing the fully-qualified path to represent a span resource. @param string $project @param string $trace @param string $span @return string The formatted span resource. @experimental
[ "Formats", "a", "string", "containing", "the", "fully", "-", "qualified", "path", "to", "represent", "a", "span", "resource", "." ]
ff5030ffa1f12904565509a7bc24ecc0bd794a3e
https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Trace/src/V2/Gapic/TraceServiceGapicClient.php#L190-L197
train
googleapis/google-cloud-php
Core/src/ConcurrencyControlTrait.php
ConcurrencyControlTrait.applyEtagHeader
private function applyEtagHeader(array $options, $argName = 'etag') { if (isset($options[$argName])) { if (!isset($options['restOptions'])) { $options['restOptions'] = []; } if (!isset($options['restOptions']['headers'])) { $options['restOptions']['headers'] = []; } $options['restOptions']['headers']['If-Match'] = $options[$argName]; } return $options; }
php
private function applyEtagHeader(array $options, $argName = 'etag') { if (isset($options[$argName])) { if (!isset($options['restOptions'])) { $options['restOptions'] = []; } if (!isset($options['restOptions']['headers'])) { $options['restOptions']['headers'] = []; } $options['restOptions']['headers']['If-Match'] = $options[$argName]; } return $options; }
[ "private", "function", "applyEtagHeader", "(", "array", "$", "options", ",", "$", "argName", "=", "'etag'", ")", "{", "if", "(", "isset", "(", "$", "options", "[", "$", "argName", "]", ")", ")", "{", "if", "(", "!", "isset", "(", "$", "options", "[", "'restOptions'", "]", ")", ")", "{", "$", "options", "[", "'restOptions'", "]", "=", "[", "]", ";", "}", "if", "(", "!", "isset", "(", "$", "options", "[", "'restOptions'", "]", "[", "'headers'", "]", ")", ")", "{", "$", "options", "[", "'restOptions'", "]", "[", "'headers'", "]", "=", "[", "]", ";", "}", "$", "options", "[", "'restOptions'", "]", "[", "'headers'", "]", "[", "'If-Match'", "]", "=", "$", "options", "[", "$", "argName", "]", ";", "}", "return", "$", "options", ";", "}" ]
Apply the If-Match header to requests requiring concurrency control. @param array $options @param string $argName @return array
[ "Apply", "the", "If", "-", "Match", "header", "to", "requests", "requiring", "concurrency", "control", "." ]
ff5030ffa1f12904565509a7bc24ecc0bd794a3e
https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Core/src/ConcurrencyControlTrait.php#L32-L47
train
googleapis/google-cloud-php
Container/src/V1/SetNetworkPolicyRequest.php
SetNetworkPolicyRequest.setNetworkPolicy
public function setNetworkPolicy($var) { GPBUtil::checkMessage($var, \Google\Cloud\Container\V1\NetworkPolicy::class); $this->network_policy = $var; return $this; }
php
public function setNetworkPolicy($var) { GPBUtil::checkMessage($var, \Google\Cloud\Container\V1\NetworkPolicy::class); $this->network_policy = $var; return $this; }
[ "public", "function", "setNetworkPolicy", "(", "$", "var", ")", "{", "GPBUtil", "::", "checkMessage", "(", "$", "var", ",", "\\", "Google", "\\", "Cloud", "\\", "Container", "\\", "V1", "\\", "NetworkPolicy", "::", "class", ")", ";", "$", "this", "->", "network_policy", "=", "$", "var", ";", "return", "$", "this", ";", "}" ]
Configuration options for the NetworkPolicy feature. Generated from protobuf field <code>.google.container.v1.NetworkPolicy network_policy = 4;</code> @param \Google\Cloud\Container\V1\NetworkPolicy $var @return $this
[ "Configuration", "options", "for", "the", "NetworkPolicy", "feature", "." ]
ff5030ffa1f12904565509a7bc24ecc0bd794a3e
https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Container/src/V1/SetNetworkPolicyRequest.php#L194-L200
train
googleapis/google-cloud-php
Dlp/src/V2/Finding.php
Finding.setLocation
public function setLocation($var) { GPBUtil::checkMessage($var, \Google\Cloud\Dlp\V2\Location::class); $this->location = $var; return $this; }
php
public function setLocation($var) { GPBUtil::checkMessage($var, \Google\Cloud\Dlp\V2\Location::class); $this->location = $var; return $this; }
[ "public", "function", "setLocation", "(", "$", "var", ")", "{", "GPBUtil", "::", "checkMessage", "(", "$", "var", ",", "\\", "Google", "\\", "Cloud", "\\", "Dlp", "\\", "V2", "\\", "Location", "::", "class", ")", ";", "$", "this", "->", "location", "=", "$", "var", ";", "return", "$", "this", ";", "}" ]
Where the content was found. Generated from protobuf field <code>.google.privacy.dlp.v2.Location location = 4;</code> @param \Google\Cloud\Dlp\V2\Location $var @return $this
[ "Where", "the", "content", "was", "found", "." ]
ff5030ffa1f12904565509a7bc24ecc0bd794a3e
https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Dlp/src/V2/Finding.php#L200-L206
train
googleapis/google-cloud-php
Dialogflow/src/V2/CreateSessionEntityTypeRequest.php
CreateSessionEntityTypeRequest.setSessionEntityType
public function setSessionEntityType($var) { GPBUtil::checkMessage($var, \Google\Cloud\Dialogflow\V2\SessionEntityType::class); $this->session_entity_type = $var; return $this; }
php
public function setSessionEntityType($var) { GPBUtil::checkMessage($var, \Google\Cloud\Dialogflow\V2\SessionEntityType::class); $this->session_entity_type = $var; return $this; }
[ "public", "function", "setSessionEntityType", "(", "$", "var", ")", "{", "GPBUtil", "::", "checkMessage", "(", "$", "var", ",", "\\", "Google", "\\", "Cloud", "\\", "Dialogflow", "\\", "V2", "\\", "SessionEntityType", "::", "class", ")", ";", "$", "this", "->", "session_entity_type", "=", "$", "var", ";", "return", "$", "this", ";", "}" ]
Required. The session entity type to create. Generated from protobuf field <code>.google.cloud.dialogflow.v2.SessionEntityType session_entity_type = 2;</code> @param \Google\Cloud\Dialogflow\V2\SessionEntityType $var @return $this
[ "Required", ".", "The", "session", "entity", "type", "to", "create", "." ]
ff5030ffa1f12904565509a7bc24ecc0bd794a3e
https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Dialogflow/src/V2/CreateSessionEntityTypeRequest.php#L96-L102
train
googleapis/google-cloud-php
Logging/src/V2/CreateSinkRequest.php
CreateSinkRequest.setSink
public function setSink($var) { GPBUtil::checkMessage($var, \Google\Cloud\Logging\V2\LogSink::class); $this->sink = $var; return $this; }
php
public function setSink($var) { GPBUtil::checkMessage($var, \Google\Cloud\Logging\V2\LogSink::class); $this->sink = $var; return $this; }
[ "public", "function", "setSink", "(", "$", "var", ")", "{", "GPBUtil", "::", "checkMessage", "(", "$", "var", ",", "\\", "Google", "\\", "Cloud", "\\", "Logging", "\\", "V2", "\\", "LogSink", "::", "class", ")", ";", "$", "this", "->", "sink", "=", "$", "var", ";", "return", "$", "this", ";", "}" ]
Required. The new sink, whose `name` parameter is a sink identifier that is not already in use. Generated from protobuf field <code>.google.logging.v2.LogSink sink = 2;</code> @param \Google\Cloud\Logging\V2\LogSink $var @return $this
[ "Required", ".", "The", "new", "sink", "whose", "name", "parameter", "is", "a", "sink", "identifier", "that", "is", "not", "already", "in", "use", "." ]
ff5030ffa1f12904565509a7bc24ecc0bd794a3e
https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Logging/src/V2/CreateSinkRequest.php#L144-L150
train
googleapis/google-cloud-php
VideoIntelligence/src/V1beta2/ExplicitContentAnnotation.php
ExplicitContentAnnotation.setFrames
public function setFrames($var) { $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\VideoIntelligence\V1beta2\ExplicitContentFrame::class); $this->frames = $arr; return $this; }
php
public function setFrames($var) { $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\VideoIntelligence\V1beta2\ExplicitContentFrame::class); $this->frames = $arr; return $this; }
[ "public", "function", "setFrames", "(", "$", "var", ")", "{", "$", "arr", "=", "GPBUtil", "::", "checkRepeatedField", "(", "$", "var", ",", "\\", "Google", "\\", "Protobuf", "\\", "Internal", "\\", "GPBType", "::", "MESSAGE", ",", "\\", "Google", "\\", "Cloud", "\\", "VideoIntelligence", "\\", "V1beta2", "\\", "ExplicitContentFrame", "::", "class", ")", ";", "$", "this", "->", "frames", "=", "$", "arr", ";", "return", "$", "this", ";", "}" ]
All video frames where explicit content was detected. Generated from protobuf field <code>repeated .google.cloud.videointelligence.v1beta2.ExplicitContentFrame frames = 1;</code> @param \Google\Cloud\VideoIntelligence\V1beta2\ExplicitContentFrame[]|\Google\Protobuf\Internal\RepeatedField $var @return $this
[ "All", "video", "frames", "where", "explicit", "content", "was", "detected", "." ]
ff5030ffa1f12904565509a7bc24ecc0bd794a3e
https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/VideoIntelligence/src/V1beta2/ExplicitContentAnnotation.php#L60-L66
train
googleapis/google-cloud-php
Datastore/src/V1/Query.php
Query.setProjection
public function setProjection($var) { $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Datastore\V1\Projection::class); $this->projection = $arr; return $this; }
php
public function setProjection($var) { $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Datastore\V1\Projection::class); $this->projection = $arr; return $this; }
[ "public", "function", "setProjection", "(", "$", "var", ")", "{", "$", "arr", "=", "GPBUtil", "::", "checkRepeatedField", "(", "$", "var", ",", "\\", "Google", "\\", "Protobuf", "\\", "Internal", "\\", "GPBType", "::", "MESSAGE", ",", "\\", "Google", "\\", "Cloud", "\\", "Datastore", "\\", "V1", "\\", "Projection", "::", "class", ")", ";", "$", "this", "->", "projection", "=", "$", "arr", ";", "return", "$", "this", ";", "}" ]
The projection to return. Defaults to returning all properties. Generated from protobuf field <code>repeated .google.datastore.v1.Projection projection = 2;</code> @param \Google\Cloud\Datastore\V1\Projection[]|\Google\Protobuf\Internal\RepeatedField $var @return $this
[ "The", "projection", "to", "return", ".", "Defaults", "to", "returning", "all", "properties", "." ]
ff5030ffa1f12904565509a7bc24ecc0bd794a3e
https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Datastore/src/V1/Query.php#L148-L154
train
googleapis/google-cloud-php
Container/src/V1/ServerConfig.php
ServerConfig.setValidNodeVersions
public function setValidNodeVersions($var) { $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING); $this->valid_node_versions = $arr; return $this; }
php
public function setValidNodeVersions($var) { $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING); $this->valid_node_versions = $arr; return $this; }
[ "public", "function", "setValidNodeVersions", "(", "$", "var", ")", "{", "$", "arr", "=", "GPBUtil", "::", "checkRepeatedField", "(", "$", "var", ",", "\\", "Google", "\\", "Protobuf", "\\", "Internal", "\\", "GPBType", "::", "STRING", ")", ";", "$", "this", "->", "valid_node_versions", "=", "$", "arr", ";", "return", "$", "this", ";", "}" ]
List of valid node upgrade target versions. Generated from protobuf field <code>repeated string valid_node_versions = 3;</code> @param string[]|\Google\Protobuf\Internal\RepeatedField $var @return $this
[ "List", "of", "valid", "node", "upgrade", "target", "versions", "." ]
ff5030ffa1f12904565509a7bc24ecc0bd794a3e
https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Container/src/V1/ServerConfig.php#L116-L122
train
googleapis/google-cloud-php
Container/src/V1/ServerConfig.php
ServerConfig.setValidImageTypes
public function setValidImageTypes($var) { $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING); $this->valid_image_types = $arr; return $this; }
php
public function setValidImageTypes($var) { $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING); $this->valid_image_types = $arr; return $this; }
[ "public", "function", "setValidImageTypes", "(", "$", "var", ")", "{", "$", "arr", "=", "GPBUtil", "::", "checkRepeatedField", "(", "$", "var", ",", "\\", "Google", "\\", "Protobuf", "\\", "Internal", "\\", "GPBType", "::", "STRING", ")", ";", "$", "this", "->", "valid_image_types", "=", "$", "arr", ";", "return", "$", "this", ";", "}" ]
List of valid image types. Generated from protobuf field <code>repeated string valid_image_types = 5;</code> @param string[]|\Google\Protobuf\Internal\RepeatedField $var @return $this
[ "List", "of", "valid", "image", "types", "." ]
ff5030ffa1f12904565509a7bc24ecc0bd794a3e
https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Container/src/V1/ServerConfig.php#L168-L174
train
googleapis/google-cloud-php
Container/src/V1/ServerConfig.php
ServerConfig.setValidMasterVersions
public function setValidMasterVersions($var) { $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING); $this->valid_master_versions = $arr; return $this; }
php
public function setValidMasterVersions($var) { $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING); $this->valid_master_versions = $arr; return $this; }
[ "public", "function", "setValidMasterVersions", "(", "$", "var", ")", "{", "$", "arr", "=", "GPBUtil", "::", "checkRepeatedField", "(", "$", "var", ",", "\\", "Google", "\\", "Protobuf", "\\", "Internal", "\\", "GPBType", "::", "STRING", ")", ";", "$", "this", "->", "valid_master_versions", "=", "$", "arr", ";", "return", "$", "this", ";", "}" ]
List of valid master versions. Generated from protobuf field <code>repeated string valid_master_versions = 6;</code> @param string[]|\Google\Protobuf\Internal\RepeatedField $var @return $this
[ "List", "of", "valid", "master", "versions", "." ]
ff5030ffa1f12904565509a7bc24ecc0bd794a3e
https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Container/src/V1/ServerConfig.php#L194-L200
train
googleapis/google-cloud-php
Firestore/src/V1/StructuredQuery.php
StructuredQuery.setFrom
public function setFrom($var) { $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Firestore\V1\StructuredQuery\CollectionSelector::class); $this->from = $arr; return $this; }
php
public function setFrom($var) { $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Firestore\V1\StructuredQuery\CollectionSelector::class); $this->from = $arr; return $this; }
[ "public", "function", "setFrom", "(", "$", "var", ")", "{", "$", "arr", "=", "GPBUtil", "::", "checkRepeatedField", "(", "$", "var", ",", "\\", "Google", "\\", "Protobuf", "\\", "Internal", "\\", "GPBType", "::", "MESSAGE", ",", "\\", "Google", "\\", "Cloud", "\\", "Firestore", "\\", "V1", "\\", "StructuredQuery", "\\", "CollectionSelector", "::", "class", ")", ";", "$", "this", "->", "from", "=", "$", "arr", ";", "return", "$", "this", ";", "}" ]
The collections to query. Generated from protobuf field <code>repeated .google.firestore.v1.StructuredQuery.CollectionSelector from = 2;</code> @param \Google\Cloud\Firestore\V1\StructuredQuery\CollectionSelector[]|\Google\Protobuf\Internal\RepeatedField $var @return $this
[ "The", "collections", "to", "query", "." ]
ff5030ffa1f12904565509a7bc24ecc0bd794a3e
https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Firestore/src/V1/StructuredQuery.php#L174-L180
train
googleapis/google-cloud-php
Firestore/src/V1/StructuredQuery.php
StructuredQuery.setStartAt
public function setStartAt($var) { GPBUtil::checkMessage($var, \Google\Cloud\Firestore\V1\Cursor::class); $this->start_at = $var; return $this; }
php
public function setStartAt($var) { GPBUtil::checkMessage($var, \Google\Cloud\Firestore\V1\Cursor::class); $this->start_at = $var; return $this; }
[ "public", "function", "setStartAt", "(", "$", "var", ")", "{", "GPBUtil", "::", "checkMessage", "(", "$", "var", ",", "\\", "Google", "\\", "Cloud", "\\", "Firestore", "\\", "V1", "\\", "Cursor", "::", "class", ")", ";", "$", "this", "->", "start_at", "=", "$", "var", ";", "return", "$", "this", ";", "}" ]
A starting point for the query results. Generated from protobuf field <code>.google.firestore.v1.Cursor start_at = 7;</code> @param \Google\Cloud\Firestore\V1\Cursor $var @return $this
[ "A", "starting", "point", "for", "the", "query", "results", "." ]
ff5030ffa1f12904565509a7bc24ecc0bd794a3e
https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Firestore/src/V1/StructuredQuery.php#L278-L284
train
googleapis/google-cloud-php
Iot/src/V1/Device.php
Device.setConfig
public function setConfig($var) { GPBUtil::checkMessage($var, \Google\Cloud\Iot\V1\DeviceConfig::class); $this->config = $var; return $this; }
php
public function setConfig($var) { GPBUtil::checkMessage($var, \Google\Cloud\Iot\V1\DeviceConfig::class); $this->config = $var; return $this; }
[ "public", "function", "setConfig", "(", "$", "var", ")", "{", "GPBUtil", "::", "checkMessage", "(", "$", "var", ",", "\\", "Google", "\\", "Cloud", "\\", "Iot", "\\", "V1", "\\", "DeviceConfig", "::", "class", ")", ";", "$", "this", "->", "config", "=", "$", "var", ";", "return", "$", "this", ";", "}" ]
The most recent device configuration, which is eventually sent from Cloud IoT Core to the device. If not present on creation, the configuration will be initialized with an empty payload and version value of `1`. To update this field after creation, use the `DeviceManager.ModifyCloudToDeviceConfig` method. Generated from protobuf field <code>.google.cloud.iot.v1.DeviceConfig config = 13;</code> @param \Google\Cloud\Iot\V1\DeviceConfig $var @return $this
[ "The", "most", "recent", "device", "configuration", "which", "is", "eventually", "sent", "from", "Cloud", "IoT", "Core", "to", "the", "device", ".", "If", "not", "present", "on", "creation", "the", "configuration", "will", "be", "initialized", "with", "an", "empty", "payload", "and", "version", "value", "of", "1", ".", "To", "update", "this", "field", "after", "creation", "use", "the", "DeviceManager", ".", "ModifyCloudToDeviceConfig", "method", "." ]
ff5030ffa1f12904565509a7bc24ecc0bd794a3e
https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Iot/src/V1/Device.php#L656-L662
train
googleapis/google-cloud-php
Iot/src/V1/Device.php
Device.setGatewayConfig
public function setGatewayConfig($var) { GPBUtil::checkMessage($var, \Google\Cloud\Iot\V1\GatewayConfig::class); $this->gateway_config = $var; return $this; }
php
public function setGatewayConfig($var) { GPBUtil::checkMessage($var, \Google\Cloud\Iot\V1\GatewayConfig::class); $this->gateway_config = $var; return $this; }
[ "public", "function", "setGatewayConfig", "(", "$", "var", ")", "{", "GPBUtil", "::", "checkMessage", "(", "$", "var", ",", "\\", "Google", "\\", "Cloud", "\\", "Iot", "\\", "V1", "\\", "GatewayConfig", "::", "class", ")", ";", "$", "this", "->", "gateway_config", "=", "$", "var", ";", "return", "$", "this", ";", "}" ]
Gateway-related configuration and state. Generated from protobuf field <code>.google.cloud.iot.v1.GatewayConfig gateway_config = 24;</code> @param \Google\Cloud\Iot\V1\GatewayConfig $var @return $this
[ "Gateway", "-", "related", "configuration", "and", "state", "." ]
ff5030ffa1f12904565509a7bc24ecc0bd794a3e
https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Iot/src/V1/Device.php#L782-L788
train
googleapis/google-cloud-php
Debugger/src/V2/ListActiveBreakpointsResponse.php
ListActiveBreakpointsResponse.setBreakpoints
public function setBreakpoints($var) { $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Debugger\V2\Breakpoint::class); $this->breakpoints = $arr; return $this; }
php
public function setBreakpoints($var) { $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Debugger\V2\Breakpoint::class); $this->breakpoints = $arr; return $this; }
[ "public", "function", "setBreakpoints", "(", "$", "var", ")", "{", "$", "arr", "=", "GPBUtil", "::", "checkRepeatedField", "(", "$", "var", ",", "\\", "Google", "\\", "Protobuf", "\\", "Internal", "\\", "GPBType", "::", "MESSAGE", ",", "\\", "Google", "\\", "Cloud", "\\", "Debugger", "\\", "V2", "\\", "Breakpoint", "::", "class", ")", ";", "$", "this", "->", "breakpoints", "=", "$", "arr", ";", "return", "$", "this", ";", "}" ]
List of all active breakpoints. The fields `id` and `location` are guaranteed to be set on each breakpoint. Generated from protobuf field <code>repeated .google.devtools.clouddebugger.v2.Breakpoint breakpoints = 1;</code> @param \Google\Cloud\Debugger\V2\Breakpoint[]|\Google\Protobuf\Internal\RepeatedField $var @return $this
[ "List", "of", "all", "active", "breakpoints", ".", "The", "fields", "id", "and", "location", "are", "guaranteed", "to", "be", "set", "on", "each", "breakpoint", "." ]
ff5030ffa1f12904565509a7bc24ecc0bd794a3e
https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Debugger/src/V2/ListActiveBreakpointsResponse.php#L84-L90
train
googleapis/google-cloud-php
Trace/src/Span.php
Span.info
public function info() { $data = [ 'displayName' => [ 'value' => $this->name ], 'spanId' => $this->spanId, 'startTime' => $this->startTime, 'endTime' => $this->endTime ]; if ($this->parentSpanId) { $data['parentSpanId'] = $this->parentSpanId; } if ($this->attributes) { $data['attributes'] = $this->attributes->info(); } if ($this->timeEvents) { $data['timeEvents'] = [ 'timeEvent' => array_map(function ($timeEvent) { return $timeEvent->info(); }, $this->timeEvents) ]; } if ($this->links) { $data['links'] = [ 'link' => array_map(function ($link) { return $link->info(); }, $this->links) ]; } if ($this->status) { $data['status'] = $this->status->info(); } if ($this->stackTrace) { $data['stackTrace'] = $this->stackTrace->info(); } if ($this->sameProcessAsParentSpan !== null) { $data['sameProcessAsParentSpan'] = $this->sameProcessAsParentSpan; } return $data; }
php
public function info() { $data = [ 'displayName' => [ 'value' => $this->name ], 'spanId' => $this->spanId, 'startTime' => $this->startTime, 'endTime' => $this->endTime ]; if ($this->parentSpanId) { $data['parentSpanId'] = $this->parentSpanId; } if ($this->attributes) { $data['attributes'] = $this->attributes->info(); } if ($this->timeEvents) { $data['timeEvents'] = [ 'timeEvent' => array_map(function ($timeEvent) { return $timeEvent->info(); }, $this->timeEvents) ]; } if ($this->links) { $data['links'] = [ 'link' => array_map(function ($link) { return $link->info(); }, $this->links) ]; } if ($this->status) { $data['status'] = $this->status->info(); } if ($this->stackTrace) { $data['stackTrace'] = $this->stackTrace->info(); } if ($this->sameProcessAsParentSpan !== null) { $data['sameProcessAsParentSpan'] = $this->sameProcessAsParentSpan; } return $data; }
[ "public", "function", "info", "(", ")", "{", "$", "data", "=", "[", "'displayName'", "=>", "[", "'value'", "=>", "$", "this", "->", "name", "]", ",", "'spanId'", "=>", "$", "this", "->", "spanId", ",", "'startTime'", "=>", "$", "this", "->", "startTime", ",", "'endTime'", "=>", "$", "this", "->", "endTime", "]", ";", "if", "(", "$", "this", "->", "parentSpanId", ")", "{", "$", "data", "[", "'parentSpanId'", "]", "=", "$", "this", "->", "parentSpanId", ";", "}", "if", "(", "$", "this", "->", "attributes", ")", "{", "$", "data", "[", "'attributes'", "]", "=", "$", "this", "->", "attributes", "->", "info", "(", ")", ";", "}", "if", "(", "$", "this", "->", "timeEvents", ")", "{", "$", "data", "[", "'timeEvents'", "]", "=", "[", "'timeEvent'", "=>", "array_map", "(", "function", "(", "$", "timeEvent", ")", "{", "return", "$", "timeEvent", "->", "info", "(", ")", ";", "}", ",", "$", "this", "->", "timeEvents", ")", "]", ";", "}", "if", "(", "$", "this", "->", "links", ")", "{", "$", "data", "[", "'links'", "]", "=", "[", "'link'", "=>", "array_map", "(", "function", "(", "$", "link", ")", "{", "return", "$", "link", "->", "info", "(", ")", ";", "}", ",", "$", "this", "->", "links", ")", "]", ";", "}", "if", "(", "$", "this", "->", "status", ")", "{", "$", "data", "[", "'status'", "]", "=", "$", "this", "->", "status", "->", "info", "(", ")", ";", "}", "if", "(", "$", "this", "->", "stackTrace", ")", "{", "$", "data", "[", "'stackTrace'", "]", "=", "$", "this", "->", "stackTrace", "->", "info", "(", ")", ";", "}", "if", "(", "$", "this", "->", "sameProcessAsParentSpan", "!==", "null", ")", "{", "$", "data", "[", "'sameProcessAsParentSpan'", "]", "=", "$", "this", "->", "sameProcessAsParentSpan", ";", "}", "return", "$", "data", ";", "}" ]
Returns the info array for serialization. @access private @return array
[ "Returns", "the", "info", "array", "for", "serialization", "." ]
ff5030ffa1f12904565509a7bc24ecc0bd794a3e
https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Trace/src/Span.php#L369-L409
train
googleapis/google-cloud-php
Trace/src/Span.php
Span.addTimeEvent
public function addTimeEvent(TimeEvent $event) { if (!$this->timeEvents) { $this->timeEvents = []; } $this->timeEvents[] = $event; }
php
public function addTimeEvent(TimeEvent $event) { if (!$this->timeEvents) { $this->timeEvents = []; } $this->timeEvents[] = $event; }
[ "public", "function", "addTimeEvent", "(", "TimeEvent", "$", "event", ")", "{", "if", "(", "!", "$", "this", "->", "timeEvents", ")", "{", "$", "this", "->", "timeEvents", "=", "[", "]", ";", "}", "$", "this", "->", "timeEvents", "[", "]", "=", "$", "event", ";", "}" ]
Add a single TimeEvent to this span. Example: ``` $annotation = new Annotation('some message'); $span->addTimeEvent($annotation); ``` @param TimeEvent $event
[ "Add", "a", "single", "TimeEvent", "to", "this", "span", "." ]
ff5030ffa1f12904565509a7bc24ecc0bd794a3e
https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Trace/src/Span.php#L444-L450
train
googleapis/google-cloud-php
Trace/src/Span.php
Span.addLink
public function addLink(Link $link) { if (!$this->links) { $this->links = []; } $this->links[] = $link; }
php
public function addLink(Link $link) { if (!$this->links) { $this->links = []; } $this->links[] = $link; }
[ "public", "function", "addLink", "(", "Link", "$", "link", ")", "{", "if", "(", "!", "$", "this", "->", "links", ")", "{", "$", "this", "->", "links", "=", "[", "]", ";", "}", "$", "this", "->", "links", "[", "]", "=", "$", "link", ";", "}" ]
Add a single Link to this span. Example: ``` $link = new Link('abcd1234', 'abcd2345'); $span->addLink($link); ``` @param Link $link
[ "Add", "a", "single", "Link", "to", "this", "span", "." ]
ff5030ffa1f12904565509a7bc24ecc0bd794a3e
https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Trace/src/Span.php#L481-L487
train
googleapis/google-cloud-php
Datastore/src/Operation.php
Operation.keys
public function keys($kind, array $options = []) { $options += [ 'number' => 1, 'ancestors' => [], 'id' => null, 'name' => null ]; if ($options['number'] < 1) { throw new \InvalidArgumentException('Number of keys cannot be less than 1.'); } $path = []; if (count($options['ancestors']) > 0) { $path = $options['ancestors']; } $path[] = array_filter([ 'kind' => $kind, 'id' => $options['id'], 'name' => $options['name'] ]); $key = new Key($this->projectId, [ 'path' => $path, 'namespaceId' => $this->namespaceId ]); $keys = [$key]; for ($i = 1; $i < $options['number']; $i++) { $keys[] = clone $key; } return $keys; }
php
public function keys($kind, array $options = []) { $options += [ 'number' => 1, 'ancestors' => [], 'id' => null, 'name' => null ]; if ($options['number'] < 1) { throw new \InvalidArgumentException('Number of keys cannot be less than 1.'); } $path = []; if (count($options['ancestors']) > 0) { $path = $options['ancestors']; } $path[] = array_filter([ 'kind' => $kind, 'id' => $options['id'], 'name' => $options['name'] ]); $key = new Key($this->projectId, [ 'path' => $path, 'namespaceId' => $this->namespaceId ]); $keys = [$key]; for ($i = 1; $i < $options['number']; $i++) { $keys[] = clone $key; } return $keys; }
[ "public", "function", "keys", "(", "$", "kind", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "options", "+=", "[", "'number'", "=>", "1", ",", "'ancestors'", "=>", "[", "]", ",", "'id'", "=>", "null", ",", "'name'", "=>", "null", "]", ";", "if", "(", "$", "options", "[", "'number'", "]", "<", "1", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'Number of keys cannot be less than 1.'", ")", ";", "}", "$", "path", "=", "[", "]", ";", "if", "(", "count", "(", "$", "options", "[", "'ancestors'", "]", ")", ">", "0", ")", "{", "$", "path", "=", "$", "options", "[", "'ancestors'", "]", ";", "}", "$", "path", "[", "]", "=", "array_filter", "(", "[", "'kind'", "=>", "$", "kind", ",", "'id'", "=>", "$", "options", "[", "'id'", "]", ",", "'name'", "=>", "$", "options", "[", "'name'", "]", "]", ")", ";", "$", "key", "=", "new", "Key", "(", "$", "this", "->", "projectId", ",", "[", "'path'", "=>", "$", "path", ",", "'namespaceId'", "=>", "$", "this", "->", "namespaceId", "]", ")", ";", "$", "keys", "=", "[", "$", "key", "]", ";", "for", "(", "$", "i", "=", "1", ";", "$", "i", "<", "$", "options", "[", "'number'", "]", ";", "$", "i", "++", ")", "{", "$", "keys", "[", "]", "=", "clone", "$", "key", ";", "}", "return", "$", "keys", ";", "}" ]
Create multiple keys with the same configuration. When inserting multiple entities, creating a set of keys at once can be useful. By defining the Key's kind and any ancestors up front, and allowing Cloud Datastore to allocate IDs, you can be sure that your entity identity and ancestry are correct and that there will be no collisions during the insert operation. @see https://cloud.google.com/datastore/reference/rest/v1/Key Key @see https://cloud.google.com/datastore/reference/rest/v1/Key#PathElement PathElement @param string $kind The kind to use in the final path element. @param array $options [optional] { Configuration Options @type array[] $ancestors An array of [PathElement](https://cloud.google.com/datastore/reference/rest/v1/Key#PathElement) arrays. Use to create [ancestor paths](https://cloud.google.com/datastore/docs/concepts/entities#ancestor_paths). @type int $number The number of keys to generate. @type string|int $id The ID for the last pathElement. @type string $name The Name for the last pathElement. } @return Key[] @throws \InvalidArgumentException If the number of keys is less than 1.
[ "Create", "multiple", "keys", "with", "the", "same", "configuration", "." ]
ff5030ffa1f12904565509a7bc24ecc0bd794a3e
https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Datastore/src/Operation.php#L139-L175
train
googleapis/google-cloud-php
Datastore/src/Operation.php
Operation.entity
public function entity($key = null, array $entity = [], array $options = []) { $options += [ 'className' => null ]; if ($key && !is_string($key) && !($key instanceof Key)) { throw new \InvalidArgumentException( '$key must be an instance of Key or a string' ); } if (is_string($key)) { $key = $this->key($key); } $className = $options['className']; if (!is_null($className) && !is_subclass_of($className, EntityInterface::class)) { throw new \InvalidArgumentException(sprintf( 'Given classname %s must implement EntityInterface', $className )); } if (is_null($className)) { $className = Entity::class; } return $className::build($key, $entity, $options); }
php
public function entity($key = null, array $entity = [], array $options = []) { $options += [ 'className' => null ]; if ($key && !is_string($key) && !($key instanceof Key)) { throw new \InvalidArgumentException( '$key must be an instance of Key or a string' ); } if (is_string($key)) { $key = $this->key($key); } $className = $options['className']; if (!is_null($className) && !is_subclass_of($className, EntityInterface::class)) { throw new \InvalidArgumentException(sprintf( 'Given classname %s must implement EntityInterface', $className )); } if (is_null($className)) { $className = Entity::class; } return $className::build($key, $entity, $options); }
[ "public", "function", "entity", "(", "$", "key", "=", "null", ",", "array", "$", "entity", "=", "[", "]", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "options", "+=", "[", "'className'", "=>", "null", "]", ";", "if", "(", "$", "key", "&&", "!", "is_string", "(", "$", "key", ")", "&&", "!", "(", "$", "key", "instanceof", "Key", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'$key must be an instance of Key or a string'", ")", ";", "}", "if", "(", "is_string", "(", "$", "key", ")", ")", "{", "$", "key", "=", "$", "this", "->", "key", "(", "$", "key", ")", ";", "}", "$", "className", "=", "$", "options", "[", "'className'", "]", ";", "if", "(", "!", "is_null", "(", "$", "className", ")", "&&", "!", "is_subclass_of", "(", "$", "className", ",", "EntityInterface", "::", "class", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "sprintf", "(", "'Given classname %s must implement EntityInterface'", ",", "$", "className", ")", ")", ";", "}", "if", "(", "is_null", "(", "$", "className", ")", ")", "{", "$", "className", "=", "Entity", "::", "class", ";", "}", "return", "$", "className", "::", "build", "(", "$", "key", ",", "$", "entity", ",", "$", "options", ")", ";", "}" ]
Create an entity This method does not execute any service requests. Entities are created with a Datastore Key, or by specifying a Kind. Kinds are only allowed for insert operations. For any other case, you must specify a named key. If a kind is given, an ID will be automatically allocated for the entity upon insert. Additionally, if your entity requires a complex key elementPath, you must create the key separately. In certain cases, you may want to create your own entity types. Google Cloud PHP supports custom types implementing {@see Google\Cloud\Datastore\EntityInterface}. If the name of an `EntityInterface` implementation is given in the options array, an instance of that class will be returned instead of {@see Google\Cloud\Datastore\Entity}. @see https://cloud.google.com/datastore/reference/rest/v1/Entity Entity @param Key|string|null $key [optional] The key used to identify the record, or a string $kind. The key may be null only if the entity will be used as an embedded entity within another entity. Attempting to use keyless entities as root entities will result in error. @param array $entity [optional] The data to fill the entity with. @param array $options [optional] { Configuration Options @type string $className If set, the given class will be returned. Value must be the name of a class implementing {@see Google\Cloud\Datastore\EntityInterface}. **Defaults to** {@see Google\Cloud\Datastore\Entity}. @type array $excludeFromIndexes A list of entity keys to exclude from datastore indexes. } @return EntityInterface @throws InvalidArgumentException
[ "Create", "an", "entity" ]
ff5030ffa1f12904565509a7bc24ecc0bd794a3e
https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Datastore/src/Operation.php#L215-L244
train
googleapis/google-cloud-php
Datastore/src/Operation.php
Operation.beginTransaction
public function beginTransaction($transactionOptions, array $options = []) { $res = $this->connection->beginTransaction([ 'projectId' => $this->projectId, 'transactionOptions' => $transactionOptions ] + $options); return $res['transaction']; }
php
public function beginTransaction($transactionOptions, array $options = []) { $res = $this->connection->beginTransaction([ 'projectId' => $this->projectId, 'transactionOptions' => $transactionOptions ] + $options); return $res['transaction']; }
[ "public", "function", "beginTransaction", "(", "$", "transactionOptions", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "res", "=", "$", "this", "->", "connection", "->", "beginTransaction", "(", "[", "'projectId'", "=>", "$", "this", "->", "projectId", ",", "'transactionOptions'", "=>", "$", "transactionOptions", "]", "+", "$", "options", ")", ";", "return", "$", "res", "[", "'transaction'", "]", ";", "}" ]
Begin a Datastore Transaction. @param array $transactionOptions [Transaction Options](https://cloud.google.com/datastore/docs/reference/data/rest/v1/projects/beginTransaction#TransactionOptions) @param array $options Configuration options. @return string
[ "Begin", "a", "Datastore", "Transaction", "." ]
ff5030ffa1f12904565509a7bc24ecc0bd794a3e
https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Datastore/src/Operation.php#L254-L262
train
googleapis/google-cloud-php
Datastore/src/Operation.php
Operation.allocateIds
public function allocateIds(array $keys, array $options = []) { // Validate the given keys. First check types, then state of each. // The API will throw a 400 if the key is named, but it's an easy // check we can handle before going to the API to save a request. // @todo replace with json schema $this->validateBatch($keys, Key::class, function ($key) { if ($key->state() !== Key::STATE_INCOMPLETE) { throw new \InvalidArgumentException(sprintf( 'Given $key is in an invalid state. Can only allocate IDs for incomplete keys. ' . 'Given path was %s', (string) $key )); } }); $serviceKeys = []; foreach ($keys as $key) { $serviceKeys[] = $key->keyObject(); } $res = $this->connection->allocateIds([ 'projectId' => $this->projectId, 'keys' => $serviceKeys ] + $options); if (isset($res['keys'])) { foreach ($res['keys'] as $index => $key) { if (!isset($keys[$index])) { continue; } $end = end($key['path']); $id = $end['id']; $keys[$index]->setLastElementIdentifier($id); } } return $keys; }
php
public function allocateIds(array $keys, array $options = []) { // Validate the given keys. First check types, then state of each. // The API will throw a 400 if the key is named, but it's an easy // check we can handle before going to the API to save a request. // @todo replace with json schema $this->validateBatch($keys, Key::class, function ($key) { if ($key->state() !== Key::STATE_INCOMPLETE) { throw new \InvalidArgumentException(sprintf( 'Given $key is in an invalid state. Can only allocate IDs for incomplete keys. ' . 'Given path was %s', (string) $key )); } }); $serviceKeys = []; foreach ($keys as $key) { $serviceKeys[] = $key->keyObject(); } $res = $this->connection->allocateIds([ 'projectId' => $this->projectId, 'keys' => $serviceKeys ] + $options); if (isset($res['keys'])) { foreach ($res['keys'] as $index => $key) { if (!isset($keys[$index])) { continue; } $end = end($key['path']); $id = $end['id']; $keys[$index]->setLastElementIdentifier($id); } } return $keys; }
[ "public", "function", "allocateIds", "(", "array", "$", "keys", ",", "array", "$", "options", "=", "[", "]", ")", "{", "// Validate the given keys. First check types, then state of each.", "// The API will throw a 400 if the key is named, but it's an easy", "// check we can handle before going to the API to save a request.", "// @todo replace with json schema", "$", "this", "->", "validateBatch", "(", "$", "keys", ",", "Key", "::", "class", ",", "function", "(", "$", "key", ")", "{", "if", "(", "$", "key", "->", "state", "(", ")", "!==", "Key", "::", "STATE_INCOMPLETE", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "sprintf", "(", "'Given $key is in an invalid state. Can only allocate IDs for incomplete keys. '", ".", "'Given path was %s'", ",", "(", "string", ")", "$", "key", ")", ")", ";", "}", "}", ")", ";", "$", "serviceKeys", "=", "[", "]", ";", "foreach", "(", "$", "keys", "as", "$", "key", ")", "{", "$", "serviceKeys", "[", "]", "=", "$", "key", "->", "keyObject", "(", ")", ";", "}", "$", "res", "=", "$", "this", "->", "connection", "->", "allocateIds", "(", "[", "'projectId'", "=>", "$", "this", "->", "projectId", ",", "'keys'", "=>", "$", "serviceKeys", "]", "+", "$", "options", ")", ";", "if", "(", "isset", "(", "$", "res", "[", "'keys'", "]", ")", ")", "{", "foreach", "(", "$", "res", "[", "'keys'", "]", "as", "$", "index", "=>", "$", "key", ")", "{", "if", "(", "!", "isset", "(", "$", "keys", "[", "$", "index", "]", ")", ")", "{", "continue", ";", "}", "$", "end", "=", "end", "(", "$", "key", "[", "'path'", "]", ")", ";", "$", "id", "=", "$", "end", "[", "'id'", "]", ";", "$", "keys", "[", "$", "index", "]", "->", "setLastElementIdentifier", "(", "$", "id", ")", ";", "}", "}", "return", "$", "keys", ";", "}" ]
Allocate available IDs to a set of keys Keys MUST be in an incomplete state (i.e. including a kind but not an ID or name in their final pathElement). This method will execute a service request. @see https://cloud.google.com/datastore/reference/rest/v1/projects/allocateIds allocateIds @param Key[] $keys The incomplete keys. @param array $options [optional] Configuration Options. @return Key[] @throws InvalidArgumentException
[ "Allocate", "available", "IDs", "to", "a", "set", "of", "keys" ]
ff5030ffa1f12904565509a7bc24ecc0bd794a3e
https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Datastore/src/Operation.php#L279-L318
train
googleapis/google-cloud-php
Datastore/src/Operation.php
Operation.lookup
public function lookup(array $keys, array $options = []) { $options += [ 'className' => Entity::class, 'sort' => false ]; $serviceKeys = []; $this->validateBatch($keys, Key::class, function ($key) use (&$serviceKeys) { if ($key->state() !== Key::STATE_NAMED) { throw new \InvalidArgumentException(sprintf( 'Given $key is in an invalid state. Can only lookup records when given a complete key. ' . 'Given path was %s', (string) $key )); } $serviceKeys[] = $key->keyObject(); }); $res = $this->connection->lookup($options + $this->readOptions($options) + [ 'projectId' => $this->projectId, 'keys' => $serviceKeys ]); $result = []; if (isset($res['found'])) { foreach ($res['found'] as $found) { $result['found'][] = $this->mapEntityResult($found, $options['className']); } if ($options['sort']) { $result['found'] = $this->sortEntities($result['found'], $keys); } } if (isset($res['missing'])) { $result['missing'] = []; foreach ($res['missing'] as $missing) { $key = $this->key( $missing['entity']['key']['path'], $missing['entity']['key']['partitionId'] ); $result['missing'][] = $key; } } if (isset($res['deferred'])) { $result['deferred'] = []; foreach ($res['deferred'] as $deferred) { $key = $this->key( $deferred['path'], $deferred['partitionId'] ); $result['deferred'][] = $key; } } return $result; }
php
public function lookup(array $keys, array $options = []) { $options += [ 'className' => Entity::class, 'sort' => false ]; $serviceKeys = []; $this->validateBatch($keys, Key::class, function ($key) use (&$serviceKeys) { if ($key->state() !== Key::STATE_NAMED) { throw new \InvalidArgumentException(sprintf( 'Given $key is in an invalid state. Can only lookup records when given a complete key. ' . 'Given path was %s', (string) $key )); } $serviceKeys[] = $key->keyObject(); }); $res = $this->connection->lookup($options + $this->readOptions($options) + [ 'projectId' => $this->projectId, 'keys' => $serviceKeys ]); $result = []; if (isset($res['found'])) { foreach ($res['found'] as $found) { $result['found'][] = $this->mapEntityResult($found, $options['className']); } if ($options['sort']) { $result['found'] = $this->sortEntities($result['found'], $keys); } } if (isset($res['missing'])) { $result['missing'] = []; foreach ($res['missing'] as $missing) { $key = $this->key( $missing['entity']['key']['path'], $missing['entity']['key']['partitionId'] ); $result['missing'][] = $key; } } if (isset($res['deferred'])) { $result['deferred'] = []; foreach ($res['deferred'] as $deferred) { $key = $this->key( $deferred['path'], $deferred['partitionId'] ); $result['deferred'][] = $key; } } return $result; }
[ "public", "function", "lookup", "(", "array", "$", "keys", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "options", "+=", "[", "'className'", "=>", "Entity", "::", "class", ",", "'sort'", "=>", "false", "]", ";", "$", "serviceKeys", "=", "[", "]", ";", "$", "this", "->", "validateBatch", "(", "$", "keys", ",", "Key", "::", "class", ",", "function", "(", "$", "key", ")", "use", "(", "&", "$", "serviceKeys", ")", "{", "if", "(", "$", "key", "->", "state", "(", ")", "!==", "Key", "::", "STATE_NAMED", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "sprintf", "(", "'Given $key is in an invalid state. Can only lookup records when given a complete key. '", ".", "'Given path was %s'", ",", "(", "string", ")", "$", "key", ")", ")", ";", "}", "$", "serviceKeys", "[", "]", "=", "$", "key", "->", "keyObject", "(", ")", ";", "}", ")", ";", "$", "res", "=", "$", "this", "->", "connection", "->", "lookup", "(", "$", "options", "+", "$", "this", "->", "readOptions", "(", "$", "options", ")", "+", "[", "'projectId'", "=>", "$", "this", "->", "projectId", ",", "'keys'", "=>", "$", "serviceKeys", "]", ")", ";", "$", "result", "=", "[", "]", ";", "if", "(", "isset", "(", "$", "res", "[", "'found'", "]", ")", ")", "{", "foreach", "(", "$", "res", "[", "'found'", "]", "as", "$", "found", ")", "{", "$", "result", "[", "'found'", "]", "[", "]", "=", "$", "this", "->", "mapEntityResult", "(", "$", "found", ",", "$", "options", "[", "'className'", "]", ")", ";", "}", "if", "(", "$", "options", "[", "'sort'", "]", ")", "{", "$", "result", "[", "'found'", "]", "=", "$", "this", "->", "sortEntities", "(", "$", "result", "[", "'found'", "]", ",", "$", "keys", ")", ";", "}", "}", "if", "(", "isset", "(", "$", "res", "[", "'missing'", "]", ")", ")", "{", "$", "result", "[", "'missing'", "]", "=", "[", "]", ";", "foreach", "(", "$", "res", "[", "'missing'", "]", "as", "$", "missing", ")", "{", "$", "key", "=", "$", "this", "->", "key", "(", "$", "missing", "[", "'entity'", "]", "[", "'key'", "]", "[", "'path'", "]", ",", "$", "missing", "[", "'entity'", "]", "[", "'key'", "]", "[", "'partitionId'", "]", ")", ";", "$", "result", "[", "'missing'", "]", "[", "]", "=", "$", "key", ";", "}", "}", "if", "(", "isset", "(", "$", "res", "[", "'deferred'", "]", ")", ")", "{", "$", "result", "[", "'deferred'", "]", "=", "[", "]", ";", "foreach", "(", "$", "res", "[", "'deferred'", "]", "as", "$", "deferred", ")", "{", "$", "key", "=", "$", "this", "->", "key", "(", "$", "deferred", "[", "'path'", "]", ",", "$", "deferred", "[", "'partitionId'", "]", ")", ";", "$", "result", "[", "'deferred'", "]", "[", "]", "=", "$", "key", ";", "}", "}", "return", "$", "result", ";", "}" ]
Lookup records by key @param Key[] $keys The identifiers to look up. @param array $options [optional] { Configuration Options @type string $readConsistency See [ReadConsistency](https://cloud.google.com/datastore/reference/rest/v1/ReadOptions#ReadConsistency). @type string $transaction The transaction ID, if the query should be run in a transaction. @type string|array $className If a string, the given class will be returned. Value must be the name of a class implementing {@see Google\Cloud\Datastore\EntityInterface}. If an array is given, it must be an associative array, where the key is a Kind and the value must implement {@see Google\Cloud\Datastore\EntityInterface}. **Defaults to** {@see Google\Cloud\Datastore\Entity}. @type bool $sort If set to true, results in each set will be sorted to match the order given in $keys. **Defaults to** `false`. } @return array Returns an array with keys [`found`, `missing`, and `deferred`]. Members of `found` will be instance of {@see Google\Cloud\Datastore\Entity}. Members of `missing` and `deferred` will be instance of {@see Google\Cloud\Datastore\Key}. @throws InvalidArgumentException
[ "Lookup", "records", "by", "key" ]
ff5030ffa1f12904565509a7bc24ecc0bd794a3e
https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Datastore/src/Operation.php#L347-L408
train
googleapis/google-cloud-php
Datastore/src/Operation.php
Operation.runQuery
public function runQuery(QueryInterface $query, array $options = []) { $options += [ 'className' => Entity::class, 'namespaceId' => $this->namespaceId ]; $iteratorConfig = [ 'itemsKey' => 'batch.entityResults', 'resultTokenKey' => 'query.startCursor', 'nextResultTokenKey' => 'batch.endCursor', 'setNextResultTokenCondition' => function ($res) use ($query) { if (isset($res['batch']['moreResults'])) { $moreResultsType = $res['batch']['moreResults']; // Transform gRPC enum to string if (is_numeric($moreResultsType)) { $moreResultsType = MoreResultsType::name($moreResultsType); } return $query->canPaginate() && $moreResultsType === 'NOT_FINISHED'; } return false; } ]; $runQueryObj = clone $query; $runQueryFn = function (array $args = []) use (&$runQueryObj, $options) { $args += [ 'query' => [] ]; // The iterator provides the startCursor for subsequent pages as an argument. $requestQueryArr = $args['query'] + $runQueryObj->queryObject(); $request = [ 'projectId' => $this->projectId, 'partitionId' => $this->partitionId($this->projectId, $options['namespaceId']), $runQueryObj->queryKey() => $requestQueryArr ] + $this->readOptions($options) + $options; $res = $this->connection->runQuery($request); // When executing a GQL Query, the server will compute a query object // and return it with the first response batch. // Automatic pagination with GQL is accomplished by requesting // subsequent pages with this query object, and discarding the GQL // query. This is done by replacing the GQL object with a Query // instance prior to the next iteration of the page. if (isset($res['query'])) { $runQueryObj = new Query($this->entityMapper, $res['query']); } return $res; }; return new EntityIterator( new EntityPageIterator( function (array $entityResult) use ($options) { return $this->mapEntityResult($entityResult, $options['className']); }, $runQueryFn, [], $iteratorConfig ) ); }
php
public function runQuery(QueryInterface $query, array $options = []) { $options += [ 'className' => Entity::class, 'namespaceId' => $this->namespaceId ]; $iteratorConfig = [ 'itemsKey' => 'batch.entityResults', 'resultTokenKey' => 'query.startCursor', 'nextResultTokenKey' => 'batch.endCursor', 'setNextResultTokenCondition' => function ($res) use ($query) { if (isset($res['batch']['moreResults'])) { $moreResultsType = $res['batch']['moreResults']; // Transform gRPC enum to string if (is_numeric($moreResultsType)) { $moreResultsType = MoreResultsType::name($moreResultsType); } return $query->canPaginate() && $moreResultsType === 'NOT_FINISHED'; } return false; } ]; $runQueryObj = clone $query; $runQueryFn = function (array $args = []) use (&$runQueryObj, $options) { $args += [ 'query' => [] ]; // The iterator provides the startCursor for subsequent pages as an argument. $requestQueryArr = $args['query'] + $runQueryObj->queryObject(); $request = [ 'projectId' => $this->projectId, 'partitionId' => $this->partitionId($this->projectId, $options['namespaceId']), $runQueryObj->queryKey() => $requestQueryArr ] + $this->readOptions($options) + $options; $res = $this->connection->runQuery($request); // When executing a GQL Query, the server will compute a query object // and return it with the first response batch. // Automatic pagination with GQL is accomplished by requesting // subsequent pages with this query object, and discarding the GQL // query. This is done by replacing the GQL object with a Query // instance prior to the next iteration of the page. if (isset($res['query'])) { $runQueryObj = new Query($this->entityMapper, $res['query']); } return $res; }; return new EntityIterator( new EntityPageIterator( function (array $entityResult) use ($options) { return $this->mapEntityResult($entityResult, $options['className']); }, $runQueryFn, [], $iteratorConfig ) ); }
[ "public", "function", "runQuery", "(", "QueryInterface", "$", "query", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "options", "+=", "[", "'className'", "=>", "Entity", "::", "class", ",", "'namespaceId'", "=>", "$", "this", "->", "namespaceId", "]", ";", "$", "iteratorConfig", "=", "[", "'itemsKey'", "=>", "'batch.entityResults'", ",", "'resultTokenKey'", "=>", "'query.startCursor'", ",", "'nextResultTokenKey'", "=>", "'batch.endCursor'", ",", "'setNextResultTokenCondition'", "=>", "function", "(", "$", "res", ")", "use", "(", "$", "query", ")", "{", "if", "(", "isset", "(", "$", "res", "[", "'batch'", "]", "[", "'moreResults'", "]", ")", ")", "{", "$", "moreResultsType", "=", "$", "res", "[", "'batch'", "]", "[", "'moreResults'", "]", ";", "// Transform gRPC enum to string", "if", "(", "is_numeric", "(", "$", "moreResultsType", ")", ")", "{", "$", "moreResultsType", "=", "MoreResultsType", "::", "name", "(", "$", "moreResultsType", ")", ";", "}", "return", "$", "query", "->", "canPaginate", "(", ")", "&&", "$", "moreResultsType", "===", "'NOT_FINISHED'", ";", "}", "return", "false", ";", "}", "]", ";", "$", "runQueryObj", "=", "clone", "$", "query", ";", "$", "runQueryFn", "=", "function", "(", "array", "$", "args", "=", "[", "]", ")", "use", "(", "&", "$", "runQueryObj", ",", "$", "options", ")", "{", "$", "args", "+=", "[", "'query'", "=>", "[", "]", "]", ";", "// The iterator provides the startCursor for subsequent pages as an argument.", "$", "requestQueryArr", "=", "$", "args", "[", "'query'", "]", "+", "$", "runQueryObj", "->", "queryObject", "(", ")", ";", "$", "request", "=", "[", "'projectId'", "=>", "$", "this", "->", "projectId", ",", "'partitionId'", "=>", "$", "this", "->", "partitionId", "(", "$", "this", "->", "projectId", ",", "$", "options", "[", "'namespaceId'", "]", ")", ",", "$", "runQueryObj", "->", "queryKey", "(", ")", "=>", "$", "requestQueryArr", "]", "+", "$", "this", "->", "readOptions", "(", "$", "options", ")", "+", "$", "options", ";", "$", "res", "=", "$", "this", "->", "connection", "->", "runQuery", "(", "$", "request", ")", ";", "// When executing a GQL Query, the server will compute a query object", "// and return it with the first response batch.", "// Automatic pagination with GQL is accomplished by requesting", "// subsequent pages with this query object, and discarding the GQL", "// query. This is done by replacing the GQL object with a Query", "// instance prior to the next iteration of the page.", "if", "(", "isset", "(", "$", "res", "[", "'query'", "]", ")", ")", "{", "$", "runQueryObj", "=", "new", "Query", "(", "$", "this", "->", "entityMapper", ",", "$", "res", "[", "'query'", "]", ")", ";", "}", "return", "$", "res", ";", "}", ";", "return", "new", "EntityIterator", "(", "new", "EntityPageIterator", "(", "function", "(", "array", "$", "entityResult", ")", "use", "(", "$", "options", ")", "{", "return", "$", "this", "->", "mapEntityResult", "(", "$", "entityResult", ",", "$", "options", "[", "'className'", "]", ")", ";", "}", ",", "$", "runQueryFn", ",", "[", "]", ",", "$", "iteratorConfig", ")", ")", ";", "}" ]
Run a query and return entities @param QueryInterface $query The query object. @param array $options [optional] { Configuration Options @type string $transaction The transaction ID, if the query should be run in a transaction. @type string $className If set, the given class will be returned. Value must be the name of a class implementing {@see Google\Cloud\Datastore\EntityInterface}. **Defaults to** {@see Google\Cloud\Datastore\Entity}. @type string $readConsistency See [ReadConsistency](https://cloud.google.com/datastore/reference/rest/v1/ReadOptions#ReadConsistency). } @return EntityIterator<EntityInterface>
[ "Run", "a", "query", "and", "return", "entities" ]
ff5030ffa1f12904565509a7bc24ecc0bd794a3e
https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Datastore/src/Operation.php#L428-L493
train
googleapis/google-cloud-php
Datastore/src/Operation.php
Operation.commit
public function commit(array $mutations, array $options = []) { $options += [ 'transaction' => null ]; $res = $this->connection->commit($options + [ 'mode' => ($options['transaction']) ? 'TRANSACTIONAL' : 'NON_TRANSACTIONAL', 'mutations' => $mutations, 'projectId' => $this->projectId ]); return $res; }
php
public function commit(array $mutations, array $options = []) { $options += [ 'transaction' => null ]; $res = $this->connection->commit($options + [ 'mode' => ($options['transaction']) ? 'TRANSACTIONAL' : 'NON_TRANSACTIONAL', 'mutations' => $mutations, 'projectId' => $this->projectId ]); return $res; }
[ "public", "function", "commit", "(", "array", "$", "mutations", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "options", "+=", "[", "'transaction'", "=>", "null", "]", ";", "$", "res", "=", "$", "this", "->", "connection", "->", "commit", "(", "$", "options", "+", "[", "'mode'", "=>", "(", "$", "options", "[", "'transaction'", "]", ")", "?", "'TRANSACTIONAL'", ":", "'NON_TRANSACTIONAL'", ",", "'mutations'", "=>", "$", "mutations", ",", "'projectId'", "=>", "$", "this", "->", "projectId", "]", ")", ";", "return", "$", "res", ";", "}" ]
Commit all mutations Calling this method will end the operation (and close the transaction, if one is specified). @codingStandardsIgnoreStart @param array $mutations [Mutation[]](https://cloud.google.com/datastore/docs/reference/rest/v1/projects/commit#Mutation). @param array $options [optional] { Configuration Options @type string $transaction The transaction ID, if the query should be run in a transaction. } @return array [Response Body](https://cloud.google.com/datastore/reference/rest/v1/projects/commit#response-body) @codingStandardsIgnoreEnd
[ "Commit", "all", "mutations" ]
ff5030ffa1f12904565509a7bc24ecc0bd794a3e
https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Datastore/src/Operation.php#L512-L525
train
googleapis/google-cloud-php
Datastore/src/Operation.php
Operation.allocateIdsToEntities
public function allocateIdsToEntities(array $entities) { $this->validateBatch($entities, EntityInterface::class); $incompleteKeys = []; foreach ($entities as $entity) { if ($entity->key()->state() === Key::STATE_INCOMPLETE) { $incompleteKeys[] = $entity->key(); } } if (!empty($incompleteKeys)) { $keys = $this->allocateIds($incompleteKeys); } return $entities; }
php
public function allocateIdsToEntities(array $entities) { $this->validateBatch($entities, EntityInterface::class); $incompleteKeys = []; foreach ($entities as $entity) { if ($entity->key()->state() === Key::STATE_INCOMPLETE) { $incompleteKeys[] = $entity->key(); } } if (!empty($incompleteKeys)) { $keys = $this->allocateIds($incompleteKeys); } return $entities; }
[ "public", "function", "allocateIdsToEntities", "(", "array", "$", "entities", ")", "{", "$", "this", "->", "validateBatch", "(", "$", "entities", ",", "EntityInterface", "::", "class", ")", ";", "$", "incompleteKeys", "=", "[", "]", ";", "foreach", "(", "$", "entities", "as", "$", "entity", ")", "{", "if", "(", "$", "entity", "->", "key", "(", ")", "->", "state", "(", ")", "===", "Key", "::", "STATE_INCOMPLETE", ")", "{", "$", "incompleteKeys", "[", "]", "=", "$", "entity", "->", "key", "(", ")", ";", "}", "}", "if", "(", "!", "empty", "(", "$", "incompleteKeys", ")", ")", "{", "$", "keys", "=", "$", "this", "->", "allocateIds", "(", "$", "incompleteKeys", ")", ";", "}", "return", "$", "entities", ";", "}" ]
Patch any incomplete keys in the given array of entities Any incomplete keys will be allocated an ID. Named keys in the input will remain unchanged. @param EntityInterface[] $entities A list of entities @return EntityInterface[]
[ "Patch", "any", "incomplete", "keys", "in", "the", "given", "array", "of", "entities" ]
ff5030ffa1f12904565509a7bc24ecc0bd794a3e
https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Datastore/src/Operation.php#L536-L552
train
googleapis/google-cloud-php
Datastore/src/Operation.php
Operation.mutation
public function mutation( $operation, $input, $type, $baseVersion = null ) { // If the given element is an EntityInterface, it will use that baseVersion. if ($input instanceof EntityInterface) { $baseVersion = $input->baseVersion(); $data = $this->entityMapper->objectToRequest($input); if (!$input->key()) { throw new \InvalidArgumentException('Base entities must provide a datastore key.'); } } elseif ($input instanceof Key) { $data = $input->keyObject(); } else { throw new \InvalidArgumentException(sprintf( 'Input must be a Key or Entity, %s given', get_class($input) )); } return array_filter([ $operation => $data, 'baseVersion' => $baseVersion ]); }
php
public function mutation( $operation, $input, $type, $baseVersion = null ) { // If the given element is an EntityInterface, it will use that baseVersion. if ($input instanceof EntityInterface) { $baseVersion = $input->baseVersion(); $data = $this->entityMapper->objectToRequest($input); if (!$input->key()) { throw new \InvalidArgumentException('Base entities must provide a datastore key.'); } } elseif ($input instanceof Key) { $data = $input->keyObject(); } else { throw new \InvalidArgumentException(sprintf( 'Input must be a Key or Entity, %s given', get_class($input) )); } return array_filter([ $operation => $data, 'baseVersion' => $baseVersion ]); }
[ "public", "function", "mutation", "(", "$", "operation", ",", "$", "input", ",", "$", "type", ",", "$", "baseVersion", "=", "null", ")", "{", "// If the given element is an EntityInterface, it will use that baseVersion.", "if", "(", "$", "input", "instanceof", "EntityInterface", ")", "{", "$", "baseVersion", "=", "$", "input", "->", "baseVersion", "(", ")", ";", "$", "data", "=", "$", "this", "->", "entityMapper", "->", "objectToRequest", "(", "$", "input", ")", ";", "if", "(", "!", "$", "input", "->", "key", "(", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'Base entities must provide a datastore key.'", ")", ";", "}", "}", "elseif", "(", "$", "input", "instanceof", "Key", ")", "{", "$", "data", "=", "$", "input", "->", "keyObject", "(", ")", ";", "}", "else", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "sprintf", "(", "'Input must be a Key or Entity, %s given'", ",", "get_class", "(", "$", "input", ")", ")", ")", ";", "}", "return", "array_filter", "(", "[", "$", "operation", "=>", "$", "data", ",", "'baseVersion'", "=>", "$", "baseVersion", "]", ")", ";", "}" ]
Enqueue a mutation A mutation is a change to the datastore. Create, Update and Delete are examples of mutations, while Read is not. Google Cloud Datastore supports multiple mutations in a single API call, subject to the limits of the service. Adding mutations separately from committing the changes allows you to create complex operations, both inside a transaction and not. @see https://cloud.google.com/datastore/docs/concepts/limits Limits @param string $operation The operation to execute. "Insert", "Upsert", "Update" or "Delete". @param EntityInterface|Key $input The entity or key to mutate. @param string $type The type of the input array. @param string $baseVersion [optional] The version of the entity that this mutation is being applied to. If this does not match the current version on the server, the mutation conflicts. @return array [Mutation](https://cloud.google.com/datastore/docs/reference/rest/v1/projects/commit#Mutation). @throws InvalidArgumentException
[ "Enqueue", "a", "mutation" ]
ff5030ffa1f12904565509a7bc24ecc0bd794a3e
https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Datastore/src/Operation.php#L577-L604
train
googleapis/google-cloud-php
Datastore/src/Operation.php
Operation.checkOverwrite
public function checkOverwrite(array $entities, $allowOverwrite = false) { $this->validateBatch($entities, EntityInterface::class); foreach ($entities as $entity) { if (!$entity->populatedByService() && !$allowOverwrite) { throw new \InvalidArgumentException(sprintf( 'Given entity cannot be saved because it may overwrite an '. 'existing record. When updating manually created entities, '. 'please set the options `$allowOverwrite` flag to `true`. '. 'Invalid entity key was %s', (string) $entity->key() )); } } }
php
public function checkOverwrite(array $entities, $allowOverwrite = false) { $this->validateBatch($entities, EntityInterface::class); foreach ($entities as $entity) { if (!$entity->populatedByService() && !$allowOverwrite) { throw new \InvalidArgumentException(sprintf( 'Given entity cannot be saved because it may overwrite an '. 'existing record. When updating manually created entities, '. 'please set the options `$allowOverwrite` flag to `true`. '. 'Invalid entity key was %s', (string) $entity->key() )); } } }
[ "public", "function", "checkOverwrite", "(", "array", "$", "entities", ",", "$", "allowOverwrite", "=", "false", ")", "{", "$", "this", "->", "validateBatch", "(", "$", "entities", ",", "EntityInterface", "::", "class", ")", ";", "foreach", "(", "$", "entities", "as", "$", "entity", ")", "{", "if", "(", "!", "$", "entity", "->", "populatedByService", "(", ")", "&&", "!", "$", "allowOverwrite", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "sprintf", "(", "'Given entity cannot be saved because it may overwrite an '", ".", "'existing record. When updating manually created entities, '", ".", "'please set the options `$allowOverwrite` flag to `true`. '", ".", "'Invalid entity key was %s'", ",", "(", "string", ")", "$", "entity", "->", "key", "(", ")", ")", ")", ";", "}", "}", "}" ]
Check whether an update or upsert operation may proceed safely @param EntityInterface[] $entities the entities to be updated or upserted. @param bool $allowOverwrite If `true`, entities may be overwritten. **Defaults to** `false`. @throws InvalidArgumentException @return void
[ "Check", "whether", "an", "update", "or", "upsert", "operation", "may", "proceed", "safely" ]
ff5030ffa1f12904565509a7bc24ecc0bd794a3e
https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Datastore/src/Operation.php#L629-L644
train
googleapis/google-cloud-php
Datastore/src/Operation.php
Operation.mapEntityResult
private function mapEntityResult(array $result, $class) { $entity = $result['entity']; $namespaceId = (isset($entity['key']['partitionId']['namespaceId'])) ? $entity['key']['partitionId']['namespaceId'] : null; $key = new Key($this->projectId, [ 'path' => $entity['key']['path'], 'namespaceId' => $namespaceId ]); if (is_array($class)) { $lastPathElement = $key->pathEnd(); if (!array_key_exists($lastPathElement['kind'], $class)) { throw new \InvalidArgumentException(sprintf( 'No class found for kind %s', $lastPathElement['kind'] )); } $className = $class[$lastPathElement['kind']]; } else { $className = $class; } $properties = []; $excludes = []; $meanings = []; if (isset($entity['properties'])) { $res = $this->entityMapper->responseToEntityProperties($entity['properties'], $className); $properties = $res['properties']; $excludes = $res['excludes']; $meanings = $res['meanings']; } return $this->entity($key, $properties, [ 'cursor' => (isset($result['cursor'])) ? $result['cursor'] : null, 'baseVersion' => (isset($result['version'])) ? $result['version'] : null, 'className' => $className, 'populatedByService' => true, 'excludeFromIndexes' => $excludes, 'meanings' => $meanings ]); }
php
private function mapEntityResult(array $result, $class) { $entity = $result['entity']; $namespaceId = (isset($entity['key']['partitionId']['namespaceId'])) ? $entity['key']['partitionId']['namespaceId'] : null; $key = new Key($this->projectId, [ 'path' => $entity['key']['path'], 'namespaceId' => $namespaceId ]); if (is_array($class)) { $lastPathElement = $key->pathEnd(); if (!array_key_exists($lastPathElement['kind'], $class)) { throw new \InvalidArgumentException(sprintf( 'No class found for kind %s', $lastPathElement['kind'] )); } $className = $class[$lastPathElement['kind']]; } else { $className = $class; } $properties = []; $excludes = []; $meanings = []; if (isset($entity['properties'])) { $res = $this->entityMapper->responseToEntityProperties($entity['properties'], $className); $properties = $res['properties']; $excludes = $res['excludes']; $meanings = $res['meanings']; } return $this->entity($key, $properties, [ 'cursor' => (isset($result['cursor'])) ? $result['cursor'] : null, 'baseVersion' => (isset($result['version'])) ? $result['version'] : null, 'className' => $className, 'populatedByService' => true, 'excludeFromIndexes' => $excludes, 'meanings' => $meanings ]); }
[ "private", "function", "mapEntityResult", "(", "array", "$", "result", ",", "$", "class", ")", "{", "$", "entity", "=", "$", "result", "[", "'entity'", "]", ";", "$", "namespaceId", "=", "(", "isset", "(", "$", "entity", "[", "'key'", "]", "[", "'partitionId'", "]", "[", "'namespaceId'", "]", ")", ")", "?", "$", "entity", "[", "'key'", "]", "[", "'partitionId'", "]", "[", "'namespaceId'", "]", ":", "null", ";", "$", "key", "=", "new", "Key", "(", "$", "this", "->", "projectId", ",", "[", "'path'", "=>", "$", "entity", "[", "'key'", "]", "[", "'path'", "]", ",", "'namespaceId'", "=>", "$", "namespaceId", "]", ")", ";", "if", "(", "is_array", "(", "$", "class", ")", ")", "{", "$", "lastPathElement", "=", "$", "key", "->", "pathEnd", "(", ")", ";", "if", "(", "!", "array_key_exists", "(", "$", "lastPathElement", "[", "'kind'", "]", ",", "$", "class", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "sprintf", "(", "'No class found for kind %s'", ",", "$", "lastPathElement", "[", "'kind'", "]", ")", ")", ";", "}", "$", "className", "=", "$", "class", "[", "$", "lastPathElement", "[", "'kind'", "]", "]", ";", "}", "else", "{", "$", "className", "=", "$", "class", ";", "}", "$", "properties", "=", "[", "]", ";", "$", "excludes", "=", "[", "]", ";", "$", "meanings", "=", "[", "]", ";", "if", "(", "isset", "(", "$", "entity", "[", "'properties'", "]", ")", ")", "{", "$", "res", "=", "$", "this", "->", "entityMapper", "->", "responseToEntityProperties", "(", "$", "entity", "[", "'properties'", "]", ",", "$", "className", ")", ";", "$", "properties", "=", "$", "res", "[", "'properties'", "]", ";", "$", "excludes", "=", "$", "res", "[", "'excludes'", "]", ";", "$", "meanings", "=", "$", "res", "[", "'meanings'", "]", ";", "}", "return", "$", "this", "->", "entity", "(", "$", "key", ",", "$", "properties", ",", "[", "'cursor'", "=>", "(", "isset", "(", "$", "result", "[", "'cursor'", "]", ")", ")", "?", "$", "result", "[", "'cursor'", "]", ":", "null", ",", "'baseVersion'", "=>", "(", "isset", "(", "$", "result", "[", "'version'", "]", ")", ")", "?", "$", "result", "[", "'version'", "]", ":", "null", ",", "'className'", "=>", "$", "className", ",", "'populatedByService'", "=>", "true", ",", "'excludeFromIndexes'", "=>", "$", "excludes", ",", "'meanings'", "=>", "$", "meanings", "]", ")", ";", "}" ]
Convert an EntityResult into an array of entities @see https://cloud.google.com/datastore/reference/rest/v1/EntityResult EntityResult @param array $result The EntityResult from a Lookup. @param string|array $class If a string, the name of the class to return results as. Must implement {@see Google\Cloud\Datastore\EntityInterface}. If not set, {@see Google\Cloud\Datastore\Entity} will be used. If an array is given, it must be an associative array, where the key is a Kind and the value is an object implementing {@see Google\Cloud\Datastore\EntityInterface}. @return EntityInterface[]
[ "Convert", "an", "EntityResult", "into", "an", "array", "of", "entities" ]
ff5030ffa1f12904565509a7bc24ecc0bd794a3e
https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Datastore/src/Operation.php#L660-L711
train
googleapis/google-cloud-php
Datastore/src/Operation.php
Operation.readOptions
private function readOptions(array $options = []) { $options += [ 'readConsistency' => null, 'transaction' => null ]; $readOptions = array_filter([ 'readConsistency' => $options['readConsistency'], 'transaction' => $options['transaction'] ]); return array_filter([ 'readOptions' => $readOptions ]); }
php
private function readOptions(array $options = []) { $options += [ 'readConsistency' => null, 'transaction' => null ]; $readOptions = array_filter([ 'readConsistency' => $options['readConsistency'], 'transaction' => $options['transaction'] ]); return array_filter([ 'readOptions' => $readOptions ]); }
[ "private", "function", "readOptions", "(", "array", "$", "options", "=", "[", "]", ")", "{", "$", "options", "+=", "[", "'readConsistency'", "=>", "null", ",", "'transaction'", "=>", "null", "]", ";", "$", "readOptions", "=", "array_filter", "(", "[", "'readConsistency'", "=>", "$", "options", "[", "'readConsistency'", "]", ",", "'transaction'", "=>", "$", "options", "[", "'transaction'", "]", "]", ")", ";", "return", "array_filter", "(", "[", "'readOptions'", "=>", "$", "readOptions", "]", ")", ";", "}" ]
Format the readOptions @param array $options [optional] { Read Options @type string $transaction If set, query or lookup will run in transaction. @type string $readConsistency See [ReadConsistency](https://cloud.google.com/datastore/reference/rest/v1/ReadOptions#ReadConsistency). } @return array
[ "Format", "the", "readOptions" ]
ff5030ffa1f12904565509a7bc24ecc0bd794a3e
https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Datastore/src/Operation.php#L725-L740
train
googleapis/google-cloud-php
Bigtable/src/Admin/V2/CreateInstanceRequest.php
CreateInstanceRequest.setInstance
public function setInstance($var) { GPBUtil::checkMessage($var, \Google\Cloud\Bigtable\Admin\V2\Instance::class); $this->instance = $var; return $this; }
php
public function setInstance($var) { GPBUtil::checkMessage($var, \Google\Cloud\Bigtable\Admin\V2\Instance::class); $this->instance = $var; return $this; }
[ "public", "function", "setInstance", "(", "$", "var", ")", "{", "GPBUtil", "::", "checkMessage", "(", "$", "var", ",", "\\", "Google", "\\", "Cloud", "\\", "Bigtable", "\\", "Admin", "\\", "V2", "\\", "Instance", "::", "class", ")", ";", "$", "this", "->", "instance", "=", "$", "var", ";", "return", "$", "this", ";", "}" ]
The instance to create. Fields marked `OutputOnly` must be left blank. Generated from protobuf field <code>.google.bigtable.admin.v2.Instance instance = 3;</code> @param \Google\Cloud\Bigtable\Admin\V2\Instance $var @return $this
[ "The", "instance", "to", "create", ".", "Fields", "marked", "OutputOnly", "must", "be", "left", "blank", "." ]
ff5030ffa1f12904565509a7bc24ecc0bd794a3e
https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Bigtable/src/Admin/V2/CreateInstanceRequest.php#L158-L164
train
googleapis/google-cloud-php
Tasks/src/V2/Task.php
Task.setLastAttempt
public function setLastAttempt($var) { GPBUtil::checkMessage($var, \Google\Cloud\Tasks\V2\Attempt::class); $this->last_attempt = $var; return $this; }
php
public function setLastAttempt($var) { GPBUtil::checkMessage($var, \Google\Cloud\Tasks\V2\Attempt::class); $this->last_attempt = $var; return $this; }
[ "public", "function", "setLastAttempt", "(", "$", "var", ")", "{", "GPBUtil", "::", "checkMessage", "(", "$", "var", ",", "\\", "Google", "\\", "Cloud", "\\", "Tasks", "\\", "V2", "\\", "Attempt", "::", "class", ")", ";", "$", "this", "->", "last_attempt", "=", "$", "var", ";", "return", "$", "this", ";", "}" ]
Output only. The status of the task's last attempt. Generated from protobuf field <code>.google.cloud.tasks.v2.Attempt last_attempt = 10;</code> @param \Google\Cloud\Tasks\V2\Attempt $var @return $this
[ "Output", "only", ".", "The", "status", "of", "the", "task", "s", "last", "attempt", "." ]
ff5030ffa1f12904565509a7bc24ecc0bd794a3e
https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Tasks/src/V2/Task.php#L522-L528
train
googleapis/google-cloud-php
Dlp/src/V2/RedactImageResponse.php
RedactImageResponse.setInspectResult
public function setInspectResult($var) { GPBUtil::checkMessage($var, \Google\Cloud\Dlp\V2\InspectResult::class); $this->inspect_result = $var; return $this; }
php
public function setInspectResult($var) { GPBUtil::checkMessage($var, \Google\Cloud\Dlp\V2\InspectResult::class); $this->inspect_result = $var; return $this; }
[ "public", "function", "setInspectResult", "(", "$", "var", ")", "{", "GPBUtil", "::", "checkMessage", "(", "$", "var", ",", "\\", "Google", "\\", "Cloud", "\\", "Dlp", "\\", "V2", "\\", "InspectResult", "::", "class", ")", ";", "$", "this", "->", "inspect_result", "=", "$", "var", ";", "return", "$", "this", ";", "}" ]
The findings. Populated when include_findings in the request is true. Generated from protobuf field <code>.google.privacy.dlp.v2.InspectResult inspect_result = 3;</code> @param \Google\Cloud\Dlp\V2\InspectResult $var @return $this
[ "The", "findings", ".", "Populated", "when", "include_findings", "in", "the", "request", "is", "true", "." ]
ff5030ffa1f12904565509a7bc24ecc0bd794a3e
https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Dlp/src/V2/RedactImageResponse.php#L134-L140
train
googleapis/google-cloud-php
AutoMl/src/V1beta1/Dataset.php
Dataset.setTranslationDatasetMetadata
public function setTranslationDatasetMetadata($var) { GPBUtil::checkMessage($var, \Google\Cloud\AutoMl\V1beta1\TranslationDatasetMetadata::class); $this->writeOneof(23, $var); return $this; }
php
public function setTranslationDatasetMetadata($var) { GPBUtil::checkMessage($var, \Google\Cloud\AutoMl\V1beta1\TranslationDatasetMetadata::class); $this->writeOneof(23, $var); return $this; }
[ "public", "function", "setTranslationDatasetMetadata", "(", "$", "var", ")", "{", "GPBUtil", "::", "checkMessage", "(", "$", "var", ",", "\\", "Google", "\\", "Cloud", "\\", "AutoMl", "\\", "V1beta1", "\\", "TranslationDatasetMetadata", "::", "class", ")", ";", "$", "this", "->", "writeOneof", "(", "23", ",", "$", "var", ")", ";", "return", "$", "this", ";", "}" ]
Metadata for a dataset used for translation. Generated from protobuf field <code>.google.cloud.automl.v1beta1.TranslationDatasetMetadata translation_dataset_metadata = 23;</code> @param \Google\Cloud\AutoMl\V1beta1\TranslationDatasetMetadata $var @return $this
[ "Metadata", "for", "a", "dataset", "used", "for", "translation", "." ]
ff5030ffa1f12904565509a7bc24ecc0bd794a3e
https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/AutoMl/src/V1beta1/Dataset.php#L98-L104
train
googleapis/google-cloud-php
AutoMl/src/V1beta1/Dataset.php
Dataset.setImageClassificationDatasetMetadata
public function setImageClassificationDatasetMetadata($var) { GPBUtil::checkMessage($var, \Google\Cloud\AutoMl\V1beta1\ImageClassificationDatasetMetadata::class); $this->writeOneof(24, $var); return $this; }
php
public function setImageClassificationDatasetMetadata($var) { GPBUtil::checkMessage($var, \Google\Cloud\AutoMl\V1beta1\ImageClassificationDatasetMetadata::class); $this->writeOneof(24, $var); return $this; }
[ "public", "function", "setImageClassificationDatasetMetadata", "(", "$", "var", ")", "{", "GPBUtil", "::", "checkMessage", "(", "$", "var", ",", "\\", "Google", "\\", "Cloud", "\\", "AutoMl", "\\", "V1beta1", "\\", "ImageClassificationDatasetMetadata", "::", "class", ")", ";", "$", "this", "->", "writeOneof", "(", "24", ",", "$", "var", ")", ";", "return", "$", "this", ";", "}" ]
Metadata for a dataset used for image classification. Generated from protobuf field <code>.google.cloud.automl.v1beta1.ImageClassificationDatasetMetadata image_classification_dataset_metadata = 24;</code> @param \Google\Cloud\AutoMl\V1beta1\ImageClassificationDatasetMetadata $var @return $this
[ "Metadata", "for", "a", "dataset", "used", "for", "image", "classification", "." ]
ff5030ffa1f12904565509a7bc24ecc0bd794a3e
https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/AutoMl/src/V1beta1/Dataset.php#L124-L130
train
googleapis/google-cloud-php
AutoMl/src/V1beta1/Dataset.php
Dataset.setTextClassificationDatasetMetadata
public function setTextClassificationDatasetMetadata($var) { GPBUtil::checkMessage($var, \Google\Cloud\AutoMl\V1beta1\TextClassificationDatasetMetadata::class); $this->writeOneof(25, $var); return $this; }
php
public function setTextClassificationDatasetMetadata($var) { GPBUtil::checkMessage($var, \Google\Cloud\AutoMl\V1beta1\TextClassificationDatasetMetadata::class); $this->writeOneof(25, $var); return $this; }
[ "public", "function", "setTextClassificationDatasetMetadata", "(", "$", "var", ")", "{", "GPBUtil", "::", "checkMessage", "(", "$", "var", ",", "\\", "Google", "\\", "Cloud", "\\", "AutoMl", "\\", "V1beta1", "\\", "TextClassificationDatasetMetadata", "::", "class", ")", ";", "$", "this", "->", "writeOneof", "(", "25", ",", "$", "var", ")", ";", "return", "$", "this", ";", "}" ]
Metadata for a dataset used for text classification. Generated from protobuf field <code>.google.cloud.automl.v1beta1.TextClassificationDatasetMetadata text_classification_dataset_metadata = 25;</code> @param \Google\Cloud\AutoMl\V1beta1\TextClassificationDatasetMetadata $var @return $this
[ "Metadata", "for", "a", "dataset", "used", "for", "text", "classification", "." ]
ff5030ffa1f12904565509a7bc24ecc0bd794a3e
https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/AutoMl/src/V1beta1/Dataset.php#L150-L156
train
googleapis/google-cloud-php
Dataproc/src/V1beta2/Job.php
Job.setSparkSqlJob
public function setSparkSqlJob($var) { GPBUtil::checkMessage($var, \Google\Cloud\Dataproc\V1beta2\SparkSqlJob::class); $this->writeOneof(12, $var); return $this; }
php
public function setSparkSqlJob($var) { GPBUtil::checkMessage($var, \Google\Cloud\Dataproc\V1beta2\SparkSqlJob::class); $this->writeOneof(12, $var); return $this; }
[ "public", "function", "setSparkSqlJob", "(", "$", "var", ")", "{", "GPBUtil", "::", "checkMessage", "(", "$", "var", ",", "\\", "Google", "\\", "Cloud", "\\", "Dataproc", "\\", "V1beta2", "\\", "SparkSqlJob", "::", "class", ")", ";", "$", "this", "->", "writeOneof", "(", "12", ",", "$", "var", ")", ";", "return", "$", "this", ";", "}" ]
Job is a SparkSql job. Generated from protobuf field <code>.google.cloud.dataproc.v1beta2.SparkSqlJob spark_sql_job = 12;</code> @param \Google\Cloud\Dataproc\V1beta2\SparkSqlJob $var @return $this
[ "Job", "is", "a", "SparkSql", "job", "." ]
ff5030ffa1f12904565509a7bc24ecc0bd794a3e
https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Dataproc/src/V1beta2/Job.php#L381-L387
train
googleapis/google-cloud-php
Dataproc/src/V1beta2/Job.php
Job.setStatusHistory
public function setStatusHistory($var) { $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Dataproc\V1beta2\JobStatus::class); $this->status_history = $arr; return $this; }
php
public function setStatusHistory($var) { $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Dataproc\V1beta2\JobStatus::class); $this->status_history = $arr; return $this; }
[ "public", "function", "setStatusHistory", "(", "$", "var", ")", "{", "$", "arr", "=", "GPBUtil", "::", "checkRepeatedField", "(", "$", "var", ",", "\\", "Google", "\\", "Protobuf", "\\", "Internal", "\\", "GPBType", "::", "MESSAGE", ",", "\\", "Google", "\\", "Cloud", "\\", "Dataproc", "\\", "V1beta2", "\\", "JobStatus", "::", "class", ")", ";", "$", "this", "->", "status_history", "=", "$", "arr", ";", "return", "$", "this", ";", "}" ]
Output only. The previous job status. Generated from protobuf field <code>repeated .google.cloud.dataproc.v1beta2.JobStatus status_history = 13;</code> @param \Google\Cloud\Dataproc\V1beta2\JobStatus[]|\Google\Protobuf\Internal\RepeatedField $var @return $this
[ "Output", "only", ".", "The", "previous", "job", "status", "." ]
ff5030ffa1f12904565509a7bc24ecc0bd794a3e
https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Dataproc/src/V1beta2/Job.php#L437-L443
train
googleapis/google-cloud-php
ErrorReporting/src/Bootstrap.php
Bootstrap.init
public static function init(PsrLogger $psrLogger = null) { self::$psrLogger = $psrLogger ?: (new LoggingClient()) ->psrLogger(self::DEFAULT_LOGNAME, [ 'batchEnabled' => true, 'debugOutput' => true, 'batchOptions' => [ 'numWorkers' => 2 ] ]); register_shutdown_function([self::class, 'shutdownHandler']); set_exception_handler([self::class, 'exceptionHandler']); set_error_handler([self::class, 'errorHandler']); }
php
public static function init(PsrLogger $psrLogger = null) { self::$psrLogger = $psrLogger ?: (new LoggingClient()) ->psrLogger(self::DEFAULT_LOGNAME, [ 'batchEnabled' => true, 'debugOutput' => true, 'batchOptions' => [ 'numWorkers' => 2 ] ]); register_shutdown_function([self::class, 'shutdownHandler']); set_exception_handler([self::class, 'exceptionHandler']); set_error_handler([self::class, 'errorHandler']); }
[ "public", "static", "function", "init", "(", "PsrLogger", "$", "psrLogger", "=", "null", ")", "{", "self", "::", "$", "psrLogger", "=", "$", "psrLogger", "?", ":", "(", "new", "LoggingClient", "(", ")", ")", "->", "psrLogger", "(", "self", "::", "DEFAULT_LOGNAME", ",", "[", "'batchEnabled'", "=>", "true", ",", "'debugOutput'", "=>", "true", ",", "'batchOptions'", "=>", "[", "'numWorkers'", "=>", "2", "]", "]", ")", ";", "register_shutdown_function", "(", "[", "self", "::", "class", ",", "'shutdownHandler'", "]", ")", ";", "set_exception_handler", "(", "[", "self", "::", "class", ",", "'exceptionHandler'", "]", ")", ";", "set_error_handler", "(", "[", "self", "::", "class", ",", "'errorHandler'", "]", ")", ";", "}" ]
Register hooks for error reporting. @param PsrLogger $psrLogger @return void @codeCoverageIgnore
[ "Register", "hooks", "for", "error", "reporting", "." ]
ff5030ffa1f12904565509a7bc24ecc0bd794a3e
https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/ErrorReporting/src/Bootstrap.php#L36-L49
train
googleapis/google-cloud-php
ErrorReporting/src/Bootstrap.php
Bootstrap.getErrorPrefix
public static function getErrorPrefix($level) { switch ($level) { case E_PARSE: $prefix = 'PHP Parse error'; break; case E_ERROR: case E_CORE_ERROR: case E_COMPILE_ERROR: $prefix = 'PHP Fatal error'; break; case E_USER_ERROR: case E_RECOVERABLE_ERROR: $prefix = 'PHP error'; break; case E_WARNING: case E_CORE_WARNING: case E_COMPILE_WARNING: case E_USER_WARNING: $prefix = 'PHP Warning'; break; case E_NOTICE: case E_USER_NOTICE: $prefix = 'PHP Notice'; break; case E_STRICT: $prefix = 'PHP Debug'; break; default: $prefix = 'PHP Notice'; } return $prefix; }
php
public static function getErrorPrefix($level) { switch ($level) { case E_PARSE: $prefix = 'PHP Parse error'; break; case E_ERROR: case E_CORE_ERROR: case E_COMPILE_ERROR: $prefix = 'PHP Fatal error'; break; case E_USER_ERROR: case E_RECOVERABLE_ERROR: $prefix = 'PHP error'; break; case E_WARNING: case E_CORE_WARNING: case E_COMPILE_WARNING: case E_USER_WARNING: $prefix = 'PHP Warning'; break; case E_NOTICE: case E_USER_NOTICE: $prefix = 'PHP Notice'; break; case E_STRICT: $prefix = 'PHP Debug'; break; default: $prefix = 'PHP Notice'; } return $prefix; }
[ "public", "static", "function", "getErrorPrefix", "(", "$", "level", ")", "{", "switch", "(", "$", "level", ")", "{", "case", "E_PARSE", ":", "$", "prefix", "=", "'PHP Parse error'", ";", "break", ";", "case", "E_ERROR", ":", "case", "E_CORE_ERROR", ":", "case", "E_COMPILE_ERROR", ":", "$", "prefix", "=", "'PHP Fatal error'", ";", "break", ";", "case", "E_USER_ERROR", ":", "case", "E_RECOVERABLE_ERROR", ":", "$", "prefix", "=", "'PHP error'", ";", "break", ";", "case", "E_WARNING", ":", "case", "E_CORE_WARNING", ":", "case", "E_COMPILE_WARNING", ":", "case", "E_USER_WARNING", ":", "$", "prefix", "=", "'PHP Warning'", ";", "break", ";", "case", "E_NOTICE", ":", "case", "E_USER_NOTICE", ":", "$", "prefix", "=", "'PHP Notice'", ";", "break", ";", "case", "E_STRICT", ":", "$", "prefix", "=", "'PHP Debug'", ";", "break", ";", "default", ":", "$", "prefix", "=", "'PHP Notice'", ";", "}", "return", "$", "prefix", ";", "}" ]
Return a string prefix for the given error level. @param int $level @return string A string prefix for reporting the error.
[ "Return", "a", "string", "prefix", "for", "the", "given", "error", "level", "." ]
ff5030ffa1f12904565509a7bc24ecc0bd794a3e
https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/ErrorReporting/src/Bootstrap.php#L57-L89
train
googleapis/google-cloud-php
ErrorReporting/src/Bootstrap.php
Bootstrap.getErrorLevelString
public static function getErrorLevelString($level) { switch ($level) { case E_PARSE: return 'CRITICAL'; case E_ERROR: case E_CORE_ERROR: case E_COMPILE_ERROR: case E_USER_ERROR: case E_RECOVERABLE_ERROR: return 'ERROR'; case E_WARNING: case E_CORE_WARNING: case E_COMPILE_WARNING: case E_USER_WARNING: return 'WARNING'; case E_NOTICE: case E_USER_NOTICE: return 'NOTICE'; case E_STRICT: return 'DEBUG'; default: return 'NOTICE'; } }
php
public static function getErrorLevelString($level) { switch ($level) { case E_PARSE: return 'CRITICAL'; case E_ERROR: case E_CORE_ERROR: case E_COMPILE_ERROR: case E_USER_ERROR: case E_RECOVERABLE_ERROR: return 'ERROR'; case E_WARNING: case E_CORE_WARNING: case E_COMPILE_WARNING: case E_USER_WARNING: return 'WARNING'; case E_NOTICE: case E_USER_NOTICE: return 'NOTICE'; case E_STRICT: return 'DEBUG'; default: return 'NOTICE'; } }
[ "public", "static", "function", "getErrorLevelString", "(", "$", "level", ")", "{", "switch", "(", "$", "level", ")", "{", "case", "E_PARSE", ":", "return", "'CRITICAL'", ";", "case", "E_ERROR", ":", "case", "E_CORE_ERROR", ":", "case", "E_COMPILE_ERROR", ":", "case", "E_USER_ERROR", ":", "case", "E_RECOVERABLE_ERROR", ":", "return", "'ERROR'", ";", "case", "E_WARNING", ":", "case", "E_CORE_WARNING", ":", "case", "E_COMPILE_WARNING", ":", "case", "E_USER_WARNING", ":", "return", "'WARNING'", ";", "case", "E_NOTICE", ":", "case", "E_USER_NOTICE", ":", "return", "'NOTICE'", ";", "case", "E_STRICT", ":", "return", "'DEBUG'", ";", "default", ":", "return", "'NOTICE'", ";", "}", "}" ]
Return an error level string for the given PHP error level. @param int $level @return string An error level string.
[ "Return", "an", "error", "level", "string", "for", "the", "given", "PHP", "error", "level", "." ]
ff5030ffa1f12904565509a7bc24ecc0bd794a3e
https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/ErrorReporting/src/Bootstrap.php#L97-L121
train
googleapis/google-cloud-php
ErrorReporting/src/Bootstrap.php
Bootstrap.shutdownHandler
public static function shutdownHandler() { if ($err = error_get_last()) { switch ($err['type']) { case E_ERROR: case E_PARSE: case E_COMPILE_ERROR: case E_CORE_ERROR: $service = self::$psrLogger ->getMetadataProvider() ->serviceId(); $version = self::$psrLogger ->getMetadataProvider() ->versionId(); $message = sprintf( '%s: %s in %s on line %d', self::getErrorPrefix($err['type']), $err['message'], $err['file'], $err['line'] ); $context = [ 'context' => [ 'reportLocation' => [ 'filePath' => $err['file'], 'lineNumber' => $err['line'], 'functionName' => self::getFunctionNameForReport(), ] ], 'serviceContext' => [ 'service' => $service, 'version' => $version ] ]; if (self::$psrLogger) { self::$psrLogger->log( self::getErrorLevelString($err['type']), $message, $context ); } break; } } }
php
public static function shutdownHandler() { if ($err = error_get_last()) { switch ($err['type']) { case E_ERROR: case E_PARSE: case E_COMPILE_ERROR: case E_CORE_ERROR: $service = self::$psrLogger ->getMetadataProvider() ->serviceId(); $version = self::$psrLogger ->getMetadataProvider() ->versionId(); $message = sprintf( '%s: %s in %s on line %d', self::getErrorPrefix($err['type']), $err['message'], $err['file'], $err['line'] ); $context = [ 'context' => [ 'reportLocation' => [ 'filePath' => $err['file'], 'lineNumber' => $err['line'], 'functionName' => self::getFunctionNameForReport(), ] ], 'serviceContext' => [ 'service' => $service, 'version' => $version ] ]; if (self::$psrLogger) { self::$psrLogger->log( self::getErrorLevelString($err['type']), $message, $context ); } break; } } }
[ "public", "static", "function", "shutdownHandler", "(", ")", "{", "if", "(", "$", "err", "=", "error_get_last", "(", ")", ")", "{", "switch", "(", "$", "err", "[", "'type'", "]", ")", "{", "case", "E_ERROR", ":", "case", "E_PARSE", ":", "case", "E_COMPILE_ERROR", ":", "case", "E_CORE_ERROR", ":", "$", "service", "=", "self", "::", "$", "psrLogger", "->", "getMetadataProvider", "(", ")", "->", "serviceId", "(", ")", ";", "$", "version", "=", "self", "::", "$", "psrLogger", "->", "getMetadataProvider", "(", ")", "->", "versionId", "(", ")", ";", "$", "message", "=", "sprintf", "(", "'%s: %s in %s on line %d'", ",", "self", "::", "getErrorPrefix", "(", "$", "err", "[", "'type'", "]", ")", ",", "$", "err", "[", "'message'", "]", ",", "$", "err", "[", "'file'", "]", ",", "$", "err", "[", "'line'", "]", ")", ";", "$", "context", "=", "[", "'context'", "=>", "[", "'reportLocation'", "=>", "[", "'filePath'", "=>", "$", "err", "[", "'file'", "]", ",", "'lineNumber'", "=>", "$", "err", "[", "'line'", "]", ",", "'functionName'", "=>", "self", "::", "getFunctionNameForReport", "(", ")", ",", "]", "]", ",", "'serviceContext'", "=>", "[", "'service'", "=>", "$", "service", ",", "'version'", "=>", "$", "version", "]", "]", ";", "if", "(", "self", "::", "$", "psrLogger", ")", "{", "self", "::", "$", "psrLogger", "->", "log", "(", "self", "::", "getErrorLevelString", "(", "$", "err", "[", "'type'", "]", ")", ",", "$", "message", ",", "$", "context", ")", ";", "}", "break", ";", "}", "}", "}" ]
Called at exit, to check there's a fatal error and report the error if any.
[ "Called", "at", "exit", "to", "check", "there", "s", "a", "fatal", "error", "and", "report", "the", "error", "if", "any", "." ]
ff5030ffa1f12904565509a7bc24ecc0bd794a3e
https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/ErrorReporting/src/Bootstrap.php#L199-L244
train
googleapis/google-cloud-php
Talent/src/V4beta1/ClientEvent.php
ClientEvent.setJobEvent
public function setJobEvent($var) { GPBUtil::checkMessage($var, \Google\Cloud\Talent\V4beta1\JobEvent::class); $this->writeOneof(5, $var); return $this; }
php
public function setJobEvent($var) { GPBUtil::checkMessage($var, \Google\Cloud\Talent\V4beta1\JobEvent::class); $this->writeOneof(5, $var); return $this; }
[ "public", "function", "setJobEvent", "(", "$", "var", ")", "{", "GPBUtil", "::", "checkMessage", "(", "$", "var", ",", "\\", "Google", "\\", "Cloud", "\\", "Talent", "\\", "V4beta1", "\\", "JobEvent", "::", "class", ")", ";", "$", "this", "->", "writeOneof", "(", "5", ",", "$", "var", ")", ";", "return", "$", "this", ";", "}" ]
An event issued when a job seeker interacts with the application that implements Cloud Talent Solution. Generated from protobuf field <code>.google.cloud.talent.v4beta1.JobEvent job_event = 5;</code> @param \Google\Cloud\Talent\V4beta1\JobEvent $var @return $this
[ "An", "event", "issued", "when", "a", "job", "seeker", "interacts", "with", "the", "application", "that", "implements", "Cloud", "Talent", "Solution", "." ]
ff5030ffa1f12904565509a7bc24ecc0bd794a3e
https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Talent/src/V4beta1/ClientEvent.php#L193-L199
train
googleapis/google-cloud-php
Talent/src/V4beta1/ClientEvent.php
ClientEvent.setProfileEvent
public function setProfileEvent($var) { GPBUtil::checkMessage($var, \Google\Cloud\Talent\V4beta1\ProfileEvent::class); $this->writeOneof(6, $var); return $this; }
php
public function setProfileEvent($var) { GPBUtil::checkMessage($var, \Google\Cloud\Talent\V4beta1\ProfileEvent::class); $this->writeOneof(6, $var); return $this; }
[ "public", "function", "setProfileEvent", "(", "$", "var", ")", "{", "GPBUtil", "::", "checkMessage", "(", "$", "var", ",", "\\", "Google", "\\", "Cloud", "\\", "Talent", "\\", "V4beta1", "\\", "ProfileEvent", "::", "class", ")", ";", "$", "this", "->", "writeOneof", "(", "6", ",", "$", "var", ")", ";", "return", "$", "this", ";", "}" ]
An event issued when a profile searcher interacts with the application that implements Cloud Talent Solution. Generated from protobuf field <code>.google.cloud.talent.v4beta1.ProfileEvent profile_event = 6;</code> @param \Google\Cloud\Talent\V4beta1\ProfileEvent $var @return $this
[ "An", "event", "issued", "when", "a", "profile", "searcher", "interacts", "with", "the", "application", "that", "implements", "Cloud", "Talent", "Solution", "." ]
ff5030ffa1f12904565509a7bc24ecc0bd794a3e
https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Talent/src/V4beta1/ClientEvent.php#L221-L227
train
googleapis/google-cloud-php
Dataproc/src/V1beta2/OrderedJob.php
OrderedJob.setPysparkJob
public function setPysparkJob($var) { GPBUtil::checkMessage($var, \Google\Cloud\Dataproc\V1beta2\PySparkJob::class); $this->writeOneof(4, $var); return $this; }
php
public function setPysparkJob($var) { GPBUtil::checkMessage($var, \Google\Cloud\Dataproc\V1beta2\PySparkJob::class); $this->writeOneof(4, $var); return $this; }
[ "public", "function", "setPysparkJob", "(", "$", "var", ")", "{", "GPBUtil", "::", "checkMessage", "(", "$", "var", ",", "\\", "Google", "\\", "Cloud", "\\", "Dataproc", "\\", "V1beta2", "\\", "PySparkJob", "::", "class", ")", ";", "$", "this", "->", "writeOneof", "(", "4", ",", "$", "var", ")", ";", "return", "$", "this", ";", "}" ]
Job is a Pyspark job. Generated from protobuf field <code>.google.cloud.dataproc.v1beta2.PySparkJob pyspark_job = 4;</code> @param \Google\Cloud\Dataproc\V1beta2\PySparkJob $var @return $this
[ "Job", "is", "a", "Pyspark", "job", "." ]
ff5030ffa1f12904565509a7bc24ecc0bd794a3e
https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Dataproc/src/V1beta2/OrderedJob.php#L219-L225
train
googleapis/google-cloud-php
Dataproc/src/V1beta2/OrderedJob.php
OrderedJob.setPrerequisiteStepIds
public function setPrerequisiteStepIds($var) { $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING); $this->prerequisite_step_ids = $arr; return $this; }
php
public function setPrerequisiteStepIds($var) { $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING); $this->prerequisite_step_ids = $arr; return $this; }
[ "public", "function", "setPrerequisiteStepIds", "(", "$", "var", ")", "{", "$", "arr", "=", "GPBUtil", "::", "checkRepeatedField", "(", "$", "var", ",", "\\", "Google", "\\", "Protobuf", "\\", "Internal", "\\", "GPBType", "::", "STRING", ")", ";", "$", "this", "->", "prerequisite_step_ids", "=", "$", "arr", ";", "return", "$", "this", ";", "}" ]
Optional. The optional list of prerequisite job step_ids. If not specified, the job will start at the beginning of workflow. Generated from protobuf field <code>repeated string prerequisite_step_ids = 10;</code> @param string[]|\Google\Protobuf\Internal\RepeatedField $var @return $this
[ "Optional", ".", "The", "optional", "list", "of", "prerequisite", "job", "step_ids", ".", "If", "not", "specified", "the", "job", "will", "start", "at", "the", "beginning", "of", "workflow", "." ]
ff5030ffa1f12904565509a7bc24ecc0bd794a3e
https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Dataproc/src/V1beta2/OrderedJob.php#L389-L395
train
googleapis/google-cloud-php
Container/src/V1/MaintenanceWindow.php
MaintenanceWindow.setDailyMaintenanceWindow
public function setDailyMaintenanceWindow($var) { GPBUtil::checkMessage($var, \Google\Cloud\Container\V1\DailyMaintenanceWindow::class); $this->writeOneof(2, $var); return $this; }
php
public function setDailyMaintenanceWindow($var) { GPBUtil::checkMessage($var, \Google\Cloud\Container\V1\DailyMaintenanceWindow::class); $this->writeOneof(2, $var); return $this; }
[ "public", "function", "setDailyMaintenanceWindow", "(", "$", "var", ")", "{", "GPBUtil", "::", "checkMessage", "(", "$", "var", ",", "\\", "Google", "\\", "Cloud", "\\", "Container", "\\", "V1", "\\", "DailyMaintenanceWindow", "::", "class", ")", ";", "$", "this", "->", "writeOneof", "(", "2", ",", "$", "var", ")", ";", "return", "$", "this", ";", "}" ]
DailyMaintenanceWindow specifies a daily maintenance operation window. Generated from protobuf field <code>.google.container.v1.DailyMaintenanceWindow daily_maintenance_window = 2;</code> @param \Google\Cloud\Container\V1\DailyMaintenanceWindow $var @return $this
[ "DailyMaintenanceWindow", "specifies", "a", "daily", "maintenance", "operation", "window", "." ]
ff5030ffa1f12904565509a7bc24ecc0bd794a3e
https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Container/src/V1/MaintenanceWindow.php#L53-L59
train
googleapis/google-cloud-php
Iot/src/V1/GatewayConfig.php
GatewayConfig.setGatewayType
public function setGatewayType($var) { GPBUtil::checkEnum($var, \Google\Cloud\Iot\V1\GatewayType::class); $this->gateway_type = $var; return $this; }
php
public function setGatewayType($var) { GPBUtil::checkEnum($var, \Google\Cloud\Iot\V1\GatewayType::class); $this->gateway_type = $var; return $this; }
[ "public", "function", "setGatewayType", "(", "$", "var", ")", "{", "GPBUtil", "::", "checkEnum", "(", "$", "var", ",", "\\", "Google", "\\", "Cloud", "\\", "Iot", "\\", "V1", "\\", "GatewayType", "::", "class", ")", ";", "$", "this", "->", "gateway_type", "=", "$", "var", ";", "return", "$", "this", ";", "}" ]
Indicates whether the device is a gateway. Generated from protobuf field <code>.google.cloud.iot.v1.GatewayType gateway_type = 1;</code> @param int $var @return $this
[ "Indicates", "whether", "the", "device", "is", "a", "gateway", "." ]
ff5030ffa1f12904565509a7bc24ecc0bd794a3e
https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Iot/src/V1/GatewayConfig.php#L86-L92
train
googleapis/google-cloud-php
Logging/src/V2/ListSinksResponse.php
ListSinksResponse.setSinks
public function setSinks($var) { $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Logging\V2\LogSink::class); $this->sinks = $arr; return $this; }
php
public function setSinks($var) { $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Logging\V2\LogSink::class); $this->sinks = $arr; return $this; }
[ "public", "function", "setSinks", "(", "$", "var", ")", "{", "$", "arr", "=", "GPBUtil", "::", "checkRepeatedField", "(", "$", "var", ",", "\\", "Google", "\\", "Protobuf", "\\", "Internal", "\\", "GPBType", "::", "MESSAGE", ",", "\\", "Google", "\\", "Cloud", "\\", "Logging", "\\", "V2", "\\", "LogSink", "::", "class", ")", ";", "$", "this", "->", "sinks", "=", "$", "arr", ";", "return", "$", "this", ";", "}" ]
A list of sinks. Generated from protobuf field <code>repeated .google.logging.v2.LogSink sinks = 1;</code> @param \Google\Cloud\Logging\V2\LogSink[]|\Google\Protobuf\Internal\RepeatedField $var @return $this
[ "A", "list", "of", "sinks", "." ]
ff5030ffa1f12904565509a7bc24ecc0bd794a3e
https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Logging/src/V2/ListSinksResponse.php#L70-L76
train
googleapis/google-cloud-php
Vision/src/V1/ImportProductSetsInputConfig.php
ImportProductSetsInputConfig.setGcsSource
public function setGcsSource($var) { GPBUtil::checkMessage($var, \Google\Cloud\Vision\V1\ImportProductSetsGcsSource::class); $this->writeOneof(1, $var); return $this; }
php
public function setGcsSource($var) { GPBUtil::checkMessage($var, \Google\Cloud\Vision\V1\ImportProductSetsGcsSource::class); $this->writeOneof(1, $var); return $this; }
[ "public", "function", "setGcsSource", "(", "$", "var", ")", "{", "GPBUtil", "::", "checkMessage", "(", "$", "var", ",", "\\", "Google", "\\", "Cloud", "\\", "Vision", "\\", "V1", "\\", "ImportProductSetsGcsSource", "::", "class", ")", ";", "$", "this", "->", "writeOneof", "(", "1", ",", "$", "var", ")", ";", "return", "$", "this", ";", "}" ]
The Google Cloud Storage location for a csv file which preserves a list of ImportProductSetRequests in each line. Generated from protobuf field <code>.google.cloud.vision.v1.ImportProductSetsGcsSource gcs_source = 1;</code> @param \Google\Cloud\Vision\V1\ImportProductSetsGcsSource $var @return $this
[ "The", "Google", "Cloud", "Storage", "location", "for", "a", "csv", "file", "which", "preserves", "a", "list", "of", "ImportProductSetRequests", "in", "each", "line", "." ]
ff5030ffa1f12904565509a7bc24ecc0bd794a3e
https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Vision/src/V1/ImportProductSetsInputConfig.php#L56-L62
train
googleapis/google-cloud-php
BigQuery/src/JobConfigurationTrait.php
JobConfigurationTrait.jobConfigurationProperties
public function jobConfigurationProperties( $projectId, array $config, $location ) { $this->config = array_replace_recursive([ 'projectId' => $projectId, 'jobReference' => ['projectId' => $projectId] ], $config); if ($location && !isset($this->config['jobReference']['location'])) { $this->config['jobReference']['location'] = $location; } if (!isset($this->config['jobReference']['jobId'])) { $this->config['jobReference']['jobId'] = $this->generateJobId(); } }
php
public function jobConfigurationProperties( $projectId, array $config, $location ) { $this->config = array_replace_recursive([ 'projectId' => $projectId, 'jobReference' => ['projectId' => $projectId] ], $config); if ($location && !isset($this->config['jobReference']['location'])) { $this->config['jobReference']['location'] = $location; } if (!isset($this->config['jobReference']['jobId'])) { $this->config['jobReference']['jobId'] = $this->generateJobId(); } }
[ "public", "function", "jobConfigurationProperties", "(", "$", "projectId", ",", "array", "$", "config", ",", "$", "location", ")", "{", "$", "this", "->", "config", "=", "array_replace_recursive", "(", "[", "'projectId'", "=>", "$", "projectId", ",", "'jobReference'", "=>", "[", "'projectId'", "=>", "$", "projectId", "]", "]", ",", "$", "config", ")", ";", "if", "(", "$", "location", "&&", "!", "isset", "(", "$", "this", "->", "config", "[", "'jobReference'", "]", "[", "'location'", "]", ")", ")", "{", "$", "this", "->", "config", "[", "'jobReference'", "]", "[", "'location'", "]", "=", "$", "location", ";", "}", "if", "(", "!", "isset", "(", "$", "this", "->", "config", "[", "'jobReference'", "]", "[", "'jobId'", "]", ")", ")", "{", "$", "this", "->", "config", "[", "'jobReference'", "]", "[", "'jobId'", "]", "=", "$", "this", "->", "generateJobId", "(", ")", ";", "}", "}" ]
Sets shared job configuration properties. @access private @param string $projectId The project's ID. @param array $config A set of configuration options for a job. @param string|null $location The geographic location in which the job is executed.
[ "Sets", "shared", "job", "configuration", "properties", "." ]
ff5030ffa1f12904565509a7bc24ecc0bd794a3e
https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/BigQuery/src/JobConfigurationTrait.php#L49-L66
train
googleapis/google-cloud-php
BigQuery/src/JobConfigurationTrait.php
JobConfigurationTrait.toArray
public function toArray() { if ($this->jobIdPrefix) { $this->config['jobReference']['jobId'] = sprintf( '%s-%s', $this->jobIdPrefix, $this->config['jobReference']['jobId'] ); } return $this->config; }
php
public function toArray() { if ($this->jobIdPrefix) { $this->config['jobReference']['jobId'] = sprintf( '%s-%s', $this->jobIdPrefix, $this->config['jobReference']['jobId'] ); } return $this->config; }
[ "public", "function", "toArray", "(", ")", "{", "if", "(", "$", "this", "->", "jobIdPrefix", ")", "{", "$", "this", "->", "config", "[", "'jobReference'", "]", "[", "'jobId'", "]", "=", "sprintf", "(", "'%s-%s'", ",", "$", "this", "->", "jobIdPrefix", ",", "$", "this", "->", "config", "[", "'jobReference'", "]", "[", "'jobId'", "]", ")", ";", "}", "return", "$", "this", "->", "config", ";", "}" ]
Returns the job config as an array. @access private @return array
[ "Returns", "the", "job", "config", "as", "an", "array", "." ]
ff5030ffa1f12904565509a7bc24ecc0bd794a3e
https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/BigQuery/src/JobConfigurationTrait.php#L134-L145
train
googleapis/google-cloud-php
Spanner/src/TransactionalReadTrait.php
TransactionalReadTrait.singleUseState
private function singleUseState() { if ($this->type === self::TYPE_SINGLE_USE) { if ($this->state === self::STATE_SINGLE_USE_USED) { throw new \BadMethodCallException('This single-use transaction has already been used.'); } $this->state = self::STATE_SINGLE_USE_USED; return true; } return false; }
php
private function singleUseState() { if ($this->type === self::TYPE_SINGLE_USE) { if ($this->state === self::STATE_SINGLE_USE_USED) { throw new \BadMethodCallException('This single-use transaction has already been used.'); } $this->state = self::STATE_SINGLE_USE_USED; return true; } return false; }
[ "private", "function", "singleUseState", "(", ")", "{", "if", "(", "$", "this", "->", "type", "===", "self", "::", "TYPE_SINGLE_USE", ")", "{", "if", "(", "$", "this", "->", "state", "===", "self", "::", "STATE_SINGLE_USE_USED", ")", "{", "throw", "new", "\\", "BadMethodCallException", "(", "'This single-use transaction has already been used.'", ")", ";", "}", "$", "this", "->", "state", "=", "self", "::", "STATE_SINGLE_USE_USED", ";", "return", "true", ";", "}", "return", "false", ";", "}" ]
Check the transaction state, and update as necessary for single-use transactions. @return bool true if transaction is single use, false otherwise. @throws \BadMethodCallException
[ "Check", "the", "transaction", "state", "and", "update", "as", "necessary", "for", "single", "-", "use", "transactions", "." ]
ff5030ffa1f12904565509a7bc24ecc0bd794a3e
https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Spanner/src/TransactionalReadTrait.php#L346-L359
train
googleapis/google-cloud-php
Spanner/src/TransactionalReadTrait.php
TransactionalReadTrait.checkReadContext
private function checkReadContext() { if ($this->type === self::TYPE_SINGLE_USE && $this->context === SessionPoolInterface::CONTEXT_READWRITE) { throw new \BadMethodCallException('Cannot use a single-use read-write transaction for read or execute.'); } }
php
private function checkReadContext() { if ($this->type === self::TYPE_SINGLE_USE && $this->context === SessionPoolInterface::CONTEXT_READWRITE) { throw new \BadMethodCallException('Cannot use a single-use read-write transaction for read or execute.'); } }
[ "private", "function", "checkReadContext", "(", ")", "{", "if", "(", "$", "this", "->", "type", "===", "self", "::", "TYPE_SINGLE_USE", "&&", "$", "this", "->", "context", "===", "SessionPoolInterface", "::", "CONTEXT_READWRITE", ")", "{", "throw", "new", "\\", "BadMethodCallException", "(", "'Cannot use a single-use read-write transaction for read or execute.'", ")", ";", "}", "}" ]
Check whether the context is valid for a read operation. Reads are not allowed in single-use read-write transactions. @throws \BadMethodCallException
[ "Check", "whether", "the", "context", "is", "valid", "for", "a", "read", "operation", ".", "Reads", "are", "not", "allowed", "in", "single", "-", "use", "read", "-", "write", "transactions", "." ]
ff5030ffa1f12904565509a7bc24ecc0bd794a3e
https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Spanner/src/TransactionalReadTrait.php#L367-L372
train
googleapis/google-cloud-php
CommonProtos/src/DevTools/Source/V1/CloudWorkspaceSourceContext.php
CloudWorkspaceSourceContext.setWorkspaceId
public function setWorkspaceId($var) { GPBUtil::checkMessage($var, \Google\Cloud\DevTools\Source\V1\CloudWorkspaceId::class); $this->workspace_id = $var; return $this; }
php
public function setWorkspaceId($var) { GPBUtil::checkMessage($var, \Google\Cloud\DevTools\Source\V1\CloudWorkspaceId::class); $this->workspace_id = $var; return $this; }
[ "public", "function", "setWorkspaceId", "(", "$", "var", ")", "{", "GPBUtil", "::", "checkMessage", "(", "$", "var", ",", "\\", "Google", "\\", "Cloud", "\\", "DevTools", "\\", "Source", "\\", "V1", "\\", "CloudWorkspaceId", "::", "class", ")", ";", "$", "this", "->", "workspace_id", "=", "$", "var", ";", "return", "$", "this", ";", "}" ]
The ID of the workspace. Generated from protobuf field <code>.google.devtools.source.v1.CloudWorkspaceId workspace_id = 1;</code> @param \Google\Cloud\DevTools\Source\V1\CloudWorkspaceId $var @return $this
[ "The", "ID", "of", "the", "workspace", "." ]
ff5030ffa1f12904565509a7bc24ecc0bd794a3e
https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/CommonProtos/src/DevTools/Source/V1/CloudWorkspaceSourceContext.php#L68-L74
train
googleapis/google-cloud-php
Dialogflow/src/V2/SessionEntityType.php
SessionEntityType.setEntityOverrideMode
public function setEntityOverrideMode($var) { GPBUtil::checkEnum($var, \Google\Cloud\Dialogflow\V2\SessionEntityType_EntityOverrideMode::class); $this->entity_override_mode = $var; return $this; }
php
public function setEntityOverrideMode($var) { GPBUtil::checkEnum($var, \Google\Cloud\Dialogflow\V2\SessionEntityType_EntityOverrideMode::class); $this->entity_override_mode = $var; return $this; }
[ "public", "function", "setEntityOverrideMode", "(", "$", "var", ")", "{", "GPBUtil", "::", "checkEnum", "(", "$", "var", ",", "\\", "Google", "\\", "Cloud", "\\", "Dialogflow", "\\", "V2", "\\", "SessionEntityType_EntityOverrideMode", "::", "class", ")", ";", "$", "this", "->", "entity_override_mode", "=", "$", "var", ";", "return", "$", "this", ";", "}" ]
Required. Indicates whether the additional data should override or supplement the developer entity type definition. Generated from protobuf field <code>.google.cloud.dialogflow.v2.SessionEntityType.EntityOverrideMode entity_override_mode = 2;</code> @param int $var @return $this
[ "Required", ".", "Indicates", "whether", "the", "additional", "data", "should", "override", "or", "supplement", "the", "developer", "entity", "type", "definition", "." ]
ff5030ffa1f12904565509a7bc24ecc0bd794a3e
https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Dialogflow/src/V2/SessionEntityType.php#L126-L132
train
googleapis/google-cloud-php
Vision/src/Image.php
Image.requestObject
public function requestObject($encode = true) { return array_filter([ 'image' => $this->imageObject($encode), 'features' => $this->features, 'imageContext' => $this->options['imageContext'] ]); }
php
public function requestObject($encode = true) { return array_filter([ 'image' => $this->imageObject($encode), 'features' => $this->features, 'imageContext' => $this->options['imageContext'] ]); }
[ "public", "function", "requestObject", "(", "$", "encode", "=", "true", ")", "{", "return", "array_filter", "(", "[", "'image'", "=>", "$", "this", "->", "imageObject", "(", "$", "encode", ")", ",", "'features'", "=>", "$", "this", "->", "features", ",", "'imageContext'", "=>", "$", "this", "->", "options", "[", "'imageContext'", "]", "]", ")", ";", "}" ]
Return a formatted annotate image request. This method is used internally by {@see Google\Cloud\Vision\VisionClient} and is not generally intended for use outside of that context. Example: ``` use Google\Cloud\Vision\Image; $imageResource = fopen(__DIR__ . '/assets/family-photo.jpg', 'r'); $image = new Image($imageResource, [ 'FACE_DETECTION' ]); $requestObj = $image->requestObject(); ``` @see https://cloud.google.com/vision/reference/rest/v1/images/annotate#annotateimagerequest AnnotateImageRequest @param bool $encode [optional] If set to true, image bytes will be base64-encoded (required for json/rest requests) @return array
[ "Return", "a", "formatted", "annotate", "image", "request", "." ]
ff5030ffa1f12904565509a7bc24ecc0bd794a3e
https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Vision/src/Image.php#L289-L296
train
googleapis/google-cloud-php
Vision/src/Image.php
Image.imageObject
private function imageObject($encode) { if ($this->type === self::TYPE_BYTES) { $bytes = (string) $this->image; return [ 'content' => ($encode) ? base64_encode($bytes) : $bytes ]; } if ($this->type === self::TYPE_STRING) { $string = $this->image; return [ 'content' => ($encode) ? base64_encode($string) : $string ]; } return [ 'source' => [ 'imageUri' => $this->image ] ]; }
php
private function imageObject($encode) { if ($this->type === self::TYPE_BYTES) { $bytes = (string) $this->image; return [ 'content' => ($encode) ? base64_encode($bytes) : $bytes ]; } if ($this->type === self::TYPE_STRING) { $string = $this->image; return [ 'content' => ($encode) ? base64_encode($string) : $string ]; } return [ 'source' => [ 'imageUri' => $this->image ] ]; }
[ "private", "function", "imageObject", "(", "$", "encode", ")", "{", "if", "(", "$", "this", "->", "type", "===", "self", "::", "TYPE_BYTES", ")", "{", "$", "bytes", "=", "(", "string", ")", "$", "this", "->", "image", ";", "return", "[", "'content'", "=>", "(", "$", "encode", ")", "?", "base64_encode", "(", "$", "bytes", ")", ":", "$", "bytes", "]", ";", "}", "if", "(", "$", "this", "->", "type", "===", "self", "::", "TYPE_STRING", ")", "{", "$", "string", "=", "$", "this", "->", "image", ";", "return", "[", "'content'", "=>", "(", "$", "encode", ")", "?", "base64_encode", "(", "$", "string", ")", ":", "$", "string", "]", ";", "}", "return", "[", "'source'", "=>", "[", "'imageUri'", "=>", "$", "this", "->", "image", "]", "]", ";", "}" ]
Create an image object. The structure of the returned array will vary depending on whether the given image is a storage object or not. @see https://cloud.google.com/vision/reference/rest/v1/images/annotate#image Image @param bool $encode If set to true, image bytes will be base64-encoded @return array [Image](https://cloud.google.com/vision/reference/rest/v1/images/annotate#image)
[ "Create", "an", "image", "object", "." ]
ff5030ffa1f12904565509a7bc24ecc0bd794a3e
https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Vision/src/Image.php#L309-L332
train
googleapis/google-cloud-php
Vision/src/Image.php
Image.normalizeFeatures
private function normalizeFeatures(array $features) { $result = []; foreach ($features as $key => $feature) { $maxResults = $this->maxResult($feature); if (array_key_exists($feature, $this->featureShortNames)) { $feature = $this->featureShortNames[$feature]; } $result[] = array_filter([ 'type' => $feature, 'maxResults' => $maxResults ]); } return $result; }
php
private function normalizeFeatures(array $features) { $result = []; foreach ($features as $key => $feature) { $maxResults = $this->maxResult($feature); if (array_key_exists($feature, $this->featureShortNames)) { $feature = $this->featureShortNames[$feature]; } $result[] = array_filter([ 'type' => $feature, 'maxResults' => $maxResults ]); } return $result; }
[ "private", "function", "normalizeFeatures", "(", "array", "$", "features", ")", "{", "$", "result", "=", "[", "]", ";", "foreach", "(", "$", "features", "as", "$", "key", "=>", "$", "feature", ")", "{", "$", "maxResults", "=", "$", "this", "->", "maxResult", "(", "$", "feature", ")", ";", "if", "(", "array_key_exists", "(", "$", "feature", ",", "$", "this", "->", "featureShortNames", ")", ")", "{", "$", "feature", "=", "$", "this", "->", "featureShortNames", "[", "$", "feature", "]", ";", "}", "$", "result", "[", "]", "=", "array_filter", "(", "[", "'type'", "=>", "$", "feature", ",", "'maxResults'", "=>", "$", "maxResults", "]", ")", ";", "}", "return", "$", "result", ";", "}" ]
Normalizes short feature names to identifiers compatible with the vision API and adds maxResults if specified. @param array $features @return array A list of type [Feature](https://cloud.google.com/vision/reference/rest/v1/images/annotate#feature)
[ "Normalizes", "short", "feature", "names", "to", "identifiers", "compatible", "with", "the", "vision", "API", "and", "adds", "maxResults", "if", "specified", "." ]
ff5030ffa1f12904565509a7bc24ecc0bd794a3e
https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Vision/src/Image.php#L341-L359
train
googleapis/google-cloud-php
Vision/src/Image.php
Image.maxResult
private function maxResult($feature) { return (isset($this->options['maxResults'][$feature])) ? $this->options['maxResults'][$feature] : null; }
php
private function maxResult($feature) { return (isset($this->options['maxResults'][$feature])) ? $this->options['maxResults'][$feature] : null; }
[ "private", "function", "maxResult", "(", "$", "feature", ")", "{", "return", "(", "isset", "(", "$", "this", "->", "options", "[", "'maxResults'", "]", "[", "$", "feature", "]", ")", ")", "?", "$", "this", "->", "options", "[", "'maxResults'", "]", "[", "$", "feature", "]", ":", "null", ";", "}" ]
Identify and return a maxResults value for a given feature, if maxResults is specified. @param string $feature @return mixed Int if set, null if not set.
[ "Identify", "and", "return", "a", "maxResults", "value", "for", "a", "given", "feature", "if", "maxResults", "is", "specified", "." ]
ff5030ffa1f12904565509a7bc24ecc0bd794a3e
https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Vision/src/Image.php#L368-L373
train
googleapis/google-cloud-php
Vision/src/V1/ProductSearchParams.php
ProductSearchParams.setProductCategories
public function setProductCategories($var) { $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING); $this->product_categories = $arr; return $this; }
php
public function setProductCategories($var) { $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING); $this->product_categories = $arr; return $this; }
[ "public", "function", "setProductCategories", "(", "$", "var", ")", "{", "$", "arr", "=", "GPBUtil", "::", "checkRepeatedField", "(", "$", "var", ",", "\\", "Google", "\\", "Protobuf", "\\", "Internal", "\\", "GPBType", "::", "STRING", ")", ";", "$", "this", "->", "product_categories", "=", "$", "arr", ";", "return", "$", "this", ";", "}" ]
The list of product categories to search in. Currently, we only consider the first category, and either "homegoods", "apparel", or "toys" should be specified. Generated from protobuf field <code>repeated string product_categories = 7;</code> @param string[]|\Google\Protobuf\Internal\RepeatedField $var @return $this
[ "The", "list", "of", "product", "categories", "to", "search", "in", ".", "Currently", "we", "only", "consider", "the", "first", "category", "and", "either", "homegoods", "apparel", "or", "toys", "should", "be", "specified", "." ]
ff5030ffa1f12904565509a7bc24ecc0bd794a3e
https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Vision/src/V1/ProductSearchParams.php#L170-L176
train
googleapis/google-cloud-php
Spanner/src/InstanceConfiguration.php
InstanceConfiguration.reload
public function reload(array $options = []) { $this->info = $this->connection->getInstanceConfig($options + [ 'name' => $this->name, 'projectId' => $this->projectId ]); return $this->info; }
php
public function reload(array $options = []) { $this->info = $this->connection->getInstanceConfig($options + [ 'name' => $this->name, 'projectId' => $this->projectId ]); return $this->info; }
[ "public", "function", "reload", "(", "array", "$", "options", "=", "[", "]", ")", "{", "$", "this", "->", "info", "=", "$", "this", "->", "connection", "->", "getInstanceConfig", "(", "$", "options", "+", "[", "'name'", "=>", "$", "this", "->", "name", ",", "'projectId'", "=>", "$", "this", "->", "projectId", "]", ")", ";", "return", "$", "this", "->", "info", ";", "}" ]
Fetch a fresh representation of the configuration from the service. **NOTE**: Requires `https://www.googleapis.com/auth/spanner.admin` scope. Example: ``` $info = $configuration->reload(); ``` @codingStandardsIgnoreStart @param array $options [optional] Configuration options. @return array [InstanceConfig](https://cloud.google.com/spanner/docs/reference/rpc/google.spanner.admin.instance.v1#instanceconfig) @codingStandardsIgnoreEnd
[ "Fetch", "a", "fresh", "representation", "of", "the", "configuration", "from", "the", "service", "." ]
ff5030ffa1f12904565509a7bc24ecc0bd794a3e
https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Spanner/src/InstanceConfiguration.php#L169-L177
train
googleapis/google-cloud-php
Spanner/src/InstanceConfiguration.php
InstanceConfiguration.fullyQualifiedConfigName
private function fullyQualifiedConfigName($name, $projectId) { try { return InstanceAdminClient::instanceConfigName( $projectId, $name ); } catch (ValidationException $e) { return $name; } }
php
private function fullyQualifiedConfigName($name, $projectId) { try { return InstanceAdminClient::instanceConfigName( $projectId, $name ); } catch (ValidationException $e) { return $name; } }
[ "private", "function", "fullyQualifiedConfigName", "(", "$", "name", ",", "$", "projectId", ")", "{", "try", "{", "return", "InstanceAdminClient", "::", "instanceConfigName", "(", "$", "projectId", ",", "$", "name", ")", ";", "}", "catch", "(", "ValidationException", "$", "e", ")", "{", "return", "$", "name", ";", "}", "}" ]
Get the fully qualified instance config name. @param string $name The configuration name. @param string $projectId The project ID. @return string
[ "Get", "the", "fully", "qualified", "instance", "config", "name", "." ]
ff5030ffa1f12904565509a7bc24ecc0bd794a3e
https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Spanner/src/InstanceConfiguration.php#L202-L212
train
googleapis/google-cloud-php
Vision/src/V1/AsyncBatchAnnotateFilesRequest.php
AsyncBatchAnnotateFilesRequest.setRequests
public function setRequests($var) { $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Vision\V1\AsyncAnnotateFileRequest::class); $this->requests = $arr; return $this; }
php
public function setRequests($var) { $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Vision\V1\AsyncAnnotateFileRequest::class); $this->requests = $arr; return $this; }
[ "public", "function", "setRequests", "(", "$", "var", ")", "{", "$", "arr", "=", "GPBUtil", "::", "checkRepeatedField", "(", "$", "var", ",", "\\", "Google", "\\", "Protobuf", "\\", "Internal", "\\", "GPBType", "::", "MESSAGE", ",", "\\", "Google", "\\", "Cloud", "\\", "Vision", "\\", "V1", "\\", "AsyncAnnotateFileRequest", "::", "class", ")", ";", "$", "this", "->", "requests", "=", "$", "arr", ";", "return", "$", "this", ";", "}" ]
Individual async file annotation requests for this batch. Generated from protobuf field <code>repeated .google.cloud.vision.v1.AsyncAnnotateFileRequest requests = 1;</code> @param \Google\Cloud\Vision\V1\AsyncAnnotateFileRequest[]|\Google\Protobuf\Internal\RepeatedField $var @return $this
[ "Individual", "async", "file", "annotation", "requests", "for", "this", "batch", "." ]
ff5030ffa1f12904565509a7bc24ecc0bd794a3e
https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Vision/src/V1/AsyncBatchAnnotateFilesRequest.php#L59-L65
train