Skip to content
Merged
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
30 changes: 30 additions & 0 deletions Run/metadata/V2/ContainerStatus.php

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

Binary file added Run/metadata/V2/Instance.php
Binary file not shown.
Binary file modified Run/metadata/V2/K8SMin.php
Binary file not shown.
101 changes: 101 additions & 0 deletions Run/samples/V2/InstancesClient/create_instance.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
<?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 run_v2_generated_Instances_CreateInstance_sync]
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\Run\V2\Client\InstancesClient;
use Google\Cloud\Run\V2\Container;
use Google\Cloud\Run\V2\CreateInstanceRequest;
use Google\Cloud\Run\V2\Instance;
use Google\Rpc\Status;

/**
* Creates an Instance.
*
* @param string $formattedParent Please see {@see InstancesClient::locationName()} for help formatting this field.
* @param string $instanceContainersImage Name of the container image in Dockerhub, Google Artifact
* Registry, or Google Container Registry. If the host is not provided,
* Dockerhub is assumed.
* @param string $instanceId The unique identifier for the Instance. It must begin with
* letter, and cannot end with hyphen; must contain fewer than 50 characters.
* The name of the instance becomes {parent}/instances/{instance_id}.
*/
function create_instance_sample(
string $formattedParent,
string $instanceContainersImage,
string $instanceId
): void {
// Create a client.
$instancesClient = new InstancesClient();

// Prepare the request message.
$container = (new Container())
->setImage($instanceContainersImage);
$instanceContainers = [$container,];
$instance = (new Instance())
->setContainers($instanceContainers);
$request = (new CreateInstanceRequest())
->setParent($formattedParent)
->setInstance($instance)
->setInstanceId($instanceId);

// Call the API and handle any network failures.
try {
/** @var OperationResponse $response */
$response = $instancesClient->createInstance($request);
$response->pollUntilComplete();

if ($response->operationSucceeded()) {
/** @var Instance $result */
$result = $response->getResult();
printf('Operation successful with response data: %s' . PHP_EOL, $result->serializeToJsonString());
} else {
/** @var Status $error */
$error = $response->getError();
printf('Operation failed with error data: %s' . PHP_EOL, $error->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
{
$formattedParent = InstancesClient::locationName('[PROJECT]', '[LOCATION]');
$instanceContainersImage = '[IMAGE]';
$instanceId = '[INSTANCE_ID]';

create_instance_sample($formattedParent, $instanceContainersImage, $instanceId);
}
// [END run_v2_generated_Instances_CreateInstance_sync]
82 changes: 82 additions & 0 deletions Run/samples/V2/InstancesClient/delete_instance.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
<?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 run_v2_generated_Instances_DeleteInstance_sync]
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\Run\V2\Client\InstancesClient;
use Google\Cloud\Run\V2\DeleteInstanceRequest;
use Google\Cloud\Run\V2\Instance;
use Google\Rpc\Status;

/**
* Deletes a Instance
*
* @param string $formattedName Please see {@see InstancesClient::instanceName()} for help formatting this field.
*/
function delete_instance_sample(string $formattedName): void
{
// Create a client.
$instancesClient = new InstancesClient();

// Prepare the request message.
$request = (new DeleteInstanceRequest())
->setName($formattedName);

// Call the API and handle any network failures.
try {
/** @var OperationResponse $response */
$response = $instancesClient->deleteInstance($request);
$response->pollUntilComplete();

if ($response->operationSucceeded()) {
/** @var Instance $result */
$result = $response->getResult();
printf('Operation successful with response data: %s' . PHP_EOL, $result->serializeToJsonString());
} else {
/** @var Status $error */
$error = $response->getError();
printf('Operation failed with error data: %s' . PHP_EOL, $error->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 = InstancesClient::instanceName('[PROJECT]', '[LOCATION]', '[INSTANCE]');

delete_instance_sample($formattedName);
}
// [END run_v2_generated_Instances_DeleteInstance_sync]
70 changes: 70 additions & 0 deletions Run/samples/V2/InstancesClient/get_instance.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
<?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 run_v2_generated_Instances_GetInstance_sync]
use Google\ApiCore\ApiException;
use Google\Cloud\Run\V2\Client\InstancesClient;
use Google\Cloud\Run\V2\GetInstanceRequest;
use Google\Cloud\Run\V2\Instance;

/**
* Gets a Instance
*
* @param string $formattedName Please see {@see InstancesClient::instanceName()} for help formatting this field.
*/
function get_instance_sample(string $formattedName): void
{
// Create a client.
$instancesClient = new InstancesClient();

// Prepare the request message.
$request = (new GetInstanceRequest())
->setName($formattedName);

// Call the API and handle any network failures.
try {
/** @var Instance $response */
$response = $instancesClient->getInstance($request);
printf('Response data: %s' . PHP_EOL, $response->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 = InstancesClient::instanceName('[PROJECT]', '[LOCATION]', '[INSTANCE]');

get_instance_sample($formattedName);
}
// [END run_v2_generated_Instances_GetInstance_sync]
78 changes: 78 additions & 0 deletions Run/samples/V2/InstancesClient/list_instances.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
<?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 run_v2_generated_Instances_ListInstances_sync]
use Google\ApiCore\ApiException;
use Google\ApiCore\PagedListResponse;
use Google\Cloud\Run\V2\Client\InstancesClient;
use Google\Cloud\Run\V2\Instance;
use Google\Cloud\Run\V2\ListInstancesRequest;

/**
* Lists Instances. Results are sorted by creation time, descending.
*
* @param string $formattedParent The location and project to list resources on.
* Format: projects/{project}/locations/{location}, where {project} can be
* project id or number. Please see
* {@see InstancesClient::locationName()} for help formatting this field.
*/
function list_instances_sample(string $formattedParent): void
{
// Create a client.
$instancesClient = new InstancesClient();

// Prepare the request message.
$request = (new ListInstancesRequest())
->setParent($formattedParent);

// Call the API and handle any network failures.
try {
/** @var PagedListResponse $response */
$response = $instancesClient->listInstances($request);

/** @var Instance $element */
foreach ($response 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
{
$formattedParent = InstancesClient::locationName('[PROJECT]', '[LOCATION]');

list_instances_sample($formattedParent);
}
// [END run_v2_generated_Instances_ListInstances_sync]
Loading
Loading