Open ghost opened 6 years ago
Leaving this here for future reference: The initial call to the LoadBalancerService returns incorrectly 'keyed' items in the Iterator.
Workaround using:
// Set up the Service
$service = $client->loadBalancerService(null, 'LON');
// Fetch the LoadBalancer Resource with a specified $id
$lb = $service->loadBalancer($id);
// Fetch a list of Certificate Mappings
$cert_mapping_list = $lb->certificateMappingList();
// Define a new container
$map = [];
// Old school way of looping through the iterator
while ($cert_mapping_list->valid()) {
// Access the method forcing it to populate
$ele = $cert_mapping_list->currentElement();
// Now has access to the property containing the key, authority and cert
$map[] = $ele->certificateMapping;
// Continue to next mapping
$cert_mapping_list->next();
}
// Re-assign back to the Resource.
$lb->certificateMappingList = $map;
That was helpful. I was wondering what happened after a recent update. This save me a bunch of time.
I can create a certficate mapping but when I come to view the list of certificate mappings I get a PaginatedIterator object which contains the correct number of CertificateMapping but each one doesn't contain any data.
I first authenticate and then do the following:
$loadbalancer = $client->loadBalancerService( null, 'LON' ); $lb = $loadbalancer->loadBalancer(xxxxxx); $list = $lb->certificateMappingList(); $cert = $list->current(); var_dump( $cert );
Which the var_dump returns:
object(OpenCloud\LoadBalancer\Resource\CertificateMapping)[52] public 'id' => null public 'hostName' => null public 'certificate' => null public 'privateKey' => null public 'intermediateCertificate' => null protected 'createKeys' => array (size=4) 0 => string 'hostName' (length=8) 1 => string 'certificate' (length=11) 2 => string 'privateKey' (length=10) 3 => string 'intermediateCertificate' (length=23)........