getQueryArray() public method

This method overrides parent method.
public getQueryArray ( string $uriParameterName = null, boolean $member = true ) : string
$uriParameterName string optional Parameter name. If null it will use class property name that is provided in constructor.
$member boolean optional Should it add member prefix
return string Returns query parameters array looks like array ( 'parameterName.member.n[.propName[.member.m]]' => value ) Values are not url encoded.
Example #1
0
 /**
  * @test
  * @dataProvider provider
  */
 public function testConstructor($aListData, $propertyName, $dataClassName = null, $opt = array())
 {
     $list = new ListDataType($aListData, $propertyName, $dataClassName);
     $this->assertEquals($opt, $list->getQueryArray(), 'Unexpected options array');
     $this->assertEquals(count($opt), (is_array($propertyName) ? count($propertyName) : 1) * count($list), 'Different number of arguments');
     $this->assertInstanceOf('Iterator', $list, 'List does not implement Iterator interface.');
     $this->assertInstanceOf('Countable', $list, 'List does not implement Countable interface.');
     if (!is_array($propertyName)) {
         $keys = array_keys($opt);
         foreach ($list->getQueryArray() as $key => $value) {
             $this->assertContains($key, $keys, 'Missing key');
             $this->assertContains($value, $opt, 'Missing value');
         }
         $this->assertEquals(array_values($opt), $list->getComputed(), 'Unexpected out of getComputed() method.');
     } else {
         if ($dataClassName != null) {
             foreach ($list as $value) {
                 $this->assertInstanceOf($dataClassName, $value);
             }
         }
     }
     unset($list);
 }
Example #2
0
 /**
  * Type cast the list of the InstanceId into accepted state.
  *
  * It transforms 'Instances.member.N.InstanceId' structure to acceptable 'InstancesId.N' structure
  *
  * @param   ListDataType $instanceIdList  The list of the Instance ID
  * @param   string       $name            optional URL parameter name
  * @return  array Returns array of the query parameters for the request
  */
 public function getInstanceIdListQuery(ListDataType $instanceIdList, $name = 'InstanceId')
 {
     if ($instanceIdList instanceof \Scalr\Service\Aws\Ec2\DataType\InstanceData || $instanceIdList instanceof \Scalr\Service\Aws\Elb\DataType\InstanceData) {
         $instanceIdList = new ListDataType(array_unique(array_values($instanceIdList->getQueryArray('Instances'))));
     }
     $options = $instanceIdList->getQueryArrayBare($name);
     return $options;
 }
Example #3
0
 /**
  * SetLoadBalancerPoliciesForBackendServer action
  *
  * Replaces the current set of policies associated with a port on which
  * the back-end server is listening with a new set of policies.
  * After the policies have been created using CreateLoadBalancerPolicy, they
  * can be applied here as a list. At this time, only the back-end server authentication policy type can be
  * applied to the back-end ports; this policy type is composed of multiple public key policies
  *
  * @param   string       $loadBalancerName The mnemonic name associated with the LoadBalancer.
  * @param   int          $instancePort     The port number associated with the back-end server.
  * @param   ListDataType $policyNamesList  List of policy names to be set. If the list is empty, then all
  *                                         current polices are removed from the back-end server.
  * @return  array Returns updated list of policy names.
  * @throws  ClientException
  */
 public function setLoadBalancerPoliciesForBackendServer($loadBalancerName, $instancePort, ListDataType $policyNamesList = null)
 {
     $result = array();
     $options = array('LoadBalancerName' => (string) $loadBalancerName, 'InstancePort' => (int) $instancePort);
     if ($policyNamesList !== null) {
         $options = array_merge($options, $policyNamesList->getQueryArray('PolicyNames'));
     } else {
         $policyNamesList = new ListDataType();
     }
     $response = $this->client->call('SetLoadBalancerPoliciesForBackendServer', $options);
     if ($response->getError() === false) {
         $result = array_values($policyNamesList->getQueryArray('PolicyNames'));
         //Tries to look loadBalancer instance up in the repository.
         $loadBalancer = $this->elb->loadBalancer->get($options['LoadBalancerName']);
         if ($loadBalancer !== null && $loadBalancer->backendServerDescriptions !== null) {
             /* @var $bsDescription BackendServerDescriptionData */
             foreach ($loadBalancer->backendServerDescriptions as $k => $bsDescription) {
                 if ($bsDescription->instancePort == $options['InstancePort']) {
                     $loadBalancer->backendServerDescriptions[$k]->policyNames = $result;
                     break;
                 }
             }
         }
     }
     return $result;
 }
Example #4
0
 /**
  * Removes metadata tags from an Amazon RDS resource.
  *
  * @param string            $resourceName  Resource identifier for the Amazon RDS resource.
  * @param string            $resourceType  The type of Amazon RDS resource (db|es|og|pg|ri|secgrp|snapshot|subgrp)
  * @param ListDataType      $tagKeyList    Array of tag keys to remove
  * @return bool
  * @throws RdsException
  */
 public function removeTagsFromResource($resourceName, $resourceType, ListDataType $tagKeyList)
 {
     $result = false;
     $options = $tagKeyList->getQueryArray();
     $options['ResourceName'] = $this->rds->getResourceName($resourceName, $resourceType);
     $response = $this->client->call(ucfirst(__FUNCTION__), $options);
     if ($response->getError() === false) {
         $sxml = simplexml_load_string($response->getRawContent());
         $result = true;
     }
     return $result;
 }
