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
sequence | docstring
stringlengths 3
47.2k
| docstring_tokens
sequence | sha
stringlengths 40
40
| url
stringlengths 91
247
| partition
stringclasses 1
value |
---|---|---|---|---|---|---|---|---|---|---|---|
googleapis/google-cloud-php | Spanner/src/Operation.php | Operation.executeUpdate | public function executeUpdate(
Session $session,
Transaction $transaction,
$sql,
array $options = []
) {
$res = $this->execute($session, $sql, [
'transactionId' => $transaction->id()
] + $options);
// Iterate through the result to ensure we have query statistics available.
iterator_to_array($res->rows());
$stats = $res->stats();
if (!$stats) {
throw new \InvalidArgumentException(
'Partitioned DML response missing stats, possible due to non-DML statement as input.'
);
}
$statsItem = isset($options['statsItem'])
? $options['statsItem']
: 'rowCountExact';
return $stats[$statsItem];
} | php | public function executeUpdate(
Session $session,
Transaction $transaction,
$sql,
array $options = []
) {
$res = $this->execute($session, $sql, [
'transactionId' => $transaction->id()
] + $options);
// Iterate through the result to ensure we have query statistics available.
iterator_to_array($res->rows());
$stats = $res->stats();
if (!$stats) {
throw new \InvalidArgumentException(
'Partitioned DML response missing stats, possible due to non-DML statement as input.'
);
}
$statsItem = isset($options['statsItem'])
? $options['statsItem']
: 'rowCountExact';
return $stats[$statsItem];
} | [
"public",
"function",
"executeUpdate",
"(",
"Session",
"$",
"session",
",",
"Transaction",
"$",
"transaction",
",",
"$",
"sql",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"res",
"=",
"$",
"this",
"->",
"execute",
"(",
"$",
"session",
",",
"$",
"sql",
",",
"[",
"'transactionId'",
"=>",
"$",
"transaction",
"->",
"id",
"(",
")",
"]",
"+",
"$",
"options",
")",
";",
"// Iterate through the result to ensure we have query statistics available.",
"iterator_to_array",
"(",
"$",
"res",
"->",
"rows",
"(",
")",
")",
";",
"$",
"stats",
"=",
"$",
"res",
"->",
"stats",
"(",
")",
";",
"if",
"(",
"!",
"$",
"stats",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Partitioned DML response missing stats, possible due to non-DML statement as input.'",
")",
";",
"}",
"$",
"statsItem",
"=",
"isset",
"(",
"$",
"options",
"[",
"'statsItem'",
"]",
")",
"?",
"$",
"options",
"[",
"'statsItem'",
"]",
":",
"'rowCountExact'",
";",
"return",
"$",
"stats",
"[",
"$",
"statsItem",
"]",
";",
"}"
] | Execute a DML statement and return an affected row count.
@param Session $session The session in which the update operation should be executed.
@param Transaction $transaction The transaction in which the operation should be executed.
@param string $sql The SQL string to execute.
@param array $options Configuration options.
@return int
@throws \InvalidArgumentException If the SQL string isn't an update operation. | [
"Execute",
"a",
"DML",
"statement",
"and",
"return",
"an",
"affected",
"row",
"count",
"."
] | ff5030ffa1f12904565509a7bc24ecc0bd794a3e | https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Spanner/src/Operation.php#L207-L232 | train |
googleapis/google-cloud-php | Spanner/src/Operation.php | Operation.read | public function read(Session $session, $table, KeySet $keySet, array $columns, array $options = [])
{
$options += [
'index' => null,
'limit' => null,
'offset' => null,
'transactionContext' => null
];
$context = $this->pluck('transactionContext', $options);
$call = function ($resumeToken = null) use ($table, $session, $columns, $keySet, $options) {
if ($resumeToken) {
$options['resumeToken'] = $resumeToken;
}
return $this->connection->streamingRead([
'table' => $table,
'session' => $session->name(),
'columns' => $columns,
'keySet' => $this->flattenKeySet($keySet),
'database' => $session->info()['database']
] + $options);
};
return new Result($this, $session, $call, $context, $this->mapper);
} | php | public function read(Session $session, $table, KeySet $keySet, array $columns, array $options = [])
{
$options += [
'index' => null,
'limit' => null,
'offset' => null,
'transactionContext' => null
];
$context = $this->pluck('transactionContext', $options);
$call = function ($resumeToken = null) use ($table, $session, $columns, $keySet, $options) {
if ($resumeToken) {
$options['resumeToken'] = $resumeToken;
}
return $this->connection->streamingRead([
'table' => $table,
'session' => $session->name(),
'columns' => $columns,
'keySet' => $this->flattenKeySet($keySet),
'database' => $session->info()['database']
] + $options);
};
return new Result($this, $session, $call, $context, $this->mapper);
} | [
"public",
"function",
"read",
"(",
"Session",
"$",
"session",
",",
"$",
"table",
",",
"KeySet",
"$",
"keySet",
",",
"array",
"$",
"columns",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"options",
"+=",
"[",
"'index'",
"=>",
"null",
",",
"'limit'",
"=>",
"null",
",",
"'offset'",
"=>",
"null",
",",
"'transactionContext'",
"=>",
"null",
"]",
";",
"$",
"context",
"=",
"$",
"this",
"->",
"pluck",
"(",
"'transactionContext'",
",",
"$",
"options",
")",
";",
"$",
"call",
"=",
"function",
"(",
"$",
"resumeToken",
"=",
"null",
")",
"use",
"(",
"$",
"table",
",",
"$",
"session",
",",
"$",
"columns",
",",
"$",
"keySet",
",",
"$",
"options",
")",
"{",
"if",
"(",
"$",
"resumeToken",
")",
"{",
"$",
"options",
"[",
"'resumeToken'",
"]",
"=",
"$",
"resumeToken",
";",
"}",
"return",
"$",
"this",
"->",
"connection",
"->",
"streamingRead",
"(",
"[",
"'table'",
"=>",
"$",
"table",
",",
"'session'",
"=>",
"$",
"session",
"->",
"name",
"(",
")",
",",
"'columns'",
"=>",
"$",
"columns",
",",
"'keySet'",
"=>",
"$",
"this",
"->",
"flattenKeySet",
"(",
"$",
"keySet",
")",
",",
"'database'",
"=>",
"$",
"session",
"->",
"info",
"(",
")",
"[",
"'database'",
"]",
"]",
"+",
"$",
"options",
")",
";",
"}",
";",
"return",
"new",
"Result",
"(",
"$",
"this",
",",
"$",
"session",
",",
"$",
"call",
",",
"$",
"context",
",",
"$",
"this",
"->",
"mapper",
")",
";",
"}"
] | Lookup rows in a database.
@param Session $session The session in which to read data.
@param string $table The table name.
@param KeySet $keySet The KeySet to select rows.
@param array $columns A list of column names to return.
@param array $options [optional] {
Configuration Options.
@type string $index The name of an index on the table.
@type int $offset The number of rows to offset results by.
@type int $limit The number of results to return.
}
@return Result | [
"Lookup",
"rows",
"in",
"a",
"database",
"."
] | ff5030ffa1f12904565509a7bc24ecc0bd794a3e | https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Spanner/src/Operation.php#L315-L341 | train |
googleapis/google-cloud-php | Spanner/src/Operation.php | Operation.createTransaction | public function createTransaction(Session $session, array $res = [], array $options = [])
{
$res += [
'id' => null
];
$options['isRetry'] = isset($options['isRetry'])
? $options['isRetry']
: false;
return new Transaction($this, $session, $res['id'], $options['isRetry']);
} | php | public function createTransaction(Session $session, array $res = [], array $options = [])
{
$res += [
'id' => null
];
$options['isRetry'] = isset($options['isRetry'])
? $options['isRetry']
: false;
return new Transaction($this, $session, $res['id'], $options['isRetry']);
} | [
"public",
"function",
"createTransaction",
"(",
"Session",
"$",
"session",
",",
"array",
"$",
"res",
"=",
"[",
"]",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"res",
"+=",
"[",
"'id'",
"=>",
"null",
"]",
";",
"$",
"options",
"[",
"'isRetry'",
"]",
"=",
"isset",
"(",
"$",
"options",
"[",
"'isRetry'",
"]",
")",
"?",
"$",
"options",
"[",
"'isRetry'",
"]",
":",
"false",
";",
"return",
"new",
"Transaction",
"(",
"$",
"this",
",",
"$",
"session",
",",
"$",
"res",
"[",
"'id'",
"]",
",",
"$",
"options",
"[",
"'isRetry'",
"]",
")",
";",
"}"
] | Create a Transaction instance from a response object.
@param Session $session The session the transaction belongs to.
@param array $res [optional] The createTransaction response.
@param array $options [optional] Options for the transaction object.
@return Transaction | [
"Create",
"a",
"Transaction",
"instance",
"from",
"a",
"response",
"object",
"."
] | ff5030ffa1f12904565509a7bc24ecc0bd794a3e | https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Spanner/src/Operation.php#L386-L397 | train |
googleapis/google-cloud-php | Spanner/src/Operation.php | Operation.snapshot | public function snapshot(Session $session, array $options = [])
{
$options += [
'singleUse' => false,
'className' => Snapshot::class
];
if (!$options['singleUse']) {
$res = $this->beginTransaction($session, $options);
} else {
$res = [];
}
$className = $this->pluck('className', $options);
return $this->createSnapshot(
$session,
$res + $options,
$className
);
} | php | public function snapshot(Session $session, array $options = [])
{
$options += [
'singleUse' => false,
'className' => Snapshot::class
];
if (!$options['singleUse']) {
$res = $this->beginTransaction($session, $options);
} else {
$res = [];
}
$className = $this->pluck('className', $options);
return $this->createSnapshot(
$session,
$res + $options,
$className
);
} | [
"public",
"function",
"snapshot",
"(",
"Session",
"$",
"session",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"options",
"+=",
"[",
"'singleUse'",
"=>",
"false",
",",
"'className'",
"=>",
"Snapshot",
"::",
"class",
"]",
";",
"if",
"(",
"!",
"$",
"options",
"[",
"'singleUse'",
"]",
")",
"{",
"$",
"res",
"=",
"$",
"this",
"->",
"beginTransaction",
"(",
"$",
"session",
",",
"$",
"options",
")",
";",
"}",
"else",
"{",
"$",
"res",
"=",
"[",
"]",
";",
"}",
"$",
"className",
"=",
"$",
"this",
"->",
"pluck",
"(",
"'className'",
",",
"$",
"options",
")",
";",
"return",
"$",
"this",
"->",
"createSnapshot",
"(",
"$",
"session",
",",
"$",
"res",
"+",
"$",
"options",
",",
"$",
"className",
")",
";",
"}"
] | Create a read-only snapshot transaction.
@see https://cloud.google.com/spanner/reference/rpc/google.spanner.v1#google.spanner.v1.BeginTransactionRequest BeginTransactionRequest
@param Session $session The session to start the snapshot in.
@param array $options [optional] {
Configuration Options.
@type bool $singleUse If true, a Transaction ID will not be allocated
up front. Instead, the transaction will be considered
"single-use", and may be used for only a single operation.
**Defaults to** `false`.
@type string $className If set, an instance of the given class will
be instantiated. This setting is intended for internal use.
**Defaults to** `Google\Cloud\Spanner\Snapshot`.
}
@return Snapshot | [
"Create",
"a",
"read",
"-",
"only",
"snapshot",
"transaction",
"."
] | ff5030ffa1f12904565509a7bc24ecc0bd794a3e | https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Spanner/src/Operation.php#L418-L437 | train |
googleapis/google-cloud-php | Spanner/src/Operation.php | Operation.createSnapshot | public function createSnapshot(Session $session, array $res = [], $className = Snapshot::class)
{
$res += [
'id' => null,
'readTimestamp' => null
];
if ($res['readTimestamp']) {
if (!($res['readTimestamp'] instanceof Timestamp)) {
$time = $this->parseTimeString($res['readTimestamp']);
$res['readTimestamp'] = new Timestamp($time[0], $time[1]);
}
}
return new $className($this, $session, $res);
} | php | public function createSnapshot(Session $session, array $res = [], $className = Snapshot::class)
{
$res += [
'id' => null,
'readTimestamp' => null
];
if ($res['readTimestamp']) {
if (!($res['readTimestamp'] instanceof Timestamp)) {
$time = $this->parseTimeString($res['readTimestamp']);
$res['readTimestamp'] = new Timestamp($time[0], $time[1]);
}
}
return new $className($this, $session, $res);
} | [
"public",
"function",
"createSnapshot",
"(",
"Session",
"$",
"session",
",",
"array",
"$",
"res",
"=",
"[",
"]",
",",
"$",
"className",
"=",
"Snapshot",
"::",
"class",
")",
"{",
"$",
"res",
"+=",
"[",
"'id'",
"=>",
"null",
",",
"'readTimestamp'",
"=>",
"null",
"]",
";",
"if",
"(",
"$",
"res",
"[",
"'readTimestamp'",
"]",
")",
"{",
"if",
"(",
"!",
"(",
"$",
"res",
"[",
"'readTimestamp'",
"]",
"instanceof",
"Timestamp",
")",
")",
"{",
"$",
"time",
"=",
"$",
"this",
"->",
"parseTimeString",
"(",
"$",
"res",
"[",
"'readTimestamp'",
"]",
")",
";",
"$",
"res",
"[",
"'readTimestamp'",
"]",
"=",
"new",
"Timestamp",
"(",
"$",
"time",
"[",
"0",
"]",
",",
"$",
"time",
"[",
"1",
"]",
")",
";",
"}",
"}",
"return",
"new",
"$",
"className",
"(",
"$",
"this",
",",
"$",
"session",
",",
"$",
"res",
")",
";",
"}"
] | Create a Snapshot instance from a response object.
@param Session $session The session the snapshot belongs to.
@param array $res [optional] The createTransaction response.
@param string $className [optional] The class to instantiate with a
snapshot. **Defaults to** `Google\Cloud\Spanner\Snapshot`.
@return Snapshot | [
"Create",
"a",
"Snapshot",
"instance",
"from",
"a",
"response",
"object",
"."
] | ff5030ffa1f12904565509a7bc24ecc0bd794a3e | https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Spanner/src/Operation.php#L448-L463 | train |
googleapis/google-cloud-php | Spanner/src/Operation.php | Operation.partitionOptions | private function partitionOptions(array $options)
{
$options['partitionOptions'] = array_filter([
'partitionSizeBytes' => $this->pluck('partitionSizeBytes', $options, false),
'maxPartitions' => $this->pluck('maxPartitions', $options, false)
]);
return $options;
} | php | private function partitionOptions(array $options)
{
$options['partitionOptions'] = array_filter([
'partitionSizeBytes' => $this->pluck('partitionSizeBytes', $options, false),
'maxPartitions' => $this->pluck('maxPartitions', $options, false)
]);
return $options;
} | [
"private",
"function",
"partitionOptions",
"(",
"array",
"$",
"options",
")",
"{",
"$",
"options",
"[",
"'partitionOptions'",
"]",
"=",
"array_filter",
"(",
"[",
"'partitionSizeBytes'",
"=>",
"$",
"this",
"->",
"pluck",
"(",
"'partitionSizeBytes'",
",",
"$",
"options",
",",
"false",
")",
",",
"'maxPartitions'",
"=>",
"$",
"this",
"->",
"pluck",
"(",
"'maxPartitions'",
",",
"$",
"options",
",",
"false",
")",
"]",
")",
";",
"return",
"$",
"options",
";",
"}"
] | Normalize options for partition configuration.
@param array $options
@return array | [
"Normalize",
"options",
"for",
"partition",
"configuration",
"."
] | ff5030ffa1f12904565509a7bc24ecc0bd794a3e | https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Spanner/src/Operation.php#L655-L663 | train |
googleapis/google-cloud-php | Spanner/src/Operation.php | Operation.beginTransaction | private function beginTransaction(Session $session, array $options = [])
{
$options += [
'transactionOptions' => []
];
return $this->connection->beginTransaction($options + [
'session' => $session->name(),
'database' => $session->info()['database']
]);
} | php | private function beginTransaction(Session $session, array $options = [])
{
$options += [
'transactionOptions' => []
];
return $this->connection->beginTransaction($options + [
'session' => $session->name(),
'database' => $session->info()['database']
]);
} | [
"private",
"function",
"beginTransaction",
"(",
"Session",
"$",
"session",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"options",
"+=",
"[",
"'transactionOptions'",
"=>",
"[",
"]",
"]",
";",
"return",
"$",
"this",
"->",
"connection",
"->",
"beginTransaction",
"(",
"$",
"options",
"+",
"[",
"'session'",
"=>",
"$",
"session",
"->",
"name",
"(",
")",
",",
"'database'",
"=>",
"$",
"session",
"->",
"info",
"(",
")",
"[",
"'database'",
"]",
"]",
")",
";",
"}"
] | Execute a service call to begin a transaction or snapshot.
@see https://cloud.google.com/spanner/reference/rpc/google.spanner.v1#google.spanner.v1.BeginTransactionRequest BeginTransactionRequest
@param Session $session The session to start the snapshot in.
@param array $options [optional] Configuration options.
@return array | [
"Execute",
"a",
"service",
"call",
"to",
"begin",
"a",
"transaction",
"or",
"snapshot",
"."
] | ff5030ffa1f12904565509a7bc24ecc0bd794a3e | https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Spanner/src/Operation.php#L674-L684 | train |
googleapis/google-cloud-php | Spanner/src/Operation.php | Operation.flattenKeySet | private function flattenKeySet(KeySet $keySet)
{
$keys = $keySet->keySetObject();
if (!empty($keys['ranges'])) {
foreach ($keys['ranges'] as $index => $range) {
foreach ($range as $type => $rangeKeys) {
$range[$type] = $this->mapper->encodeValuesAsSimpleType($rangeKeys);
}
$keys['ranges'][$index] = $range;
}
}
if (!empty($keys['keys'])) {
$keys['keys'] = $this->mapper->encodeValuesAsSimpleType($keys['keys'], true);
}
return $this->arrayFilterRemoveNull($keys);
} | php | private function flattenKeySet(KeySet $keySet)
{
$keys = $keySet->keySetObject();
if (!empty($keys['ranges'])) {
foreach ($keys['ranges'] as $index => $range) {
foreach ($range as $type => $rangeKeys) {
$range[$type] = $this->mapper->encodeValuesAsSimpleType($rangeKeys);
}
$keys['ranges'][$index] = $range;
}
}
if (!empty($keys['keys'])) {
$keys['keys'] = $this->mapper->encodeValuesAsSimpleType($keys['keys'], true);
}
return $this->arrayFilterRemoveNull($keys);
} | [
"private",
"function",
"flattenKeySet",
"(",
"KeySet",
"$",
"keySet",
")",
"{",
"$",
"keys",
"=",
"$",
"keySet",
"->",
"keySetObject",
"(",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"keys",
"[",
"'ranges'",
"]",
")",
")",
"{",
"foreach",
"(",
"$",
"keys",
"[",
"'ranges'",
"]",
"as",
"$",
"index",
"=>",
"$",
"range",
")",
"{",
"foreach",
"(",
"$",
"range",
"as",
"$",
"type",
"=>",
"$",
"rangeKeys",
")",
"{",
"$",
"range",
"[",
"$",
"type",
"]",
"=",
"$",
"this",
"->",
"mapper",
"->",
"encodeValuesAsSimpleType",
"(",
"$",
"rangeKeys",
")",
";",
"}",
"$",
"keys",
"[",
"'ranges'",
"]",
"[",
"$",
"index",
"]",
"=",
"$",
"range",
";",
"}",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"keys",
"[",
"'keys'",
"]",
")",
")",
"{",
"$",
"keys",
"[",
"'keys'",
"]",
"=",
"$",
"this",
"->",
"mapper",
"->",
"encodeValuesAsSimpleType",
"(",
"$",
"keys",
"[",
"'keys'",
"]",
",",
"true",
")",
";",
"}",
"return",
"$",
"this",
"->",
"arrayFilterRemoveNull",
"(",
"$",
"keys",
")",
";",
"}"
] | Convert a KeySet object to an API-ready array.
@param KeySet $keySet The keySet object.
@return array [KeySet](https://cloud.google.com/spanner/reference/rpc/google.spanner.v1#keyset) | [
"Convert",
"a",
"KeySet",
"object",
"to",
"an",
"API",
"-",
"ready",
"array",
"."
] | ff5030ffa1f12904565509a7bc24ecc0bd794a3e | https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Spanner/src/Operation.php#L692-L711 | train |
googleapis/google-cloud-php | Talent/src/V4beta1/Activity.php | Activity.setTeamMembers | public function setTeamMembers($var)
{
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING);
$this->team_members = $arr;
return $this;
} | php | public function setTeamMembers($var)
{
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING);
$this->team_members = $arr;
return $this;
} | [
"public",
"function",
"setTeamMembers",
"(",
"$",
"var",
")",
"{",
"$",
"arr",
"=",
"GPBUtil",
"::",
"checkRepeatedField",
"(",
"$",
"var",
",",
"\\",
"Google",
"\\",
"Protobuf",
"\\",
"Internal",
"\\",
"GPBType",
"::",
"STRING",
")",
";",
"$",
"this",
"->",
"team_members",
"=",
"$",
"arr",
";",
"return",
"$",
"this",
";",
"}"
] | Optional.
A list of team members involved in this activity.
Number of characters allowed is 100.
Generated from protobuf field <code>repeated string team_members = 6;</code>
@param string[]|\Google\Protobuf\Internal\RepeatedField $var
@return $this | [
"Optional",
".",
"A",
"list",
"of",
"team",
"members",
"involved",
"in",
"this",
"activity",
".",
"Number",
"of",
"characters",
"allowed",
"is",
"100",
"."
] | ff5030ffa1f12904565509a7bc24ecc0bd794a3e | https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Talent/src/V4beta1/Activity.php#L328-L334 | train |
googleapis/google-cloud-php | Logging/src/V2/LogSink.php | LogSink.setOutputVersionFormat | public function setOutputVersionFormat($var)
{
GPBUtil::checkEnum($var, \Google\Cloud\Logging\V2\LogSink_VersionFormat::class);
$this->output_version_format = $var;
return $this;
} | php | public function setOutputVersionFormat($var)
{
GPBUtil::checkEnum($var, \Google\Cloud\Logging\V2\LogSink_VersionFormat::class);
$this->output_version_format = $var;
return $this;
} | [
"public",
"function",
"setOutputVersionFormat",
"(",
"$",
"var",
")",
"{",
"GPBUtil",
"::",
"checkEnum",
"(",
"$",
"var",
",",
"\\",
"Google",
"\\",
"Cloud",
"\\",
"Logging",
"\\",
"V2",
"\\",
"LogSink_VersionFormat",
"::",
"class",
")",
";",
"$",
"this",
"->",
"output_version_format",
"=",
"$",
"var",
";",
"return",
"$",
"this",
";",
"}"
] | Deprecated. The log entry format to use for this sink's exported log
entries. The v2 format is used by default and cannot be changed.
Generated from protobuf field <code>.google.logging.v2.LogSink.VersionFormat output_version_format = 6 [deprecated = true];</code>
@param int $var
@return $this | [
"Deprecated",
".",
"The",
"log",
"entry",
"format",
"to",
"use",
"for",
"this",
"sink",
"s",
"exported",
"log",
"entries",
".",
"The",
"v2",
"format",
"is",
"used",
"by",
"default",
"and",
"cannot",
"be",
"changed",
"."
] | ff5030ffa1f12904565509a7bc24ecc0bd794a3e | https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Logging/src/V2/LogSink.php#L306-L312 | train |
googleapis/google-cloud-php | Talent/src/V4beta1/SearchJobsRequest.php | SearchJobsRequest.setJobQuery | public function setJobQuery($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\Talent\V4beta1\JobQuery::class);
$this->job_query = $var;
return $this;
} | php | public function setJobQuery($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\Talent\V4beta1\JobQuery::class);
$this->job_query = $var;
return $this;
} | [
"public",
"function",
"setJobQuery",
"(",
"$",
"var",
")",
"{",
"GPBUtil",
"::",
"checkMessage",
"(",
"$",
"var",
",",
"\\",
"Google",
"\\",
"Cloud",
"\\",
"Talent",
"\\",
"V4beta1",
"\\",
"JobQuery",
"::",
"class",
")",
";",
"$",
"this",
"->",
"job_query",
"=",
"$",
"var",
";",
"return",
"$",
"this",
";",
"}"
] | Optional.
Query used to search against jobs, such as keyword, location filters, etc.
Generated from protobuf field <code>.google.cloud.talent.v4beta1.JobQuery job_query = 4;</code>
@param \Google\Cloud\Talent\V4beta1\JobQuery $var
@return $this | [
"Optional",
".",
"Query",
"used",
"to",
"search",
"against",
"jobs",
"such",
"as",
"keyword",
"location",
"filters",
"etc",
"."
] | ff5030ffa1f12904565509a7bc24ecc0bd794a3e | https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Talent/src/V4beta1/SearchJobsRequest.php#L685-L691 | train |
googleapis/google-cloud-php | Vision/src/V1/Paragraph.php | Paragraph.setProperty | public function setProperty($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\Vision\V1\TextAnnotation_TextProperty::class);
$this->property = $var;
return $this;
} | php | public function setProperty($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\Vision\V1\TextAnnotation_TextProperty::class);
$this->property = $var;
return $this;
} | [
"public",
"function",
"setProperty",
"(",
"$",
"var",
")",
"{",
"GPBUtil",
"::",
"checkMessage",
"(",
"$",
"var",
",",
"\\",
"Google",
"\\",
"Cloud",
"\\",
"Vision",
"\\",
"V1",
"\\",
"TextAnnotation_TextProperty",
"::",
"class",
")",
";",
"$",
"this",
"->",
"property",
"=",
"$",
"var",
";",
"return",
"$",
"this",
";",
"}"
] | Additional information detected for the paragraph.
Generated from protobuf field <code>.google.cloud.vision.v1.TextAnnotation.TextProperty property = 1;</code>
@param \Google\Cloud\Vision\V1\TextAnnotation\TextProperty $var
@return $this | [
"Additional",
"information",
"detected",
"for",
"the",
"paragraph",
"."
] | ff5030ffa1f12904565509a7bc24ecc0bd794a3e | https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Vision/src/V1/Paragraph.php#L110-L116 | train |
googleapis/google-cloud-php | Vision/src/V1/Paragraph.php | Paragraph.setWords | public function setWords($var)
{
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Vision\V1\Word::class);
$this->words = $arr;
return $this;
} | php | public function setWords($var)
{
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Vision\V1\Word::class);
$this->words = $arr;
return $this;
} | [
"public",
"function",
"setWords",
"(",
"$",
"var",
")",
"{",
"$",
"arr",
"=",
"GPBUtil",
"::",
"checkRepeatedField",
"(",
"$",
"var",
",",
"\\",
"Google",
"\\",
"Protobuf",
"\\",
"Internal",
"\\",
"GPBType",
"::",
"MESSAGE",
",",
"\\",
"Google",
"\\",
"Cloud",
"\\",
"Vision",
"\\",
"V1",
"\\",
"Word",
"::",
"class",
")",
";",
"$",
"this",
"->",
"words",
"=",
"$",
"arr",
";",
"return",
"$",
"this",
";",
"}"
] | List of words in this paragraph.
Generated from protobuf field <code>repeated .google.cloud.vision.v1.Word words = 3;</code>
@param \Google\Cloud\Vision\V1\Word[]|\Google\Protobuf\Internal\RepeatedField $var
@return $this | [
"List",
"of",
"words",
"in",
"this",
"paragraph",
"."
] | ff5030ffa1f12904565509a7bc24ecc0bd794a3e | https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Vision/src/V1/Paragraph.php#L190-L196 | train |
googleapis/google-cloud-php | Iot/src/V1/ListDeviceConfigVersionsResponse.php | ListDeviceConfigVersionsResponse.setDeviceConfigs | public function setDeviceConfigs($var)
{
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Iot\V1\DeviceConfig::class);
$this->device_configs = $arr;
return $this;
} | php | public function setDeviceConfigs($var)
{
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Iot\V1\DeviceConfig::class);
$this->device_configs = $arr;
return $this;
} | [
"public",
"function",
"setDeviceConfigs",
"(",
"$",
"var",
")",
"{",
"$",
"arr",
"=",
"GPBUtil",
"::",
"checkRepeatedField",
"(",
"$",
"var",
",",
"\\",
"Google",
"\\",
"Protobuf",
"\\",
"Internal",
"\\",
"GPBType",
"::",
"MESSAGE",
",",
"\\",
"Google",
"\\",
"Cloud",
"\\",
"Iot",
"\\",
"V1",
"\\",
"DeviceConfig",
"::",
"class",
")",
";",
"$",
"this",
"->",
"device_configs",
"=",
"$",
"arr",
";",
"return",
"$",
"this",
";",
"}"
] | The device configuration for the last few versions. Versions are listed
in decreasing order, starting from the most recent one.
Generated from protobuf field <code>repeated .google.cloud.iot.v1.DeviceConfig device_configs = 1;</code>
@param \Google\Cloud\Iot\V1\DeviceConfig[]|\Google\Protobuf\Internal\RepeatedField $var
@return $this | [
"The",
"device",
"configuration",
"for",
"the",
"last",
"few",
"versions",
".",
"Versions",
"are",
"listed",
"in",
"decreasing",
"order",
"starting",
"from",
"the",
"most",
"recent",
"one",
"."
] | ff5030ffa1f12904565509a7bc24ecc0bd794a3e | https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Iot/src/V1/ListDeviceConfigVersionsResponse.php#L62-L68 | train |
googleapis/google-cloud-php | Dialogflow/src/V2/Intent/Message/Text.php | Text.setText | public function setText($var)
{
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING);
$this->text = $arr;
return $this;
} | php | public function setText($var)
{
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING);
$this->text = $arr;
return $this;
} | [
"public",
"function",
"setText",
"(",
"$",
"var",
")",
"{",
"$",
"arr",
"=",
"GPBUtil",
"::",
"checkRepeatedField",
"(",
"$",
"var",
",",
"\\",
"Google",
"\\",
"Protobuf",
"\\",
"Internal",
"\\",
"GPBType",
"::",
"STRING",
")",
";",
"$",
"this",
"->",
"text",
"=",
"$",
"arr",
";",
"return",
"$",
"this",
";",
"}"
] | Optional. The collection of the agent's responses.
Generated from protobuf field <code>repeated string text = 1;</code>
@param string[]|\Google\Protobuf\Internal\RepeatedField $var
@return $this | [
"Optional",
".",
"The",
"collection",
"of",
"the",
"agent",
"s",
"responses",
"."
] | ff5030ffa1f12904565509a7bc24ecc0bd794a3e | https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Dialogflow/src/V2/Intent/Message/Text.php#L58-L64 | train |
googleapis/google-cloud-php | Talent/src/V4beta1/JobServiceGrpcClient.php | JobServiceGrpcClient.GetJob | public function GetJob(\Google\Cloud\Talent\V4beta1\GetJobRequest $argument,
$metadata = [], $options = []) {
return $this->_simpleRequest('/google.cloud.talent.v4beta1.JobService/GetJob',
$argument,
['\Google\Cloud\Talent\V4beta1\Job', 'decode'],
$metadata, $options);
} | php | public function GetJob(\Google\Cloud\Talent\V4beta1\GetJobRequest $argument,
$metadata = [], $options = []) {
return $this->_simpleRequest('/google.cloud.talent.v4beta1.JobService/GetJob',
$argument,
['\Google\Cloud\Talent\V4beta1\Job', 'decode'],
$metadata, $options);
} | [
"public",
"function",
"GetJob",
"(",
"\\",
"Google",
"\\",
"Cloud",
"\\",
"Talent",
"\\",
"V4beta1",
"\\",
"GetJobRequest",
"$",
"argument",
",",
"$",
"metadata",
"=",
"[",
"]",
",",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"return",
"$",
"this",
"->",
"_simpleRequest",
"(",
"'/google.cloud.talent.v4beta1.JobService/GetJob'",
",",
"$",
"argument",
",",
"[",
"'\\Google\\Cloud\\Talent\\V4beta1\\Job'",
",",
"'decode'",
"]",
",",
"$",
"metadata",
",",
"$",
"options",
")",
";",
"}"
] | Retrieves the specified job, whose status is OPEN or recently EXPIRED
within the last 90 days.
@param \Google\Cloud\Talent\V4beta1\GetJobRequest $argument input argument
@param array $metadata metadata
@param array $options call options | [
"Retrieves",
"the",
"specified",
"job",
"whose",
"status",
"is",
"OPEN",
"or",
"recently",
"EXPIRED",
"within",
"the",
"last",
"90",
"days",
"."
] | ff5030ffa1f12904565509a7bc24ecc0bd794a3e | https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Talent/src/V4beta1/JobServiceGrpcClient.php#L60-L66 | train |
googleapis/google-cloud-php | Talent/src/V4beta1/JobServiceGrpcClient.php | JobServiceGrpcClient.UpdateJob | public function UpdateJob(\Google\Cloud\Talent\V4beta1\UpdateJobRequest $argument,
$metadata = [], $options = []) {
return $this->_simpleRequest('/google.cloud.talent.v4beta1.JobService/UpdateJob',
$argument,
['\Google\Cloud\Talent\V4beta1\Job', 'decode'],
$metadata, $options);
} | php | public function UpdateJob(\Google\Cloud\Talent\V4beta1\UpdateJobRequest $argument,
$metadata = [], $options = []) {
return $this->_simpleRequest('/google.cloud.talent.v4beta1.JobService/UpdateJob',
$argument,
['\Google\Cloud\Talent\V4beta1\Job', 'decode'],
$metadata, $options);
} | [
"public",
"function",
"UpdateJob",
"(",
"\\",
"Google",
"\\",
"Cloud",
"\\",
"Talent",
"\\",
"V4beta1",
"\\",
"UpdateJobRequest",
"$",
"argument",
",",
"$",
"metadata",
"=",
"[",
"]",
",",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"return",
"$",
"this",
"->",
"_simpleRequest",
"(",
"'/google.cloud.talent.v4beta1.JobService/UpdateJob'",
",",
"$",
"argument",
",",
"[",
"'\\Google\\Cloud\\Talent\\V4beta1\\Job'",
",",
"'decode'",
"]",
",",
"$",
"metadata",
",",
"$",
"options",
")",
";",
"}"
] | Updates specified job.
Typically, updated contents become visible in search results within 10
seconds, but it may take up to 5 minutes.
@param \Google\Cloud\Talent\V4beta1\UpdateJobRequest $argument input argument
@param array $metadata metadata
@param array $options call options | [
"Updates",
"specified",
"job",
"."
] | ff5030ffa1f12904565509a7bc24ecc0bd794a3e | https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Talent/src/V4beta1/JobServiceGrpcClient.php#L77-L83 | train |
googleapis/google-cloud-php | Talent/src/V4beta1/JobServiceGrpcClient.php | JobServiceGrpcClient.DeleteJob | public function DeleteJob(\Google\Cloud\Talent\V4beta1\DeleteJobRequest $argument,
$metadata = [], $options = []) {
return $this->_simpleRequest('/google.cloud.talent.v4beta1.JobService/DeleteJob',
$argument,
['\Google\Protobuf\GPBEmpty', 'decode'],
$metadata, $options);
} | php | public function DeleteJob(\Google\Cloud\Talent\V4beta1\DeleteJobRequest $argument,
$metadata = [], $options = []) {
return $this->_simpleRequest('/google.cloud.talent.v4beta1.JobService/DeleteJob',
$argument,
['\Google\Protobuf\GPBEmpty', 'decode'],
$metadata, $options);
} | [
"public",
"function",
"DeleteJob",
"(",
"\\",
"Google",
"\\",
"Cloud",
"\\",
"Talent",
"\\",
"V4beta1",
"\\",
"DeleteJobRequest",
"$",
"argument",
",",
"$",
"metadata",
"=",
"[",
"]",
",",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"return",
"$",
"this",
"->",
"_simpleRequest",
"(",
"'/google.cloud.talent.v4beta1.JobService/DeleteJob'",
",",
"$",
"argument",
",",
"[",
"'\\Google\\Protobuf\\GPBEmpty'",
",",
"'decode'",
"]",
",",
"$",
"metadata",
",",
"$",
"options",
")",
";",
"}"
] | Deletes the specified job.
Typically, the job becomes unsearchable within 10 seconds, but it may take
up to 5 minutes.
@param \Google\Cloud\Talent\V4beta1\DeleteJobRequest $argument input argument
@param array $metadata metadata
@param array $options call options | [
"Deletes",
"the",
"specified",
"job",
"."
] | ff5030ffa1f12904565509a7bc24ecc0bd794a3e | https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Talent/src/V4beta1/JobServiceGrpcClient.php#L94-L100 | train |
googleapis/google-cloud-php | Talent/src/V4beta1/JobServiceGrpcClient.php | JobServiceGrpcClient.ListJobs | public function ListJobs(\Google\Cloud\Talent\V4beta1\ListJobsRequest $argument,
$metadata = [], $options = []) {
return $this->_simpleRequest('/google.cloud.talent.v4beta1.JobService/ListJobs',
$argument,
['\Google\Cloud\Talent\V4beta1\ListJobsResponse', 'decode'],
$metadata, $options);
} | php | public function ListJobs(\Google\Cloud\Talent\V4beta1\ListJobsRequest $argument,
$metadata = [], $options = []) {
return $this->_simpleRequest('/google.cloud.talent.v4beta1.JobService/ListJobs',
$argument,
['\Google\Cloud\Talent\V4beta1\ListJobsResponse', 'decode'],
$metadata, $options);
} | [
"public",
"function",
"ListJobs",
"(",
"\\",
"Google",
"\\",
"Cloud",
"\\",
"Talent",
"\\",
"V4beta1",
"\\",
"ListJobsRequest",
"$",
"argument",
",",
"$",
"metadata",
"=",
"[",
"]",
",",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"return",
"$",
"this",
"->",
"_simpleRequest",
"(",
"'/google.cloud.talent.v4beta1.JobService/ListJobs'",
",",
"$",
"argument",
",",
"[",
"'\\Google\\Cloud\\Talent\\V4beta1\\ListJobsResponse'",
",",
"'decode'",
"]",
",",
"$",
"metadata",
",",
"$",
"options",
")",
";",
"}"
] | Lists jobs by filter.
@param \Google\Cloud\Talent\V4beta1\ListJobsRequest $argument input argument
@param array $metadata metadata
@param array $options call options | [
"Lists",
"jobs",
"by",
"filter",
"."
] | ff5030ffa1f12904565509a7bc24ecc0bd794a3e | https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Talent/src/V4beta1/JobServiceGrpcClient.php#L108-L114 | train |
googleapis/google-cloud-php | PubSub/src/V1/ListTopicSnapshotsResponse.php | ListTopicSnapshotsResponse.setSnapshots | public function setSnapshots($var)
{
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING);
$this->snapshots = $arr;
return $this;
} | php | public function setSnapshots($var)
{
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING);
$this->snapshots = $arr;
return $this;
} | [
"public",
"function",
"setSnapshots",
"(",
"$",
"var",
")",
"{",
"$",
"arr",
"=",
"GPBUtil",
"::",
"checkRepeatedField",
"(",
"$",
"var",
",",
"\\",
"Google",
"\\",
"Protobuf",
"\\",
"Internal",
"\\",
"GPBType",
"::",
"STRING",
")",
";",
"$",
"this",
"->",
"snapshots",
"=",
"$",
"arr",
";",
"return",
"$",
"this",
";",
"}"
] | The names of the snapshots that match the request.
Generated from protobuf field <code>repeated string snapshots = 1;</code>
@param string[]|\Google\Protobuf\Internal\RepeatedField $var
@return $this | [
"The",
"names",
"of",
"the",
"snapshots",
"that",
"match",
"the",
"request",
"."
] | ff5030ffa1f12904565509a7bc24ecc0bd794a3e | https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/PubSub/src/V1/ListTopicSnapshotsResponse.php#L70-L76 | train |
googleapis/google-cloud-php | Talent/src/V4beta1/CreateJobRequest.php | CreateJobRequest.setJob | public function setJob($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\Talent\V4beta1\Job::class);
$this->job = $var;
return $this;
} | php | public function setJob($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\Talent\V4beta1\Job::class);
$this->job = $var;
return $this;
} | [
"public",
"function",
"setJob",
"(",
"$",
"var",
")",
"{",
"GPBUtil",
"::",
"checkMessage",
"(",
"$",
"var",
",",
"\\",
"Google",
"\\",
"Cloud",
"\\",
"Talent",
"\\",
"V4beta1",
"\\",
"Job",
"::",
"class",
")",
";",
"$",
"this",
"->",
"job",
"=",
"$",
"var",
";",
"return",
"$",
"this",
";",
"}"
] | Required.
The Job to be created.
Generated from protobuf field <code>.google.cloud.talent.v4beta1.Job job = 2;</code>
@param \Google\Cloud\Talent\V4beta1\Job $var
@return $this | [
"Required",
".",
"The",
"Job",
"to",
"be",
"created",
"."
] | ff5030ffa1f12904565509a7bc24ecc0bd794a3e | https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Talent/src/V4beta1/CreateJobRequest.php#L117-L123 | train |
googleapis/google-cloud-php | Bigtable/src/Filter/Builder/KeyFilter.php | KeyFilter.sample | public function sample($probability)
{
if ($probability < 0) {
throw new \InvalidArgumentException('Probability must be positive');
}
if ($probability >= 1.0) {
throw new \InvalidArgumentException('Probability must be less than 1.0');
}
return new SimpleFilter(
(new RowFilter)->setRowSampleFilter($probability)
);
} | php | public function sample($probability)
{
if ($probability < 0) {
throw new \InvalidArgumentException('Probability must be positive');
}
if ($probability >= 1.0) {
throw new \InvalidArgumentException('Probability must be less than 1.0');
}
return new SimpleFilter(
(new RowFilter)->setRowSampleFilter($probability)
);
} | [
"public",
"function",
"sample",
"(",
"$",
"probability",
")",
"{",
"if",
"(",
"$",
"probability",
"<",
"0",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Probability must be positive'",
")",
";",
"}",
"if",
"(",
"$",
"probability",
">=",
"1.0",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Probability must be less than 1.0'",
")",
";",
"}",
"return",
"new",
"SimpleFilter",
"(",
"(",
"new",
"RowFilter",
")",
"->",
"setRowSampleFilter",
"(",
"$",
"probability",
")",
")",
";",
"}"
] | Matches all cells from a row with `probability`, and matches no cells
from the row with probability 1-`probability`.
Example:
```
$keyFilter = $builder->sample(.7);
```
@param float $probability The probability to filter by. Must be within
the range [0, 1], end points excluded.
@return SimpleFilter
@throws \InvalidArgumentException When the probability does not fall
within the acceptable range. | [
"Matches",
"all",
"cells",
"from",
"a",
"row",
"with",
"probability",
"and",
"matches",
"no",
"cells",
"from",
"the",
"row",
"with",
"probability",
"1",
"-",
"probability",
"."
] | ff5030ffa1f12904565509a7bc24ecc0bd794a3e | https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Bigtable/src/Filter/Builder/KeyFilter.php#L102-L114 | train |
googleapis/google-cloud-php | Talent/src/V4beta1/ListCompaniesResponse.php | ListCompaniesResponse.setCompanies | public function setCompanies($var)
{
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Talent\V4beta1\Company::class);
$this->companies = $arr;
return $this;
} | php | public function setCompanies($var)
{
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Talent\V4beta1\Company::class);
$this->companies = $arr;
return $this;
} | [
"public",
"function",
"setCompanies",
"(",
"$",
"var",
")",
"{",
"$",
"arr",
"=",
"GPBUtil",
"::",
"checkRepeatedField",
"(",
"$",
"var",
",",
"\\",
"Google",
"\\",
"Protobuf",
"\\",
"Internal",
"\\",
"GPBType",
"::",
"MESSAGE",
",",
"\\",
"Google",
"\\",
"Cloud",
"\\",
"Talent",
"\\",
"V4beta1",
"\\",
"Company",
"::",
"class",
")",
";",
"$",
"this",
"->",
"companies",
"=",
"$",
"arr",
";",
"return",
"$",
"this",
";",
"}"
] | Companies for the current client.
Generated from protobuf field <code>repeated .google.cloud.talent.v4beta1.Company companies = 1;</code>
@param \Google\Cloud\Talent\V4beta1\Company[]|\Google\Protobuf\Internal\RepeatedField $var
@return $this | [
"Companies",
"for",
"the",
"current",
"client",
"."
] | ff5030ffa1f12904565509a7bc24ecc0bd794a3e | https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Talent/src/V4beta1/ListCompaniesResponse.php#L77-L83 | train |
googleapis/google-cloud-php | Speech/src/V1/LongRunningRecognizeResponse.php | LongRunningRecognizeResponse.setResults | public function setResults($var)
{
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Speech\V1\SpeechRecognitionResult::class);
$this->results = $arr;
return $this;
} | php | public function setResults($var)
{
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Speech\V1\SpeechRecognitionResult::class);
$this->results = $arr;
return $this;
} | [
"public",
"function",
"setResults",
"(",
"$",
"var",
")",
"{",
"$",
"arr",
"=",
"GPBUtil",
"::",
"checkRepeatedField",
"(",
"$",
"var",
",",
"\\",
"Google",
"\\",
"Protobuf",
"\\",
"Internal",
"\\",
"GPBType",
"::",
"MESSAGE",
",",
"\\",
"Google",
"\\",
"Cloud",
"\\",
"Speech",
"\\",
"V1",
"\\",
"SpeechRecognitionResult",
"::",
"class",
")",
";",
"$",
"this",
"->",
"results",
"=",
"$",
"arr",
";",
"return",
"$",
"this",
";",
"}"
] | Output only. Sequential list of transcription results corresponding to
sequential portions of audio.
Generated from protobuf field <code>repeated .google.cloud.speech.v1.SpeechRecognitionResult results = 2;</code>
@param \Google\Cloud\Speech\V1\SpeechRecognitionResult[]|\Google\Protobuf\Internal\RepeatedField $var
@return $this | [
"Output",
"only",
".",
"Sequential",
"list",
"of",
"transcription",
"results",
"corresponding",
"to",
"sequential",
"portions",
"of",
"audio",
"."
] | ff5030ffa1f12904565509a7bc24ecc0bd794a3e | https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Speech/src/V1/LongRunningRecognizeResponse.php#L66-L72 | train |
googleapis/google-cloud-php | Bigtable/src/ChunkFormatter.php | ChunkFormatter.readAll | public function readAll()
{
// Chunks contain 3 properties:
// - rowContents: The row contents, this essentially is all data
// pertaining to a single family.
// - commitRow: This is a boolean telling us the all previous chunks for
// this row are ok to consume.
// - resetRow: This is a boolean telling us that all the previous chunks
// are to be discarded.
foreach ($this->stream as $readRowsResponse) {
foreach ($readRowsResponse->getChunks() as $chunk) {
switch ($this->state) {
case self::$rowStateEnum['NEW_ROW']:
$this->newRow($chunk);
break;
case self::$rowStateEnum['ROW_IN_PROGRESS']:
$this->rowInProgress($chunk);
break;
case self::$rowStateEnum['CELL_IN_PROGRESS']:
$this->cellInProgress($chunk);
break;
}
if ($chunk->getCommitRow()) {
$row = $this->row;
$rowKey = $this->rowKey;
$this->commit();
yield $rowKey => $row;
$this->numberOfRowsRead++;
}
}
}
$this->onStreamEnd();
} | php | public function readAll()
{
// Chunks contain 3 properties:
// - rowContents: The row contents, this essentially is all data
// pertaining to a single family.
// - commitRow: This is a boolean telling us the all previous chunks for
// this row are ok to consume.
// - resetRow: This is a boolean telling us that all the previous chunks
// are to be discarded.
foreach ($this->stream as $readRowsResponse) {
foreach ($readRowsResponse->getChunks() as $chunk) {
switch ($this->state) {
case self::$rowStateEnum['NEW_ROW']:
$this->newRow($chunk);
break;
case self::$rowStateEnum['ROW_IN_PROGRESS']:
$this->rowInProgress($chunk);
break;
case self::$rowStateEnum['CELL_IN_PROGRESS']:
$this->cellInProgress($chunk);
break;
}
if ($chunk->getCommitRow()) {
$row = $this->row;
$rowKey = $this->rowKey;
$this->commit();
yield $rowKey => $row;
$this->numberOfRowsRead++;
}
}
}
$this->onStreamEnd();
} | [
"public",
"function",
"readAll",
"(",
")",
"{",
"// Chunks contain 3 properties:",
"// - rowContents: The row contents, this essentially is all data",
"// pertaining to a single family.",
"// - commitRow: This is a boolean telling us the all previous chunks for",
"// this row are ok to consume.",
"// - resetRow: This is a boolean telling us that all the previous chunks",
"// are to be discarded.",
"foreach",
"(",
"$",
"this",
"->",
"stream",
"as",
"$",
"readRowsResponse",
")",
"{",
"foreach",
"(",
"$",
"readRowsResponse",
"->",
"getChunks",
"(",
")",
"as",
"$",
"chunk",
")",
"{",
"switch",
"(",
"$",
"this",
"->",
"state",
")",
"{",
"case",
"self",
"::",
"$",
"rowStateEnum",
"[",
"'NEW_ROW'",
"]",
":",
"$",
"this",
"->",
"newRow",
"(",
"$",
"chunk",
")",
";",
"break",
";",
"case",
"self",
"::",
"$",
"rowStateEnum",
"[",
"'ROW_IN_PROGRESS'",
"]",
":",
"$",
"this",
"->",
"rowInProgress",
"(",
"$",
"chunk",
")",
";",
"break",
";",
"case",
"self",
"::",
"$",
"rowStateEnum",
"[",
"'CELL_IN_PROGRESS'",
"]",
":",
"$",
"this",
"->",
"cellInProgress",
"(",
"$",
"chunk",
")",
";",
"break",
";",
"}",
"if",
"(",
"$",
"chunk",
"->",
"getCommitRow",
"(",
")",
")",
"{",
"$",
"row",
"=",
"$",
"this",
"->",
"row",
";",
"$",
"rowKey",
"=",
"$",
"this",
"->",
"rowKey",
";",
"$",
"this",
"->",
"commit",
"(",
")",
";",
"yield",
"$",
"rowKey",
"=>",
"$",
"row",
";",
"$",
"this",
"->",
"numberOfRowsRead",
"++",
";",
"}",
"}",
"}",
"$",
"this",
"->",
"onStreamEnd",
"(",
")",
";",
"}"
] | Formats the row's chunks into a friendly format.
Example:
```
$rows = $formatter->readAll();
```
@return \Generator
@throws BigtableDataOperationException If a malformed response is received. | [
"Formats",
"the",
"row",
"s",
"chunks",
"into",
"a",
"friendly",
"format",
"."
] | ff5030ffa1f12904565509a7bc24ecc0bd794a3e | https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Bigtable/src/ChunkFormatter.php#L158-L193 | train |
googleapis/google-cloud-php | Bigtable/src/ChunkFormatter.php | ChunkFormatter.validateNewRow | private function validateNewRow(CellChunk $chunk)
{
$this->isError(
$this->row,
'A new row cannot have existing state.'
);
$this->isError(
!$chunk->getRowKey(),
'A row key must be set.'
);
$this->isError(
$chunk->getResetRow(),
'A new row cannot be reset.'
);
$this->isError(
$this->prevRowKey &&
$this->prevRowKey === $chunk->getRowKey(),
'A commit happened but the same key followed.'
);
$this->isError(!$chunk->getFamilyName(), 'A family must be set.');
$this->isError(!$chunk->getQualifier(), 'A column qualifier must be set.');
$this->validateValueSizeAndCommitRow($chunk);
} | php | private function validateNewRow(CellChunk $chunk)
{
$this->isError(
$this->row,
'A new row cannot have existing state.'
);
$this->isError(
!$chunk->getRowKey(),
'A row key must be set.'
);
$this->isError(
$chunk->getResetRow(),
'A new row cannot be reset.'
);
$this->isError(
$this->prevRowKey &&
$this->prevRowKey === $chunk->getRowKey(),
'A commit happened but the same key followed.'
);
$this->isError(!$chunk->getFamilyName(), 'A family must be set.');
$this->isError(!$chunk->getQualifier(), 'A column qualifier must be set.');
$this->validateValueSizeAndCommitRow($chunk);
} | [
"private",
"function",
"validateNewRow",
"(",
"CellChunk",
"$",
"chunk",
")",
"{",
"$",
"this",
"->",
"isError",
"(",
"$",
"this",
"->",
"row",
",",
"'A new row cannot have existing state.'",
")",
";",
"$",
"this",
"->",
"isError",
"(",
"!",
"$",
"chunk",
"->",
"getRowKey",
"(",
")",
",",
"'A row key must be set.'",
")",
";",
"$",
"this",
"->",
"isError",
"(",
"$",
"chunk",
"->",
"getResetRow",
"(",
")",
",",
"'A new row cannot be reset.'",
")",
";",
"$",
"this",
"->",
"isError",
"(",
"$",
"this",
"->",
"prevRowKey",
"&&",
"$",
"this",
"->",
"prevRowKey",
"===",
"$",
"chunk",
"->",
"getRowKey",
"(",
")",
",",
"'A commit happened but the same key followed.'",
")",
";",
"$",
"this",
"->",
"isError",
"(",
"!",
"$",
"chunk",
"->",
"getFamilyName",
"(",
")",
",",
"'A family must be set.'",
")",
";",
"$",
"this",
"->",
"isError",
"(",
"!",
"$",
"chunk",
"->",
"getQualifier",
"(",
")",
",",
"'A column qualifier must be set.'",
")",
";",
"$",
"this",
"->",
"validateValueSizeAndCommitRow",
"(",
"$",
"chunk",
")",
";",
"}"
] | Validates state for a new row.
@param CellChunk $chunk The chunk to validate.
@return void
@throws BigtableDataOperationException | [
"Validates",
"state",
"for",
"a",
"new",
"row",
"."
] | ff5030ffa1f12904565509a7bc24ecc0bd794a3e | https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Bigtable/src/ChunkFormatter.php#L281-L303 | train |
googleapis/google-cloud-php | Bigtable/src/ChunkFormatter.php | ChunkFormatter.reset | private function reset()
{
$this->prevRowKey = null;
$this->rowKey = null;
$this->state = self::$rowStateEnum['NEW_ROW'];
$this->row = [];
} | php | private function reset()
{
$this->prevRowKey = null;
$this->rowKey = null;
$this->state = self::$rowStateEnum['NEW_ROW'];
$this->row = [];
} | [
"private",
"function",
"reset",
"(",
")",
"{",
"$",
"this",
"->",
"prevRowKey",
"=",
"null",
";",
"$",
"this",
"->",
"rowKey",
"=",
"null",
";",
"$",
"this",
"->",
"state",
"=",
"self",
"::",
"$",
"rowStateEnum",
"[",
"'NEW_ROW'",
"]",
";",
"$",
"this",
"->",
"row",
"=",
"[",
"]",
";",
"}"
] | Resets the state of formatter.
@return void | [
"Resets",
"the",
"state",
"of",
"formatter",
"."
] | ff5030ffa1f12904565509a7bc24ecc0bd794a3e | https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Bigtable/src/ChunkFormatter.php#L310-L316 | train |
googleapis/google-cloud-php | Bigtable/src/ChunkFormatter.php | ChunkFormatter.moveToNextState | private function moveToNextState(CellChunk $chunk)
{
$this->state = $chunk->getValueSize() > 0
? self::$rowStateEnum['CELL_IN_PROGRESS']
: self::$rowStateEnum['ROW_IN_PROGRESS'];
} | php | private function moveToNextState(CellChunk $chunk)
{
$this->state = $chunk->getValueSize() > 0
? self::$rowStateEnum['CELL_IN_PROGRESS']
: self::$rowStateEnum['ROW_IN_PROGRESS'];
} | [
"private",
"function",
"moveToNextState",
"(",
"CellChunk",
"$",
"chunk",
")",
"{",
"$",
"this",
"->",
"state",
"=",
"$",
"chunk",
"->",
"getValueSize",
"(",
")",
">",
"0",
"?",
"self",
"::",
"$",
"rowStateEnum",
"[",
"'CELL_IN_PROGRESS'",
"]",
":",
"self",
"::",
"$",
"rowStateEnum",
"[",
"'ROW_IN_PROGRESS'",
"]",
";",
"}"
] | Moves to the next state in processing.
@param CellChunk $chunk The chunk to analyze.
@return void | [
"Moves",
"to",
"the",
"next",
"state",
"in",
"processing",
"."
] | ff5030ffa1f12904565509a7bc24ecc0bd794a3e | https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Bigtable/src/ChunkFormatter.php#L336-L341 | train |
googleapis/google-cloud-php | Bigtable/src/ChunkFormatter.php | ChunkFormatter.newRow | private function newRow(CellChunk $chunk)
{
$this->validateNewRow($chunk);
$this->rowKey = $chunk->getRowKey();
$familyName = $chunk->getFamilyName()->getValue();
$qualifierName = $chunk->getQualifier()->getValue();
$labels = ($chunk->getLabels()->getIterator()->valid())
? implode(iterator_to_array($chunk->getLabels()->getIterator()))
: '';
$this->row[$familyName] = [];
$this->family = &$this->row[$familyName];
$this->family[$qualifierName] = [];
$this->qualifiers = &$this->family[$qualifierName];
$qualifier = [
'value' => $chunk->getValue(),
'labels' => $labels,
'timeStamp' => $chunk->getTimestampMicros()
];
$this->qualifierValue = &$qualifier['value'];
$this->qualifiers[] = &$qualifier;
$this->moveToNextState($chunk);
} | php | private function newRow(CellChunk $chunk)
{
$this->validateNewRow($chunk);
$this->rowKey = $chunk->getRowKey();
$familyName = $chunk->getFamilyName()->getValue();
$qualifierName = $chunk->getQualifier()->getValue();
$labels = ($chunk->getLabels()->getIterator()->valid())
? implode(iterator_to_array($chunk->getLabels()->getIterator()))
: '';
$this->row[$familyName] = [];
$this->family = &$this->row[$familyName];
$this->family[$qualifierName] = [];
$this->qualifiers = &$this->family[$qualifierName];
$qualifier = [
'value' => $chunk->getValue(),
'labels' => $labels,
'timeStamp' => $chunk->getTimestampMicros()
];
$this->qualifierValue = &$qualifier['value'];
$this->qualifiers[] = &$qualifier;
$this->moveToNextState($chunk);
} | [
"private",
"function",
"newRow",
"(",
"CellChunk",
"$",
"chunk",
")",
"{",
"$",
"this",
"->",
"validateNewRow",
"(",
"$",
"chunk",
")",
";",
"$",
"this",
"->",
"rowKey",
"=",
"$",
"chunk",
"->",
"getRowKey",
"(",
")",
";",
"$",
"familyName",
"=",
"$",
"chunk",
"->",
"getFamilyName",
"(",
")",
"->",
"getValue",
"(",
")",
";",
"$",
"qualifierName",
"=",
"$",
"chunk",
"->",
"getQualifier",
"(",
")",
"->",
"getValue",
"(",
")",
";",
"$",
"labels",
"=",
"(",
"$",
"chunk",
"->",
"getLabels",
"(",
")",
"->",
"getIterator",
"(",
")",
"->",
"valid",
"(",
")",
")",
"?",
"implode",
"(",
"iterator_to_array",
"(",
"$",
"chunk",
"->",
"getLabels",
"(",
")",
"->",
"getIterator",
"(",
")",
")",
")",
":",
"''",
";",
"$",
"this",
"->",
"row",
"[",
"$",
"familyName",
"]",
"=",
"[",
"]",
";",
"$",
"this",
"->",
"family",
"=",
"&",
"$",
"this",
"->",
"row",
"[",
"$",
"familyName",
"]",
";",
"$",
"this",
"->",
"family",
"[",
"$",
"qualifierName",
"]",
"=",
"[",
"]",
";",
"$",
"this",
"->",
"qualifiers",
"=",
"&",
"$",
"this",
"->",
"family",
"[",
"$",
"qualifierName",
"]",
";",
"$",
"qualifier",
"=",
"[",
"'value'",
"=>",
"$",
"chunk",
"->",
"getValue",
"(",
")",
",",
"'labels'",
"=>",
"$",
"labels",
",",
"'timeStamp'",
"=>",
"$",
"chunk",
"->",
"getTimestampMicros",
"(",
")",
"]",
";",
"$",
"this",
"->",
"qualifierValue",
"=",
"&",
"$",
"qualifier",
"[",
"'value'",
"]",
";",
"$",
"this",
"->",
"qualifiers",
"[",
"]",
"=",
"&",
"$",
"qualifier",
";",
"$",
"this",
"->",
"moveToNextState",
"(",
"$",
"chunk",
")",
";",
"}"
] | Processes a chunk when in the NEW_ROW state.
@param CellChunk $chunk The chunk to process.
@return void
@throws BigtableDataOperationException | [
"Processes",
"a",
"chunk",
"when",
"in",
"the",
"NEW_ROW",
"state",
"."
] | ff5030ffa1f12904565509a7bc24ecc0bd794a3e | https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Bigtable/src/ChunkFormatter.php#L350-L371 | train |
googleapis/google-cloud-php | Bigtable/src/ChunkFormatter.php | ChunkFormatter.validateResetRow | private function validateResetRow(CellChunk $chunk)
{
$this->isError(
$chunk->getResetRow() &&
(
$chunk->getRowKey() ||
$chunk->getQualifier() ||
$chunk->getValue() ||
$chunk->getTimestampMicros() > 0
),
'A reset should have no data.'
);
} | php | private function validateResetRow(CellChunk $chunk)
{
$this->isError(
$chunk->getResetRow() &&
(
$chunk->getRowKey() ||
$chunk->getQualifier() ||
$chunk->getValue() ||
$chunk->getTimestampMicros() > 0
),
'A reset should have no data.'
);
} | [
"private",
"function",
"validateResetRow",
"(",
"CellChunk",
"$",
"chunk",
")",
"{",
"$",
"this",
"->",
"isError",
"(",
"$",
"chunk",
"->",
"getResetRow",
"(",
")",
"&&",
"(",
"$",
"chunk",
"->",
"getRowKey",
"(",
")",
"||",
"$",
"chunk",
"->",
"getQualifier",
"(",
")",
"||",
"$",
"chunk",
"->",
"getValue",
"(",
")",
"||",
"$",
"chunk",
"->",
"getTimestampMicros",
"(",
")",
">",
"0",
")",
",",
"'A reset should have no data.'",
")",
";",
"}"
] | Validates the reset row condition for a chunk.
@param CellChunk $chunk chunk The chunk to validate.
@return void
@throws BigtableDataOperationException | [
"Validates",
"the",
"reset",
"row",
"condition",
"for",
"a",
"chunk",
"."
] | ff5030ffa1f12904565509a7bc24ecc0bd794a3e | https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Bigtable/src/ChunkFormatter.php#L380-L392 | train |
googleapis/google-cloud-php | Bigtable/src/ChunkFormatter.php | ChunkFormatter.validateRowInProgress | private function validateRowInProgress(CellChunk $chunk)
{
$this->validateResetRow($chunk);
$newRowKey = $chunk->getRowKey();
$this->isError(
$chunk->getRowKey() && $newRowKey !== $this->rowKey,
'A commit is required between row keys.'
);
$this->isError(
$chunk->getFamilyName() && !$chunk->getQualifier(),
'A qualifier must be specified.'
);
$this->validateValueSizeAndCommitRow($chunk);
} | php | private function validateRowInProgress(CellChunk $chunk)
{
$this->validateResetRow($chunk);
$newRowKey = $chunk->getRowKey();
$this->isError(
$chunk->getRowKey() && $newRowKey !== $this->rowKey,
'A commit is required between row keys.'
);
$this->isError(
$chunk->getFamilyName() && !$chunk->getQualifier(),
'A qualifier must be specified.'
);
$this->validateValueSizeAndCommitRow($chunk);
} | [
"private",
"function",
"validateRowInProgress",
"(",
"CellChunk",
"$",
"chunk",
")",
"{",
"$",
"this",
"->",
"validateResetRow",
"(",
"$",
"chunk",
")",
";",
"$",
"newRowKey",
"=",
"$",
"chunk",
"->",
"getRowKey",
"(",
")",
";",
"$",
"this",
"->",
"isError",
"(",
"$",
"chunk",
"->",
"getRowKey",
"(",
")",
"&&",
"$",
"newRowKey",
"!==",
"$",
"this",
"->",
"rowKey",
",",
"'A commit is required between row keys.'",
")",
";",
"$",
"this",
"->",
"isError",
"(",
"$",
"chunk",
"->",
"getFamilyName",
"(",
")",
"&&",
"!",
"$",
"chunk",
"->",
"getQualifier",
"(",
")",
",",
"'A qualifier must be specified.'",
")",
";",
"$",
"this",
"->",
"validateValueSizeAndCommitRow",
"(",
"$",
"chunk",
")",
";",
"}"
] | Validates state for a row in progress.
@param CellChunk $chunk The chunk to validate.
@return void
@throws BigtableDataOperationException | [
"Validates",
"state",
"for",
"a",
"row",
"in",
"progress",
"."
] | ff5030ffa1f12904565509a7bc24ecc0bd794a3e | https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Bigtable/src/ChunkFormatter.php#L401-L414 | train |
googleapis/google-cloud-php | Bigtable/src/ChunkFormatter.php | ChunkFormatter.rowInProgress | private function rowInProgress(CellChunk $chunk)
{
$this->validateRowInProgress($chunk);
if ($chunk->getResetRow()) {
$this->reset();
return;
}
if ($chunk->getFamilyName()) {
$familyName = $chunk->getFamilyName()->getValue();
if (!isset($this->row[$familyName])) {
$this->row[$familyName] = [];
}
$this->family = &$this->row[$familyName];
}
if ($chunk->getQualifier()) {
$qualifierName = $chunk->getQualifier()->getValue();
if (!isset($this->family[$qualifierName])) {
$this->family[$qualifierName] = [];
}
$this->qualifiers = &$this->family[$qualifierName];
}
$labels = ($chunk->getLabels()->getIterator()->valid())
? implode(iterator_to_array($chunk->getLabels()->getIterator()))
: '';
$qualifier = [
'value' => $chunk->getValue(),
'labels' => $labels,
'timeStamp' => $chunk->getTimestampMicros()
];
$this->qualifierValue = &$qualifier['value'];
$this->qualifiers[] = &$qualifier;
$this->moveToNextState($chunk);
} | php | private function rowInProgress(CellChunk $chunk)
{
$this->validateRowInProgress($chunk);
if ($chunk->getResetRow()) {
$this->reset();
return;
}
if ($chunk->getFamilyName()) {
$familyName = $chunk->getFamilyName()->getValue();
if (!isset($this->row[$familyName])) {
$this->row[$familyName] = [];
}
$this->family = &$this->row[$familyName];
}
if ($chunk->getQualifier()) {
$qualifierName = $chunk->getQualifier()->getValue();
if (!isset($this->family[$qualifierName])) {
$this->family[$qualifierName] = [];
}
$this->qualifiers = &$this->family[$qualifierName];
}
$labels = ($chunk->getLabels()->getIterator()->valid())
? implode(iterator_to_array($chunk->getLabels()->getIterator()))
: '';
$qualifier = [
'value' => $chunk->getValue(),
'labels' => $labels,
'timeStamp' => $chunk->getTimestampMicros()
];
$this->qualifierValue = &$qualifier['value'];
$this->qualifiers[] = &$qualifier;
$this->moveToNextState($chunk);
} | [
"private",
"function",
"rowInProgress",
"(",
"CellChunk",
"$",
"chunk",
")",
"{",
"$",
"this",
"->",
"validateRowInProgress",
"(",
"$",
"chunk",
")",
";",
"if",
"(",
"$",
"chunk",
"->",
"getResetRow",
"(",
")",
")",
"{",
"$",
"this",
"->",
"reset",
"(",
")",
";",
"return",
";",
"}",
"if",
"(",
"$",
"chunk",
"->",
"getFamilyName",
"(",
")",
")",
"{",
"$",
"familyName",
"=",
"$",
"chunk",
"->",
"getFamilyName",
"(",
")",
"->",
"getValue",
"(",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"row",
"[",
"$",
"familyName",
"]",
")",
")",
"{",
"$",
"this",
"->",
"row",
"[",
"$",
"familyName",
"]",
"=",
"[",
"]",
";",
"}",
"$",
"this",
"->",
"family",
"=",
"&",
"$",
"this",
"->",
"row",
"[",
"$",
"familyName",
"]",
";",
"}",
"if",
"(",
"$",
"chunk",
"->",
"getQualifier",
"(",
")",
")",
"{",
"$",
"qualifierName",
"=",
"$",
"chunk",
"->",
"getQualifier",
"(",
")",
"->",
"getValue",
"(",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"family",
"[",
"$",
"qualifierName",
"]",
")",
")",
"{",
"$",
"this",
"->",
"family",
"[",
"$",
"qualifierName",
"]",
"=",
"[",
"]",
";",
"}",
"$",
"this",
"->",
"qualifiers",
"=",
"&",
"$",
"this",
"->",
"family",
"[",
"$",
"qualifierName",
"]",
";",
"}",
"$",
"labels",
"=",
"(",
"$",
"chunk",
"->",
"getLabels",
"(",
")",
"->",
"getIterator",
"(",
")",
"->",
"valid",
"(",
")",
")",
"?",
"implode",
"(",
"iterator_to_array",
"(",
"$",
"chunk",
"->",
"getLabels",
"(",
")",
"->",
"getIterator",
"(",
")",
")",
")",
":",
"''",
";",
"$",
"qualifier",
"=",
"[",
"'value'",
"=>",
"$",
"chunk",
"->",
"getValue",
"(",
")",
",",
"'labels'",
"=>",
"$",
"labels",
",",
"'timeStamp'",
"=>",
"$",
"chunk",
"->",
"getTimestampMicros",
"(",
")",
"]",
";",
"$",
"this",
"->",
"qualifierValue",
"=",
"&",
"$",
"qualifier",
"[",
"'value'",
"]",
";",
"$",
"this",
"->",
"qualifiers",
"[",
"]",
"=",
"&",
"$",
"qualifier",
";",
"$",
"this",
"->",
"moveToNextState",
"(",
"$",
"chunk",
")",
";",
"}"
] | Process a chunk when in ROW_IN_PROGRESS state.
@param CellChunk $chunk The chunk to process.
@return void
@throws BigtableDataOperationException | [
"Process",
"a",
"chunk",
"when",
"in",
"ROW_IN_PROGRESS",
"state",
"."
] | ff5030ffa1f12904565509a7bc24ecc0bd794a3e | https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Bigtable/src/ChunkFormatter.php#L423-L455 | train |
googleapis/google-cloud-php | Bigtable/src/ChunkFormatter.php | ChunkFormatter.cellInProgress | private function cellInProgress(CellChunk $chunk)
{
$this->validateCellInProgress($chunk);
if ($chunk->getResetRow()) {
$this->reset();
return;
}
$this->qualifierValue = $this->qualifierValue . $chunk->getValue();
$this->moveToNextState($chunk);
} | php | private function cellInProgress(CellChunk $chunk)
{
$this->validateCellInProgress($chunk);
if ($chunk->getResetRow()) {
$this->reset();
return;
}
$this->qualifierValue = $this->qualifierValue . $chunk->getValue();
$this->moveToNextState($chunk);
} | [
"private",
"function",
"cellInProgress",
"(",
"CellChunk",
"$",
"chunk",
")",
"{",
"$",
"this",
"->",
"validateCellInProgress",
"(",
"$",
"chunk",
")",
";",
"if",
"(",
"$",
"chunk",
"->",
"getResetRow",
"(",
")",
")",
"{",
"$",
"this",
"->",
"reset",
"(",
")",
";",
"return",
";",
"}",
"$",
"this",
"->",
"qualifierValue",
"=",
"$",
"this",
"->",
"qualifierValue",
".",
"$",
"chunk",
"->",
"getValue",
"(",
")",
";",
"$",
"this",
"->",
"moveToNextState",
"(",
"$",
"chunk",
")",
";",
"}"
] | Process chunk when in CELL_IN_PROGRESS state.
@param CellChunk $chunk The chunk to process.
@return void
@throws BigtableDataOperationException | [
"Process",
"chunk",
"when",
"in",
"CELL_IN_PROGRESS",
"state",
"."
] | ff5030ffa1f12904565509a7bc24ecc0bd794a3e | https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Bigtable/src/ChunkFormatter.php#L477-L486 | train |
googleapis/google-cloud-php | Vision/src/V1/WebDetection.php | WebDetection.setWebEntities | public function setWebEntities($var)
{
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Vision\V1\WebDetection\WebEntity::class);
$this->web_entities = $arr;
return $this;
} | php | public function setWebEntities($var)
{
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Vision\V1\WebDetection\WebEntity::class);
$this->web_entities = $arr;
return $this;
} | [
"public",
"function",
"setWebEntities",
"(",
"$",
"var",
")",
"{",
"$",
"arr",
"=",
"GPBUtil",
"::",
"checkRepeatedField",
"(",
"$",
"var",
",",
"\\",
"Google",
"\\",
"Protobuf",
"\\",
"Internal",
"\\",
"GPBType",
"::",
"MESSAGE",
",",
"\\",
"Google",
"\\",
"Cloud",
"\\",
"Vision",
"\\",
"V1",
"\\",
"WebDetection",
"\\",
"WebEntity",
"::",
"class",
")",
";",
"$",
"this",
"->",
"web_entities",
"=",
"$",
"arr",
";",
"return",
"$",
"this",
";",
"}"
] | Deduced entities from similar images on the Internet.
Generated from protobuf field <code>repeated .google.cloud.vision.v1.WebDetection.WebEntity web_entities = 1;</code>
@param \Google\Cloud\Vision\V1\WebDetection\WebEntity[]|\Google\Protobuf\Internal\RepeatedField $var
@return $this | [
"Deduced",
"entities",
"from",
"similar",
"images",
"on",
"the",
"Internet",
"."
] | ff5030ffa1f12904565509a7bc24ecc0bd794a3e | https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Vision/src/V1/WebDetection.php#L106-L112 | train |
googleapis/google-cloud-php | Vision/src/V1/WebDetection.php | WebDetection.setFullMatchingImages | public function setFullMatchingImages($var)
{
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Vision\V1\WebDetection\WebImage::class);
$this->full_matching_images = $arr;
return $this;
} | php | public function setFullMatchingImages($var)
{
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Vision\V1\WebDetection\WebImage::class);
$this->full_matching_images = $arr;
return $this;
} | [
"public",
"function",
"setFullMatchingImages",
"(",
"$",
"var",
")",
"{",
"$",
"arr",
"=",
"GPBUtil",
"::",
"checkRepeatedField",
"(",
"$",
"var",
",",
"\\",
"Google",
"\\",
"Protobuf",
"\\",
"Internal",
"\\",
"GPBType",
"::",
"MESSAGE",
",",
"\\",
"Google",
"\\",
"Cloud",
"\\",
"Vision",
"\\",
"V1",
"\\",
"WebDetection",
"\\",
"WebImage",
"::",
"class",
")",
";",
"$",
"this",
"->",
"full_matching_images",
"=",
"$",
"arr",
";",
"return",
"$",
"this",
";",
"}"
] | Fully matching images from the Internet.
Can include resized copies of the query image.
Generated from protobuf field <code>repeated .google.cloud.vision.v1.WebDetection.WebImage full_matching_images = 2;</code>
@param \Google\Cloud\Vision\V1\WebDetection\WebImage[]|\Google\Protobuf\Internal\RepeatedField $var
@return $this | [
"Fully",
"matching",
"images",
"from",
"the",
"Internet",
".",
"Can",
"include",
"resized",
"copies",
"of",
"the",
"query",
"image",
"."
] | ff5030ffa1f12904565509a7bc24ecc0bd794a3e | https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Vision/src/V1/WebDetection.php#L134-L140 | train |
googleapis/google-cloud-php | Vision/src/V1/WebDetection.php | WebDetection.setPartialMatchingImages | public function setPartialMatchingImages($var)
{
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Vision\V1\WebDetection\WebImage::class);
$this->partial_matching_images = $arr;
return $this;
} | php | public function setPartialMatchingImages($var)
{
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Vision\V1\WebDetection\WebImage::class);
$this->partial_matching_images = $arr;
return $this;
} | [
"public",
"function",
"setPartialMatchingImages",
"(",
"$",
"var",
")",
"{",
"$",
"arr",
"=",
"GPBUtil",
"::",
"checkRepeatedField",
"(",
"$",
"var",
",",
"\\",
"Google",
"\\",
"Protobuf",
"\\",
"Internal",
"\\",
"GPBType",
"::",
"MESSAGE",
",",
"\\",
"Google",
"\\",
"Cloud",
"\\",
"Vision",
"\\",
"V1",
"\\",
"WebDetection",
"\\",
"WebImage",
"::",
"class",
")",
";",
"$",
"this",
"->",
"partial_matching_images",
"=",
"$",
"arr",
";",
"return",
"$",
"this",
";",
"}"
] | Partial matching images from the Internet.
Those images are similar enough to share some key-point features. For
example an original image will likely have partial matching for its crops.
Generated from protobuf field <code>repeated .google.cloud.vision.v1.WebDetection.WebImage partial_matching_images = 3;</code>
@param \Google\Cloud\Vision\V1\WebDetection\WebImage[]|\Google\Protobuf\Internal\RepeatedField $var
@return $this | [
"Partial",
"matching",
"images",
"from",
"the",
"Internet",
".",
"Those",
"images",
"are",
"similar",
"enough",
"to",
"share",
"some",
"key",
"-",
"point",
"features",
".",
"For",
"example",
"an",
"original",
"image",
"will",
"likely",
"have",
"partial",
"matching",
"for",
"its",
"crops",
"."
] | ff5030ffa1f12904565509a7bc24ecc0bd794a3e | https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Vision/src/V1/WebDetection.php#L164-L170 | train |
googleapis/google-cloud-php | Vision/src/V1/WebDetection.php | WebDetection.setPagesWithMatchingImages | public function setPagesWithMatchingImages($var)
{
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Vision\V1\WebDetection\WebPage::class);
$this->pages_with_matching_images = $arr;
return $this;
} | php | public function setPagesWithMatchingImages($var)
{
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Vision\V1\WebDetection\WebPage::class);
$this->pages_with_matching_images = $arr;
return $this;
} | [
"public",
"function",
"setPagesWithMatchingImages",
"(",
"$",
"var",
")",
"{",
"$",
"arr",
"=",
"GPBUtil",
"::",
"checkRepeatedField",
"(",
"$",
"var",
",",
"\\",
"Google",
"\\",
"Protobuf",
"\\",
"Internal",
"\\",
"GPBType",
"::",
"MESSAGE",
",",
"\\",
"Google",
"\\",
"Cloud",
"\\",
"Vision",
"\\",
"V1",
"\\",
"WebDetection",
"\\",
"WebPage",
"::",
"class",
")",
";",
"$",
"this",
"->",
"pages_with_matching_images",
"=",
"$",
"arr",
";",
"return",
"$",
"this",
";",
"}"
] | Web pages containing the matching images from the Internet.
Generated from protobuf field <code>repeated .google.cloud.vision.v1.WebDetection.WebPage pages_with_matching_images = 4;</code>
@param \Google\Cloud\Vision\V1\WebDetection\WebPage[]|\Google\Protobuf\Internal\RepeatedField $var
@return $this | [
"Web",
"pages",
"containing",
"the",
"matching",
"images",
"from",
"the",
"Internet",
"."
] | ff5030ffa1f12904565509a7bc24ecc0bd794a3e | https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Vision/src/V1/WebDetection.php#L190-L196 | train |
googleapis/google-cloud-php | Vision/src/V1/WebDetection.php | WebDetection.setVisuallySimilarImages | public function setVisuallySimilarImages($var)
{
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Vision\V1\WebDetection\WebImage::class);
$this->visually_similar_images = $arr;
return $this;
} | php | public function setVisuallySimilarImages($var)
{
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Vision\V1\WebDetection\WebImage::class);
$this->visually_similar_images = $arr;
return $this;
} | [
"public",
"function",
"setVisuallySimilarImages",
"(",
"$",
"var",
")",
"{",
"$",
"arr",
"=",
"GPBUtil",
"::",
"checkRepeatedField",
"(",
"$",
"var",
",",
"\\",
"Google",
"\\",
"Protobuf",
"\\",
"Internal",
"\\",
"GPBType",
"::",
"MESSAGE",
",",
"\\",
"Google",
"\\",
"Cloud",
"\\",
"Vision",
"\\",
"V1",
"\\",
"WebDetection",
"\\",
"WebImage",
"::",
"class",
")",
";",
"$",
"this",
"->",
"visually_similar_images",
"=",
"$",
"arr",
";",
"return",
"$",
"this",
";",
"}"
] | The visually similar image results.
Generated from protobuf field <code>repeated .google.cloud.vision.v1.WebDetection.WebImage visually_similar_images = 6;</code>
@param \Google\Cloud\Vision\V1\WebDetection\WebImage[]|\Google\Protobuf\Internal\RepeatedField $var
@return $this | [
"The",
"visually",
"similar",
"image",
"results",
"."
] | ff5030ffa1f12904565509a7bc24ecc0bd794a3e | https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Vision/src/V1/WebDetection.php#L216-L222 | train |
googleapis/google-cloud-php | Talent/src/V4beta1/Degree.php | Degree.setDegreeType | public function setDegreeType($var)
{
GPBUtil::checkEnum($var, \Google\Cloud\Talent\V4beta1\DegreeType::class);
$this->degree_type = $var;
return $this;
} | php | public function setDegreeType($var)
{
GPBUtil::checkEnum($var, \Google\Cloud\Talent\V4beta1\DegreeType::class);
$this->degree_type = $var;
return $this;
} | [
"public",
"function",
"setDegreeType",
"(",
"$",
"var",
")",
"{",
"GPBUtil",
"::",
"checkEnum",
"(",
"$",
"var",
",",
"\\",
"Google",
"\\",
"Cloud",
"\\",
"Talent",
"\\",
"V4beta1",
"\\",
"DegreeType",
"::",
"class",
")",
";",
"$",
"this",
"->",
"degree_type",
"=",
"$",
"var",
";",
"return",
"$",
"this",
";",
"}"
] | Optional.
ISCED degree type.
Generated from protobuf field <code>.google.cloud.talent.v4beta1.DegreeType degree_type = 1;</code>
@param int $var
@return $this | [
"Optional",
".",
"ISCED",
"degree",
"type",
"."
] | ff5030ffa1f12904565509a7bc24ecc0bd794a3e | https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Talent/src/V4beta1/Degree.php#L90-L96 | train |
googleapis/google-cloud-php | Talent/src/V4beta1/Degree.php | Degree.setFieldsOfStudy | public function setFieldsOfStudy($var)
{
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING);
$this->fields_of_study = $arr;
return $this;
} | php | public function setFieldsOfStudy($var)
{
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING);
$this->fields_of_study = $arr;
return $this;
} | [
"public",
"function",
"setFieldsOfStudy",
"(",
"$",
"var",
")",
"{",
"$",
"arr",
"=",
"GPBUtil",
"::",
"checkRepeatedField",
"(",
"$",
"var",
",",
"\\",
"Google",
"\\",
"Protobuf",
"\\",
"Internal",
"\\",
"GPBType",
"::",
"STRING",
")",
";",
"$",
"this",
"->",
"fields_of_study",
"=",
"$",
"arr",
";",
"return",
"$",
"this",
";",
"}"
] | Optional.
Fields of study for the degree.
For example, "Computer science", "engineering".
Number of characters allowed is 100.
Generated from protobuf field <code>repeated string fields_of_study = 3;</code>
@param string[]|\Google\Protobuf\Internal\RepeatedField $var
@return $this | [
"Optional",
".",
"Fields",
"of",
"study",
"for",
"the",
"degree",
".",
"For",
"example",
"Computer",
"science",
"engineering",
".",
"Number",
"of",
"characters",
"allowed",
"is",
"100",
"."
] | ff5030ffa1f12904565509a7bc24ecc0bd794a3e | https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Talent/src/V4beta1/Degree.php#L154-L160 | train |
googleapis/google-cloud-php | Datastore/src/Key.php | Key.pathElement | public function pathElement($kind, $identifier = null, array $options = [])
{
$options += [
'identifierType' => null
];
if (!empty($this->path) && $this->state() !== Key::STATE_NAMED) {
throw new InvalidArgumentException(
'Cannot add pathElement because the previous element is missing an id or name'
);
}
$pathElement = $this->normalizeElement($kind, $identifier, $options['identifierType']);
$this->path[] = $pathElement;
return $this;
} | php | public function pathElement($kind, $identifier = null, array $options = [])
{
$options += [
'identifierType' => null
];
if (!empty($this->path) && $this->state() !== Key::STATE_NAMED) {
throw new InvalidArgumentException(
'Cannot add pathElement because the previous element is missing an id or name'
);
}
$pathElement = $this->normalizeElement($kind, $identifier, $options['identifierType']);
$this->path[] = $pathElement;
return $this;
} | [
"public",
"function",
"pathElement",
"(",
"$",
"kind",
",",
"$",
"identifier",
"=",
"null",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"options",
"+=",
"[",
"'identifierType'",
"=>",
"null",
"]",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"path",
")",
"&&",
"$",
"this",
"->",
"state",
"(",
")",
"!==",
"Key",
"::",
"STATE_NAMED",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Cannot add pathElement because the previous element is missing an id or name'",
")",
";",
"}",
"$",
"pathElement",
"=",
"$",
"this",
"->",
"normalizeElement",
"(",
"$",
"kind",
",",
"$",
"identifier",
",",
"$",
"options",
"[",
"'identifierType'",
"]",
")",
";",
"$",
"this",
"->",
"path",
"[",
"]",
"=",
"$",
"pathElement",
";",
"return",
"$",
"this",
";",
"}"
] | Add a path element to the end of the Key path
If the previous pathElement is incomplete (has no name or ID specified),
an `InvalidArgumentException` will be thrown. Once an incomplete
pathElement is given, the key cannot be extended any further.
Example:
```
$key->pathElement('Person', 'Jane');
```
```
// In cases where the identifier type is ambiguous, you can choose the
// type to be used.
$key->pathElement('Robots', '1337', [
'identifierType' => Key::TYPE_NAME
]);
```
@see https://cloud.google.com/datastore/reference/rest/v1/Key#PathElement PathElement
@param string $kind The kind.
@param string|int $identifier [optional] The name or ID of the object.
@param array $options {
Configuration Options
@type string $identifierType [optional] If omitted, the type will be
determined internally. Setting this to either `Key::TYPE_ID` or
`Key::TYPE_NAME` will force the pathElement identifier type.
}
@return Key
@throws InvalidArgumentException | [
"Add",
"a",
"path",
"element",
"to",
"the",
"end",
"of",
"the",
"Key",
"path"
] | ff5030ffa1f12904565509a7bc24ecc0bd794a3e | https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Datastore/src/Key.php#L166-L183 | train |
googleapis/google-cloud-php | Datastore/src/Key.php | Key.ancestor | public function ancestor($kind, $identifier, array $options = [])
{
$options += [
'identifierType' => null
];
$pathElement = $this->normalizeElement($kind, $identifier, $options['identifierType']);
array_unshift($this->path, $pathElement);
return $this;
} | php | public function ancestor($kind, $identifier, array $options = [])
{
$options += [
'identifierType' => null
];
$pathElement = $this->normalizeElement($kind, $identifier, $options['identifierType']);
array_unshift($this->path, $pathElement);
return $this;
} | [
"public",
"function",
"ancestor",
"(",
"$",
"kind",
",",
"$",
"identifier",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"options",
"+=",
"[",
"'identifierType'",
"=>",
"null",
"]",
";",
"$",
"pathElement",
"=",
"$",
"this",
"->",
"normalizeElement",
"(",
"$",
"kind",
",",
"$",
"identifier",
",",
"$",
"options",
"[",
"'identifierType'",
"]",
")",
";",
"array_unshift",
"(",
"$",
"this",
"->",
"path",
",",
"$",
"pathElement",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Add a path element to the beginning of the Key path.
Example:
```
$key->ancestor('Person', 'Jane');
```
```
// In cases where the identifier type is ambiguous, you can choose the
// type to be used.
$key->ancestor('Robots', '1337', [
'identifierType' => Key::TYPE_NAME
]);
```
@see https://cloud.google.com/datastore/reference/rest/v1/Key#PathElement PathElement
@param string $kind The kind.
@param string|int $identifier The name or ID of the object.
@param array $options {
Configuration Options
@type string $identifierType [optional] If omitted, the type will be
determined internally. Setting this to either `Key::TYPE_ID` or
`Key::TYPE_NAME` will force the pathElement identifier type.
}
@return Key | [
"Add",
"a",
"path",
"element",
"to",
"the",
"beginning",
"of",
"the",
"Key",
"path",
"."
] | ff5030ffa1f12904565509a7bc24ecc0bd794a3e | https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Datastore/src/Key.php#L215-L226 | train |
googleapis/google-cloud-php | Datastore/src/Key.php | Key.ancestorKey | public function ancestorKey(Key $key)
{
if ($key->state() !== self::STATE_NAMED) {
throw new InvalidArgumentException('Cannot use an incomplete key as an ancestor');
}
$path = $key->path();
$this->path = array_merge($path, $this->path);
return $this;
} | php | public function ancestorKey(Key $key)
{
if ($key->state() !== self::STATE_NAMED) {
throw new InvalidArgumentException('Cannot use an incomplete key as an ancestor');
}
$path = $key->path();
$this->path = array_merge($path, $this->path);
return $this;
} | [
"public",
"function",
"ancestorKey",
"(",
"Key",
"$",
"key",
")",
"{",
"if",
"(",
"$",
"key",
"->",
"state",
"(",
")",
"!==",
"self",
"::",
"STATE_NAMED",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Cannot use an incomplete key as an ancestor'",
")",
";",
"}",
"$",
"path",
"=",
"$",
"key",
"->",
"path",
"(",
")",
";",
"$",
"this",
"->",
"path",
"=",
"array_merge",
"(",
"$",
"path",
",",
"$",
"this",
"->",
"path",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Use another Key's path as the current Key's ancestor
Given key path will be prepended to any path elements on the current key.
Example:
```
$parent = $datastore->key('Person', 'Dad');
$key->ancestorKey($parent);
```
@param Key $key The ancestor Key.
@return Key
@throws InvalidArgumentException | [
"Use",
"another",
"Key",
"s",
"path",
"as",
"the",
"current",
"Key",
"s",
"ancestor"
] | ff5030ffa1f12904565509a7bc24ecc0bd794a3e | https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Datastore/src/Key.php#L243-L254 | train |
googleapis/google-cloud-php | Datastore/src/Key.php | Key.state | public function state()
{
$end = $this->pathEnd();
return (isset($end['id']) || isset($end['name']))
? self::STATE_NAMED
: self::STATE_INCOMPLETE;
} | php | public function state()
{
$end = $this->pathEnd();
return (isset($end['id']) || isset($end['name']))
? self::STATE_NAMED
: self::STATE_INCOMPLETE;
} | [
"public",
"function",
"state",
"(",
")",
"{",
"$",
"end",
"=",
"$",
"this",
"->",
"pathEnd",
"(",
")",
";",
"return",
"(",
"isset",
"(",
"$",
"end",
"[",
"'id'",
"]",
")",
"||",
"isset",
"(",
"$",
"end",
"[",
"'name'",
"]",
")",
")",
"?",
"self",
"::",
"STATE_NAMED",
":",
"self",
"::",
"STATE_INCOMPLETE",
";",
"}"
] | Check if the Key is considered Named or Incomplete.
Use `Key::STATE_NAMED` and `Key::STATE_INCOMPLETE` to check value.
Example:
```
// An incomplete key does not have an ID on its last path element.
$key = $datastore->key('parent', 1234)
->pathElement('child');
if ($key->state() === Key::STATE_INCOMPLETE) {
echo 'Key is incomplete!';
}
```
```
// A named key has a kind and an identifier on each path element.
$key = $datastore->key('parent', 1234)
->pathElement('child', 4321);
if ($key->state() === Key::STATE_NAMED) {
echo 'Key is named!';
}
```
@return bool | [
"Check",
"if",
"the",
"Key",
"is",
"considered",
"Named",
"or",
"Incomplete",
"."
] | ff5030ffa1f12904565509a7bc24ecc0bd794a3e | https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Datastore/src/Key.php#L284-L290 | train |
googleapis/google-cloud-php | Datastore/src/Key.php | Key.setLastElementIdentifier | public function setLastElementIdentifier($value, $type = Key::TYPE_ID)
{
$end = $this->pathEnd();
$end[$type] = (string) $value;
$elements = array_keys($this->path);
$lastElement = end($elements);
$this->path[$lastElement] = $end;
} | php | public function setLastElementIdentifier($value, $type = Key::TYPE_ID)
{
$end = $this->pathEnd();
$end[$type] = (string) $value;
$elements = array_keys($this->path);
$lastElement = end($elements);
$this->path[$lastElement] = $end;
} | [
"public",
"function",
"setLastElementIdentifier",
"(",
"$",
"value",
",",
"$",
"type",
"=",
"Key",
"::",
"TYPE_ID",
")",
"{",
"$",
"end",
"=",
"$",
"this",
"->",
"pathEnd",
"(",
")",
";",
"$",
"end",
"[",
"$",
"type",
"]",
"=",
"(",
"string",
")",
"$",
"value",
";",
"$",
"elements",
"=",
"array_keys",
"(",
"$",
"this",
"->",
"path",
")",
";",
"$",
"lastElement",
"=",
"end",
"(",
"$",
"elements",
")",
";",
"$",
"this",
"->",
"path",
"[",
"$",
"lastElement",
"]",
"=",
"$",
"end",
";",
"}"
] | Set the value of the last path element in a Key
This method is used internally when IDs are allocated to existing instances
of a Key. It should not generally be used externally.
Example:
```
$key = $datastore->key('Person');
$key->setLastElementIdentifier('Bob', Key::TYPE_NAME);
```
@param string $value The value of the ID or Name.
@param string $type [optional] 'id' or 'name'. **Defaults to** `"id"`.
@return void
@access private | [
"Set",
"the",
"value",
"of",
"the",
"last",
"path",
"element",
"in",
"a",
"Key"
] | ff5030ffa1f12904565509a7bc24ecc0bd794a3e | https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Datastore/src/Key.php#L309-L318 | train |
googleapis/google-cloud-php | Datastore/src/Key.php | Key.pathEndIdentifier | public function pathEndIdentifier()
{
$end = $this->pathEnd();
if (isset($end['id'])) {
return $end['id'];
}
if (isset($end['name'])) {
return $end['name'];
}
return null;
} | php | public function pathEndIdentifier()
{
$end = $this->pathEnd();
if (isset($end['id'])) {
return $end['id'];
}
if (isset($end['name'])) {
return $end['name'];
}
return null;
} | [
"public",
"function",
"pathEndIdentifier",
"(",
")",
"{",
"$",
"end",
"=",
"$",
"this",
"->",
"pathEnd",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"end",
"[",
"'id'",
"]",
")",
")",
"{",
"return",
"$",
"end",
"[",
"'id'",
"]",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"end",
"[",
"'name'",
"]",
")",
")",
"{",
"return",
"$",
"end",
"[",
"'name'",
"]",
";",
"}",
"return",
"null",
";",
"}"
] | Get the last pathElement identifier.
If the key is incomplete, returns `null`.
Example:
```
$lastPathElementIndentifier = $key->pathEndIdentifier();
```
@return string|int|null | [
"Get",
"the",
"last",
"pathElement",
"identifier",
"."
] | ff5030ffa1f12904565509a7bc24ecc0bd794a3e | https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Datastore/src/Key.php#L365-L378 | train |
googleapis/google-cloud-php | Datastore/src/Key.php | Key.pathEndIdentifierType | public function pathEndIdentifierType()
{
$end = $this->pathEnd();
if (isset($end['id'])) {
return self::TYPE_ID;
}
if (isset($end['name'])) {
return self::TYPE_NAME;
}
return null;
} | php | public function pathEndIdentifierType()
{
$end = $this->pathEnd();
if (isset($end['id'])) {
return self::TYPE_ID;
}
if (isset($end['name'])) {
return self::TYPE_NAME;
}
return null;
} | [
"public",
"function",
"pathEndIdentifierType",
"(",
")",
"{",
"$",
"end",
"=",
"$",
"this",
"->",
"pathEnd",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"end",
"[",
"'id'",
"]",
")",
")",
"{",
"return",
"self",
"::",
"TYPE_ID",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"end",
"[",
"'name'",
"]",
")",
")",
"{",
"return",
"self",
"::",
"TYPE_NAME",
";",
"}",
"return",
"null",
";",
"}"
] | Get the last pathElement identifier type.
If the key is incomplete, returns `null`.
Example:
```
$lastPathElementIdentifierType = $key->pathEndIdentifierType();
```
@return string|null | [
"Get",
"the",
"last",
"pathElement",
"identifier",
"type",
"."
] | ff5030ffa1f12904565509a7bc24ecc0bd794a3e | https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Datastore/src/Key.php#L392-L405 | train |
googleapis/google-cloud-php | Datastore/src/Key.php | Key.normalizeElement | private function normalizeElement($kind, $identifier, $identifierType)
{
$identifierType = $this->determineIdentifierType($identifier, $identifierType);
$element = [];
$element['kind'] = $kind;
if (!is_null($identifier)) {
$element[$identifierType] = $identifier;
}
return $element;
} | php | private function normalizeElement($kind, $identifier, $identifierType)
{
$identifierType = $this->determineIdentifierType($identifier, $identifierType);
$element = [];
$element['kind'] = $kind;
if (!is_null($identifier)) {
$element[$identifierType] = $identifier;
}
return $element;
} | [
"private",
"function",
"normalizeElement",
"(",
"$",
"kind",
",",
"$",
"identifier",
",",
"$",
"identifierType",
")",
"{",
"$",
"identifierType",
"=",
"$",
"this",
"->",
"determineIdentifierType",
"(",
"$",
"identifier",
",",
"$",
"identifierType",
")",
";",
"$",
"element",
"=",
"[",
"]",
";",
"$",
"element",
"[",
"'kind'",
"]",
"=",
"$",
"kind",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"identifier",
")",
")",
"{",
"$",
"element",
"[",
"$",
"identifierType",
"]",
"=",
"$",
"identifier",
";",
"}",
"return",
"$",
"element",
";",
"}"
] | Determine the identifier type and return the valid pathElement
@param string $kind the kind.
@param mixed $identifier The ID or name.
@param string $identifierType Either `id` or `name`.
@return array | [
"Determine",
"the",
"identifier",
"type",
"and",
"return",
"the",
"valid",
"pathElement"
] | ff5030ffa1f12904565509a7bc24ecc0bd794a3e | https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Datastore/src/Key.php#L437-L449 | train |
googleapis/google-cloud-php | Datastore/src/Key.php | Key.determineIdentifierType | private function determineIdentifierType($identifier, $identifierType)
{
$allowedTypes = [self::TYPE_ID, self::TYPE_NAME];
if (!is_null($identifierType) && in_array($identifierType, $allowedTypes)) {
return $identifierType;
} elseif (!is_null($identifierType)) {
throw new InvalidArgumentException(sprintf(
'Invalid identifier type %s',
$identifierType
));
}
if (is_numeric($identifier)) {
return self::TYPE_ID;
}
return self::TYPE_NAME;
} | php | private function determineIdentifierType($identifier, $identifierType)
{
$allowedTypes = [self::TYPE_ID, self::TYPE_NAME];
if (!is_null($identifierType) && in_array($identifierType, $allowedTypes)) {
return $identifierType;
} elseif (!is_null($identifierType)) {
throw new InvalidArgumentException(sprintf(
'Invalid identifier type %s',
$identifierType
));
}
if (is_numeric($identifier)) {
return self::TYPE_ID;
}
return self::TYPE_NAME;
} | [
"private",
"function",
"determineIdentifierType",
"(",
"$",
"identifier",
",",
"$",
"identifierType",
")",
"{",
"$",
"allowedTypes",
"=",
"[",
"self",
"::",
"TYPE_ID",
",",
"self",
"::",
"TYPE_NAME",
"]",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"identifierType",
")",
"&&",
"in_array",
"(",
"$",
"identifierType",
",",
"$",
"allowedTypes",
")",
")",
"{",
"return",
"$",
"identifierType",
";",
"}",
"elseif",
"(",
"!",
"is_null",
"(",
"$",
"identifierType",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'Invalid identifier type %s'",
",",
"$",
"identifierType",
")",
")",
";",
"}",
"if",
"(",
"is_numeric",
"(",
"$",
"identifier",
")",
")",
"{",
"return",
"self",
"::",
"TYPE_ID",
";",
"}",
"return",
"self",
"::",
"TYPE_NAME",
";",
"}"
] | Determine whether the given identifier is an ID or a Name
@param mixed $identifier The given value.
@param string|null $identifierType If not null and allowed, this will be
used as the type. If null, type will be inferred.
@return string
@throws InvalidArgumentException | [
"Determine",
"whether",
"the",
"given",
"identifier",
"is",
"an",
"ID",
"or",
"a",
"Name"
] | ff5030ffa1f12904565509a7bc24ecc0bd794a3e | https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Datastore/src/Key.php#L460-L478 | train |
googleapis/google-cloud-php | Datastore/src/Key.php | Key.normalizePath | private function normalizePath(array $path)
{
// If the path is associative (i.e. not nested), wrap it up.
if ($this->isAssoc($path)) {
$path = [$path];
}
$res = [];
foreach ($path as $index => $pathElement) {
if (!isset($pathElement['kind'])) {
throw new InvalidArgumentException('Each path element must contain a kind.');
}
$incomplete = (!isset($pathElement['id']) && !isset($pathElement['name']));
if ($index < count($path) -1 && $incomplete) {
throw new InvalidArgumentException(
'Only the final pathElement may omit a name or ID.'
);
}
if (isset($pathElement['id']) && !is_string($pathElement['id'])) {
$pathElement['id'] = (string) $pathElement['id'];
}
$res[] = $pathElement;
}
return $res;
} | php | private function normalizePath(array $path)
{
// If the path is associative (i.e. not nested), wrap it up.
if ($this->isAssoc($path)) {
$path = [$path];
}
$res = [];
foreach ($path as $index => $pathElement) {
if (!isset($pathElement['kind'])) {
throw new InvalidArgumentException('Each path element must contain a kind.');
}
$incomplete = (!isset($pathElement['id']) && !isset($pathElement['name']));
if ($index < count($path) -1 && $incomplete) {
throw new InvalidArgumentException(
'Only the final pathElement may omit a name or ID.'
);
}
if (isset($pathElement['id']) && !is_string($pathElement['id'])) {
$pathElement['id'] = (string) $pathElement['id'];
}
$res[] = $pathElement;
}
return $res;
} | [
"private",
"function",
"normalizePath",
"(",
"array",
"$",
"path",
")",
"{",
"// If the path is associative (i.e. not nested), wrap it up.",
"if",
"(",
"$",
"this",
"->",
"isAssoc",
"(",
"$",
"path",
")",
")",
"{",
"$",
"path",
"=",
"[",
"$",
"path",
"]",
";",
"}",
"$",
"res",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"path",
"as",
"$",
"index",
"=>",
"$",
"pathElement",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"pathElement",
"[",
"'kind'",
"]",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Each path element must contain a kind.'",
")",
";",
"}",
"$",
"incomplete",
"=",
"(",
"!",
"isset",
"(",
"$",
"pathElement",
"[",
"'id'",
"]",
")",
"&&",
"!",
"isset",
"(",
"$",
"pathElement",
"[",
"'name'",
"]",
")",
")",
";",
"if",
"(",
"$",
"index",
"<",
"count",
"(",
"$",
"path",
")",
"-",
"1",
"&&",
"$",
"incomplete",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Only the final pathElement may omit a name or ID.'",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"pathElement",
"[",
"'id'",
"]",
")",
"&&",
"!",
"is_string",
"(",
"$",
"pathElement",
"[",
"'id'",
"]",
")",
")",
"{",
"$",
"pathElement",
"[",
"'id'",
"]",
"=",
"(",
"string",
")",
"$",
"pathElement",
"[",
"'id'",
"]",
";",
"}",
"$",
"res",
"[",
"]",
"=",
"$",
"pathElement",
";",
"}",
"return",
"$",
"res",
";",
"}"
] | Normalize the internal representation of a path
@param array $path
@return array
@throws InvalidArgumentException | [
"Normalize",
"the",
"internal",
"representation",
"of",
"a",
"path"
] | ff5030ffa1f12904565509a7bc24ecc0bd794a3e | https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Datastore/src/Key.php#L487-L515 | train |
googleapis/google-cloud-php | Talent/src/V4beta1/Address.php | Address.setUsage | public function setUsage($var)
{
GPBUtil::checkEnum($var, \Google\Cloud\Talent\V4beta1\ContactInfoUsage::class);
$this->usage = $var;
return $this;
} | php | public function setUsage($var)
{
GPBUtil::checkEnum($var, \Google\Cloud\Talent\V4beta1\ContactInfoUsage::class);
$this->usage = $var;
return $this;
} | [
"public",
"function",
"setUsage",
"(",
"$",
"var",
")",
"{",
"GPBUtil",
"::",
"checkEnum",
"(",
"$",
"var",
",",
"\\",
"Google",
"\\",
"Cloud",
"\\",
"Talent",
"\\",
"V4beta1",
"\\",
"ContactInfoUsage",
"::",
"class",
")",
";",
"$",
"this",
"->",
"usage",
"=",
"$",
"var",
";",
"return",
"$",
"this",
";",
"}"
] | Optional.
The usage of the address. For example, SCHOOL, WORK, PERSONAL.
Generated from protobuf field <code>.google.cloud.talent.v4beta1.ContactInfoUsage usage = 1;</code>
@param int $var
@return $this | [
"Optional",
".",
"The",
"usage",
"of",
"the",
"address",
".",
"For",
"example",
"SCHOOL",
"WORK",
"PERSONAL",
"."
] | ff5030ffa1f12904565509a7bc24ecc0bd794a3e | https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Talent/src/V4beta1/Address.php#L83-L89 | train |
googleapis/google-cloud-php | Core/src/Batch/BatchDaemon.php | BatchDaemon.run | public function run()
{
$this->setupSignalHandlers();
$procs = [];
while (true) {
$jobs = $this->runner->getJobs();
foreach ($jobs as $job) {
if (! array_key_exists($job->identifier(), $procs)) {
$procs[$job->identifier()] = [];
}
while (count($procs[$job->identifier()]) > $job->numWorkers()) {
// Stopping an excessive child.
echo 'Stopping an excessive child.' . PHP_EOL;
$proc = array_pop($procs[$job->identifier()]);
$status = proc_get_status($proc);
// Keep sending SIGTERM until the child exits.
while ($status['running'] === true) {
@proc_terminate($proc);
usleep(50000);
$status = proc_get_status($proc);
}
@proc_close($proc);
}
for ($i = 0; $i < $job->numWorkers(); $i++) {
$needStart = false;
if (array_key_exists($i, $procs[$job->identifier()])) {
$status = proc_get_status($procs[$job->identifier()][$i]);
if ($status['running'] !== true) {
$needStart = true;
}
} else {
$needStart = true;
}
if ($needStart) {
echo 'Starting a child.' . PHP_EOL;
$procs[$job->identifier()][$i] = proc_open(
sprintf('%s %d', $this->command, $job->id()),
$this->descriptorSpec,
$pipes
);
}
}
}
usleep(1000000); // Reload the config after 1 second
pcntl_signal_dispatch();
if ($this->shutdown) {
echo 'Shutting down, waiting for the children' . PHP_EOL;
foreach ($procs as $k => $v) {
foreach ($v as $proc) {
$status = proc_get_status($proc);
// Keep sending SIGTERM until the child exits.
while ($status['running'] === true) {
@proc_terminate($proc);
usleep(50000);
$status = proc_get_status($proc);
}
@proc_close($proc);
}
}
echo 'BatchDaemon exiting' . PHP_EOL;
exit;
}
// Reload the config
$this->runner->loadConfig();
}
} | php | public function run()
{
$this->setupSignalHandlers();
$procs = [];
while (true) {
$jobs = $this->runner->getJobs();
foreach ($jobs as $job) {
if (! array_key_exists($job->identifier(), $procs)) {
$procs[$job->identifier()] = [];
}
while (count($procs[$job->identifier()]) > $job->numWorkers()) {
// Stopping an excessive child.
echo 'Stopping an excessive child.' . PHP_EOL;
$proc = array_pop($procs[$job->identifier()]);
$status = proc_get_status($proc);
// Keep sending SIGTERM until the child exits.
while ($status['running'] === true) {
@proc_terminate($proc);
usleep(50000);
$status = proc_get_status($proc);
}
@proc_close($proc);
}
for ($i = 0; $i < $job->numWorkers(); $i++) {
$needStart = false;
if (array_key_exists($i, $procs[$job->identifier()])) {
$status = proc_get_status($procs[$job->identifier()][$i]);
if ($status['running'] !== true) {
$needStart = true;
}
} else {
$needStart = true;
}
if ($needStart) {
echo 'Starting a child.' . PHP_EOL;
$procs[$job->identifier()][$i] = proc_open(
sprintf('%s %d', $this->command, $job->id()),
$this->descriptorSpec,
$pipes
);
}
}
}
usleep(1000000); // Reload the config after 1 second
pcntl_signal_dispatch();
if ($this->shutdown) {
echo 'Shutting down, waiting for the children' . PHP_EOL;
foreach ($procs as $k => $v) {
foreach ($v as $proc) {
$status = proc_get_status($proc);
// Keep sending SIGTERM until the child exits.
while ($status['running'] === true) {
@proc_terminate($proc);
usleep(50000);
$status = proc_get_status($proc);
}
@proc_close($proc);
}
}
echo 'BatchDaemon exiting' . PHP_EOL;
exit;
}
// Reload the config
$this->runner->loadConfig();
}
} | [
"public",
"function",
"run",
"(",
")",
"{",
"$",
"this",
"->",
"setupSignalHandlers",
"(",
")",
";",
"$",
"procs",
"=",
"[",
"]",
";",
"while",
"(",
"true",
")",
"{",
"$",
"jobs",
"=",
"$",
"this",
"->",
"runner",
"->",
"getJobs",
"(",
")",
";",
"foreach",
"(",
"$",
"jobs",
"as",
"$",
"job",
")",
"{",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"job",
"->",
"identifier",
"(",
")",
",",
"$",
"procs",
")",
")",
"{",
"$",
"procs",
"[",
"$",
"job",
"->",
"identifier",
"(",
")",
"]",
"=",
"[",
"]",
";",
"}",
"while",
"(",
"count",
"(",
"$",
"procs",
"[",
"$",
"job",
"->",
"identifier",
"(",
")",
"]",
")",
">",
"$",
"job",
"->",
"numWorkers",
"(",
")",
")",
"{",
"// Stopping an excessive child.",
"echo",
"'Stopping an excessive child.'",
".",
"PHP_EOL",
";",
"$",
"proc",
"=",
"array_pop",
"(",
"$",
"procs",
"[",
"$",
"job",
"->",
"identifier",
"(",
")",
"]",
")",
";",
"$",
"status",
"=",
"proc_get_status",
"(",
"$",
"proc",
")",
";",
"// Keep sending SIGTERM until the child exits.",
"while",
"(",
"$",
"status",
"[",
"'running'",
"]",
"===",
"true",
")",
"{",
"@",
"proc_terminate",
"(",
"$",
"proc",
")",
";",
"usleep",
"(",
"50000",
")",
";",
"$",
"status",
"=",
"proc_get_status",
"(",
"$",
"proc",
")",
";",
"}",
"@",
"proc_close",
"(",
"$",
"proc",
")",
";",
"}",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"$",
"job",
"->",
"numWorkers",
"(",
")",
";",
"$",
"i",
"++",
")",
"{",
"$",
"needStart",
"=",
"false",
";",
"if",
"(",
"array_key_exists",
"(",
"$",
"i",
",",
"$",
"procs",
"[",
"$",
"job",
"->",
"identifier",
"(",
")",
"]",
")",
")",
"{",
"$",
"status",
"=",
"proc_get_status",
"(",
"$",
"procs",
"[",
"$",
"job",
"->",
"identifier",
"(",
")",
"]",
"[",
"$",
"i",
"]",
")",
";",
"if",
"(",
"$",
"status",
"[",
"'running'",
"]",
"!==",
"true",
")",
"{",
"$",
"needStart",
"=",
"true",
";",
"}",
"}",
"else",
"{",
"$",
"needStart",
"=",
"true",
";",
"}",
"if",
"(",
"$",
"needStart",
")",
"{",
"echo",
"'Starting a child.'",
".",
"PHP_EOL",
";",
"$",
"procs",
"[",
"$",
"job",
"->",
"identifier",
"(",
")",
"]",
"[",
"$",
"i",
"]",
"=",
"proc_open",
"(",
"sprintf",
"(",
"'%s %d'",
",",
"$",
"this",
"->",
"command",
",",
"$",
"job",
"->",
"id",
"(",
")",
")",
",",
"$",
"this",
"->",
"descriptorSpec",
",",
"$",
"pipes",
")",
";",
"}",
"}",
"}",
"usleep",
"(",
"1000000",
")",
";",
"// Reload the config after 1 second",
"pcntl_signal_dispatch",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"shutdown",
")",
"{",
"echo",
"'Shutting down, waiting for the children'",
".",
"PHP_EOL",
";",
"foreach",
"(",
"$",
"procs",
"as",
"$",
"k",
"=>",
"$",
"v",
")",
"{",
"foreach",
"(",
"$",
"v",
"as",
"$",
"proc",
")",
"{",
"$",
"status",
"=",
"proc_get_status",
"(",
"$",
"proc",
")",
";",
"// Keep sending SIGTERM until the child exits.",
"while",
"(",
"$",
"status",
"[",
"'running'",
"]",
"===",
"true",
")",
"{",
"@",
"proc_terminate",
"(",
"$",
"proc",
")",
";",
"usleep",
"(",
"50000",
")",
";",
"$",
"status",
"=",
"proc_get_status",
"(",
"$",
"proc",
")",
";",
"}",
"@",
"proc_close",
"(",
"$",
"proc",
")",
";",
"}",
"}",
"echo",
"'BatchDaemon exiting'",
".",
"PHP_EOL",
";",
"exit",
";",
"}",
"// Reload the config",
"$",
"this",
"->",
"runner",
"->",
"loadConfig",
"(",
")",
";",
"}",
"}"
] | A loop for the parent.
@return void | [
"A",
"loop",
"for",
"the",
"parent",
"."
] | ff5030ffa1f12904565509a7bc24ecc0bd794a3e | https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Core/src/Batch/BatchDaemon.php#L83-L149 | train |
googleapis/google-cloud-php | Storage/src/SigningHelper.php | SigningHelper.v2Sign | public function v2Sign(ConnectionInterface $connection, $expires, $resource, $generation, array $options)
{
list($credentials, $options) = $this->getSigningCredentials($connection, $options);
$expires = $this->normalizeExpiration($expires);
$resource = $this->normalizeResource($resource);
$options = $this->normalizeOptions($options);
$headers = $this->normalizeHeaders($options['headers']);
// Make sure disallowed headers are not included.
$illegalHeaders = [
'x-goog-encryption-key',
'x-goog-encryption-key-sha256'
];
if ($illegal = array_intersect_key(array_flip($illegalHeaders), $headers)) {
throw new \InvalidArgumentException(sprintf(
'%s %s not allowed in Signed URL headers.',
implode(' and ', array_keys($illegal)),
count($illegal) === 1 ? 'is' : 'are'
));
}
// Sort headers by name.
ksort($headers);
$toSign = [
$options['method'],
$options['contentMd5'],
$options['contentType'],
$expires,
];
$signedHeaders = [];
foreach ($headers as $name => $value) {
$signedHeaders[] = $name .':'. $value;
}
// Push the headers onto the end of the signing string.
if ($signedHeaders) {
$toSign = array_merge($toSign, $signedHeaders);
}
$toSign[] = $resource;
$stringToSign = $this->createV2CanonicalRequest($toSign);
$signature = $credentials->signBlob($stringToSign, [
'forceOpenssl' => $options['forceOpenssl']
]);
// Start with user-provided query params and add required parameters.
$params = $options['queryParams'];
$params['GoogleAccessId'] = $credentials->getClientName();
$params['Expires'] = $expires;
$params['Signature'] = $signature;
$params = $this->addCommonParams($generation, $params, $options);
$queryString = $this->buildQueryString($params);
$resource = $this->normalizeUriPath($options['cname'], $resource);
return 'https://' . $options['cname'] . $resource . '?' . $queryString;
} | php | public function v2Sign(ConnectionInterface $connection, $expires, $resource, $generation, array $options)
{
list($credentials, $options) = $this->getSigningCredentials($connection, $options);
$expires = $this->normalizeExpiration($expires);
$resource = $this->normalizeResource($resource);
$options = $this->normalizeOptions($options);
$headers = $this->normalizeHeaders($options['headers']);
// Make sure disallowed headers are not included.
$illegalHeaders = [
'x-goog-encryption-key',
'x-goog-encryption-key-sha256'
];
if ($illegal = array_intersect_key(array_flip($illegalHeaders), $headers)) {
throw new \InvalidArgumentException(sprintf(
'%s %s not allowed in Signed URL headers.',
implode(' and ', array_keys($illegal)),
count($illegal) === 1 ? 'is' : 'are'
));
}
// Sort headers by name.
ksort($headers);
$toSign = [
$options['method'],
$options['contentMd5'],
$options['contentType'],
$expires,
];
$signedHeaders = [];
foreach ($headers as $name => $value) {
$signedHeaders[] = $name .':'. $value;
}
// Push the headers onto the end of the signing string.
if ($signedHeaders) {
$toSign = array_merge($toSign, $signedHeaders);
}
$toSign[] = $resource;
$stringToSign = $this->createV2CanonicalRequest($toSign);
$signature = $credentials->signBlob($stringToSign, [
'forceOpenssl' => $options['forceOpenssl']
]);
// Start with user-provided query params and add required parameters.
$params = $options['queryParams'];
$params['GoogleAccessId'] = $credentials->getClientName();
$params['Expires'] = $expires;
$params['Signature'] = $signature;
$params = $this->addCommonParams($generation, $params, $options);
$queryString = $this->buildQueryString($params);
$resource = $this->normalizeUriPath($options['cname'], $resource);
return 'https://' . $options['cname'] . $resource . '?' . $queryString;
} | [
"public",
"function",
"v2Sign",
"(",
"ConnectionInterface",
"$",
"connection",
",",
"$",
"expires",
",",
"$",
"resource",
",",
"$",
"generation",
",",
"array",
"$",
"options",
")",
"{",
"list",
"(",
"$",
"credentials",
",",
"$",
"options",
")",
"=",
"$",
"this",
"->",
"getSigningCredentials",
"(",
"$",
"connection",
",",
"$",
"options",
")",
";",
"$",
"expires",
"=",
"$",
"this",
"->",
"normalizeExpiration",
"(",
"$",
"expires",
")",
";",
"$",
"resource",
"=",
"$",
"this",
"->",
"normalizeResource",
"(",
"$",
"resource",
")",
";",
"$",
"options",
"=",
"$",
"this",
"->",
"normalizeOptions",
"(",
"$",
"options",
")",
";",
"$",
"headers",
"=",
"$",
"this",
"->",
"normalizeHeaders",
"(",
"$",
"options",
"[",
"'headers'",
"]",
")",
";",
"// Make sure disallowed headers are not included.",
"$",
"illegalHeaders",
"=",
"[",
"'x-goog-encryption-key'",
",",
"'x-goog-encryption-key-sha256'",
"]",
";",
"if",
"(",
"$",
"illegal",
"=",
"array_intersect_key",
"(",
"array_flip",
"(",
"$",
"illegalHeaders",
")",
",",
"$",
"headers",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'%s %s not allowed in Signed URL headers.'",
",",
"implode",
"(",
"' and '",
",",
"array_keys",
"(",
"$",
"illegal",
")",
")",
",",
"count",
"(",
"$",
"illegal",
")",
"===",
"1",
"?",
"'is'",
":",
"'are'",
")",
")",
";",
"}",
"// Sort headers by name.",
"ksort",
"(",
"$",
"headers",
")",
";",
"$",
"toSign",
"=",
"[",
"$",
"options",
"[",
"'method'",
"]",
",",
"$",
"options",
"[",
"'contentMd5'",
"]",
",",
"$",
"options",
"[",
"'contentType'",
"]",
",",
"$",
"expires",
",",
"]",
";",
"$",
"signedHeaders",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"headers",
"as",
"$",
"name",
"=>",
"$",
"value",
")",
"{",
"$",
"signedHeaders",
"[",
"]",
"=",
"$",
"name",
".",
"':'",
".",
"$",
"value",
";",
"}",
"// Push the headers onto the end of the signing string.",
"if",
"(",
"$",
"signedHeaders",
")",
"{",
"$",
"toSign",
"=",
"array_merge",
"(",
"$",
"toSign",
",",
"$",
"signedHeaders",
")",
";",
"}",
"$",
"toSign",
"[",
"]",
"=",
"$",
"resource",
";",
"$",
"stringToSign",
"=",
"$",
"this",
"->",
"createV2CanonicalRequest",
"(",
"$",
"toSign",
")",
";",
"$",
"signature",
"=",
"$",
"credentials",
"->",
"signBlob",
"(",
"$",
"stringToSign",
",",
"[",
"'forceOpenssl'",
"=>",
"$",
"options",
"[",
"'forceOpenssl'",
"]",
"]",
")",
";",
"// Start with user-provided query params and add required parameters.",
"$",
"params",
"=",
"$",
"options",
"[",
"'queryParams'",
"]",
";",
"$",
"params",
"[",
"'GoogleAccessId'",
"]",
"=",
"$",
"credentials",
"->",
"getClientName",
"(",
")",
";",
"$",
"params",
"[",
"'Expires'",
"]",
"=",
"$",
"expires",
";",
"$",
"params",
"[",
"'Signature'",
"]",
"=",
"$",
"signature",
";",
"$",
"params",
"=",
"$",
"this",
"->",
"addCommonParams",
"(",
"$",
"generation",
",",
"$",
"params",
",",
"$",
"options",
")",
";",
"$",
"queryString",
"=",
"$",
"this",
"->",
"buildQueryString",
"(",
"$",
"params",
")",
";",
"$",
"resource",
"=",
"$",
"this",
"->",
"normalizeUriPath",
"(",
"$",
"options",
"[",
"'cname'",
"]",
",",
"$",
"resource",
")",
";",
"return",
"'https://'",
".",
"$",
"options",
"[",
"'cname'",
"]",
".",
"$",
"resource",
".",
"'?'",
".",
"$",
"queryString",
";",
"}"
] | Sign a URL using Google Signed URLs v2.
This method will be deprecated in the future.
@param ConnectionInterface $connection A connection to the Cloud Storage
API.
@param Timestamp|\DateTimeInterface|int $expires The signed URL
expiration.
@param string $resource The URI to the storage resource, preceded by a
leading slash.
@param int|null $generation The resource generation.
@param array $options Configuration options. See
{@see Google\Cloud\Storage\StorageObject::signedUrl()} for
details.
@return string
@throws \InvalidArgumentException
@throws \RuntimeException If required data could not be gathered from
credentials.
@throws \RuntimeException If OpenSSL signing is required by user input
and OpenSSL is not available. | [
"Sign",
"a",
"URL",
"using",
"Google",
"Signed",
"URLs",
"v2",
"."
] | ff5030ffa1f12904565509a7bc24ecc0bd794a3e | https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Storage/src/SigningHelper.php#L123-L185 | train |
googleapis/google-cloud-php | Storage/src/SigningHelper.php | SigningHelper.normalizeExpiration | private function normalizeExpiration($expires)
{
if ($expires instanceof Timestamp) {
$seconds = $expires->get()->format('U');
} elseif ($expires instanceof \DateTimeInterface) {
$seconds = $expires->format('U');
} elseif (is_numeric($expires)) {
$seconds = (int) $expires;
} else {
throw new \InvalidArgumentException('Invalid expiration.');
}
return $seconds;
} | php | private function normalizeExpiration($expires)
{
if ($expires instanceof Timestamp) {
$seconds = $expires->get()->format('U');
} elseif ($expires instanceof \DateTimeInterface) {
$seconds = $expires->format('U');
} elseif (is_numeric($expires)) {
$seconds = (int) $expires;
} else {
throw new \InvalidArgumentException('Invalid expiration.');
}
return $seconds;
} | [
"private",
"function",
"normalizeExpiration",
"(",
"$",
"expires",
")",
"{",
"if",
"(",
"$",
"expires",
"instanceof",
"Timestamp",
")",
"{",
"$",
"seconds",
"=",
"$",
"expires",
"->",
"get",
"(",
")",
"->",
"format",
"(",
"'U'",
")",
";",
"}",
"elseif",
"(",
"$",
"expires",
"instanceof",
"\\",
"DateTimeInterface",
")",
"{",
"$",
"seconds",
"=",
"$",
"expires",
"->",
"format",
"(",
"'U'",
")",
";",
"}",
"elseif",
"(",
"is_numeric",
"(",
"$",
"expires",
")",
")",
"{",
"$",
"seconds",
"=",
"(",
"int",
")",
"$",
"expires",
";",
"}",
"else",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Invalid expiration.'",
")",
";",
"}",
"return",
"$",
"seconds",
";",
"}"
] | Normalizes and validates an expiration.
@param Timestamp|\DateTimeInterface|int $expires The expiration
@return int
@throws \InvalidArgumentException If an invalid value is given. | [
"Normalizes",
"and",
"validates",
"an",
"expiration",
"."
] | ff5030ffa1f12904565509a7bc24ecc0bd794a3e | https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Storage/src/SigningHelper.php#L350-L363 | train |
googleapis/google-cloud-php | Storage/src/SigningHelper.php | SigningHelper.normalizeResource | private function normalizeResource($resource)
{
$pieces = explode('/', trim($resource, '/'));
array_walk($pieces, function (&$piece) {
$piece = rawurlencode($piece);
});
return '/' . implode('/', $pieces);
} | php | private function normalizeResource($resource)
{
$pieces = explode('/', trim($resource, '/'));
array_walk($pieces, function (&$piece) {
$piece = rawurlencode($piece);
});
return '/' . implode('/', $pieces);
} | [
"private",
"function",
"normalizeResource",
"(",
"$",
"resource",
")",
"{",
"$",
"pieces",
"=",
"explode",
"(",
"'/'",
",",
"trim",
"(",
"$",
"resource",
",",
"'/'",
")",
")",
";",
"array_walk",
"(",
"$",
"pieces",
",",
"function",
"(",
"&",
"$",
"piece",
")",
"{",
"$",
"piece",
"=",
"rawurlencode",
"(",
"$",
"piece",
")",
";",
"}",
")",
";",
"return",
"'/'",
".",
"implode",
"(",
"'/'",
",",
"$",
"pieces",
")",
";",
"}"
] | Normalizes and encodes the resource identifier.
@param string $resource The resource identifier. In form
`[/]$bucket/$object`.
@return string The resource, with pieces encoded and prefixed with a
forward slash. | [
"Normalizes",
"and",
"encodes",
"the",
"resource",
"identifier",
"."
] | ff5030ffa1f12904565509a7bc24ecc0bd794a3e | https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Storage/src/SigningHelper.php#L373-L380 | train |
googleapis/google-cloud-php | Storage/src/SigningHelper.php | SigningHelper.normalizeOptions | private function normalizeOptions(array $options)
{
$options += [
'method' => 'GET',
'cname' => self::DEFAULT_DOWNLOAD_HOST,
'contentMd5' => null,
'contentType' => null,
'headers' => [],
'saveAsName' => null,
'responseDisposition' => null,
'responseType' => null,
'keyFile' => null,
'keyFilePath' => null,
'allowPost' => false,
'forceOpenssl' => false,
'queryParams' => [],
'timestamp' => null
];
$allowedMethods = ['GET', 'PUT', 'POST', 'DELETE'];
$options['method'] = strtoupper($options['method']);
if (!in_array($options['method'], $allowedMethods)) {
throw new \InvalidArgumentException('$options.method must be one of `GET`, `PUT` or `DELETE`.');
}
if ($options['method'] === 'POST' && !$options['allowPost']) {
throw new \InvalidArgumentException(
'Invalid method. To create an upload URI, use StorageObject::signedUploadUrl().'
);
}
unset($options['allowPost']);
// For backwards compatibility, strip protocol from cname.
$cnameParts = explode('//', $options['cname']);
if (count($cnameParts) > 1) {
$options['cname'] = $cnameParts[1];
}
$options['cname'] = trim($options['cname'], '/');
// If a timestamp is provided, use it in place of `now` for v4 URLs only..
// This option exists for testing purposes, and should not generally be provided by users.
if ($options['timestamp']) {
if (!($options['timestamp'] instanceof \DateTimeInterface)) {
if (!is_string($options['timestamp'])) {
throw new \InvalidArgumentException(
'User-provided timestamps must be a string or instance of `\DateTimeInterface`.'
);
}
$options['timestamp'] = \DateTimeImmutable::createFromFormat(
self::V4_TIMESTAMP_FORMAT,
$options['timestamp'],
new \DateTimeZone('UTC')
);
if (!$options['timestamp']) {
throw new \InvalidArgumentException(
'Given timestamp string is in an invalid format. Provide timestamp formatted as follows: `' .
self::V4_TIMESTAMP_FORMAT .
'`. Note that timestamps MUST be in UTC.'
);
}
}
} else {
$options['timestamp'] = new \DateTimeImmutable('now', new \DateTimeZone('UTC'));
}
return $options;
} | php | private function normalizeOptions(array $options)
{
$options += [
'method' => 'GET',
'cname' => self::DEFAULT_DOWNLOAD_HOST,
'contentMd5' => null,
'contentType' => null,
'headers' => [],
'saveAsName' => null,
'responseDisposition' => null,
'responseType' => null,
'keyFile' => null,
'keyFilePath' => null,
'allowPost' => false,
'forceOpenssl' => false,
'queryParams' => [],
'timestamp' => null
];
$allowedMethods = ['GET', 'PUT', 'POST', 'DELETE'];
$options['method'] = strtoupper($options['method']);
if (!in_array($options['method'], $allowedMethods)) {
throw new \InvalidArgumentException('$options.method must be one of `GET`, `PUT` or `DELETE`.');
}
if ($options['method'] === 'POST' && !$options['allowPost']) {
throw new \InvalidArgumentException(
'Invalid method. To create an upload URI, use StorageObject::signedUploadUrl().'
);
}
unset($options['allowPost']);
// For backwards compatibility, strip protocol from cname.
$cnameParts = explode('//', $options['cname']);
if (count($cnameParts) > 1) {
$options['cname'] = $cnameParts[1];
}
$options['cname'] = trim($options['cname'], '/');
// If a timestamp is provided, use it in place of `now` for v4 URLs only..
// This option exists for testing purposes, and should not generally be provided by users.
if ($options['timestamp']) {
if (!($options['timestamp'] instanceof \DateTimeInterface)) {
if (!is_string($options['timestamp'])) {
throw new \InvalidArgumentException(
'User-provided timestamps must be a string or instance of `\DateTimeInterface`.'
);
}
$options['timestamp'] = \DateTimeImmutable::createFromFormat(
self::V4_TIMESTAMP_FORMAT,
$options['timestamp'],
new \DateTimeZone('UTC')
);
if (!$options['timestamp']) {
throw new \InvalidArgumentException(
'Given timestamp string is in an invalid format. Provide timestamp formatted as follows: `' .
self::V4_TIMESTAMP_FORMAT .
'`. Note that timestamps MUST be in UTC.'
);
}
}
} else {
$options['timestamp'] = new \DateTimeImmutable('now', new \DateTimeZone('UTC'));
}
return $options;
} | [
"private",
"function",
"normalizeOptions",
"(",
"array",
"$",
"options",
")",
"{",
"$",
"options",
"+=",
"[",
"'method'",
"=>",
"'GET'",
",",
"'cname'",
"=>",
"self",
"::",
"DEFAULT_DOWNLOAD_HOST",
",",
"'contentMd5'",
"=>",
"null",
",",
"'contentType'",
"=>",
"null",
",",
"'headers'",
"=>",
"[",
"]",
",",
"'saveAsName'",
"=>",
"null",
",",
"'responseDisposition'",
"=>",
"null",
",",
"'responseType'",
"=>",
"null",
",",
"'keyFile'",
"=>",
"null",
",",
"'keyFilePath'",
"=>",
"null",
",",
"'allowPost'",
"=>",
"false",
",",
"'forceOpenssl'",
"=>",
"false",
",",
"'queryParams'",
"=>",
"[",
"]",
",",
"'timestamp'",
"=>",
"null",
"]",
";",
"$",
"allowedMethods",
"=",
"[",
"'GET'",
",",
"'PUT'",
",",
"'POST'",
",",
"'DELETE'",
"]",
";",
"$",
"options",
"[",
"'method'",
"]",
"=",
"strtoupper",
"(",
"$",
"options",
"[",
"'method'",
"]",
")",
";",
"if",
"(",
"!",
"in_array",
"(",
"$",
"options",
"[",
"'method'",
"]",
",",
"$",
"allowedMethods",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'$options.method must be one of `GET`, `PUT` or `DELETE`.'",
")",
";",
"}",
"if",
"(",
"$",
"options",
"[",
"'method'",
"]",
"===",
"'POST'",
"&&",
"!",
"$",
"options",
"[",
"'allowPost'",
"]",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Invalid method. To create an upload URI, use StorageObject::signedUploadUrl().'",
")",
";",
"}",
"unset",
"(",
"$",
"options",
"[",
"'allowPost'",
"]",
")",
";",
"// For backwards compatibility, strip protocol from cname.",
"$",
"cnameParts",
"=",
"explode",
"(",
"'//'",
",",
"$",
"options",
"[",
"'cname'",
"]",
")",
";",
"if",
"(",
"count",
"(",
"$",
"cnameParts",
")",
">",
"1",
")",
"{",
"$",
"options",
"[",
"'cname'",
"]",
"=",
"$",
"cnameParts",
"[",
"1",
"]",
";",
"}",
"$",
"options",
"[",
"'cname'",
"]",
"=",
"trim",
"(",
"$",
"options",
"[",
"'cname'",
"]",
",",
"'/'",
")",
";",
"// If a timestamp is provided, use it in place of `now` for v4 URLs only..",
"// This option exists for testing purposes, and should not generally be provided by users.",
"if",
"(",
"$",
"options",
"[",
"'timestamp'",
"]",
")",
"{",
"if",
"(",
"!",
"(",
"$",
"options",
"[",
"'timestamp'",
"]",
"instanceof",
"\\",
"DateTimeInterface",
")",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"options",
"[",
"'timestamp'",
"]",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'User-provided timestamps must be a string or instance of `\\DateTimeInterface`.'",
")",
";",
"}",
"$",
"options",
"[",
"'timestamp'",
"]",
"=",
"\\",
"DateTimeImmutable",
"::",
"createFromFormat",
"(",
"self",
"::",
"V4_TIMESTAMP_FORMAT",
",",
"$",
"options",
"[",
"'timestamp'",
"]",
",",
"new",
"\\",
"DateTimeZone",
"(",
"'UTC'",
")",
")",
";",
"if",
"(",
"!",
"$",
"options",
"[",
"'timestamp'",
"]",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Given timestamp string is in an invalid format. Provide timestamp formatted as follows: `'",
".",
"self",
"::",
"V4_TIMESTAMP_FORMAT",
".",
"'`. Note that timestamps MUST be in UTC.'",
")",
";",
"}",
"}",
"}",
"else",
"{",
"$",
"options",
"[",
"'timestamp'",
"]",
"=",
"new",
"\\",
"DateTimeImmutable",
"(",
"'now'",
",",
"new",
"\\",
"DateTimeZone",
"(",
"'UTC'",
")",
")",
";",
"}",
"return",
"$",
"options",
";",
"}"
] | Fixes the user input options, filters and validates data.
@param array $options Signed URL configuration options.
@return array
@throws \InvalidArgumentException | [
"Fixes",
"the",
"user",
"input",
"options",
"filters",
"and",
"validates",
"data",
"."
] | ff5030ffa1f12904565509a7bc24ecc0bd794a3e | https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Storage/src/SigningHelper.php#L389-L458 | train |
googleapis/google-cloud-php | Storage/src/SigningHelper.php | SigningHelper.normalizeHeaders | private function normalizeHeaders(array $headers)
{
$out = [];
foreach ($headers as $name => $value) {
$name = strtolower(trim($name));
// collapse arrays of values into a comma-separated list.
if (!is_array($value)) {
$value = [$value];
}
foreach ($value as &$headerValue) {
// strip trailing and leading spaces.
$headerValue = trim($headerValue);
// replace newlines with empty strings.
$headerValue = str_replace(PHP_EOL, '', $headerValue);
// collapse multiple whitespace chars to a single space.
$headerValue = preg_replace('/\s+/', ' ', $headerValue);
}
$out[$name] = implode(', ', $value);
}
return $out;
} | php | private function normalizeHeaders(array $headers)
{
$out = [];
foreach ($headers as $name => $value) {
$name = strtolower(trim($name));
// collapse arrays of values into a comma-separated list.
if (!is_array($value)) {
$value = [$value];
}
foreach ($value as &$headerValue) {
// strip trailing and leading spaces.
$headerValue = trim($headerValue);
// replace newlines with empty strings.
$headerValue = str_replace(PHP_EOL, '', $headerValue);
// collapse multiple whitespace chars to a single space.
$headerValue = preg_replace('/\s+/', ' ', $headerValue);
}
$out[$name] = implode(', ', $value);
}
return $out;
} | [
"private",
"function",
"normalizeHeaders",
"(",
"array",
"$",
"headers",
")",
"{",
"$",
"out",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"headers",
"as",
"$",
"name",
"=>",
"$",
"value",
")",
"{",
"$",
"name",
"=",
"strtolower",
"(",
"trim",
"(",
"$",
"name",
")",
")",
";",
"// collapse arrays of values into a comma-separated list.",
"if",
"(",
"!",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"$",
"value",
"=",
"[",
"$",
"value",
"]",
";",
"}",
"foreach",
"(",
"$",
"value",
"as",
"&",
"$",
"headerValue",
")",
"{",
"// strip trailing and leading spaces.",
"$",
"headerValue",
"=",
"trim",
"(",
"$",
"headerValue",
")",
";",
"// replace newlines with empty strings.",
"$",
"headerValue",
"=",
"str_replace",
"(",
"PHP_EOL",
",",
"''",
",",
"$",
"headerValue",
")",
";",
"// collapse multiple whitespace chars to a single space.",
"$",
"headerValue",
"=",
"preg_replace",
"(",
"'/\\s+/'",
",",
"' '",
",",
"$",
"headerValue",
")",
";",
"}",
"$",
"out",
"[",
"$",
"name",
"]",
"=",
"implode",
"(",
"', '",
",",
"$",
"value",
")",
";",
"}",
"return",
"$",
"out",
";",
"}"
] | Cleans and normalizes header values.
Arrays of values are collapsed into a comma-separated list, trailing and
leading spaces are removed, newlines are replaced by empty strings, and
multiple whitespace chars are replaced by a single space.
@param array $headers Input headers
@return array | [
"Cleans",
"and",
"normalizes",
"header",
"values",
"."
] | ff5030ffa1f12904565509a7bc24ecc0bd794a3e | https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Storage/src/SigningHelper.php#L470-L495 | train |
googleapis/google-cloud-php | Storage/src/SigningHelper.php | SigningHelper.normalizeUriPath | private function normalizeUriPath($cname, $resource)
{
if ($cname !== self::DEFAULT_DOWNLOAD_HOST) {
$resourceParts = explode('/', trim($resource, '/'));
array_shift($resourceParts);
// Resource is a Bucket.
if (empty($resourceParts)) {
$resource = '/';
} else {
$resource = '/' . implode('/', $resourceParts);
}
}
return $resource;
} | php | private function normalizeUriPath($cname, $resource)
{
if ($cname !== self::DEFAULT_DOWNLOAD_HOST) {
$resourceParts = explode('/', trim($resource, '/'));
array_shift($resourceParts);
// Resource is a Bucket.
if (empty($resourceParts)) {
$resource = '/';
} else {
$resource = '/' . implode('/', $resourceParts);
}
}
return $resource;
} | [
"private",
"function",
"normalizeUriPath",
"(",
"$",
"cname",
",",
"$",
"resource",
")",
"{",
"if",
"(",
"$",
"cname",
"!==",
"self",
"::",
"DEFAULT_DOWNLOAD_HOST",
")",
"{",
"$",
"resourceParts",
"=",
"explode",
"(",
"'/'",
",",
"trim",
"(",
"$",
"resource",
",",
"'/'",
")",
")",
";",
"array_shift",
"(",
"$",
"resourceParts",
")",
";",
"// Resource is a Bucket.",
"if",
"(",
"empty",
"(",
"$",
"resourceParts",
")",
")",
"{",
"$",
"resource",
"=",
"'/'",
";",
"}",
"else",
"{",
"$",
"resource",
"=",
"'/'",
".",
"implode",
"(",
"'/'",
",",
"$",
"resourceParts",
")",
";",
"}",
"}",
"return",
"$",
"resource",
";",
"}"
] | Returns a resource formatted for use in a URI.
If the cname is other than the default, will omit the bucket name.
@param string $cname The cname provided by the user, or the default
value.
@param string $resource The GCS resource path (i.e. /bucket/object).
@return string | [
"Returns",
"a",
"resource",
"formatted",
"for",
"use",
"in",
"a",
"URI",
"."
] | ff5030ffa1f12904565509a7bc24ecc0bd794a3e | https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Storage/src/SigningHelper.php#L507-L522 | train |
googleapis/google-cloud-php | Storage/src/SigningHelper.php | SigningHelper.getSigningCredentials | private function getSigningCredentials(ConnectionInterface $connection, array $options)
{
$keyFilePath = isset($options['keyFilePath'])
? $options['keyFilePath']
: null;
if ($keyFilePath) {
if (!file_exists($keyFilePath)) {
throw new \InvalidArgumentException(sprintf(
'Keyfile path %s does not exist.',
$keyFilePath
));
}
$options['keyFile'] = self::jsonDecode(file_get_contents($keyFilePath), true);
}
$rw = $connection->requestWrapper();
$keyFile = isset($options['keyFile'])
? $options['keyFile']
: null;
if ($keyFile) {
$scopes = isset($options['scopes'])
? $options['scopes']
: $rw->scopes();
$credentials = CredentialsLoader::makeCredentials($scopes, $keyFile);
} else {
$credentials = $rw->getCredentialsFetcher();
}
if (!($credentials instanceof SignBlobInterface)) {
throw new \RuntimeException(sprintf(
'Credentials object is of type `%s` and is not valid for signing.',
get_class($credentials)
));
}
unset(
$options['keyFilePath'],
$options['keyFile'],
$options['scopes']
);
return [$credentials, $options];
} | php | private function getSigningCredentials(ConnectionInterface $connection, array $options)
{
$keyFilePath = isset($options['keyFilePath'])
? $options['keyFilePath']
: null;
if ($keyFilePath) {
if (!file_exists($keyFilePath)) {
throw new \InvalidArgumentException(sprintf(
'Keyfile path %s does not exist.',
$keyFilePath
));
}
$options['keyFile'] = self::jsonDecode(file_get_contents($keyFilePath), true);
}
$rw = $connection->requestWrapper();
$keyFile = isset($options['keyFile'])
? $options['keyFile']
: null;
if ($keyFile) {
$scopes = isset($options['scopes'])
? $options['scopes']
: $rw->scopes();
$credentials = CredentialsLoader::makeCredentials($scopes, $keyFile);
} else {
$credentials = $rw->getCredentialsFetcher();
}
if (!($credentials instanceof SignBlobInterface)) {
throw new \RuntimeException(sprintf(
'Credentials object is of type `%s` and is not valid for signing.',
get_class($credentials)
));
}
unset(
$options['keyFilePath'],
$options['keyFile'],
$options['scopes']
);
return [$credentials, $options];
} | [
"private",
"function",
"getSigningCredentials",
"(",
"ConnectionInterface",
"$",
"connection",
",",
"array",
"$",
"options",
")",
"{",
"$",
"keyFilePath",
"=",
"isset",
"(",
"$",
"options",
"[",
"'keyFilePath'",
"]",
")",
"?",
"$",
"options",
"[",
"'keyFilePath'",
"]",
":",
"null",
";",
"if",
"(",
"$",
"keyFilePath",
")",
"{",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"keyFilePath",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'Keyfile path %s does not exist.'",
",",
"$",
"keyFilePath",
")",
")",
";",
"}",
"$",
"options",
"[",
"'keyFile'",
"]",
"=",
"self",
"::",
"jsonDecode",
"(",
"file_get_contents",
"(",
"$",
"keyFilePath",
")",
",",
"true",
")",
";",
"}",
"$",
"rw",
"=",
"$",
"connection",
"->",
"requestWrapper",
"(",
")",
";",
"$",
"keyFile",
"=",
"isset",
"(",
"$",
"options",
"[",
"'keyFile'",
"]",
")",
"?",
"$",
"options",
"[",
"'keyFile'",
"]",
":",
"null",
";",
"if",
"(",
"$",
"keyFile",
")",
"{",
"$",
"scopes",
"=",
"isset",
"(",
"$",
"options",
"[",
"'scopes'",
"]",
")",
"?",
"$",
"options",
"[",
"'scopes'",
"]",
":",
"$",
"rw",
"->",
"scopes",
"(",
")",
";",
"$",
"credentials",
"=",
"CredentialsLoader",
"::",
"makeCredentials",
"(",
"$",
"scopes",
",",
"$",
"keyFile",
")",
";",
"}",
"else",
"{",
"$",
"credentials",
"=",
"$",
"rw",
"->",
"getCredentialsFetcher",
"(",
")",
";",
"}",
"if",
"(",
"!",
"(",
"$",
"credentials",
"instanceof",
"SignBlobInterface",
")",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"sprintf",
"(",
"'Credentials object is of type `%s` and is not valid for signing.'",
",",
"get_class",
"(",
"$",
"credentials",
")",
")",
")",
";",
"}",
"unset",
"(",
"$",
"options",
"[",
"'keyFilePath'",
"]",
",",
"$",
"options",
"[",
"'keyFile'",
"]",
",",
"$",
"options",
"[",
"'scopes'",
"]",
")",
";",
"return",
"[",
"$",
"credentials",
",",
"$",
"options",
"]",
";",
"}"
] | Get the credentials for use with signing.
@param ConnectionInterface $connection A Storage connection object.
@param array $options Configuration options.
@return array A list containing a credentials object at index 0 and the
modified options at index 1.
@throws \RuntimeException If the credentials type is not valid for signing.
@throws \InvalidArgumentException If a keyfile is given and is not valid. | [
"Get",
"the",
"credentials",
"for",
"use",
"with",
"signing",
"."
] | ff5030ffa1f12904565509a7bc24ecc0bd794a3e | https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Storage/src/SigningHelper.php#L534-L580 | train |
googleapis/google-cloud-php | Storage/src/SigningHelper.php | SigningHelper.addCommonParams | private function addCommonParams($generation, array $params, array $options)
{
if ($options['responseType']) {
$params['response-content-type'] = $options['responseType'];
}
if ($options['responseDisposition']) {
$params['response-content-disposition'] = $options['responseDisposition'];
} elseif ($options['saveAsName']) {
$params['response-content-disposition'] = 'attachment; filename='
. '"' . $options['saveAsName'] . '"';
}
if ($generation) {
$params['generation'] = $generation;
}
return $params;
} | php | private function addCommonParams($generation, array $params, array $options)
{
if ($options['responseType']) {
$params['response-content-type'] = $options['responseType'];
}
if ($options['responseDisposition']) {
$params['response-content-disposition'] = $options['responseDisposition'];
} elseif ($options['saveAsName']) {
$params['response-content-disposition'] = 'attachment; filename='
. '"' . $options['saveAsName'] . '"';
}
if ($generation) {
$params['generation'] = $generation;
}
return $params;
} | [
"private",
"function",
"addCommonParams",
"(",
"$",
"generation",
",",
"array",
"$",
"params",
",",
"array",
"$",
"options",
")",
"{",
"if",
"(",
"$",
"options",
"[",
"'responseType'",
"]",
")",
"{",
"$",
"params",
"[",
"'response-content-type'",
"]",
"=",
"$",
"options",
"[",
"'responseType'",
"]",
";",
"}",
"if",
"(",
"$",
"options",
"[",
"'responseDisposition'",
"]",
")",
"{",
"$",
"params",
"[",
"'response-content-disposition'",
"]",
"=",
"$",
"options",
"[",
"'responseDisposition'",
"]",
";",
"}",
"elseif",
"(",
"$",
"options",
"[",
"'saveAsName'",
"]",
")",
"{",
"$",
"params",
"[",
"'response-content-disposition'",
"]",
"=",
"'attachment; filename='",
".",
"'\"'",
".",
"$",
"options",
"[",
"'saveAsName'",
"]",
".",
"'\"'",
";",
"}",
"if",
"(",
"$",
"generation",
")",
"{",
"$",
"params",
"[",
"'generation'",
"]",
"=",
"$",
"generation",
";",
"}",
"return",
"$",
"params",
";",
"}"
] | Add parameters common to all signed URL versions.
@param int|null $generation
@param array $params
@param array $options
@return array | [
"Add",
"parameters",
"common",
"to",
"all",
"signed",
"URL",
"versions",
"."
] | ff5030ffa1f12904565509a7bc24ecc0bd794a3e | https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Storage/src/SigningHelper.php#L590-L608 | train |
googleapis/google-cloud-php | Spanner/src/Batch/ReadPartition.php | ReadPartition.serialize | public function serialize()
{
$vars = get_object_vars($this);
$vars['keySet'] = $vars['keySet']->keySetObject();
return base64_encode(json_encode($vars + [
BatchClient::PARTITION_TYPE_KEY => static::class
]));
} | php | public function serialize()
{
$vars = get_object_vars($this);
$vars['keySet'] = $vars['keySet']->keySetObject();
return base64_encode(json_encode($vars + [
BatchClient::PARTITION_TYPE_KEY => static::class
]));
} | [
"public",
"function",
"serialize",
"(",
")",
"{",
"$",
"vars",
"=",
"get_object_vars",
"(",
"$",
"this",
")",
";",
"$",
"vars",
"[",
"'keySet'",
"]",
"=",
"$",
"vars",
"[",
"'keySet'",
"]",
"->",
"keySetObject",
"(",
")",
";",
"return",
"base64_encode",
"(",
"json_encode",
"(",
"$",
"vars",
"+",
"[",
"BatchClient",
"::",
"PARTITION_TYPE_KEY",
"=>",
"static",
"::",
"class",
"]",
")",
")",
";",
"}"
] | Return a stringified representation of the ReadPartition object.
Example:
```
$partitionString = $partition->serialize();
```
@return string | [
"Return",
"a",
"stringified",
"representation",
"of",
"the",
"ReadPartition",
"object",
"."
] | ff5030ffa1f12904565509a7bc24ecc0bd794a3e | https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Spanner/src/Batch/ReadPartition.php#L166-L174 | train |
googleapis/google-cloud-php | Spanner/src/Batch/ReadPartition.php | ReadPartition.hydrate | public static function hydrate(array $data)
{
return new self(
$data['token'],
$data['table'],
KeySet::fromArray($data['keySet']),
$data['columns'],
$data['options']
);
} | php | public static function hydrate(array $data)
{
return new self(
$data['token'],
$data['table'],
KeySet::fromArray($data['keySet']),
$data['columns'],
$data['options']
);
} | [
"public",
"static",
"function",
"hydrate",
"(",
"array",
"$",
"data",
")",
"{",
"return",
"new",
"self",
"(",
"$",
"data",
"[",
"'token'",
"]",
",",
"$",
"data",
"[",
"'table'",
"]",
",",
"KeySet",
"::",
"fromArray",
"(",
"$",
"data",
"[",
"'keySet'",
"]",
")",
",",
"$",
"data",
"[",
"'columns'",
"]",
",",
"$",
"data",
"[",
"'options'",
"]",
")",
";",
"}"
] | Create a ReadPartition object from a deserialized array of partition data.
@param array $data The partition data.
@return ReadPartition
@access private | [
"Create",
"a",
"ReadPartition",
"object",
"from",
"a",
"deserialized",
"array",
"of",
"partition",
"data",
"."
] | ff5030ffa1f12904565509a7bc24ecc0bd794a3e | https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Spanner/src/Batch/ReadPartition.php#L183-L192 | train |
googleapis/google-cloud-php | Datastore/src/V1/CommitRequest.php | CommitRequest.setMode | public function setMode($var)
{
GPBUtil::checkEnum($var, \Google\Cloud\Datastore\V1\CommitRequest_Mode::class);
$this->mode = $var;
return $this;
} | php | public function setMode($var)
{
GPBUtil::checkEnum($var, \Google\Cloud\Datastore\V1\CommitRequest_Mode::class);
$this->mode = $var;
return $this;
} | [
"public",
"function",
"setMode",
"(",
"$",
"var",
")",
"{",
"GPBUtil",
"::",
"checkEnum",
"(",
"$",
"var",
",",
"\\",
"Google",
"\\",
"Cloud",
"\\",
"Datastore",
"\\",
"V1",
"\\",
"CommitRequest_Mode",
"::",
"class",
")",
";",
"$",
"this",
"->",
"mode",
"=",
"$",
"var",
";",
"return",
"$",
"this",
";",
"}"
] | The type of commit to perform. Defaults to `TRANSACTIONAL`.
Generated from protobuf field <code>.google.datastore.v1.CommitRequest.Mode mode = 5;</code>
@param int $var
@return $this | [
"The",
"type",
"of",
"commit",
"to",
"perform",
".",
"Defaults",
"to",
"TRANSACTIONAL",
"."
] | ff5030ffa1f12904565509a7bc24ecc0bd794a3e | https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Datastore/src/V1/CommitRequest.php#L123-L129 | train |
googleapis/google-cloud-php | BigQueryDataTransfer/src/V1/ListTransferRunsRequest.php | ListTransferRunsRequest.setStates | public function setStates($var)
{
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::ENUM, \Google\Cloud\BigQuery\DataTransfer\V1\TransferState::class);
$this->states = $arr;
return $this;
} | php | public function setStates($var)
{
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::ENUM, \Google\Cloud\BigQuery\DataTransfer\V1\TransferState::class);
$this->states = $arr;
return $this;
} | [
"public",
"function",
"setStates",
"(",
"$",
"var",
")",
"{",
"$",
"arr",
"=",
"GPBUtil",
"::",
"checkRepeatedField",
"(",
"$",
"var",
",",
"\\",
"Google",
"\\",
"Protobuf",
"\\",
"Internal",
"\\",
"GPBType",
"::",
"ENUM",
",",
"\\",
"Google",
"\\",
"Cloud",
"\\",
"BigQuery",
"\\",
"DataTransfer",
"\\",
"V1",
"\\",
"TransferState",
"::",
"class",
")",
";",
"$",
"this",
"->",
"states",
"=",
"$",
"arr",
";",
"return",
"$",
"this",
";",
"}"
] | When specified, only transfer runs with requested states are returned.
Generated from protobuf field <code>repeated .google.cloud.bigquery.datatransfer.v1.TransferState states = 2;</code>
@param int[]|\Google\Protobuf\Internal\RepeatedField $var
@return $this | [
"When",
"specified",
"only",
"transfer",
"runs",
"with",
"requested",
"states",
"are",
"returned",
"."
] | ff5030ffa1f12904565509a7bc24ecc0bd794a3e | https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/BigQueryDataTransfer/src/V1/ListTransferRunsRequest.php#L134-L140 | train |
googleapis/google-cloud-php | BigQueryDataTransfer/src/V1/ListTransferRunsRequest.php | ListTransferRunsRequest.setRunAttempt | public function setRunAttempt($var)
{
GPBUtil::checkEnum($var, \Google\Cloud\BigQuery\DataTransfer\V1\ListTransferRunsRequest_RunAttempt::class);
$this->run_attempt = $var;
return $this;
} | php | public function setRunAttempt($var)
{
GPBUtil::checkEnum($var, \Google\Cloud\BigQuery\DataTransfer\V1\ListTransferRunsRequest_RunAttempt::class);
$this->run_attempt = $var;
return $this;
} | [
"public",
"function",
"setRunAttempt",
"(",
"$",
"var",
")",
"{",
"GPBUtil",
"::",
"checkEnum",
"(",
"$",
"var",
",",
"\\",
"Google",
"\\",
"Cloud",
"\\",
"BigQuery",
"\\",
"DataTransfer",
"\\",
"V1",
"\\",
"ListTransferRunsRequest_RunAttempt",
"::",
"class",
")",
";",
"$",
"this",
"->",
"run_attempt",
"=",
"$",
"var",
";",
"return",
"$",
"this",
";",
"}"
] | Indicates how run attempts are to be pulled.
Generated from protobuf field <code>.google.cloud.bigquery.datatransfer.v1.ListTransferRunsRequest.RunAttempt run_attempt = 5;</code>
@param int $var
@return $this | [
"Indicates",
"how",
"run",
"attempts",
"are",
"to",
"be",
"pulled",
"."
] | ff5030ffa1f12904565509a7bc24ecc0bd794a3e | https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/BigQueryDataTransfer/src/V1/ListTransferRunsRequest.php#L220-L226 | train |
googleapis/google-cloud-php | Dataproc/src/V1beta2/Gapic/ClusterControllerGapicClient.php | ClusterControllerGapicClient.createCluster | public function createCluster($projectId, $region, $cluster, array $optionalArgs = [])
{
$request = new CreateClusterRequest();
$request->setProjectId($projectId);
$request->setRegion($region);
$request->setCluster($cluster);
if (isset($optionalArgs['requestId'])) {
$request->setRequestId($optionalArgs['requestId']);
}
return $this->startOperationsCall(
'CreateCluster',
$optionalArgs,
$request,
$this->getOperationsClient()
)->wait();
} | php | public function createCluster($projectId, $region, $cluster, array $optionalArgs = [])
{
$request = new CreateClusterRequest();
$request->setProjectId($projectId);
$request->setRegion($region);
$request->setCluster($cluster);
if (isset($optionalArgs['requestId'])) {
$request->setRequestId($optionalArgs['requestId']);
}
return $this->startOperationsCall(
'CreateCluster',
$optionalArgs,
$request,
$this->getOperationsClient()
)->wait();
} | [
"public",
"function",
"createCluster",
"(",
"$",
"projectId",
",",
"$",
"region",
",",
"$",
"cluster",
",",
"array",
"$",
"optionalArgs",
"=",
"[",
"]",
")",
"{",
"$",
"request",
"=",
"new",
"CreateClusterRequest",
"(",
")",
";",
"$",
"request",
"->",
"setProjectId",
"(",
"$",
"projectId",
")",
";",
"$",
"request",
"->",
"setRegion",
"(",
"$",
"region",
")",
";",
"$",
"request",
"->",
"setCluster",
"(",
"$",
"cluster",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"optionalArgs",
"[",
"'requestId'",
"]",
")",
")",
"{",
"$",
"request",
"->",
"setRequestId",
"(",
"$",
"optionalArgs",
"[",
"'requestId'",
"]",
")",
";",
"}",
"return",
"$",
"this",
"->",
"startOperationsCall",
"(",
"'CreateCluster'",
",",
"$",
"optionalArgs",
",",
"$",
"request",
",",
"$",
"this",
"->",
"getOperationsClient",
"(",
")",
")",
"->",
"wait",
"(",
")",
";",
"}"
] | Creates a cluster in a project.
Sample code:
```
$clusterControllerClient = new ClusterControllerClient();
try {
$projectId = '';
$region = '';
$cluster = new Cluster();
$operationResponse = $clusterControllerClient->createCluster($projectId, $region, $cluster);
$operationResponse->pollUntilComplete();
if ($operationResponse->operationSucceeded()) {
$result = $operationResponse->getResult();
// doSomethingWith($result)
} else {
$error = $operationResponse->getError();
// handleError($error)
}
// Alternatively:
// start the operation, keep the operation name, and resume later
$operationResponse = $clusterControllerClient->createCluster($projectId, $region, $cluster);
$operationName = $operationResponse->getName();
// ... do other work
$newOperationResponse = $clusterControllerClient->resumeOperation($operationName, 'createCluster');
while (!$newOperationResponse->isDone()) {
// ... do other work
$newOperationResponse->reload();
}
if ($newOperationResponse->operationSucceeded()) {
$result = $newOperationResponse->getResult();
// doSomethingWith($result)
} else {
$error = $newOperationResponse->getError();
// handleError($error)
}
} finally {
$clusterControllerClient->close();
}
```
@param string $projectId Required. The ID of the Google Cloud Platform project that the cluster
belongs to.
@param string $region Required. The Cloud Dataproc region in which to handle the request.
@param Cluster $cluster Required. The cluster to create.
@param array $optionalArgs {
Optional.
@type string $requestId
Optional. A unique id used to identify the request. If the server
receives two
[CreateClusterRequest][google.cloud.dataproc.v1beta2.CreateClusterRequest]
requests with the same id, then the second request will be ignored and the
first [google.longrunning.Operation][google.longrunning.Operation] created
and stored in the backend is returned.
It is recommended to always set this value to a
[UUID](https://en.wikipedia.org/wiki/Universally_unique_identifier).
The id must contain only letters (a-z, A-Z), numbers (0-9),
underscores (_), and hyphens (-). The maximum length is 40 characters.
@type RetrySettings|array $retrySettings
Retry settings to use for this call. Can be a
{@see Google\ApiCore\RetrySettings} object, or an associative array
of retry settings parameters. See the documentation on
{@see Google\ApiCore\RetrySettings} for example usage.
}
@return \Google\ApiCore\OperationResponse
@throws ApiException if the remote call fails
@experimental | [
"Creates",
"a",
"cluster",
"in",
"a",
"project",
"."
] | ff5030ffa1f12904565509a7bc24ecc0bd794a3e | https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Dataproc/src/V1beta2/Gapic/ClusterControllerGapicClient.php#L321-L337 | train |
googleapis/google-cloud-php | Dataproc/src/V1beta2/Gapic/ClusterControllerGapicClient.php | ClusterControllerGapicClient.updateCluster | public function updateCluster($projectId, $region, $clusterName, $cluster, $updateMask, array $optionalArgs = [])
{
$request = new UpdateClusterRequest();
$request->setProjectId($projectId);
$request->setRegion($region);
$request->setClusterName($clusterName);
$request->setCluster($cluster);
$request->setUpdateMask($updateMask);
if (isset($optionalArgs['gracefulDecommissionTimeout'])) {
$request->setGracefulDecommissionTimeout($optionalArgs['gracefulDecommissionTimeout']);
}
if (isset($optionalArgs['requestId'])) {
$request->setRequestId($optionalArgs['requestId']);
}
return $this->startOperationsCall(
'UpdateCluster',
$optionalArgs,
$request,
$this->getOperationsClient()
)->wait();
} | php | public function updateCluster($projectId, $region, $clusterName, $cluster, $updateMask, array $optionalArgs = [])
{
$request = new UpdateClusterRequest();
$request->setProjectId($projectId);
$request->setRegion($region);
$request->setClusterName($clusterName);
$request->setCluster($cluster);
$request->setUpdateMask($updateMask);
if (isset($optionalArgs['gracefulDecommissionTimeout'])) {
$request->setGracefulDecommissionTimeout($optionalArgs['gracefulDecommissionTimeout']);
}
if (isset($optionalArgs['requestId'])) {
$request->setRequestId($optionalArgs['requestId']);
}
return $this->startOperationsCall(
'UpdateCluster',
$optionalArgs,
$request,
$this->getOperationsClient()
)->wait();
} | [
"public",
"function",
"updateCluster",
"(",
"$",
"projectId",
",",
"$",
"region",
",",
"$",
"clusterName",
",",
"$",
"cluster",
",",
"$",
"updateMask",
",",
"array",
"$",
"optionalArgs",
"=",
"[",
"]",
")",
"{",
"$",
"request",
"=",
"new",
"UpdateClusterRequest",
"(",
")",
";",
"$",
"request",
"->",
"setProjectId",
"(",
"$",
"projectId",
")",
";",
"$",
"request",
"->",
"setRegion",
"(",
"$",
"region",
")",
";",
"$",
"request",
"->",
"setClusterName",
"(",
"$",
"clusterName",
")",
";",
"$",
"request",
"->",
"setCluster",
"(",
"$",
"cluster",
")",
";",
"$",
"request",
"->",
"setUpdateMask",
"(",
"$",
"updateMask",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"optionalArgs",
"[",
"'gracefulDecommissionTimeout'",
"]",
")",
")",
"{",
"$",
"request",
"->",
"setGracefulDecommissionTimeout",
"(",
"$",
"optionalArgs",
"[",
"'gracefulDecommissionTimeout'",
"]",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"optionalArgs",
"[",
"'requestId'",
"]",
")",
")",
"{",
"$",
"request",
"->",
"setRequestId",
"(",
"$",
"optionalArgs",
"[",
"'requestId'",
"]",
")",
";",
"}",
"return",
"$",
"this",
"->",
"startOperationsCall",
"(",
"'UpdateCluster'",
",",
"$",
"optionalArgs",
",",
"$",
"request",
",",
"$",
"this",
"->",
"getOperationsClient",
"(",
")",
")",
"->",
"wait",
"(",
")",
";",
"}"
] | Updates a cluster in a project.
Sample code:
```
$clusterControllerClient = new ClusterControllerClient();
try {
$projectId = '';
$region = '';
$clusterName = '';
$cluster = new Cluster();
$updateMask = new FieldMask();
$operationResponse = $clusterControllerClient->updateCluster($projectId, $region, $clusterName, $cluster, $updateMask);
$operationResponse->pollUntilComplete();
if ($operationResponse->operationSucceeded()) {
$result = $operationResponse->getResult();
// doSomethingWith($result)
} else {
$error = $operationResponse->getError();
// handleError($error)
}
// Alternatively:
// start the operation, keep the operation name, and resume later
$operationResponse = $clusterControllerClient->updateCluster($projectId, $region, $clusterName, $cluster, $updateMask);
$operationName = $operationResponse->getName();
// ... do other work
$newOperationResponse = $clusterControllerClient->resumeOperation($operationName, 'updateCluster');
while (!$newOperationResponse->isDone()) {
// ... do other work
$newOperationResponse->reload();
}
if ($newOperationResponse->operationSucceeded()) {
$result = $newOperationResponse->getResult();
// doSomethingWith($result)
} else {
$error = $newOperationResponse->getError();
// handleError($error)
}
} finally {
$clusterControllerClient->close();
}
```
@param string $projectId Required. The ID of the Google Cloud Platform project the
cluster belongs to.
@param string $region Required. The Cloud Dataproc region in which to handle the request.
@param string $clusterName Required. The cluster name.
@param Cluster $cluster Required. The changes to the cluster.
@param FieldMask $updateMask Required. Specifies the path, relative to `Cluster`, of
the field to update. For example, to change the number of workers
in a cluster to 5, the `update_mask` parameter would be
specified as `config.worker_config.num_instances`,
and the `PATCH` request body would specify the new value, as follows:
{
"config":{
"workerConfig":{
"numInstances":"5"
}
}
}
Similarly, to change the number of preemptible workers in a cluster to 5,
the `update_mask` parameter would be
`config.secondary_worker_config.num_instances`, and the `PATCH` request
body would be set as follows:
{
"config":{
"secondaryWorkerConfig":{
"numInstances":"5"
}
}
}
<strong>Note:</strong> currently only the following fields can be updated:
<table>
<tr>
<td><strong>Mask</strong></td><td><strong>Purpose</strong></td>
</tr>
<tr>
<td>labels</td><td>Updates labels</td>
</tr>
<tr>
<td>config.worker_config.num_instances</td><td>Resize primary worker
group</td>
</tr>
<tr>
<td>config.secondary_worker_config.num_instances</td><td>Resize secondary
worker group</td>
</tr>
<tr>
<td>config.lifecycle_config.auto_delete_ttl</td><td>Reset MAX TTL
duration</td>
</tr>
<tr>
<td>config.lifecycle_config.auto_delete_time</td><td>Update MAX TTL
deletion timestamp</td>
</tr>
<tr>
<td>config.lifecycle_config.idle_delete_ttl</td><td>Update Idle TTL
duration</td>
</tr>
</table>
@param array $optionalArgs {
Optional.
@type Duration $gracefulDecommissionTimeout
Optional. Timeout for graceful YARN decomissioning. Graceful
decommissioning allows removing nodes from the cluster without
interrupting jobs in progress. Timeout specifies how long to wait for jobs
in progress to finish before forcefully removing nodes (and potentially
interrupting jobs). Default timeout is 0 (for forceful decommission), and
the maximum allowed timeout is 1 day.
Only supported on Dataproc image versions 1.2 and higher.
@type string $requestId
Optional. A unique id used to identify the request. If the server
receives two
[UpdateClusterRequest][google.cloud.dataproc.v1beta2.UpdateClusterRequest]
requests with the same id, then the second request will be ignored and the
first [google.longrunning.Operation][google.longrunning.Operation] created
and stored in the backend is returned.
It is recommended to always set this value to a
[UUID](https://en.wikipedia.org/wiki/Universally_unique_identifier).
The id must contain only letters (a-z, A-Z), numbers (0-9),
underscores (_), and hyphens (-). The maximum length is 40 characters.
@type RetrySettings|array $retrySettings
Retry settings to use for this call. Can be a
{@see Google\ApiCore\RetrySettings} object, or an associative array
of retry settings parameters. See the documentation on
{@see Google\ApiCore\RetrySettings} for example usage.
}
@return \Google\ApiCore\OperationResponse
@throws ApiException if the remote call fails
@experimental | [
"Updates",
"a",
"cluster",
"in",
"a",
"project",
"."
] | ff5030ffa1f12904565509a7bc24ecc0bd794a3e | https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Dataproc/src/V1beta2/Gapic/ClusterControllerGapicClient.php#L483-L504 | train |
googleapis/google-cloud-php | Dataproc/src/V1beta2/Gapic/ClusterControllerGapicClient.php | ClusterControllerGapicClient.deleteCluster | public function deleteCluster($projectId, $region, $clusterName, array $optionalArgs = [])
{
$request = new DeleteClusterRequest();
$request->setProjectId($projectId);
$request->setRegion($region);
$request->setClusterName($clusterName);
if (isset($optionalArgs['clusterUuid'])) {
$request->setClusterUuid($optionalArgs['clusterUuid']);
}
if (isset($optionalArgs['requestId'])) {
$request->setRequestId($optionalArgs['requestId']);
}
return $this->startOperationsCall(
'DeleteCluster',
$optionalArgs,
$request,
$this->getOperationsClient()
)->wait();
} | php | public function deleteCluster($projectId, $region, $clusterName, array $optionalArgs = [])
{
$request = new DeleteClusterRequest();
$request->setProjectId($projectId);
$request->setRegion($region);
$request->setClusterName($clusterName);
if (isset($optionalArgs['clusterUuid'])) {
$request->setClusterUuid($optionalArgs['clusterUuid']);
}
if (isset($optionalArgs['requestId'])) {
$request->setRequestId($optionalArgs['requestId']);
}
return $this->startOperationsCall(
'DeleteCluster',
$optionalArgs,
$request,
$this->getOperationsClient()
)->wait();
} | [
"public",
"function",
"deleteCluster",
"(",
"$",
"projectId",
",",
"$",
"region",
",",
"$",
"clusterName",
",",
"array",
"$",
"optionalArgs",
"=",
"[",
"]",
")",
"{",
"$",
"request",
"=",
"new",
"DeleteClusterRequest",
"(",
")",
";",
"$",
"request",
"->",
"setProjectId",
"(",
"$",
"projectId",
")",
";",
"$",
"request",
"->",
"setRegion",
"(",
"$",
"region",
")",
";",
"$",
"request",
"->",
"setClusterName",
"(",
"$",
"clusterName",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"optionalArgs",
"[",
"'clusterUuid'",
"]",
")",
")",
"{",
"$",
"request",
"->",
"setClusterUuid",
"(",
"$",
"optionalArgs",
"[",
"'clusterUuid'",
"]",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"optionalArgs",
"[",
"'requestId'",
"]",
")",
")",
"{",
"$",
"request",
"->",
"setRequestId",
"(",
"$",
"optionalArgs",
"[",
"'requestId'",
"]",
")",
";",
"}",
"return",
"$",
"this",
"->",
"startOperationsCall",
"(",
"'DeleteCluster'",
",",
"$",
"optionalArgs",
",",
"$",
"request",
",",
"$",
"this",
"->",
"getOperationsClient",
"(",
")",
")",
"->",
"wait",
"(",
")",
";",
"}"
] | Deletes a cluster in a project.
Sample code:
```
$clusterControllerClient = new ClusterControllerClient();
try {
$projectId = '';
$region = '';
$clusterName = '';
$operationResponse = $clusterControllerClient->deleteCluster($projectId, $region, $clusterName);
$operationResponse->pollUntilComplete();
if ($operationResponse->operationSucceeded()) {
// operation succeeded and returns no value
} else {
$error = $operationResponse->getError();
// handleError($error)
}
// Alternatively:
// start the operation, keep the operation name, and resume later
$operationResponse = $clusterControllerClient->deleteCluster($projectId, $region, $clusterName);
$operationName = $operationResponse->getName();
// ... do other work
$newOperationResponse = $clusterControllerClient->resumeOperation($operationName, 'deleteCluster');
while (!$newOperationResponse->isDone()) {
// ... do other work
$newOperationResponse->reload();
}
if ($newOperationResponse->operationSucceeded()) {
// operation succeeded and returns no value
} else {
$error = $newOperationResponse->getError();
// handleError($error)
}
} finally {
$clusterControllerClient->close();
}
```
@param string $projectId Required. The ID of the Google Cloud Platform project that the cluster
belongs to.
@param string $region Required. The Cloud Dataproc region in which to handle the request.
@param string $clusterName Required. The cluster name.
@param array $optionalArgs {
Optional.
@type string $clusterUuid
Optional. Specifying the `cluster_uuid` means the RPC should fail
(with error NOT_FOUND) if cluster with specified UUID does not exist.
@type string $requestId
Optional. A unique id used to identify the request. If the server
receives two
[DeleteClusterRequest][google.cloud.dataproc.v1beta2.DeleteClusterRequest]
requests with the same id, then the second request will be ignored and the
first [google.longrunning.Operation][google.longrunning.Operation] created
and stored in the backend is returned.
It is recommended to always set this value to a
[UUID](https://en.wikipedia.org/wiki/Universally_unique_identifier).
The id must contain only letters (a-z, A-Z), numbers (0-9),
underscores (_), and hyphens (-). The maximum length is 40 characters.
@type RetrySettings|array $retrySettings
Retry settings to use for this call. Can be a
{@see Google\ApiCore\RetrySettings} object, or an associative array
of retry settings parameters. See the documentation on
{@see Google\ApiCore\RetrySettings} for example usage.
}
@return \Google\ApiCore\OperationResponse
@throws ApiException if the remote call fails
@experimental | [
"Deletes",
"a",
"cluster",
"in",
"a",
"project",
"."
] | ff5030ffa1f12904565509a7bc24ecc0bd794a3e | https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Dataproc/src/V1beta2/Gapic/ClusterControllerGapicClient.php#L583-L602 | train |
googleapis/google-cloud-php | dev/src/DocGenerator/Parser/CodeParser.php | CodeParser.buildNestedParams | private function buildNestedParams($nestedParams, $origParam, $isProto = false)
{
$paramsArray = [];
foreach ($nestedParams as $param) {
$nestedParam = explode(' ', trim($param), 3);
// START proto nested arg missing description workaround
if (count($nestedParam) < 3 && !$isProto) {
throw new \Exception('nested param is in an invalid format: '. $param);
}
// END proto nested arg missing description workaround
list($type, $name, $description) = $nestedParam;
$name = substr($name, 1);
$description = preg_replace('/\s+/', ' ', $description);
$types = new Collection(
array($type),
$origParam->getDocBlock() ? $origParam->getDocBlock()->getContext() : null
);
$paramsArray[] = [
'name' => substr($origParam->getVariableName(), 1) . '.' . $name,
'description' => $this->buildDescription($origParam->getDocBlock(), $description, $origParam),
'types' => $this->handleTypes($types),
'optional' => null, // @todo
'nullable' => null //@todo
];
}
return $paramsArray;
} | php | private function buildNestedParams($nestedParams, $origParam, $isProto = false)
{
$paramsArray = [];
foreach ($nestedParams as $param) {
$nestedParam = explode(' ', trim($param), 3);
// START proto nested arg missing description workaround
if (count($nestedParam) < 3 && !$isProto) {
throw new \Exception('nested param is in an invalid format: '. $param);
}
// END proto nested arg missing description workaround
list($type, $name, $description) = $nestedParam;
$name = substr($name, 1);
$description = preg_replace('/\s+/', ' ', $description);
$types = new Collection(
array($type),
$origParam->getDocBlock() ? $origParam->getDocBlock()->getContext() : null
);
$paramsArray[] = [
'name' => substr($origParam->getVariableName(), 1) . '.' . $name,
'description' => $this->buildDescription($origParam->getDocBlock(), $description, $origParam),
'types' => $this->handleTypes($types),
'optional' => null, // @todo
'nullable' => null //@todo
];
}
return $paramsArray;
} | [
"private",
"function",
"buildNestedParams",
"(",
"$",
"nestedParams",
",",
"$",
"origParam",
",",
"$",
"isProto",
"=",
"false",
")",
"{",
"$",
"paramsArray",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"nestedParams",
"as",
"$",
"param",
")",
"{",
"$",
"nestedParam",
"=",
"explode",
"(",
"' '",
",",
"trim",
"(",
"$",
"param",
")",
",",
"3",
")",
";",
"// START proto nested arg missing description workaround",
"if",
"(",
"count",
"(",
"$",
"nestedParam",
")",
"<",
"3",
"&&",
"!",
"$",
"isProto",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'nested param is in an invalid format: '",
".",
"$",
"param",
")",
";",
"}",
"// END proto nested arg missing description workaround",
"list",
"(",
"$",
"type",
",",
"$",
"name",
",",
"$",
"description",
")",
"=",
"$",
"nestedParam",
";",
"$",
"name",
"=",
"substr",
"(",
"$",
"name",
",",
"1",
")",
";",
"$",
"description",
"=",
"preg_replace",
"(",
"'/\\s+/'",
",",
"' '",
",",
"$",
"description",
")",
";",
"$",
"types",
"=",
"new",
"Collection",
"(",
"array",
"(",
"$",
"type",
")",
",",
"$",
"origParam",
"->",
"getDocBlock",
"(",
")",
"?",
"$",
"origParam",
"->",
"getDocBlock",
"(",
")",
"->",
"getContext",
"(",
")",
":",
"null",
")",
";",
"$",
"paramsArray",
"[",
"]",
"=",
"[",
"'name'",
"=>",
"substr",
"(",
"$",
"origParam",
"->",
"getVariableName",
"(",
")",
",",
"1",
")",
".",
"'.'",
".",
"$",
"name",
",",
"'description'",
"=>",
"$",
"this",
"->",
"buildDescription",
"(",
"$",
"origParam",
"->",
"getDocBlock",
"(",
")",
",",
"$",
"description",
",",
"$",
"origParam",
")",
",",
"'types'",
"=>",
"$",
"this",
"->",
"handleTypes",
"(",
"$",
"types",
")",
",",
"'optional'",
"=>",
"null",
",",
"// @todo",
"'nullable'",
"=>",
"null",
"//@todo",
"]",
";",
"}",
"return",
"$",
"paramsArray",
";",
"}"
] | PHPDoc has no support for nested params currently. this is a workaround
until it is implemented. | [
"PHPDoc",
"has",
"no",
"support",
"for",
"nested",
"params",
"currently",
".",
"this",
"is",
"a",
"workaround",
"until",
"it",
"is",
"implemented",
"."
] | ff5030ffa1f12904565509a7bc24ecc0bd794a3e | https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/dev/src/DocGenerator/Parser/CodeParser.php#L600-L632 | train |
googleapis/google-cloud-php | PubSub/src/Subscription.php | Subscription.create | public function create(array $options = [])
{
// If a subscription is created via PubSubClient::subscription(),
// it may or may not have a topic name. This is fine for most API
// interactions, but a topic name is required to create a subscription.
if (!$this->topicName) {
throw new InvalidArgumentException('A topic name is required to
create a subscription.');
}
$this->info = $this->connection->createSubscription($options + [
'name' => $this->name,
'topic' => $this->topicName
]);
return $this->info;
} | php | public function create(array $options = [])
{
// If a subscription is created via PubSubClient::subscription(),
// it may or may not have a topic name. This is fine for most API
// interactions, but a topic name is required to create a subscription.
if (!$this->topicName) {
throw new InvalidArgumentException('A topic name is required to
create a subscription.');
}
$this->info = $this->connection->createSubscription($options + [
'name' => $this->name,
'topic' => $this->topicName
]);
return $this->info;
} | [
"public",
"function",
"create",
"(",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"// If a subscription is created via PubSubClient::subscription(),",
"// it may or may not have a topic name. This is fine for most API",
"// interactions, but a topic name is required to create a subscription.",
"if",
"(",
"!",
"$",
"this",
"->",
"topicName",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"'A topic name is required to\n create a subscription.'",
")",
";",
"}",
"$",
"this",
"->",
"info",
"=",
"$",
"this",
"->",
"connection",
"->",
"createSubscription",
"(",
"$",
"options",
"+",
"[",
"'name'",
"=>",
"$",
"this",
"->",
"name",
",",
"'topic'",
"=>",
"$",
"this",
"->",
"topicName",
"]",
")",
";",
"return",
"$",
"this",
"->",
"info",
";",
"}"
] | Execute a service request creating the subscription.
The suggested way of creating a subscription is by calling through
{@see Google\Cloud\PubSub\Topic::subscribe()} or {@see Google\Cloud\PubSub\Topic::subscription()}.
Returns subscription info in the format detailed in the documentation
for a [subscription](https://cloud.google.com/pubsub/docs/reference/rest/v1/projects.subscriptions#Subscription).
**NOTE: Some methods of instantiation of a Subscription do not supply a
topic name. The topic name is required to create a subscription.**
Example:
```
$topic = $pubsub->topic('my-new-topic');
$subscription = $topic->subscription('my-new-subscription');
$result = $subscription->create();
```
@see https://cloud.google.com/pubsub/docs/reference/rest/v1/projects.subscriptions/create Create Subscription
@param array $options [optional] {
Configuration Options
For information regarding the push configuration settings, see
[PushConfig](https://cloud.google.com/pubsub/docs/reference/rest/v1/projects.subscriptions#PushConfig).
@type string $pushConfig.pushEndpoint A URL locating the endpoint to which
messages should be pushed. For example, a Webhook endpoint
might use "https://example.com/push".
@type array $pushConfig.attributes Endpoint configuration attributes.
@type int $ackDeadlineSeconds The maximum time after a subscriber
receives a message before the subscriber should acknowledge the
message.
@type bool $retainAckedMessages Indicates whether to retain
acknowledged messages.
@type Duration $messageRetentionDuration How long to retain
unacknowledged messages in the subscription's backlog, from the
moment a message is published. If `$retainAckedMessages` is
true, then this also configures the retention of acknowledged
messages, and thus configures how far back in time a `Seek`
can be done. Cannot be more than 7 days or less than 10 minutes.
**Defaults to** 7 days.
}
@return array An array of subscription info
@throws \InvalidArgumentException | [
"Execute",
"a",
"service",
"request",
"creating",
"the",
"subscription",
"."
] | ff5030ffa1f12904565509a7bc24ecc0bd794a3e | https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/PubSub/src/Subscription.php#L207-L223 | train |
googleapis/google-cloud-php | PubSub/src/Subscription.php | Subscription.update | public function update(array $subscription, array $options = [])
{
return $this->info = $this->connection->updateSubscription([
'name' => $this->name
] + $options + $subscription);
} | php | public function update(array $subscription, array $options = [])
{
return $this->info = $this->connection->updateSubscription([
'name' => $this->name
] + $options + $subscription);
} | [
"public",
"function",
"update",
"(",
"array",
"$",
"subscription",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"return",
"$",
"this",
"->",
"info",
"=",
"$",
"this",
"->",
"connection",
"->",
"updateSubscription",
"(",
"[",
"'name'",
"=>",
"$",
"this",
"->",
"name",
"]",
"+",
"$",
"options",
"+",
"$",
"subscription",
")",
";",
"}"
] | Update the subscription.
Note that subscription name and topic are immutable properties and may
not be modified.
Example:
```
$subscription->update([
'retainAckedMessages' => true
]);
```
@param array $subscription {
The Subscription data.
For information regarding the push configuration settings, see
[PushConfig](https://cloud.google.com/pubsub/docs/reference/rest/v1/projects.subscriptions#PushConfig).
@type string $pushConfig.pushEndpoint A URL locating the endpoint to which
messages should be pushed. For example, a Webhook endpoint
might use "https://example.com/push".
@type array $pushConfig.attributes Endpoint configuration attributes.
@type int $ackDeadlineSeconds The maximum time after a subscriber
receives a message before the subscriber should acknowledge the
message.
@type bool $retainAckedMessages Indicates whether to retain
acknowledged messages.
@type Duration $messageRetentionDuration How long to retain
unacknowledged messages in the subscription's backlog, from the
moment a message is published. If `$retainAckedMessages` is
true, then this also configures the retention of acknowledged
messages, and thus configures how far back in time a `Seek`
can be done. Cannot be more than 7 days or less than 10 minutes.
**Defaults to** 7 days.
}
@param array $options [optional] Configuration options.
@return array The subscription info. | [
"Update",
"the",
"subscription",
"."
] | ff5030ffa1f12904565509a7bc24ecc0bd794a3e | https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/PubSub/src/Subscription.php#L264-L269 | train |
googleapis/google-cloud-php | PubSub/src/Subscription.php | Subscription.reload | public function reload(array $options = [])
{
return $this->info = $this->connection->getSubscription($options + [
'subscription' => $this->name
]);
} | php | public function reload(array $options = [])
{
return $this->info = $this->connection->getSubscription($options + [
'subscription' => $this->name
]);
} | [
"public",
"function",
"reload",
"(",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"return",
"$",
"this",
"->",
"info",
"=",
"$",
"this",
"->",
"connection",
"->",
"getSubscription",
"(",
"$",
"options",
"+",
"[",
"'subscription'",
"=>",
"$",
"this",
"->",
"name",
"]",
")",
";",
"}"
] | Retrieve info on a subscription from the API.
To use the previously cached result (if it exists), use
{@see Subscription::info()}.
Example:
```
$subscription->reload();
$info = $subscription->info();
echo $info['name']; // `projects/my-awesome-project/subscriptions/my-new-subscription`
```
@see https://cloud.google.com/pubsub/docs/reference/rest/v1/projects.subscriptions/get Get Subscription
@param array $options [optional] Configuration Options
@return array Subscription data | [
"Retrieve",
"info",
"on",
"a",
"subscription",
"from",
"the",
"API",
"."
] | ff5030ffa1f12904565509a7bc24ecc0bd794a3e | https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/PubSub/src/Subscription.php#L366-L371 | train |
googleapis/google-cloud-php | PubSub/src/Subscription.php | Subscription.pull | public function pull(array $options = [])
{
$messages = [];
$options['returnImmediately'] = isset($options['returnImmediately'])
? $options['returnImmediately']
: false;
$options['maxMessages'] = isset($options['maxMessages'])
? $options['maxMessages']
: self::MAX_MESSAGES;
$response = $this->connection->pull($options + [
'subscription' => $this->name
]);
if (isset($response['receivedMessages'])) {
foreach ($response['receivedMessages'] as $message) {
$messages[] = $this->messageFactory($message, $this->connection, $this->projectId, $this->encode);
}
}
return $messages;
} | php | public function pull(array $options = [])
{
$messages = [];
$options['returnImmediately'] = isset($options['returnImmediately'])
? $options['returnImmediately']
: false;
$options['maxMessages'] = isset($options['maxMessages'])
? $options['maxMessages']
: self::MAX_MESSAGES;
$response = $this->connection->pull($options + [
'subscription' => $this->name
]);
if (isset($response['receivedMessages'])) {
foreach ($response['receivedMessages'] as $message) {
$messages[] = $this->messageFactory($message, $this->connection, $this->projectId, $this->encode);
}
}
return $messages;
} | [
"public",
"function",
"pull",
"(",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"messages",
"=",
"[",
"]",
";",
"$",
"options",
"[",
"'returnImmediately'",
"]",
"=",
"isset",
"(",
"$",
"options",
"[",
"'returnImmediately'",
"]",
")",
"?",
"$",
"options",
"[",
"'returnImmediately'",
"]",
":",
"false",
";",
"$",
"options",
"[",
"'maxMessages'",
"]",
"=",
"isset",
"(",
"$",
"options",
"[",
"'maxMessages'",
"]",
")",
"?",
"$",
"options",
"[",
"'maxMessages'",
"]",
":",
"self",
"::",
"MAX_MESSAGES",
";",
"$",
"response",
"=",
"$",
"this",
"->",
"connection",
"->",
"pull",
"(",
"$",
"options",
"+",
"[",
"'subscription'",
"=>",
"$",
"this",
"->",
"name",
"]",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"response",
"[",
"'receivedMessages'",
"]",
")",
")",
"{",
"foreach",
"(",
"$",
"response",
"[",
"'receivedMessages'",
"]",
"as",
"$",
"message",
")",
"{",
"$",
"messages",
"[",
"]",
"=",
"$",
"this",
"->",
"messageFactory",
"(",
"$",
"message",
",",
"$",
"this",
"->",
"connection",
",",
"$",
"this",
"->",
"projectId",
",",
"$",
"this",
"->",
"encode",
")",
";",
"}",
"}",
"return",
"$",
"messages",
";",
"}"
] | Retrieve new messages from the topic.
Example:
```
$messages = $subscription->pull();
foreach ($messages as $message) {
echo $message->data();
}
```
@see https://cloud.google.com/pubsub/docs/reference/rest/v1/projects.subscriptions/pull Pull Subscriptions
@param array $options [optional] {
Configuration Options
@type bool $returnImmediately If true, the system will respond
immediately, even if no messages are available. Otherwise,
wait until new messages are available. **Defaults to**
`false`.
@type int $maxMessages Limit the amount of messages pulled.
**Defaults to** `1000`.
}
@return Message[] | [
"Retrieve",
"new",
"messages",
"from",
"the",
"topic",
"."
] | ff5030ffa1f12904565509a7bc24ecc0bd794a3e | https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/PubSub/src/Subscription.php#L398-L419 | train |
googleapis/google-cloud-php | PubSub/src/Subscription.php | Subscription.acknowledgeBatch | public function acknowledgeBatch(array $messages, array $options = [])
{
$this->validateBatch($messages, Message::class);
$this->connection->acknowledge($options + [
'subscription' => $this->name,
'ackIds' => $this->getMessageAckIds($messages)
]);
} | php | public function acknowledgeBatch(array $messages, array $options = [])
{
$this->validateBatch($messages, Message::class);
$this->connection->acknowledge($options + [
'subscription' => $this->name,
'ackIds' => $this->getMessageAckIds($messages)
]);
} | [
"public",
"function",
"acknowledgeBatch",
"(",
"array",
"$",
"messages",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"this",
"->",
"validateBatch",
"(",
"$",
"messages",
",",
"Message",
"::",
"class",
")",
";",
"$",
"this",
"->",
"connection",
"->",
"acknowledge",
"(",
"$",
"options",
"+",
"[",
"'subscription'",
"=>",
"$",
"this",
"->",
"name",
",",
"'ackIds'",
"=>",
"$",
"this",
"->",
"getMessageAckIds",
"(",
"$",
"messages",
")",
"]",
")",
";",
"}"
] | Acknowledge receipt of multiple messages at once.
Use {@see Google\Cloud\PubSub\Subscription::acknowledge()} to acknowledge
a single message.
Example:
```
$messages = $subscription->pull();
$subscription->acknowledgeBatch($messages);
```
@codingStandardsIgnoreStart
@see https://cloud.google.com/pubsub/docs/reference/rest/v1/projects.subscriptions/acknowledge Acknowledge Message
@codingStandardsIgnoreEnd
@param Message[] $messages An array of messages
@param array $options Configuration Options
@return void | [
"Acknowledge",
"receipt",
"of",
"multiple",
"messages",
"at",
"once",
"."
] | ff5030ffa1f12904565509a7bc24ecc0bd794a3e | https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/PubSub/src/Subscription.php#L468-L476 | train |
googleapis/google-cloud-php | PubSub/src/Subscription.php | Subscription.modifyAckDeadline | public function modifyAckDeadline(Message $message, $seconds, array $options = [])
{
$this->modifyAckDeadlineBatch([$message], $seconds, $options);
} | php | public function modifyAckDeadline(Message $message, $seconds, array $options = [])
{
$this->modifyAckDeadlineBatch([$message], $seconds, $options);
} | [
"public",
"function",
"modifyAckDeadline",
"(",
"Message",
"$",
"message",
",",
"$",
"seconds",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"this",
"->",
"modifyAckDeadlineBatch",
"(",
"[",
"$",
"message",
"]",
",",
"$",
"seconds",
",",
"$",
"options",
")",
";",
"}"
] | Set the acknowledge deadline for a single ackId.
Use {@see Google\Cloud\PubSub\Subscription::modifyAckDeadlineBatch()} to
modify the ack deadline for multiple messages at once.
Example:
```
$messages = $subscription->pull();
foreach ($messages as $message) {
$subscription->modifyAckDeadline($message, 3);
sleep(2);
// Now we'll acknowledge!
$subscription->acknowledge($message);
break;
}
```
@codingStandardsIgnoreStart
@see https://cloud.google.com/pubsub/docs/reference/rest/v1/projects.subscriptions/modifyAckDeadline Modify Ack Deadline
@codingStandardsIgnoreEnd
@param Message $message A message object
@param int $seconds The new ack deadline with respect to the time
this request was sent to the Pub/Sub system. Must be >= 0. For
example, if the value is 10, the new ack deadline will expire 10
seconds after the ModifyAckDeadline call was made. Specifying
zero may immediately make the message available for another pull
request.
@param array $options [optional] Configuration Options
@return void | [
"Set",
"the",
"acknowledge",
"deadline",
"for",
"a",
"single",
"ackId",
"."
] | ff5030ffa1f12904565509a7bc24ecc0bd794a3e | https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/PubSub/src/Subscription.php#L513-L516 | train |
googleapis/google-cloud-php | PubSub/src/Subscription.php | Subscription.modifyAckDeadlineBatch | public function modifyAckDeadlineBatch(array $messages, $seconds, array $options = [])
{
$this->validateBatch($messages, Message::class);
$this->connection->modifyAckDeadline($options + [
'subscription' => $this->name,
'ackIds' => $this->getMessageAckIds($messages),
'ackDeadlineSeconds' => $seconds
]);
} | php | public function modifyAckDeadlineBatch(array $messages, $seconds, array $options = [])
{
$this->validateBatch($messages, Message::class);
$this->connection->modifyAckDeadline($options + [
'subscription' => $this->name,
'ackIds' => $this->getMessageAckIds($messages),
'ackDeadlineSeconds' => $seconds
]);
} | [
"public",
"function",
"modifyAckDeadlineBatch",
"(",
"array",
"$",
"messages",
",",
"$",
"seconds",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"this",
"->",
"validateBatch",
"(",
"$",
"messages",
",",
"Message",
"::",
"class",
")",
";",
"$",
"this",
"->",
"connection",
"->",
"modifyAckDeadline",
"(",
"$",
"options",
"+",
"[",
"'subscription'",
"=>",
"$",
"this",
"->",
"name",
",",
"'ackIds'",
"=>",
"$",
"this",
"->",
"getMessageAckIds",
"(",
"$",
"messages",
")",
",",
"'ackDeadlineSeconds'",
"=>",
"$",
"seconds",
"]",
")",
";",
"}"
] | Set the acknowledge deadline for multiple ackIds.
Use {@see Google\Cloud\PubSub\Subscription::modifyAckDeadline()} to
modify the ack deadline for a single message.
Example:
```
$messages = $subscription->pull();
// Set the ack deadline to three seconds from now for every message
$subscription->modifyAckDeadlineBatch($messages, 3);
// Delay execution, or make a sandwich or something.
sleep(2);
// Now we'll acknowledge
$subscription->acknowledgeBatch($messages);
```
@codingStandardsIgnoreStart
@see https://cloud.google.com/pubsub/docs/reference/rest/v1/projects.subscriptions/modifyAckDeadline Modify Ack Deadline
@codingStandardsIgnoreEnd
@param Message[] $messages An array of messages
@param int $seconds The new ack deadline with respect to the time
this request was sent to the Pub/Sub system. Must be >= 0. For
example, if the value is 10, the new ack deadline will expire 10
seconds after the ModifyAckDeadline call was made. Specifying
zero may immediately make the message available for another pull
request.
@param array $options [optional] Configuration Options
@return void | [
"Set",
"the",
"acknowledge",
"deadline",
"for",
"multiple",
"ackIds",
"."
] | ff5030ffa1f12904565509a7bc24ecc0bd794a3e | https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/PubSub/src/Subscription.php#L552-L561 | train |
googleapis/google-cloud-php | PubSub/src/Subscription.php | Subscription.modifyPushConfig | public function modifyPushConfig(array $pushConfig, array $options = [])
{
$this->connection->modifyPushConfig($options + [
'subscription' => $this->name,
'pushConfig' => $pushConfig
]);
} | php | public function modifyPushConfig(array $pushConfig, array $options = [])
{
$this->connection->modifyPushConfig($options + [
'subscription' => $this->name,
'pushConfig' => $pushConfig
]);
} | [
"public",
"function",
"modifyPushConfig",
"(",
"array",
"$",
"pushConfig",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"this",
"->",
"connection",
"->",
"modifyPushConfig",
"(",
"$",
"options",
"+",
"[",
"'subscription'",
"=>",
"$",
"this",
"->",
"name",
",",
"'pushConfig'",
"=>",
"$",
"pushConfig",
"]",
")",
";",
"}"
] | Set the push config for the subscription
Example:
```
$subscription->modifyPushConfig([
'pushEndpoint' => 'https://www.example.com/foo/bar'
]);
```
@codingStandardsIgnoreStart
@see https://cloud.google.com/pubsub/docs/reference/rest/v1/projects.subscriptions/modifyPushConfig Modify Push Config
@codingStandardsIgnoreEnd
@param array $pushConfig {
Push delivery configuration. See
[PushConfig](https://cloud.google.com/pubsub/docs/reference/rest/v1/projects.subscriptions#PushConfig)
for more details.
@type string $pushEndpoint A URL locating the endpoint to which
messages should be pushed. For example, a Webhook endpoint
might use "https://example.com/push".
@type array $attributes Endpoint configuration attributes.
}
@param array $options [optional] Configuration Options
@return void | [
"Set",
"the",
"push",
"config",
"for",
"the",
"subscription"
] | ff5030ffa1f12904565509a7bc24ecc0bd794a3e | https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/PubSub/src/Subscription.php#L590-L596 | train |
googleapis/google-cloud-php | PubSub/src/Subscription.php | Subscription.seekToTime | public function seekToTime(Timestamp $timestamp)
{
return $this->connection->seek([
'subscription' => $this->name,
'time' => $timestamp->formatAsString()
]);
} | php | public function seekToTime(Timestamp $timestamp)
{
return $this->connection->seek([
'subscription' => $this->name,
'time' => $timestamp->formatAsString()
]);
} | [
"public",
"function",
"seekToTime",
"(",
"Timestamp",
"$",
"timestamp",
")",
"{",
"return",
"$",
"this",
"->",
"connection",
"->",
"seek",
"(",
"[",
"'subscription'",
"=>",
"$",
"this",
"->",
"name",
",",
"'time'",
"=>",
"$",
"timestamp",
"->",
"formatAsString",
"(",
")",
"]",
")",
";",
"}"
] | Seek to a given timestamp.
When you seek to a time, it has the effect of marking every message
received before this time as acknowledged, and all messages received
after the time as unacknowledged.
Please note that this method may not yet be available in your project.
Example:
```
$time = $pubsub->timestamp(new \DateTime('2017-04-01'));
$subscription->seekToTime($time);
```
@param Timestamp $timestamp The time to seek to.
@return void | [
"Seek",
"to",
"a",
"given",
"timestamp",
"."
] | ff5030ffa1f12904565509a7bc24ecc0bd794a3e | https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/PubSub/src/Subscription.php#L616-L622 | train |
googleapis/google-cloud-php | PubSub/src/Subscription.php | Subscription.seekToSnapshot | public function seekToSnapshot(Snapshot $snapshot)
{
return $this->connection->seek([
'subscription' => $this->name,
'snapshot' => $snapshot->name()
]);
} | php | public function seekToSnapshot(Snapshot $snapshot)
{
return $this->connection->seek([
'subscription' => $this->name,
'snapshot' => $snapshot->name()
]);
} | [
"public",
"function",
"seekToSnapshot",
"(",
"Snapshot",
"$",
"snapshot",
")",
"{",
"return",
"$",
"this",
"->",
"connection",
"->",
"seek",
"(",
"[",
"'subscription'",
"=>",
"$",
"this",
"->",
"name",
",",
"'snapshot'",
"=>",
"$",
"snapshot",
"->",
"name",
"(",
")",
"]",
")",
";",
"}"
] | Seek to a given snapshot.
When seeking to a snapshot, any message that had an "unacknowledged"
state when the snapshot was created can be re-delivered.
Please note that this method may not yet be available in your project.
Example:
```
$snapshot = $pubsub->snapshot('my-snapshot');
$subscription->seekToSnapshot($snapshot);
```
@param Snapshot $snapshot The snapshot to seek to.
@return void | [
"Seek",
"to",
"a",
"given",
"snapshot",
"."
] | ff5030ffa1f12904565509a7bc24ecc0bd794a3e | https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/PubSub/src/Subscription.php#L641-L647 | train |
googleapis/google-cloud-php | PubSub/src/Subscription.php | Subscription.iam | public function iam()
{
if (!$this->iam) {
$iamConnection = new IamSubscription($this->connection);
$this->iam = new Iam($iamConnection, $this->name);
}
return $this->iam;
} | php | public function iam()
{
if (!$this->iam) {
$iamConnection = new IamSubscription($this->connection);
$this->iam = new Iam($iamConnection, $this->name);
}
return $this->iam;
} | [
"public",
"function",
"iam",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"iam",
")",
"{",
"$",
"iamConnection",
"=",
"new",
"IamSubscription",
"(",
"$",
"this",
"->",
"connection",
")",
";",
"$",
"this",
"->",
"iam",
"=",
"new",
"Iam",
"(",
"$",
"iamConnection",
",",
"$",
"this",
"->",
"name",
")",
";",
"}",
"return",
"$",
"this",
"->",
"iam",
";",
"}"
] | Manage the IAM policy for the current Subscription.
Example:
```
$iam = $subscription->iam();
```
@codingStandardsIgnoreStart
@see https://cloud.google.com/pubsub/access_control PubSub Access Control Documentation
@see https://cloud.google.com/pubsub/docs/reference/rest/v1/projects.subscriptions/getIamPolicy Get Subscription IAM Policy
@see https://cloud.google.com/pubsub/docs/reference/rest/v1/projects.subscriptions/setIamPolicy Set Subscription IAM Policy
@see https://cloud.google.com/pubsub/docs/reference/rest/v1/projects.subscriptions/testIamPermissions Test Subscription Permissions
@codingStandardsIgnoreEnd
@return Iam | [
"Manage",
"the",
"IAM",
"policy",
"for",
"the",
"current",
"Subscription",
"."
] | ff5030ffa1f12904565509a7bc24ecc0bd794a3e | https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/PubSub/src/Subscription.php#L666-L674 | train |
googleapis/google-cloud-php | PubSub/src/Subscription.php | Subscription.getMessageAckIds | private function getMessageAckIds(array $messages)
{
$ackIds = [];
foreach ($messages as $message) {
$ackIds[] = $message->ackId();
}
return $ackIds;
} | php | private function getMessageAckIds(array $messages)
{
$ackIds = [];
foreach ($messages as $message) {
$ackIds[] = $message->ackId();
}
return $ackIds;
} | [
"private",
"function",
"getMessageAckIds",
"(",
"array",
"$",
"messages",
")",
"{",
"$",
"ackIds",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"messages",
"as",
"$",
"message",
")",
"{",
"$",
"ackIds",
"[",
"]",
"=",
"$",
"message",
"->",
"ackId",
"(",
")",
";",
"}",
"return",
"$",
"ackIds",
";",
"}"
] | Get a list of ackIds from a list of Message objects.
@param Message[] $messages The messages
@return array | [
"Get",
"a",
"list",
"of",
"ackIds",
"from",
"a",
"list",
"of",
"Message",
"objects",
"."
] | ff5030ffa1f12904565509a7bc24ecc0bd794a3e | https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/PubSub/src/Subscription.php#L682-L690 | train |
googleapis/google-cloud-php | TextToSpeech/src/V1/SynthesizeSpeechRequest.php | SynthesizeSpeechRequest.setInput | public function setInput($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\TextToSpeech\V1\SynthesisInput::class);
$this->input = $var;
return $this;
} | php | public function setInput($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\TextToSpeech\V1\SynthesisInput::class);
$this->input = $var;
return $this;
} | [
"public",
"function",
"setInput",
"(",
"$",
"var",
")",
"{",
"GPBUtil",
"::",
"checkMessage",
"(",
"$",
"var",
",",
"\\",
"Google",
"\\",
"Cloud",
"\\",
"TextToSpeech",
"\\",
"V1",
"\\",
"SynthesisInput",
"::",
"class",
")",
";",
"$",
"this",
"->",
"input",
"=",
"$",
"var",
";",
"return",
"$",
"this",
";",
"}"
] | Required. The Synthesizer requires either plain text or SSML as input.
Generated from protobuf field <code>.google.cloud.texttospeech.v1.SynthesisInput input = 1;</code>
@param \Google\Cloud\TextToSpeech\V1\SynthesisInput $var
@return $this | [
"Required",
".",
"The",
"Synthesizer",
"requires",
"either",
"plain",
"text",
"or",
"SSML",
"as",
"input",
"."
] | ff5030ffa1f12904565509a7bc24ecc0bd794a3e | https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/TextToSpeech/src/V1/SynthesizeSpeechRequest.php#L74-L80 | train |
googleapis/google-cloud-php | TextToSpeech/src/V1/SynthesizeSpeechRequest.php | SynthesizeSpeechRequest.setVoice | public function setVoice($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\TextToSpeech\V1\VoiceSelectionParams::class);
$this->voice = $var;
return $this;
} | php | public function setVoice($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\TextToSpeech\V1\VoiceSelectionParams::class);
$this->voice = $var;
return $this;
} | [
"public",
"function",
"setVoice",
"(",
"$",
"var",
")",
"{",
"GPBUtil",
"::",
"checkMessage",
"(",
"$",
"var",
",",
"\\",
"Google",
"\\",
"Cloud",
"\\",
"TextToSpeech",
"\\",
"V1",
"\\",
"VoiceSelectionParams",
"::",
"class",
")",
";",
"$",
"this",
"->",
"voice",
"=",
"$",
"var",
";",
"return",
"$",
"this",
";",
"}"
] | Required. The desired voice of the synthesized audio.
Generated from protobuf field <code>.google.cloud.texttospeech.v1.VoiceSelectionParams voice = 2;</code>
@param \Google\Cloud\TextToSpeech\V1\VoiceSelectionParams $var
@return $this | [
"Required",
".",
"The",
"desired",
"voice",
"of",
"the",
"synthesized",
"audio",
"."
] | ff5030ffa1f12904565509a7bc24ecc0bd794a3e | https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/TextToSpeech/src/V1/SynthesizeSpeechRequest.php#L100-L106 | train |
googleapis/google-cloud-php | TextToSpeech/src/V1/SynthesizeSpeechRequest.php | SynthesizeSpeechRequest.setAudioConfig | public function setAudioConfig($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\TextToSpeech\V1\AudioConfig::class);
$this->audio_config = $var;
return $this;
} | php | public function setAudioConfig($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\TextToSpeech\V1\AudioConfig::class);
$this->audio_config = $var;
return $this;
} | [
"public",
"function",
"setAudioConfig",
"(",
"$",
"var",
")",
"{",
"GPBUtil",
"::",
"checkMessage",
"(",
"$",
"var",
",",
"\\",
"Google",
"\\",
"Cloud",
"\\",
"TextToSpeech",
"\\",
"V1",
"\\",
"AudioConfig",
"::",
"class",
")",
";",
"$",
"this",
"->",
"audio_config",
"=",
"$",
"var",
";",
"return",
"$",
"this",
";",
"}"
] | Required. The configuration of the synthesized audio.
Generated from protobuf field <code>.google.cloud.texttospeech.v1.AudioConfig audio_config = 3;</code>
@param \Google\Cloud\TextToSpeech\V1\AudioConfig $var
@return $this | [
"Required",
".",
"The",
"configuration",
"of",
"the",
"synthesized",
"audio",
"."
] | ff5030ffa1f12904565509a7bc24ecc0bd794a3e | https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/TextToSpeech/src/V1/SynthesizeSpeechRequest.php#L126-L132 | train |
googleapis/google-cloud-php | SecurityCenter/src/V1/Asset.php | Asset.setSecurityCenterProperties | public function setSecurityCenterProperties($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\SecurityCenter\V1\Asset_SecurityCenterProperties::class);
$this->security_center_properties = $var;
return $this;
} | php | public function setSecurityCenterProperties($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\SecurityCenter\V1\Asset_SecurityCenterProperties::class);
$this->security_center_properties = $var;
return $this;
} | [
"public",
"function",
"setSecurityCenterProperties",
"(",
"$",
"var",
")",
"{",
"GPBUtil",
"::",
"checkMessage",
"(",
"$",
"var",
",",
"\\",
"Google",
"\\",
"Cloud",
"\\",
"SecurityCenter",
"\\",
"V1",
"\\",
"Asset_SecurityCenterProperties",
"::",
"class",
")",
";",
"$",
"this",
"->",
"security_center_properties",
"=",
"$",
"var",
";",
"return",
"$",
"this",
";",
"}"
] | Cloud SCC managed properties. These properties are managed by
Cloud SCC and cannot be modified by the user.
Generated from protobuf field <code>.google.cloud.securitycenter.v1.Asset.SecurityCenterProperties security_center_properties = 2;</code>
@param \Google\Cloud\SecurityCenter\V1\Asset\SecurityCenterProperties $var
@return $this | [
"Cloud",
"SCC",
"managed",
"properties",
".",
"These",
"properties",
"are",
"managed",
"by",
"Cloud",
"SCC",
"and",
"cannot",
"be",
"modified",
"by",
"the",
"user",
"."
] | ff5030ffa1f12904565509a7bc24ecc0bd794a3e | https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/SecurityCenter/src/V1/Asset.php#L162-L168 | train |
googleapis/google-cloud-php | SecurityCenter/src/V1/Asset.php | Asset.setResourceProperties | public function setResourceProperties($var)
{
$arr = GPBUtil::checkMapField($var, \Google\Protobuf\Internal\GPBType::STRING, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Value::class);
$this->resource_properties = $arr;
return $this;
} | php | public function setResourceProperties($var)
{
$arr = GPBUtil::checkMapField($var, \Google\Protobuf\Internal\GPBType::STRING, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Value::class);
$this->resource_properties = $arr;
return $this;
} | [
"public",
"function",
"setResourceProperties",
"(",
"$",
"var",
")",
"{",
"$",
"arr",
"=",
"GPBUtil",
"::",
"checkMapField",
"(",
"$",
"var",
",",
"\\",
"Google",
"\\",
"Protobuf",
"\\",
"Internal",
"\\",
"GPBType",
"::",
"STRING",
",",
"\\",
"Google",
"\\",
"Protobuf",
"\\",
"Internal",
"\\",
"GPBType",
"::",
"MESSAGE",
",",
"\\",
"Google",
"\\",
"Protobuf",
"\\",
"Value",
"::",
"class",
")",
";",
"$",
"this",
"->",
"resource_properties",
"=",
"$",
"arr",
";",
"return",
"$",
"this",
";",
"}"
] | Resource managed properties. These properties are managed and defined by
the GCP resource and cannot be modified by the user.
Generated from protobuf field <code>map<string, .google.protobuf.Value> resource_properties = 7;</code>
@param array|\Google\Protobuf\Internal\MapField $var
@return $this | [
"Resource",
"managed",
"properties",
".",
"These",
"properties",
"are",
"managed",
"and",
"defined",
"by",
"the",
"GCP",
"resource",
"and",
"cannot",
"be",
"modified",
"by",
"the",
"user",
"."
] | ff5030ffa1f12904565509a7bc24ecc0bd794a3e | https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/SecurityCenter/src/V1/Asset.php#L190-L196 | train |
googleapis/google-cloud-php | SecurityCenter/src/V1/Asset.php | Asset.setIamPolicy | public function setIamPolicy($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\SecurityCenter\V1\Asset_IamPolicy::class);
$this->iam_policy = $var;
return $this;
} | php | public function setIamPolicy($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\SecurityCenter\V1\Asset_IamPolicy::class);
$this->iam_policy = $var;
return $this;
} | [
"public",
"function",
"setIamPolicy",
"(",
"$",
"var",
")",
"{",
"GPBUtil",
"::",
"checkMessage",
"(",
"$",
"var",
",",
"\\",
"Google",
"\\",
"Cloud",
"\\",
"SecurityCenter",
"\\",
"V1",
"\\",
"Asset_IamPolicy",
"::",
"class",
")",
";",
"$",
"this",
"->",
"iam_policy",
"=",
"$",
"var",
";",
"return",
"$",
"this",
";",
"}"
] | IAM Policy information associated with the GCP resource described by the
Cloud SCC asset. This information is managed and defined by the GCP
resource and cannot be modified by the user.
Generated from protobuf field <code>.google.cloud.securitycenter.v1.Asset.IamPolicy iam_policy = 11;</code>
@param \Google\Cloud\SecurityCenter\V1\Asset\IamPolicy $var
@return $this | [
"IAM",
"Policy",
"information",
"associated",
"with",
"the",
"GCP",
"resource",
"described",
"by",
"the",
"Cloud",
"SCC",
"asset",
".",
"This",
"information",
"is",
"managed",
"and",
"defined",
"by",
"the",
"GCP",
"resource",
"and",
"cannot",
"be",
"modified",
"by",
"the",
"user",
"."
] | ff5030ffa1f12904565509a7bc24ecc0bd794a3e | https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/SecurityCenter/src/V1/Asset.php#L302-L308 | train |
googleapis/google-cloud-php | Firestore/src/V1beta1/ListenResponse.php | ListenResponse.setFilter | public function setFilter($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\Firestore\V1beta1\ExistenceFilter::class);
$this->writeOneof(5, $var);
return $this;
} | php | public function setFilter($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\Firestore\V1beta1\ExistenceFilter::class);
$this->writeOneof(5, $var);
return $this;
} | [
"public",
"function",
"setFilter",
"(",
"$",
"var",
")",
"{",
"GPBUtil",
"::",
"checkMessage",
"(",
"$",
"var",
",",
"\\",
"Google",
"\\",
"Cloud",
"\\",
"Firestore",
"\\",
"V1beta1",
"\\",
"ExistenceFilter",
"::",
"class",
")",
";",
"$",
"this",
"->",
"writeOneof",
"(",
"5",
",",
"$",
"var",
")",
";",
"return",
"$",
"this",
";",
"}"
] | A filter to apply to the set of documents previously returned for the
given target.
Returned when documents may have been removed from the given target, but
the exact documents are unknown.
Generated from protobuf field <code>.google.firestore.v1beta1.ExistenceFilter filter = 5;</code>
@param \Google\Cloud\Firestore\V1beta1\ExistenceFilter $var
@return $this | [
"A",
"filter",
"to",
"apply",
"to",
"the",
"set",
"of",
"documents",
"previously",
"returned",
"for",
"the",
"given",
"target",
".",
"Returned",
"when",
"documents",
"may",
"have",
"been",
"removed",
"from",
"the",
"given",
"target",
"but",
"the",
"exact",
"documents",
"are",
"unknown",
"."
] | ff5030ffa1f12904565509a7bc24ecc0bd794a3e | https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Firestore/src/V1beta1/ListenResponse.php#L177-L183 | train |
googleapis/google-cloud-php | Dlp/src/V2/TransformationOverview.php | TransformationOverview.setTransformationSummaries | public function setTransformationSummaries($var)
{
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Dlp\V2\TransformationSummary::class);
$this->transformation_summaries = $arr;
return $this;
} | php | public function setTransformationSummaries($var)
{
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Dlp\V2\TransformationSummary::class);
$this->transformation_summaries = $arr;
return $this;
} | [
"public",
"function",
"setTransformationSummaries",
"(",
"$",
"var",
")",
"{",
"$",
"arr",
"=",
"GPBUtil",
"::",
"checkRepeatedField",
"(",
"$",
"var",
",",
"\\",
"Google",
"\\",
"Protobuf",
"\\",
"Internal",
"\\",
"GPBType",
"::",
"MESSAGE",
",",
"\\",
"Google",
"\\",
"Cloud",
"\\",
"Dlp",
"\\",
"V2",
"\\",
"TransformationSummary",
"::",
"class",
")",
";",
"$",
"this",
"->",
"transformation_summaries",
"=",
"$",
"arr",
";",
"return",
"$",
"this",
";",
"}"
] | Transformations applied to the dataset.
Generated from protobuf field <code>repeated .google.privacy.dlp.v2.TransformationSummary transformation_summaries = 3;</code>
@param \Google\Cloud\Dlp\V2\TransformationSummary[]|\Google\Protobuf\Internal\RepeatedField $var
@return $this | [
"Transformations",
"applied",
"to",
"the",
"dataset",
"."
] | ff5030ffa1f12904565509a7bc24ecc0bd794a3e | https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Dlp/src/V2/TransformationOverview.php#L92-L98 | train |
googleapis/google-cloud-php | Dlp/src/V2/ListJobTriggersResponse.php | ListJobTriggersResponse.setJobTriggers | public function setJobTriggers($var)
{
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Dlp\V2\JobTrigger::class);
$this->job_triggers = $arr;
return $this;
} | php | public function setJobTriggers($var)
{
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Dlp\V2\JobTrigger::class);
$this->job_triggers = $arr;
return $this;
} | [
"public",
"function",
"setJobTriggers",
"(",
"$",
"var",
")",
"{",
"$",
"arr",
"=",
"GPBUtil",
"::",
"checkRepeatedField",
"(",
"$",
"var",
",",
"\\",
"Google",
"\\",
"Protobuf",
"\\",
"Internal",
"\\",
"GPBType",
"::",
"MESSAGE",
",",
"\\",
"Google",
"\\",
"Cloud",
"\\",
"Dlp",
"\\",
"V2",
"\\",
"JobTrigger",
"::",
"class",
")",
";",
"$",
"this",
"->",
"job_triggers",
"=",
"$",
"arr",
";",
"return",
"$",
"this",
";",
"}"
] | List of triggeredJobs, up to page_size in ListJobTriggersRequest.
Generated from protobuf field <code>repeated .google.privacy.dlp.v2.JobTrigger job_triggers = 1;</code>
@param \Google\Cloud\Dlp\V2\JobTrigger[]|\Google\Protobuf\Internal\RepeatedField $var
@return $this | [
"List",
"of",
"triggeredJobs",
"up",
"to",
"page_size",
"in",
"ListJobTriggersRequest",
"."
] | ff5030ffa1f12904565509a7bc24ecc0bd794a3e | https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Dlp/src/V2/ListJobTriggersResponse.php#L68-L74 | train |
googleapis/google-cloud-php | Dataproc/src/V1beta2/TemplateParameter.php | TemplateParameter.setValidation | public function setValidation($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\Dataproc\V1beta2\ParameterValidation::class);
$this->validation = $var;
return $this;
} | php | public function setValidation($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\Dataproc\V1beta2\ParameterValidation::class);
$this->validation = $var;
return $this;
} | [
"public",
"function",
"setValidation",
"(",
"$",
"var",
")",
"{",
"GPBUtil",
"::",
"checkMessage",
"(",
"$",
"var",
",",
"\\",
"Google",
"\\",
"Cloud",
"\\",
"Dataproc",
"\\",
"V1beta2",
"\\",
"ParameterValidation",
"::",
"class",
")",
";",
"$",
"this",
"->",
"validation",
"=",
"$",
"var",
";",
"return",
"$",
"this",
";",
"}"
] | Optional. Validation rules to be applied to this parameter's value.
Generated from protobuf field <code>.google.cloud.dataproc.v1beta2.ParameterValidation validation = 4;</code>
@param \Google\Cloud\Dataproc\V1beta2\ParameterValidation $var
@return $this | [
"Optional",
".",
"Validation",
"rules",
"to",
"be",
"applied",
"to",
"this",
"parameter",
"s",
"value",
"."
] | ff5030ffa1f12904565509a7bc24ecc0bd794a3e | https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Dataproc/src/V1beta2/TemplateParameter.php#L336-L342 | train |
googleapis/google-cloud-php | Container/src/V1/NodeConfig.php | NodeConfig.setTags | public function setTags($var)
{
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING);
$this->tags = $arr;
return $this;
} | php | public function setTags($var)
{
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING);
$this->tags = $arr;
return $this;
} | [
"public",
"function",
"setTags",
"(",
"$",
"var",
")",
"{",
"$",
"arr",
"=",
"GPBUtil",
"::",
"checkRepeatedField",
"(",
"$",
"var",
",",
"\\",
"Google",
"\\",
"Protobuf",
"\\",
"Internal",
"\\",
"GPBType",
"::",
"STRING",
")",
";",
"$",
"this",
"->",
"tags",
"=",
"$",
"arr",
";",
"return",
"$",
"this",
";",
"}"
] | The list of instance tags applied to all nodes. Tags are used to identify
valid sources or targets for network firewalls and are specified by
the client during cluster or node pool creation. Each tag within the list
must comply with RFC1035.
Generated from protobuf field <code>repeated string tags = 8;</code>
@param string[]|\Google\Protobuf\Internal\RepeatedField $var
@return $this | [
"The",
"list",
"of",
"instance",
"tags",
"applied",
"to",
"all",
"nodes",
".",
"Tags",
"are",
"used",
"to",
"identify",
"valid",
"sources",
"or",
"targets",
"for",
"network",
"firewalls",
"and",
"are",
"specified",
"by",
"the",
"client",
"during",
"cluster",
"or",
"node",
"pool",
"creation",
".",
"Each",
"tag",
"within",
"the",
"list",
"must",
"comply",
"with",
"RFC1035",
"."
] | ff5030ffa1f12904565509a7bc24ecc0bd794a3e | https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Container/src/V1/NodeConfig.php#L588-L594 | train |
googleapis/google-cloud-php | Firestore/src/ValueMapper.php | ValueMapper.encodeValues | public function encodeValues(array $fields)
{
$output = [];
foreach ($fields as $key => $val) {
$output[$key] = $this->encodeValue($val);
}
return $output;
} | php | public function encodeValues(array $fields)
{
$output = [];
foreach ($fields as $key => $val) {
$output[$key] = $this->encodeValue($val);
}
return $output;
} | [
"public",
"function",
"encodeValues",
"(",
"array",
"$",
"fields",
")",
"{",
"$",
"output",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"fields",
"as",
"$",
"key",
"=>",
"$",
"val",
")",
"{",
"$",
"output",
"[",
"$",
"key",
"]",
"=",
"$",
"this",
"->",
"encodeValue",
"(",
"$",
"val",
")",
";",
"}",
"return",
"$",
"output",
";",
"}"
] | Convert a PHP array containing google-cloud-php and simple types to an
array ready to be sent to Firestore.
@param array $fields A list of fields to encode.
@return array | [
"Convert",
"a",
"PHP",
"array",
"containing",
"google",
"-",
"cloud",
"-",
"php",
"and",
"simple",
"types",
"to",
"an",
"array",
"ready",
"to",
"be",
"sent",
"to",
"Firestore",
"."
] | ff5030ffa1f12904565509a7bc24ecc0bd794a3e | https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Firestore/src/ValueMapper.php#L96-L105 | train |
googleapis/google-cloud-php | Firestore/src/ValueMapper.php | ValueMapper.encodeValue | public function encodeValue($value)
{
$type = gettype($value);
switch ($type) {
case 'boolean':
return ['booleanValue' => $value];
break;
case 'integer':
return ['integerValue' => $value];
break;
case 'double':
return ['doubleValue' => $value];
break;
case 'string':
return ['stringValue' => $value];
break;
case 'resource':
return ['bytesValue' => stream_get_contents($value)];
break;
case 'object':
return $this->encodeObjectValue($value);
break;
case 'array':
if (!empty($value) && $this->isAssoc($value)) {
return $this->encodeAssociativeArrayValue($value);
}
return ['arrayValue' => $this->encodeArrayValue($value)];
break;
case 'NULL':
// @todo encode this in a way such that is compatible with a potential future REST transport.
return ['nullValue' => NullValue::NULL_VALUE];
break;
// @codeCoverageIgnoreStart
default:
throw new \RuntimeException(sprintf(
'Invalid value type %s',
$type
));
break;
// @codeCoverageIgnoreEnd
}
} | php | public function encodeValue($value)
{
$type = gettype($value);
switch ($type) {
case 'boolean':
return ['booleanValue' => $value];
break;
case 'integer':
return ['integerValue' => $value];
break;
case 'double':
return ['doubleValue' => $value];
break;
case 'string':
return ['stringValue' => $value];
break;
case 'resource':
return ['bytesValue' => stream_get_contents($value)];
break;
case 'object':
return $this->encodeObjectValue($value);
break;
case 'array':
if (!empty($value) && $this->isAssoc($value)) {
return $this->encodeAssociativeArrayValue($value);
}
return ['arrayValue' => $this->encodeArrayValue($value)];
break;
case 'NULL':
// @todo encode this in a way such that is compatible with a potential future REST transport.
return ['nullValue' => NullValue::NULL_VALUE];
break;
// @codeCoverageIgnoreStart
default:
throw new \RuntimeException(sprintf(
'Invalid value type %s',
$type
));
break;
// @codeCoverageIgnoreEnd
}
} | [
"public",
"function",
"encodeValue",
"(",
"$",
"value",
")",
"{",
"$",
"type",
"=",
"gettype",
"(",
"$",
"value",
")",
";",
"switch",
"(",
"$",
"type",
")",
"{",
"case",
"'boolean'",
":",
"return",
"[",
"'booleanValue'",
"=>",
"$",
"value",
"]",
";",
"break",
";",
"case",
"'integer'",
":",
"return",
"[",
"'integerValue'",
"=>",
"$",
"value",
"]",
";",
"break",
";",
"case",
"'double'",
":",
"return",
"[",
"'doubleValue'",
"=>",
"$",
"value",
"]",
";",
"break",
";",
"case",
"'string'",
":",
"return",
"[",
"'stringValue'",
"=>",
"$",
"value",
"]",
";",
"break",
";",
"case",
"'resource'",
":",
"return",
"[",
"'bytesValue'",
"=>",
"stream_get_contents",
"(",
"$",
"value",
")",
"]",
";",
"break",
";",
"case",
"'object'",
":",
"return",
"$",
"this",
"->",
"encodeObjectValue",
"(",
"$",
"value",
")",
";",
"break",
";",
"case",
"'array'",
":",
"if",
"(",
"!",
"empty",
"(",
"$",
"value",
")",
"&&",
"$",
"this",
"->",
"isAssoc",
"(",
"$",
"value",
")",
")",
"{",
"return",
"$",
"this",
"->",
"encodeAssociativeArrayValue",
"(",
"$",
"value",
")",
";",
"}",
"return",
"[",
"'arrayValue'",
"=>",
"$",
"this",
"->",
"encodeArrayValue",
"(",
"$",
"value",
")",
"]",
";",
"break",
";",
"case",
"'NULL'",
":",
"// @todo encode this in a way such that is compatible with a potential future REST transport.",
"return",
"[",
"'nullValue'",
"=>",
"NullValue",
"::",
"NULL_VALUE",
"]",
";",
"break",
";",
"// @codeCoverageIgnoreStart",
"default",
":",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"sprintf",
"(",
"'Invalid value type %s'",
",",
"$",
"type",
")",
")",
";",
"break",
";",
"// @codeCoverageIgnoreEnd",
"}",
"}"
] | Encode a Google Cloud PHP value as a Firestore value.
@param mixed $value
@return array [Value](https://firebase.google.com/docs/firestore/reference/rpc/google.firestore.v1beta1#value)
@throws \RuntimeException If an unknown type is encountered. | [
"Encode",
"a",
"Google",
"Cloud",
"PHP",
"value",
"as",
"a",
"Firestore",
"value",
"."
] | ff5030ffa1f12904565509a7bc24ecc0bd794a3e | https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Firestore/src/ValueMapper.php#L195-L246 | train |
googleapis/google-cloud-php | Firestore/src/ValueMapper.php | ValueMapper.encodeObjectValue | private function encodeObjectValue($value)
{
if ($value instanceof \stdClass) {
return $this->encodeAssociativeArrayValue((array) $value);
}
if ($value instanceof Blob) {
return ['bytesValue' => (string) $value];
}
if ($value instanceof \DateTimeInterface) {
return [
'timestampValue' => [
'seconds' => $value->format('U'),
'nanos' => (int)($value->format('u') * 1000)
]
];
}
if ($value instanceof Timestamp) {
return [
'timestampValue' => [
'seconds' => $value->get()->format('U'),
'nanos' => $value->nanoSeconds()
]
];
}
if ($value instanceof GeoPoint) {
return ['geoPointValue' => $value->point()];
}
if ($value instanceof DocumentReference || $value instanceof DocumentSnapshot) {
return ['referenceValue' => $value->name()];
}
throw new \RuntimeException(sprintf(
'Object of type %s cannot be encoded to a Firestore value type.',
get_class($value)
));
} | php | private function encodeObjectValue($value)
{
if ($value instanceof \stdClass) {
return $this->encodeAssociativeArrayValue((array) $value);
}
if ($value instanceof Blob) {
return ['bytesValue' => (string) $value];
}
if ($value instanceof \DateTimeInterface) {
return [
'timestampValue' => [
'seconds' => $value->format('U'),
'nanos' => (int)($value->format('u') * 1000)
]
];
}
if ($value instanceof Timestamp) {
return [
'timestampValue' => [
'seconds' => $value->get()->format('U'),
'nanos' => $value->nanoSeconds()
]
];
}
if ($value instanceof GeoPoint) {
return ['geoPointValue' => $value->point()];
}
if ($value instanceof DocumentReference || $value instanceof DocumentSnapshot) {
return ['referenceValue' => $value->name()];
}
throw new \RuntimeException(sprintf(
'Object of type %s cannot be encoded to a Firestore value type.',
get_class($value)
));
} | [
"private",
"function",
"encodeObjectValue",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"value",
"instanceof",
"\\",
"stdClass",
")",
"{",
"return",
"$",
"this",
"->",
"encodeAssociativeArrayValue",
"(",
"(",
"array",
")",
"$",
"value",
")",
";",
"}",
"if",
"(",
"$",
"value",
"instanceof",
"Blob",
")",
"{",
"return",
"[",
"'bytesValue'",
"=>",
"(",
"string",
")",
"$",
"value",
"]",
";",
"}",
"if",
"(",
"$",
"value",
"instanceof",
"\\",
"DateTimeInterface",
")",
"{",
"return",
"[",
"'timestampValue'",
"=>",
"[",
"'seconds'",
"=>",
"$",
"value",
"->",
"format",
"(",
"'U'",
")",
",",
"'nanos'",
"=>",
"(",
"int",
")",
"(",
"$",
"value",
"->",
"format",
"(",
"'u'",
")",
"*",
"1000",
")",
"]",
"]",
";",
"}",
"if",
"(",
"$",
"value",
"instanceof",
"Timestamp",
")",
"{",
"return",
"[",
"'timestampValue'",
"=>",
"[",
"'seconds'",
"=>",
"$",
"value",
"->",
"get",
"(",
")",
"->",
"format",
"(",
"'U'",
")",
",",
"'nanos'",
"=>",
"$",
"value",
"->",
"nanoSeconds",
"(",
")",
"]",
"]",
";",
"}",
"if",
"(",
"$",
"value",
"instanceof",
"GeoPoint",
")",
"{",
"return",
"[",
"'geoPointValue'",
"=>",
"$",
"value",
"->",
"point",
"(",
")",
"]",
";",
"}",
"if",
"(",
"$",
"value",
"instanceof",
"DocumentReference",
"||",
"$",
"value",
"instanceof",
"DocumentSnapshot",
")",
"{",
"return",
"[",
"'referenceValue'",
"=>",
"$",
"value",
"->",
"name",
"(",
")",
"]",
";",
"}",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"sprintf",
"(",
"'Object of type %s cannot be encoded to a Firestore value type.'",
",",
"get_class",
"(",
"$",
"value",
")",
")",
")",
";",
"}"
] | Encode a value of type `object` as a Firestore value.
@param object $value
@return array
@throws \RuntimeException If an invalid object type is provided. | [
"Encode",
"a",
"value",
"of",
"type",
"object",
"as",
"a",
"Firestore",
"value",
"."
] | ff5030ffa1f12904565509a7bc24ecc0bd794a3e | https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Firestore/src/ValueMapper.php#L278-L318 | train |
googleapis/google-cloud-php | Firestore/src/ValueMapper.php | ValueMapper.encodeAssociativeArrayValue | private function encodeAssociativeArrayValue(array $value)
{
$out = [];
foreach ($value as $key => $item) {
$out[$key] = $this->encodeValue($item);
}
return ['mapValue' => ['fields' => $out]];
} | php | private function encodeAssociativeArrayValue(array $value)
{
$out = [];
foreach ($value as $key => $item) {
$out[$key] = $this->encodeValue($item);
}
return ['mapValue' => ['fields' => $out]];
} | [
"private",
"function",
"encodeAssociativeArrayValue",
"(",
"array",
"$",
"value",
")",
"{",
"$",
"out",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"value",
"as",
"$",
"key",
"=>",
"$",
"item",
")",
"{",
"$",
"out",
"[",
"$",
"key",
"]",
"=",
"$",
"this",
"->",
"encodeValue",
"(",
"$",
"item",
")",
";",
"}",
"return",
"[",
"'mapValue'",
"=>",
"[",
"'fields'",
"=>",
"$",
"out",
"]",
"]",
";",
"}"
] | Encode an associative array as a Firestore Map value.
@codingStandardsIgnoreStart
@param array $value
@return array [MapValue](https://firebase.google.com/docs/firestore/reference/rpc/google.firestore.v1beta1#google.firestore.v1beta1.MapValue)
@codingStandardsIgnoreEnd | [
"Encode",
"an",
"associative",
"array",
"as",
"a",
"Firestore",
"Map",
"value",
"."
] | ff5030ffa1f12904565509a7bc24ecc0bd794a3e | https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Firestore/src/ValueMapper.php#L328-L336 | train |
googleapis/google-cloud-php | Iot/src/V1/CreateDeviceRequest.php | CreateDeviceRequest.setDevice | public function setDevice($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\Iot\V1\Device::class);
$this->device = $var;
return $this;
} | php | public function setDevice($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\Iot\V1\Device::class);
$this->device = $var;
return $this;
} | [
"public",
"function",
"setDevice",
"(",
"$",
"var",
")",
"{",
"GPBUtil",
"::",
"checkMessage",
"(",
"$",
"var",
",",
"\\",
"Google",
"\\",
"Cloud",
"\\",
"Iot",
"\\",
"V1",
"\\",
"Device",
"::",
"class",
")",
";",
"$",
"this",
"->",
"device",
"=",
"$",
"var",
";",
"return",
"$",
"this",
";",
"}"
] | The device registration details. The field `name` must be empty. The server
generates `name` from the device registry `id` and the
`parent` field.
Generated from protobuf field <code>.google.cloud.iot.v1.Device device = 2;</code>
@param \Google\Cloud\Iot\V1\Device $var
@return $this | [
"The",
"device",
"registration",
"details",
".",
"The",
"field",
"name",
"must",
"be",
"empty",
".",
"The",
"server",
"generates",
"name",
"from",
"the",
"device",
"registry",
"id",
"and",
"the",
"parent",
"field",
"."
] | ff5030ffa1f12904565509a7bc24ecc0bd794a3e | https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Iot/src/V1/CreateDeviceRequest.php#L108-L114 | train |
googleapis/google-cloud-php | Dialogflow/src/V2/WebhookResponse.php | WebhookResponse.setFollowupEventInput | public function setFollowupEventInput($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\Dialogflow\V2\EventInput::class);
$this->followup_event_input = $var;
return $this;
} | php | public function setFollowupEventInput($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\Dialogflow\V2\EventInput::class);
$this->followup_event_input = $var;
return $this;
} | [
"public",
"function",
"setFollowupEventInput",
"(",
"$",
"var",
")",
"{",
"GPBUtil",
"::",
"checkMessage",
"(",
"$",
"var",
",",
"\\",
"Google",
"\\",
"Cloud",
"\\",
"Dialogflow",
"\\",
"V2",
"\\",
"EventInput",
"::",
"class",
")",
";",
"$",
"this",
"->",
"followup_event_input",
"=",
"$",
"var",
";",
"return",
"$",
"this",
";",
"}"
] | Optional. Makes the platform immediately invoke another `DetectIntent` call
internally with the specified event as input.
Generated from protobuf field <code>.google.cloud.dialogflow.v2.EventInput followup_event_input = 6;</code>
@param \Google\Cloud\Dialogflow\V2\EventInput $var
@return $this | [
"Optional",
".",
"Makes",
"the",
"platform",
"immediately",
"invoke",
"another",
"DetectIntent",
"call",
"internally",
"with",
"the",
"specified",
"event",
"as",
"input",
"."
] | ff5030ffa1f12904565509a7bc24ecc0bd794a3e | https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Dialogflow/src/V2/WebhookResponse.php#L328-L334 | train |
googleapis/google-cloud-php | Bigtable/src/Admin/V2/CreateClusterRequest.php | CreateClusterRequest.setCluster | public function setCluster($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\Bigtable\Admin\V2\Cluster::class);
$this->cluster = $var;
return $this;
} | php | public function setCluster($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\Bigtable\Admin\V2\Cluster::class);
$this->cluster = $var;
return $this;
} | [
"public",
"function",
"setCluster",
"(",
"$",
"var",
")",
"{",
"GPBUtil",
"::",
"checkMessage",
"(",
"$",
"var",
",",
"\\",
"Google",
"\\",
"Cloud",
"\\",
"Bigtable",
"\\",
"Admin",
"\\",
"V2",
"\\",
"Cluster",
"::",
"class",
")",
";",
"$",
"this",
"->",
"cluster",
"=",
"$",
"var",
";",
"return",
"$",
"this",
";",
"}"
] | The cluster to be created.
Fields marked `OutputOnly` must be left blank.
Generated from protobuf field <code>.google.bigtable.admin.v2.Cluster cluster = 3;</code>
@param \Google\Cloud\Bigtable\Admin\V2\Cluster $var
@return $this | [
"The",
"cluster",
"to",
"be",
"created",
".",
"Fields",
"marked",
"OutputOnly",
"must",
"be",
"left",
"blank",
"."
] | ff5030ffa1f12904565509a7bc24ecc0bd794a3e | https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Bigtable/src/Admin/V2/CreateClusterRequest.php#L146-L152 | train |
googleapis/google-cloud-php | Spanner/src/KeySet.php | KeySet.keySetObject | public function keySetObject()
{
$ranges = [];
foreach ($this->ranges as $range) {
$ranges[] = $range->keyRangeObject();
}
$set = [];
if ($this->all) {
$set['all'] = true;
}
if ($this->keys) {
$set['keys'] = $this->keys;
}
if ($ranges) {
$set['ranges'] = $ranges;
}
return $set;
} | php | public function keySetObject()
{
$ranges = [];
foreach ($this->ranges as $range) {
$ranges[] = $range->keyRangeObject();
}
$set = [];
if ($this->all) {
$set['all'] = true;
}
if ($this->keys) {
$set['keys'] = $this->keys;
}
if ($ranges) {
$set['ranges'] = $ranges;
}
return $set;
} | [
"public",
"function",
"keySetObject",
"(",
")",
"{",
"$",
"ranges",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"ranges",
"as",
"$",
"range",
")",
"{",
"$",
"ranges",
"[",
"]",
"=",
"$",
"range",
"->",
"keyRangeObject",
"(",
")",
";",
"}",
"$",
"set",
"=",
"[",
"]",
";",
"if",
"(",
"$",
"this",
"->",
"all",
")",
"{",
"$",
"set",
"[",
"'all'",
"]",
"=",
"true",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"keys",
")",
"{",
"$",
"set",
"[",
"'keys'",
"]",
"=",
"$",
"this",
"->",
"keys",
";",
"}",
"if",
"(",
"$",
"ranges",
")",
"{",
"$",
"set",
"[",
"'ranges'",
"]",
"=",
"$",
"ranges",
";",
"}",
"return",
"$",
"set",
";",
"}"
] | Format a KeySet object for use in the Spanner API.
@access private | [
"Format",
"a",
"KeySet",
"object",
"for",
"use",
"in",
"the",
"Spanner",
"API",
"."
] | ff5030ffa1f12904565509a7bc24ecc0bd794a3e | https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Spanner/src/KeySet.php#L234-L256 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.