_id stringlengths 2 7 | title stringlengths 3 151 | partition stringclasses 3
values | text stringlengths 83 13k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q15800 | CacheSessionPool.validateConfig | train | private function validateConfig()
{
$mustBePositiveKeys = ['maxCyclesToWaitForSession', 'maxSessions', 'minSessions', 'sleepIntervalSeconds'];
foreach ($mustBePositiveKeys as $key) {
if ($this->config[$key] < 0) {
throw new \InvalidArgumentException("$key may not be negative");
}
}
if ($this->config['maxSessions'] < $this->config['minSessions']) {
throw new \InvalidArgumentException('minSessions cannot exceed maxSessions');
}
if (isset($this->config['lock']) && !$this->config['lock'] instanceof LockInterface) {
throw new \InvalidArgumentException(
'The lock must implement Google\Cloud\Core\Lock\LockInterface'
);
}
} | php | {
"resource": ""
} |
q15801 | CacheSessionPool.deleteSessions | train | private function deleteSessions(array $sessions)
{
// gRPC calls appear to cancel when the corresponding UnaryCall object
// goes out of scope. Keeping the calls in scope allows time for the
// calls to complete at the expense of a small memory footprint.
$this->deleteCalls = [];
foreach ($sessions as $session) {
$this->deleteCalls[] = $this->database->connection()
->deleteSessionAsync([
'name' => $session['name'],
'database' => $this->database->name()
]);
}
} | php | {
"resource": ""
} |
q15802 | ReadModifyWriteRowResponse.setRow | train | public function setRow($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\Bigtable\V2\Row::class);
$this->row = $var;
return $this;
} | php | {
"resource": ""
} |
q15803 | HandleFailureTrait.initFailureFile | train | private function initFailureFile()
{
$this->baseDir = getenv('GOOGLE_CLOUD_BATCH_DAEMON_FAILURE_DIR');
if ($this->baseDir === false) {
$this->baseDir = sprintf(
'%s/batch-daemon-failure',
sys_get_temp_dir()
);
}
if (! is_dir($this->baseDir)) {
if (@mkdir($this->baseDir, 0700, true) === false) {
throw new \RuntimeException(
sprintf(
'Couuld not create a directory: %s',
$this->baseDir
)
);
}
}
// Use getmypid for simplicity.
$this->failureFile = sprintf(
'%s/failed-items-%d',
$this->baseDir,
getmypid()
);
} | php | {
"resource": ""
} |
q15804 | HandleFailureTrait.handleFailure | train | public function handleFailure($idNum, array $items)
{
if (!$this->failureFile) {
$this->initFailureFile();
}
$fp = @fopen($this->failureFile, 'a');
@fwrite($fp, serialize([$idNum => $items]) . PHP_EOL);
@fclose($fp);
} | php | {
"resource": ""
} |
q15805 | BreakpointActionValue.setValue | train | public function setValue($var)
{
GPBUtil::checkEnum($var, \Google\Cloud\Debugger\V2\Breakpoint_Action::class);
$this->value = $var;
return $this;
} | php | {
"resource": ""
} |
q15806 | ListClustersResponse.setClusters | train | public function setClusters($var)
{
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Dataproc\V1\Cluster::class);
$this->clusters = $arr;
return $this;
} | php | {
"resource": ""
} |
q15807 | Span.setAttributes | train | public function setAttributes($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\Trace\V2\Span_Attributes::class);
$this->attributes = $var;
return $this;
} | php | {
"resource": ""
} |
q15808 | Span.setStackTrace | train | public function setStackTrace($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\Trace\V2\StackTrace::class);
$this->stack_trace = $var;
return $this;
} | php | {
"resource": ""
} |
q15809 | Span.setTimeEvents | train | public function setTimeEvents($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\Trace\V2\Span_TimeEvents::class);
$this->time_events = $var;
return $this;
} | php | {
"resource": ""
} |
q15810 | Span.setLinks | train | public function setLinks($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\Trace\V2\Span_Links::class);
$this->links = $var;
return $this;
} | php | {
"resource": ""
} |
q15811 | FirestoreAdminGapicClient.fieldName | train | public static function fieldName($project, $database, $collectionId, $fieldId)
{
return self::getFieldNameTemplate()->render([
'project' => $project,
'database' => $database,
'collection_id' => $collectionId,
'field_id' => $fieldId,
]);
} | php | {
"resource": ""
} |
q15812 | FirestoreAdminGapicClient.indexName | train | public static function indexName($project, $database, $collectionId, $indexId)
{
return self::getIndexNameTemplate()->render([
'project' => $project,
'database' => $database,
'collection_id' => $collectionId,
'index_id' => $indexId,
]);
} | php | {
"resource": ""
} |
q15813 | FirestoreAdminGapicClient.parentName | train | public static function parentName($project, $database, $collectionId)
{
return self::getParentNameTemplate()->render([
'project' => $project,
'database' => $database,
'collection_id' => $collectionId,
]);
} | php | {
"resource": ""
} |
q15814 | Parameter.setPrompts | train | public function setPrompts($var)
{
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING);
$this->prompts = $arr;
return $this;
} | php | {
"resource": ""
} |
q15815 | DateShiftConfig.setCryptoKey | train | public function setCryptoKey($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\Dlp\V2\CryptoKey::class);
$this->writeOneof(4, $var);
return $this;
} | php | {
"resource": ""
} |
q15816 | PubSubClient.topics | train | public function topics(array $options = [])
{
$resultLimit = $this->pluck('resultLimit', $options, false);
return new ItemIterator(
new PageIterator(
function (array $topic) {
return $this->topicFactory($topic['name'], $topic);
},
[$this->connection, 'listTopics'],
$options + ['project' => $this->formatName('project', $this->projectId)],
[
'itemsKey' => 'topics',
'resultLimit' => $resultLimit
]
)
);
} | php | {
"resource": ""
} |
q15817 | PubSubClient.subscriptions | train | public function subscriptions(array $options = [])
{
$resultLimit = $this->pluck('resultLimit', $options, false);
return new ItemIterator(
new PageIterator(
function (array $subscription) {
return $this->subscriptionFactory(
$subscription['name'],
$subscription['topic'],
$subscription
);
},
[$this->connection, 'listSubscriptions'],
$options + ['project' => $this->formatName('project', $this->projectId)],
[
'itemsKey' => 'subscriptions',
'resultLimit' => $resultLimit
]
)
);
} | php | {
"resource": ""
} |
q15818 | PubSubClient.snapshot | train | public function snapshot($name, array $info = [])
{
return new Snapshot($this->connection, $this->projectId, $name, $this->encode, $info);
} | php | {
"resource": ""
} |
q15819 | PubSubClient.snapshots | train | public function snapshots(array $options = [])
{
$resultLimit = $this->pluck('resultLimit', $options, false);
return new ItemIterator(
new PageIterator(
function (array $snapshot) {
return new Snapshot(
$this->connection,
$this->projectId,
$this->pluckName('snapshot', $snapshot['name']),
$this->encode,
$snapshot
);
},
[$this->connection, 'listSnapshots'],
['project' => $this->formatName('project', $this->projectId)] + $options,
[
'itemsKey' => 'snapshots',
'resultLimit' => $resultLimit
]
)
);
} | php | {
"resource": ""
} |
q15820 | PubSubClient.consume | train | public function consume(array $requestData)
{
return $this->messageFactory($requestData, $this->connection, $this->projectId, $this->encode);
} | php | {
"resource": ""
} |
q15821 | PubSubClient.topicFactory | train | private function topicFactory($name, array $info = [])
{
return new Topic(
$this->connection,
$this->projectId,
$name,
$this->encode,
$info,
$this->clientConfig
);
} | php | {
"resource": ""
} |
q15822 | EmploymentRecord.setAddress | train | public function setAddress($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\Talent\V4beta1\Address::class);
$this->address = $var;
return $this;
} | php | {
"resource": ""
} |
q15823 | AutoMlGapicClient.datasetName | train | public static function datasetName($project, $location, $dataset)
{
return self::getDatasetNameTemplate()->render([
'project' => $project,
'location' => $location,
'dataset' => $dataset,
]);
} | php | {
"resource": ""
} |
q15824 | AutoMlGapicClient.modelEvaluationName | train | public static function modelEvaluationName($project, $location, $model, $modelEvaluation)
{
return self::getModelEvaluationNameTemplate()->render([
'project' => $project,
'location' => $location,
'model' => $model,
'model_evaluation' => $modelEvaluation,
]);
} | php | {
"resource": ""
} |
q15825 | Query.documents | train | public function documents(array $options = [])
{
$maxRetries = $this->pluck('maxRetries', $options, false);
$maxRetries = $maxRetries === null
? FirestoreClient::MAX_RETRIES
: $maxRetries;
$rows = (new ExponentialBackoff($maxRetries))->execute(function () use ($options) {
$query = $this->finalQueryPrepare($this->query);
$generator = $this->connection->runQuery($this->arrayFilterRemoveNull([
'parent' => $this->parent,
'structuredQuery' => $query,
'retries' => 0
]) + $options);
// cache collection references
$collections = [];
$out = [];
while ($generator->valid()) {
$result = $generator->current();
if (isset($result['document']) && $result['document']) {
$collectionName = $this->parentPath($result['document']['name']);
if (!isset($collections[$collectionName])) {
$collections[$collectionName] = new CollectionReference(
$this->connection,
$this->valueMapper,
$collectionName
);
}
$ref = new DocumentReference(
$this->connection,
$this->valueMapper,
$collections[$collectionName],
$result['document']['name']
);
$document = $result['document'];
$document['readTime'] = $result['readTime'];
$out[] = $this->createSnapshotWithData($this->valueMapper, $ref, $document);
}
$generator->next();
}
return $out;
});
return new QuerySnapshot($this, $rows);
} | php | {
"resource": ""
} |
q15826 | Query.select | train | public function select(array $fieldPaths)
{
$fields = [];
foreach ($fieldPaths as $field) {
if (!($field instanceof FieldPath)) {
$field = FieldPath::fromString($field);
}
$fields[] = [
'fieldPath' => $field->pathString()
];
}
if (!$fields) {
$fields[] = [
'fieldPath' => self::DOCUMENT_ID
];
}
return $this->newQuery([
'select' => [
'fields' => $fields
]
], true);
} | php | {
"resource": ""
} |
q15827 | Query.where | train | public function where($fieldPath, $operator, $value)
{
if ($value instanceof FieldValueInterface) {
throw new \InvalidArgumentException(sprintf(
'Value cannot be a `%s` value.',
FieldValue::class
));
}
if (!($fieldPath instanceof FieldPath)) {
$fieldPath = FieldPath::fromString($fieldPath);
}
$escapedPathString = $fieldPath->pathString();
$operator = array_key_exists($operator, $this->shortOperators)
? $this->shortOperators[$operator]
: $operator;
if (!in_array($operator, $this->allowedOperators)) {
throw new \InvalidArgumentException(sprintf(
'Operator %s is not a valid operator',
$operator
));
}
if ((is_float($value) && is_nan($value)) || is_null($value)) {
if ($operator !== self::OP_EQUAL) {
throw new \InvalidArgumentException('Null and NaN are allowed only with operator EQUALS.');
}
$unaryOperator = is_nan($value)
? self::OP_NAN
: self::OP_NULL;
$filter = [
'unaryFilter' => [
'field' => [
'fieldPath' => $escapedPathString
],
'op' => $unaryOperator
]
];
} else {
$filter = [
'fieldFilter' => [
'field' => [
'fieldPath' => $escapedPathString,
],
'op' => $operator,
'value' => $this->valueMapper->encodeValue($value)
]
];
}
$query = [
'where' => [
'compositeFilter' => [
'op' => Operator::PBAND,
'filters' => [
$filter
]
]
]
];
return $this->newQuery($query);
} | php | {
"resource": ""
} |
q15828 | Query.orderBy | train | public function orderBy($fieldPath, $direction = self::DIR_ASCENDING)
{
$direction = array_key_exists(strtoupper($direction), $this->shortDirections)
? $this->shortDirections[strtoupper($direction)]
: $direction;
if (!in_array($direction, $this->allowedDirections)) {
throw new \InvalidArgumentException(sprintf(
'Direction %s is not a valid direction',
$direction
));
}
if ($this->queryHas('startAt') || $this->queryHas('endAt')) {
throw new \InvalidArgumentException(
'Cannot specify an orderBy constraint after calling any of ' .
'`startAt()`, `startAfter()`, `endBefore()` or `endAt`().'
);
}
if (!($fieldPath instanceof FieldPath)) {
$fieldPath = FieldPath::fromString($fieldPath);
}
return $this->newQuery([
'orderBy' => [
[
'field' => [
'fieldPath' => $fieldPath->pathString()
],
'direction' => $direction
]
]
]);
} | php | {
"resource": ""
} |
q15829 | Query.snapshotPosition | train | private function snapshotPosition(DocumentSnapshot $snapshot, array $orderBy)
{
$appendName = true;
foreach ($orderBy as $order) {
if ($order['field']['fieldPath'] === self::DOCUMENT_ID) {
$appendName = false;
break;
}
}
if ($appendName) {
// If there is inequality filter (anything other than equals),
// append orderBy(the last inequality filter’s path, ascending).
if (!$orderBy && $this->queryHas('where')) {
$filters = $this->query['where']['compositeFilter']['filters'];
$inequality = array_filter($filters, function ($filter) {
$type = array_keys($filter)[0];
return !in_array($filter[$type]['op'], [
self::OP_EQUAL,
self::OP_ARRAY_CONTAINS
]);
});
if ($inequality) {
$filter = end($inequality);
$type = array_keys($filter)[0];
$orderBy[] = [
'field' => [
'fieldPath' => $filter[$type]['field']['fieldPath'],
],
'direction' => self::DIR_ASCENDING
];
}
}
// If the query has existing orderBy constraints
if ($orderBy) {
// Append orderBy(__name__, direction of last orderBy clause)
$lastOrderDirection = end($orderBy)['direction'];
$orderBy[] = [
'field' => [
'fieldPath' => self::DOCUMENT_ID
],
'direction' => $lastOrderDirection
];
} else {
// no existing orderBy constraints
// Otherwise append orderBy(__name__, ‘asc’)
$orderBy[] = [
'field' => [
'fieldPath' => self::DOCUMENT_ID
],
'direction' => self::DIR_ASCENDING
];
}
}
$fieldValues = $this->snapshotCursorValues($snapshot, $orderBy);
return [
$fieldValues,
$orderBy
];
} | php | {
"resource": ""
} |
q15830 | Query.snapshotCursorValues | train | private function snapshotCursorValues(DocumentSnapshot $snapshot, array $orderBy)
{
$fieldValues = [];
foreach ($orderBy as $order) {
$path = $order['field']['fieldPath'];
if ($path === self::DOCUMENT_ID) {
continue;
}
$fieldValues[] = $snapshot->get($path);
}
$fieldValues[] = $snapshot->reference();
return $fieldValues;
} | php | {
"resource": ""
} |
q15831 | Query.newQuery | train | private function newQuery(array $additionalConfig, $overrideTopLevelKeys = false)
{
$query = $this->query;
if ($overrideTopLevelKeys) {
$keys = array_keys($additionalConfig);
foreach ($keys as $key) {
unset($query[$key]);
}
}
$query = $this->arrayMergeRecursive($query, $additionalConfig);
return new self(
$this->connection,
$this->valueMapper,
$this->parent,
$query
);
} | php | {
"resource": ""
} |
q15832 | Query.finalQueryPrepare | train | private function finalQueryPrepare(array $query)
{
if (isset($query['where']['compositeFilter']) && count($query['where']['compositeFilter']['filters']) === 1) {
$filter = $query['where']['compositeFilter']['filters'][0];
$query['where'] = $filter;
}
return $query;
} | php | {
"resource": ""
} |
q15833 | CommitResponse.setMutationResults | train | public function setMutationResults($var)
{
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Datastore\V1\MutationResult::class);
$this->mutation_results = $arr;
return $this;
} | php | {
"resource": ""
} |
q15834 | CloudRedisGapicClient.instanceName | train | public static function instanceName($project, $location, $instance)
{
return self::getInstanceNameTemplate()->render([
'project' => $project,
'location' => $location,
'instance' => $instance,
]);
} | php | {
"resource": ""
} |
q15835 | BigtableInstanceAdminGrpcClient.CreateInstance | train | public function CreateInstance(\Google\Cloud\Bigtable\Admin\V2\CreateInstanceRequest $argument,
$metadata = [], $options = []) {
return $this->_simpleRequest('/google.bigtable.admin.v2.BigtableInstanceAdmin/CreateInstance',
$argument,
['\Google\LongRunning\Operation', 'decode'],
$metadata, $options);
} | php | {
"resource": ""
} |
q15836 | StreamingRecognizeRequest.setStreamingConfig | train | public function setStreamingConfig($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\Speech\V1\StreamingRecognitionConfig::class);
$this->writeOneof(1, $var);
return $this;
} | php | {
"resource": ""
} |
q15837 | Image.setSource | train | public function setSource($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\Vision\V1\ImageSource::class);
$this->source = $var;
return $this;
} | php | {
"resource": ""
} |
q15838 | BatchDmlResult.rowCounts | train | public function rowCounts()
{
if (!$this->rowCounts) {
foreach ($this->data['resultSets'] as $resultSet) {
$this->rowCounts[] = $resultSet['stats']['rowCountExact'];
}
}
return $this->rowCounts;
} | php | {
"resource": ""
} |
q15839 | DocumentSnapshot.get | train | public function get($fieldPath)
{
$res = null;
if (is_string($fieldPath)) {
$parts = explode('.', $fieldPath);
} elseif ($fieldPath instanceof FieldPath) {
$parts = $fieldPath->path();
} else {
throw new \InvalidArgumentException('Given path was not a string or instance of FieldPath.');
}
$len = count($parts);
$fields = $this->data;
foreach ($parts as $idx => $part) {
if ($idx === $len-1 && isset($fields[$part])) {
$res = $fields[$part];
break;
} else {
if (!isset($fields[$part])) {
throw new \InvalidArgumentException(sprintf(
'Field path `%s` does not exist.',
$fieldPath
));
}
$fields = $fields[$part];
}
}
return $res;
} | php | {
"resource": ""
} |
q15840 | ListEntityTypesResponse.setEntityTypes | train | public function setEntityTypes($var)
{
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Dialogflow\V2\EntityType::class);
$this->entity_types = $arr;
return $this;
} | php | {
"resource": ""
} |
q15841 | ScheduleTransferRunsResponse.setRuns | train | public function setRuns($var)
{
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\BigQuery\DataTransfer\V1\TransferRun::class);
$this->runs = $arr;
return $this;
} | php | {
"resource": ""
} |
q15842 | ProfileEvent.setType | train | public function setType($var)
{
GPBUtil::checkEnum($var, \Google\Cloud\Talent\V4beta1\ProfileEvent_ProfileEventType::class);
$this->type = $var;
return $this;
} | php | {
"resource": ""
} |
q15843 | CreateContextRequest.setContext | train | public function setContext($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\Dialogflow\V2\Context::class);
$this->context = $var;
return $this;
} | php | {
"resource": ""
} |
q15844 | InspectResult.setFindings | train | public function setFindings($var)
{
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Dlp\V2\Finding::class);
$this->findings = $arr;
return $this;
} | php | {
"resource": ""
} |
q15845 | ListDebuggeesResponse.setDebuggees | train | public function setDebuggees($var)
{
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Debugger\V2\Debuggee::class);
$this->debuggees = $arr;
return $this;
} | php | {
"resource": ""
} |
q15846 | OrganizationSettings.setAssetDiscoveryConfig | train | public function setAssetDiscoveryConfig($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\SecurityCenter\V1\OrganizationSettings_AssetDiscoveryConfig::class);
$this->asset_discovery_config = $var;
return $this;
} | php | {
"resource": ""
} |
q15847 | Job.setJobBenefits | train | public function setJobBenefits($var)
{
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::ENUM, \Google\Cloud\Talent\V4beta1\JobBenefit::class);
$this->job_benefits = $arr;
return $this;
} | php | {
"resource": ""
} |
q15848 | Job.setDegreeTypes | train | public function setDegreeTypes($var)
{
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::ENUM, \Google\Cloud\Talent\V4beta1\DegreeType::class);
$this->degree_types = $arr;
return $this;
} | php | {
"resource": ""
} |
q15849 | Job.setJobLevel | train | public function setJobLevel($var)
{
GPBUtil::checkEnum($var, \Google\Cloud\Talent\V4beta1\JobLevel::class);
$this->job_level = $var;
return $this;
} | php | {
"resource": ""
} |
q15850 | Job.setDerivedInfo | train | public function setDerivedInfo($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\Talent\V4beta1\Job_DerivedInfo::class);
$this->derived_info = $var;
return $this;
} | php | {
"resource": ""
} |
q15851 | Job.setProcessingOptions | train | public function setProcessingOptions($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\Talent\V4beta1\Job_ProcessingOptions::class);
$this->processing_options = $var;
return $this;
} | php | {
"resource": ""
} |
q15852 | Write.setUpdate | train | public function setUpdate($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\Firestore\V1beta1\Document::class);
$this->writeOneof(1, $var);
return $this;
} | php | {
"resource": ""
} |
q15853 | Write.setTransform | train | public function setTransform($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\Firestore\V1beta1\DocumentTransform::class);
$this->writeOneof(6, $var);
return $this;
} | php | {
"resource": ""
} |
q15854 | Write.setUpdateMask | train | public function setUpdateMask($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\Firestore\V1beta1\DocumentMask::class);
$this->update_mask = $var;
return $this;
} | php | {
"resource": ""
} |
q15855 | ReplaceValueConfig.setNewValue | train | public function setNewValue($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\Dlp\V2\Value::class);
$this->new_value = $var;
return $this;
} | php | {
"resource": ""
} |
q15856 | Command.execute | train | protected function execute(InputInterface $input, OutputInterface $output)
{
if (PHP_VERSION_ID < 50600) {
throw new \RuntimeException('This command is only available in PHP 5.6 and later.');
}
$execDir = $this->rootPath . '/' . self::EXEC_DIR;
$token = $this->githubToken($input->getOption('token'));
$shell = new RunShell;
$guzzle = $this->guzzleClient();
$github = $this->githubClient($output, $shell, $guzzle, $token);
$split = $this->splitWrapper($output, $shell);
@mkdir($execDir);
$splitBinaryPath = $this->splitshInstall($output, $shell, $execDir, $input->getOption('splitsh'));
$componentId = $input->getOption('component');
$components = $this->componentManager->componentsExtra($componentId);
// remove umbrella component.
$components = array_filter($components, function ($component, $key) {
return $key !== 'google-cloud';
}, ARRAY_FILTER_USE_BOTH);
$manifestPath = $this->rootPath . '/docs/manifest.json';
$parentTagSource = sprintf(self::PARENT_TAG_NAME, $input->getArgument('parent'));
$errors = [];
foreach ($components as $component) {
$res = $this->processComponent($output, $github, $split, $component, $splitBinaryPath, $parentTagSource);
if (!$res) {
$errors[] = $component['id'];
}
$output->writeln('');
$output->writeln('');
}
if ($errors) {
$output->writeln('<error>[ERROR]</error>: One or more components reported an error.');
$output->writeln('Please correct errors and try again.');
$output->writeln('Error component(s): ' . implode(', ', $errors));
return 1;
}
return 0;
} | php | {
"resource": ""
} |
q15857 | Command.processComponent | train | private function processComponent(
OutputInterface $output,
GitHub $github,
Split $split,
array $component,
$splitBinaryPath,
$parentTagSource
) {
$output->writeln('');
$localVersion = current($this->componentManager->componentsVersion($component['id']));
$isAlreadyTagged = $github->doesTagExist($component['target'], $localVersion);
$output->writeln(sprintf(
'<comment>%s</comment>: Starting on component. Target version <info>%s</info>',
$component['id'],
$localVersion
));
$this->writeDiv($output);
if ($isAlreadyTagged) {
$output->writeln(sprintf(
'Version <info>%s</info> already exists on target <info>%s</info>',
$localVersion,
$component['target']
));
$output->writeln('<comment>[info]</comment> Skipping.');
return true;
}
$output->writeln(sprintf(
'<comment>%s</comment>: Running splitsh',
$component['id']
));
$splitBranch = $split->execute($splitBinaryPath, $this->rootPath, $component['path']);
if ($splitBranch) {
$output->writeln(sprintf('Split succeeded, branch <info>%s</info> created.', $splitBranch));
} else {
$output->writeln('<error>Split failed!</error>');
return false;
}
$output->writeln('');
$output->writeln(sprintf(
'<comment>%s</comment>: Push to github target %s',
$component['id'],
$component['target']
));
$res = $github->push($component['target'], $splitBranch);
if ($res[0]) {
$output->writeln(sprintf('<comment>%s</comment>: Push succeeded.', $component['id']));
} else {
$output->writeln(sprintf('<error>%s</error>: Push failed.', $component['id']));
return false;
}
$output->writeln('');
$output->writeln('<comment>[info]</comment> Creating GitHub tag.');
// @todo once the release builder is refactored, this should generate
// actually useful release notes for the component in question.
$notes = sprintf(
'For release notes, please see the [associated Google Cloud PHP release](%s).',
$parentTagSource
);
$res = $github->createRelease(
$component['target'],
$localVersion,
$component['displayName'] . ' ' . $localVersion,
$notes
);
if ($res) {
$output->writeln(sprintf('<comment>%s</comment>: Tag succeeded.', $component['id']));
} else {
$output->writeln(sprintf('<error>%s</error>: Tag failed.', $component['id']));
return false;
}
return true;
} | php | {
"resource": ""
} |
q15858 | Command.githubToken | train | protected function githubToken($userToken)
{
$token = $userToken ?: getenv(self::TOKEN_ENV);
if (!$token) {
throw new \RuntimeException(sprintf(
'Could not find GitHub auth token. Please set the environment ' .
'variable `%s` or pass token as console argument.',
self::TOKEN_ENV
));
}
return $token;
} | php | {
"resource": ""
} |
q15859 | Command.githubClient | train | protected function githubClient(OutputInterface $output, RunShell $shell, Client $guzzle, $token)
{
$output->writeln('<comment>[info]</comment> Instantiating GitHub API Wrapper.');
return new GitHub($shell, $guzzle, $token);
} | php | {
"resource": ""
} |
q15860 | Command.splitshInstall | train | protected function splitshInstall(OutputInterface $output, RunShell $shell, $execDir, $binaryPath)
{
if ($binaryPath) {
$output->writeln('<comment>[info]</comment> Using User-Provided Splitsh binary.');
return $binaryPath;
}
$output->writeln('<comment>[info]</comment> Compiling Splitsh');
$this->writeDiv($output);
$install = new SplitInstall($shell, $execDir);
$res = $install->installFromSource($this->rootPath);
$output->writeln(sprintf(
'<comment>[info]</comment> Splitsh Installer says <info>%s</info>',
$res[0]
));
return $res[1];
} | php | {
"resource": ""
} |
q15861 | Table.mutateRows | train | public function mutateRows(array $rowMutations, array $options = [])
{
if (!$this->isAssoc($rowMutations)) {
throw new \InvalidArgumentException(
'Expected rowMutations to be of type associative array, instead got list.'
);
}
$entries = [];
foreach ($rowMutations as $rowKey => $mutations) {
$entries[] = $this->toEntry($rowKey, $mutations);
}
$this->mutateRowsWithEntries($entries, $options);
} | php | {
"resource": ""
} |
q15862 | Table.mutateRow | train | public function mutateRow($rowKey, Mutations $mutations, array $options = [])
{
$this->gapicClient->mutateRow(
$this->tableName,
$rowKey,
$mutations->toProto(),
$options + $this->options
);
} | php | {
"resource": ""
} |
q15863 | Table.readRows | train | public function readRows(array $options = [])
{
$rowKeys = $this->pluck('rowKeys', $options, false) ?: [];
$ranges = $this->pluck('rowRanges', $options, false) ?: [];
$filter = $this->pluck('filter', $options, false) ?: null;
array_walk($ranges, function (&$range) {
$range = $this->serializer->decodeMessage(
new RowRange(),
$range
);
});
if (!is_array($rowKeys)) {
throw new \InvalidArgumentException(
sprintf(
'Expected rowKeys to be of type array, instead got \'%s\'.',
gettype($rowKeys)
)
);
}
if ($ranges || $rowKeys) {
$options['rows'] = $this->serializer->decodeMessage(
new RowSet,
[
'rowKeys' => $rowKeys,
'rowRanges' => $ranges
]
);
}
if ($filter !== null) {
if (!$filter instanceof FilterInterface) {
throw new \InvalidArgumentException(
sprintf(
'Expected filter to be of type \'%s\', instead got \'%s\'.',
FilterInterface::class,
gettype($filter)
)
);
}
$options['filter'] = $filter->toProto();
}
return new ChunkFormatter(
[$this->gapicClient, 'readRows'],
$this->tableName,
$options + $this->options
);
} | php | {
"resource": ""
} |
q15864 | Table.readRow | train | public function readRow($rowKey, array $options = [])
{
return $this->readRows(
['rowKeys' => [$rowKey]] + $options + $this->options
)
->readAll()
->current();
} | php | {
"resource": ""
} |
q15865 | Table.checkAndMutateRow | train | public function checkAndMutateRow($rowKey, array $options = [])
{
$hasSetMutations = false;
if (isset($options['predicateFilter'])) {
$this->convertToProto($options, 'predicateFilter', FilterInterface::class);
}
if (isset($options['trueMutations'])) {
$this->convertToProto($options, 'trueMutations', Mutations::class);
$hasSetMutations = true;
}
if (isset($options['falseMutations'])) {
$this->convertToProto($options, 'falseMutations', Mutations::class);
$hasSetMutations = true;
}
if (!$hasSetMutations) {
throw new \InvalidArgumentException('checkAndMutateRow must have either trueMutations or falseMutations.');
}
return $this->gapicClient
->checkAndMutateRow(
$this->tableName,
$rowKey,
$options + $this->options
)
->getPredicateMatched();
} | php | {
"resource": ""
} |
q15866 | LogMetric.setLabelExtractors | train | public function setLabelExtractors($var)
{
$arr = GPBUtil::checkMapField($var, \Google\Protobuf\Internal\GPBType::STRING, \Google\Protobuf\Internal\GPBType::STRING);
$this->label_extractors = $arr;
return $this;
} | php | {
"resource": ""
} |
q15867 | LogMetric.setVersion | train | public function setVersion($var)
{
GPBUtil::checkEnum($var, \Google\Cloud\Logging\V2\LogMetric_ApiVersion::class);
$this->version = $var;
return $this;
} | php | {
"resource": ""
} |
q15868 | BatchWriteSpansRequest.setSpans | train | public function setSpans($var)
{
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Trace\V2\Span::class);
$this->spans = $arr;
return $this;
} | php | {
"resource": ""
} |
q15869 | DeidentifyConfig.setInfoTypeTransformations | train | public function setInfoTypeTransformations($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\Dlp\V2\InfoTypeTransformations::class);
$this->writeOneof(1, $var);
return $this;
} | php | {
"resource": ""
} |
q15870 | DeidentifyConfig.setRecordTransformations | train | public function setRecordTransformations($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\Dlp\V2\RecordTransformations::class);
$this->writeOneof(2, $var);
return $this;
} | php | {
"resource": ""
} |
q15871 | Task.setStatus | train | public function setStatus($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\Tasks\V2beta2\TaskStatus::class);
$this->status = $var;
return $this;
} | php | {
"resource": ""
} |
q15872 | ByteContentItem.setType | train | public function setType($var)
{
GPBUtil::checkEnum($var, \Google\Cloud\Dlp\V2\ByteContentItem_BytesType::class);
$this->type = $var;
return $this;
} | php | {
"resource": ""
} |
q15873 | CloudSchedulerGapicClient.jobName | train | public static function jobName($project, $location, $job)
{
return self::getJobNameTemplate()->render([
'project' => $project,
'location' => $location,
'job' => $job,
]);
} | php | {
"resource": ""
} |
q15874 | CloudSchedulerGapicClient.deleteJob | train | public function deleteJob($name, array $optionalArgs = [])
{
$request = new DeleteJobRequest();
$request->setName($name);
$requestParams = new RequestParamsHeaderDescriptor([
'name' => $request->getName(),
]);
$optionalArgs['headers'] = isset($optionalArgs['headers'])
? array_merge($requestParams->getHeader(), $optionalArgs['headers'])
: $requestParams->getHeader();
return $this->startCall(
'DeleteJob',
GPBEmpty::class,
$optionalArgs,
$request
)->wait();
} | php | {
"resource": ""
} |
q15875 | RepoId.setProjectRepoId | train | public function setProjectRepoId($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\DevTools\Source\V1\ProjectRepoId::class);
$this->writeOneof(1, $var);
return $this;
} | php | {
"resource": ""
} |
q15876 | Operation.setOperationType | train | public function setOperationType($var)
{
GPBUtil::checkEnum($var, \Google\Cloud\Container\V1\Operation_Type::class);
$this->operation_type = $var;
return $this;
} | php | {
"resource": ""
} |
q15877 | LogEntry.setSeverity | train | public function setSeverity($var)
{
GPBUtil::checkEnum($var, \Google\Cloud\Logging\Type\LogSeverity::class);
$this->severity = $var;
return $this;
} | php | {
"resource": ""
} |
q15878 | LogEntry.setHttpRequest | train | public function setHttpRequest($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\Logging\Type\HttpRequest::class);
$this->http_request = $var;
return $this;
} | php | {
"resource": ""
} |
q15879 | LogEntry.setOperation | train | public function setOperation($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\Logging\V2\LogEntryOperation::class);
$this->operation = $var;
return $this;
} | php | {
"resource": ""
} |
q15880 | LogEntry.setSourceLocation | train | public function setSourceLocation($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\Logging\V2\LogEntrySourceLocation::class);
$this->source_location = $var;
return $this;
} | php | {
"resource": ""
} |
q15881 | ListDevicesRequest.setGatewayListOptions | train | public function setGatewayListOptions($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\Iot\V1\GatewayListOptions::class);
$this->gateway_list_options = $var;
return $this;
} | php | {
"resource": ""
} |
q15882 | UpdateTransferConfigRequest.setTransferConfig | train | public function setTransferConfig($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\BigQuery\DataTransfer\V1\TransferConfig::class);
$this->transfer_config = $var;
return $this;
} | php | {
"resource": ""
} |
q15883 | ListIndexesResponse.setIndexes | train | public function setIndexes($var)
{
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Firestore\Admin\V1\Index::class);
$this->indexes = $arr;
return $this;
} | php | {
"resource": ""
} |
q15884 | LockTrait.synchronize | train | public function synchronize(callable $func, array $options = [])
{
$result = null;
$exception = null;
if ($this->acquire($options)) {
try {
$result = $func();
} catch (\Exception $ex) {
$exception = $ex;
}
$this->release();
}
if ($exception) {
throw $exception;
}
return $result;
} | php | {
"resource": ""
} |
q15885 | Modification.setCreate | train | public function setCreate($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\Bigtable\Admin\V2\ColumnFamily::class);
$this->writeOneof(2, $var);
return $this;
} | php | {
"resource": ""
} |
q15886 | NotificationChannelDescriptor.setLabels | train | public function setLabels($var)
{
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Api\LabelDescriptor::class);
$this->labels = $arr;
return $this;
} | php | {
"resource": ""
} |
q15887 | NotificationChannelDescriptor.setSupportedTiers | train | public function setSupportedTiers($var)
{
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::ENUM, \Google\Cloud\Monitoring\V3\ServiceTier::class);
$this->supported_tiers = $arr;
return $this;
} | php | {
"resource": ""
} |
q15888 | ClusterManagerGapicClient.listClusters | train | public function listClusters($projectId, $zone, array $optionalArgs = [])
{
$request = new ListClustersRequest();
$request->setProjectId($projectId);
$request->setZone($zone);
if (isset($optionalArgs['parent'])) {
$request->setParent($optionalArgs['parent']);
}
$requestParams = new RequestParamsHeaderDescriptor([
'parent' => $request->getParent(),
]);
$optionalArgs['headers'] = isset($optionalArgs['headers'])
? array_merge($requestParams->getHeader(), $optionalArgs['headers'])
: $requestParams->getHeader();
return $this->startCall(
'ListClusters',
ListClustersResponse::class,
$optionalArgs,
$request
)->wait();
} | php | {
"resource": ""
} |
q15889 | ClusterManagerGapicClient.getCluster | train | public function getCluster($projectId, $zone, $clusterId, array $optionalArgs = [])
{
$request = new GetClusterRequest();
$request->setProjectId($projectId);
$request->setZone($zone);
$request->setClusterId($clusterId);
if (isset($optionalArgs['name'])) {
$request->setName($optionalArgs['name']);
}
$requestParams = new RequestParamsHeaderDescriptor([
'name' => $request->getName(),
]);
$optionalArgs['headers'] = isset($optionalArgs['headers'])
? array_merge($requestParams->getHeader(), $optionalArgs['headers'])
: $requestParams->getHeader();
return $this->startCall(
'GetCluster',
Cluster::class,
$optionalArgs,
$request
)->wait();
} | php | {
"resource": ""
} |
q15890 | ListBreakpointsRequest.setAction | train | public function setAction($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\Debugger\V2\ListBreakpointsRequest_BreakpointActionValue::class);
$this->action = $var;
return $this;
} | php | {
"resource": ""
} |
q15891 | AsyncBatchAnnotateFilesResponse.setResponses | train | public function setResponses($var)
{
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Vision\V1\AsyncAnnotateFileResponse::class);
$this->responses = $arr;
return $this;
} | php | {
"resource": ""
} |
q15892 | AnnotateVideoRequest.setFeatures | train | public function setFeatures($var)
{
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::ENUM, \Google\Cloud\VideoIntelligence\V1\Feature::class);
$this->features = $arr;
return $this;
} | php | {
"resource": ""
} |
q15893 | RequestWrapperTrait.setCommonDefaults | train | public function setCommonDefaults(array $config)
{
$config += [
'authCache' => new MemoryCacheItemPool(),
'authCacheOptions' => [],
'credentialsFetcher' => null,
'keyFile' => null,
'requestTimeout' => null,
'retries' => 3,
'scopes' => null
];
if ($config['credentialsFetcher'] && !$config['credentialsFetcher'] instanceof FetchAuthTokenInterface) {
throw new \InvalidArgumentException('credentialsFetcher must implement FetchAuthTokenInterface.');
}
if (!$config['authCache'] instanceof CacheItemPoolInterface) {
throw new \InvalidArgumentException('authCache must implement CacheItemPoolInterface.');
}
$this->authCache = $config['authCache'];
$this->authCacheOptions = $config['authCacheOptions'];
$this->credentialsFetcher = $config['credentialsFetcher'];
$this->retries = $config['retries'];
$this->scopes = $config['scopes'];
$this->keyFile = $config['keyFile'];
$this->requestTimeout = $config['requestTimeout'];
} | php | {
"resource": ""
} |
q15894 | CropHintsAnnotation.setCropHints | train | public function setCropHints($var)
{
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Vision\V1\CropHint::class);
$this->crop_hints = $arr;
return $this;
} | php | {
"resource": ""
} |
q15895 | DatastoreGapicClient.beginTransaction | train | public function beginTransaction($projectId, array $optionalArgs = [])
{
$request = new BeginTransactionRequest();
$request->setProjectId($projectId);
if (isset($optionalArgs['transactionOptions'])) {
$request->setTransactionOptions($optionalArgs['transactionOptions']);
}
$requestParams = new RequestParamsHeaderDescriptor([
'project_id' => $request->getProjectId(),
]);
$optionalArgs['headers'] = isset($optionalArgs['headers'])
? array_merge($requestParams->getHeader(), $optionalArgs['headers'])
: $requestParams->getHeader();
return $this->startCall(
'BeginTransaction',
BeginTransactionResponse::class,
$optionalArgs,
$request
)->wait();
} | php | {
"resource": ""
} |
q15896 | DatastoreGapicClient.commit | train | public function commit($projectId, $mode, $mutations, array $optionalArgs = [])
{
$request = new CommitRequest();
$request->setProjectId($projectId);
$request->setMode($mode);
$request->setMutations($mutations);
if (isset($optionalArgs['transaction'])) {
$request->setTransaction($optionalArgs['transaction']);
}
$requestParams = new RequestParamsHeaderDescriptor([
'project_id' => $request->getProjectId(),
]);
$optionalArgs['headers'] = isset($optionalArgs['headers'])
? array_merge($requestParams->getHeader(), $optionalArgs['headers'])
: $requestParams->getHeader();
return $this->startCall(
'Commit',
CommitResponse::class,
$optionalArgs,
$request
)->wait();
} | php | {
"resource": ""
} |
q15897 | PsrLogger.log | train | public function log($level, $message, array $context = [])
{
$this->validateLogLevel($level);
$options = [];
if (isset($context['exception'])
&& ($context['exception'] instanceof \Exception || $context['exception'] instanceof \Throwable)) {
$context['exception'] = (string) $context['exception'];
}
if (isset($context['stackdriverOptions'])) {
$options = $context['stackdriverOptions'];
unset($context['stackdriverOptions']);
}
$formatter = new NormalizerFormatter();
$processor = new PsrLogMessageProcessor();
$processedData = $processor([
'message' => (string) $message,
'context' => $formatter->format($context)
]);
$jsonPayload = [$this->messageKey => $processedData['message']];
// Adding labels for log request correlation.
$labels = $this->getLabels();
if (!empty($labels)) {
$options['labels'] =
(isset($options['labels'])
? $options['labels']
: []) + $labels;
// Copy over the value for 'appengine.googleapis.com/trace_id' to
// `trace` option too.
if (isset($labels['appengine.googleapis.com/trace_id'])) {
$options['trace'] =
$labels['appengine.googleapis.com/trace_id'];
}
}
// Adding MonitoredResource
$resource = $this->metadataProvider->monitoredResource();
if (!empty($resource)) {
$options['resource'] =
(isset($options['resource'])
? $options['resource']
: []) + $resource;
}
$entry = $this->logger->entry(
$jsonPayload + $processedData['context'],
$options + [
'severity' => $level
]
);
$this->sendEntry($entry);
} | php | {
"resource": ""
} |
q15898 | PsrLogger.serialize | train | public function serialize()
{
$debugOutputResource = null;
if (is_resource($this->debugOutputResource)) {
$metadata = stream_get_meta_data($this->debugOutputResource);
$debugOutputResource = [
'uri' => $metadata['uri'],
'mode' => $metadata['mode']
];
}
return serialize([
$this->messageKey,
$this->batchEnabled,
$this->metadataProvider,
$this->debugOutput,
$this->clientConfig,
$this->batchMethod,
$this->logName,
$debugOutputResource
]);
} | php | {
"resource": ""
} |
q15899 | PsrLogger.unserialize | train | public function unserialize($data)
{
list(
$this->messageKey,
$this->batchEnabled,
$this->metadataProvider,
$this->debugOutput,
$this->clientConfig,
$this->batchMethod,
$this->logName,
$debugOutputResource
) = unserialize($data);
if (is_array($debugOutputResource)) {
$this->debugOutputResource = fopen(
$debugOutputResource['uri'],
$debugOutputResource['mode']
);
}
} | php | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.