1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 try:
18 import json
19 except ImportError:
20 import simplejson as json
21
22 from cm_api.endpoints.types import *
23
24 __docformat__ = "epytext"
25
26 EXTERNAL_ACCOUNT_PATH = "/externalAccounts/%s"
27 EXTERNAL_ACCOUNT_FETCH_PATH = "/externalAccounts/%s/%s"
28
30 """
31 Lookup all supported categories.
32 @param resource_root: The root Resource object.
33 @return: An ApiExternalAcccountCategory list
34 """
35 return call(resource_root.get, EXTERNAL_ACCOUNT_PATH % ("supportedCategories",) ,
36 ApiExternalAccountCategory, True)
37
39 """
40 Lookup all supported types in a category.
41 @param resource_root: The root Resource object.
42 @param category_name: The category name
43 @return: An ApiExternalAcccountType list
44 """
45 return call(resource_root.get,
46 EXTERNAL_ACCOUNT_FETCH_PATH % ("supportedTypes", category_name,),
47 ApiExternalAccountType, True)
48
51 """
52 Create an external account
53 @param resource_root: The root Resource object.
54 @param name: Immutable external account name
55 @param display_name: Display name
56 @param type_name: Account type
57 @param account_configs: Optional account configuration (ApiList of ApiConfig objects)
58 @return: An ApiExternalAccount object matching the newly created account
59 """
60 account = ApiExternalAccount(resource_root,
61 name=name,
62 displayName=display_name,
63 typeName=type_name,
64 accountConfigs=account_configs)
65 return call(resource_root.post,
66 EXTERNAL_ACCOUNT_PATH % ("create",),
67 ApiExternalAccount, False, data=account)
68
70 """
71 Lookup an external account by name
72 @param resource_root: The root Resource object.
73 @param name: Account name
74 @param view: View
75 @return: An ApiExternalAccount object
76 """
77 return call(resource_root.get,
78 EXTERNAL_ACCOUNT_FETCH_PATH % ("account", name,),
79 ApiExternalAccount, False, params=view and dict(view=view) or None)
80
83 """
84 Lookup an external account by display name
85 @param resource_root: The root Resource object.
86 @param display_name: Account display name
87 @param view: View
88 @return: An ApiExternalAccount object
89 """
90 return call(resource_root.get,
91 EXTERNAL_ACCOUNT_FETCH_PATH % ("accountByDisplayName", display_name,),
92 ApiExternalAccount, False, params=view and dict(view=view) or None)
93
95 """
96 Lookup all external accounts of a particular type, by type name.
97 @param resource_root: The root Resource object.
98 @param type_name: Type name
99 @param view: View
100 @return: An ApiList of ApiExternalAccount objects matching the specified type
101 """
102 return call(resource_root.get,
103 EXTERNAL_ACCOUNT_FETCH_PATH % ("type", type_name,),
104 ApiExternalAccount, True, params=view and dict(view=view) or None)
105
107 """
108 Update an external account
109 @param resource_root: The root Resource object.
110 @param account: Account to update, account name must be specified.
111 @return: An ApiExternalAccount object, representing the updated external account
112 """
113 return call(resource_root.put,
114 EXTERNAL_ACCOUNT_PATH % ("update",),
115 ApiExternalAccount, False, data=account)
116
118 """
119 Delete an external account by name
120 @param resource_root: The root Resource object.
121 @param name: Account name
122 @return: The deleted ApiExternalAccount object
123 """
124 return call(resource_root.delete,
125 EXTERNAL_ACCOUNT_FETCH_PATH % ("delete", name,),
126 ApiExternalAccount, False)
127
128
130 _ATTRIBUTES = {
131 'name' : None,
132 'displayName' : None,
133 'description' : None
134 }
135
137 return "<ApiExternalAccountCategory>: %s" % (
138 self.name)
139
141 _ATTRIBUTES = {
142 'name' : None,
143 'displayName' : None,
144 'type' : None,
145 'categoryName' : None,
146 'description' : None,
147 'allowedAccountConfigs' : Attr(ApiConfig)
148 }
149
151 return "<ApiExternalAccountType>: %s (categoryName: %s)" % (
152 self.name, self.typeName)
153
155 _ATTRIBUTES = {
156 'name' : None,
157 'displayName' : None,
158 'typeName' : None,
159 'createdTime' : ROAttr(),
160 'lastModifiedTime' : ROAttr(),
161 'accountConfigs' : Attr(ApiConfig)
162 }
163
164 - def __init__(self, resource_root, name=None, displayName=None,
165 typeName=None, accountConfigs=None):
167
169 return "<ApiExternalAccount>: %s (typeName: %s)" % (
170 self.name, self.typeName)
171