forked from cloudControl/phpcclib
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathphpcclib.php
1590 lines (1485 loc) · 46.3 KB
/
phpcclib.php
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
<?php
/**
* require Pear::HTTP_Request2, Pear::Net_URL2 packages
*/
require_once 'HTTP/Request2.php';
require_once 'Net/URL2.php';
/*
phpcclib
library for accessing the cloudControl API using PHP
Copyright 2010 cloudControl UG (haftungsbeschraenkt)
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
class API {
/**
* predefined API URL
* @const string
*/
const URL = 'https://api.cloudcontrol.com';
/**
* set certificate validation (if https protocol used)
* @const boolean
*/
const SSL_VERIFY_PEER = false;
/**
* api version
* @var string
*/
const VERSION = '0.1.3.6';
/**
* token length - to check the token
* @var int
*/
const TOKEN_STRLEN = 30;
private $_url = null;
private $_token = null;
/**
* constructor
*
* @param string $url
*
* @return API
*/
public function __construct($url=Api::URL) {
$this->setUrl($url);
}
/**
* set url
* @todo check if it is a valid url
* @param string $url
*
* @return void
*/
public function setUrl($url) {
$this->_url = $url;
}
/**
* get url
*
* @return string
*/
public function getUrl() {
return $this->_url;
}
/**
* requiresToken checks that methods that require
* a token can't be called without a token.
*
* If checkToken doesn't return true; a TokenRequiredError exception is
* raised telling the caller to use the create_token method to get a
* valid token.
*
* @throws TokenRequiredError
*
* @return void
*/
public function requiresToken() {
$token = $this->getToken();
if (!$this->checkToken($token)) {
throw new TokenRequiredError();
}
}
/**
* Queries the API for a new Token and saves it as self._token.
*
* @param string $email users email-address
* @param string $password users password
*
* @throws TokenRequiredError
* @throws BadRequestError
* @throws UnauthorizedError
* @throws ForbiddenError
* @throws ConflictDuplicateError
* @throws GoneError
* @throws InternalServerError
* @throws NotImplementedError
* @throws ThrottledError
* @throws CCException
*
* @return boolean
*/
public function auth($email, $password) {
$request = new Request($this->_url);
$request->setAuth($email, $password);
$content = $request->post('/token/', array());
$tokenObject = $this->_jsonDecode($content);
return $this->setToken($tokenObject->token);
}
/**
* This method checks if there's a token.
*
* @todo implement a stronger check
* @param string $token token to check
*
* @return boolean
*/
public function checkToken($token) {
if (strlen($token) == Api::TOKEN_STRLEN) {
return true;
}
return false;
}
/**
* We use to set the token.
*
* @param string $token token to set
*
* @return void
*/
public function setToken($token) {
if ($this->checkToken($token)) {
$this->_token = $token;
}
return $this;
}
/**
* We use getToken to get the token.
*
* @return string
*/
public function getToken() {
return $this->_token;
}
/**
* Create a new application and return it.
*
* @param string $applicationName applications name
* @param string $type applications type [default:"php"]
*
* @throws TokenRequiredError
* @throws BadRequestError
* @throws UnauthorizedError
* @throws ForbiddenError
* @throws GoneError
* @throws InternalServerError
* @throws NotImplementedError
* @throws ThrottledError
* @throws CCException
*
* @return stdObj contains app data
*/
public function application_create($applicationName, $type="php") {
$resource = '/app/';
$data = array(
'name' => $applicationName,
'type' => $type
);
return $this->_executePost($resource, $data);
}
/**
* Returns a list of applications.
*
* @throws TokenRequiredError
* @throws BadRequestError
* @throws UnauthorizedError
* @throws ForbiddenError
* @throws GoneError
* @throws InternalServerError
* @throws NotImplementedError
* @throws ThrottledError
* @throws CCException
*
* @return array<stdObj> contains app list
*/
public function application_getList() {
return $this->_executeGet('/app/');
}
/**
* Returns all application details.
*
* @param string $applicationName applications name
*
* @throws TokenRequiredError
* @throws BadRequestError
* @throws UnauthorizedError
* @throws ForbiddenError
* @throws GoneError
* @throws InternalServerError
* @throws NotImplementedError
* @throws ThrottledError
* @throws CCException
*
* @return stdObj contains app details
*/
public function application_getDetails($applicationName) {
$resource = sprintf('/app/%s/', $applicationName);
return $this->_executeGet($resource);
}
/**
* Delete a application.
*
* @param string $applicationName applications name
*
* @throws TokenRequiredError
* @throws BadRequestError
* @throws UnauthorizedError
* @throws ForbiddenError
* @throws GoneError
* @throws InternalServerError
* @throws NotImplementedError
* @throws ThrottledError
* @throws CCException
*
* @return true
*/
public function application_delete($applicationName) {
$resource = sprintf('/app/%s/', $applicationName);
$this->_executeDelete($resource);
return true;
}
/**
* Add a user to an application.
*
* @param string $applicationName applications name
* @param string $email users email
*
* @throws TokenRequiredError
* @throws BadRequestError
* @throws UnauthorizedError
* @throws ForbiddenError
* @throws ConflictDuplicateError
* @throws GoneError
* @throws InternalServerError
* @throws NotImplementedError
* @throws ThrottledError
* @throws CCException
*
* @return stdObj contains app and user data
*/
public function application_addUser($applicationName, $email) {
$resource = sprintf('/app/%s/user/', $applicationName);
$data = array('email' => email);
return $this->_executePost($resource, $data);
}
/**
* Remove a user from an application.
*
* @param string $applicationName applications name
* @param string $userName users name
*
* @throws TokenRequiredError
* @throws BadRequestError
* @throws UnauthorizedError
* @throws ForbiddenError
* @throws GoneError
* @throws InternalServerError
* @throws NotImplementedError
* @throws ThrottledError
* @throws CCException
*
* @return boolean
*/
public function application_removeUser($applicationName, $userName) {
$resource = sprintf('/app/%s/user/%s/', $applicationName, $userName);
$this->_executeDelete($resource);
return true;
}
/**
* Create a new deployment.
* deploymentName is optional
* Attention!, (at current state), the first deployment of an application
* will ever be named "default". But if you give your first deployment a certain name
* an additional alias with this name will be created
*
* @param string $applicationName applications name
* @param string $deploymentName deployments name [default="default"]
*
* @throws TokenRequiredError
* @throws BadRequestError
* @throws UnauthorizedError
* @throws ForbiddenError
* @throws GoneError
* @throws InternalServerError
* @throws NotImplementedError
* @throws ThrottledError
* @throws CCException
*
* @return stdObj contains deployment data
*/
public function deployment_create($applicationName, $deploymentName='default') {
$resource = sprintf('/app/%s/deployment/', $applicationName);
$data = array();
if ($deploymentName) {
$data['name'] = $deploymentName;
}
return $this->_executePost($resource, $data);
}
/**
* return applications deployment.list
*
* @param string $applicationName applications name
*
* @throws TokenRequiredError
* @throws BadRequestError
* @throws UnauthorizedError
* @throws ForbiddenError
* @throws ConflictDuplicateError
* @throws GoneError
* @throws InternalServerError
* @throws NotImplementedError
* @throws ThrottledError
* @throws CCException
*
* @return array<stdObj> contains deployment info data
*/
public function deployment_getList($applicationName) {
$resource = sprintf('/app/%s/deployment/', $applicationName);
return $this->_executeGet($resource);
}
/**
* Returns deployment details.
*
* @param string $applicationName applications name
* @param string $deploymentName deployments name
*
* @throws TokenRequiredError
* @throws BadRequestError
* @throws UnauthorizedError
* @throws ForbiddenError
* @throws GoneError
* @throws InternalServerError
* @throws NotImplementedError
* @throws ThrottledError
* @throws CCException
*
* @return stdObj contains deployment details
*/
public function deployment_getDetails($applicationName, $deploymentName) {
$resource = sprintf('/app/%s/deployment/%s/', $applicationName, $deploymentName);
return $this->_executeGet($resource);
}
/**
* Returns deployments boxeslist for one month backwards.
*
* @param string $applicationName applications name
* @param string $deploymentName deployments name
* @param int $from start timestamp
* @param int $until end timestamp
*
* @throws TokenRequiredError
* @throws BadRequestError
* @throws UnauthorizedError
* @throws ForbiddenError
* @throws GoneError
* @throws InternalServerError
* @throws NotImplementedError
* @throws ThrottledError
* @throws CCException
*
* @return array<stdObj> contains boxes list
*/
public function deployment_getBoxeslist($applicationName, $deploymentName, $from, $until) {
$resource = sprintf('/app/%s/deployment/%s/boxes/', $applicationName, $deploymentName);
$data = array('start' => $from, 'end' => $until);
return $this->_executeGet($resource, $requiresToken=true, $data=$data);
}
/**
* Updates a deployment.
* Use this to deploy new versions. If no version is provided the
* last version is deployed.
*
* @param string $applicationName applications name
* @param string $deploymentName deployments name
* @param array $data deployments data in an associative array
*
* @throws TokenRequiredError
* @throws BadRequestError
* @throws UnauthorizedError
* @throws ForbiddenError
* @throws GoneError
* @throws InternalServerError
* @throws NotImplementedError
* @throws ThrottledError
* @throws CCException
*
* @return stdObj contains deployment data
*/
public function deployment_update($applicationName, $deploymentName, $data) {
$resource = sprintf('/app/%s/deployment/%s/', $applicationName, $deploymentName);
return $this->_executePut($resource, $data);
}
/**
* Delete a deployment.
*
* @param string $applicationName applications name
* @param string $deploymentName deployments name
*
* @throws TokenRequiredError
* @throws BadRequestError
* @throws UnauthorizedError
* @throws ForbiddenError
* @throws GoneError
* @throws InternalServerError
* @throws NotImplementedError
* @throws ThrottledError
* @throws CCException
*
* @return boolean
*/
public function deployment_delete($applicationName, $deploymentName) {
$resource = sprintf('/app/%s/deployment/%s/', $applicationName, $deploymentName);
$this->_executeDelete($resource);
return true;
}
/**
* Get a deployment's log by log_type.
* log_type choices are 'access' or 'error'
* last_time is optional - any English textual datetime description '2010-8-30 17:04:22' Y-m-d H:i:s
*
* @param string $applicationName applications name
* @param string $deploymentName deployments name
* @param string $logType logs type [default:"error"]
* @param string $lastTime logs start time [default:null]
*
* @throws TokenRequiredError
* @throws BadRequestError
* @throws UnauthorizedError
* @throws ForbiddenError
* @throws GoneError
* @throws InternalServerError
* @throws NotImplementedError
* @throws ThrottledError
* @throws CCException
*
* @return stdObj contains log data
*/
public function deployment_getLog($applicationName, $deploymentName, $logType="error", $lastTime=null) {
$url = sprintf(
'/app/%s/deployment/%s/log/%s/',
$applicationName,
$deploymentName,
$logType
);
$resource = $url;
if (!is_null($lastTime)) {
$timestamp = strtotime($lastTime);
$resource = sprintf('%s?timestamp=%s', $url, $timestamp);
}
return $this->_executeGet($resource);
}
/**
* add an addon to a deployment
*
* @param string $applicationName applications name
* @param string $deploymentName deployments name
* @param string $addonName addons name
*
* @throws TokenRequiredError
* @throws BadRequestError
* @throws UnauthorizedError
* @throws ForbiddenError
* @throws GoneError
* @throws InternalServerError
* @throws NotImplementedError
* @throws ThrottledError
* @throws CCException
*
* @return array<stdObj> contains addon list
*/
public function deployment_addAddon($applicationName, $deploymentName, $addonName) {
$resource = sprintf('/app/%s/deployment/%s/addon/', $applicationName, $deploymentName);
$data = array('addon' => $addonName);
return $this->_executePost($resource, $data);
}
/**
* get sso login data
*
* @param string $applicationName applications name
* @param string $deploymentName deployments name
* @param string $addonName addons name
*
* @throws TokenRequiredError
* @throws BadRequestError
* @throws UnauthorizedError
* @throws ForbiddenError
* @throws GoneError
* @throws InternalServerError
* @throws NotImplementedError
* @throws ThrottledError
* @throws CCException
*
* @return stdObj sso login data
*/
public function deployment_getAddonSSO($applicationName, $deploymentName, $addonName) {
$resource = sprintf('/app/%s/deployment/%s/addon/%s/login', $applicationName, $deploymentName, $addonName);
return $this->_executeGet($resource);
}
/**
* creates an alias for a deployment.
*
* @param string $applicationName applications name
* @param string $deploymentName deployments name
* @param string $aliasName new alias name
*
* @throws TokenRequiredError
* @throws BadRequestError
* @throws UnauthorizedError
* @throws ForbiddenError
* @throws GoneError
* @throws InternalServerError
* @throws NotImplementedError
* @throws ThrottledError
* @throws CCException
*
* @return stdObj contains alias details
*/
public function alias_create($applicationName, $deploymentName, $aliasName) {
$resource = sprintf('/app/%s/deployment/%s/alias/', $applicationName, $deploymentName);
$data = array('name' => $aliasName);
return $this->_executePost($resource, $data);
}
/**
* Get all alias details.
*
* @param string $applicationName applications name
* @param string $deploymentName deployments name
* @param string $aliasName alias' name
*
* @throws TokenRequiredError
* @throws BadRequestError
* @throws UnauthorizedError
* @throws ForbiddenError
* @throws GoneError
* @throws InternalServerError
* @throws NotImplementedError
* @throws ThrottledError
* @throws CCException
*
* @return stdObj contains app details
*/
public function alias_getDetails($applicationName, $deploymentName, $aliasName) {
$resource = sprintf('/app/%s/deployment/%s/alias/%s/', $applicationName, $deploymentName, $aliasName);
return $this->_executeGet($resource);
}
/**
* Remove an alias from a deployment.
*
* @param string $applicationName applications name
* @param string $deploymentName deployments name
* @param string $aliasName alias' name
*
* @throws TokenRequiredError
* @throws BadRequestError
* @throws UnauthorizedError
* @throws ForbiddenError
* @throws GoneError
* @throws InternalServerError
* @throws NotImplementedError
* @throws ThrottledError
* @throws CCException
*
* @return boolean
*/
public function alias_delete($applicationName, $deploymentName, $aliasName) {
$resource = sprintf('/app/%s/deployment/%s/alias/%s/', $applicationName, $deploymentName, $aliasName);
$this->_executeDelete($resource);
return true;
}
/**
* Get a list of users. Usually just your own.
*
* @throws TokenRequiredError
* @throws BadRequestError
* @throws UnauthorizedError
* @throws ForbiddenError
* @throws GoneError
* @throws InternalServerError
* @throws NotImplementedError
* @throws ThrottledError
* @throws CCException
*
* @return array<stdObj> contains user list
*/
public function user_getList() {
return $this->_executeGet('/user/');
}
/**
* Create a new user.
*
* @param string $userName users name
* @param string $email users email
* @param string $password users password
*
* @throws BadRequestError
* @throws UnauthorizedError
* @throws ForbiddenError
* @throws ConflictDuplicateError
* @throws GoneError
* @throws InternalServerError
* @throws NotImplementedError
* @throws ThrottledError
* @throws CCException
*
* @return stdObj contains user details
*/
public function user_create($userName, $email, $password) {
$resource = '/user/';
$data = array(
'username' => $userName,
'email' => $email,
'password' => $password
);
return $this->_executePost($resource, $data, $requiresToken=false);
}
/**
* Get user by name.
*
* @param string $userName users name
*
* @throws TokenRequiredError
* @throws BadRequestError
* @throws UnauthorizedError
* @throws ForbiddenError
* @throws GoneError
* @throws InternalServerError
* @throws NotImplementedError
* @throws ThrottledError
* @throws CCException
*
* @return stdObj contains user details
*/
public function user_getDetails($userName) {
$resource = sprintf('/user/%s/', $userName);
return $this->_executeGet($resource);
}
/**
* activate user by name.
* Use this for activation after registration.
*
* @param string $userName users name
* @param string $activationCode users activation code
*
* @throws BadRequestError
* @throws UnauthorizedError
* @throws ForbiddenError
* @throws GoneError
* @throws InternalServerError
* @throws NotImplementedError
* @throws ThrottledError
* @throws CCException
*
* @return boolean
*/
public function user_activate($userName, $activationCode) {
$resource = sprintf('/user/%s/', $userName);
$data = array(
'activation_code' => $activationCode
);
$this->_executePut($resource, $data, $requiresToken=false);
return true;
}
/**
* Delete user by $userName.
* .
* @param string $userName users name
*
* @throws TokenRequiredError
* @throws BadRequestError
* @throws UnauthorizedError
* @throws ForbiddenError
* @throws GoneError
* @throws InternalServerError
* @throws NotImplementedError
* @throws ThrottledError
* @throws CCException
*
* @return boolean
*/
public function user_delete($userName) {
$resource = sprintf('/user/%s/', $userName);
$this->_executeDelete($resource);
return true;
}
/**
* Get a list of keys belonging to user selected by $userName.
*
* @param string $userName users name
*
* @throws TokenRequiredError
* @throws BadRequestError
* @throws UnauthorizedError
* @throws ForbiddenError
* @throws GoneError
* @throws InternalServerError
* @throws NotImplementedError
* @throws ThrottledError
* @throws CCException
*
* @return array<stdObj> contains key list
*/
public function user_getKeyList($userName) {
$resource = sprintf('/user/%s/key/', $userName);
return $this->_executeGet($resource);
}
/**
* Add a key to user by $userName.
*
* @param string $userName users name
* @param string $publicKey users public key as string
*
* @throws TokenRequiredError
* @throws BadRequestError
* @throws UnauthorizedError
* @throws ForbiddenError
* @throws ConflictDuplicateError
* @throws GoneError
* @throws InternalServerError
* @throws NotImplementedError
* @throws ThrottledError
* @throws CCException
*
* @return stdObj contains key data
*/
public function user_addKey($userName, $publicKey) {
$resource = sprintf('/user/%s/key/', $userName);
$data = array('key' => $publicKey);
return $this->_executePost($resource, $data);
}
/**
* Remove a key from user by $userName.
* Requires key_id that can be requested using read_user_keys()
*
* @param string $userName users name
* @param string $keyId users public key id
*
* @throws TokenRequiredError
* @throws BadRequestError
* @throws UnauthorizedError
* @throws ForbiddenError
* @throws GoneError
* @throws InternalServerError
* @throws NotImplementedError
* @throws ThrottledError
* @throws CCException
*
* @return boolean
*/
public function user_removeKey($userName, $keyId) {
$resource = sprintf('/user/%s/key/%s/', $userName, $keyId);
$this->_executeDelete($resource);
return true;
}
/**
* creates a billing account.
*
* @param string $userName users name
* @param string $billingName billing address' name
* @param array $data billing account data as associative array
*
* @throws TokenRequiredError
* @throws BadRequestError
* @throws UnauthorizedError
* @throws ForbiddenError
* @throws ConflictDuplicateError
* @throws GoneError
* @throws InternalServerError
* @throws NotImplementedError
* @throws ThrottledError
* @throws CCException
*
* @return stdObj contains billing account data
*/
public function billingAccount_create($userName, $data) {
$resource = sprintf('/user/%s/billing/', $userName);
return $this->_executePost($resource, $data);
}
/**
* get a billing account details.
*
* @param string $userName users name
* @param string $billingName billing address' name
*
* @throws TokenRequiredError
* @throws BadRequestError
* @throws UnauthorizedError
* @throws ForbiddenError
* @throws ConflictDuplicateError
* @throws GoneError
* @throws InternalServerError
* @throws NotImplementedError
* @throws ThrottledError
* @throws CCException
*
* @return stdObj contains billing account data
*/
public function billingAccount_getDetails($userName, $billingName) {
$resource = sprintf('/user/%s/billing/%s/', $userName, $billingName);
return $this->_executeGet($resource);
}
/**
* updates a billing account.
*
* @param string $userName users name
* @param string $billingName billing address' name
* @param array $data billing account data as associative array
*
* @throws TokenRequiredError
* @throws BadRequestError
* @throws UnauthorizedError
* @throws ForbiddenError
* @throws GoneError
* @throws InternalServerError
* @throws NotImplementedError
* @throws ThrottledError
* @throws CCException
*
* @return stdObj contains billing account data
*/
public function billingAccount_update($userName, $billingName, $data) {
$resource = sprintf('/user/%s/billing/%s/', $userName, $billingName);
return $this->_executePut($resource, $data);
}
/**
* return all users billling accounts
*
* @param string $userName users name
*
* @throws TokenRequiredError
* @throws BadRequestError
* @throws UnauthorizedError
* @throws ForbiddenError
* @throws GoneError
* @throws InternalServerError
* @throws NotImplementedError
* @throws ThrottledError
* @throws CCException
*
* @return array<stdObj> contains billing account data
*/
public function billingAccount_getList($userName) {
$resource = sprintf('/user/%s/billing/', $userName);
return $this->_executeGet($resource);
}
/**
* create a billing account voucher.
*
* @param string $userName users name
* @param string $billingName billing address' name
* @param array $data billing account vouchers data as associative array
*
* @throws TokenRequiredError
* @throws BadRequestError
* @throws UnauthorizedError
* @throws ForbiddenError
* @throws ConflictDuplicateError
* @throws GoneError
* @throws InternalServerError
* @throws NotImplementedError
* @throws ThrottledError
* @throws CCException
*
* @return stdObj contains billing voucher data
*/
public function billingAccount_addVoucher($userName, $billingName, $data) {
$resource = sprintf('/user/%s/billing/%s/voucher/', $userName, $billingName);
return $this->_executePost($resource, $data);
}
/**
* get a list o billing account vouchers.
*
* @param string $userName users name
* @param string $billingName billing address' name
*
* @throws TokenRequiredError
* @throws BadRequestError
* @throws UnauthorizedError
* @throws ForbiddenError
* @throws GoneError
* @throws InternalServerError
* @throws NotImplementedError
* @throws ThrottledError
* @throws CCException
*
* @return array<stdObj> contains billing voucher data
*/
public function billingAccount_getVoucherList($userName, $billingName)
{
$resource = sprintf('/user/%s/billing/%s/voucher/', $userName, $billingName);
return $this->_executeGet($resource);
}
/**
* return list of all addons
*
* @param string $userName users name
*
* @throws BadRequestError
* @throws ForbiddenError
* @throws GoneError
* @throws InternalServerError
* @throws NotImplementedError
* @throws ThrottledError
* @throws CCException
*
* @return array<stdObj> contains all addons
*/
public function addon_getList() {
return $this->_executeGet('/addon/', $requiresToken=false);
}
/**
* return list of all support plans
*
* @throws BadRequestError
* @throws ForbiddenError
* @throws GoneError
* @throws InternalServerError
* @throws NotImplementedError
* @throws ThrottledError
* @throws CCException
*
* @return array<stdObj> contains all available support plans
*/
public function support_getList() {
return $this->_executeGet('/support/', $requiresToken=false);
}
/**
* return a single support plan
*
* @param string $planName name of the support plan