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
1 change: 1 addition & 0 deletions .php_cs.dist
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ return PhpCsFixer\Config::create()
'@PSR2' => true,
'concat_space' => ['spacing' => 'one'],
'no_unused_imports' => true,
'method_argument_space' => false,
])
->setFinder(
PhpCsFixer\Finder::create()
Expand Down
198 changes: 119 additions & 79 deletions compute/helloworld/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,52 +120,60 @@ function generateMarkup($apiRequestName, $apiResponse)
* Google Compute Engine API request to retrieve the list of instances in your
* Google Compute Engine project.
*/
$instances = $computeService->instances->listInstances(DEFAULT_PROJECT,
DEFAULT_ZONE_NAME);
$instancesListMarkup = generateMarkup('List Instances', $instances);
$instances = $computeService->instances->listInstances(
DEFAULT_PROJECT,
DEFAULT_ZONE_NAME
);

/**
* Google Compute Engine API request to retrieve the list of all data center
* locations associated with your Google Compute Engine project.
*/
$zones = $computeService->zones->listZones(DEFAULT_PROJECT);
$instancesListMarkup = generateMarkup(
'List Instances',
$instances
);

/**
* Google Compute Engine API request to retrieve the list of all data center
* locations associated with your Google Compute Engine project.
*/
$zones = $computeService->zones->listZones(DEFAULT_PROJECT);
$zonesListMarkup = generateMarkup('List Zones', $zones);

/**
* Google Compute Engine API request to retrieve the list of all machine types
* associated associated with your Google Compute Engine project.
*/
$machineTypes = $computeService->machineTypes->listMachineTypes(DEFAULT_PROJECT);
$machineTypesListMarkup = generateMarkup('List Machine Types',
$machineTypes);
/**
* Google Compute Engine API request to retrieve the list of all machine types
* associated with your Google Compute Engine project.
*/
$machineTypes = $computeService->machineTypes->listMachineTypes(DEFAULT_PROJECT);
$machineTypesListMarkup = generateMarkup(
'List Machine Types',
$machineTypes
);

/**
* Google Compute Engine API request to retrieve the list of all image types
* associated associated with your Google Compute Engine project.
*/
$images = $computeService->images->listImages(GOOGLE_PROJECT);
/**
* Google Compute Engine API request to retrieve the list of all image types
* associated with your Google Compute Engine project.
*/
$images = $computeService->images->listImages(GOOGLE_PROJECT);
$imagesListMarkup = generateMarkup('List Images', $images);

/**
* Google Compute Engine API request to retrieve the list of all firewalls
* associated associated with your Google Compute Engine project.
*/
$firewalls = $computeService->firewalls->listFirewalls(DEFAULT_PROJECT);
/**
* Google Compute Engine API request to retrieve the list of all firewalls
* associated with your Google Compute Engine project.
*/
$firewalls = $computeService->firewalls->listFirewalls(DEFAULT_PROJECT);
$firewallsListMarkup = generateMarkup('List Firewalls', $firewalls);

/**
* Google Compute Engine API request to retrieve the list of all networks
* associated associated with your Google Compute Engine project.
*/
$networks = $computeService->networks->listNetworks(DEFAULT_PROJECT);
/**
* Google Compute Engine API request to retrieve the list of all networks
* associated with your Google Compute Engine project.
*/
$networks = $computeService->networks->listNetworks(DEFAULT_PROJECT);
$networksListMarkup = generateMarkup('List Networks', $networks);
;

/**
* Google Compute Engine API request to insert a new instance into your Google
* Compute Engine project.
*/
$name = DEFAULT_NAME;
/**
* Google Compute Engine API request to insert a new instance into your Google
* Compute Engine project.
*/
$name = DEFAULT_NAME;
$machineType = DEFAULT_MACHINE_TYPE;
$zone = DEFAULT_ZONE_NAME;
$image = DEFAULT_IMAGE;
Expand All @@ -184,11 +192,11 @@ function generateMarkup($apiRequestName, $apiResponse)
$zone, $new_instance);
$insertInstanceMarkup = generateMarkup('Insert Instance', $insertInstance);

/**
* Google Compute Engine API request to insert a new instance (with metadata)
* into your Google Compute Engine project.
*/
$name = DEFAULT_NAME_WITH_METADATA;
/**
* Google Compute Engine API request to insert a new instance (with metadata)
* into your Google Compute Engine project.
*/
$name = DEFAULT_NAME_WITH_METADATA;
$machineType = DEFAULT_MACHINE_TYPE;
$zone = DEFAULT_ZONE_NAME;
$image = DEFAULT_IMAGE;
Expand All @@ -212,53 +220,85 @@ function generateMarkup($apiRequestName, $apiResponse)
$new_instance->setMetadata($metadata);

$insertInstanceWithMetadata = $computeService->instances->insert(
DEFAULT_PROJECT, $zone, $new_instance);
DEFAULT_PROJECT,
$zone,
$new_instance
);

$insertInstanceWithMetadataMarkup = generateMarkup(
'Insert Instance With Metadata', $insertInstanceWithMetadata);
'Insert Instance With Metadata',
$insertInstanceWithMetadata
);

