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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
|
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE book [
<!-- Some useful entities borrowed from HTML -->
<!ENTITY ndash "–">
<!ENTITY mdash "—">
<!ENTITY hellip "…">
<!-- Useful for describing APIs -->
<!ENTITY GET '<command xmlns="http://docbook.org/ns/docbook">GET</command>'>
<!ENTITY PUT '<command xmlns="http://docbook.org/ns/docbook">PUT</command>'>
<!ENTITY POST '<command xmlns="http://docbook.org/ns/docbook">POST</command>'>
<!ENTITY DELETE '<command xmlns="http://docbook.org/ns/docbook">DELETE</command>'>
<!-- changing authentication endpoints; define entities for US & UK rather than maintaining in text -->
<!ENTITY ENDPOINT-US "https://identity.api.rackspacecloud.com/v1.1/">
<!ENTITY ENDPOINT-UK "https://lon.identity.api.rackspacecloud.com/v1.1/">
<!ENTITY ENDPOINT-US-20 "https://identity.api.rackspacecloud.com/v2.0/">
<!ENTITY ENDPOINT-UK-20 "https://lon.identity.api.rackspacecloud.com/v2.0/">
<!-- Useful for specs -->
<!ENTITY MAY '<emphasis xmlns="http://docbook.org/ns/docbook" role="strong">MAY</emphasis>'>
<!ENTITY SHOULD '<emphasis xmlns="http://docbook.org/ns/docbook" role="strong">SHOULD</emphasis>'>
<!ENTITY MUST '<emphasis xmlns="http://docbook.org/ns/docbook" role="strong">MUST</emphasis>'>
<!ENTITY MUST_NOT '<emphasis xmlns="http://docbook.org/ns/docbook" role="strong">MUST NOT</emphasis>'>
]>
<book version="5.0"
xmlns="http://docbook.org/ns/docbook"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:xi="http://www.w3.org/2001/XInclude"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns:m="http://www.w3.org/1998/Math/MathML"
xmlns:html="http://www.w3.org/1999/xhtml"
xml:id="cdb-getting-started">
<?rax title.font.size="35px" subtitle.font.size="20px"?>
<title>Rackspace Cloud Databases Getting Started Guide</title>
<titleabbrev>Rackspace Cloud Databases and Servers Getting Started Guide</titleabbrev>
<info>
<copyright>
<year>2011</year>
<year>2012</year>
<holder>Rackspace US, Inc.</holder>
</copyright>
<releaseinfo>API v1.0</releaseinfo>
<productname>Rackspace Cloud Databases</productname>
<pubdate>2012-09-04</pubdate>
<legalnotice role="rs-api">
<annotation>
<remark>Copyright details are filled in by the template.</remark>
</annotation>
</legalnotice>
<revhistory>
<revision>
<date>2012-09-04</date>
<revdescription>
<itemizedlist spacing="compact">
<listitem>
<para>Added information for pricing and
service level (refer to <xref
linkend="Pricing_SLA-d1e1362"
/>).</para>
</listitem>
</itemizedlist>
</revdescription>
</revision>
<revision>
<date>2012-08-02</date>
<revdescription>
<itemizedlist spacing="compact">
<listitem>
<para>Corrected request examples for
authentication (refer to <xref
linkend="Generating_Auth_Token"
/>).</para>
</listitem>
</itemizedlist>
</revdescription>
</revision>
<revision>
<date>2012-08-01</date>
<revdescription>
<itemizedlist spacing="compact">
<listitem>
<para>Initial Unlimited Availability (UA)
release for Rackspace Cloud
Databases.</para>
</listitem>
</itemizedlist>
</revdescription>
</revision>
</revhistory>
<raxm:metadata xmlns:raxm="http://docs.rackspace.com/api/metadata">
<raxm:product version="v1.0">cdb</raxm:product>
<raxm:priority>1</raxm:priority>
</raxm:metadata>
</info>
<chapter xml:id="DB_Doc_Change_History">
<title>Document Change History</title>
<para>This version of the Getting Started replaces and
obsoletes all previous versions. The most recent changes
are described in the table below:</para>
<?rax revhistory?>
</chapter>
<chapter xml:id="DB_Overview">
<title>Overview</title>
<para>Follow the steps described in this guide to use the
Rackspace Cloud Databases API and the Cloud
Servers<trademark/> section of the Rackspace Cloud Control
Panel to create and access your database instances via
Rackspace Cloud Servers.</para>
<para>For details about using the Cloud Databases API, refer
to the <citetitle>Cloud Databases Developer
Guide</citetitle> at <link
xlink:href="http://docs.rackspace.com/"
>http://docs.rackspace.com/</link>.</para>
<para>For more details about Rackspace Cloud Databases, refer
to <link
xlink:href="http://www.rackspace.com/cloud/cloud_hosting_products/databases/"
>http://www.rackspace.com/cloud/cloud_hosting_products/databases/</link>.
This site also offers links to Rackspace's official
support channels, including knowledge center articles,
forums, phone, chat, and email. </para>
<para>Please visit our <link
xlink:href="http://feedback.rackspacecloud.com/forums/71021-product-feedback/category/42449-cloud-databases"
>Product Feedback Forum</link> and let us know what
you think about Cloud Databases!</para>
<section xml:id="Prerequisites_Examples">
<title>Prerequisites for Running Examples</title>
<para>In order to run the examples in this guide, you must
have the following prerequisites: <itemizedlist
spacing="compact">
<listitem>
<para>Rackspace Cloud account</para>
</listitem>
<listitem>
<para>Rackspace Cloud username and password,
as specified during registration</para>
</listitem>
</itemizedlist></para>
</section>
<section xml:id="Pricing_SLA-d1e1362">
<title>Pricing and Service Level</title>
<para>Cloud Databases is part of the Rackspace Cloud and
your use through the API will be billed as per the
pricing schedule at <link
xlink:href="http://www.rackspace.com/cloud/public/databases/pricing"
>http://www.rackspace.com/cloud/public/databases/pricing</link>.
Cloud Servers is also part of the Rackspace Cloud and
your use through the Control Panel will be billed as
per the pricing schedule at <link
xlink:href="http://www.rackspace.com/cloud/public/servers/pricing"
>http://www.rackspace.com/cloud/public/servers/pricing</link>.</para>
<para>The Service Level Agreements (SLAs) for Cloud
Databases and Cloud Servers are available at <link
xlink:href="http://www.rackspace.com/cloud/legal/sla/#cloud_databases"
>http://www.rackspace.com/cloud/legal/sla/#cloud_databases</link>
and <link
xlink:href="http://www.rackspace.com/cloud/legal/sla"
>http://www.rackspace.com/cloud/legal/sla</link>
respectively.</para>
</section>
</chapter>
<chapter xml:id="DB_Sending_API_Requests">
<title>Send Requests to the API</title>
<para>You have several options for sending requests through an
API: </para>
<itemizedlist spacing="compact">
<listitem>
<para>Developers and testers may prefer to use cURL,
the command-line tool from <link
xlink:href="http://curl.haxx.se/"
>http://curl.haxx.se/</link>. </para>
<para>With cURL you can send HTTP requests and receive
responses back from the command line. </para>
</listitem>
<listitem>
<para>If you like to use a more graphical interface,
the ReST client for Firefox also works well for
testing and trying out commands, see <link
xlink:href="https://addons.mozilla.org/en-US/firefox/addon/restclient/"
>https://addons.mozilla.org/en-US/firefox/addon/restclient/</link>. </para>
</listitem>
<listitem>
<para>You can also download and install rest-client, a
Java application to test ReSTful web services,
from <link
xlink:href="http://code.google.com/p/rest-client/"
>http://code.google.com/p/rest-client/</link>. </para>
</listitem>
</itemizedlist>
<section xml:id="DB_using-curl-cli">
<title>Send API Requests Using cURL</title>
<para>cURL is a command-line tool that is available on
most UNIX®-like environments and Mac OS X® and can be
downloaded for Windows® in order to interact with the
ReST interfaces. For more information on cURL, visit
<link xlink:href="http://curl.haxx.se/"
>http://curl.haxx.se/</link>. </para>
<para>cURL allows you to transmit and receive HTTP requests and responses from the
command-line or from within a shell script. This makes it possible to work with the ReST API
directly without using one of the client APIs. </para>
<para>The following cURL command-line options will be used
in this guide to run the examples:</para>
<variablelist>
<title>cURL Command-Line Options</title>
<varlistentry>
<term><option>-d</option></term>
<listitem>
<para>Sends the specified data in a post
request to the HTTP server.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><option>-i</option></term>
<listitem>
<para>Includes the HTTP header in the
output.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><option>-H HEADER</option></term>
<listitem>
<para>Specify an HTTP header in the request.</para>
</listitem>
</varlistentry>
</variablelist>
<note>
<para>If you have the tools, you can run the cURL JSON
request examples with the following options to
format the output from cURL: <command><curl
JSON request example> | python
-mjson.tool</command>.</para>
</note>
</section>
<section xml:id="DB_copy_paste_examples">
<title>Copying and Pasting cURL Request Examples into a
Terminal Window</title>
<para>To run the cURL request examples shown in this guide
on Linux or Mac systems, copy and paste each example
from the HTML version of this guide into an ASCII
editor (for example <emphasis role="bold"
>vi</emphasis> or <emphasis role="bold"
>TextEdit</emphasis>). Then modify each example
with your required account information and so forth,
as detailed in this guide.</para>
<note>
<para>The carriage returns in the cURL request
examples that are part of the cURL syntax are
escaped with a backslash ('\') in order to avoid
prematurely terminating the command. However you
should not escape carriage returns inside the xml
or json message within the command.</para>
</note>
<para>Consider the following cURL Authenticate Request:
XML example that is described in detail in <xref
linkend="Generating_Auth_Token"/>:</para>
<example>
<title>cURL Authenticate Request: XML</title>
<?dbfo keep-together="always"?>
<screen language="bash"><command>curl</command> <option>-i</option> <option>-d</option> \
'<?xml version="1.0" encoding="UTF-8"?>
<auth>
<apiKeyCredentials
xmlns="http://docs.rackspace.com/identity/api/ext/RAX-KSKEY/v1.0"
username="<emphasis role="bold">your_username</emphasis>"
apiKey="<emphasis role="bold">your_api_key</emphasis>"/>
</auth><option>'</option> \
<uri>'https://identity.api.rackspacecloud.com/v2.0/tokens'</uri></screen>
</example>
<para>You can see that the lines that are part of the cURL
command syntax have all been escaped with a backslash
('\') to indicate that the command continues on the
next line:</para>
<screen language="bash"><command>curl</command> <option>-i</option> <option>-d</option> \
(... lines within the xml portion of the message are not shown in this example)
(... the example only shows lines that are part of cURL syntax)
</auth><option>'</option> \
<uri>'https://identity.api.rackspacecloud.com/v2.0/tokens'</uri></screen>
<para>However the lines <emphasis>within</emphasis> the
xml portion of the message are
<emphasis>not</emphasis> escaped with a backslash
('\') in order to avoid issues with the xml
processing:</para>
<screen language="bash">'<?xml version="1.0" encoding="UTF-8"?>
<auth>
<apiKeyCredentials
xmlns="http://docs.rackspace.com/identity/api/ext/RAX-KSKEY/v1.0"
username="<emphasis role="bold">your_username</emphasis>"
apiKey="<emphasis role="bold">your_api_key</emphasis>"/>
</auth><option>'</option> \
</screen>
<note>
<para>The final line of the xml message is escaped
since the backslash lies
<emphasis>outside</emphasis> the xml message
and continues the cURL command to the next
line.</para>
</note>
<para>After you are finished modifying the text for the
cURL request example with your information (for
example <emphasis role="bold"
><code>your_username</code></emphasis> and
<emphasis role="bold"
><code>your_api_key</code></emphasis>), paste it
into your terminal window. Then execute the cURL
command by pressing <guilabel>Enter</guilabel>.</para>
<para>If you have trouble copying and pasting the examples
as described, try typing the entire example on one
long line, removing all the backslash line
continuation characters.</para>
</section>
</chapter>
<chapter xml:id="Generating_Auth_Token">
<title>Generate an Authentication Token</title>
<para>You need to generate a token whether you use cURL or a
ReST client.</para>
<para>In order to use the ReST API, you will first need to
obtain an authentication token, which will need to be
passed in for each request using the
<code>X-Auth-Token</code> header. </para>
<para>The following example demonstrates how to use cURL to
obtain the authentication token and the account number.
You will need to supply the authentication token and
account number when making subsequent Cloud Databases API
calls.</para>
<para>Remember to replace the names in the Authenticate
Request examples below with their respective
values:<itemizedlist spacing="compact">
<listitem>
<para><emphasis role="bold"
>your_username</emphasis> — The
username is your common Rackspace Cloud
username, as supplied during
registration.</para>
</listitem>
<listitem>
<para><emphasis role="bold"
>your_api_key</emphasis> — The key
is your API access key. The key can be
obtained from the Rackspace Cloud Control
Panel in the <guimenu><Your
Account></guimenu> / <guimenuitem>API
Keys</guimenuitem> section (login here:
<link
xlink:href="http://mycloud.rackspace.com/"
>Control Panel Login</link>).</para>
</listitem>
</itemizedlist></para>
<para> To access the Authentication Service, you must know
whether your account is US-based or UK-based: </para>
<itemizedlist spacing="compact">
<listitem>
<para> US-based accounts authenticate through <link
xlink:href="&ENDPOINT-US-20;"
>&ENDPOINT-US-20;</link>. </para>
</listitem>
<listitem>
<para> UK-based accounts authenticate through <link
xlink:href="&ENDPOINT-UK-20;"
>&ENDPOINT-UK-20;</link>. </para>
</listitem>
</itemizedlist>
<para> Your account may be based in either the US or the UK;
this is not determined by your physical location but by
the location of the Rackspace retail site which was used
to create your account: </para>
<itemizedlist spacing="compact">
<listitem>
<para> If your account was created via <link
xlink:href="http://www.rackspacecloud.com"
>http://www.rackspacecloud.com</link>, it is a
US-based account. </para>
</listitem>
<listitem>
<para> If your account was created via <link
xlink:href="http:/www.rackspace.co.uk"
>http:/www.rackspace.co.uk</link>, it is a
UK-based account. </para>
</listitem>
</itemizedlist>
<para> If you are unsure how your account was created, use the
Rackspace contact information at either site to ask for
help. </para>
<para>Notice that you authenticate using a special URL for
Cloud authentication services. For example, for US-based
accounts, you use
<code>https://identity.api.rackspacecloud.com/v2.0/tokens</code>,
as shown in the following Authenticate Request examples.
Note that the <code>v2.0</code> component in the URL
indicates that you are using version 2.0 of the Cloud Auth
API.</para>
<example>
<title>cURL Authenticate Request: XML</title>
<?dbfo keep-together="always"?>
<screen language="bash"><command>curl</command> <option>-i</option> <option>-d</option> \
'<?xml version="1.0" encoding="UTF-8"?>
<auth>
<apiKeyCredentials
xmlns="http://docs.rackspace.com/identity/api/ext/RAX-KSKEY/v1.0"
username="<emphasis role="bold">your_username</emphasis>"
apiKey="<emphasis role="bold">your_api_key</emphasis>"/>
</auth>' \
<option>-H 'Content-Type: application/xml'</option> \
<option>-H 'Accept: application/xml'</option> \
<uri>'https://identity.api.rackspacecloud.com/v2.0/tokens'</uri></screen>
</example>
<example>
<title>cURL Authenticate Request: JSON</title>
<?dbfo keep-together="always"?>
<screen language="bash"><command>curl</command> <option>-i</option> <option>-d</option> \
'{
"auth":
{
"RAX-KSKEY:apiKeyCredentials":
{
"username": "<emphasis role="bold">your_username</emphasis>",
"apiKey": "<emphasis role="bold">your_api_key</emphasis>"}
}
}' \
<option>-H 'Content-Type: application/json'</option> \
<uri>'https://identity.api.rackspacecloud.com/v2.0/tokens'</uri></screen>
</example>
<note>
<para>For UK-based accounts, you would need to modify the
URL shown in the last line of each of the Authenticate
Request examples above to be
<code>'https://lon.identity.api.rackspacecloud.com/v2.0/tokens'</code>
instead.</para>
</note>
<example>
<title>Authenticate Response: XML</title>
<programlisting language="xml"><xi:include href="../../src/resources/samples/db-auth-20.xml" parse="text"><xi:fallback>Missing code sample! <?rax fail?></xi:fallback></xi:include></programlisting>
</example>
<example>
<title>Authenticate Response: JSON</title>
<programlisting language="json"><xi:include href="../../src/resources/samples/db-auth-20.json" parse="text"><xi:fallback>Missing code sample! <?rax fail?></xi:fallback></xi:include></programlisting>
</example>
<para>The authentication token <code>id</code> is returned
along with an <code>expires</code> attribute that
specifies when the token expires. </para>
<note>
<title>Notes</title>
<itemizedlist spacing="compact">
<listitem>
<para>For all response examples in this guide, the
field values you receive in your responses
will vary from those shown here since they
will be specific to your account.</para>
</listitem>
<listitem>
<para>The information shown in the Authenticate
Response examples above is for US-based
accounts. If you authenticate against the
UK-endpoint for auth, you will see the service
catalog information for UK-based
accounts.</para>
</listitem>
<listitem>
<para>The <code>id</code> attribute in the
Authenticate Response specifies the
authentication token. Tokens are valid for a
finite duration.</para>
<para>Remember to supply your authentication token
wherever you see the field <emphasis
role="bold">your_auth_token</emphasis> in
the examples in this guide.</para>
</listitem>
<listitem>
<para> The <code>expires</code> attribute denotes
the time after which the token will
automatically become invalid. A token may be
manually revoked before the time identified by
the expires attribute; <code>expires</code>
predicts a token's maximum possible lifespan
but does not guarantee that it will reach that
lifespan. Clients are encouraged to cache a
token until it expires.</para>
</listitem>
<listitem>
<para>Applications should be designed to
re-authenticate after receiving a 401
(Unauthorized) response from a service
endpoint.</para>
</listitem>
</itemizedlist>
</note>
<para>The <code>publicURL</code> endpoints for
<code>cloudDatabases</code> (for example
<code>https://ord.databases.api.rackspacecloud.com/v1.0/1100111</code>)
are also returned in the response. </para>
<para>You will find the actual account number after the final
'/' in the <code>publicURL</code> field. In this example,
you can see that the account number is 1100111. You need
to specify your account number on most of the Cloud
Databases API calls, wherever you see the field <emphasis
role="bold">your_acct_id</emphasis> specified in the
examples in this guide.</para>
<para>After authentication, you can use cURL to perform &GET;,
&DELETE;, and &POST; requests for the Cloud Databases
API.</para>
</chapter>
<chapter xml:id="Service_Access_Endpoints-d1e753">
<title>Service Access/Endpoints</title>
<para>The endpoints to use for your Cloud Databases API calls
are summarized in the table below.</para>
<para>
<table rules="all">
<caption>Regionalized Service Endpoints</caption>
<thead>
<tr align="center">
<td colspan="2">Region</td>
<td colspan="5">Endpoint</td>
</tr>
</thead>
<tbody>
<tr align="left">
<td colspan="2">Chicago (ORD)</td>
<td colspan="5"
><code>https://ord.databases.api.rackspacecloud.com/v1.0/</code><parameter>1234</parameter>/
</td>
</tr>
<tr align="left">
<td colspan="2">Dallas/Ft. Worth (DFW)</td>
<td colspan="5"
><code>https://dfw.databases.api.rackspacecloud.com/v1.0/</code><parameter>1234</parameter>/
</td>
</tr>
<tr align="left">
<td colspan="2">London (LON)</td>
<td colspan="5">
<code>https://lon.databases.api.rackspacecloud.com/v1.0/</code><parameter>1234</parameter>/
</td>
</tr>
</tbody>
</table>
</para>
<note>
<title>Notes:</title>
<itemizedlist>
<listitem>
<para>Choose the endpoint from the table for the
datacenter where your Cloud resources are
located.</para>
</listitem>
<listitem>
<para>The Cloud Server that you use in <xref
linkend="Create_Cloud_Server"/> must be
located in the same datacenter where your
database resides.</para>
</listitem>
<listitem>
<para>All examples in this guide assume that you
are operating against the ORD datacenter,
however if you are using a different
datacenter, be sure to use the associated
endpoint from the table above instead.</para>
</listitem>
</itemizedlist>
</note>
<para>Replace the sample account ID number,
<parameter>1234</parameter>, with your actual account
number returned as part of the authentication response.
Use your actual account number wherever you see the field
<emphasis role="bold">your_acct_id</emphasis>
specified in this guide. Refer to <xref
linkend="Generating_Auth_Token"/>.</para>
<para>When making a Cloud Databases API call, place the
endpoint at the beginning of the request URL, for example:
(<code>https://ord.databases.api.rackspacecloud.com/v1.0/your_acct_id/</code>),
as you can see in the cURL List Flavors Details Request
examples in <xref linkend="List_Flavors"/>.</para>
</chapter>
<chapter xml:id="List_Flavors">
<title>List Flavors</title>
<para> A flavor is an available hardware configuration for a
database instance. Each flavor has a unique combination of
memory capacity and priority for CPU time. The larger the
flavor size you use, the larger the amount of RAM and
priority for CPU time your database instance will
receive.</para>
<para>You need to use the List Flavors API call
(<code>/flavors</code>) to find the available
configurations for your database instance, and then decide
which size you need.</para>
<para>This operation does not require a request body.</para>
<para>The following examples show the cURL requests for List
Flavors:</para>
<example>
<title>cURL List Flavors Request: XML</title>
<programlisting language="bash"><command>curl -i</command> \
-H 'X-Auth-Token: <emphasis role="bold">your_auth_token</emphasis>' \
<option>-H 'Accept: application/xml'</option> \
<uri>'https://ord.databases.api.rackspacecloud.com/v1.0/</uri><emphasis role="bold">your_acct_id</emphasis><uri>/flavors'</uri></programlisting>
</example>
<example>
<title>cURL List Flavors Request: JSON</title>
<programlisting language="bash"><command>curl -i</command> \
-H 'X-Auth-Token: <emphasis role="bold">your_auth_token</emphasis>' \
<option>-H 'Accept: application/json'</option> \
<uri>'https://ord.databases.api.rackspacecloud.com/v1.0/</uri><emphasis role="bold">your_acct_id</emphasis><uri>/flavors'</uri></programlisting>
</example>
<para>Remember to replace the names in the examples above with
their actual respective values for all the cURL examples
that follow:<itemizedlist spacing="compact">
<listitem>
<para><emphasis role="bold"
>your_auth_token</emphasis> — as
returned in your authentication response (see
the response examples in <xref
linkend="Generating_Auth_Token"/>)</para>
</listitem>
<listitem>
<para><emphasis role="bold"
>your_acct_id</emphasis> — as
returned in your authentication response (must
be replaced in the request URL)</para>
</listitem>
</itemizedlist></para>
<para>The following examples show the responses for List
Flavors:</para>
<example>
<title>List Flavors Response: XML</title>
<programlisting language="xml"><xi:include href="../../src/resources/samples/db-flavors-response.xml" parse="text"><xi:fallback>Missing code sample! <?rax fail?></xi:fallback></xi:include></programlisting>
</example>
<example>
<title>List Flavors Response: JSON</title>
<programlisting language="json"><xi:include href="../../src/resources/samples/db-flavors-response.json" parse="text"><xi:fallback>Missing code sample! <?rax fail?></xi:fallback></xi:include></programlisting>
</example>
<para>In the previous examples, you can see from the flavor
<code>name</code> that there are multiple flavors
available, including <code>medium</code> (with 1 virtual
CPU and 2 gigabytes of memory) and <code>tiny</code> (with
1 virtual CPU and 0.5 gigabytes of memory). </para>
<para>In this example, assume that you decide to use the tiny
flavor (id 1) to provide the needed capacity for your
database instance.</para>
<para>Notice that there are two kinds of link relations
associated with flavor resources. A <code>self</code> link
contains a <emphasis>versioned</emphasis> link to the
flavor resource. These links should be used in cases where
the link will be followed immediately (as you will see in
the next section). A <code>bookmark</code> link provides a
permanent link to a flavor resource that is appropriate
for long term storage and works across API
versions.</para>
</chapter>
<chapter xml:id="Create_DB_Instance">
<title>Create a Database Instance with a Database and a
User</title>
<para>A database instance is an isolated MySQL instance in
a single tenant environment on a shared physical host
machine. In the example below, you create a database
instance with a database and a user. The example instance
uses the tiny flavor and a volume size of 2 gigabytes
(GB). </para>
<para>Refer to <link
xlink:href="http://docs-beta.rackspace.com/cdb/api/v1.0/cdb-devguide/content/POST_createDatabase__version___accountID__instances__instanceId__databases_databases.html"
>Create Database</link> in the <citetitle>Cloud
Databases Developer Guide</citetitle> for the
restrictions for choosing the database name.</para>
<para>The example creates a database instance
<code>myrackinstance</code>, with the following: <itemizedlist>
<listitem>
<para>the tiny flavor</para>
</listitem>
<listitem>
<para>volume size of 2 gigabytes (GB)</para>
</listitem>
<listitem>
<para>a database named <code>sampledb</code> with:<itemizedlist>
<listitem>
<para><code>utf8</code> character
set</para>
</listitem>
<listitem>
<para><code>utf8_general_ci</code>
collation</para>
</listitem>
</itemizedlist></para>
</listitem>
<listitem>
<para>a user <code>simplestUser</code> with
password <code>password</code></para>
</listitem>
</itemizedlist>
</para>
<para>Notice that the request specifies the flavor reference
(<code>flavorRef</code>) to the tiny flavor (id 1)
that was returned by the List Flavors Details call:
<code>"https://ord.databases.api.rackspacecloud.com/v1.0/1234/flavors/1"</code>.
This is the <code>self</code> link that is the versioned
link to the flavor resource. Refer to the response
examples in <xref linkend="List_Flavors"/>.</para>
<para>The following examples show the cURL requests for Create
Instance:</para>
<example>
<title>cURL Create Instance Request: XML</title>
<programlisting language="bash"><command>curl</command> <option>-i</option> <option>-d</option> \
'<?xml version="1.0" ?>
<instance xmlns="http://docs.openstack.org/database/api/v1.0"
name="myrackinstance"
flavorRef=
"https://ord.databases.api.rackspacecloud.com/v1.0/<emphasis role="bold">your_acct_id</emphasis>/flavors/1">
<databases>
<database name="sampledb" character_set="utf8"
collate="utf8_general_ci" />
</databases>
<users>
<user name="simplestUser" password="password">
<databases>
<database name="sampledb"/>
</databases>
</user>
</users>
<volume size="2" />
</instance>' \
-H 'X-Auth-Token: <emphasis role="bold">your_auth_token</emphasis>' \
<option>-H 'Content-Type: application/xml'</option> \
<option>-H 'Accept: application/xml'</option> \
<uri>'https://ord.databases.api.rackspacecloud.com/v1.0/</uri><emphasis role="bold">your_acct_id</emphasis><uri>/instances'</uri></programlisting>
</example>
<example>
<title>cURL Create Instance Request: JSON</title>
<programlisting language="bash"><command>curl</command> <option>-i</option> <option>-d</option> \
'{
"instance": {
"databases": [
{
"character_set": "utf8",
"collate": "utf8_general_ci",
"name": "sampledb"
}
],
"flavorRef": "https://ord.databases.api.rackspacecloud.com/v1.0/<emphasis role="bold">your_acct_id</emphasis>/flavors/1",
"name": "myrackinstance",
"users": [
{
"databases": [
{
"name": "sampledb"
}
],
"name": "simplestUser",
"password": "password"
}
],
"volume":
{
"size": 2
}
}
}' \
-H 'X-Auth-Token: <emphasis role="bold">your_auth_token</emphasis>' \
<option>-H 'Content-Type: application/json'</option> \
<uri>'https://ord.databases.api.rackspacecloud.com/v1.0/</uri><emphasis role="bold">your_acct_id</emphasis><uri>/instances'</uri></programlisting>
</example>
<para>Remember to replace the names in the examples above with
their actual respective values for all the cURL examples
that follow:<itemizedlist spacing="compact">
<listitem>
<para><emphasis role="bold"
>your_auth_token</emphasis> — as
returned in your authentication response (see
the response examples in <xref
linkend="Generating_Auth_Token"/>)</para>
</listitem>
<listitem>
<para><emphasis role="bold"
>your_acct_id</emphasis> — as
returned in your authentication response (must
be replaced in the request URL)</para>
</listitem>
</itemizedlist></para>
<para>Remember to replace the account id shown in the
<code>flavorRef</code> property for the examples with
your actual account id:
<code>"https://ord.databases.api.rackspacecloud.com/v1.0/</code><emphasis
role="bold"
>your_acct_id</emphasis><code>/flavors/1"</code>.
Rather than the flavor URI shown in the previous sentence,
you can also pass the flavor id (integer) as the value for
flavorRef. For example, the flavor id for the flavor URI
shown above is "1". </para>
<para>The following examples show the Create Instance
responses:</para>
<example>
<title>Create Instance Response: XML</title>
<programlisting language="xml"><xi:include href="../../src/resources/samples/db-gs-create-database-instance-response.xml" parse="text"><xi:fallback>Missing code sample! <?rax fail?></xi:fallback></xi:include></programlisting>
</example>
<example>
<title>Create Instance Response: JSON</title>
<programlisting language="json"><xi:include href="../../src/resources/samples/db-gs-create-database-instance-response.json" parse="text"><xi:fallback>Missing code sample! <?rax fail?></xi:fallback></xi:include></programlisting>
</example>
<para>You will need to specify the instance id returned (in
the response examples above:
<code>id="d379ba5c-9a1f-4aa9-9a17-afe237d04c65"</code>)
on subsequent API calls that require it, for example List
Databases for Instance.</para>
<para>Note that the database and user are not listed in the
Create Instance responses. Next you will verify that both
were successfully created.<note>
<para> The operation of creating the database instance
may take up to several minutes. You will not be
able to perform the operations to List Databases
for Instance and List Users for Instance in the
sections that follow until the instance has ACTIVE
status. </para>
</note></para>
</chapter>
<chapter xml:id="List_DBS_For_Instance">
<title>List Databases for Instance</title>
<para>In this section you will list the databases in the
specified database instance.</para>
<para>This operation does not require a request body.</para>
<para xmlns="http://docbook.org/ns/docbook">The following
examples show the cURL requests for List Databases for
Instance:</para>
<example>
<title>cURL List Databases for Instance Request:
XML</title>
<programlisting language="bash"><command>curl</command> <option>-i</option> \
-H 'X-Auth-Token: <emphasis role="bold">your_auth_token</emphasis>' \
<option>-H 'Content-Type: application/xml'</option> \
<option>-H 'Accept: application/xml'</option> \
<uri>'https://ord.databases.api.rackspacecloud.com/v1.0/</uri><emphasis role="bold">your_acct_id</emphasis><uri>/instances/</uri><emphasis role="bold">instance_id</emphasis><uri>/databases'</uri></programlisting>
</example>
<example>
<?dbfo keep-together="always"?>
<title>cURL List Databases for Instance Request:
JSON</title>
<programlisting language="bash"><command>curl</command> <option>-i</option> \
-H 'X-Auth-Token: <emphasis role="bold">your_auth_token</emphasis>' \
<option>-H 'Content-Type: application/json'</option> \
<uri>'https://ord.databases.api.rackspacecloud.com/v1.0/</uri><emphasis role="bold">your_acct_id</emphasis><uri>/instances/</uri><emphasis role="bold">instance_id</emphasis><uri>/databases'</uri></programlisting>
</example>
<para>Remember to replace the names in the examples above with
their actual respective values:<itemizedlist spacing="compact">
<listitem>
<para><emphasis role="bold"
>your_auth_token</emphasis> — as
returned in your authentication response (see
the examples in <xref
linkend="Generating_Auth_Token"/>)</para>
</listitem>
<listitem>
<para><emphasis role="bold"
>your_acct_id</emphasis> — as
returned in your authentication response (see
the examples in <xref
linkend="Generating_Auth_Token"/>)</para>
</listitem>
<listitem>
<para><emphasis role="bold">instance_id</emphasis>
— as returned in your create instance
response (see the examples in <xref
linkend="Create_DB_Instance"/>)</para>
</listitem>
</itemizedlist></para>
<para>The following examples show the responses for Create
User:</para>
<example>
<title>List Databases for Instance Response: XML</title>
<programlisting language="xml">HTTP/1.1 200 OK
Content-Type: application/xml
Content-Length: 109
Date: Thu, 05 Apr 2012 18:20:18 GMT
<databases xmlns="http://docs.openstack.org/database/api/v1.0">
<database name="sampledb"/>
</databases>
</programlisting>
</example>
<example>
<title>List Databases for Instance Response: JSON</title>
<programlisting language="json">HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 37
Date: Thu, 05 Apr 2012 18:13:53 GMT
{
"databases": [
{
"name": "sampledb"
}
]
}</programlisting>
</example>
<para>You can see that the database <code>sampledb</code> was
successfully created. Next you will list the users.</para>
</chapter>
<chapter xml:id="List_Users_DB_Instance">
<title>List Users in Database Instance</title>
<para>In this section you will list the users in the specified
database instance.</para>
<para>This operation does not require a request body.</para>
<para>The following examples show the cURL requests for List
Users in Database Instance:</para>
<example>
<title>cURL List Users in Database Instance Request:
XML</title>
<programlisting language="bash"><command>curl</command> <option>-i</option> \
-H 'X-Auth-Token: <emphasis role="bold">your_auth_token</emphasis>' \
<option>-H 'Content-Type: application/xml'</option> \
<option>-H 'Accept: application/xml'</option> \
<uri>'https://ord.databases.api.rackspacecloud.com/v1.0/</uri><emphasis role="bold">your_acct_id</emphasis><uri>/instances/</uri><emphasis role="bold">instance_id</emphasis><uri>/users'</uri></programlisting>
</example>
<example>
<?dbfo keep-together="always"?>
<title>cURL List Users in Database Instance Request:
JSON</title>
<programlisting language="bash"><command>curl</command> <option>-i</option> \
-H 'X-Auth-Token: <emphasis role="bold">your_auth_token</emphasis>' \
<option>-H 'Content-Type: application/json'</option> \
<uri>'https://ord.databases.api.rackspacecloud.com/v1.0/</uri><emphasis role="bold">your_acct_id</emphasis><uri>/instances/</uri><emphasis role="bold">instance_id</emphasis><uri>/users'</uri></programlisting>
</example>
<para>Remember to replace the names in the examples above with
their actual respective values:<itemizedlist
spacing="compact">
<listitem>
<para><emphasis role="bold"
>your_auth_token</emphasis> — as
returned in your authentication response (see
the examples in <xref
linkend="Generating_Auth_Token"/>)</para>
</listitem>
<listitem>
<para><emphasis role="bold"
>your_acct_id</emphasis> — as
returned in your authentication response (see
the examples in <xref
linkend="Generating_Auth_Token"/>)</para>
</listitem>
<listitem>
<para><emphasis role="bold">instance_id</emphasis>
— as returned in your create instance
response (see the examples in <xref
linkend="Create_DB_Instance"/>)</para>
</listitem>
</itemizedlist></para>
<para>The following examples show the responses for List
Users in Database Instance:</para>
<example>
<title>List Users in Database Instance Response:
XML</title>
<programlisting language="xml">HTTP/1.1 200 OK
Content-Type: application/xml
Content-Length: 109
Date: Thu, 05 Apr 2012 18:20:18 GMT
<?xml version="1.0" ?>
<users xmlns="http://docs.openstack.org/database/api/v1.0">
<user name="simplestUser">
<databases>
<database>
<name>
sampledb
</name>
</database>
</databases>
</user>
</users>
</programlisting>
</example>
<example>
<title>List Users in Database Instance Response:
JSON</title>
<programlisting language="json">HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 113
Date: Thu, 05 Apr 2012 18:13:53 GMT
{
"users": [
{
"databases": [
{
"name": "sampledb"
}
],
"name": "simplestUser"
}
]
}</programlisting>
</example>
<para>You can see that the user <code>simplestUser</code> was
successfully created.</para>
</chapter>
<chapter xml:id="Create_Cloud_Server">
<title>Create a New Cloud Server</title>
<para>Create a Cloud Server (or use an existing Cloud Server)
to access your database.</para>
<note>
<para>If you are using an existing Cloud Server on your
account, skip this step and go directly to <xref
linkend="Configure_Cloud_Server_DB"/>.</para>
</note>
<para>Create a Cloud Server using the Cloud Servers section of
the Cloud Control Panel (login here: <link
xlink:href="http://mycloud.rackspace.com/"
>Control Panel Login</link>).</para>
<procedure>
<title>To create a Cloud Server using the Cloud Control
Panel:</title>
<step>
<para>Click <guimenuitem>Servers</guimenuitem> to view
the Cloud Servers page.</para>
</step>
<step>
<para> Using the <guimenu>Region</guimenu> drop-down
menu, select the appropriate region, depending on
whether you want to create a first generation
Cloud Server or a next generation Cloud Server.
(The type of Cloud Server does not matter for this
exercise.)</para>
</step>
<step>
<para> Select an image from a list of different
operating systems, including Linux Distributions
and Windows Images:</para>
<para><inlinemediaobject>
<imageobject>
<imagedata
fileref="images/Choose_CS_Image_CCP.png"
contentwidth="6in"/>
</imageobject>
</inlinemediaobject></para>
</step>
<step>
<para> Specify the <guilabel>Server Name</guilabel>
and select a <guilabel>Size</guilabel> for your
Cloud Server, then click <guibutton>Create
Server</guibutton>. </para>
</step>
</procedure>
<note>
<para>You can also create a Cloud Server using the Cloud
Servers API. Refer to the <link
xlink:href="http://docs.rackspace.com/">Next Generation Cloud
Servers Developer Guide</link> for
details.</para>
</note>
</chapter>
<chapter xml:id="Configure_Cloud_Server_DB">
<title>Configuring an Application to Use Your Cloud
Database</title>
<para>If you are configuring an application to use your
database on a Cloud Server, you need to configure the
application with the hostname for the database instance
and user name / password for the database. Refer to the
response examples in <xref linkend="Create_DB_Instance"/>
for the <code>hostname</code> returned and the request
examples for the user name and password you
specified.</para>
</chapter>
<chapter xml:id="MySQL_GUI_Admin">
<title>MySQL GUI Administration</title>
<para> If you want to access your database using the command
line MySQL client, then you have now completed the
<citetitle>Getting Started</citetitle>.</para>
<para>Otherwise, you can use a GUI tool such as phpMyAdmin to
interact with your database instance. Common operations
include managing databases, tables, fields, relations,
indexes, users, and permissions. Included below is a
procedure to set up phpMyAdmin on an Ubuntu 11.04 Cloud
Server. </para>
<para>For more detailed installation configuration
instructions see the phpMyAdmin documentation at: <link
xlink:href="http://www.phpmyadmin.net/documentation/"
>http://www.phpmyadmin.net/documentation/</link>. <note>
<para>Rackspace does not provide phpMyAdmin support,
and the user is responsible for any security
related configuration.</para>
</note></para>
<procedure>
<title>To install and configure phpMyAdmin on an Ubuntu
11.04 Cloud Server:</title>
<step>
<para> Install phpMyAdmin:</para>
<para>
<command>sudo apt-get install
phpmyadmin</command></para>
</step>
<step>
<para> Set up a symbolic link to the phpmyadmin config
file:</para>
<para><command>sudo ln -s /etc/phpmyadmin/apache.conf
/etc/apache2/conf.d/phpmyadmin.conf</command>
</para>
</step>
<step>
<para>Edit the
<code>/etc/phpmyadmin/config-db.php</code>
config file to point to your database
instance:</para>
<para><command>$dbserver='<cloud database
hostname>';</command>
</para>
</step>
<step>
<para>Restart apache:</para>
<para><command>sudo apachectl restart</command></para>
</step>
<step>
<para>Access phpMyAdmin at
http://<your_ipaddress>/phpMyAdmin:</para>
<para><inlinemediaobject>
<imageobject>
<imagedata fileref="images/phpMyAdmin.png"
contentwidth="6in"/>
</imageobject>
</inlinemediaobject></para>
</step>
</procedure>
<para>This concludes the <citetitle>Getting
Started</citetitle>. Thank you for using Rackspace Cloud
products.</para>
</chapter>
</book>
|