_id stringlengths 2 7 | title stringlengths 3 151 | partition stringclasses 3
values | text stringlengths 83 13k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q16100 | CheckAndMutateRowRequest.setTrueMutations | train | public function setTrueMutations($var)
{
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Bigtable\V2\Mutation::class);
$this->true_mutations = $arr;
return $this;
} | php | {
"resource": ""
} |
q16101 | CheckAndMutateRowRequest.setFalseMutations | train | public function setFalseMutations($var)
{
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Bigtable\V2\Mutation::class);
$this->false_mutations = $arr;
return $this;
} | php | {
"resource": ""
} |
q16102 | Transaction.snapshot | train | public function snapshot(DocumentReference $document, array $options = [])
{
return $this->createSnapshot($this->connection, $this->valueMapper, $document, [
'transaction' => $this->transaction,
] + $options);
} | php | {
"resource": ""
} |
q16103 | Transaction.create | train | public function create(DocumentReference $document, array $fields)
{
$this->writer->create($document->name(), $fields);
return $this;
} | php | {
"resource": ""
} |
q16104 | Transaction.set | train | public function set(DocumentReference $document, array $fields, array $options = [])
{
$this->writer->set($document->name(), $fields, $options);
return $this;
} | php | {
"resource": ""
} |
q16105 | Transaction.delete | train | public function delete(DocumentReference $document, array $options = [])
{
$this->writer->delete($document->name(), $options);
return $this;
} | php | {
"resource": ""
} |
q16106 | OperationMetadata.setState | train | public function setState($var)
{
GPBUtil::checkEnum($var, \Google\Cloud\Vision\V1\OperationMetadata_State::class);
$this->state = $var;
return $this;
} | php | {
"resource": ""
} |
q16107 | UptimeCheckConfig.setResourceGroup | train | public function setResourceGroup($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\Monitoring\V3\UptimeCheckConfig_ResourceGroup::class);
$this->writeOneof(4, $var);
return $this;
} | php | {
"resource": ""
} |
q16108 | UptimeCheckConfig.setHttpCheck | train | public function setHttpCheck($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\Monitoring\V3\UptimeCheckConfig_HttpCheck::class);
$this->writeOneof(5, $var);
return $this;
} | php | {
"resource": ""
} |
q16109 | UptimeCheckConfig.setTcpCheck | train | public function setTcpCheck($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\Monitoring\V3\UptimeCheckConfig_TcpCheck::class);
$this->writeOneof(6, $var);
return $this;
} | php | {
"resource": ""
} |
q16110 | UptimeCheckConfig.setContentMatchers | train | public function setContentMatchers($var)
{
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Monitoring\V3\UptimeCheckConfig\ContentMatcher::class);
$this->content_matchers = $arr;
return $this;
} | php | {
"resource": ""
} |
q16111 | UptimeCheckConfig.setSelectedRegions | train | public function setSelectedRegions($var)
{
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::ENUM, \Google\Cloud\Monitoring\V3\UptimeCheckRegion::class);
$this->selected_regions = $arr;
return $this;
} | php | {
"resource": ""
} |
q16112 | InstanceGroupConfig.setInstanceNames | train | public function setInstanceNames($var)
{
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING);
$this->instance_names = $arr;
return $this;
} | php | {
"resource": ""
} |
q16113 | InstanceGroupConfig.setDiskConfig | train | public function setDiskConfig($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\Dataproc\V1beta2\DiskConfig::class);
$this->disk_config = $var;
return $this;
} | php | {
"resource": ""
} |
q16114 | InstanceGroupConfig.setManagedGroupConfig | train | public function setManagedGroupConfig($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\Dataproc\V1beta2\ManagedGroupConfig::class);
$this->managed_group_config = $var;
return $this;
} | php | {
"resource": ""
} |
q16115 | UpdateFindingRequest.setFinding | train | public function setFinding($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\SecurityCenter\V1\Finding::class);
$this->finding = $var;
return $this;
} | php | {
"resource": ""
} |
q16116 | ListSnapshotsResponse.setSnapshots | train | public function setSnapshots($var)
{
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Bigtable\Admin\V2\Snapshot::class);
$this->snapshots = $arr;
return $this;
} | php | {
"resource": ""
} |
q16117 | LoginProfile.setPosixAccounts | train | public function setPosixAccounts($var)
{
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\OsLogin\Common\PosixAccount::class);
$this->posix_accounts = $arr;
return $this;
} | php | {
"resource": ""
} |
q16118 | LoginProfile.setSshPublicKeys | train | public function setSshPublicKeys($var)
{
$arr = GPBUtil::checkMapField($var, \Google\Protobuf\Internal\GPBType::STRING, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\OsLogin\Common\SshPublicKey::class);
$this->ssh_public_keys = $arr;
return $this;
} | php | {
"resource": ""
} |
q16119 | ListQueuesResponse.setQueues | train | public function setQueues($var)
{
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Tasks\V2\Queue::class);
$this->queues = $arr;
return $this;
} | php | {
"resource": ""
} |
q16120 | PageIteratorTrait.next | train | public function next()
{
$this->position++;
$this->page = $this->nextResultToken()
? $this->executeCall()
: null;
} | php | {
"resource": ""
} |
q16121 | PageIteratorTrait.executeCall | train | private function executeCall()
{
$call = $this->call;
list($results, $shouldContinue) = $this->mapResults(
$call($this->callOptions)
);
$this->set(
$this->resultTokenPath,
$this->callOptions,
$this->determineNextResultToken($results, $shouldContinue)
);
return $results;
} | php | {
"resource": ""
} |
q16122 | ListLogMetricsResponse.setMetrics | train | public function setMetrics($var)
{
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Logging\V2\LogMetric::class);
$this->metrics = $arr;
return $this;
} | php | {
"resource": ""
} |
q16123 | DependencyEdge.setLabel | train | public function setLabel($var)
{
GPBUtil::checkEnum($var, \Google\Cloud\Language\V1\DependencyEdge_Label::class);
$this->label = $var;
return $this;
} | php | {
"resource": ""
} |
q16124 | Link.setType | train | public function setType($var)
{
GPBUtil::checkEnum($var, \Google\Cloud\Trace\V2\Span_Link_Type::class);
$this->type = $var;
return $this;
} | php | {
"resource": ""
} |
q16125 | SearchHashesResponse.setThreats | train | public function setThreats($var)
{
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\WebRisk\V1beta1\SearchHashesResponse\ThreatHash::class);
$this->threats = $arr;
return $this;
} | php | {
"resource": ""
} |
q16126 | InfoTypeDescription.setSupportedBy | train | public function setSupportedBy($var)
{
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::ENUM, \Google\Cloud\Dlp\V2\InfoTypeSupportedBy::class);
$this->supported_by = $arr;
return $this;
} | php | {
"resource": ""
} |
q16127 | LabelDetectionConfig.setLabelDetectionMode | train | public function setLabelDetectionMode($var)
{
GPBUtil::checkEnum($var, \Google\Cloud\VideoIntelligence\V1\LabelDetectionMode::class);
$this->label_detection_mode = $var;
return $this;
} | php | {
"resource": ""
} |
q16128 | TranslateClient.translate | train | public function translate($string, array $options = [])
{
$res = $this->translateBatch([$string], $options);
if (count($res) > 0) {
return $res[0];
}
} | php | {
"resource": ""
} |
q16129 | TranslateClient.translateBatch | train | public function translateBatch(array $strings, array $options = [])
{
$options += [
'model' => null,
];
$options = array_filter($options + [
'q' => $strings,
'key' => $this->key,
'target' => $this->targetLanguage,
'model' => $options['model']
], function ($opt) {
return !is_null($opt);
});
$response = $this->connection->listTranslations($options);
$translations = [];
$strings = array_values($strings);
if (isset($response['data']['translations'])) {
foreach ($response['data']['translations'] as $key => $translation) {
$source = isset($translation['detectedSourceLanguage'])
? $translation['detectedSourceLanguage']
: $options['source'];
$model = (isset($translation['model']))
? $translation['model']
: null;
$translations[] = [
'source' => $source,
'input' => $strings[$key],
'text' => $translation['translatedText'],
'model' => $model
];
}
}
return $translations;
} | php | {
"resource": ""
} |
q16130 | TranslateClient.detectLanguageBatch | train | public function detectLanguageBatch(array $strings, array $options = [])
{
$response = $this->connection->listDetections($options + [
'q' => $strings,
'key' => $this->key
]);
$detections = [];
foreach ($response['data']['detections'] as $key => $detection) {
$detection = $detection[0];
$detections[] = array_filter([
'languageCode' => $detection['language'],
'input' => $strings[$key],
'confidence' => isset($detection['confidence']) ? $detection['confidence'] : null
]);
}
return $detections;
} | php | {
"resource": ""
} |
q16131 | TranslateClient.languages | train | public function languages(array $options = [])
{
$response = $this->localizedLanguages($options + ['target' => null]);
return array_map(function ($language) {
return $language['code'];
}, $response);
} | php | {
"resource": ""
} |
q16132 | TranslateClient.localizedLanguages | train | public function localizedLanguages(array $options = [])
{
$response = $this->connection->listLanguages($options + [
'key' => $this->key,
'target' => $this->targetLanguage
]);
return array_map(function ($language) {
return array_filter([
'code' => $language['language'],
'name' => isset($language['name']) ? $language['name'] : null
]);
}, $response['data']['languages']);
} | php | {
"resource": ""
} |
q16133 | CompositeFilter.setOp | train | public function setOp($var)
{
GPBUtil::checkEnum($var, \Google\Cloud\Datastore\V1\CompositeFilter_Operator::class);
$this->op = $var;
return $this;
} | php | {
"resource": ""
} |
q16134 | ListDeviceStatesResponse.setDeviceStates | train | public function setDeviceStates($var)
{
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Iot\V1\DeviceState::class);
$this->device_states = $arr;
return $this;
} | php | {
"resource": ""
} |
q16135 | BatchUpdateEntityTypesRequest.setEntityTypeBatchInline | train | public function setEntityTypeBatchInline($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\Dialogflow\V2\EntityTypeBatch::class);
$this->writeOneof(3, $var);
return $this;
} | php | {
"resource": ""
} |
q16136 | Notification.reload | train | public function reload(array $options = [])
{
return $this->info = $this->connection->getNotification(
$options + $this->identity
);
} | php | {
"resource": ""
} |
q16137 | LargeCustomDictionaryConfig.setOutputPath | train | public function setOutputPath($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\Dlp\V2\CloudStoragePath::class);
$this->output_path = $var;
return $this;
} | php | {
"resource": ""
} |
q16138 | LargeCustomDictionaryConfig.setCloudStorageFileSet | train | public function setCloudStorageFileSet($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\Dlp\V2\CloudStorageFileSet::class);
$this->writeOneof(2, $var);
return $this;
} | php | {
"resource": ""
} |
q16139 | LargeCustomDictionaryConfig.setBigQueryField | train | public function setBigQueryField($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\Dlp\V2\BigQueryField::class);
$this->writeOneof(3, $var);
return $this;
} | php | {
"resource": ""
} |
q16140 | CreateClientEventRequest.setClientEvent | train | public function setClientEvent($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\Talent\V4beta1\ClientEvent::class);
$this->client_event = $var;
return $this;
} | php | {
"resource": ""
} |
q16141 | ProductSearchGapicClient.productName | train | public static function productName($project, $location, $product)
{
return self::getProductNameTemplate()->render([
'project' => $project,
'location' => $location,
'product' => $product,
]);
} | php | {
"resource": ""
} |
q16142 | ProductSearchGapicClient.productSetName | train | public static function productSetName($project, $location, $productSet)
{
return self::getProductSetNameTemplate()->render([
'project' => $project,
'location' => $location,
'product_set' => $productSet,
]);
} | php | {
"resource": ""
} |
q16143 | ProductSearchGapicClient.referenceImageName | train | public static function referenceImageName($project, $location, $product, $referenceImage)
{
return self::getReferenceImageNameTemplate()->render([
'project' => $project,
'location' => $location,
'product' => $product,
'reference_image' => $referenceImage,
]);
} | php | {
"resource": ""
} |
q16144 | Message.attribute | train | public function attribute($key)
{
return (isset($this->message['attributes'][$key]))
? $this->message['attributes'][$key]
: null;
} | php | {
"resource": ""
} |
q16145 | RetryDeciderTrait.getRetryFunction | train | private function getRetryFunction($shouldRetryMessages = true)
{
$httpRetryCodes = $this->httpRetryCodes;
$httpRetryMessages = $this->httpRetryMessages;
return function (\Exception $ex) use ($httpRetryCodes, $httpRetryMessages, $shouldRetryMessages) {
$statusCode = $ex->getCode();
if (in_array($statusCode, $httpRetryCodes)) {
return true;
}
if (!$shouldRetryMessages) {
return false;
}
$message = ($ex instanceof RequestException && $ex->hasResponse())
? (string) $ex->getResponse()->getBody()
: $ex->getMessage();
try {
$message = $this->jsonDecode(
$message,
true
);
} catch (\InvalidArgumentException $ex) {
return false;
}
if (!isset($message['error']['errors'])) {
return false;
}
foreach ($message['error']['errors'] as $error) {
if (in_array($error['reason'], $httpRetryMessages)) {
return true;
}
}
return false;
};
} | php | {
"resource": ""
} |
q16146 | DetectedBreak.setType | train | public function setType($var)
{
GPBUtil::checkEnum($var, \Google\Cloud\Vision\V1\TextAnnotation_DetectedBreak_BreakType::class);
$this->type = $var;
return $this;
} | php | {
"resource": ""
} |
q16147 | Cluster.setMasterAuth | train | public function setMasterAuth($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\Container\V1\MasterAuth::class);
$this->master_auth = $var;
return $this;
} | php | {
"resource": ""
} |
q16148 | Cluster.setLegacyAbac | train | public function setLegacyAbac($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\Container\V1\LegacyAbac::class);
$this->legacy_abac = $var;
return $this;
} | php | {
"resource": ""
} |
q16149 | Cluster.setIpAllocationPolicy | train | public function setIpAllocationPolicy($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\Container\V1\IPAllocationPolicy::class);
$this->ip_allocation_policy = $var;
return $this;
} | php | {
"resource": ""
} |
q16150 | Cluster.setMasterAuthorizedNetworksConfig | train | public function setMasterAuthorizedNetworksConfig($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\Container\V1\MasterAuthorizedNetworksConfig::class);
$this->master_authorized_networks_config = $var;
return $this;
} | php | {
"resource": ""
} |
q16151 | Cluster.setNetworkConfig | train | public function setNetworkConfig($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\Container\V1\NetworkConfig::class);
$this->network_config = $var;
return $this;
} | php | {
"resource": ""
} |
q16152 | Cluster.setPrivateClusterConfig | train | public function setPrivateClusterConfig($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\Container\V1\PrivateClusterConfig::class);
$this->private_cluster_config = $var;
return $this;
} | php | {
"resource": ""
} |
q16153 | Publication.setAuthors | train | public function setAuthors($var)
{
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING);
$this->authors = $arr;
return $this;
} | php | {
"resource": ""
} |
q16154 | ConfusionMatrix.setAnnotationSpecId | train | public function setAnnotationSpecId($var)
{
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING);
$this->annotation_spec_id = $arr;
return $this;
} | php | {
"resource": ""
} |
q16155 | DocumentDelete.setRemovedTargetIds | train | public function setRemovedTargetIds($var)
{
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::INT32);
$this->removed_target_ids = $arr;
return $this;
} | php | {
"resource": ""
} |
q16156 | DataTransferServiceGapicClient.projectRunName | train | public static function projectRunName($project, $transferConfig, $run)
{
return self::getProjectRunNameTemplate()->render([
'project' => $project,
'transfer_config' => $transferConfig,
'run' => $run,
]);
} | php | {
"resource": ""
} |
q16157 | CreateNodePoolRequest.setNodePool | train | public function setNodePool($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\Container\V1\NodePool::class);
$this->node_pool = $var;
return $this;
} | php | {
"resource": ""
} |
q16158 | OutputConfig.setGcsDestination | train | public function setGcsDestination($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\Asset\V1\GcsDestination::class);
$this->writeOneof(1, $var);
return $this;
} | php | {
"resource": ""
} |
q16159 | SecurityCenterGapicClient.findingSecurityMarksName | train | public static function findingSecurityMarksName($organization, $source, $finding)
{
return self::getFindingSecurityMarksNameTemplate()->render([
'organization' => $organization,
'source' => $source,
'finding' => $finding,
]);
} | php | {
"resource": ""
} |
q16160 | SecurityCenterGapicClient.findingName | train | public static function findingName($organization, $source, $finding)
{
return self::getFindingNameTemplate()->render([
'organization' => $organization,
'source' => $source,
'finding' => $finding,
]);
} | php | {
"resource": ""
} |
q16161 | SecurityCenterGapicClient.getIamPolicy | train | public function getIamPolicy($resource, array $optionalArgs = [])
{
$request = new GetIamPolicyRequest();
$request->setResource($resource);
return $this->startCall(
'GetIamPolicy',
Policy::class,
$optionalArgs,
$request
)->wait();
} | php | {
"resource": ""
} |
q16162 | ClassificationEvaluationMetrics.setConfidenceMetricsEntry | train | public function setConfidenceMetricsEntry($var)
{
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\AutoMl\V1beta1\ClassificationEvaluationMetrics\ConfidenceMetricsEntry::class);
$this->confidence_metrics_entry = $arr;
return $this;
} | php | {
"resource": ""
} |
q16163 | ClassificationEvaluationMetrics.setConfusionMatrix | train | public function setConfusionMatrix($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\AutoMl\V1beta1\ClassificationEvaluationMetrics_ConfusionMatrix::class);
$this->confusion_matrix = $var;
return $this;
} | php | {
"resource": ""
} |
q16164 | ListTransferLogsRequest.setMessageTypes | train | public function setMessageTypes($var)
{
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::ENUM, \Google\Cloud\BigQuery\DataTransfer\V1\TransferMessage\MessageSeverity::class);
$this->message_types = $arr;
return $this;
} | php | {
"resource": ""
} |
q16165 | CreateSourceRequest.setSource | train | public function setSource($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\SecurityCenter\V1\Source::class);
$this->source = $var;
return $this;
} | php | {
"resource": ""
} |
q16166 | UpdateOrganizationSettingsRequest.setOrganizationSettings | train | public function setOrganizationSettings($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\SecurityCenter\V1\OrganizationSettings::class);
$this->organization_settings = $var;
return $this;
} | php | {
"resource": ""
} |
q16167 | UpdateSubscriptionRequest.setSubscription | train | public function setSubscription($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\PubSub\V1\Subscription::class);
$this->subscription = $var;
return $this;
} | php | {
"resource": ""
} |
q16168 | Metric.update | train | public function update(array $metadata, array $options = [])
{
$options += $metadata;
$options += $this->info($options);
return $this->info = $this->connection->updateMetric($options + [
'metricName' => $this->formattedName
]);
} | php | {
"resource": ""
} |
q16169 | Metric.reload | train | public function reload(array $options = [])
{
return $this->info = $this->connection->getMetric($options + [
'metricName' => $this->formattedName
]);
} | php | {
"resource": ""
} |
q16170 | AnnotateImageRequest.setImage | train | public function setImage($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\Vision\V1\Image::class);
$this->image = $var;
return $this;
} | php | {
"resource": ""
} |
q16171 | Daemon.run | train | public function run(DebuggerClient $client = null, $asDaemon = true)
{
$client = $client ?: $this->defaultClient();
$extSourceContexts = $this->extSourceContext ? [$this->extSourceContext] : [];
$uniquifier = $this->uniquifier ?: $this->defaultUniquifier();
do {
$debuggee = $client->debuggee(null, [
'uniquifier' => $uniquifier,
'description' => $this->description,
'extSourceContexts' => $extSourceContexts,
'labels' => $this->labels
]);
// If registration with backoff fails, then propagate the exception.
$backoff = new ExponentialBackoff();
$backoff->execute(function () use ($debuggee) {
$debuggee->register();
});
try {
$options = [];
do {
try {
$resp = $debuggee->breakpointsWithWaitToken($options);
$this->setBreakpoints($debuggee, $resp['breakpoints']);
$options['waitToken'] = $resp['nextWaitToken'];
} catch (ConflictException $e) {
// The hanging GET call returns a 409 (Conflict) response
// when the request times out with a status of 'ABORTED'.
// In this case, we'll fetch again with the same waitToken.
}
gc_collect_cycles();
} while ($asDaemon);
} catch (ServiceException $e) {
// For any other ServiceExceptions, re-register and start over.
}
gc_collect_cycles();
} while ($asDaemon);
} | php | {
"resource": ""
} |
q16172 | Condition.setTrueFilter | train | public function setTrueFilter($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\Bigtable\V2\RowFilter::class);
$this->true_filter = $var;
return $this;
} | php | {
"resource": ""
} |
q16173 | Condition.setFalseFilter | train | public function setFalseFilter($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\Bigtable\V2\RowFilter::class);
$this->false_filter = $var;
return $this;
} | php | {
"resource": ""
} |
q16174 | LanguageServiceGapicClient.annotateText | train | public function annotateText($document, $features, array $optionalArgs = [])
{
$request = new AnnotateTextRequest();
$request->setDocument($document);
$request->setFeatures($features);
if (isset($optionalArgs['encodingType'])) {
$request->setEncodingType($optionalArgs['encodingType']);
}
return $this->startCall(
'AnnotateText',
AnnotateTextResponse::class,
$optionalArgs,
$request
)->wait();
} | php | {
"resource": ""
} |
q16175 | RecognitionMetadata.setInteractionType | train | public function setInteractionType($var)
{
GPBUtil::checkEnum($var, \Google\Cloud\Speech\V1p1beta1\RecognitionMetadata_InteractionType::class);
$this->interaction_type = $var;
return $this;
} | php | {
"resource": ""
} |
q16176 | RecognitionMetadata.setMicrophoneDistance | train | public function setMicrophoneDistance($var)
{
GPBUtil::checkEnum($var, \Google\Cloud\Speech\V1p1beta1\RecognitionMetadata_MicrophoneDistance::class);
$this->microphone_distance = $var;
return $this;
} | php | {
"resource": ""
} |
q16177 | RecognitionMetadata.setOriginalMediaType | train | public function setOriginalMediaType($var)
{
GPBUtil::checkEnum($var, \Google\Cloud\Speech\V1p1beta1\RecognitionMetadata_OriginalMediaType::class);
$this->original_media_type = $var;
return $this;
} | php | {
"resource": ""
} |
q16178 | RecognitionMetadata.setRecordingDeviceType | train | public function setRecordingDeviceType($var)
{
GPBUtil::checkEnum($var, \Google\Cloud\Speech\V1p1beta1\RecognitionMetadata_RecordingDeviceType::class);
$this->recording_device_type = $var;
return $this;
} | php | {
"resource": ""
} |
q16179 | EntityMapper.responseToEntityProperties | train | public function responseToEntityProperties(array $entityData, $className = Entity::class)
{
if (!is_subclass_of($className, EntityInterface::class)) {
throw new \InvalidArgumentException(sprintf(
'Class %s must implement EntityInterface.',
$className
));
}
$properties = [];
$excludes = [];
$meanings = [];
$mappings = $className::mappings();
foreach ($entityData as $key => $property) {
$mapClassName = Entity::class;
if (array_key_exists($key, $mappings)) {
$mapClassName = $mappings[$key];
}
if ($mapClassName) {
if (!is_subclass_of($mapClassName, EntityInterface::class)) {
throw new \InvalidArgumentException(sprintf(
'Class %s must implement EntityInterface. (Found in mappings on %s)',
$mapClassName,
$className
));
}
}
$properties[$key] = $this->getPropertyValue($property, $mapClassName);
if (isset($property['excludeFromIndexes']) && $property['excludeFromIndexes']) {
$excludes[] = $key;
}
if (isset($property['meaning']) && $property['meaning']) {
$meanings[$key] = $property['meaning'];
}
}
return [
'properties' => $properties,
'excludes' => $excludes,
'meanings' => $meanings
];
} | php | {
"resource": ""
} |
q16180 | EntityMapper.objectToRequest | train | public function objectToRequest(EntityInterface $entity)
{
$data = $entity->get();
$properties = [];
foreach ($data as $key => $value) {
$exclude = in_array($key, $entity->excludedProperties());
$meaning = (isset($entity->meanings()[$key]))
? $entity->meanings()[$key]
: null;
$properties[$key] = $this->valueObject(
$value,
$exclude,
$meaning
);
}
$key = $entity->key()
? $entity->key()->keyObject()
: null;
return array_filter([
'key' => $key,
'properties' => $properties
]);
} | php | {
"resource": ""
} |
q16181 | EntityMapper.valueObject | train | public function valueObject($value, $exclude = false, $meaning = null)
{
switch (gettype($value)) {
case 'boolean':
$propertyValue = [
'booleanValue' => $value
];
break;
case 'integer':
$propertyValue = [
'integerValue' => $value
];
break;
case 'double':
$propertyValue = [
'doubleValue' => $value
];
break;
case 'string':
$propertyValue = [
'stringValue' => $value
];
break;
case 'array':
if (!empty($value) && $this->isAssoc($value)) {
$propertyValue = $this->convertArrayToEntityValue($value);
} else {
$propertyValue = $this->convertArrayToArrayValue($value);
}
break;
case 'object':
$propertyValue = $this->objectProperty($value);
break;
case 'resource':
$content = stream_get_contents($value);
$propertyValue = [
'blobValue' => ($this->encode)
? base64_encode($content)
: $content
];
break;
case 'NULL':
$propertyValue = [
'nullValue' => null
];
break;
//@codeCoverageIgnoreStart
case 'unknown type':
throw new \InvalidArgumentException(sprintf(
'Unknown type for `%s',
$content
));
break;
default:
throw new \InvalidArgumentException(sprintf(
'Invalid type for `%s',
$content
));
break;
//@codeCoverageIgnoreEnd
}
if ($exclude) {
$propertyValue['excludeFromIndexes'] = true;
}
if ($meaning) {
$propertyValue['meaning'] = $meaning;
}
return $propertyValue;
} | php | {
"resource": ""
} |
q16182 | EntityMapper.objectProperty | train | public function objectProperty($value)
{
switch (true) {
case $value instanceof Int64:
return [
'integerValue' => $value->get()
];
break;
case $value instanceof Blob:
return [
'blobValue' => ($this->encode)
? base64_encode((string) $value)
: (string) $value
];
break;
case $value instanceof \DateTimeInterface:
return [
'timestampValue' => $value->format(self::DATE_FORMAT)
];
break;
case $value instanceof EntityInterface:
return [
'entityValue' => $this->objectToRequest($value)
];
break;
case $value instanceof GeoPoint:
return [
'geoPointValue' => $value->point()
];
break;
case $value instanceof Key:
return [
'keyValue' => $value->keyObject()
];
break;
case $value instanceof \stdClass:
return $this->convertArrayToEntityValue((array) $value);
default:
throw new \InvalidArgumentException(
sprintf('Value of type `%s` could not be serialized', get_class($value))
);
break;
}
} | php | {
"resource": ""
} |
q16183 | EntityMapper.convertArrayToArrayValue | train | private function convertArrayToArrayValue(array $value)
{
$values = [];
foreach ($value as $val) {
// ListValues may not contain nested ListValues.
// Therefore, if an empty array is provided as part of an array,
// we can encode it as an EntityValue.
if (is_array($val) && empty($val)) {
$val = (object) $val;
}
$values[] = $this->valueObject($val);
}
return [
'arrayValue' => [
'values' => $values
]
];
} | php | {
"resource": ""
} |
q16184 | EntityMapper.convertArrayToEntityValue | train | private function convertArrayToEntityValue(array $value)
{
$excludes = $this->pluck(Entity::EXCLUDE_FROM_INDEXES, $value, false) ?: [];
$properties = [];
foreach ($value as $key => $val) {
$properties[$key] = $this->valueObject(
$val,
in_array($key, $excludes)
);
}
if (!$properties) {
$properties = (object) $properties;
}
return [
'entityValue' => [
'properties' => $properties
]
];
} | php | {
"resource": ""
} |
q16185 | EntityMapper.getPropertyValue | train | private function getPropertyValue(array $property, $className = Entity::class)
{
$type = $this->getValueType($property);
return $this->convertValue($type, $property[$type], $className);
} | php | {
"resource": ""
} |
q16186 | EntityMapper.getValueType | train | private function getValueType(array $value)
{
$keys = array_keys($value);
$types = array_values(array_filter($keys, function ($key) {
return strpos($key, 'Value') !== false;
}));
if (!empty($types)) {
return $types[0];
}
throw new \RuntimeException('Invalid entity property value given');
} | php | {
"resource": ""
} |
q16187 | ListenRequest.setAddTarget | train | public function setAddTarget($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\Firestore\V1\Target::class);
$this->writeOneof(2, $var);
return $this;
} | php | {
"resource": ""
} |
q16188 | ClusterManagerGrpcClient.DeleteCluster | train | public function DeleteCluster(\Google\Cloud\Container\V1\DeleteClusterRequest $argument,
$metadata = [], $options = []) {
return $this->_simpleRequest('/google.container.v1.ClusterManager/DeleteCluster',
$argument,
['\Google\Cloud\Container\V1\Operation', 'decode'],
$metadata, $options);
} | php | {
"resource": ""
} |
q16189 | ClusterManagerGrpcClient.RollbackNodePoolUpgrade | train | public function RollbackNodePoolUpgrade(\Google\Cloud\Container\V1\RollbackNodePoolUpgradeRequest $argument,
$metadata = [], $options = []) {
return $this->_simpleRequest('/google.container.v1.ClusterManager/RollbackNodePoolUpgrade',
$argument,
['\Google\Cloud\Container\V1\Operation', 'decode'],
$metadata, $options);
} | php | {
"resource": ""
} |
q16190 | SentimentAnalysisResult.setQueryTextSentiment | train | public function setQueryTextSentiment($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\Dialogflow\V2\Sentiment::class);
$this->query_text_sentiment = $var;
return $this;
} | php | {
"resource": ""
} |
q16191 | LanguageServiceGrpcClient.AnnotateText | train | public function AnnotateText(\Google\Cloud\Language\V1\AnnotateTextRequest $argument,
$metadata = [], $options = []) {
return $this->_simpleRequest('/google.cloud.language.v1.LanguageService/AnnotateText',
$argument,
['\Google\Cloud\Language\V1\AnnotateTextResponse', 'decode'],
$metadata, $options);
} | php | {
"resource": ""
} |
q16192 | Session.exists | train | public function exists(array $options = [])
{
try {
$this->connection->getSession($options + [
'name' => $this->name(),
'database' => $this->database
]);
return true;
} catch (NotFoundException $e) {
return false;
}
} | php | {
"resource": ""
} |
q16193 | Session.delete | train | public function delete(array $options = [])
{
return $this->connection->deleteSession($options + [
'name' => $this->name(),
'database' => $this->database
]);
} | php | {
"resource": ""
} |
q16194 | Session.name | train | public function name()
{
return SpannerClient::sessionName(
$this->projectId,
$this->instance,
$this->database,
$this->name
);
} | php | {
"resource": ""
} |
q16195 | Agent.setMatchMode | train | public function setMatchMode($var)
{
GPBUtil::checkEnum($var, \Google\Cloud\Dialogflow\V2\Agent_MatchMode::class);
$this->match_mode = $var;
return $this;
} | php | {
"resource": ""
} |
q16196 | WriteBatch.create | train | public function create($document, array $fields, array $options = [])
{
// Record whether the document is empty before any filtering.
$emptyDocument = count($fields) === 0;
list ($fields, $sentinels, $metadata) = $this->filterFields($fields);
if ($metadata['hasDelete']) {
throw new \InvalidArgumentException('Cannot delete fields when creating a document.');
}
// Cannot create a document that already exists!
$precondition = ['exists' => false];
// Enqueue an update operation if an empty document was provided,
// or if there are still fields after filtering.
$transformOptions = [];
if (!empty($fields) || $emptyDocument) {
$this->writes[] = $this->createDatabaseWrite(self::TYPE_UPDATE, $document, [
'fields' => $this->valueMapper->encodeValues($fields),
'precondition' => $precondition
] + $options);
} else {
// If no UPDATE mutation is enqueued, we need the precondition applied
// to the transform mutation.
$transformOptions = [
'precondition' => $precondition
];
}
// document transform operations are enqueued as a separate mutation.
$this->enqueueTransforms($document, $sentinels, $transformOptions);
return $this;
} | php | {
"resource": ""
} |
q16197 | WriteBatch.set | train | public function set($document, array $fields, array $options = [])
{
$merge = $this->pluck('merge', $options, false) ?: false;
// Record whether the document is empty before any filtering.
$emptyDocument = count($fields) === 0;
list ($fields, $sentinels, $metadata) = $this->filterFields($fields);
if (!$merge && $metadata['hasDelete']) {
throw new \InvalidArgumentException('Delete cannot appear in data unless `$options[\'merge\']` is set.');
}
// Enqueue a write if any of the following conditions are met
// - if there are still fields remaining after sentinels were removed
// - if the user provided an empty set to begin with
// - if the user provided only transform sentinel values AND did not specify merge behavior
// - if the user provided only delete sentinel field values.
$updateNotRequired = count($fields) === 0
&& !$emptyDocument
&& !$metadata['hasUpdateMask']
&& $metadata['hasTransform'];
$shouldEnqueueUpdate = $fields
|| $emptyDocument
|| ($updateNotRequired && !$merge)
|| $metadata['hasUpdateMask'];
if ($shouldEnqueueUpdate) {
$write = [
'fields' => $this->valueMapper->encodeValues($fields),
];
if ($merge) {
$write['updateMask'] = $this->pathsToStrings($this->encodeFieldPaths($fields), $sentinels);
}
$this->writes[] = $this->createDatabaseWrite(self::TYPE_UPDATE, $document, $write, $options);
}
// document transform operations are enqueued as a separate mutation.
$this->enqueueTransforms($document, $sentinels, $options);
return $this;
} | php | {
"resource": ""
} |
q16198 | WriteBatch.commit | train | public function commit(array $options = [])
{
unset($options['merge'], $options['precondition']);
$response = $this->connection->commit(array_filter([
'database' => $this->database,
'writes' => $this->writes,
'transaction' => $this->transaction
]) + $options);
if (isset($response['commitTime'])) {
$time = $this->parseTimeString($response['commitTime']);
$response['commitTime'] = new Timestamp($time[0], $time[1]);
}
if (isset($response['writeResults'])) {
foreach ($response['writeResults'] as &$result) {
if (isset($result['updateTime'])) {
$time = $this->parseTimeString($result['updateTime']);
$result['updateTime'] = new Timestamp($time[0], $time[1]);
}
}
}
return $response;
} | php | {
"resource": ""
} |
q16199 | WriteBatch.enqueueTransforms | train | private function enqueueTransforms($document, array $transforms, array $options = [])
{
$operations = [];
foreach ($transforms as $transform) {
if (!($transform instanceof DocumentTransformInterface)) {
continue;
}
$args = $transform->args();
if (!$transform->sendRaw()) {
if (is_array($args) && !$this->isAssoc($args)) {
$args = $this->valueMapper->encodeArrayValue($args);
} else {
$args = $this->valueMapper->encodeValue($args);
}
}
$operations[] = [
'fieldPath' => $transform->fieldPath()->pathString(),
$transform->key() => $args
];
}
if ($operations) {
$this->writes[] = $this->createDatabaseWrite(self::TYPE_TRANSFORM, $document, [
'fieldTransforms' => $operations
] + $options);
}
} | php | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.