/**
* Google Compute Engine API request to get an instance matching the outlined
* parameters from your Google Compute Engine project.
*/
$getInstance = $computeService->instances->get(
DEFAULT_PROJECT,
DEFAULT_ZONE_NAME,
DEFAULT_NAME
);

/**
* Google Compute Engine API request to get an instance matching the outlined
* parameters from your Google Compute Engine project.
*/
$getInstance = $computeService->instances->get(DEFAULT_PROJECT,
DEFAULT_ZONE_NAME, DEFAULT_NAME);
$getInstanceMarkup = generateMarkup('Get Instance', $getInstance);

/**
* Google Compute Engine API request to get an instance matching the outlined
* parameters from your Google Compute Engine project.
*/
$getInstanceWithMetadata = $computeService->instances->get(DEFAULT_PROJECT,
DEFAULT_ZONE_NAME, DEFAULT_NAME_WITH_METADATA);
$getInstanceWithMetadataMarkup = generateMarkup('Get Instance With Metadata',
$getInstanceWithMetadata);

/**
* Google Compute Engine API request to delete an instance matching the
* outlined parameters from your Google Compute Engine project.
*/
$deleteInstance = $computeService->instances->delete(DEFAULT_PROJECT,
DEFAULT_ZONE_NAME, DEFAULT_NAME);
/**
* Google Compute Engine API request to get an instance matching the outlined
* parameters from your Google Compute Engine project.
*/
$getInstanceWithMetadata = $computeService->instances->get(
DEFAULT_PROJECT,
DEFAULT_ZONE_NAME,
DEFAULT_NAME_WITH_METADATA
);

$getInstanceWithMetadataMarkup = generateMarkup(
'Get Instance With Metadata',
$getInstanceWithMetadata
);

/**
* Google Compute Engine API request to delete an instance matching the
* outlined parameters from your Google Compute Engine project.
*/
$deleteInstance = $computeService->instances->delete(
DEFAULT_PROJECT,
DEFAULT_ZONE_NAME,
DEFAULT_NAME
);

$deleteInstanceMarkup = generateMarkup('Delete Instance', $deleteInstance);

/**
* Google Compute Engine API request to delete an instance matching the
* outlined parameters from your Google Compute Engine project.
*/
$deleteInstanceWithMetadata = $computeService->instances->delete(DEFAULT_PROJECT,
DEFAULT_ZONE_NAME, DEFAULT_NAME_WITH_METADATA);
$deleteInstanceWithMetadataMarkup = generateMarkup(
'Delete Instance With Metadata', $deleteInstanceWithMetadata);
/**
* Google Compute Engine API request to delete an instance matching the
* outlined parameters from your Google Compute Engine project.
*/
$deleteInstanceWithMetadata = $computeService->instances->delete(
DEFAULT_PROJECT,
DEFAULT_ZONE_NAME,
DEFAULT_NAME_WITH_METADATA
);

/**
* Google Compute Engine API request to retrieve the list of all global
* operations associated with your Google Compute Engine project.
*/
$globalOperations = $computeService->globalOperations->listGlobalOperations(DEFAULT_PROJECT);
$operationsListMarkup = generateMarkup('List Global Operations', $globalOperations);
$deleteInstanceWithMetadataMarkup = generateMarkup(
'Delete Instance With Metadata',
$deleteInstanceWithMetadata
);

// The access token may have been updated lazily.
$_SESSION['access_token'] = $client->getAccessToken();
/**
* Google Compute Engine API request to retrieve the list of all global
* operations associated with your Google Compute Engine project.
*/
$globalOperations = $computeService->globalOperations->listGlobalOperations(
DEFAULT_PROJECT
);

$operationsListMarkup = generateMarkup(
'List Global Operations',
$globalOperations
);

// The access token may have been updated lazily.
$_SESSION['access_token'] = $client->getAccessToken();
} else {
$authUrl = $client->createAuthUrl();
}
Expand Down
18 changes: 11 additions & 7 deletions logging/api/test/ListEntriesCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,23 +51,27 @@ public function setUp()
if (!$this->projectId = getenv('GOOGLE_PROJECT_ID')) {
$this->markTestSkipped('No project ID');
}

// up the default retry count
$this->eventuallyConsistentRetryCount = 5;
}

public function testListEntries()
{
$application = new Application();
$application->add(new WriteCommand());
$commandTester = new CommandTester($application->get('write'));
$commandTester->execute(
$application->add(new ListEntriesCommand());

$writeCommandTester = new CommandTester($application->get('write'));
$writeCommandTester->execute(
[
'--project' => $this->projectId,
'--logger' => 'my_test_logger',
'message' => 'Test Message'
],
['interactive' => false]
);
}

public function testListEntries()
{
$application = new Application();
$application->add(new ListEntriesCommand());
$commandTester = new CommandTester($application->get('list-entries'));
$this->runEventuallyConsistentTest(function () use ($commandTester) {
ob_start();
Expand Down
2 changes: 1 addition & 1 deletion spanner/test/spannerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public static function setUpBeforeClass()
$instance = $spanner->instance(self::$instanceId);

$operation = $instance->create($configuration);
$operation->result();
$operation->pollUntilComplete();

self::$instance = $instance;
}
Expand Down