Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ModelArmor/metadata/V1Beta/Service.php

Large diffs are not rendered by default.

15 changes: 15 additions & 0 deletions ModelArmor/samples/V1beta/ModelArmorClient/list_locations.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,21 @@

/**
* Lists information about the supported locations for this service.

This method lists locations based on the resource scope provided in
the [ListLocationsRequest.name][google.cloud.location.ListLocationsRequest.name] field: *
**Global locations**: If `name` is empty, the method lists the
public locations available to all projects. * **Project-specific
locations**: If `name` follows the format
`projects/{project}`, the method lists locations visible to that
specific project. This includes public, private, or other
project-specific locations enabled for the project.

For gRPC and client library implementations, the resource name is
passed as the `name` field. For direct service calls, the resource
name is
incorporated into the request path based on the specific service
implementation and version.
*
* This sample has been automatically generated and should be regarded as a code
* template only. It will require modifications to work:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
<?php
/*
* Copyright 2026 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

/*
* GENERATED CODE WARNING
* This file was automatically generated - do not edit!
*/

require_once __DIR__ . '/../../../vendor/autoload.php';

// [START modelarmor_v1beta_generated_ModelArmor_StreamSanitizeModelResponse_sync]
use Google\ApiCore\ApiException;
use Google\ApiCore\BidiStream;
use Google\Cloud\ModelArmor\V1beta\Client\ModelArmorClient;
use Google\Cloud\ModelArmor\V1beta\DataItem;
use Google\Cloud\ModelArmor\V1beta\SanitizeModelResponseRequest;
use Google\Cloud\ModelArmor\V1beta\SanitizeModelResponseResponse;

/**
* Streaming version of Sanitizes Model Response.
*
* @param string $formattedName Represents resource name of template
* e.g. name=projects/sample-project/locations/us-central1/templates/templ01
* Please see {@see ModelArmorClient::templateName()} for help formatting this field.
*/
function stream_sanitize_model_response_sample(string $formattedName): void
{
// Create a client.
$modelArmorClient = new ModelArmorClient();

// Prepare the request message.
$modelResponseData = new DataItem();
$request = (new SanitizeModelResponseRequest())
->setName($formattedName)
->setModelResponseData($modelResponseData);

// Call the API and handle any network failures.
try {
/** @var BidiStream $stream */
$stream = $modelArmorClient->streamSanitizeModelResponse();
$stream->writeAll([$request,]);

/** @var SanitizeModelResponseResponse $element */
foreach ($stream->closeWriteAndReadAll() as $element) {
printf('Element data: %s' . PHP_EOL, $element->serializeToJsonString());
}
} catch (ApiException $ex) {
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
}
}

/**
* Helper to execute the sample.
*
* This sample has been automatically generated and should be regarded as a code
* template only. It will require modifications to work:
* - It may require correct/in-range values for request initialization.
* - It may require specifying regional endpoints when creating the service client,
* please see the apiEndpoint client configuration option for more details.
*/
function callSample(): void
{
$formattedName = ModelArmorClient::templateName('[PROJECT]', '[LOCATION]', '[TEMPLATE]');

stream_sanitize_model_response_sample($formattedName);
}
// [END modelarmor_v1beta_generated_ModelArmor_StreamSanitizeModelResponse_sync]
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
<?php
/*
* Copyright 2026 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

/*
* GENERATED CODE WARNING
* This file was automatically generated - do not edit!
*/

require_once __DIR__ . '/../../../vendor/autoload.php';

// [START modelarmor_v1beta_generated_ModelArmor_StreamSanitizeUserPrompt_sync]
use Google\ApiCore\ApiException;
use Google\ApiCore\BidiStream;
use Google\Cloud\ModelArmor\V1beta\Client\ModelArmorClient;
use Google\Cloud\ModelArmor\V1beta\DataItem;
use Google\Cloud\ModelArmor\V1beta\SanitizeUserPromptRequest;
use Google\Cloud\ModelArmor\V1beta\SanitizeUserPromptResponse;