Example #5
0
 /**
  * Removes one or more tags from the specified load balancer.
  *
  * @param ListDataType $loadBalancerNamesList A list of names associated with the LoadBalancers at creation time.
  * @param ListDataType $tagsKeys              A list of tag keys to remove.
  * @return bool                               Returns true on success. False otherwise
  * @throws ElbException
  */
 public function removeTags(ListDataType $loadBalancerNamesList, ListDataType $tagsKeys)
 {
     $result = false;
     $options = $loadBalancerNamesList->getQueryArray('LoadBalancerNames');
     $tagsArray = $tagsKeys->getQueryArray();
     foreach ($tagsArray as $key => $option) {
         $newKey = $key . '.Key';
         $tagsOptions[$newKey] = $option;
     }
     $options = array_merge($options, $tagsOptions);
     $response = $this->client->call('RemoveTags', $options);
     if ($response->getError() === false) {
         $sxml = simplexml_load_string($response->getRawContent());
         if (!isset($sxml->RemoveTagsResult)) {
             throw new ElbException('Unexpected response ' . $response->getRawContent());
         }
         $result = true;
     }
     return $result;
 }
Example #6
0
 /**
  * Gets statistics for the specified metric.
  *
  * Note!
  * The maximum number of data points returned from a single GetMetricStatistics request
  * is 1,440. If a request is made that generates more than 1,440 data points, Amazon CloudWatch
  * returns an error. In such a case, alter the request by narrowing the specified time range or
  * increasing the specified period. Alternatively, make multiple requests across adjacent time ranges.
  *
  * Amazon CloudWatch aggregates data points based on the length of the period that you specify. For
  * example, if you request statistics with a one-minute granularity, Amazon CloudWatch aggregates data
  * points with time stamps that fall within the same one-minute period. In such a case, the data points queried
  * can greatly outnumber the data points returned.
  *
  * Note!
  * The maximum number of data points that can be queried is 50,850; whereas the maximum
  * number of data points returned is 1,440.
  *
  * The following examples show various statistics allowed by the data point query maximum of 50,850 when
  * you call GetMetricStatistics on Amazon EC2 instances with detailed (one-minute) monitoring
  * enabled:
  *  -  Statistics for up to 400 instances for a span of one hour
  *  -  Statistics for up to 35 instances over a span of 24 hours
  *  -  Statistics for up to 2 instances over a span of 2 weeks
  *
  * @param   string        $metricName The name of the metric, with or without spaces.
  * @param   \DateTime     $startTime  The time stamp to use for determining the first datapoint to return.
  *                                    The value specified is inclusive; results include datapoints with the
  *                                    time stamp specified.
  * @param   \DateTime     $endTime    The time stamp to use for determining the last datapoint to return.
  *                                    The value specified is exclusive; results will include datapoints up
  *                                    to the time stamp specified.
  * @param   ListDataType  $statistics The metric statistics to return.
  *                                    Valid Values: Average | Sum | SampleCount | Maximum | Minimum
  * @param   string        $namespace  The namespace of the metric, with or without spaces.
  * @param   int           $period     optional The granularity, in seconds, of the returned datapoints.
  *                                    Period must be at least 60 seconds and must be a multiple of 60.
  *                                    The default value is 60.
  * @param   string        $unit       optional The unit for the metric.
  * @param   DimensionList $dimensions optional A list of dimensions describing qualities of the metric.
  * @return  DatapointList Returns the datapoints for the specified metric.
  * @throws  ClientException
  * @throws  CloudWatchException
  */
 public function getMetricStatistics($metricName, \DateTime $startTime, \DateTime $endTime, ListDataType $statistics, $namespace, $period = 60, $unit = null, DimensionList $dimensions = null)
 {
     $result = null;
     $options = array('MetricName' => (string) $metricName, 'StartTime' => $startTime->format('c'), 'EndTime' => $endTime->format('c'), 'Period' => (int) $period, 'Namespace' => (string) $namespace);
     $options = array_merge($options, $statistics->getQueryArray('Statistics'));
     if ($dimensions != null) {
         $options = array_merge($options, $dimensions->getQueryArray());
     }
     if ($unit !== null) {
         $options['Unit'] = (string) $unit;
     }
     $response = $this->client->call('GetMetricStatistics', $options);
     if ($response->getError() === false) {
         //Success
         $sxml = simplexml_load_string($response->getRawContent());
         if (!isset($sxml->GetMetricStatisticsResult)) {
             throw new CloudWatchException('Unexpected response! ' . $response->getRawContent());
         }
         $ptr =& $sxml->GetMetricStatisticsResult;
         $result = new DatapointList();
         $result->setCloudWatch($this->cloudWatch);
         $result->setMetricName(!empty($ptr->Label) ? (string) $ptr->Label : null);
         if (!empty($ptr->Datapoints->member)) {
             foreach ($ptr->Datapoints->member as $v) {
                 $datapoint = new DatapointData();
                 $datapoint->average = (double) $v->Average;
                 $datapoint->maximum = (double) $v->Maximum;
                 $datapoint->minimum = (double) $v->Minimum;
                 $datapoint->sampleCount = (double) $v->SampleCount;
                 $datapoint->sum = (double) $v->Sum;
                 $datapoint->timestamp = new \DateTime((string) $v->Timestamp);
                 $datapoint->unit = (string) $v->Unit;
                 $result->append($datapoint);
                 unset($datapoint);
             }
         }
         unset($ptr);
     }
     return $result;
 }