_id stringlengths 2 7 | title stringlengths 3 151 | partition stringclasses 3
values | text stringlengths 83 13k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q15600 | ListEventsResponse.setErrorEvents | train | public function setErrorEvents($var)
{
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\ErrorReporting\V1beta1\ErrorEvent::class);
$this->error_events = $arr;
return $this;
} | php | {
"resource": ""
} |
q15601 | InspectionRuleSet.setRules | train | public function setRules($var)
{
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Dlp\V2\InspectionRule::class);
$this->rules = $arr;
return $this;
} | php | {
"resource": ""
} |
q15602 | PersonStructuredName.setSuffixes | train | public function setSuffixes($var)
{
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING);
$this->suffixes = $arr;
return $this;
} | php | {
"resource": ""
} |
q15603 | PersonStructuredName.setPrefixes | train | public function setPrefixes($var)
{
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING);
$this->prefixes = $arr;
return $this;
} | php | {
"resource": ""
} |
q15604 | UpdateInstanceRequest.setInstance | train | public function setInstance($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\Redis\V1\Instance::class);
$this->instance = $var;
return $this;
} | php | {
"resource": ""
} |
q15605 | FirestoreGapicClient.anyPathName | train | public static function anyPathName($project, $database, $document, $anyPath)
{
return self::getAnyPathNameTemplate()->render([
'project' => $project,
'database' => $database,
'document' => $document,
'any_path' => $anyPath,
]);
} | php | {
"resource": ""
} |
q15606 | FirestoreGapicClient.documentPathName | train | public static function documentPathName($project, $database, $documentPath)
{
return self::getDocumentPathNameTemplate()->render([
'project' => $project,
'database' => $database,
'document_path' => $documentPath,
]);
} | php | {
"resource": ""
} |
q15607 | FirestoreGapicClient.commit | train | public function commit($database, $writes, array $optionalArgs = [])
{
$request = new CommitRequest();
$request->setDatabase($database);
$request->setWrites($writes);
if (isset($optionalArgs['transaction'])) {
$request->setTransaction($optionalArgs['transaction']);
}
$requestParams = new RequestParamsHeaderDescriptor([
'database' => $request->getDatabase(),
]);
$optionalArgs['headers'] = isset($optionalArgs['headers'])
? array_merge($requestParams->getHeader(), $optionalArgs['headers'])
: $requestParams->getHeader();
return $this->startCall(
'Commit',
CommitResponse::class,
$optionalArgs,
$request
)->wait();
} | php | {
"resource": ""
} |
q15608 | SimpleJobTrait.setSimpleJobProperties | train | private function setSimpleJobProperties(array $options = [])
{
if (!isset($options['identifier'])) {
throw new \InvalidArgumentException(
'A valid identifier is required in order to register a job.'
);
}
$options += [
'configStorage' => null,
];
$this->setSerializableClientOptions($options);
$identifier = $options['identifier'];
$configStorage = $options['configStorage'] ?: $this->defaultConfigStorage();
$result = $configStorage->lock();
if ($result === false) {
return false;
}
$config = $configStorage->load();
$config->registerJob(
$identifier,
function ($id) use ($identifier, $options) {
return new SimpleJob($identifier, [$this, 'run'], $id, $options);
}
);
try {
$result = $configStorage->save($config);
} finally {
$configStorage->unlock();
}
return $result;
} | php | {
"resource": ""
} |
q15609 | LoggingClient.psrBatchLogger | train | public static function psrBatchLogger($name, array $options = [])
{
$client = array_key_exists('clientConfig', $options)
? new self($options['clientConfig'])
: new self();
// Force enabling batch.
$options['batchEnabled'] = true;
return $client->psrLogger($name, $options);
} | php | {
"resource": ""
} |
q15610 | LoggingClient.createSink | train | public function createSink($name, $destination, array $options = [])
{
$response = $this->connection->createSink($options + [
'parent' => $this->formattedProjectName,
'name' => $name,
'destination' => $destination,
'outputVersionFormat' => 'VERSION_FORMAT_UNSPECIFIED'
]);
return new Sink($this->connection, $name, $this->projectId, $response);
} | php | {
"resource": ""
} |
q15611 | LoggingClient.sinks | train | public function sinks(array $options = [])
{
$resultLimit = $this->pluck('resultLimit', $options, false);
return new ItemIterator(
new PageIterator(
function (array $sink) {
return new Sink($this->connection, $sink['name'], $this->projectId, $sink);
},
[$this->connection, 'listSinks'],
$options + ['parent' => $this->formattedProjectName],
[
'itemsKey' => 'sinks',
'resultLimit' => $resultLimit
]
)
);
} | php | {
"resource": ""
} |
q15612 | LoggingClient.createMetric | train | public function createMetric($name, $filter, array $options = [])
{
$response = $this->connection->createMetric($options + [
'parent' => $this->formattedProjectName,
'name' => $name,
'filter' => $filter
]);
return new Metric($this->connection, $name, $this->projectId, $response);
} | php | {
"resource": ""
} |
q15613 | LoggingClient.metrics | train | public function metrics(array $options = [])
{
$resultLimit = $this->pluck('resultLimit', $options, false);
return new ItemIterator(
new PageIterator(
function (array $metric) {
return new Metric($this->connection, $metric['name'], $this->projectId, $metric);
},
[$this->connection, 'listMetrics'],
$options + ['parent' => $this->formattedProjectName],
[
'itemsKey' => 'metrics',
'resultLimit' => $resultLimit
]
)
);
} | php | {
"resource": ""
} |
q15614 | LoggingClient.entries | train | public function entries(array $options = [])
{
$resultLimit = $this->pluck('resultLimit', $options, false);
$resourceNames = ['projects/' . $this->projectId];
if (isset($options['projectIds'])) {
foreach ($options['projectIds'] as $projectId) {
$resourceNames[] = 'projects/' . $projectId;
}
unset($options['projectIds']);
}
if (isset($options['resourceNames'])) {
$options['resourceNames'] = array_merge($resourceNames, $options['projectIds']);
} else {
$options['resourceNames'] = $resourceNames;
}
return new ItemIterator(
new PageIterator(
function (array $entry) {
return new Entry($entry);
},
[$this->connection, 'listEntries'],
$options,
[
'itemsKey' => 'entries',
'resultLimit' => $resultLimit
]
)
);
} | php | {
"resource": ""
} |
q15615 | LoggingClient.psrLogger | train | public function psrLogger($name, array $options = [])
{
$messageKey = null;
if (isset($options['messageKey'])) {
$messageKey = $options['messageKey'];
unset($options['messageKey']);
}
$psrLoggerOptions = $this->pluckArray([
'metadataProvider',
'batchEnabled',
'debugOutput',
'batchOptions',
'clientConfig',
'batchRunner',
'closureSerializer',
'debugOutputResource'
], $options);
return new PsrLogger(
$this->logger($name, $options),
$messageKey,
$psrLoggerOptions + [
'clientConfig' => $this->config
]
);
} | php | {
"resource": ""
} |
q15616 | LoggingClient.logger | train | public function logger($name, array $options = [])
{
return new Logger(
$this->connection,
$name,
$this->projectId,
isset($options['resource']) ? $options['resource'] : null,
isset($options['labels']) ? $options['labels'] : null
);
} | php | {
"resource": ""
} |
q15617 | ListSourcesResponse.setSources | train | public function setSources($var)
{
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\SecurityCenter\V1\Source::class);
$this->sources = $arr;
return $this;
} | php | {
"resource": ""
} |
q15618 | ClusterSelector.setClusterLabels | train | public function setClusterLabels($var)
{
$arr = GPBUtil::checkMapField($var, \Google\Protobuf\Internal\GPBType::STRING, \Google\Protobuf\Internal\GPBType::STRING);
$this->cluster_labels = $arr;
return $this;
} | php | {
"resource": ""
} |
q15619 | Bucket.upload | train | public function upload($data, array $options = [])
{
if ($this->isObjectNameRequired($data) && !isset($options['name'])) {
throw new \InvalidArgumentException('A name is required when data is of type string or null.');
}
$encryptionKey = isset($options['encryptionKey']) ? $options['encryptionKey'] : null;
$encryptionKeySHA256 = isset($options['encryptionKeySHA256']) ? $options['encryptionKeySHA256'] : null;
$response = $this->connection->insertObject(
$this->formatEncryptionHeaders($options) + $this->identity + [
'data' => $data
]
)->upload();
return new StorageObject(
$this->connection,
$response['name'],
$this->identity['bucket'],
$response['generation'],
$response,
$encryptionKey,
$encryptionKeySHA256
);
} | php | {
"resource": ""
} |
q15620 | Bucket.getResumableUploader | train | public function getResumableUploader($data, array $options = [])
{
if ($this->isObjectNameRequired($data) && !isset($options['name'])) {
throw new \InvalidArgumentException('A name is required when data is of type string or null.');
}
return $this->connection->insertObject(
$this->formatEncryptionHeaders($options) + $this->identity + [
'data' => $data,
'resumable' => true
]
);
} | php | {
"resource": ""
} |
q15621 | Bucket.getStreamableUploader | train | public function getStreamableUploader($data, array $options = [])
{
if ($this->isObjectNameRequired($data) && !isset($options['name'])) {
throw new \InvalidArgumentException('A name is required when data is of type string or null.');
}
return $this->connection->insertObject(
$this->formatEncryptionHeaders($options) + $this->identity + [
'data' => $data,
'streamable' => true,
'validate' => false
]
);
} | php | {
"resource": ""
} |
q15622 | Bucket.objects | train | public function objects(array $options = [])
{
$resultLimit = $this->pluck('resultLimit', $options, false);
return new ObjectIterator(
new ObjectPageIterator(
function (array $object) {
return new StorageObject(
$this->connection,
$object['name'],
$this->identity['bucket'],
isset($object['generation']) ? $object['generation'] : null,
$object + array_filter([
'requesterProjectId' => $this->identity['userProject']
])
);
},
[$this->connection, 'listObjects'],
$options + $this->identity,
['resultLimit' => $resultLimit]
)
);
} | php | {
"resource": ""
} |
q15623 | Bucket.createNotification | train | public function createNotification($topic, array $options = [])
{
$res = $this->connection->insertNotification($options + $this->identity + [
'topic' => $this->getFormattedTopic($topic),
'payload_format' => 'JSON_API_V1'
]);
return new Notification(
$this->connection,
$res['id'],
$this->identity['bucket'],
$res + [
'requesterProjectId' => $this->identity['userProject']
]
);
} | php | {
"resource": ""
} |
q15624 | Bucket.notifications | train | public function notifications(array $options = [])
{
$resultLimit = $this->pluck('resultLimit', $options, false);
return new ItemIterator(
new PageIterator(
function (array $notification) {
return new Notification(
$this->connection,
$notification['id'],
$this->identity['bucket'],
$notification + [
'requesterProjectId' => $this->identity['userProject']
]
);
},
[$this->connection, 'listNotifications'],
$options + $this->identity,
['resultLimit' => $resultLimit]
)
);
} | php | {
"resource": ""
} |
q15625 | Bucket.update | train | public function update(array $options = [])
{
if (isset($options['lifecycle']) && $options['lifecycle'] instanceof Lifecycle) {
$options['lifecycle'] = $options['lifecycle']->toArray();
}
return $this->info = $this->connection->patchBucket($options + $this->identity);
} | php | {
"resource": ""
} |
q15626 | Bucket.compose | train | public function compose(array $sourceObjects, $name, array $options = [])
{
if (count($sourceObjects) < 2) {
throw new \InvalidArgumentException('Must provide at least two objects to compose.');
}
$options += [
'destinationBucket' => $this->name(),
'destinationObject' => $name,
'destinationPredefinedAcl' => isset($options['predefinedAcl']) ? $options['predefinedAcl'] : null,
'destination' => isset($options['metadata']) ? $options['metadata'] : null,
'userProject' => $this->identity['userProject'],
'sourceObjects' => array_map(function ($sourceObject) {
$name = null;
$generation = null;
if ($sourceObject instanceof StorageObject) {
$name = $sourceObject->name();
$generation = isset($sourceObject->identity()['generation'])
? $sourceObject->identity()['generation']
: null;
}
return array_filter([
'name' => $name ?: $sourceObject,
'generation' => $generation
]);
}, $sourceObjects)
];
if (!isset($options['destination']['contentType'])) {
$options['destination']['contentType'] = Psr7\mimetype_from_filename($name);
}
if ($options['destination']['contentType'] === null) {
throw new \InvalidArgumentException('A content type could not be detected and must be provided manually.');
}
unset($options['metadata']);
unset($options['predefinedAcl']);
$response = $this->connection->composeObject(array_filter($options));
return new StorageObject(
$this->connection,
$response['name'],
$this->identity['bucket'],
$response['generation'],
$response + array_filter([
'requesterProjectId' => $this->identity['userProject']
])
);
} | php | {
"resource": ""
} |
q15627 | Bucket.reload | train | public function reload(array $options = [])
{
return $this->info = $this->connection->getBucket($options + $this->identity);
} | php | {
"resource": ""
} |
q15628 | Bucket.iam | train | public function iam()
{
if (!$this->iam) {
$this->iam = new Iam(
new IamBucket($this->connection),
$this->identity['bucket'],
[
'parent' => null,
'args' => $this->identity
]
);
}
return $this->iam;
} | php | {
"resource": ""
} |
q15629 | Bucket.lockRetentionPolicy | train | public function lockRetentionPolicy(array $options = [])
{
if (!isset($options['ifMetagenerationMatch'])) {
if (!isset($this->info['metageneration'])) {
throw new \BadMethodCallException(
'No metageneration value was detected. Please either provide ' .
'a value explicitly or ensure metadata is loaded through a ' .
'call such as Bucket::reload().'
);
}
$options['ifMetagenerationMatch'] = $this->info['metageneration'];
}
return $this->info = $this->connection->lockRetentionPolicy(
$options + $this->identity
);
} | php | {
"resource": ""
} |
q15630 | Bucket.signedUrl | train | public function signedUrl($expires, array $options = [])
{
// May be overridden for testing.
$signingHelper = $this->pluck('helper', $options, false)
?: SigningHelper::getHelper();
$resource = sprintf(
'/%s',
$this->identity['bucket']
);
return $signingHelper->sign(
$this->connection,
$expires,
$resource,
null,
$options
);
} | php | {
"resource": ""
} |
q15631 | Bucket.getFormattedTopic | train | private function getFormattedTopic($topic)
{
if ($topic instanceof Topic) {
return sprintf(self::NOTIFICATION_TEMPLATE, $topic->name());
}
if (!is_string($topic)) {
throw new \InvalidArgumentException(
'$topic may only be a string or instance of Google\Cloud\PubSub\Topic'
);
}
if (preg_match('/projects\/[^\/]*\/topics\/(.*)/', $topic) === 1) {
return sprintf(self::NOTIFICATION_TEMPLATE, $topic);
}
if (!$this->projectId) {
throw new GoogleException(
'No project ID was provided, ' .
'and we were unable to detect a default project ID.'
);
}
return sprintf(
self::NOTIFICATION_TEMPLATE,
sprintf(self::TOPIC_TEMPLATE, $this->projectId, $topic)
);
} | php | {
"resource": ""
} |
q15632 | Trigger.setSchedule | train | public function setSchedule($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\Dlp\V2\Schedule::class);
$this->writeOneof(1, $var);
return $this;
} | php | {
"resource": ""
} |
q15633 | DocumentTransform.setFieldTransforms | train | public function setFieldTransforms($var)
{
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Firestore\V1beta1\DocumentTransform\FieldTransform::class);
$this->field_transforms = $arr;
return $this;
} | php | {
"resource": ""
} |
q15634 | PredictResponse.setPayload | train | public function setPayload($var)
{
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\AutoMl\V1beta1\AnnotationPayload::class);
$this->payload = $arr;
return $this;
} | php | {
"resource": ""
} |
q15635 | ListTimeSeriesRequest.setInterval | train | public function setInterval($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\Monitoring\V3\TimeInterval::class);
$this->interval = $var;
return $this;
} | php | {
"resource": ""
} |
q15636 | ListTimeSeriesRequest.setAggregation | train | public function setAggregation($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\Monitoring\V3\Aggregation::class);
$this->aggregation = $var;
return $this;
} | php | {
"resource": ""
} |
q15637 | ListTimeSeriesRequest.setView | train | public function setView($var)
{
GPBUtil::checkEnum($var, \Google\Cloud\Monitoring\V3\ListTimeSeriesRequest_TimeSeriesView::class);
$this->view = $var;
return $this;
} | php | {
"resource": ""
} |
q15638 | FaceFrame.setNormalizedBoundingBoxes | train | public function setNormalizedBoundingBoxes($var)
{
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\VideoIntelligence\V1\NormalizedBoundingBox::class);
$this->normalized_bounding_boxes = $arr;
return $this;
} | php | {
"resource": ""
} |
q15639 | AuditLog.setAuthenticationInfo | train | public function setAuthenticationInfo($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\Audit\AuthenticationInfo::class);
$this->authentication_info = $var;
return $this;
} | php | {
"resource": ""
} |
q15640 | AuditLog.setRequestMetadata | train | public function setRequestMetadata($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\Audit\RequestMetadata::class);
$this->request_metadata = $var;
return $this;
} | php | {
"resource": ""
} |
q15641 | NodePool.setConfig | train | public function setConfig($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\Container\V1\NodeConfig::class);
$this->config = $var;
return $this;
} | php | {
"resource": ""
} |
q15642 | NodePool.setAutoscaling | train | public function setAutoscaling($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\Container\V1\NodePoolAutoscaling::class);
$this->autoscaling = $var;
return $this;
} | php | {
"resource": ""
} |
q15643 | NodePool.setManagement | train | public function setManagement($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\Container\V1\NodeManagement::class);
$this->management = $var;
return $this;
} | php | {
"resource": ""
} |
q15644 | ListUptimeCheckConfigsResponse.setUptimeCheckConfigs | train | public function setUptimeCheckConfigs($var)
{
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Monitoring\V3\UptimeCheckConfig::class);
$this->uptime_check_configs = $arr;
return $this;
} | php | {
"resource": ""
} |
q15645 | LocationMetadata.setAvailableZones | train | public function setAvailableZones($var)
{
$arr = GPBUtil::checkMapField($var, \Google\Protobuf\Internal\GPBType::STRING, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Redis\V1\ZoneMetadata::class);
$this->available_zones = $arr;
return $this;
} | php | {
"resource": ""
} |
q15646 | StructType.add | train | public function add($name, $type)
{
$invalidIntTypes = [
Database::TYPE_STRUCT,
Database::TYPE_ARRAY
];
if (is_int($type) && in_array($type, $invalidIntTypes)) {
throw new \InvalidArgumentException(
'`Database::TYPE_ARRAY` and `Database::TYPE_STRUCT` are not valid as struct types. ' .
'Instead provide `Google\Cloud\Spanner\ArrayType` or `Google\Cloud\Spanner\StructType`.'
);
}
$child = null;
if ($type instanceof StructType) {
$child = $type;
$type = Database::TYPE_STRUCT;
} elseif ($type instanceof ArrayType) {
$child = $type;
$type = Database::TYPE_ARRAY;
}
if (!in_array($type, ValueMapper::$allowedTypes)) {
throw new \InvalidArgumentException(sprintf(
'Field type `%s` is not valid.',
$type
));
}
$this->fields[] = [
'name' => $name,
'type' => $type,
'child' => $child
];
return $this;
} | php | {
"resource": ""
} |
q15647 | CreateAppProfileRequest.setAppProfile | train | public function setAppProfile($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\Bigtable\Admin\V2\AppProfile::class);
$this->app_profile = $var;
return $this;
} | php | {
"resource": ""
} |
q15648 | UpdateExclusionRequest.setExclusion | train | public function setExclusion($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\Logging\V2\LogExclusion::class);
$this->exclusion = $var;
return $this;
} | php | {
"resource": ""
} |
q15649 | TraceServiceGapicClient.spanName | train | public static function spanName($project, $trace, $span)
{
return self::getSpanNameTemplate()->render([
'project' => $project,
'trace' => $trace,
'span' => $span,
]);
} | php | {
"resource": ""
} |
q15650 | ConcurrencyControlTrait.applyEtagHeader | train | private function applyEtagHeader(array $options, $argName = 'etag')
{
if (isset($options[$argName])) {
if (!isset($options['restOptions'])) {
$options['restOptions'] = [];
}
if (!isset($options['restOptions']['headers'])) {
$options['restOptions']['headers'] = [];
}
$options['restOptions']['headers']['If-Match'] = $options[$argName];
}
return $options;
} | php | {
"resource": ""
} |
q15651 | SetNetworkPolicyRequest.setNetworkPolicy | train | public function setNetworkPolicy($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\Container\V1\NetworkPolicy::class);
$this->network_policy = $var;
return $this;
} | php | {
"resource": ""
} |
q15652 | Finding.setLocation | train | public function setLocation($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\Dlp\V2\Location::class);
$this->location = $var;
return $this;
} | php | {
"resource": ""
} |
q15653 | CreateSessionEntityTypeRequest.setSessionEntityType | train | public function setSessionEntityType($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\Dialogflow\V2\SessionEntityType::class);
$this->session_entity_type = $var;
return $this;
} | php | {
"resource": ""
} |
q15654 | CreateSinkRequest.setSink | train | public function setSink($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\Logging\V2\LogSink::class);
$this->sink = $var;
return $this;
} | php | {
"resource": ""
} |
q15655 | ExplicitContentAnnotation.setFrames | train | public function setFrames($var)
{
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\VideoIntelligence\V1beta2\ExplicitContentFrame::class);
$this->frames = $arr;
return $this;
} | php | {
"resource": ""
} |
q15656 | Query.setProjection | train | public function setProjection($var)
{
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Datastore\V1\Projection::class);
$this->projection = $arr;
return $this;
} | php | {
"resource": ""
} |
q15657 | ServerConfig.setValidNodeVersions | train | public function setValidNodeVersions($var)
{
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING);
$this->valid_node_versions = $arr;
return $this;
} | php | {
"resource": ""
} |
q15658 | ServerConfig.setValidImageTypes | train | public function setValidImageTypes($var)
{
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING);
$this->valid_image_types = $arr;
return $this;
} | php | {
"resource": ""
} |
q15659 | ServerConfig.setValidMasterVersions | train | public function setValidMasterVersions($var)
{
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING);
$this->valid_master_versions = $arr;
return $this;
} | php | {
"resource": ""
} |
q15660 | StructuredQuery.setFrom | train | public function setFrom($var)
{
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Firestore\V1\StructuredQuery\CollectionSelector::class);
$this->from = $arr;
return $this;
} | php | {
"resource": ""
} |
q15661 | StructuredQuery.setStartAt | train | public function setStartAt($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\Firestore\V1\Cursor::class);
$this->start_at = $var;
return $this;
} | php | {
"resource": ""
} |
q15662 | Device.setConfig | train | public function setConfig($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\Iot\V1\DeviceConfig::class);
$this->config = $var;
return $this;
} | php | {
"resource": ""
} |
q15663 | Device.setGatewayConfig | train | public function setGatewayConfig($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\Iot\V1\GatewayConfig::class);
$this->gateway_config = $var;
return $this;
} | php | {
"resource": ""
} |
q15664 | ListActiveBreakpointsResponse.setBreakpoints | train | public function setBreakpoints($var)
{
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Debugger\V2\Breakpoint::class);
$this->breakpoints = $arr;
return $this;
} | php | {
"resource": ""
} |
q15665 | Span.info | train | public function info()
{
$data = [
'displayName' => [
'value' => $this->name
],
'spanId' => $this->spanId,
'startTime' => $this->startTime,
'endTime' => $this->endTime
];
if ($this->parentSpanId) {
$data['parentSpanId'] = $this->parentSpanId;
}
if ($this->attributes) {
$data['attributes'] = $this->attributes->info();
}
if ($this->timeEvents) {
$data['timeEvents'] = [
'timeEvent' => array_map(function ($timeEvent) {
return $timeEvent->info();
}, $this->timeEvents)
];
}
if ($this->links) {
$data['links'] = [
'link' => array_map(function ($link) {
return $link->info();
}, $this->links)
];
}
if ($this->status) {
$data['status'] = $this->status->info();
}
if ($this->stackTrace) {
$data['stackTrace'] = $this->stackTrace->info();
}
if ($this->sameProcessAsParentSpan !== null) {
$data['sameProcessAsParentSpan'] = $this->sameProcessAsParentSpan;
}
return $data;
} | php | {
"resource": ""
} |
q15666 | Span.addTimeEvent | train | public function addTimeEvent(TimeEvent $event)
{
if (!$this->timeEvents) {
$this->timeEvents = [];
}
$this->timeEvents[] = $event;
} | php | {
"resource": ""
} |
q15667 | Span.addLink | train | public function addLink(Link $link)
{
if (!$this->links) {
$this->links = [];
}
$this->links[] = $link;
} | php | {
"resource": ""
} |
q15668 | Operation.keys | train | public function keys($kind, array $options = [])
{
$options += [
'number' => 1,
'ancestors' => [],
'id' => null,
'name' => null
];
if ($options['number'] < 1) {
throw new \InvalidArgumentException('Number of keys cannot be less than 1.');
}
$path = [];
if (count($options['ancestors']) > 0) {
$path = $options['ancestors'];
}
$path[] = array_filter([
'kind' => $kind,
'id' => $options['id'],
'name' => $options['name']
]);
$key = new Key($this->projectId, [
'path' => $path,
'namespaceId' => $this->namespaceId
]);
$keys = [$key];
for ($i = 1; $i < $options['number']; $i++) {
$keys[] = clone $key;
}
return $keys;
} | php | {
"resource": ""
} |
q15669 | Operation.entity | train | public function entity($key = null, array $entity = [], array $options = [])
{
$options += [
'className' => null
];
if ($key && !is_string($key) && !($key instanceof Key)) {
throw new \InvalidArgumentException(
'$key must be an instance of Key or a string'
);
}
if (is_string($key)) {
$key = $this->key($key);
}
$className = $options['className'];
if (!is_null($className) && !is_subclass_of($className, EntityInterface::class)) {
throw new \InvalidArgumentException(sprintf(
'Given classname %s must implement EntityInterface',
$className
));
}
if (is_null($className)) {
$className = Entity::class;
}
return $className::build($key, $entity, $options);
} | php | {
"resource": ""
} |
q15670 | Operation.beginTransaction | train | public function beginTransaction($transactionOptions, array $options = [])
{
$res = $this->connection->beginTransaction([
'projectId' => $this->projectId,
'transactionOptions' => $transactionOptions
] + $options);
return $res['transaction'];
} | php | {
"resource": ""
} |
q15671 | Operation.allocateIds | train | public function allocateIds(array $keys, array $options = [])
{
// Validate the given keys. First check types, then state of each.
// The API will throw a 400 if the key is named, but it's an easy
// check we can handle before going to the API to save a request.
// @todo replace with json schema
$this->validateBatch($keys, Key::class, function ($key) {
if ($key->state() !== Key::STATE_INCOMPLETE) {
throw new \InvalidArgumentException(sprintf(
'Given $key is in an invalid state. Can only allocate IDs for incomplete keys. ' .
'Given path was %s',
(string) $key
));
}
});
$serviceKeys = [];
foreach ($keys as $key) {
$serviceKeys[] = $key->keyObject();
}
$res = $this->connection->allocateIds([
'projectId' => $this->projectId,
'keys' => $serviceKeys
] + $options);
if (isset($res['keys'])) {
foreach ($res['keys'] as $index => $key) {
if (!isset($keys[$index])) {
continue;
}
$end = end($key['path']);
$id = $end['id'];
$keys[$index]->setLastElementIdentifier($id);
}
}
return $keys;
} | php | {
"resource": ""
} |
q15672 | Operation.lookup | train | public function lookup(array $keys, array $options = [])
{
$options += [
'className' => Entity::class,
'sort' => false
];
$serviceKeys = [];
$this->validateBatch($keys, Key::class, function ($key) use (&$serviceKeys) {
if ($key->state() !== Key::STATE_NAMED) {
throw new \InvalidArgumentException(sprintf(
'Given $key is in an invalid state. Can only lookup records when given a complete key. ' .
'Given path was %s',
(string) $key
));
}
$serviceKeys[] = $key->keyObject();
});
$res = $this->connection->lookup($options + $this->readOptions($options) + [
'projectId' => $this->projectId,
'keys' => $serviceKeys
]);
$result = [];
if (isset($res['found'])) {
foreach ($res['found'] as $found) {
$result['found'][] = $this->mapEntityResult($found, $options['className']);
}
if ($options['sort']) {
$result['found'] = $this->sortEntities($result['found'], $keys);
}
}
if (isset($res['missing'])) {
$result['missing'] = [];
foreach ($res['missing'] as $missing) {
$key = $this->key(
$missing['entity']['key']['path'],
$missing['entity']['key']['partitionId']
);
$result['missing'][] = $key;
}
}
if (isset($res['deferred'])) {
$result['deferred'] = [];
foreach ($res['deferred'] as $deferred) {
$key = $this->key(
$deferred['path'],
$deferred['partitionId']
);
$result['deferred'][] = $key;
}
}
return $result;
} | php | {
"resource": ""
} |
q15673 | Operation.runQuery | train | public function runQuery(QueryInterface $query, array $options = [])
{
$options += [
'className' => Entity::class,
'namespaceId' => $this->namespaceId
];
$iteratorConfig = [
'itemsKey' => 'batch.entityResults',
'resultTokenKey' => 'query.startCursor',
'nextResultTokenKey' => 'batch.endCursor',
'setNextResultTokenCondition' => function ($res) use ($query) {
if (isset($res['batch']['moreResults'])) {
$moreResultsType = $res['batch']['moreResults'];
// Transform gRPC enum to string
if (is_numeric($moreResultsType)) {
$moreResultsType = MoreResultsType::name($moreResultsType);
}
return $query->canPaginate() && $moreResultsType === 'NOT_FINISHED';
}
return false;
}
];
$runQueryObj = clone $query;
$runQueryFn = function (array $args = []) use (&$runQueryObj, $options) {
$args += [
'query' => []
];
// The iterator provides the startCursor for subsequent pages as an argument.
$requestQueryArr = $args['query'] + $runQueryObj->queryObject();
$request = [
'projectId' => $this->projectId,
'partitionId' => $this->partitionId($this->projectId, $options['namespaceId']),
$runQueryObj->queryKey() => $requestQueryArr
] + $this->readOptions($options) + $options;
$res = $this->connection->runQuery($request);
// When executing a GQL Query, the server will compute a query object
// and return it with the first response batch.
// Automatic pagination with GQL is accomplished by requesting
// subsequent pages with this query object, and discarding the GQL
// query. This is done by replacing the GQL object with a Query
// instance prior to the next iteration of the page.
if (isset($res['query'])) {
$runQueryObj = new Query($this->entityMapper, $res['query']);
}
return $res;
};
return new EntityIterator(
new EntityPageIterator(
function (array $entityResult) use ($options) {
return $this->mapEntityResult($entityResult, $options['className']);
},
$runQueryFn,
[],
$iteratorConfig
)
);
} | php | {
"resource": ""
} |
q15674 | Operation.commit | train | public function commit(array $mutations, array $options = [])
{
$options += [
'transaction' => null
];
$res = $this->connection->commit($options + [
'mode' => ($options['transaction']) ? 'TRANSACTIONAL' : 'NON_TRANSACTIONAL',
'mutations' => $mutations,
'projectId' => $this->projectId
]);
return $res;
} | php | {
"resource": ""
} |
q15675 | Operation.allocateIdsToEntities | train | public function allocateIdsToEntities(array $entities)
{
$this->validateBatch($entities, EntityInterface::class);
$incompleteKeys = [];
foreach ($entities as $entity) {
if ($entity->key()->state() === Key::STATE_INCOMPLETE) {
$incompleteKeys[] = $entity->key();
}
}
if (!empty($incompleteKeys)) {
$keys = $this->allocateIds($incompleteKeys);
}
return $entities;
} | php | {
"resource": ""
} |
q15676 | Operation.mutation | train | public function mutation(
$operation,
$input,
$type,
$baseVersion = null
) {
// If the given element is an EntityInterface, it will use that baseVersion.
if ($input instanceof EntityInterface) {
$baseVersion = $input->baseVersion();
$data = $this->entityMapper->objectToRequest($input);
if (!$input->key()) {
throw new \InvalidArgumentException('Base entities must provide a datastore key.');
}
} elseif ($input instanceof Key) {
$data = $input->keyObject();
} else {
throw new \InvalidArgumentException(sprintf(
'Input must be a Key or Entity, %s given',
get_class($input)
));
}
return array_filter([
$operation => $data,
'baseVersion' => $baseVersion
]);
} | php | {
"resource": ""
} |
q15677 | Operation.checkOverwrite | train | public function checkOverwrite(array $entities, $allowOverwrite = false)
{
$this->validateBatch($entities, EntityInterface::class);
foreach ($entities as $entity) {
if (!$entity->populatedByService() && !$allowOverwrite) {
throw new \InvalidArgumentException(sprintf(
'Given entity cannot be saved because it may overwrite an '.
'existing record. When updating manually created entities, '.
'please set the options `$allowOverwrite` flag to `true`. '.
'Invalid entity key was %s',
(string) $entity->key()
));
}
}
} | php | {
"resource": ""
} |
q15678 | Operation.mapEntityResult | train | private function mapEntityResult(array $result, $class)
{
$entity = $result['entity'];
$namespaceId = (isset($entity['key']['partitionId']['namespaceId']))
? $entity['key']['partitionId']['namespaceId']
: null;
$key = new Key($this->projectId, [
'path' => $entity['key']['path'],
'namespaceId' => $namespaceId
]);
if (is_array($class)) {
$lastPathElement = $key->pathEnd();
if (!array_key_exists($lastPathElement['kind'], $class)) {
throw new \InvalidArgumentException(sprintf(
'No class found for kind %s',
$lastPathElement['kind']
));
}
$className = $class[$lastPathElement['kind']];
} else {
$className = $class;
}
$properties = [];
$excludes = [];
$meanings = [];
if (isset($entity['properties'])) {
$res = $this->entityMapper->responseToEntityProperties($entity['properties'], $className);
$properties = $res['properties'];
$excludes = $res['excludes'];
$meanings = $res['meanings'];
}
return $this->entity($key, $properties, [
'cursor' => (isset($result['cursor']))
? $result['cursor']
: null,
'baseVersion' => (isset($result['version']))
? $result['version']
: null,
'className' => $className,
'populatedByService' => true,
'excludeFromIndexes' => $excludes,
'meanings' => $meanings
]);
} | php | {
"resource": ""
} |
q15679 | Operation.readOptions | train | private function readOptions(array $options = [])
{
$options += [
'readConsistency' => null,
'transaction' => null
];
$readOptions = array_filter([
'readConsistency' => $options['readConsistency'],
'transaction' => $options['transaction']
]);
return array_filter([
'readOptions' => $readOptions
]);
} | php | {
"resource": ""
} |
q15680 | CreateInstanceRequest.setInstance | train | public function setInstance($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\Bigtable\Admin\V2\Instance::class);
$this->instance = $var;
return $this;
} | php | {
"resource": ""
} |
q15681 | Task.setLastAttempt | train | public function setLastAttempt($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\Tasks\V2\Attempt::class);
$this->last_attempt = $var;
return $this;
} | php | {
"resource": ""
} |
q15682 | RedactImageResponse.setInspectResult | train | public function setInspectResult($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\Dlp\V2\InspectResult::class);
$this->inspect_result = $var;
return $this;
} | php | {
"resource": ""
} |
q15683 | Dataset.setTranslationDatasetMetadata | train | public function setTranslationDatasetMetadata($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\AutoMl\V1beta1\TranslationDatasetMetadata::class);
$this->writeOneof(23, $var);
return $this;
} | php | {
"resource": ""
} |
q15684 | Dataset.setImageClassificationDatasetMetadata | train | public function setImageClassificationDatasetMetadata($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\AutoMl\V1beta1\ImageClassificationDatasetMetadata::class);
$this->writeOneof(24, $var);
return $this;
} | php | {
"resource": ""
} |
q15685 | Dataset.setTextClassificationDatasetMetadata | train | public function setTextClassificationDatasetMetadata($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\AutoMl\V1beta1\TextClassificationDatasetMetadata::class);
$this->writeOneof(25, $var);
return $this;
} | php | {
"resource": ""
} |
q15686 | Job.setSparkSqlJob | train | public function setSparkSqlJob($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\Dataproc\V1beta2\SparkSqlJob::class);
$this->writeOneof(12, $var);
return $this;
} | php | {
"resource": ""
} |
q15687 | Job.setStatusHistory | train | public function setStatusHistory($var)
{
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Dataproc\V1beta2\JobStatus::class);
$this->status_history = $arr;
return $this;
} | php | {
"resource": ""
} |
q15688 | Bootstrap.init | train | public static function init(PsrLogger $psrLogger = null)
{
self::$psrLogger = $psrLogger ?: (new LoggingClient())
->psrLogger(self::DEFAULT_LOGNAME, [
'batchEnabled' => true,
'debugOutput' => true,
'batchOptions' => [
'numWorkers' => 2
]
]);
register_shutdown_function([self::class, 'shutdownHandler']);
set_exception_handler([self::class, 'exceptionHandler']);
set_error_handler([self::class, 'errorHandler']);
} | php | {
"resource": ""
} |
q15689 | Bootstrap.getErrorPrefix | train | public static function getErrorPrefix($level)
{
switch ($level) {
case E_PARSE:
$prefix = 'PHP Parse error';
break;
case E_ERROR:
case E_CORE_ERROR:
case E_COMPILE_ERROR:
$prefix = 'PHP Fatal error';
break;
case E_USER_ERROR:
case E_RECOVERABLE_ERROR:
$prefix = 'PHP error';
break;
case E_WARNING:
case E_CORE_WARNING:
case E_COMPILE_WARNING:
case E_USER_WARNING:
$prefix = 'PHP Warning';
break;
case E_NOTICE:
case E_USER_NOTICE:
$prefix = 'PHP Notice';
break;
case E_STRICT:
$prefix = 'PHP Debug';
break;
default:
$prefix = 'PHP Notice';
}
return $prefix;
} | php | {
"resource": ""
} |
q15690 | Bootstrap.getErrorLevelString | train | public static function getErrorLevelString($level)
{
switch ($level) {
case E_PARSE:
return 'CRITICAL';
case E_ERROR:
case E_CORE_ERROR:
case E_COMPILE_ERROR:
case E_USER_ERROR:
case E_RECOVERABLE_ERROR:
return 'ERROR';
case E_WARNING:
case E_CORE_WARNING:
case E_COMPILE_WARNING:
case E_USER_WARNING:
return 'WARNING';
case E_NOTICE:
case E_USER_NOTICE:
return 'NOTICE';
case E_STRICT:
return 'DEBUG';
default:
return 'NOTICE';
}
} | php | {
"resource": ""
} |
q15691 | Bootstrap.shutdownHandler | train | public static function shutdownHandler()
{
if ($err = error_get_last()) {
switch ($err['type']) {
case E_ERROR:
case E_PARSE:
case E_COMPILE_ERROR:
case E_CORE_ERROR:
$service = self::$psrLogger
->getMetadataProvider()
->serviceId();
$version = self::$psrLogger
->getMetadataProvider()
->versionId();
$message = sprintf(
'%s: %s in %s on line %d',
self::getErrorPrefix($err['type']),
$err['message'],
$err['file'],
$err['line']
);
$context = [
'context' => [
'reportLocation' => [
'filePath' => $err['file'],
'lineNumber' => $err['line'],
'functionName' =>
self::getFunctionNameForReport(),
]
],
'serviceContext' => [
'service' => $service,
'version' => $version
]
];
if (self::$psrLogger) {
self::$psrLogger->log(
self::getErrorLevelString($err['type']),
$message,
$context
);
}
break;
}
}
} | php | {
"resource": ""
} |
q15692 | ClientEvent.setJobEvent | train | public function setJobEvent($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\Talent\V4beta1\JobEvent::class);
$this->writeOneof(5, $var);
return $this;
} | php | {
"resource": ""
} |
q15693 | ClientEvent.setProfileEvent | train | public function setProfileEvent($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\Talent\V4beta1\ProfileEvent::class);
$this->writeOneof(6, $var);
return $this;
} | php | {
"resource": ""
} |
q15694 | OrderedJob.setPysparkJob | train | public function setPysparkJob($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\Dataproc\V1beta2\PySparkJob::class);
$this->writeOneof(4, $var);
return $this;
} | php | {
"resource": ""
} |
q15695 | OrderedJob.setPrerequisiteStepIds | train | public function setPrerequisiteStepIds($var)
{
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING);
$this->prerequisite_step_ids = $arr;
return $this;
} | php | {
"resource": ""
} |
q15696 | MaintenanceWindow.setDailyMaintenanceWindow | train | public function setDailyMaintenanceWindow($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\Container\V1\DailyMaintenanceWindow::class);
$this->writeOneof(2, $var);
return $this;
} | php | {
"resource": ""
} |
q15697 | GatewayConfig.setGatewayType | train | public function setGatewayType($var)
{
GPBUtil::checkEnum($var, \Google\Cloud\Iot\V1\GatewayType::class);
$this->gateway_type = $var;
return $this;
} | php | {
"resource": ""
} |
q15698 | ListSinksResponse.setSinks | train | public function setSinks($var)
{
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Logging\V2\LogSink::class);
$this->sinks = $arr;
return $this;
} | php | {
"resource": ""
} |
q15699 | ImportProductSetsInputConfig.setGcsSource | train | public function setGcsSource($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\Vision\V1\ImportProductSetsGcsSource::class);
$this->writeOneof(1, $var);
return $this;
} | php | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.