/**
  * Builds a file object.
  *
  * @param string $connectionString The configuration connection string.
  *
  * @return \WindowsFileService\File\Internal\IFile
  */
 public function createFileService($connectionString)
 {
     $settings = StorageServiceSettings::createFromConnectionString($connectionString);
     $httpClient = $this->httpClient();
     $serializer = $this->serializer();
     $uri = Utilities::tryAddUrlScheme($settings->getFileEndpointUri());
     $fileWrapper = new FileRestProxy($httpClient, $uri, $settings->getName(), $serializer);
     // Adding headers filter
     $headers = array(Resources::USER_AGENT => Resources::SDK_USER_AGENT);
     $headers[Resources::X_MS_VERSION] = Resources::FILE_API_LATEST_VERSION;
     $headersFilter = new HeadersFilter($headers);
     $fileWrapper = $fileWrapper->withFilter($headersFilter);
     // Adding date filter
     $dateFilter = new DateFilter();
     $fileWrapper = $fileWrapper->withFilter($dateFilter);
     $authFilter = new AuthenticationFilter($this->fileAuthenticationScheme($settings->getName(), $settings->getKey()));
     $fileWrapper = $fileWrapper->withFilter($authFilter);
     return $fileWrapper;
 }
 /**
  * @covers WindowsAzure\Common\Internal\Utilities::tryAddUrlScheme
  */
 public function testTryAddUrlSchemeWithoutScheme()
 {
     // Setup
     $url = 'microsoft.com';
     $expected = 'http://microsoft.com';
     // Test
     $actual = Utilities::tryAddUrlScheme($url);
     // Assert
     $this->assertEquals($expected, $actual);
 }
 /**
  * Builds a media services object.
  *
  * @param WindowsAzure\Common\Internal\MediaServicesSettings $settings The media
  * services configuration settings.
  *
  * @return WindowsAzure\MediaServices\Internal\IMediaServices
  */
 public function createMediaServicesService($settings)
 {
     Validate::isA($settings, 'WindowsAzure\\Common\\Internal\\MediaServicesSettings', 'settings');
     $httpClient = new HttpClient();
     $serializer = $this->serializer();
     $uri = Utilities::tryAddUrlScheme($settings->getEndpointUri(), Resources::HTTPS_SCHEME);
     $mediaServicesWrapper = new MediaServicesRestProxy($httpClient, $uri, $settings->getAccountName(), $serializer);
     // Adding headers filter
     $xMSVersion = Resources::MEDIA_SERVICES_API_LATEST_VERSION;
     $dataVersion = Resources::MEDIA_SERVICES_DATA_SERVICE_VERSION_VALUE;
     $dataMaxVersion = Resources::MEDIA_SERVICES_MAX_DATA_SERVICE_VERSION_VALUE;
     $accept = Resources::ACCEPT_HEADER_VALUE;
     $contentType = Resources::ATOM_ENTRY_CONTENT_TYPE;
     $userAgent = Resources::SDK_USER_AGENT;
     $headers = array(Resources::X_MS_VERSION => $xMSVersion, Resources::DATA_SERVICE_VERSION => $dataVersion, Resources::MAX_DATA_SERVICE_VERSION => $dataMaxVersion, Resources::ACCEPT_HEADER => $accept, Resources::CONTENT_TYPE => $contentType, Resources::USER_AGENT => $userAgent);
     $headersFilter = new HeadersFilter($headers);
     $mediaServicesWrapper = $mediaServicesWrapper->withFilter($headersFilter);
     // Adding OAuth filter
     $oauthService = new OAuthRestProxy(new HttpClient(), $settings->getOAuthEndpointUri());
     $authentification = new OAuthScheme($settings->getAccountName(), $settings->getAccessKey(), Resources::OAUTH_GT_CLIENT_CREDENTIALS, Resources::MEDIA_SERVICES_OAUTH_SCOPE, $oauthService);
     $authentificationFilter = new AuthenticationFilter($authentification);
     $mediaServicesWrapper = $mediaServicesWrapper->withFilter($authentificationFilter);
     return $mediaServicesWrapper;
 }
Esempio n. 4
0
 /**
  * Builds a service management object.
  *
  * @param string $connectionString The configuration connection string.
  * 
  * @return WindowsAzure\ServiceManagement\Internal\IServiceManagement
  */
 public function createServiceManagementService($connectionString)
 {
     $settings = ServiceManagementSettings::createFromConnectionString($connectionString);
     $certificatePath = $settings->getCertificatePath();
     $httpClient = new HttpClient($certificatePath);
     $serializer = $this->serializer();
     $uri = Utilities::tryAddUrlScheme($settings->getEndpointUri(), Resources::HTTPS_SCHEME);
     $serviceManagementWrapper = new ServiceManagementRestProxy($httpClient, $settings->getSubscriptionId(), $uri, $serializer);
     // Adding headers filter
     $headers = array();
     $headers[Resources::X_MS_VERSION] = Resources::SM_API_LATEST_VERSION;
     $headersFilter = new HeadersFilter($headers);
     $serviceManagementWrapper = $serviceManagementWrapper->withFilter($headersFilter);
     return $serviceManagementWrapper;
 }
 /**
  * Builds a service management object.
  *
  * @param WindowsAzure\Common\Configuration $config The configuration.
  * 
  * @return WindowsAzure\ServiceManagement\Internal\IServiceManagement
  */
 private function _buildServiceManagement($config)
 {
     $certificatePath = $config->getProperty(ServiceManagementSettings::CERTIFICATE_PATH);
     $httpClient = new HttpClient($certificatePath);
     $xmlSerializer = new XmlSerializer();
     $uri = Utilities::tryAddUrlScheme($config->getProperty(ServiceManagementSettings::URI), Resources::HTTPS_SCHEME);
     $serviceManagementWrapper = new ServiceManagementRestProxy($httpClient, $config->getProperty(ServiceManagementSettings::SUBSCRIPTION_ID), $uri, $xmlSerializer);
     // Adding headers filter
     $serviceManagementWrapper = self::_addHeadersFilter($serviceManagementWrapper, Resources::SERVICE_MANAGEMENT_TYPE_NAME);
     return $serviceManagementWrapper;
 }