Esempio n. 1
0
 /**
  * Creates object from $parsedResponse.
  * 
  * @param array $parsedResponse XML response parsed into array.
  * 
  * @return WindowsAzure\Common\Models\RetentionPolicy
  */
 public static function create($parsedResponse)
 {
     $result = new RetentionPolicy();
     $result->setEnabled(Utilities::toBoolean($parsedResponse['Enabled']));
     if ($result->getEnabled()) {
         $result->setDays(intval($parsedResponse['Days']));
     }
     return $result;
 }
Esempio n. 2
0
 /**
  * Creates object from $parsedResponse.
  * 
  * @param array $parsedResponse XML response parsed into array.
  * 
  * @return WindowsAzure\Common\Models\Logging
  */
 public static function create($parsedResponse)
 {
     $result = new Logging();
     $result->setVersion($parsedResponse['Version']);
     $result->setDelete(Utilities::toBoolean($parsedResponse['Delete']));
     $result->setRead(Utilities::toBoolean($parsedResponse['Read']));
     $result->setWrite(Utilities::toBoolean($parsedResponse['Write']));
     $result->setRetentionPolicy(RetentionPolicy::create($parsedResponse['RetentionPolicy']));
     return $result;
 }
Esempio n. 3
0
 /**
  * Creates object from $parsedResponse.
  * 
  * @param array $parsedResponse XML response parsed into array.
  * 
  * @return WindowsAzure\Common\Models\Metrics
  */
 public static function create($parsedResponse)
 {
     $result = new Metrics();
     $result->setVersion($parsedResponse['Version']);
     $result->setEnabled(Utilities::toBoolean($parsedResponse['Enabled']));
     if ($result->getEnabled()) {
         $result->setIncludeAPIs(Utilities::toBoolean($parsedResponse['IncludeAPIs']));
     }
     $result->setRetentionPolicy(RetentionPolicy::create($parsedResponse['RetentionPolicy']));
     return $result;
 }
Esempio n. 4
0
 /**
  * @covers WindowsAzure\Common\Models\Metrics::setRetentionPolicy
  */
 public function testSetRetentionPolicy()
 {
     // Setup
     $sample = TestResources::getServicePropertiesSample();
     $metrics = new Metrics();
     $expected = RetentionPolicy::create($sample['Metrics']['RetentionPolicy']);
     // Test
     $metrics->setRetentionPolicy($expected);
     // Assert
     $actual = $metrics->getRetentionPolicy();
     $this->assertEquals($expected, $actual);
 }
