Welcome to mirror list, hosted at ThFree Co, Russian Federation.

Rackspace.php « OpenCloud « lib « php-opencloud « 3rdparty « files_external « apps - github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 41be608b347fb218d9df248986c19f1f4ebc83b9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
<?php
/**
 * The Rackspace cloud/connection class (which uses different authentication
 * than the pure OpenStack class)
 *
 * @copyright 2012-2013 Rackspace Hosting, Inc.
 * See COPYING for licensing information
 *
 * @package phpOpenCloud
 * @version 1.0
 * @author Glen Campbell <glen.campbell@rackspace.com>
 */

namespace OpenCloud;

/**
 * Rackspace extends the OpenStack class with support for Rackspace's
 * API key and tenant requirements.
 *
 * The only difference between Rackspace and OpenStack is that the
 * Rackspace class generates credentials using the username
 * and API key, as required by the Rackspace authentication
 * service.
 *
 * Example:
 * <code>
 * $username = 'FRED';
 * $apiKey = '0900af093093788912388fc09dde090ffee09';
 * $conn = new Rackspace(
 *      'https://identity.api.rackspacecloud.com/v2.0/',
 *      array(
 *          'username' => $username,
 *          'apiKey' => $apiKey
 *      ));
 * </code>
 */
class Rackspace extends OpenStack
{

    //this is the JSON string for our new credentials
const APIKEYTEMPLATE = <<<ENDCRED
{ "auth": { "RAX-KSKEY:apiKeyCredentials": { "username": "%s",
          "apiKey": "%s"
        }
    }
}
ENDCRED;

    /**
     * Generates Rackspace API key credentials
     *
     * @return string
     */
    public function Credentials()
    {
        $sec = $this->Secret();
        if (isset($sec['username'])
            && isset($sec['apiKey'])
        ) {
            return sprintf(
                self::APIKEYTEMPLATE,
                $sec['username'],
                $sec['apiKey']
           );
        } else {
            return parent::Credentials();
        }
    }

    /**
     * Creates a new DbService (Database as a Service) object
     *
     * This is a factory method that is Rackspace-only (NOT part of OpenStack).
     *
     * @param string $name the name of the service (e.g., 'Cloud Databases')
     * @param string $region the region (e.g., 'DFW')
     * @param string $urltype the type of URL (e.g., 'publicURL');
     */
    public function DbService($name = null, $region = null, $urltype = null)
    {
        return $this->Service('Database', $name, $region, $urltype);
    }

    /**
     * Creates a new LoadBalancerService object
     *
     * This is a factory method that is Rackspace-only (NOT part of OpenStack).
     *
     * @param string $name the name of the service
     *      (e.g., 'Cloud Load Balancers')
     * @param string $region the region (e.g., 'DFW')
     * @param string $urltype the type of URL (e.g., 'publicURL');
     */
    public function LoadBalancerService($name = null, $region = null, $urltype = null)
    {
        return $this->Service('LoadBalancer', $name, $region, $urltype);
    }

    /**
     * creates a new DNS service object
     *
     * This is a factory method that is currently Rackspace-only
     * (not available via the OpenStack class)
     */
    public function DNS($name = null, $region = null, $urltype = null)
    {
        return $this->Service('DNS', $name, $region, $urltype);
    }

    /**
     * creates a new CloudMonitoring service object
     *
     * This is a factory method that is currently Rackspace-only
     * (not available via the OpenStack class)
     */
    public function CloudMonitoring($name=null, $region=null, $urltype=null)
    {
        return $this->Service('CloudMonitoring', $name, $region, $urltype);
    }

    /**
     * creates a new Autoscale service object
     *
     * This is a factory method that is currently Rackspace-only
     * (not available via the OpenStack class)
     */
    public function Autoscale($name=null, $region=null, $urltype=null)
    {
        return $this->Service('Autoscale', $name, $region, $urltype);
    }

}