_id stringlengths 2 7 | title stringlengths 3 151 | partition stringclasses 3
values | text stringlengths 83 13k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q15100 | StorageObject.beginSignedUploadSession | train | public function beginSignedUploadSession(array $options = [])
{
$expires = new \DateTimeImmutable('+1 minute');
$startUri = $this->signedUploadUrl($expires, $options);
$uploaderOptions = $this->pluckArray([
'contentType',
'origin'
], $options);
if (!isset($uploaderOptions['origin'])) {
$uploaderOptions['origin'] = '*';
}
$uploader = new SignedUrlUploader($this->connection->requestWrapper(), '', $startUri, $uploaderOptions);
return $uploader->getResumeUri();
} | php | {
"resource": ""
} |
q15101 | StorageObject.reload | train | public function reload(array $options = [])
{
return $this->info = $this->connection->getObject(
$this->formatEncryptionHeaders(
$options
+ $this->encryptionData
+ array_filter($this->identity)
)
);
} | php | {
"resource": ""
} |
q15102 | StorageObject.formatDestinationRequest | train | private function formatDestinationRequest($destination, array $options)
{
if (!is_string($destination) && !($destination instanceof Bucket)) {
throw new \InvalidArgumentException(
'$destination must be either a string or an instance of Bucket.'
);
}
$destAcl = isset($options['predefinedAcl']) ? $options['predefinedAcl'] : null;
$destObject = isset($options['name']) ? $options['name'] : $this->identity['object'];
unset($options['name']);
unset($options['predefinedAcl']);
return array_filter([
'destinationBucket' => $destination instanceof Bucket ? $destination->name() : $destination,
'destinationObject' => $destObject,
'destinationPredefinedAcl' => $destAcl,
'sourceBucket' => $this->identity['bucket'],
'sourceObject' => $this->identity['object'],
'sourceGeneration' => $this->identity['generation'],
'userProject' => $this->identity['userProject'],
]) + $this->formatEncryptionHeaders($options + $this->encryptionData);
} | php | {
"resource": ""
} |
q15103 | JobTrigger.setTriggers | train | public function setTriggers($var)
{
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Dlp\V2\JobTrigger\Trigger::class);
$this->triggers = $arr;
return $this;
} | php | {
"resource": ""
} |
q15104 | JobTrigger.setErrors | train | public function setErrors($var)
{
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Dlp\V2\Error::class);
$this->errors = $arr;
return $this;
} | php | {
"resource": ""
} |
q15105 | AssetServiceGrpcClient.BatchGetAssetsHistory | train | public function BatchGetAssetsHistory(\Google\Cloud\Asset\V1\BatchGetAssetsHistoryRequest $argument,
$metadata = [], $options = []) {
return $this->_simpleRequest('/google.cloud.asset.v1.AssetService/BatchGetAssetsHistory',
$argument,
['\Google\Cloud\Asset\V1\BatchGetAssetsHistoryResponse', 'decode'],
$metadata, $options);
} | php | {
"resource": ""
} |
q15106 | StoredInfoTypeConfig.setLargeCustomDictionary | train | public function setLargeCustomDictionary($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\Dlp\V2\LargeCustomDictionaryConfig::class);
$this->writeOneof(3, $var);
return $this;
} | php | {
"resource": ""
} |
q15107 | InputConfig.setGcsSource | train | public function setGcsSource($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\AutoMl\V1beta1\GcsSource::class);
$this->writeOneof(1, $var);
return $this;
} | php | {
"resource": ""
} |
q15108 | JobStatus.setSubstate | train | public function setSubstate($var)
{
GPBUtil::checkEnum($var, \Google\Cloud\Dataproc\V1\JobStatus_Substate::class);
$this->substate = $var;
return $this;
} | php | {
"resource": ""
} |
q15109 | CreateEntityTypeRequest.setEntityType | train | public function setEntityType($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\Dialogflow\V2\EntityType::class);
$this->entity_type = $var;
return $this;
} | php | {
"resource": ""
} |
q15110 | ValueFrequency.setValue | train | public function setValue($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\Dlp\V2\Value::class);
$this->value = $var;
return $this;
} | php | {
"resource": ""
} |
q15111 | Location.setByteRange | train | public function setByteRange($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\Dlp\V2\Range::class);
$this->byte_range = $var;
return $this;
} | php | {
"resource": ""
} |
q15112 | Location.setCodepointRange | train | public function setCodepointRange($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\Dlp\V2\Range::class);
$this->codepoint_range = $var;
return $this;
} | php | {
"resource": ""
} |
q15113 | Location.setContentLocations | train | public function setContentLocations($var)
{
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Dlp\V2\ContentLocation::class);
$this->content_locations = $arr;
return $this;
} | php | {
"resource": ""
} |
q15114 | ListModelEvaluationsResponse.setModelEvaluation | train | public function setModelEvaluation($var)
{
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\AutoMl\V1beta1\ModelEvaluation::class);
$this->model_evaluation = $arr;
return $this;
} | php | {
"resource": ""
} |
q15115 | CreateTableRequest.setTable | train | public function setTable($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\Bigtable\Admin\V2\Table::class);
$this->table = $var;
return $this;
} | php | {
"resource": ""
} |
q15116 | SelectItemInfo.setSynonyms | train | public function setSynonyms($var)
{
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING);
$this->synonyms = $arr;
return $this;
} | php | {
"resource": ""
} |
q15117 | SafeSearchAnnotation.setAdult | train | public function setAdult($var)
{
GPBUtil::checkEnum($var, \Google\Cloud\Vision\V1\Likelihood::class);
$this->adult = $var;
return $this;
} | php | {
"resource": ""
} |
q15118 | SafeSearchAnnotation.setSpoof | train | public function setSpoof($var)
{
GPBUtil::checkEnum($var, \Google\Cloud\Vision\V1\Likelihood::class);
$this->spoof = $var;
return $this;
} | php | {
"resource": ""
} |
q15119 | SafeSearchAnnotation.setMedical | train | public function setMedical($var)
{
GPBUtil::checkEnum($var, \Google\Cloud\Vision\V1\Likelihood::class);
$this->medical = $var;
return $this;
} | php | {
"resource": ""
} |
q15120 | SafeSearchAnnotation.setViolence | train | public function setViolence($var)
{
GPBUtil::checkEnum($var, \Google\Cloud\Vision\V1\Likelihood::class);
$this->violence = $var;
return $this;
} | php | {
"resource": ""
} |
q15121 | SessionEntityTypesGapicClient.sessionEntityTypeName | train | public static function sessionEntityTypeName($project, $session, $entityType)
{
return self::getSessionEntityTypeNameTemplate()->render([
'project' => $project,
'session' => $session,
'entity_type' => $entityType,
]);
} | php | {
"resource": ""
} |
q15122 | SearchProfilesRequest.setRequestMetadata | train | public function setRequestMetadata($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\Talent\V4beta1\RequestMetadata::class);
$this->request_metadata = $var;
return $this;
} | php | {
"resource": ""
} |
q15123 | ListCryptoKeysRequest.setVersionView | train | public function setVersionView($var)
{
GPBUtil::checkEnum($var, \Google\Cloud\Kms\V1\CryptoKeyVersion_CryptoKeyVersionView::class);
$this->version_view = $var;
return $this;
} | php | {
"resource": ""
} |
q15124 | WorkflowMetadata.setDeleteCluster | train | public function setDeleteCluster($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\Dataproc\V1\ClusterOperation::class);
$this->delete_cluster = $var;
return $this;
} | php | {
"resource": ""
} |
q15125 | WorkflowMetadata.setState | train | public function setState($var)
{
GPBUtil::checkEnum($var, \Google\Cloud\Dataproc\V1\WorkflowMetadata_State::class);
$this->state = $var;
return $this;
} | php | {
"resource": ""
} |
q15126 | CommuteInfo.setJobLocation | train | public function setJobLocation($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\Talent\V4beta1\Location::class);
$this->job_location = $var;
return $this;
} | php | {
"resource": ""
} |
q15127 | LeaseTasksResponse.setTasks | train | public function setTasks($var)
{
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Tasks\V2beta2\Task::class);
$this->tasks = $arr;
return $this;
} | php | {
"resource": ""
} |
q15128 | MasterAuth.setClientCertificateConfig | train | public function setClientCertificateConfig($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\Container\V1\ClientCertificateConfig::class);
$this->client_certificate_config = $var;
return $this;
} | php | {
"resource": ""
} |
q15129 | QueryResults.rows | train | public function rows(array $options = [])
{
$options += $this->queryResultsOptions;
$this->waitUntilComplete($options);
$schema = $this->info['schema']['fields'];
return new ItemIterator(
new PageIterator(
function (array $row) use ($schema) {
$mergedRow = [];
if ($row === null) {
return $mergedRow;
}
if (!array_key_exists('f', $row)) {
throw new GoogleException('Bad response - missing key "f" for a row.');
}
foreach ($row['f'] as $key => $value) {
$fieldSchema = $schema[$key];
$mergedRow[$fieldSchema['name']] = $this->mapper->fromBigQuery($value, $fieldSchema);
}
return $mergedRow;
},
[$this->connection, 'getQueryResults'],
$options + $this->identity,
[
'itemsKey' => 'rows',
'firstPage' => $this->info,
'nextResultTokenKey' => 'pageToken'
]
)
);
} | php | {
"resource": ""
} |
q15130 | QueryResults.waitUntilComplete | train | public function waitUntilComplete(array $options = [])
{
$options += $this->queryResultsOptions;
$maxRetries = $this->pluck('maxRetries', $options, false);
$this->wait(
function () {
return $this->isComplete();
},
function () use ($options) {
return $this->reload($options);
},
$this->job,
$maxRetries
);
} | php | {
"resource": ""
} |
q15131 | QueryResults.reload | train | public function reload(array $options = [])
{
return $this->info = $this->connection->getQueryResults(
$options + $this->identity
);
} | php | {
"resource": ""
} |
q15132 | ListTablesResponse.setTables | train | public function setTables($var)
{
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Bigtable\Admin\V2\Table::class);
$this->tables = $arr;
return $this;
} | php | {
"resource": ""
} |
q15133 | AssetDiscoveryConfig.setProjectIds | train | public function setProjectIds($var)
{
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING);
$this->project_ids = $arr;
return $this;
} | php | {
"resource": ""
} |
q15134 | AssetDiscoveryConfig.setInclusionMode | train | public function setInclusionMode($var)
{
GPBUtil::checkEnum($var, \Google\Cloud\SecurityCenter\V1\OrganizationSettings_AssetDiscoveryConfig_InclusionMode::class);
$this->inclusion_mode = $var;
return $this;
} | php | {
"resource": ""
} |
q15135 | CreateInspectTemplateRequest.setInspectTemplate | train | public function setInspectTemplate($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\Dlp\V2\InspectTemplate::class);
$this->inspect_template = $var;
return $this;
} | php | {
"resource": ""
} |
q15136 | StorageConfig.setDatastoreOptions | train | public function setDatastoreOptions($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\Dlp\V2\DatastoreOptions::class);
$this->writeOneof(2, $var);
return $this;
} | php | {
"resource": ""
} |
q15137 | StorageConfig.setCloudStorageOptions | train | public function setCloudStorageOptions($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\Dlp\V2\CloudStorageOptions::class);
$this->writeOneof(3, $var);
return $this;
} | php | {
"resource": ""
} |
q15138 | StorageConfig.setBigQueryOptions | train | public function setBigQueryOptions($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\Dlp\V2\BigQueryOptions::class);
$this->writeOneof(4, $var);
return $this;
} | php | {
"resource": ""
} |
q15139 | ListModelsResponse.setModel | train | public function setModel($var)
{
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\AutoMl\V1beta1\Model::class);
$this->model = $arr;
return $this;
} | php | {
"resource": ""
} |
q15140 | StackFrame.setLoadModule | train | public function setLoadModule($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\Trace\V2\Module::class);
$this->load_module = $var;
return $this;
} | php | {
"resource": ""
} |
q15141 | SynthesizeSpeechConfig.setVoice | train | public function setVoice($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\Dialogflow\V2\VoiceSelectionParams::class);
$this->voice = $var;
return $this;
} | php | {
"resource": ""
} |
q15142 | Image.setInputConfig | train | public function setInputConfig($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\AutoMl\V1beta1\InputConfig::class);
$this->writeOneof(6, $var);
return $this;
} | php | {
"resource": ""
} |
q15143 | BeginTransactionRequest.setTransactionOptions | train | public function setTransactionOptions($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\Datastore\V1\TransactionOptions::class);
$this->transaction_options = $var;
return $this;
} | php | {
"resource": ""
} |
q15144 | UpdateProductRequest.setProduct | train | public function setProduct($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\Vision\V1\Product::class);
$this->product = $var;
return $this;
} | php | {
"resource": ""
} |
q15145 | BigQueryKey.setTableReference | train | public function setTableReference($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\Dlp\V2\BigQueryTable::class);
$this->table_reference = $var;
return $this;
} | php | {
"resource": ""
} |
q15146 | FailoverInstanceRequest.setDataProtectionMode | train | public function setDataProtectionMode($var)
{
GPBUtil::checkEnum($var, \Google\Cloud\Redis\V1beta1\FailoverInstanceRequest_DataProtectionMode::class);
$this->data_protection_mode = $var;
return $this;
} | php | {
"resource": ""
} |
q15147 | ContextsGapicClient.contextName | train | public static function contextName($project, $session, $context)
{
return self::getContextNameTemplate()->render([
'project' => $project,
'session' => $session,
'context' => $context,
]);
} | php | {
"resource": ""
} |
q15148 | ListMonitoredResourceDescriptorsResponse.setResourceDescriptors | train | public function setResourceDescriptors($var)
{
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Api\MonitoredResourceDescriptor::class);
$this->resource_descriptors = $arr;
return $this;
} | php | {
"resource": ""
} |
q15149 | BigtableInstanceAdminGapicClient.appProfileName | train | public static function appProfileName($project, $instance, $appProfile)
{
return self::getAppProfileNameTemplate()->render([
'project' => $project,
'instance' => $instance,
'app_profile' => $appProfile,
]);
} | php | {
"resource": ""
} |
q15150 | BigtableInstanceAdminGapicClient.clusterName | train | public static function clusterName($project, $instance, $cluster)
{
return self::getClusterNameTemplate()->render([
'project' => $project,
'instance' => $instance,
'cluster' => $cluster,
]);
} | php | {
"resource": ""
} |
q15151 | PartitionResponse.setPartitions | train | public function setPartitions($var)
{
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Spanner\V1\Partition::class);
$this->partitions = $arr;
return $this;
} | php | {
"resource": ""
} |
q15152 | PartitionResponse.setTransaction | train | public function setTransaction($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\Spanner\V1\Transaction::class);
$this->transaction = $var;
return $this;
} | php | {
"resource": ""
} |
q15153 | CreateApplicationRequest.setApplication | train | public function setApplication($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\Talent\V4beta1\Application::class);
$this->application = $var;
return $this;
} | php | {
"resource": ""
} |
q15154 | TimestampTrait.formatDate | train | private function formatDate($when = null)
{
if (is_string($when)) {
return $when;
} elseif (!$when) {
list($usec, $sec) = explode(' ', microtime());
$micro = sprintf("%06d", $usec * 1000000);
$when = new \DateTime(date('Y-m-d H:i:s.' . $micro));
} elseif (is_numeric($when)) {
// Expect that this is a timestamp
$micro = sprintf("%06d", ($when - floor($when)) * 1000000);
$when = new \DateTime(date('Y-m-d H:i:s.'. $micro, (int) $when));
}
$when->setTimezone(new \DateTimeZone('UTC'));
return $when->format('Y-m-d\TH:i:s.u000\Z');
} | php | {
"resource": ""
} |
q15155 | CreateDatasetRequest.setDataset | train | public function setDataset($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\AutoMl\V1beta1\Dataset::class);
$this->dataset = $var;
return $this;
} | php | {
"resource": ""
} |
q15156 | Instance.setState | train | public function setState($var)
{
GPBUtil::checkEnum($var, \Google\Cloud\Redis\V1beta1\Instance_State::class);
$this->state = $var;
return $this;
} | php | {
"resource": ""
} |
q15157 | Instance.setTier | train | public function setTier($var)
{
GPBUtil::checkEnum($var, \Google\Cloud\Redis\V1beta1\Instance_Tier::class);
$this->tier = $var;
return $this;
} | php | {
"resource": ""
} |
q15158 | Item.setInfo | train | public function setInfo($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\Dialogflow\V2\Intent_Message_SelectItemInfo::class);
$this->info = $var;
return $this;
} | php | {
"resource": ""
} |
q15159 | Item.setImage | train | public function setImage($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\Dialogflow\V2\Intent_Message_Image::class);
$this->image = $var;
return $this;
} | php | {
"resource": ""
} |
q15160 | JobQuery.setPublishTimeRange | train | public function setPublishTimeRange($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\Talent\V4beta1\TimestampRange::class);
$this->publish_time_range = $var;
return $this;
} | php | {
"resource": ""
} |
q15161 | JobQuery.setExcludedJobs | train | public function setExcludedJobs($var)
{
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING);
$this->excluded_jobs = $arr;
return $this;
} | php | {
"resource": ""
} |
q15162 | ListJobsResponse.setJobs | train | public function setJobs($var)
{
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Talent\V4beta1\Job::class);
$this->jobs = $arr;
return $this;
} | php | {
"resource": ""
} |
q15163 | ListJobsResponse.setMetadata | train | public function setMetadata($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\Talent\V4beta1\ResponseMetadata::class);
$this->metadata = $var;
return $this;
} | php | {
"resource": ""
} |
q15164 | Action.setSaveFindings | train | public function setSaveFindings($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\Dlp\V2\Action_SaveFindings::class);
$this->writeOneof(1, $var);
return $this;
} | php | {
"resource": ""
} |
q15165 | Action.setPubSub | train | public function setPubSub($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\Dlp\V2\Action_PublishToPubSub::class);
$this->writeOneof(2, $var);
return $this;
} | php | {
"resource": ""
} |
q15166 | TemporalAsset.setWindow | train | public function setWindow($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\Asset\V1\TimeWindow::class);
$this->window = $var;
return $this;
} | php | {
"resource": ""
} |
q15167 | GitHub.doesTagExist | train | public function doesTagExist($target, $tagName)
{
$res = $this->client->get(sprintf(
self::GITHUB_RELEASES_ENDPOINT,
$this->cleanTarget($target), $tagName
), [
'http_errors' => false,
'auth' => [null, $this->token]
]);
return ($res->getStatusCode() === 200);
} | php | {
"resource": ""
} |
q15168 | GitHub.createRelease | train | public function createRelease($target, $tagName, $display, $notes)
{
$requestBody = [
'tag_name' => $tagName,
'name' => $display,
'body' => $notes
];
$res = $this->client->post(sprintf(
self::GITHUB_RELEASE_CREATE_ENDPOINT,
$this->cleanTarget($target)
), [
'http_errors' => false,
'json' => $requestBody,
'auth' => [null, $this->token]
]);
return $this->doesTagExist($target, $tagName);
} | php | {
"resource": ""
} |
q15169 | GitHub.push | train | public function push($target, $ref, $targetBranch = 'master', $force = true)
{
$cmd = [
'git push -q',
sprintf('https://%s@github.com/%s', $this->token, $target),
sprintf('%s:%s', $ref, $targetBranch)
];
if ($force) {
$cmd[] = '--force';
}
return $this->shell->execute(implode(' ' , $cmd));
} | php | {
"resource": ""
} |
q15170 | AlertPolicy.setDocumentation | train | public function setDocumentation($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\Monitoring\V3\AlertPolicy_Documentation::class);
$this->documentation = $var;
return $this;
} | php | {
"resource": ""
} |
q15171 | AlertPolicy.setConditions | train | public function setConditions($var)
{
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Monitoring\V3\AlertPolicy\Condition::class);
$this->conditions = $arr;
return $this;
} | php | {
"resource": ""
} |
q15172 | AlertPolicy.setCombiner | train | public function setCombiner($var)
{
GPBUtil::checkEnum($var, \Google\Cloud\Monitoring\V3\AlertPolicy_ConditionCombinerType::class);
$this->combiner = $var;
return $this;
} | php | {
"resource": ""
} |
q15173 | AlertPolicy.setCreationRecord | train | public function setCreationRecord($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\Monitoring\V3\MutationRecord::class);
$this->creation_record = $var;
return $this;
} | php | {
"resource": ""
} |
q15174 | AlertPolicy.setMutationRecord | train | public function setMutationRecord($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\Monitoring\V3\MutationRecord::class);
$this->mutation_record = $var;
return $this;
} | php | {
"resource": ""
} |
q15175 | AnnotateTextRequest.setDocument | train | public function setDocument($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\Language\V1\Document::class);
$this->document = $var;
return $this;
} | php | {
"resource": ""
} |
q15176 | AnnotateTextRequest.setFeatures | train | public function setFeatures($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\Language\V1\AnnotateTextRequest_Features::class);
$this->features = $var;
return $this;
} | php | {
"resource": ""
} |
q15177 | AnnotateTextRequest.setEncodingType | train | public function setEncodingType($var)
{
GPBUtil::checkEnum($var, \Google\Cloud\Language\V1\EncodingType::class);
$this->encoding_type = $var;
return $this;
} | php | {
"resource": ""
} |
q15178 | TransactionConfigurationTrait.transactionSelector | train | private function transactionSelector(array &$options, array $previous = [])
{
$options += [
'begin' => false,
'transactionType' => SessionPoolInterface::CONTEXT_READ,
];
$res = $this->transactionOptions($options, $previous);
// TransactionSelector uses a different key name for singleUseTransaction
// and transactionId than transactionOptions, so we'll rewrite those here
// so transactionOptions works as expected for commitRequest.
$type = $res[1];
if ($type === 'singleUseTransaction') {
$type = 'singleUse';
} elseif ($type === 'transactionId') {
$type = 'id';
}
return [
[$type => $res[0]],
$res[2]
];
} | php | {
"resource": ""
} |
q15179 | TransactionConfigurationTrait.transactionOptions | train | private function transactionOptions(array &$options, array $previous = [])
{
$options += [
'begin' => false,
'transactionType' => SessionPoolInterface::CONTEXT_READWRITE,
'transactionId' => null,
];
$type = null;
$context = $this->pluck('transactionType', $options);
$id = $this->pluck('transactionId', $options);
$begin = $this->pluck('begin', $options);
if ($id === null) {
if ($begin) {
$type = 'begin';
} else {
$type = 'singleUseTransaction';
$options['singleUse'] = true;
}
}
if ($id !== null) {
$type = 'transactionId';
$transactionOptions = $id;
} elseif ($context === SessionPoolInterface::CONTEXT_READ) {
$transactionOptions = $this->configureSnapshotOptions($options, $previous);
} elseif ($context === SessionPoolInterface::CONTEXT_READWRITE) {
$transactionOptions = $this->configureTransactionOptions();
} else {
throw new \BadMethodCallException(sprintf(
'Invalid transaction context %s',
$context
));
}
return [$transactionOptions, $type, $context];
} | php | {
"resource": ""
} |
q15180 | TransactionConfigurationTrait.configureSnapshotOptions | train | private function configureSnapshotOptions(array &$options, array $previous = [])
{
$options += [
'singleUse' => false,
'returnReadTimestamp' => null,
'strong' => null,
'readTimestamp' => null,
'exactStaleness' => null,
'minReadTimestamp' => null,
'maxStaleness' => null,
];
$previousOptions = isset($previous['transactionOptions']['readOnly'])
? $previous['transactionOptions']['readOnly']
: [];
// These are only available in single-use transactions.
if (!$options['singleUse'] && ($options['maxStaleness'] || $options['minReadTimestamp'])) {
throw new \BadMethodCallException(
'maxStaleness and minReadTimestamp are only available in single-use transactions.'
);
}
$transactionOptions = [
'readOnly' => $this->arrayFilterRemoveNull([
'returnReadTimestamp' => $this->pluck('returnReadTimestamp', $options),
'strong' => $this->pluck('strong', $options),
'minReadTimestamp' => $this->pluck('minReadTimestamp', $options),
'maxStaleness' => $this->pluck('maxStaleness', $options),
'readTimestamp' => $this->pluck('readTimestamp', $options),
'exactStaleness' => $this->pluck('exactStaleness', $options),
]) + $previousOptions
];
if (empty($transactionOptions['readOnly'])) {
$transactionOptions['readOnly']['strong'] = true;
}
$timestampFields = [
'minReadTimestamp',
'readTimestamp'
];
$durationFields = [
'exactStaleness',
'maxStaleness'
];
foreach ($timestampFields as $tsf) {
if (isset($transactionOptions['readOnly'][$tsf]) && !isset($previousOptions[$tsf])) {
$field = $transactionOptions['readOnly'][$tsf];
if (!($field instanceof Timestamp)) {
throw new \BadMethodCallException(sprintf(
'Read Only Transaction Configuration Field %s must be an instance of `%s`.',
$tsf,
Timestamp::class
));
}
$transactionOptions['readOnly'][$tsf] = $field->formatAsString();
}
}
foreach ($durationFields as $df) {
if (isset($transactionOptions['readOnly'][$df]) && !isset($previousOptions[$df])) {
$field = $transactionOptions['readOnly'][$df];
if (!($field instanceof Duration)) {
throw new \BadMethodCallException(sprintf(
'Read Only Transaction Configuration Field %s must be an instance of `%s`.',
$df,
Duration::class
));
}
$transactionOptions['readOnly'][$df] = $field->get();
}
}
return $transactionOptions;
} | php | {
"resource": ""
} |
q15181 | RegistryCredential.setPublicKeyCertificate | train | public function setPublicKeyCertificate($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\Iot\V1\PublicKeyCertificate::class);
$this->writeOneof(1, $var);
return $this;
} | php | {
"resource": ""
} |
q15182 | StackFrame.setArguments | train | public function setArguments($var)
{
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Debugger\V2\Variable::class);
$this->arguments = $arr;
return $this;
} | php | {
"resource": ""
} |
q15183 | StackFrame.setLocals | train | public function setLocals($var)
{
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Debugger\V2\Variable::class);
$this->locals = $arr;
return $this;
} | php | {
"resource": ""
} |
q15184 | ResourceGroup.setResourceType | train | public function setResourceType($var)
{
GPBUtil::checkEnum($var, \Google\Cloud\Monitoring\V3\GroupResourceType::class);
$this->resource_type = $var;
return $this;
} | php | {
"resource": ""
} |
q15185 | StreamWrapper.register | train | public static function register(StorageClient $client, $protocol = null)
{
$protocol = $protocol ?: self::DEFAULT_PROTOCOL;
if (!in_array($protocol, stream_get_wrappers())) {
if (!stream_wrapper_register($protocol, StreamWrapper::class, STREAM_IS_URL)) {
throw new \RuntimeException("Failed to register '$protocol://' protocol");
}
self::$clients[$protocol] = $client;
return true;
}
return false;
} | php | {
"resource": ""
} |
q15186 | StreamWrapper.unregister | train | public static function unregister($protocol = null)
{
$protocol = $protocol ?: self::DEFAULT_PROTOCOL;
stream_wrapper_unregister($protocol);
unset(self::$clients[$protocol]);
} | php | {
"resource": ""
} |
q15187 | StreamWrapper.getClient | train | public static function getClient($protocol = null)
{
$protocol = $protocol ?: self::DEFAULT_PROTOCOL;
return self::$clients[$protocol];
} | php | {
"resource": ""
} |
q15188 | StreamWrapper.stream_open | train | public function stream_open($path, $mode, $flags, &$openedPath)
{
$client = $this->openPath($path);
// strip off 'b' or 't' from the mode
$mode = rtrim($mode, 'bt');
$options = [];
if ($this->context) {
$contextOptions = stream_context_get_options($this->context);
if (array_key_exists($this->protocol, $contextOptions)) {
$options = $contextOptions[$this->protocol] ?: [];
}
}
if ($mode == 'w') {
$this->stream = new WriteStream(null, $options);
$this->stream->setUploader(
$this->bucket->getStreamableUploader(
$this->stream,
$options + ['name' => $this->file]
)
);
} elseif ($mode == 'r') {
try {
// Lazy read from the source
$options['restOptions']['stream'] = true;
$this->stream = new ReadStream(
$this->bucket->object($this->file)->downloadAsStream($options)
);
// Wrap the response in a caching stream to make it seekable
if (!$this->stream->isSeekable() && ($flags & STREAM_MUST_SEEK)) {
$this->stream = new CachingStream($this->stream);
}
} catch (ServiceException $ex) {
return $this->returnError($ex->getMessage(), $flags);
}
} else {
return $this->returnError('Unknown stream_open mode.', $flags);
}
if ($flags & STREAM_USE_PATH) {
$openedPath = $path;
}
return true;
} | php | {
"resource": ""
} |
q15189 | StreamWrapper.stream_stat | train | public function stream_stat()
{
$mode = $this->stream->isWritable()
? self::FILE_WRITABLE_MODE
: self::FILE_READABLE_MODE;
return $this->makeStatArray([
'mode' => $mode,
'size' => $this->stream->getSize()
]);
} | php | {
"resource": ""
} |
q15190 | StreamWrapper.stream_seek | train | public function stream_seek($offset, $whence = SEEK_SET)
{
if ($this->stream->isSeekable()) {
$this->stream->seek($offset, $whence);
return true;
}
return false;
} | php | {
"resource": ""
} |
q15191 | StreamWrapper.dir_readdir | train | public function dir_readdir()
{
$object = $this->directoryIterator->current();
if ($object) {
$this->directoryIterator->next();
return $object->name();
}
return false;
} | php | {
"resource": ""
} |
q15192 | StreamWrapper.dir_rewinddir | train | public function dir_rewinddir()
{
try {
$this->directoryIterator = $this->bucket->objects([
'prefix' => $this->file,
'fields' => 'items/name,nextPageToken'
]);
} catch (ServiceException $e) {
return false;
}
return true;
} | php | {
"resource": ""
} |
q15193 | StreamWrapper.mkdir | train | public function mkdir($path, $mode, $options)
{
$path = $this->makeDirectory($path);
$client = $this->openPath($path);
$predefinedAcl = $this->determineAclFromMode($mode);
try {
if ($options & STREAM_MKDIR_RECURSIVE || $this->file == '') {
if (!$this->bucket->exists()) {
$client->createBucket($this->bucket->name(), [
'predefinedAcl' => $predefinedAcl,
'predefinedDefaultObjectAcl' => $predefinedAcl
]);
}
}
// If the file name is empty, we were trying to create a bucket. In this case,
// don't create the placeholder file.
if ($this->file != '') {
// Fake a directory by creating an empty placeholder file whose name ends in '/'
$this->bucket->upload('', [
'name' => $this->file,
'predefinedAcl' => $predefinedAcl
]);
}
} catch (ServiceException $e) {
return false;
}
return true;
} | php | {
"resource": ""
} |
q15194 | StreamWrapper.rename | train | public function rename($from, $to)
{
$url = (array) parse_url($to) + [
'path' => '',
'host' => ''
];
$destinationBucket = $url['host'];
$destinationPath = substr($url['path'], 1);
$this->dir_opendir($from, []);
foreach ($this->directoryIterator as $file) {
$name = $file->name();
$newPath = str_replace($this->file, $destinationPath, $name);
$obj = $this->bucket->object($name);
try {
$obj->rename($newPath, ['destinationBucket' => $destinationBucket]);
} catch (ServiceException $e) {
// If any rename calls fail, abort and return false
return false;
}
}
return true;
} | php | {
"resource": ""
} |
q15195 | StreamWrapper.unlink | train | public function unlink($path)
{
$client = $this->openPath($path);
$object = $this->bucket->object($this->file);
try {
$object->delete();
return true;
} catch (ServiceException $e) {
return false;
}
} | php | {
"resource": ""
} |
q15196 | StreamWrapper.url_stat | train | public function url_stat($path, $flags)
{
$client = $this->openPath($path);
// if directory
if ($this->isDirectory($this->file)) {
return $this->urlStatDirectory();
}
return $this->urlStatFile();
} | php | {
"resource": ""
} |
q15197 | StreamWrapper.openPath | train | private function openPath($path)
{
$url = (array) parse_url($path) + [
'scheme' => '',
'path' => '',
'host' => ''
];
$this->protocol = $url['scheme'];
$this->file = ltrim($url['path'], '/');
$client = self::getClient($this->protocol);
$this->bucket = $client->bucket($url['host']);
return $client;
} | php | {
"resource": ""
} |
q15198 | StreamWrapper.urlStatDirectory | train | private function urlStatDirectory()
{
$stats = [];
// 1. try to look up the directory as a file
try {
$this->object = $this->bucket->object($this->file);
$info = $this->object->info();
// equivalent to 40777 and 40444 in octal
$stats['mode'] = $this->bucket->isWritable()
? self::DIRECTORY_WRITABLE_MODE
: self::DIRECTORY_READABLE_MODE;
$this->statsFromFileInfo($info, $stats);
return $this->makeStatArray($stats);
} catch (NotFoundException $e) {
} catch (ServiceException $e) {
return false;
}
// 2. try list files in that directory
try {
$objects = $this->bucket->objects([
'prefix' => $this->file,
]);
if (!$objects->current()) {
// can't list objects or doesn't exist
return false;
}
} catch (ServiceException $e) {
return false;
}
// equivalent to 40777 and 40444 in octal
$mode = $this->bucket->isWritable()
? self::DIRECTORY_WRITABLE_MODE
: self::DIRECTORY_READABLE_MODE;
return $this->makeStatArray([
'mode' => $mode
]);
} | php | {
"resource": ""
} |
q15199 | StreamWrapper.urlStatFile | train | private function urlStatFile()
{
try {
$this->object = $this->bucket->object($this->file);
$info = $this->object->info();
} catch (ServiceException $e) {
// couldn't stat file
return false;
}
// equivalent to 100666 and 100444 in octal
$stats = array(
'mode' => $this->bucket->isWritable()
? self::FILE_WRITABLE_MODE
: self::FILE_READABLE_MODE
);
$this->statsFromFileInfo($info, $stats);
return $this->makeStatArray($stats);
} | php | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.