_id stringlengths 2 7 | title stringlengths 3 151 | partition stringclasses 3
values | text stringlengths 83 13k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q15200 | Regex.setGroupIndexes | train | public function setGroupIndexes($var)
{
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::INT32);
$this->group_indexes = $arr;
return $this;
} | php | {
"resource": ""
} |
q15201 | UptimeCheckServiceGrpcClient.ListUptimeCheckIps | train | public function ListUptimeCheckIps(\Google\Cloud\Monitoring\V3\ListUptimeCheckIpsRequest $argument,
$metadata = [], $options = []) {
return $this->_simpleRequest('/google.monitoring.v3.UptimeCheckService/ListUptimeCheckIps',
$argument,
['\Google\Cloud\Monitoring\V3\ListUptimeCheckIpsResponse', 'decode'],
$metadata, $options);
} | php | {
"resource": ""
} |
q15202 | SysvTrait.getSysvKey | train | private function getSysvKey($idNum)
{
$key = getenv('GOOGLE_CLOUD_SYSV_ID') ?: self::$productionKey;
$base = ftok(__FILE__, $key);
if ($base == PHP_INT_MAX) {
$base = 1;
}
return $base + $idNum;
} | php | {
"resource": ""
} |
q15203 | InspectConfig.setContentOptions | train | public function setContentOptions($var)
{
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::ENUM, \Google\Cloud\Dlp\V2\ContentOption::class);
$this->content_options = $arr;
return $this;
} | php | {
"resource": ""
} |
q15204 | InspectConfig.setRuleSet | train | public function setRuleSet($var)
{
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Dlp\V2\InspectionRuleSet::class);
$this->rule_set = $arr;
return $this;
} | php | {
"resource": ""
} |
q15205 | ListTimeSeriesResponse.setTimeSeries | train | public function setTimeSeries($var)
{
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Monitoring\V3\TimeSeries::class);
$this->time_series = $arr;
return $this;
} | php | {
"resource": ""
} |
q15206 | ListTimeSeriesResponse.setExecutionErrors | train | public function setExecutionErrors($var)
{
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Rpc\Status::class);
$this->execution_errors = $arr;
return $this;
} | php | {
"resource": ""
} |
q15207 | ComputeThreatListDiffRequest.setThreatType | train | public function setThreatType($var)
{
GPBUtil::checkEnum($var, \Google\Cloud\WebRisk\V1beta1\ThreatType::class);
$this->threat_type = $var;
return $this;
} | php | {
"resource": ""
} |
q15208 | ComputeThreatListDiffRequest.setConstraints | train | public function setConstraints($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\WebRisk\V1beta1\ComputeThreatListDiffRequest_Constraints::class);
$this->constraints = $var;
return $this;
} | php | {
"resource": ""
} |
q15209 | ListAppProfilesResponse.setAppProfiles | train | public function setAppProfiles($var)
{
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Bigtable\Admin\V2\AppProfile::class);
$this->app_profiles = $arr;
return $this;
} | php | {
"resource": ""
} |
q15210 | Operation.mutation | train | public function mutation($operation, $table, $mutation)
{
return [
$operation => [
'table' => $table,
'columns' => array_keys($mutation),
'values' => $this->mapper->encodeValuesAsSimpleType(array_values($mutation))
]
];
} | php | {
"resource": ""
} |
q15211 | Operation.deleteMutation | train | public function deleteMutation($table, KeySet $keySet)
{
return [
self::OP_DELETE => [
'table' => $table,
'keySet' => $this->flattenKeySet($keySet),
]
];
} | php | {
"resource": ""
} |
q15212 | Operation.commit | train | public function commit(Session $session, array $mutations, array $options = [])
{
$options += [
'transactionId' => null
];
$res = $this->connection->commit($this->arrayFilterRemoveNull([
'mutations' => $mutations,
'session' => $session->name(),
'database' => $session->info()['database']
]) + $options);
$time = $this->parseTimeString($res['commitTimestamp']);
return new Timestamp($time[0], $time[1]);
} | php | {
"resource": ""
} |
q15213 | Operation.rollback | train | public function rollback(Session $session, $transactionId, array $options = [])
{
return $this->connection->rollback([
'transactionId' => $transactionId,
'session' => $session->name(),
'database' => $session->info()['database']
] + $options);
} | php | {
"resource": ""
} |
q15214 | Operation.executeUpdate | train | 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 | {
"resource": ""
} |
q15215 | Operation.read | train | 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 | {
"resource": ""
} |
q15216 | Operation.createTransaction | train | 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 | {
"resource": ""
} |
q15217 | Operation.snapshot | train | 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 | {
"resource": ""
} |
q15218 | Operation.createSnapshot | train | 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 | {
"resource": ""
} |
q15219 | Operation.partitionOptions | train | private function partitionOptions(array $options)
{
$options['partitionOptions'] = array_filter([
'partitionSizeBytes' => $this->pluck('partitionSizeBytes', $options, false),
'maxPartitions' => $this->pluck('maxPartitions', $options, false)
]);
return $options;
} | php | {
"resource": ""
} |
q15220 | Operation.beginTransaction | train | private function beginTransaction(Session $session, array $options = [])
{
$options += [
'transactionOptions' => []
];
return $this->connection->beginTransaction($options + [
'session' => $session->name(),
'database' => $session->info()['database']
]);
} | php | {
"resource": ""
} |
q15221 | Operation.flattenKeySet | train | 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 | {
"resource": ""
} |
q15222 | Activity.setTeamMembers | train | public function setTeamMembers($var)
{
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING);
$this->team_members = $arr;
return $this;
} | php | {
"resource": ""
} |
q15223 | LogSink.setOutputVersionFormat | train | public function setOutputVersionFormat($var)
{
GPBUtil::checkEnum($var, \Google\Cloud\Logging\V2\LogSink_VersionFormat::class);
$this->output_version_format = $var;
return $this;
} | php | {
"resource": ""
} |
q15224 | SearchJobsRequest.setJobQuery | train | public function setJobQuery($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\Talent\V4beta1\JobQuery::class);
$this->job_query = $var;
return $this;
} | php | {
"resource": ""
} |
q15225 | Paragraph.setProperty | train | public function setProperty($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\Vision\V1\TextAnnotation_TextProperty::class);
$this->property = $var;
return $this;
} | php | {
"resource": ""
} |
q15226 | Paragraph.setWords | train | 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 | {
"resource": ""
} |
q15227 | ListDeviceConfigVersionsResponse.setDeviceConfigs | train | 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 | {
"resource": ""
} |
q15228 | Text.setText | train | public function setText($var)
{
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING);
$this->text = $arr;
return $this;
} | php | {
"resource": ""
} |
q15229 | JobServiceGrpcClient.GetJob | train | 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 | {
"resource": ""
} |
q15230 | JobServiceGrpcClient.UpdateJob | train | 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 | {
"resource": ""
} |
q15231 | JobServiceGrpcClient.DeleteJob | train | 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 | {
"resource": ""
} |
q15232 | JobServiceGrpcClient.ListJobs | train | 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 | {
"resource": ""
} |
q15233 | ListTopicSnapshotsResponse.setSnapshots | train | public function setSnapshots($var)
{
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING);
$this->snapshots = $arr;
return $this;
} | php | {
"resource": ""
} |
q15234 | CreateJobRequest.setJob | train | public function setJob($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\Talent\V4beta1\Job::class);
$this->job = $var;
return $this;
} | php | {
"resource": ""
} |
q15235 | KeyFilter.sample | train | 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 | {
"resource": ""
} |
q15236 | ListCompaniesResponse.setCompanies | train | 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 | {
"resource": ""
} |
q15237 | LongRunningRecognizeResponse.setResults | train | 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 | {
"resource": ""
} |
q15238 | ChunkFormatter.readAll | train | 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 | {
"resource": ""
} |
q15239 | ChunkFormatter.validateNewRow | train | 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 | {
"resource": ""
} |
q15240 | ChunkFormatter.reset | train | private function reset()
{
$this->prevRowKey = null;
$this->rowKey = null;
$this->state = self::$rowStateEnum['NEW_ROW'];
$this->row = [];
} | php | {
"resource": ""
} |
q15241 | ChunkFormatter.moveToNextState | train | private function moveToNextState(CellChunk $chunk)
{
$this->state = $chunk->getValueSize() > 0
? self::$rowStateEnum['CELL_IN_PROGRESS']
: self::$rowStateEnum['ROW_IN_PROGRESS'];
} | php | {
"resource": ""
} |
q15242 | ChunkFormatter.newRow | train | 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 | {
"resource": ""
} |
q15243 | ChunkFormatter.validateResetRow | train | 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 | {
"resource": ""
} |
q15244 | ChunkFormatter.validateRowInProgress | train | 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 | {
"resource": ""
} |
q15245 | ChunkFormatter.rowInProgress | train | 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 | {
"resource": ""
} |
q15246 | ChunkFormatter.cellInProgress | train | private function cellInProgress(CellChunk $chunk)
{
$this->validateCellInProgress($chunk);
if ($chunk->getResetRow()) {
$this->reset();
return;
}
$this->qualifierValue = $this->qualifierValue . $chunk->getValue();
$this->moveToNextState($chunk);
} | php | {
"resource": ""
} |
q15247 | WebDetection.setWebEntities | train | 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 | {
"resource": ""
} |
q15248 | WebDetection.setFullMatchingImages | train | 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 | {
"resource": ""
} |
q15249 | WebDetection.setPartialMatchingImages | train | 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 | {
"resource": ""
} |
q15250 | WebDetection.setPagesWithMatchingImages | train | 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 | {
"resource": ""
} |
q15251 | WebDetection.setVisuallySimilarImages | train | 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 | {
"resource": ""
} |
q15252 | Degree.setDegreeType | train | public function setDegreeType($var)
{
GPBUtil::checkEnum($var, \Google\Cloud\Talent\V4beta1\DegreeType::class);
$this->degree_type = $var;
return $this;
} | php | {
"resource": ""
} |
q15253 | Degree.setFieldsOfStudy | train | public function setFieldsOfStudy($var)
{
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING);
$this->fields_of_study = $arr;
return $this;
} | php | {
"resource": ""
} |
q15254 | Key.pathElement | train | 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 | {
"resource": ""
} |
q15255 | Key.ancestor | train | 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 | {
"resource": ""
} |
q15256 | Key.ancestorKey | train | 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 | {
"resource": ""
} |
q15257 | Key.state | train | public function state()
{
$end = $this->pathEnd();
return (isset($end['id']) || isset($end['name']))
? self::STATE_NAMED
: self::STATE_INCOMPLETE;
} | php | {
"resource": ""
} |
q15258 | Key.setLastElementIdentifier | train | 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 | {
"resource": ""
} |
q15259 | Key.pathEndIdentifier | train | public function pathEndIdentifier()
{
$end = $this->pathEnd();
if (isset($end['id'])) {
return $end['id'];
}
if (isset($end['name'])) {
return $end['name'];
}
return null;
} | php | {
"resource": ""
} |
q15260 | Key.pathEndIdentifierType | train | 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 | {
"resource": ""
} |
q15261 | Key.normalizeElement | train | 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 | {
"resource": ""
} |
q15262 | Key.determineIdentifierType | train | 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 | {
"resource": ""
} |
q15263 | Key.normalizePath | train | 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 | {
"resource": ""
} |
q15264 | Address.setUsage | train | public function setUsage($var)
{
GPBUtil::checkEnum($var, \Google\Cloud\Talent\V4beta1\ContactInfoUsage::class);
$this->usage = $var;
return $this;
} | php | {
"resource": ""
} |
q15265 | BatchDaemon.run | train | 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 | {
"resource": ""
} |
q15266 | SigningHelper.v2Sign | train | 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 | {
"resource": ""
} |
q15267 | SigningHelper.normalizeExpiration | train | 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 | {
"resource": ""
} |
q15268 | SigningHelper.normalizeResource | train | private function normalizeResource($resource)
{
$pieces = explode('/', trim($resource, '/'));
array_walk($pieces, function (&$piece) {
$piece = rawurlencode($piece);
});
return '/' . implode('/', $pieces);
} | php | {
"resource": ""
} |
q15269 | SigningHelper.normalizeOptions | train | 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 | {
"resource": ""
} |
q15270 | SigningHelper.normalizeHeaders | train | 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 | {
"resource": ""
} |
q15271 | SigningHelper.normalizeUriPath | train | 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 | {
"resource": ""
} |
q15272 | SigningHelper.getSigningCredentials | train | 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 | {
"resource": ""
} |
q15273 | SigningHelper.addCommonParams | train | 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 | {
"resource": ""
} |
q15274 | ReadPartition.serialize | train | 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 | {
"resource": ""
} |
q15275 | ReadPartition.hydrate | train | public static function hydrate(array $data)
{
return new self(
$data['token'],
$data['table'],
KeySet::fromArray($data['keySet']),
$data['columns'],
$data['options']
);
} | php | {
"resource": ""
} |
q15276 | CommitRequest.setMode | train | public function setMode($var)
{
GPBUtil::checkEnum($var, \Google\Cloud\Datastore\V1\CommitRequest_Mode::class);
$this->mode = $var;
return $this;
} | php | {
"resource": ""
} |
q15277 | ListTransferRunsRequest.setStates | train | 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 | {
"resource": ""
} |
q15278 | ListTransferRunsRequest.setRunAttempt | train | public function setRunAttempt($var)
{
GPBUtil::checkEnum($var, \Google\Cloud\BigQuery\DataTransfer\V1\ListTransferRunsRequest_RunAttempt::class);
$this->run_attempt = $var;
return $this;
} | php | {
"resource": ""
} |
q15279 | ClusterControllerGapicClient.createCluster | train | 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 | {
"resource": ""
} |
q15280 | ClusterControllerGapicClient.updateCluster | train | 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 | {
"resource": ""
} |
q15281 | ClusterControllerGapicClient.deleteCluster | train | 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 | {
"resource": ""
} |
q15282 | CodeParser.buildNestedParams | train | 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 | {
"resource": ""
} |
q15283 | Subscription.create | train | 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 | {
"resource": ""
} |
q15284 | Subscription.update | train | public function update(array $subscription, array $options = [])
{
return $this->info = $this->connection->updateSubscription([
'name' => $this->name
] + $options + $subscription);
} | php | {
"resource": ""
} |
q15285 | Subscription.reload | train | public function reload(array $options = [])
{
return $this->info = $this->connection->getSubscription($options + [
'subscription' => $this->name
]);
} | php | {
"resource": ""
} |
q15286 | Subscription.pull | train | 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 | {
"resource": ""
} |
q15287 | Subscription.acknowledgeBatch | train | public function acknowledgeBatch(array $messages, array $options = [])
{
$this->validateBatch($messages, Message::class);
$this->connection->acknowledge($options + [
'subscription' => $this->name,
'ackIds' => $this->getMessageAckIds($messages)
]);
} | php | {
"resource": ""
} |
q15288 | Subscription.modifyAckDeadline | train | public function modifyAckDeadline(Message $message, $seconds, array $options = [])
{
$this->modifyAckDeadlineBatch([$message], $seconds, $options);
} | php | {
"resource": ""
} |
q15289 | Subscription.modifyAckDeadlineBatch | train | 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 | {
"resource": ""
} |
q15290 | Subscription.modifyPushConfig | train | public function modifyPushConfig(array $pushConfig, array $options = [])
{
$this->connection->modifyPushConfig($options + [
'subscription' => $this->name,
'pushConfig' => $pushConfig
]);
} | php | {
"resource": ""
} |
q15291 | Subscription.seekToTime | train | public function seekToTime(Timestamp $timestamp)
{
return $this->connection->seek([
'subscription' => $this->name,
'time' => $timestamp->formatAsString()
]);
} | php | {
"resource": ""
} |
q15292 | Subscription.seekToSnapshot | train | public function seekToSnapshot(Snapshot $snapshot)
{
return $this->connection->seek([
'subscription' => $this->name,
'snapshot' => $snapshot->name()
]);
} | php | {
"resource": ""
} |
q15293 | Subscription.iam | train | public function iam()
{
if (!$this->iam) {
$iamConnection = new IamSubscription($this->connection);
$this->iam = new Iam($iamConnection, $this->name);
}
return $this->iam;
} | php | {
"resource": ""
} |
q15294 | Subscription.getMessageAckIds | train | private function getMessageAckIds(array $messages)
{
$ackIds = [];
foreach ($messages as $message) {
$ackIds[] = $message->ackId();
}
return $ackIds;
} | php | {
"resource": ""
} |
q15295 | SynthesizeSpeechRequest.setInput | train | public function setInput($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\TextToSpeech\V1\SynthesisInput::class);
$this->input = $var;
return $this;
} | php | {
"resource": ""
} |
q15296 | SynthesizeSpeechRequest.setVoice | train | public function setVoice($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\TextToSpeech\V1\VoiceSelectionParams::class);
$this->voice = $var;
return $this;
} | php | {
"resource": ""
} |
q15297 | SynthesizeSpeechRequest.setAudioConfig | train | public function setAudioConfig($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\TextToSpeech\V1\AudioConfig::class);
$this->audio_config = $var;
return $this;
} | php | {
"resource": ""
} |
q15298 | Asset.setSecurityCenterProperties | train | public function setSecurityCenterProperties($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\SecurityCenter\V1\Asset_SecurityCenterProperties::class);
$this->security_center_properties = $var;
return $this;
} | php | {
"resource": ""
} |
q15299 | Asset.setResourceProperties | train | 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 | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.