/**
* Streaming version of Sanitize User Prompt.
*
* @param string $formattedName Represents resource name of template
* e.g. name=projects/sample-project/locations/us-central1/templates/templ01
* Please see {@see ModelArmorClient::templateName()} for help formatting this field.
*/
function stream_sanitize_user_prompt_sample(string $formattedName): void
{
// Create a client.
$modelArmorClient = new ModelArmorClient();

// Prepare the request message.
$userPromptData = new DataItem();
$request = (new SanitizeUserPromptRequest())
->setName($formattedName)
->setUserPromptData($userPromptData);

// Call the API and handle any network failures.
try {
/** @var BidiStream $stream */
$stream = $modelArmorClient->streamSanitizeUserPrompt();
$stream->writeAll([$request,]);

/** @var SanitizeUserPromptResponse $element */
foreach ($stream->closeWriteAndReadAll() as $element) {
printf('Element data: %s' . PHP_EOL, $element->serializeToJsonString());
}
} catch (ApiException $ex) {
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
}
}

/**
* Helper to execute the sample.
*
* This sample has been automatically generated and should be regarded as a code
* template only. It will require modifications to work:
* - It may require correct/in-range values for request initialization.
* - It may require specifying regional endpoints when creating the service client,
* please see the apiEndpoint client configuration option for more details.
*/
function callSample(): void
{
$formattedName = ModelArmorClient::templateName('[PROJECT]', '[LOCATION]', '[TEMPLATE]');

stream_sanitize_user_prompt_sample($formattedName);
}
// [END modelarmor_v1beta_generated_ModelArmor_StreamSanitizeUserPrompt_sync]
38 changes: 38 additions & 0 deletions ModelArmor/src/V1beta/ByteDataItem.php

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions ModelArmor/src/V1beta/ByteDataItem/ByteItemType.php

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

62 changes: 62 additions & 0 deletions ModelArmor/src/V1beta/Client/ModelArmorClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
namespace Google\Cloud\ModelArmor\V1beta\Client;

use Google\ApiCore\ApiException;
use Google\ApiCore\BidiStream;
use Google\ApiCore\CredentialsWrapper;
use Google\ApiCore\GapicClientTrait;
use Google\ApiCore\Options\ClientOptions;
Expand Down Expand Up @@ -558,6 +559,52 @@ public function sanitizeUserPrompt(
return $this->startApiCall('SanitizeUserPrompt', $request, $callOptions)->wait();
}

/**
* Streaming version of Sanitizes Model Response.
*
* @example samples/V1beta/ModelArmorClient/stream_sanitize_model_response.php
*
* @param array $callOptions {
* Optional.
*
* @type int $timeoutMillis
* Timeout to use for this call.
* }
*
* @return BidiStream
*
* @throws ApiException Thrown if the API call fails.
*
* @experimental
*/
public function streamSanitizeModelResponse(array $callOptions = []): BidiStream
{
return $this->startApiCall('StreamSanitizeModelResponse', null, $callOptions);
}

/**
* Streaming version of Sanitize User Prompt.
*
* @example samples/V1beta/ModelArmorClient/stream_sanitize_user_prompt.php
*
* @param array $callOptions {
* Optional.
*
* @type int $timeoutMillis
* Timeout to use for this call.
* }
*
* @return BidiStream
*
* @throws ApiException Thrown if the API call fails.
*
* @experimental
*/
public function streamSanitizeUserPrompt(array $callOptions = []): BidiStream
{
return $this->startApiCall('StreamSanitizeUserPrompt', null, $callOptions);
}

/**
* Updates the parameters of a single floor setting of a project
*
Expand Down Expand Up @@ -644,6 +691,21 @@ public function getLocation(GetLocationRequest $request, array $callOptions = []

/**
* Lists information about the supported locations for this service.

This method lists locations based on the resource scope provided in
the [ListLocationsRequest.name][google.cloud.location.ListLocationsRequest.name] field: *
**Global locations**: If `name` is empty, the method lists the
public locations available to all projects. * **Project-specific
locations**: If `name` follows the format
`projects/{project}`, the method lists locations visible to that
specific project. This includes public, private, or other
project-specific locations enabled for the project.

For gRPC and client library implementations, the resource name is
passed as the `name` field. For direct service calls, the resource
name is
incorporated into the request path based on the specific service
implementation and version.
*
* The async variant is {@see ModelArmorClient::listLocationsAsync()} .
*
Expand Down
Loading
Loading