idx int64 0 241k | question stringlengths 64 6.21k | target stringlengths 5 803 |
|---|---|---|
2,300 | public function setChannelDescriptors ( $ var ) { $ arr = GPBUtil :: checkRepeatedField ( $ var , \ Google \ Protobuf \ Internal \ GPBType :: MESSAGE , \ Google \ Cloud \ Monitoring \ V3 \ NotificationChannelDescriptor :: class ) ; $ this -> channel_descriptors = $ arr ; return $ this ; } | The monitored resource descriptors supported for the specified project optionally filtered . |
2,301 | public function reload ( array $ options = [ ] ) { return $ this -> info = $ this -> connection -> getTopic ( $ options + [ 'topic' => $ this -> name ] ) ; } | Get topic information from the API . |
2,302 | public function publishBatch ( array $ messages , array $ options = [ ] ) { foreach ( $ messages as & $ message ) { $ message = $ this -> formatMessage ( $ message ) ; } return $ this -> connection -> publishMessage ( $ options + [ 'topic' => $ this -> name , 'messages' => $ messages ] ) ; } | Publish multiple messages at once . |
2,303 | public function subscribe ( $ name , array $ options = [ ] ) { $ subscription = $ this -> subscriptionFactory ( $ name ) ; $ subscription -> create ( $ options ) ; return $ subscription ; } | Create a subscription to the topic . |
2,304 | public function subscriptions ( array $ options = [ ] ) { $ resultLimit = $ this -> pluck ( 'resultLimit' , $ options , false ) ; return new ItemIterator ( new PageIterator ( function ( $ subscription ) { return $ this -> subscriptionFactory ( $ subscription ) ; } , [ $ this -> connection , 'listSubscriptionsByTopic' ] , $ options + [ 'topic' => $ this -> name ] , [ 'itemsKey' => 'subscriptions' , 'resultLimit' => $ resultLimit ] ) ) ; } | Retrieve a list of active subscriptions to the current topic . |
2,305 | public function iam ( ) { if ( ! $ this -> iam ) { $ iamConnection = new IamTopic ( $ this -> connection ) ; $ this -> iam = new Iam ( $ iamConnection , $ this -> name ) ; } return $ this -> iam ; } | Manage the IAM policy for the current Topic . |
2,306 | private function formatMessage ( array $ message ) { if ( isset ( $ message [ 'data' ] ) && $ this -> encode ) { $ message [ 'data' ] = base64_encode ( $ message [ 'data' ] ) ; } if ( ! array_key_exists ( 'data' , $ message ) && ! array_key_exists ( 'attributes' , $ message ) ) { throw new InvalidArgumentException ( 'At least one of $data or $attributes must be specified on each message, but neither was given.' ) ; } return $ message ; } | Ensure that the message is in a correct format base64_encode the data and error if the input is too wrong to proceed . |
2,307 | private function subscriptionFactory ( $ name , array $ info = [ ] ) { return new Subscription ( $ this -> connection , $ this -> projectId , $ name , $ this -> name , $ this -> encode , $ info ) ; } | Create a new subscription instance with the given name and optional subscription data . |
2,308 | public function setLogicalOperator ( $ var ) { GPBUtil :: checkEnum ( $ var , \ Google \ Cloud \ Dlp \ V2 \ RecordCondition_Expressions_LogicalOperator :: class ) ; $ this -> logical_operator = $ var ; return $ this ; } | The operator to apply to the result of conditions . Default and currently only supported value is AND . |
2,309 | public function setSession ( $ var ) { GPBUtil :: checkMessage ( $ var , \ Google \ Cloud \ Spanner \ V1 \ Session :: class ) ; $ this -> session = $ var ; return $ this ; } | The session to create . |
2,310 | public function setReadTimeWindow ( $ var ) { GPBUtil :: checkMessage ( $ var , \ Google \ Cloud \ Asset \ V1beta1 \ TimeWindow :: class ) ; $ this -> read_time_window = $ var ; return $ this ; } | Optional . The time window for the asset history . Both start_time and end_time are optional and if set it must be after 2018 - 10 - 02 UTC . If end_time is not set it is default to current timestamp . If start_time is not set the snapshot of the assets at end_time will be returned . The returned results contain all temporal assets whose time window overlap with read_time_window . |
2,311 | public function setShotChangeDetectionConfig ( $ var ) { GPBUtil :: checkMessage ( $ var , \ Google \ Cloud \ VideoIntelligence \ V1 \ ShotChangeDetectionConfig :: class ) ; $ this -> shot_change_detection_config = $ var ; return $ this ; } | Config for SHOT_CHANGE_DETECTION . |
2,312 | public function setExplicitContentDetectionConfig ( $ var ) { GPBUtil :: checkMessage ( $ var , \ Google \ Cloud \ VideoIntelligence \ V1 \ ExplicitContentDetectionConfig :: class ) ; $ this -> explicit_content_detection_config = $ var ; return $ this ; } | Config for EXPLICIT_CONTENT_DETECTION . |
2,313 | public function setSpeechTranscriptionConfig ( $ var ) { GPBUtil :: checkMessage ( $ var , \ Google \ Cloud \ VideoIntelligence \ V1 \ SpeechTranscriptionConfig :: class ) ; $ this -> speech_transcription_config = $ var ; return $ this ; } | Config for SPEECH_TRANSCRIPTION . |
2,314 | public function setTextDetectionConfig ( $ var ) { GPBUtil :: checkMessage ( $ var , \ Google \ Cloud \ VideoIntelligence \ V1 \ TextDetectionConfig :: class ) ; $ this -> text_detection_config = $ var ; return $ this ; } | Config for TEXT_DETECTION . |
2,315 | public function setState ( $ var ) { GPBUtil :: checkEnum ( $ var , \ Google \ Cloud \ Dlp \ V2 \ DlpJob_JobState :: class ) ; $ this -> state = $ var ; return $ this ; } | State of a job . |
2,316 | public function setRiskDetails ( $ var ) { GPBUtil :: checkMessage ( $ var , \ Google \ Cloud \ Dlp \ V2 \ AnalyzeDataSourceRiskDetails :: class ) ; $ this -> writeOneof ( 4 , $ var ) ; return $ this ; } | Results from analyzing risk of a data source . |
2,317 | public function setInspectDetails ( $ var ) { GPBUtil :: checkMessage ( $ var , \ Google \ Cloud \ Dlp \ V2 \ InspectDataSourceDetails :: class ) ; $ this -> writeOneof ( 5 , $ var ) ; return $ this ; } | Results from inspecting a data source . |
2,318 | public function setBlocks ( $ var ) { $ arr = GPBUtil :: checkRepeatedField ( $ var , \ Google \ Protobuf \ Internal \ GPBType :: MESSAGE , \ Google \ Cloud \ Vision \ V1 \ Block :: class ) ; $ this -> blocks = $ arr ; return $ this ; } | List of blocks of text images etc on this page . |
2,319 | public function setType ( $ var ) { GPBUtil :: checkEnum ( $ var , \ Google \ Cloud \ Dialogflow \ V2 \ Intent_TrainingPhrase_Type :: class ) ; $ this -> type = $ var ; return $ this ; } | Required . The type of the training phrase . |
2,320 | public function setResourceLabels ( $ var ) { $ arr = GPBUtil :: checkMapField ( $ var , \ Google \ Protobuf \ Internal \ GPBType :: STRING , \ Google \ Protobuf \ Internal \ GPBType :: STRING ) ; $ this -> resource_labels = $ arr ; return $ this ; } | The labels to set for that cluster . |
2,321 | public function setAgents ( $ var ) { $ arr = GPBUtil :: checkRepeatedField ( $ var , \ Google \ Protobuf \ Internal \ GPBType :: MESSAGE , \ Google \ Cloud \ Dialogflow \ V2 \ Agent :: class ) ; $ this -> agents = $ arr ; return $ this ; } | The list of agents . There will be a maximum number of items returned based on the page_size field in the request . |
2,322 | public function setNewTransaction ( $ var ) { GPBUtil :: checkMessage ( $ var , \ Google \ Cloud \ Firestore \ V1beta1 \ TransactionOptions :: class ) ; $ this -> writeOneof ( 5 , $ var ) ; return $ this ; } | Starts a new transaction and reads the documents . Defaults to a read - only transaction . The new transaction ID will be returned as the first response in the stream . |
2,323 | public function setLevel ( $ var ) { GPBUtil :: checkEnum ( $ var , \ Google \ Cloud \ Talent \ V4beta1 \ SkillProficiencyLevel :: class ) ; $ this -> level = $ var ; return $ this ; } | Optional . Skill proficiency level which indicates how proficient the candidate is at this skill . |
2,324 | public function setGroup ( $ var ) { GPBUtil :: checkMessage ( $ var , \ Google \ Cloud \ ErrorReporting \ V1beta1 \ ErrorGroup :: class ) ; $ this -> group = $ var ; return $ this ; } | Group data that is independent of the filter criteria . |
2,325 | public function setAffectedServices ( $ var ) { $ arr = GPBUtil :: checkRepeatedField ( $ var , \ Google \ Protobuf \ Internal \ GPBType :: MESSAGE , \ Google \ Cloud \ ErrorReporting \ V1beta1 \ ServiceContext :: class ) ; $ this -> affected_services = $ arr ; return $ this ; } | Service contexts with a non - zero error count for the given filter criteria . This list can be truncated if multiple services are affected . Refer to num_affected_services for the total count . |
2,326 | public function setRepresentative ( $ var ) { GPBUtil :: checkMessage ( $ var , \ Google \ Cloud \ ErrorReporting \ V1beta1 \ ErrorEvent :: class ) ; $ this -> representative = $ var ; return $ this ; } | An arbitrary event that is chosen as representative for the whole group . The representative event is intended to be used as a quick preview for the whole group . Events in the group are usually sufficiently similar to each other such that showing an arbitrary representative provides insight into the characteristics of the group as a whole . |
2,327 | public function setDateTime ( $ var ) { GPBUtil :: checkMessage ( $ var , \ Google \ Cloud \ Dlp \ V2 \ DateTime :: class ) ; $ this -> writeOneof ( 2 , $ var ) ; return $ this ; } | The date time indicated by the quote . |
2,328 | public function setView ( $ var ) { GPBUtil :: checkEnum ( $ var , \ Google \ Cloud \ Kms \ V1 \ CryptoKeyVersion_CryptoKeyVersionView :: class ) ; $ this -> view = $ var ; return $ this ; } | The fields to include in the response . |
2,329 | public function setImageClassificationModelMetadata ( $ var ) { GPBUtil :: checkMessage ( $ var , \ Google \ Cloud \ AutoMl \ V1beta1 \ ImageClassificationModelMetadata :: class ) ; $ this -> writeOneof ( 13 , $ var ) ; return $ this ; } | Metadata for image classification models . |
2,330 | public function setTextClassificationModelMetadata ( $ var ) { GPBUtil :: checkMessage ( $ var , \ Google \ Cloud \ AutoMl \ V1beta1 \ TextClassificationModelMetadata :: class ) ; $ this -> writeOneof ( 14 , $ var ) ; return $ this ; } | Metadata for text classification models . |
2,331 | public function setTranslationModelMetadata ( $ var ) { GPBUtil :: checkMessage ( $ var , \ Google \ Cloud \ AutoMl \ V1beta1 \ TranslationModelMetadata :: class ) ; $ this -> writeOneof ( 15 , $ var ) ; return $ this ; } | Metadata for translation models . |
2,332 | public function setDeploymentState ( $ var ) { GPBUtil :: checkEnum ( $ var , \ Google \ Cloud \ AutoMl \ V1beta1 \ Model_DeploymentState :: class ) ; $ this -> deployment_state = $ var ; return $ this ; } | Output only . Deployment state of the model . |
2,333 | public function setDeidentifyTemplates ( $ var ) { $ arr = GPBUtil :: checkRepeatedField ( $ var , \ Google \ Protobuf \ Internal \ GPBType :: MESSAGE , \ Google \ Cloud \ Dlp \ V2 \ DeidentifyTemplate :: class ) ; $ this -> deidentify_templates = $ arr ; return $ this ; } | List of deidentify templates up to page_size in ListDeidentifyTemplatesRequest . |
2,334 | public function setRating ( $ var ) { GPBUtil :: checkMessage ( $ var , \ Google \ Cloud \ Talent \ V4beta1 \ Rating :: class ) ; $ this -> rating = $ var ; return $ this ; } | Optional . The rating on this interview . |
2,335 | public function setInputConfig ( $ var ) { GPBUtil :: checkMessage ( $ var , \ Google \ Cloud \ Vision \ V1 \ InputConfig :: class ) ; $ this -> input_config = $ var ; return $ this ; } | Required . Information about the input file . |
2,336 | public function setFeatures ( $ var ) { $ arr = GPBUtil :: checkRepeatedField ( $ var , \ Google \ Protobuf \ Internal \ GPBType :: MESSAGE , \ Google \ Cloud \ Vision \ V1 \ Feature :: class ) ; $ this -> features = $ arr ; return $ this ; } | Required . Requested features . |
2,337 | public function setPages ( $ var ) { $ arr = GPBUtil :: checkRepeatedField ( $ var , \ Google \ Protobuf \ Internal \ GPBType :: INT32 ) ; $ this -> pages = $ arr ; return $ this ; } | Pages of the file to perform image annotation . Pages starts from 1 we assume the first page of the file is page 1 . At most 5 pages are supported per request . Pages can be negative . Page 1 means the first page . Page 2 means the second page . Page - 1 means the last page . Page - 2 means the second to the last page . If the file is GIF instead of PDF or TIFF page refers to GIF frames . If this field is empty by default the service performs image annotation for the first 5 pages of the file . |
2,338 | public function insertBatch ( array $ entities ) { $ entities = $ this -> operation -> allocateIdsToEntities ( $ entities ) ; foreach ( $ entities as $ entity ) { $ this -> mutations [ ] = $ this -> operation -> mutation ( 'insert' , $ entity , Entity :: class ) ; } return $ this ; } | Insert multiple entities . |
2,339 | public function updateBatch ( array $ entities , array $ options = [ ] ) { $ options += [ 'allowOverwrite' => false ] ; $ this -> operation -> checkOverwrite ( $ entities , $ options [ 'allowOverwrite' ] ) ; foreach ( $ entities as $ entity ) { $ this -> mutations [ ] = $ this -> operation -> mutation ( 'update' , $ entity , Entity :: class ) ; } return $ this ; } | Update multiple entities . |
2,340 | public function deleteBatch ( array $ keys ) { foreach ( $ keys as $ key ) { $ this -> mutations [ ] = $ this -> operation -> mutation ( 'delete' , $ key , Key :: class ) ; } return $ this ; } | Delete multiple records . |
2,341 | public function commit ( array $ options = [ ] ) { $ options [ 'transaction' ] = $ this -> transactionId ; return $ this -> operation -> commit ( $ this -> mutations , $ options ) ; } | Commit all mutations . |
2,342 | public function setRecognitionResult ( $ var ) { GPBUtil :: checkMessage ( $ var , \ Google \ Cloud \ Dialogflow \ V2 \ StreamingRecognitionResult :: class ) ; $ this -> recognition_result = $ var ; return $ this ; } | The result of speech recognition . |
2,343 | public function setStateChange ( $ var ) { GPBUtil :: checkEnum ( $ var , \ Google \ Cloud \ SecurityCenter \ V1 \ ListAssetsResponse_ListAssetsResult_StateChange :: class ) ; $ this -> state_change = $ var ; return $ this ; } | State change of the asset between the points in time . |
2,344 | public function setRegion ( $ var ) { GPBUtil :: checkEnum ( $ var , \ Google \ Cloud \ Monitoring \ V3 \ UptimeCheckRegion :: class ) ; $ this -> region = $ var ; return $ this ; } | A broad region category in which the IP address is located . |
2,345 | public function setDeidentifyTemplate ( $ var ) { GPBUtil :: checkMessage ( $ var , \ Google \ Cloud \ Dlp \ V2 \ DeidentifyTemplate :: class ) ; $ this -> deidentify_template = $ var ; return $ this ; } | New DeidentifyTemplate value . |
2,346 | public function setValues ( $ var ) { $ arr = GPBUtil :: checkRepeatedField ( $ var , \ Google \ Protobuf \ Internal \ GPBType :: STRING ) ; $ this -> values = $ arr ; return $ this ; } | Required . List of allowed values for the parameter . |
2,347 | public function setIntentBatchInline ( $ var ) { GPBUtil :: checkMessage ( $ var , \ Google \ Cloud \ Dialogflow \ V2 \ IntentBatch :: class ) ; $ this -> writeOneof ( 3 , $ var ) ; return $ this ; } | The collection of intents to update or create . |
2,348 | public function setTag ( $ var ) { GPBUtil :: checkEnum ( $ var , \ Google \ Cloud \ Language \ V1beta2 \ PartOfSpeech_Tag :: class ) ; $ this -> tag = $ var ; return $ this ; } | The part of speech tag . |
2,349 | public function setCase ( $ var ) { GPBUtil :: checkEnum ( $ var , \ Google \ Cloud \ Language \ V1beta2 \ PartOfSpeech_Case :: class ) ; $ this -> case = $ var ; return $ this ; } | The grammatical case . |
2,350 | public function setForm ( $ var ) { GPBUtil :: checkEnum ( $ var , \ Google \ Cloud \ Language \ V1beta2 \ PartOfSpeech_Form :: class ) ; $ this -> form = $ var ; return $ this ; } | The grammatical form . |
2,351 | public function setGender ( $ var ) { GPBUtil :: checkEnum ( $ var , \ Google \ Cloud \ Language \ V1beta2 \ PartOfSpeech_Gender :: class ) ; $ this -> gender = $ var ; return $ this ; } | The grammatical gender . |
2,352 | public function setNumber ( $ var ) { GPBUtil :: checkEnum ( $ var , \ Google \ Cloud \ Language \ V1beta2 \ PartOfSpeech_Number :: class ) ; $ this -> number = $ var ; return $ this ; } | The grammatical number . |
2,353 | public function setProper ( $ var ) { GPBUtil :: checkEnum ( $ var , \ Google \ Cloud \ Language \ V1beta2 \ PartOfSpeech_Proper :: class ) ; $ this -> proper = $ var ; return $ this ; } | The grammatical properness . |
2,354 | public function setBindings ( array $ bindings = [ ] ) { $ this -> bindings = [ ] ; foreach ( $ bindings as $ binding ) { $ this -> addBinding ( $ binding [ 'role' ] , $ binding [ 'members' ] ) ; } return $ this ; } | Override all stored bindings on the policy . |
2,355 | public function removeBinding ( $ role , array $ members ) { $ bindings = $ this -> bindings ; foreach ( ( array ) $ bindings as $ i => $ binding ) { if ( $ binding [ 'role' ] == $ role ) { $ newMembers = array_diff ( $ binding [ 'members' ] , $ members ) ; if ( count ( $ newMembers ) != count ( $ binding [ 'members' ] ) - count ( $ members ) ) { throw new InvalidArgumentException ( 'One or more role-members were not found.' ) ; } if ( empty ( $ newMembers ) ) { unset ( $ bindings [ $ i ] ) ; $ bindings = array_values ( $ bindings ) ; } else { $ binding [ 'members' ] = array_values ( $ newMembers ) ; $ bindings [ $ i ] = $ binding ; } $ this -> bindings = $ bindings ; return $ this ; } } throw new InvalidArgumentException ( 'The role was not found.' ) ; } | Remove a binding from the policy . |
2,356 | public function entries ( array $ options = [ ] ) { $ resultLimit = $ this -> pluck ( 'resultLimit' , $ options , false ) ; $ logNameFilter = "logName = $this->formattedName" ; $ options += [ 'resourceNames' => [ "projects/$this->projectId" ] , 'filter' => isset ( $ options [ 'filter' ] ) ? $ options [ 'filter' ] .= " AND $logNameFilter" : $ logNameFilter ] ; return new ItemIterator ( new PageIterator ( function ( array $ entry ) { return new Entry ( $ entry ) ; } , [ $ this -> connection , 'listEntries' ] , $ options , [ 'itemsKey' => 'entries' , 'resultLimit' => $ resultLimit ] ) ) ; } | Fetches entries scoped to the selected log . |
2,357 | public function write ( $ entry , array $ options = [ ] ) { $ entryOptions = $ this -> pluckArray ( $ this -> entryOptions , $ options ) ; $ this -> writeBatch ( [ $ this -> handleEntry ( $ entry , $ entryOptions ) ] , $ options ) ; } | Write a single entry to the log . |
2,358 | public function writeBatch ( array $ entries , array $ options = [ ] ) { $ this -> validateBatch ( $ entries , Entry :: class ) ; foreach ( $ entries as & $ entry ) { $ entry = $ entry -> info ( ) ; } $ this -> connection -> writeEntries ( $ options + [ 'entries' => $ entries ] ) ; } | Write a set of entries to the log . |
2,359 | public function setTargetChange ( $ var ) { GPBUtil :: checkMessage ( $ var , \ Google \ Cloud \ Firestore \ V1 \ TargetChange :: class ) ; $ this -> writeOneof ( 2 , $ var ) ; return $ this ; } | Targets have changed . |
2,360 | public function clearRules ( $ action = null ) { if ( ! $ action ) { $ this -> lifecycle = [ ] ; return $ this ; } if ( ! is_string ( $ action ) && ! is_callable ( $ action ) ) { throw new \ InvalidArgumentException ( sprintf ( 'Expected either a string or callable, instead got \'%s\'.' , gettype ( $ action ) ) ) ; } if ( isset ( $ this -> lifecycle [ 'rule' ] ) ) { if ( is_string ( $ action ) ) { $ action = function ( $ rule ) use ( $ action ) { return $ rule [ 'action' ] [ 'type' ] !== $ action ; } ; } $ this -> lifecycle [ 'rule' ] = array_filter ( $ this -> lifecycle [ 'rule' ] , $ action ) ; if ( ! $ this -> lifecycle [ 'rule' ] ) { $ this -> lifecycle = [ ] ; } } return $ this ; } | Clear all Object Lifecycle rules or rules of a certain action type . |
2,361 | public function setMaintenancePolicy ( $ var ) { GPBUtil :: checkMessage ( $ var , \ Google \ Cloud \ Container \ V1 \ MaintenancePolicy :: class ) ; $ this -> maintenance_policy = $ var ; return $ this ; } | The maintenance policy to be set for the cluster . An empty field clears the existing maintenance policy . |
2,362 | private function pluck ( $ key , array & $ arr , $ isRequired = true ) { if ( ! array_key_exists ( $ key , $ arr ) ) { if ( $ isRequired ) { throw new \ InvalidArgumentException ( "Key $key does not exist in the provided array." ) ; } return null ; } $ value = $ arr [ $ key ] ; unset ( $ arr [ $ key ] ) ; return $ value ; } | Pluck a value out of an array . |
2,363 | private function pluckArray ( array $ keys , & $ arr ) { $ values = [ ] ; foreach ( $ keys as $ key ) { if ( array_key_exists ( $ key , $ arr ) ) { $ values [ $ key ] = $ this -> pluck ( $ key , $ arr , false ) ; } } return $ values ; } | Pluck a subset of an array . |
2,364 | private function arrayMergeRecursive ( array $ array1 , array $ array2 ) { foreach ( $ array2 as $ key => $ value ) { if ( array_key_exists ( $ key , $ array1 ) && is_array ( $ array1 [ $ key ] ) && is_array ( $ value ) ) { $ array1 [ $ key ] = ( $ this -> isAssoc ( $ array1 [ $ key ] ) && $ this -> isAssoc ( $ value ) ) ? $ this -> arrayMergeRecursive ( $ array1 [ $ key ] , $ value ) : array_merge ( $ array1 [ $ key ] , $ value ) ; } else { $ array1 [ $ key ] = $ value ; } } return $ array1 ; } | A method similar to PHP s array_merge_recursive with two differences . |
2,365 | public function update ( array $ metadata , array $ options = [ ] ) { $ options += $ metadata ; $ options += $ this -> info ( $ options ) ; return $ this -> info = $ this -> connection -> updateSink ( $ options + [ 'sinkName' => $ this -> formattedName ] ) ; } | Update the sink . Please note this will trigger a network request if cached data is not available to perform the update with . |
2,366 | public function reload ( array $ options = [ ] ) { return $ this -> info = $ this -> connection -> getSink ( $ options + [ 'sinkName' => $ this -> formattedName ] ) ; } | Triggers a network request to reload the sink s details . |
2,367 | public function setImageRedactionConfigs ( $ var ) { $ arr = GPBUtil :: checkRepeatedField ( $ var , \ Google \ Protobuf \ Internal \ GPBType :: MESSAGE , \ Google \ Cloud \ Dlp \ V2 \ RedactImageRequest \ ImageRedactionConfig :: class ) ; $ this -> image_redaction_configs = $ arr ; return $ this ; } | The configuration for specifying what content to redact from images . |
2,368 | public function setByteItem ( $ var ) { GPBUtil :: checkMessage ( $ var , \ Google \ Cloud \ Dlp \ V2 \ ByteContentItem :: class ) ; $ this -> byte_item = $ var ; return $ this ; } | The content must be PNG JPEG SVG or BMP . |
2,369 | public function setSpellCorrection ( $ var ) { GPBUtil :: checkMessage ( $ var , \ Google \ Cloud \ Talent \ V4beta1 \ SpellingCorrection :: class ) ; $ this -> spell_correction = $ var ; return $ this ; } | The spell checking result and correction . |
2,370 | public function setType ( $ var ) { GPBUtil :: checkEnum ( $ var , \ Google \ Cloud \ Bigtable \ Admin \ V2 \ Instance_Type :: class ) ; $ this -> type = $ var ; return $ this ; } | The type of the instance . Defaults to PRODUCTION . |
2,371 | public function setRules ( $ var ) { $ arr = GPBUtil :: checkRepeatedField ( $ var , \ Google \ Protobuf \ Internal \ GPBType :: MESSAGE , \ Google \ Cloud \ Bigtable \ Admin \ V2 \ GcRule :: class ) ; $ this -> rules = $ arr ; return $ this ; } | Only delete cells which would be deleted by every element of rules . |
2,372 | public function release ( Session $ session ) { $ this -> config [ 'lock' ] -> synchronize ( function ( ) use ( $ session ) { $ item = $ this -> cacheItemPool -> getItem ( $ this -> cacheKey ) ; $ data = $ item -> get ( ) ; $ name = $ session -> name ( ) ; if ( isset ( $ data [ 'inUse' ] [ $ name ] ) ) { unset ( $ data [ 'inUse' ] [ $ name ] ) ; array_push ( $ data [ 'queue' ] , [ 'name' => $ name , 'expiration' => $ session -> expiration ( ) ? : $ this -> time ( ) + SessionPoolInterface :: SESSION_EXPIRATION_SECONDS ] ) ; $ this -> cacheItemPool -> save ( $ item -> set ( $ data ) ) ; } } ) ; } | Release a session back to the pool . |
2,373 | public function keepAlive ( Session $ session ) { $ this -> config [ 'lock' ] -> synchronize ( function ( ) use ( $ session ) { $ item = $ this -> cacheItemPool -> getItem ( $ this -> cacheKey ) ; $ data = $ item -> get ( ) ; $ data [ 'inUse' ] [ $ session -> name ( ) ] [ 'lastActive' ] = $ this -> time ( ) ; $ this -> cacheItemPool -> save ( $ item -> set ( $ data ) ) ; } ) ; } | Keeps a checked out session alive . |
2,374 | public function warmup ( ) { $ toCreate = $ this -> config [ 'lock' ] -> synchronize ( function ( ) { $ item = $ this -> cacheItemPool -> getItem ( $ this -> cacheKey ) ; $ data = ( array ) $ item -> get ( ) ? : $ this -> initialize ( ) ; $ count = $ this -> getSessionCount ( $ data ) ; $ toCreate = [ ] ; if ( $ count < $ this -> config [ 'minSessions' ] ) { $ toCreate = $ this -> buildToCreateList ( $ this -> config [ 'minSessions' ] - $ count ) ; $ data [ 'toCreate' ] += $ toCreate ; $ this -> cacheItemPool -> save ( $ item -> set ( $ data ) ) ; } return $ toCreate ; } ) ; if ( ! $ toCreate ) { return 0 ; } $ createdSessions = [ ] ; $ exception = null ; try { $ createdSessions = $ this -> createSessions ( count ( $ toCreate ) ) ; } catch ( \ Exception $ exception ) { } $ this -> config [ 'lock' ] -> synchronize ( function ( ) use ( $ toCreate , $ createdSessions ) { $ item = $ this -> cacheItemPool -> getItem ( $ this -> cacheKey ) ; $ data = $ item -> get ( ) ; $ data [ 'queue' ] = array_merge ( $ data [ 'queue' ] , $ createdSessions ) ; foreach ( $ toCreate as $ id => $ time ) { unset ( $ data [ 'toCreate' ] [ $ id ] ) ; } $ this -> cacheItemPool -> save ( $ item -> set ( $ data ) ) ; } ) ; if ( $ exception ) { throw $ exception ; } return count ( $ toCreate ) ; } | Create enough sessions to meet the minimum session constraint . |
2,375 | public function clear ( ) { $ sessions = $ this -> config [ 'lock' ] -> synchronize ( function ( ) { $ item = $ this -> cacheItemPool -> getItem ( $ this -> cacheKey ) ; $ data = ( array ) $ item -> get ( ) ? : $ this -> initialize ( ) ; $ sessions = $ data [ 'queue' ] + $ data [ 'inUse' ] ; $ this -> cacheItemPool -> clear ( ) ; return $ sessions ; } ) ; $ this -> deleteSessions ( $ sessions ) ; } | Clear the cache and attempt to delete all sessions in the pool . |
2,376 | public function setDatabase ( Database $ database ) { $ this -> database = $ database ; $ identity = $ database -> identity ( ) ; $ this -> cacheKey = sprintf ( self :: CACHE_KEY_TEMPLATE , $ identity [ 'projectId' ] , $ identity [ 'instance' ] , $ identity [ 'database' ] ) ; if ( ! isset ( $ this -> config [ 'lock' ] ) ) { $ this -> config [ 'lock' ] = $ this -> getDefaultLock ( ) ; } } | Set the database used to make calls to manage sessions . |
2,377 | private function buildToCreateList ( $ number ) { $ toCreate = [ ] ; $ time = $ this -> time ( ) ; for ( $ i = 0 ; $ i < $ number ; $ i ++ ) { $ toCreate [ uniqid ( $ time . '_' , true ) ] = $ time ; } return $ toCreate ; } | Builds out a list of timestamps indicating the start time of the intent to create a session . |
2,378 | private function purgeOrphanedToCreateItems ( array & $ data ) { foreach ( $ data [ 'toCreate' ] as $ key => $ timestamp ) { $ time = $ this -> time ( ) ; if ( $ timestamp + self :: DURATION_TWENTY_MINUTES < $ this -> time ( ) ) { unset ( $ data [ 'toCreate' ] [ $ key ] ) ; } } } | Purge any items in the to create queue that have been inactive for 20 minutes or more . |
2,379 | private function purgeOrphanedInUseSessions ( array & $ data ) { foreach ( $ data [ 'inUse' ] as $ key => $ session ) { if ( $ session [ 'lastActive' ] + SessionPoolInterface :: SESSION_EXPIRATION_SECONDS < $ this -> time ( ) ) { unset ( $ data [ 'inUse' ] [ $ key ] ) ; } elseif ( $ session [ 'lastActive' ] + self :: DURATION_TWENTY_MINUTES < $ this -> time ( ) ) { unset ( $ session [ 'lastActive' ] ) ; array_push ( $ data [ 'queue' ] , $ session ) ; unset ( $ data [ 'inUse' ] [ $ key ] ) ; } } } | Purges in use sessions . If a session was last active an hour ago we assume it is expired and remove it from the pool . If last active 20 minutes ago we attempt to return the session back to the queue . |
2,380 | private function getSession ( array & $ data ) { $ session = array_shift ( $ data [ 'queue' ] ) ; if ( $ session ) { if ( $ session [ 'expiration' ] - self :: DURATION_ONE_MINUTE < $ this -> time ( ) ) { return $ this -> getSession ( $ data ) ; } $ data [ 'inUse' ] [ $ session [ 'name' ] ] = $ session + [ 'lastActive' => $ this -> time ( ) ] ; if ( $ this -> config [ 'shouldAutoDownsize' ] ) { $ this -> manageSessionsToDelete ( $ data ) ; } } return $ session ; } | Gets the next session in the queue clearing out any which are expired . |
2,381 | private function createSessions ( $ count ) { $ args = [ 'database' => $ this -> database -> name ( ) , 'session' => [ 'labels' => isset ( $ this -> config [ 'labels' ] ) ? $ this -> config [ 'labels' ] : [ ] ] ] ; $ promises = [ ] ; for ( $ i = 0 ; $ i < $ count ; $ i ++ ) { $ promises [ ] = $ this -> database -> connection ( ) -> createSessionAsync ( $ args ) ; } $ results = Promise \ settle ( $ promises ) -> wait ( ) ; $ sessions = [ ] ; foreach ( $ results as $ result ) { if ( $ result [ 'state' ] === 'fulfilled' ) { $ name = $ result [ 'value' ] -> getName ( ) ; $ sessions [ ] = [ 'name' => $ name , 'expiration' => $ this -> time ( ) + SessionPoolInterface :: SESSION_EXPIRATION_SECONDS ] ; } } return $ sessions ; } | Creates sessions up to the count provided . |
2,382 | private function isSessionValid ( array $ session ) { $ halfHourBeforeExpiration = $ session [ 'expiration' ] - ( SessionPoolInterface :: SESSION_EXPIRATION_SECONDS / 2 ) ; if ( $ this -> time ( ) < $ halfHourBeforeExpiration ) { return true ; } elseif ( $ halfHourBeforeExpiration < $ this -> time ( ) && $ this -> time ( ) < $ session [ 'expiration' ] ) { return $ this -> database -> session ( $ session [ 'name' ] ) -> exists ( ) ; } return false ; } | If necessary triggers a network request to determine the status of the provided session . |
2,383 | private function handleSession ( array $ session ) { if ( $ this -> isSessionValid ( $ session ) ) { return $ session ; } $ this -> config [ 'lock' ] -> synchronize ( function ( ) use ( $ session ) { $ item = $ this -> cacheItemPool -> getItem ( $ this -> cacheKey ) ; $ data = $ item -> get ( ) ; unset ( $ data [ 'inUse' ] [ $ session [ 'name' ] ] ) ; $ this -> cacheItemPool -> save ( $ item -> set ( $ data ) ) ; } ) ; } | If the session is valid return it - otherwise remove from the in use list . |
2,384 | private function waitForNextAvailableSession ( ) { $ elapsedCycles = 0 ; while ( true ) { $ session = $ this -> config [ 'lock' ] -> synchronize ( function ( ) use ( $ elapsedCycles ) { $ item = $ this -> cacheItemPool -> getItem ( $ this -> cacheKey ) ; $ data = $ item -> get ( ) ; $ session = $ this -> getSession ( $ data ) ; if ( $ session ) { $ this -> cacheItemPool -> save ( $ item -> set ( $ data ) ) ; return $ session ; } if ( $ this -> config [ 'maxCyclesToWaitForSession' ] <= $ elapsedCycles ) { $ this -> cacheItemPool -> save ( $ item -> set ( $ data ) ) ; throw new \ RuntimeException ( 'A session did not become available in the allotted number of attempts.' ) ; } } ) ; if ( $ session && $ this -> handleSession ( $ session ) ) { return $ session ; } $ elapsedCycles ++ ; usleep ( $ this -> config [ 'sleepIntervalSeconds' ] * 1000000 ) ; } } | Blocks until a session becomes available . |
2,385 | private function getDefaultLock ( ) { if ( $ this -> isSysvIPCLoaded ( ) ) { return new SemaphoreLock ( $ this -> getSysvKey ( crc32 ( $ this -> cacheKey ) ) ) ; } return new FlockLock ( $ this -> cacheKey ) ; } | Get the default lock . |
2,386 | private function validateConfig ( ) { $ mustBePositiveKeys = [ 'maxCyclesToWaitForSession' , 'maxSessions' , 'minSessions' , 'sleepIntervalSeconds' ] ; foreach ( $ mustBePositiveKeys as $ key ) { if ( $ this -> config [ $ key ] < 0 ) { throw new \ InvalidArgumentException ( "$key may not be negative" ) ; } } if ( $ this -> config [ 'maxSessions' ] < $ this -> config [ 'minSessions' ] ) { throw new \ InvalidArgumentException ( 'minSessions cannot exceed maxSessions' ) ; } if ( isset ( $ this -> config [ 'lock' ] ) && ! $ this -> config [ 'lock' ] instanceof LockInterface ) { throw new \ InvalidArgumentException ( 'The lock must implement Google\Cloud\Core\Lock\LockInterface' ) ; } } | Validate the config . |
2,387 | private function deleteSessions ( array $ sessions ) { $ this -> deleteCalls = [ ] ; foreach ( $ sessions as $ session ) { $ this -> deleteCalls [ ] = $ this -> database -> connection ( ) -> deleteSessionAsync ( [ 'name' => $ session [ 'name' ] , 'database' => $ this -> database -> name ( ) ] ) ; } } | Delete the provided sessions . |
2,388 | public function setRow ( $ var ) { GPBUtil :: checkMessage ( $ var , \ Google \ Cloud \ Bigtable \ V2 \ Row :: class ) ; $ this -> row = $ var ; return $ this ; } | A Row containing the new contents of all cells modified by the request . |
2,389 | private function initFailureFile ( ) { $ this -> baseDir = getenv ( 'GOOGLE_CLOUD_BATCH_DAEMON_FAILURE_DIR' ) ; if ( $ this -> baseDir === false ) { $ this -> baseDir = sprintf ( '%s/batch-daemon-failure' , sys_get_temp_dir ( ) ) ; } if ( ! is_dir ( $ this -> baseDir ) ) { if ( @ mkdir ( $ this -> baseDir , 0700 , true ) === false ) { throw new \ RuntimeException ( sprintf ( 'Couuld not create a directory: %s' , $ this -> baseDir ) ) ; } } $ this -> failureFile = sprintf ( '%s/failed-items-%d' , $ this -> baseDir , getmypid ( ) ) ; } | Determine the failureFile . |
2,390 | public function handleFailure ( $ idNum , array $ items ) { if ( ! $ this -> failureFile ) { $ this -> initFailureFile ( ) ; } $ fp = @ fopen ( $ this -> failureFile , 'a' ) ; @ fwrite ( $ fp , serialize ( [ $ idNum => $ items ] ) . PHP_EOL ) ; @ fclose ( $ fp ) ; } | Save the items to the failureFile . We silently abandon the items upon failures in this method because there s nothing we can do . |
2,391 | public function setValue ( $ var ) { GPBUtil :: checkEnum ( $ var , \ Google \ Cloud \ Debugger \ V2 \ Breakpoint_Action :: class ) ; $ this -> value = $ var ; return $ this ; } | Only breakpoints with the specified action will pass the filter . |
2,392 | public function setClusters ( $ var ) { $ arr = GPBUtil :: checkRepeatedField ( $ var , \ Google \ Protobuf \ Internal \ GPBType :: MESSAGE , \ Google \ Cloud \ Dataproc \ V1 \ Cluster :: class ) ; $ this -> clusters = $ arr ; return $ this ; } | Output only . The clusters in the project . |
2,393 | public function setAttributes ( $ var ) { GPBUtil :: checkMessage ( $ var , \ Google \ Cloud \ Trace \ V2 \ Span_Attributes :: class ) ; $ this -> attributes = $ var ; return $ this ; } | A set of attributes on the span . You can have up to 32 attributes per span . |
2,394 | public function setStackTrace ( $ var ) { GPBUtil :: checkMessage ( $ var , \ Google \ Cloud \ Trace \ V2 \ StackTrace :: class ) ; $ this -> stack_trace = $ var ; return $ this ; } | Stack trace captured at the start of the span . |
2,395 | public function setTimeEvents ( $ var ) { GPBUtil :: checkMessage ( $ var , \ Google \ Cloud \ Trace \ V2 \ Span_TimeEvents :: class ) ; $ this -> time_events = $ var ; return $ this ; } | A set of time events . You can have up to 32 annotations and 128 message events per span . |
2,396 | public function setLinks ( $ var ) { GPBUtil :: checkMessage ( $ var , \ Google \ Cloud \ Trace \ V2 \ Span_Links :: class ) ; $ this -> links = $ var ; return $ this ; } | Links associated with the span . You can have up to 128 links per Span . |
2,397 | public static function fieldName ( $ project , $ database , $ collectionId , $ fieldId ) { return self :: getFieldNameTemplate ( ) -> render ( [ 'project' => $ project , 'database' => $ database , 'collection_id' => $ collectionId , 'field_id' => $ fieldId , ] ) ; } | Formats a string containing the fully - qualified path to represent a field resource . |
2,398 | public static function indexName ( $ project , $ database , $ collectionId , $ indexId ) { return self :: getIndexNameTemplate ( ) -> render ( [ 'project' => $ project , 'database' => $ database , 'collection_id' => $ collectionId , 'index_id' => $ indexId , ] ) ; } | Formats a string containing the fully - qualified path to represent a index resource . |
2,399 | public static function parentName ( $ project , $ database , $ collectionId ) { return self :: getParentNameTemplate ( ) -> render ( [ 'project' => $ project , 'database' => $ database , 'collection_id' => $ collectionId , ] ) ; } | Formats a string containing the fully - qualified path to represent a parent resource . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.