Esempio n. 5
0
 /**
  * @covers WindowsAzure\Common\Models\Logging::setRetentionPolicy
  */
 public function testSetRetentionPolicy()
 {
     // Setup
     $sample = TestResources::getServicePropertiesSample();
     $logging = new Logging();
     $expected = RetentionPolicy::create($sample['Logging']['RetentionPolicy']);
     // Test
     $logging->setRetentionPolicy($expected);
     // Assert
     $actual = $logging->getRetentionPolicy();
     $this->assertEquals($expected, $actual);
 }
 public function testCheckRetentionPolicy()
 {
     $rp = new RetentionPolicy();
     $this->assertNull($rp->getDays(), 'Default RetentionPolicy->getDays should be null');
     $this->assertNull($rp->getEnabled(), 'Default RetentionPolicy->getEnabled should be null');
     $rp->setDays(10);
     $rp->setEnabled(true);
     $this->assertEquals(10, $rp->getDays(), 'Set RetentionPolicy->getDays should be 10');
     $this->assertTrue($rp->getEnabled(), 'Set RetentionPolicy->getEnabled should be true');
 }
 public function testCheckRetentionPolicy()
 {
     // Check that the default values of options are reasonable
     $rp = new RetentionPolicy();
     $this->assertNull($rp->getDays(), 'Default RetentionPolicy->getDays should be null');
     $this->assertNull($rp->getEnabled(), 'Default RetentionPolicy->getEnabled should be null');
     $rp->setDays(10);
     $rp->setEnabled(true);
     $this->assertEquals(10, $rp->getDays(), 'Set RetentionPolicy->getDays should be 10');
     $this->assertTrue($rp->getEnabled(), 'Set RetentionPolicy->getEnabled should be true');
 }
 /**
  * @covers WindowsAzure\Common\Models\RetentionPolicy::toArray
  */
 public function testToArrayWithoutDays()
 {
     // Setup
     $sample = TestResources::getServicePropertiesSample();
     $retentionPolicy = RetentionPolicy::create($sample['Logging']['RetentionPolicy']);
     $expected = array('Enabled' => $sample['Logging']['RetentionPolicy']['Enabled']);
     $retentionPolicy->setDays(null);
     // Test
     $actual = $retentionPolicy->toArray();
     // Assert
     $this->assertEquals($expected, $actual);
 }
 public static function getInterestingServiceProperties()
 {
     $ret = array();
     // This is the default that comes from the server.
     array_push($ret, self::getDefaultServiceProperties());
     $rp = new RetentionPolicy();
     $rp->setEnabled(true);
     $rp->setDays(10);
     $l = new Logging();
     $l->setRetentionPolicy($rp);
     // Note: looks like only v1.0 is available now.
     // http://msdn.microsoft.com/en-us/library/windowsazure/hh360996.aspx
     $l->setVersion('1.0');
     $l->setDelete(true);
     $l->setRead(true);
     $l->setWrite(true);
     $m = new Metrics();
     $m->setRetentionPolicy($rp);
     $m->setVersion('1.0');
     $m->setEnabled(true);
     $m->setIncludeAPIs(true);
     $sp = new ServiceProperties();
     $sp->setLogging($l);
     $sp->setMetrics($m);
     array_push($ret, $sp);
     $rp = new RetentionPolicy();
     // The service does not accept setting days when enabled is false.
     $rp->setEnabled(false);
     $rp->setDays(null);
     $l = new Logging();
     $l->setRetentionPolicy($rp);
     // Note: looks like only v1.0 is available now.
     // http://msdn.microsoft.com/en-us/library/windowsazure/hh360996.aspx
     $l->setVersion('1.0');
     $l->setDelete(false);
     $l->setRead(false);
     $l->setWrite(false);
     $m = new Metrics();
     $m->setRetentionPolicy($rp);
     $m->setVersion('1.0');
     $m->setEnabled(true);
     $m->setIncludeAPIs(true);
     $sp = new ServiceProperties();
     $sp->setLogging($l);
     $sp->setMetrics($m);
     array_push($ret, $sp);
     $rp = new RetentionPolicy();
     $rp->setEnabled(true);
     // Days has to be 0 < days <= 365
     $rp->setDays(364);
     $l = new Logging();
     $l->setRetentionPolicy($rp);
     // Note: looks like only v1.0 is available now.
     // http://msdn.microsoft.com/en-us/library/windowsazure/hh360996.aspx
     $l->setVersion('1.0');
     $l->setDelete(false);
     $l->setRead(false);
     $l->setWrite(false);
     $m = new Metrics();
     $m->setVersion('1.0');
     $m->setEnabled(false);
     $m->setIncludeAPIs(null);
     $m->setRetentionPolicy($rp);
     $sp = new ServiceProperties();
     $sp->setLogging($l);
     $sp->setMetrics($m);
     array_push($ret, $sp);
     return $ret;
 }
Esempio n. 10
0
 /**
  * Converts this object to array with XML tags
  * 
  * @return array. 
  */
 public function toArray()
 {
     return array('Version' => $this->_version, 'Delete' => Utilities::booleanToString($this->_delete), 'Read' => Utilities::booleanToString($this->_read), 'Write' => Utilities::booleanToString($this->_write), 'RetentionPolicy' => !empty($this->_retentionPolicy) ? $this->_retentionPolicy->toArray() : null);
 }