_id stringlengths 2 7 | title stringlengths 3 151 | partition stringclasses 3
values | text stringlengths 83 13k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q15000 | ListNodePoolsResponse.setNodePools | train | public function setNodePools($var)
{
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Container\V1\NodePool::class);
$this->node_pools = $arr;
return $this;
} | php | {
"resource": ""
} |
q15001 | Metadata.getProjectId | train | public function getProjectId()
{
if (!isset($this->projectId)) {
$this->projectId = $this->get('project/project-id');
}
return $this->projectId;
} | php | {
"resource": ""
} |
q15002 | Metadata.getNumericProjectId | train | public function getNumericProjectId()
{
if (!isset($this->numericProjectId)) {
$this->numericProjectId = $this->get('project/numeric-project-id');
}
return $this->numericProjectId;
} | php | {
"resource": ""
} |
q15003 | IndexField.setArrayConfig | train | public function setArrayConfig($var)
{
GPBUtil::checkEnum($var, \Google\Cloud\Firestore\Admin\V1\Index_IndexField_ArrayConfig::class);
$this->writeOneof(3, $var);
return $this;
} | php | {
"resource": ""
} |
q15004 | TransferRun.setState | train | public function setState($var)
{
GPBUtil::checkEnum($var, \Google\Cloud\BigQuery\DataTransfer\V1\TransferState::class);
$this->state = $var;
return $this;
} | php | {
"resource": ""
} |
q15005 | ComponentVersionTrait.addToComponentManifest | train | private function addToComponentManifest($version, array $component)
{
$manifest = $this->getManifest($this->manifest());
$index = $this->getManifestComponentModuleIndex($manifest, $component['id']);
array_unshift($manifest['modules'][$index]['versions'], 'v'. $version);
$content = json_encode($manifest, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES) ."\n";
$result = file_put_contents($this->manifest(), $content);
$this->setManifest($manifest);
if (!$result) {
throw new \RuntimeException('File write failed');
}
} | php | {
"resource": ""
} |
q15006 | ComponentVersionTrait.updateComponentVersionConstant | train | private function updateComponentVersionConstant($version, $componentPath, $componentEntry)
{
if (is_null($componentEntry)) {
return false;
}
$path = $this->rootPath() .'/'. $componentPath .'/'. $componentEntry;
if (!file_exists($path)) {
throw new \RuntimeException(sprintf(
'Component entry file %s does not exist',
$path
));
}
$entry = file_get_contents($path);
$replacement = sprintf("const VERSION = '%s';", $version);
$entry = preg_replace("/const VERSION = [\'\\\"]([0-9.]{0,}|master)[\'\\\"]\;/", $replacement, $entry);
$result = file_put_contents($path, $entry);
if (!$result) {
throw new \RuntimeException('File write failed');
}
return true;
} | php | {
"resource": ""
} |
q15007 | ComponentVersionTrait.updateComponentVersionFile | train | private function updateComponentVersionFile($version, array $component)
{
$path = $this->rootPath() .'/'. $component['path'] .'/VERSION';
$result = file_put_contents($path, $version);
if (!$result) {
throw new \RuntimeException('File write failed');
}
return true;
} | php | {
"resource": ""
} |
q15008 | ComponentVersionTrait.updateComposerReplacesVersion | train | private function updateComposerReplacesVersion($version, array $component)
{
$composer = $this->rootPath() .'/composer.json';
if (!file_exists($composer)) {
throw new \Exception('Invalid composer.json path');
}
$data = json_decode(file_get_contents($composer), true);
$data['replace'][$component['name']] = $version;
file_put_contents($composer, json_encode($data, JSON_PRETTY_PRINT|JSON_UNESCAPED_SLASHES));
} | php | {
"resource": ""
} |
q15009 | KeyRange.setStart | train | public function setStart($type, array $start)
{
$rangeKey = $this->fromDefinition($type, 'start');
$this->startType = $rangeKey;
$this->start = $start;
} | php | {
"resource": ""
} |
q15010 | KeyRange.setEnd | train | public function setEnd($type, array $end)
{
if (!in_array($type, array_keys($this->definition))) {
throw new \InvalidArgumentException(sprintf(
'Invalid KeyRange type. Allowed values are %s',
implode(', ', array_keys($this->definition))
));
}
$rangeKey = $this->fromDefinition($type, 'end');
$this->endType = $rangeKey;
$this->end = $end;
} | php | {
"resource": ""
} |
q15011 | KeyRange.keyRangeObject | train | public function keyRangeObject()
{
if (!$this->start || !$this->end) {
throw new \BadMethodCallException('Key Range must supply a start and an end');
}
return [
$this->startType => $this->start,
$this->endType => $this->end
];
} | php | {
"resource": ""
} |
q15012 | KeyRange.fromDefinition | train | private function fromDefinition($type, $startOrEnd)
{
if (!array_key_exists($type, $this->definition)) {
throw new \InvalidArgumentException(sprintf(
'Invalid KeyRange %s type. Allowed values are %s.',
$startOrEnd,
implode(', ', array_keys($this->definition))
));
}
return $this->definition[$type][$startOrEnd];
} | php | {
"resource": ""
} |
q15013 | LanguageClient.analyzeSentiment | train | public function analyzeSentiment($content, array $options = [])
{
return new Annotation(
$this->connection->analyzeSentiment(
$this->formatRequest($content, $options)
)
);
} | php | {
"resource": ""
} |
q15014 | LanguageClient.analyzeEntitySentiment | train | public function analyzeEntitySentiment($content, array $options = [])
{
return new Annotation(
$this->connection->analyzeEntitySentiment(
$this->formatRequest($content, $options)
)
);
} | php | {
"resource": ""
} |
q15015 | LanguageClient.analyzeSyntax | train | public function analyzeSyntax($content, array $options = [])
{
$syntaxResponse = $this->connection->analyzeSyntax(
$this->formatRequest($content, $options)
);
return new Annotation($syntaxResponse + ['entities' => []]);
} | php | {
"resource": ""
} |
q15016 | LanguageClient.normalizeFeatures | train | private function normalizeFeatures(array $features)
{
$results = [];
foreach ($features as $feature) {
$featureName = array_key_exists($feature, $this->featureShortNames)
? $this->featureShortNames[$feature]
: $feature;
$results[$featureName] = true;
}
return $results;
} | php | {
"resource": ""
} |
q15017 | NotificationChannelServiceGrpcClient.SendNotificationChannelVerificationCode | train | public function SendNotificationChannelVerificationCode(\Google\Cloud\Monitoring\V3\SendNotificationChannelVerificationCodeRequest $argument,
$metadata = [], $options = []) {
return $this->_simpleRequest('/google.monitoring.v3.NotificationChannelService/SendNotificationChannelVerificationCode',
$argument,
['\Google\Protobuf\GPBEmpty', 'decode'],
$metadata, $options);
} | php | {
"resource": ""
} |
q15018 | NotificationChannelServiceGrpcClient.VerifyNotificationChannel | train | public function VerifyNotificationChannel(\Google\Cloud\Monitoring\V3\VerifyNotificationChannelRequest $argument,
$metadata = [], $options = []) {
return $this->_simpleRequest('/google.monitoring.v3.NotificationChannelService/VerifyNotificationChannel',
$argument,
['\Google\Cloud\Monitoring\V3\NotificationChannel', 'decode'],
$metadata, $options);
} | php | {
"resource": ""
} |
q15019 | RawIndices.setIndices | train | public function setIndices($var)
{
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::INT32);
$this->indices = $arr;
return $this;
} | php | {
"resource": ""
} |
q15020 | WorkflowTemplateServiceGapicClient.workflowTemplateName | train | public static function workflowTemplateName($project, $region, $workflowTemplate)
{
return self::getWorkflowTemplateNameTemplate()->render([
'project' => $project,
'region' => $region,
'workflow_template' => $workflowTemplate,
]);
} | php | {
"resource": ""
} |
q15021 | ListAlertPoliciesResponse.setAlertPolicies | train | public function setAlertPolicies($var)
{
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Monitoring\V3\AlertPolicy::class);
$this->alert_policies = $arr;
return $this;
} | php | {
"resource": ""
} |
q15022 | Patent.setInventors | train | public function setInventors($var)
{
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING);
$this->inventors = $arr;
return $this;
} | php | {
"resource": ""
} |
q15023 | Patent.setSkillsUsed | train | public function setSkillsUsed($var)
{
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Talent\V4beta1\Skill::class);
$this->skills_used = $arr;
return $this;
} | php | {
"resource": ""
} |
q15024 | ListProductsResponse.setProducts | train | public function setProducts($var)
{
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Vision\V1\Product::class);
$this->products = $arr;
return $this;
} | php | {
"resource": ""
} |
q15025 | ProductSearchResults.setResults | train | public function setResults($var)
{
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Vision\V1\ProductSearchResults\Result::class);
$this->results = $arr;
return $this;
} | php | {
"resource": ""
} |
q15026 | ProductSearchResults.setProductGroupedResults | train | public function setProductGroupedResults($var)
{
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Vision\V1\ProductSearchResults\GroupedResult::class);
$this->product_grouped_results = $arr;
return $this;
} | php | {
"resource": ""
} |
q15027 | ItemIteratorTrait.current | train | public function current()
{
$page = $this->pageIterator->current();
return isset($page[$this->pageIndex])
? $page[$this->pageIndex]
: null;
} | php | {
"resource": ""
} |
q15028 | ItemIteratorTrait.next | train | public function next()
{
$this->pageIndex++;
$this->position++;
if (count($this->pageIterator->current()) <= $this->pageIndex && $this->nextResultToken()) {
$this->pageIterator->next();
$this->pageIndex = 0;
}
} | php | {
"resource": ""
} |
q15029 | ItemIteratorTrait.valid | train | public function valid()
{
$page = $this->pageIterator->current();
if (isset($page[$this->pageIndex])) {
return true;
}
// If there are no results, but a token for the next page
// exists let's continue paging until there are results.
while ($this->nextResultToken()) {
$this->pageIterator->next();
$page = $this->pageIterator->current();
if (isset($page[$this->pageIndex])) {
return true;
}
}
return false;
} | php | {
"resource": ""
} |
q15030 | SparkSqlJob.setQueryList | train | public function setQueryList($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\Dataproc\V1beta2\QueryList::class);
$this->writeOneof(2, $var);
return $this;
} | php | {
"resource": ""
} |
q15031 | SparkSqlJob.setProperties | train | public function setProperties($var)
{
$arr = GPBUtil::checkMapField($var, \Google\Protobuf\Internal\GPBType::STRING, \Google\Protobuf\Internal\GPBType::STRING);
$this->properties = $arr;
return $this;
} | php | {
"resource": ""
} |
q15032 | SparkSqlJob.setJarFileUris | train | public function setJarFileUris($var)
{
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING);
$this->jar_file_uris = $arr;
return $this;
} | php | {
"resource": ""
} |
q15033 | SparkSqlJob.setLoggingConfig | train | public function setLoggingConfig($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\Dataproc\V1beta2\LoggingConfig::class);
$this->logging_config = $var;
return $this;
} | php | {
"resource": ""
} |
q15034 | BatchDeleteEntityTypesRequest.setEntityTypeNames | train | public function setEntityTypeNames($var)
{
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING);
$this->entity_type_names = $arr;
return $this;
} | php | {
"resource": ""
} |
q15035 | ModelEvaluation.setClassificationEvaluationMetrics | train | public function setClassificationEvaluationMetrics($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\AutoMl\V1beta1\ClassificationEvaluationMetrics::class);
$this->writeOneof(8, $var);
return $this;
} | php | {
"resource": ""
} |
q15036 | ModelEvaluation.setTranslationEvaluationMetrics | train | public function setTranslationEvaluationMetrics($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\AutoMl\V1beta1\TranslationEvaluationMetrics::class);
$this->writeOneof(9, $var);
return $this;
} | php | {
"resource": ""
} |
q15037 | ReleaseBuilder.updateComponentVersions | train | private function updateComponentVersions(array $release)
{
foreach ($release as $key => $releaseComponent)
{
$component = $this->getComponentComposer($this->rootPath(), $key);
$this->addToComponentManifest($releaseComponent['version'], $component);
foreach ((array) $component['entry'] as $entry) {
$entryUpdated = $this->updateComponentVersionConstant(
$releaseComponent['version'],
$component['path'],
$entry
);
}
if ($component['id'] !== 'google-cloud') {
$this->updateComponentVersionFile($releaseComponent['version'], $component);
$this->updateComposerReplacesVersion($releaseComponent['version'], $component);
}
}
} | php | {
"resource": ""
} |
q15038 | ReleaseBuilder.determineUmbrellaLevel | train | private function determineUmbrellaLevel(array $release)
{
$levels = [];
array_walk($release, function ($component) use (&$levels) {
$levels[] = $component['level'];
});
$levels = array_unique($levels);
rsort($levels);
// Since we don't use major versions of the umbrella, major versions of
// components only bump the umbrella by a minor increment.
if ($levels[0] === self::LEVEL_MAJOR) {
$levels[0] = self::LEVEL_MINOR;
}
$release[self::DEFAULT_COMPONENT] = [
'level' => $levels[0]
];
return $release;
} | php | {
"resource": ""
} |
q15039 | ReleaseBuilder.createReleaseNotes | train | private function createReleaseNotes(array $release)
{
$buildDir = $this->rootPath .'/build';
$locationTemplate = $buildDir . '/release-%s.md';
if (!is_dir($buildDir)) {
mkdir($buildDir);
}
$umbrella = $release[self::DEFAULT_COMPONENT];
$location = sprintf($locationTemplate, $umbrella['version']);
unset($release[self::DEFAULT_COMPONENT]);
ksort($release);
$notes = [];
foreach ($release as $key => $component) {
$messages = [];
foreach ($component['messages'] as $message) {
$messages[] = sprintf('* %s', $message);
}
$notes[] = sprintf('### google/%s v%s', $key, $component['version'])
. PHP_EOL . PHP_EOL . implode(PHP_EOL, $messages);
}
$template = file_get_contents(__DIR__ .'/templates/release-notes.md.txt');
$template = str_replace('{version}', $umbrella['version'], $template);
$template = str_replace('{notes}', implode(PHP_EOL . PHP_EOL, $notes), $template);
file_put_contents($location, $template);
return $location;
} | php | {
"resource": ""
} |
q15040 | ReleaseBuilder.mergeCommitIntoRelease | train | private function mergeCommitIntoRelease(array $release, array $commitRelease)
{
foreach ($commitRelease as $key => $commit) {
if (!isset($release[$key])) {
$release[$key] = [
'level' => $commit['level'],
'messages' => [$commit['message']]
];
} else {
$release[$key]['messages'][] = $commit['message'];
$release[$key]['level'] = ($release[$key]['level'] >= $commit['level'])
? $release[$key]['level']
: $commit['level'];
}
}
return $release;
} | php | {
"resource": ""
} |
q15041 | ReleaseBuilder.interactiveCommitRelease | train | private function interactiveCommitRelease(OutputInterface $output, array $commit, array $components)
{
$commitRelease = $this->processCommit($output, $commit, $components);
$proceed = false;
do {
$this->displayCommitSummary($output, $commitRelease);
$output->writeln('');
$choices = [
'Proceed without changes',
'Change Release Message',
'Change Release Type to Patch',
'Change Release Type to Minor',
'Change Release Type to Major',
'Start over'
];
$q = $this->choice('Choose an action', $choices, $choices[0]);
$action = $this->askQuestion($q);
$action = $this->removeDefaultFromChoice($action);
switch ($action) {
case $choices[0]:
$proceed = true;
break;
case $choices[1]:
$commitRelease = $this->handleChange($output, $commitRelease);
break;
case $choices[2]: // patch
$commitRelease = $this->handleChange($output, $commitRelease, self::LEVEL_PATCH);
break;
case $choices[3]: // minor
$commitRelease = $this->handleChange($output, $commitRelease, self::LEVEL_MINOR);
break;
case $choices[4]: // major
$commitRelease = $this->handleChange($output, $commitRelease, self::LEVEL_MAJOR);
break;
case $choices[5]:
$commitRelease = $this->processCommit($output, $commit, $components);
break;
}
} while (!$proceed);
$output->writeln('');
return $commitRelease;
} | php | {
"resource": ""
} |
q15042 | ReleaseBuilder.handleChange | train | public function handleChange(OutputInterface $output, array $commitRelease, $level = null)
{
$choices = array_keys($commitRelease);
if (count($choices) > 1) {
$options = array_merge([
'All Components'
], $choices, [
'Go Back'
]);
// By default, all components are batch modified in this method.
$q = $this->choice('Choose a component to modify.', $options, $options[0]);
$component = $this->removeDefaultFromChoice($this->askQuestion($q));
if ($component === 'Go Back') {
return $commitRelease;
}
if ($component === 'All Components') {
$component = null;
}
} else {
$component = $choices[0];
}
if ($level === null) {
if ($component) {
$componentOverview = sprintf(
'<info>google/%s</info> [<info>%s</info>]:',
$component,
$this->levels[$commitRelease[$component]['level']]
);
$currentMessage = $commitRelease[$component]['message'];
} else {
$componentOverview = sprintf(
'Modifying <info>%s</info> components.',
count($commitRelease)
);
$currentMessage = current($commitRelease)['message'];
}
$key = 'message';
$value = $this->ask(sprintf(
'%s Enter a release note message. Do not enter the Pull Request reference number.'.
PHP_EOL .' - Message: <info>%s</info>',
$componentOverview,
$currentMessage
), $currentMessage);
$value .= ' (#'. current($commitRelease)['ref'] .')';
} elseif (array_key_exists($level, $this->levels)) {
$key = 'level';
$value = $level;
} else {
throw new \Exception('Something went really wrong.');
}
if ($component) {
$commitRelease[$component][$key] = $value;
} else {
foreach ($commitRelease as &$commitComponent) {
$commitComponent[$key] = $value;
}
}
return $commitRelease;
} | php | {
"resource": ""
} |
q15043 | ReleaseBuilder.processCommit | train | private function processCommit(OutputInterface $output, array $commit, array $components)
{
$output->writeln(sprintf(
'Processing Commit: <info>%s</info>',
$commit['message']
));
$output->writeln(sprintf('View on GitHub: %s', $commit['htmlUrl']));
$output->writeln('----------');
$output->writeln('');
$message = trim($this->ask('Enter a release summary for this commit. You can change this later.', $commit['message']));
$commitRelease = [];
foreach ($components as $key => $component) {
$componentRelease = isset($commitRelease[$key])
? $commitRelease[$key]
: ['level' => self::LEVEL_PATCH, 'message' => '', 'reasons' => []];
$lowestAllowedLevel = $componentRelease['level'];
$suggestedLevel = $lowestAllowedLevel;
$allowedLevels = array_filter($this->levels, function ($name, $key) use ($lowestAllowedLevel) {
return $key >= $lowestAllowedLevel;
}, ARRAY_FILTER_USE_BOTH);
$output->writeln(sprintf('Component <comment>%s</comment> modified by commit.', $key));
list ($suggestedLevel, $reasons) =
$this->determineSuggestedLevel($allowedLevels, $suggestedLevel, $component['files']);
$output->writeln(sprintf(
'We suggest a <info>%s</info> release because of the following reasons. Please do not use this as an ' .
'absolute guide, as this tool is unable to determine the correct outcome in every scenario.',
$this->levels[$suggestedLevel]
));
$output->writeln('');
foreach ($reasons as $reason) {
$output->writeln('* '. $reason);
}
$output->writeln('');
$componentRelease['level'] = $suggestedLevel;
$componentRelease['message'] = $message .' (#'. $commit['reference'] .')';
$componentRelease['reasons'] = array_merge($componentRelease['reasons'], $reasons);
$componentRelease['ref'] = $commit['reference'];
$commitRelease[$key] = $componentRelease;
}
return $commitRelease;
} | php | {
"resource": ""
} |
q15044 | ReleaseBuilder.displayCommitSummary | train | private function displayCommitSummary(OutputInterface $output, array $commitRelease)
{
$output->writeln('Commit Summary');
$output->writeln('-----');
foreach ($commitRelease as $key => $releaseInfo) {
$output->writeln(sprintf('<info>google/%s</info> [<info>%s</info>]', $key, $this->levels[$releaseInfo['level']]));
$output->writeln(sprintf(' - Message: <info>%s</info>', $releaseInfo['message']));
}
} | php | {
"resource": ""
} |
q15045 | ReleaseBuilder.determineSuggestedLevel | train | private function determineSuggestedLevel(array $levelChoices, $suggestedLevel, array $files)
{
$reasons = [];
if ($levelChoices !== $this->levels) {
$suggestedLevel = array_keys($levelChoices)[0];
$reasons[] = 'Another change specified a higher minimum release level.';
}
if (isset($levelChoices[self::LEVEL_MINOR]) && (bool) array_filter($files, function ($file) {
$parts = explode('/', $file);
return isset($parts[1]) && $parts[1] === 'src' && count($parts) > 2;
})) {
$suggestedLevel = self::LEVEL_MINOR;
$reasons[] = 'There are changes in the component `src` folder.';
}
if (isset($levelChoices[self::LEVEL_MINOR]) && in_array('composer.json', $files)) {
$suggestedLevel = self::LEVEL_MINOR;
$reasons[] = 'The component `composer.json` file was modified.';
}
if ($suggestedLevel === self::LEVEL_PATCH) {
$reasons[] = 'None of the indicators show the commit includes a client-facing code change.';
}
return [$suggestedLevel, $reasons];
} | php | {
"resource": ""
} |
q15046 | ReleaseBuilder.getOrgAndRepo | train | private function getOrgAndRepo(array $composer)
{
$target = $composer['target'];
$matches = [];
preg_match(self::TARGET_REGEX, $target, $matches);
$org = $matches[1];
$repo = $matches[2];
return [$org, $repo];
} | php | {
"resource": ""
} |
q15047 | ReleaseBuilder.hasExpectedBase | train | private function hasExpectedBase($org, $repo, $version)
{
$url = sprintf(
self::GITHUB_RELEASES_ENDPOINT,
$org,
$repo,
$version
);
try {
$res = $this->http->get($url, [
'auth' => [null, $this->token]
]);
return true;
} catch (RequestException $e) {
return false;
}
} | php | {
"resource": ""
} |
q15048 | ReleaseBuilder.getCommits | train | private function getCommits($org, $repo, $version)
{
$url = sprintf(
self::GITHUB_COMPARE_ENDPOINT,
$org,
$repo,
$version
);
$res = json_decode($this->http->get($url, [
'auth' => [null, $this->token]
])->getBody(), true);
$commits = [];
foreach ($res['commits'] as $commit) {
$message = $commit['commit']['message'];
$description = explode("\n", $message)[0];
$matches = [];
if (preg_match('/(.{0,})\(\#(\d{1,})\)/', $description, $matches) === 1) {
$message = trim($matches[1]);
$prNumber = isset($matches[2]) ? $matches[2] : null;
} else {
$prNumber = $this->askForPrNumber($message);
}
if (strpos($message, '[CHANGE ME]') === 0 && $prNumber) {
$message = $this->getMessageFromPullRequest($org, $repo, $prNumber);
}
$commits[] = [
'url' => $commit['url'],
'htmlUrl' => $commit['html_url'],
'message' => $message,
'reference' => $prNumber,
'hash' => $commit['sha']
];
}
return $commits;
} | php | {
"resource": ""
} |
q15049 | ReleaseBuilder.getCommitComponentModifiedList | train | private function getCommitComponentModifiedList($url)
{
$commit = json_decode($this->http->get($url, [
'auth' => [null, $this->token]
])->getBody(), true);
$changedComponents = [];
$fileDirectoryComponent = [];
foreach ($commit['files'] as $file) {
$filename = $file['filename'];
if (strpos($filename, '/') === false) {
continue;
}
$fileParts = explode('/', $filename);
$componentDirectory = $fileParts[0];
$composerPath = $this->rootPath .'/'. $componentDirectory .'/composer.json';
if (!array_key_exists($composerPath, $fileDirectoryComponent)) {
if (!file_exists($composerPath)) {
continue;
}
$composer = json_decode(file_get_contents($composerPath), true)['extra']['component'];
$fileDirectoryComponent[$composerPath] = $composer;
} else {
$composer = $fileDirectoryComponent[$composerPath];
}
if (!isset($changedComponents[$composer['id']])) {
$changedComponents[$composer['id']] = [
'files' => [],
'level' => 'minor'
];
}
$changedComponents[$composer['id']]['files'][] = $file['filename'];
}
return $changedComponents;
} | php | {
"resource": ""
} |
q15050 | SpannerClient.batch | train | public function batch($instanceId, $databaseId)
{
$operation = new Operation(
$this->connection,
$this->returnInt64AsObject
);
return new BatchClient(
$operation,
GapicSpannerClient::databaseName(
$this->projectId,
$instanceId,
$databaseId
)
);
} | php | {
"resource": ""
} |
q15051 | SpannerClient.instanceConfigurations | train | public function instanceConfigurations(array $options = [])
{
$resultLimit = $this->pluck('resultLimit', $options, false) ?: 0;
return new ItemIterator(
new PageIterator(
function (array $config) {
return $this->instanceConfiguration($config['name'], $config);
},
[$this->connection, 'listInstanceConfigs'],
['projectId' => InstanceAdminClient::projectName($this->projectId)] + $options,
[
'itemsKey' => 'instanceConfigs',
'resultLimit' => $resultLimit
]
)
);
} | php | {
"resource": ""
} |
q15052 | SpannerClient.instanceConfiguration | train | public function instanceConfiguration($name, array $config = [])
{
return new InstanceConfiguration($this->connection, $this->projectId, $name, $config);
} | php | {
"resource": ""
} |
q15053 | SpannerClient.instance | train | public function instance($name, array $instance = [])
{
return new Instance(
$this->connection,
$this->lroConnection,
$this->lroCallables,
$this->projectId,
$name,
$this->returnInt64AsObject,
$instance
);
} | php | {
"resource": ""
} |
q15054 | SpannerClient.instances | train | public function instances(array $options = [])
{
$options += [
'filter' => null
];
$resultLimit = $this->pluck('resultLimit', $options, false);
return new ItemIterator(
new PageIterator(
function (array $instance) {
$name = InstanceAdminClient::parseName($instance['name'])['instance'];
return $this->instance($name, $instance);
},
[$this->connection, 'listInstances'],
['projectId' => InstanceAdminClient::projectName($this->projectId)] + $options,
[
'itemsKey' => 'instances',
'resultLimit' => $resultLimit
]
)
);
} | php | {
"resource": ""
} |
q15055 | SpannerClient.connect | train | public function connect($instance, $name, array $options = [])
{
if (is_string($instance)) {
$instance = $this->instance($instance);
}
$database = $instance->database($name, $options);
return $database;
} | php | {
"resource": ""
} |
q15056 | Aggregation.setPerSeriesAligner | train | public function setPerSeriesAligner($var)
{
GPBUtil::checkEnum($var, \Google\Cloud\Monitoring\V3\Aggregation_Aligner::class);
$this->per_series_aligner = $var;
return $this;
} | php | {
"resource": ""
} |
q15057 | Aggregation.setCrossSeriesReducer | train | public function setCrossSeriesReducer($var)
{
GPBUtil::checkEnum($var, \Google\Cloud\Monitoring\V3\Aggregation_Reducer::class);
$this->cross_series_reducer = $var;
return $this;
} | php | {
"resource": ""
} |
q15058 | Aggregation.setGroupByFields | train | public function setGroupByFields($var)
{
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING);
$this->group_by_fields = $arr;
return $this;
} | php | {
"resource": ""
} |
q15059 | ResumableUploader.resume | train | public function resume($resumeUri)
{
if (!$this->data->isSeekable()) {
throw new GoogleException('Cannot resume upload on a stream which cannot be seeked.');
}
$this->resumeUri = $resumeUri;
$response = $this->getStatusResponse();
if ($response->getBody()->getSize() > 0) {
return $this->decodeResponse($response);
}
$this->rangeStart = $this->getRangeStart($response->getHeaderLine('Range'));
return $this->upload();
} | php | {
"resource": ""
} |
q15060 | ResumableUploader.getStatusResponse | train | protected function getStatusResponse()
{
$request = new Request(
'PUT',
$this->resumeUri,
['Content-Range' => 'bytes */*']
);
return $this->requestWrapper->send($request, $this->requestOptions);
} | php | {
"resource": ""
} |
q15061 | MaintenancePolicy.setWindow | train | public function setWindow($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\Container\V1\MaintenanceWindow::class);
$this->window = $var;
return $this;
} | php | {
"resource": ""
} |
q15062 | PredictRequest.setPayload | train | public function setPayload($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\AutoMl\V1beta1\ExamplePayload::class);
$this->payload = $var;
return $this;
} | php | {
"resource": ""
} |
q15063 | ListDocumentsResponse.setDocuments | train | public function setDocuments($var)
{
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Firestore\V1\Document::class);
$this->documents = $arr;
return $this;
} | php | {
"resource": ""
} |
q15064 | Grpc.getInstanceAdminClient | train | private function getInstanceAdminClient()
{
//@codeCoverageIgnoreStart
if ($this->instanceAdminClient) {
return $this->instanceAdminClient;
}
//@codeCoverageIgnoreEnd
$this->instanceAdminClient = new InstanceAdminClient($this->grpcConfig);
return $this->instanceAdminClient;
} | php | {
"resource": ""
} |
q15065 | Grpc.getDatabaseAdminClient | train | private function getDatabaseAdminClient()
{
//@codeCoverageIgnoreStart
if ($this->databaseAdminClient) {
return $this->databaseAdminClient;
}
//@codeCoverageIgnoreEnd
$this->databaseAdminClient = new DatabaseAdminClient($this->grpcConfig);
return $this->databaseAdminClient;
} | php | {
"resource": ""
} |
q15066 | AppEngineFlexFormatter.format | train | public function format(array $record)
{
$message = parent::format($record);
list($usec, $sec) = explode(" ", microtime());
$usec = (int)(((float)$usec)*1000000000);
$sec = (int)$sec;
$payload = [
'message' => $message,
'timestamp'=> ['seconds' => $sec,
'nanos' => $usec],
'thread' => '',
'severity' => $record['level_name'],
];
if (isset($_SERVER['HTTP_X_CLOUD_TRACE_CONTEXT'])) {
$payload['traceId'] = explode(
"/",
$_SERVER['HTTP_X_CLOUD_TRACE_CONTEXT']
)[0];
}
return "\n" . json_encode($payload);
} | php | {
"resource": ""
} |
q15067 | HadoopJob.setArgs | train | public function setArgs($var)
{
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING);
$this->args = $arr;
return $this;
} | php | {
"resource": ""
} |
q15068 | Condition.setConditionThreshold | train | public function setConditionThreshold($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\Monitoring\V3\AlertPolicy_Condition_MetricThreshold::class);
$this->writeOneof(1, $var);
return $this;
} | php | {
"resource": ""
} |
q15069 | Condition.setConditionAbsent | train | public function setConditionAbsent($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\Monitoring\V3\AlertPolicy_Condition_MetricAbsence::class);
$this->writeOneof(2, $var);
return $this;
} | php | {
"resource": ""
} |
q15070 | Iam.setPolicy | train | public function setPolicy($policy, array $options = [])
{
if ($policy instanceof PolicyBuilder) {
$policy = $policy->result();
}
if (!is_array($policy)) {
throw new \InvalidArgumentException('Given policy data must be an array or an instance of PolicyBuilder.');
}
$request = [];
if ($this->options['parent']) {
$parent = $this->options['parent'];
$request[$parent] = $policy;
} else {
$request = $policy;
}
return $this->policy = $this->connection->setPolicy([
'resource' => $this->resource
] + $request + $options + $this->options['args']);
} | php | {
"resource": ""
} |
q15071 | Iam.reload | train | public function reload(array $options = [])
{
return $this->policy = $this->connection->getPolicy([
'resource' => $this->resource
] + $options + $this->options['args']);
} | php | {
"resource": ""
} |
q15072 | WorkflowTemplate.setJobs | train | public function setJobs($var)
{
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Dataproc\V1\OrderedJob::class);
$this->jobs = $arr;
return $this;
} | php | {
"resource": ""
} |
q15073 | WorkflowTemplate.setParameters | train | public function setParameters($var)
{
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Dataproc\V1\TemplateParameter::class);
$this->parameters = $arr;
return $this;
} | php | {
"resource": ""
} |
q15074 | RunQueryRequest.setPartitionId | train | public function setPartitionId($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\Datastore\V1\PartitionId::class);
$this->partition_id = $var;
return $this;
} | php | {
"resource": ""
} |
q15075 | RunQueryRequest.setReadOptions | train | public function setReadOptions($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\Datastore\V1\ReadOptions::class);
$this->read_options = $var;
return $this;
} | php | {
"resource": ""
} |
q15076 | RunQueryRequest.setQuery | train | public function setQuery($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\Datastore\V1\Query::class);
$this->writeOneof(3, $var);
return $this;
} | php | {
"resource": ""
} |
q15077 | RunQueryRequest.setGqlQuery | train | public function setGqlQuery($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\Datastore\V1\GqlQuery::class);
$this->writeOneof(7, $var);
return $this;
} | php | {
"resource": ""
} |
q15078 | PublishRequest.setMessages | train | public function setMessages($var)
{
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\PubSub\V1\PubsubMessage::class);
$this->messages = $arr;
return $this;
} | php | {
"resource": ""
} |
q15079 | GetComponentsTrait.getComponentManifest | train | private function getComponentManifest($manifestPath, $componentId)
{
$manifest = $this->getManifest($manifestPath);
$index = $this->getManifestComponentModuleIndex($manifest, $componentId);
return $manifest['modules'][$index];
} | php | {
"resource": ""
} |
q15080 | GetComponentsTrait.getManifestComponentModuleIndex | train | private function getManifestComponentModuleIndex($manifest, $componentId)
{
$manifest = is_array($manifest)
? $manifest
: $this->getManifest($manifest);
$modules = array_filter($manifest['modules'], function ($module) use ($componentId) {
return ($module['id'] === $componentId);
});
return array_keys($modules)[0];
} | php | {
"resource": ""
} |
q15081 | GetComponentsTrait.getManifest | train | private function getManifest($manifestPath)
{
if (self::$__manifest) {
$manifest = self::$__manifest;
} else {
$manifest = json_decode(file_get_contents($manifestPath), true);
if (json_last_error() !== JSON_ERROR_NONE) {
throw new \RuntimeException('Could not decode manifest json');
}
self::$__manifest = $manifest;
}
return $manifest;
} | php | {
"resource": ""
} |
q15082 | GetComponentsTrait.getComponentComposer | train | private function getComponentComposer($libraryRootPath, $componentId, $defaultComposerPath = null)
{
if (!$defaultComposerPath) {
$defaultComposerPath = isset($this->defaultComponentComposer)
? $this->defaultComponentComposer
: null;
}
$componentsDir = isset($this->components)
? $this->components
: $libraryRootPath;
$components = $this->getComponents($libraryRootPath, $componentsDir, $defaultComposerPath);
$components = array_values(array_filter($components, function ($component) use ($componentId) {
return ($component['id'] === $componentId);
}));
if (count($components) === 0) {
throw new \InvalidArgumentException(sprintf(
'Given component id %s is not a valid component.',
$componentId
));
}
return $components[0];
} | php | {
"resource": ""
} |
q15083 | ImageProperties.setDominantColors | train | public function setDominantColors($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\Vision\V1\DominantColorsAnnotation::class);
$this->dominant_colors = $var;
return $this;
} | php | {
"resource": ""
} |
q15084 | ComponentManager.componentsExtra | train | public function componentsExtra($componentId = null)
{
$components = $this->components ?: $this->loadComponents();
array_walk($components, function (&$component) {
$name = $component['composer']['name'];
$component = $component['composer']['extra']['component'];
$component['displayName'] = $name;
});
return $componentId
? [$componentId => $components[$componentId]]
: $components;
} | php | {
"resource": ""
} |
q15085 | ComponentManager.componentsManifest | train | public function componentsManifest($componentId = null)
{
$manifest = $this->manifest ?: $this->loadManifest;
$modules = $manifest['modules'];
if ($componentId) {
$modules = array_filter($modules, function ($module) use ($componentId) {
return $module['id'] === $componentId;
});
}
return $modules;
} | php | {
"resource": ""
} |
q15086 | ComponentManager.componentsVersion | train | public function componentsVersion($componentId = null)
{
$components = $this->components ?: $this->loadComponents();
array_walk($components, function (&$component) {
$component = $component['version'];
});
return $componentId
? [$componentId => $components[$componentId]]
: $components;
} | php | {
"resource": ""
} |
q15087 | Mutations.deleteFromFamily | train | public function deleteFromFamily($family)
{
$this->mutations[] = (new Mutation)
->setDeleteFromFamily(
(new DeleteFromFamily)->setFamilyName($family)
);
return $this;
} | php | {
"resource": ""
} |
q15088 | Mutations.deleteFromColumn | train | public function deleteFromColumn($family, $qualifier, array $timeRange = [])
{
$deleteFromColumn = (new DeleteFromColumn)
->setFamilyName($family)
->setColumnQualifier($qualifier);
if (!empty($timeRange)) {
$timestampRange = new TimestampRange;
if (isset($timeRange['start'])) {
$timestampRange->setStartTimestampMicros($timeRange['start']);
}
if (isset($timeRange['end'])) {
$timestampRange->setEndTimestampMicros($timeRange['end']);
}
$deleteFromColumn->setTimeRange($timestampRange);
}
$this->mutations[] = (new Mutation)->setDeleteFromColumn($deleteFromColumn);
return $this;
} | php | {
"resource": ""
} |
q15089 | DatastoreOptions.setPartitionId | train | public function setPartitionId($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\Dlp\V2\PartitionId::class);
$this->partition_id = $var;
return $this;
} | php | {
"resource": ""
} |
q15090 | DatastoreOptions.setKind | train | public function setKind($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\Dlp\V2\KindExpression::class);
$this->kind = $var;
return $this;
} | php | {
"resource": ""
} |
q15091 | StorageObject.exists | train | public function exists(array $options = [])
{
try {
$this->connection->getObject($this->identity + $options + ['fields' => 'name']);
} catch (NotFoundException $ex) {
return false;
}
return true;
} | php | {
"resource": ""
} |
q15092 | StorageObject.update | train | public function update(array $metadata, array $options = [])
{
$options += $metadata;
// can only set predefinedAcl or acl
if (isset($options['predefinedAcl'])) {
$options['acl'] = null;
}
return $this->info = $this->connection->patchObject($options + array_filter($this->identity));
} | php | {
"resource": ""
} |
q15093 | StorageObject.copy | train | public function copy($destination, array $options = [])
{
$key = isset($options['encryptionKey']) ? $options['encryptionKey'] : null;
$keySHA256 = isset($options['encryptionKeySHA256']) ? $options['encryptionKeySHA256'] : null;
$response = $this->connection->copyObject(
$this->formatDestinationRequest($destination, $options)
);
return new StorageObject(
$this->connection,
$response['name'],
$response['bucket'],
$response['generation'],
$response + ['requesterProjectId' => $this->identity['userProject']],
$key,
$keySHA256
);
} | php | {
"resource": ""
} |
q15094 | StorageObject.rewrite | train | public function rewrite($destination, array $options = [])
{
$options['useCopySourceHeaders'] = true;
$destinationKey = isset($options['destinationEncryptionKey']) ? $options['destinationEncryptionKey'] : null;
$destinationKeySHA256 = isset($options['destinationEncryptionKeySHA256'])
? $options['destinationEncryptionKeySHA256']
: null;
$options = $this->formatDestinationRequest($destination, $options);
do {
$response = $this->connection->rewriteObject($options);
$options['rewriteToken'] = isset($response['rewriteToken']) ? $response['rewriteToken'] : null;
} while ($options['rewriteToken']);
return new StorageObject(
$this->connection,
$response['resource']['name'],
$response['resource']['bucket'],
$response['resource']['generation'],
$response['resource'] + ['requesterProjectId' => $this->identity['userProject']],
$destinationKey,
$destinationKeySHA256
);
} | php | {
"resource": ""
} |
q15095 | StorageObject.rename | train | public function rename($name, array $options = [])
{
$destinationBucket = isset($options['destinationBucket'])
? $options['destinationBucket']
: $this->identity['bucket'];
unset($options['destinationBucket']);
$copiedObject = $this->copy($destinationBucket, [
'name' => $name
] + $options);
$this->delete(
array_intersect_key($options, [
'restOptions' => null,
'retries' => null
])
);
$this->info = [];
return $copiedObject;
} | php | {
"resource": ""
} |
q15096 | StorageObject.downloadToFile | train | public function downloadToFile($path, array $options = [])
{
$destination = Psr7\stream_for(fopen($path, 'w'));
Psr7\copy_to_stream(
$this->downloadAsStream($options),
$destination
);
$destination->seek(0);
return $destination;
} | php | {
"resource": ""
} |
q15097 | StorageObject.downloadAsStream | train | public function downloadAsStream(array $options = [])
{
return $this->connection->downloadObject(
$this->formatEncryptionHeaders(
$options
+ $this->encryptionData
+ array_filter($this->identity)
)
);
} | php | {
"resource": ""
} |
q15098 | StorageObject.downloadAsStreamAsync | train | public function downloadAsStreamAsync(array $options = [])
{
return $this->connection->downloadObjectAsync(
$this->formatEncryptionHeaders(
$options
+ $this->encryptionData
+ array_filter($this->identity)
)
);
} | php | {
"resource": ""
} |
q15099 | StorageObject.signedUploadUrl | train | public function signedUploadUrl($expires, array $options = [])
{
$options += [
'headers' => []
];
$options['headers']['x-goog-resumable'] = 'start';
unset(
$options['cname'],
$options['saveAsName'],
$options['responseDisposition'],
$options['responseType']
);
return $this->signedUrl($expires, [
'method' => 'POST',
'allowPost' => true
] + $options);
} | php | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.