UAccountClient.php 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276
  1. <?php
  2. /**
  3. * Copyright 2022 UCloud Technology Co., Ltd.
  4. *
  5. * Licensed under the Apache License, Version 2.0 (the "License");
  6. * you may not use this file except in compliance with the License.
  7. * You may obtain a copy of the License at
  8. *
  9. * http://www.apache.org/licenses/LICENSE-2.0
  10. *
  11. * Unless required by applicable law or agreed to in writing, software
  12. * distributed under the License is distributed on an "AS IS" BASIS,
  13. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. * See the License for the specific language governing permissions and
  15. * limitations under the License.
  16. */
  17. namespace UCloud\UAccount;
  18. use UCloud\Core\Client;
  19. use UCloud\Core\Exception\UCloudException;
  20. use UCloud\UAccount\Apis\AddMemberToProjectRequest;
  21. use UCloud\UAccount\Apis\AddMemberToProjectResponse;
  22. use UCloud\UAccount\Apis\FreezeMemberRequest;
  23. use UCloud\UAccount\Apis\FreezeMemberResponse;
  24. use UCloud\UAccount\Apis\GetNetworkMaskRequest;
  25. use UCloud\UAccount\Apis\GetNetworkMaskResponse;
  26. use UCloud\UAccount\Apis\GetProjectListRequest;
  27. use UCloud\UAccount\Apis\GetProjectListResponse;
  28. use UCloud\UAccount\Apis\GetRegionRequest;
  29. use UCloud\UAccount\Apis\GetRegionResponse;
  30. use UCloud\UAccount\Apis\InviteSubaccountRequest;
  31. use UCloud\UAccount\Apis\InviteSubaccountResponse;
  32. use UCloud\UAccount\Apis\RemoveMemberFromProjectRequest;
  33. use UCloud\UAccount\Apis\RemoveMemberFromProjectResponse;
  34. use UCloud\UAccount\Apis\SetNetworkMaskRequest;
  35. use UCloud\UAccount\Apis\SetNetworkMaskResponse;
  36. /**
  37. * This client is used to call actions of **UAccount** service
  38. */
  39. class UAccountClient extends Client
  40. {
  41. /**
  42. * AddMemberToProject - 添加成员到项目
  43. *
  44. * See also: https://docs.ucloud.cn/api/uaccount-api/add_member_to_project
  45. *
  46. * Arguments:
  47. *
  48. * $args = [
  49. * "ProjectId" => (string) 项目ID,请参考[GetProjectList接口](../summary/get_project_list.html)的描述。不填写为创建时间最早的项目。
  50. * "MemberEmail" => (string) 被加入成员Email
  51. * "CharacterId" => (string) 被加入成员归属角色ID
  52. * ]
  53. *
  54. * Outputs:
  55. *
  56. * $outputs = [
  57. * ]
  58. *
  59. * @return AddMemberToProjectResponse
  60. * @throws UCloudException
  61. */
  62. public function addMemberToProject(AddMemberToProjectRequest $request = null)
  63. {
  64. $resp = $this->invoke($request);
  65. return new AddMemberToProjectResponse($resp->toArray(), $resp->getRequestId());
  66. }
  67. /**
  68. * FreezeMember - 冻结成员
  69. *
  70. * See also: https://docs.ucloud.cn/api/uaccount-api/freeze_member
  71. *
  72. * Arguments:
  73. *
  74. * $args = [
  75. * "MemberEmail" => (string) 需要被冻结的成员Email
  76. * ]
  77. *
  78. * Outputs:
  79. *
  80. * $outputs = [
  81. * ]
  82. *
  83. * @return FreezeMemberResponse
  84. * @throws UCloudException
  85. */
  86. public function freezeMember(FreezeMemberRequest $request = null)
  87. {
  88. $resp = $this->invoke($request);
  89. return new FreezeMemberResponse($resp->toArray(), $resp->getRequestId());
  90. }
  91. /**
  92. * GetNetworkMask - 查询登录与API调用的网络掩码
  93. *
  94. * See also: https://docs.ucloud.cn/api/uaccount-api/get_network_mask
  95. *
  96. * Arguments:
  97. *
  98. * $args = [
  99. * ]
  100. *
  101. * Outputs:
  102. *
  103. * $outputs = [
  104. * "Data" => (object) 接口返回数据[
  105. * "APINetworkMask" => (string) API调用网络掩码,默认空字符串,不限制登录IP,多个IP以英文逗号分隔。
  106. * "LoginNetworkMask" => (string) 登录网络掩码,默认空字符串,不限制登录IP,多个IP以英文逗号分隔。
  107. * ]
  108. * ]
  109. *
  110. * @return GetNetworkMaskResponse
  111. * @throws UCloudException
  112. */
  113. public function getNetworkMask(GetNetworkMaskRequest $request = null)
  114. {
  115. $resp = $this->invoke($request);
  116. return new GetNetworkMaskResponse($resp->toArray(), $resp->getRequestId());
  117. }
  118. /**
  119. * GetProjectList - 获取项目列表
  120. *
  121. * See also: https://docs.ucloud.cn/api/uaccount-api/get_project_list
  122. *
  123. * Arguments:
  124. *
  125. * $args = [
  126. * "IsFinance" => (string) 是否是财务账号(Yes:是,No:否)
  127. * ]
  128. *
  129. * Outputs:
  130. *
  131. * $outputs = [
  132. * "ProjectCount" => (integer) 项目总数
  133. * "ProjectSet" => (array<object>) JSON格式的项目列表实例[
  134. * [
  135. * "ProjectId" => (string) 项目ID
  136. * "ProjectName" => (string) 项目名称
  137. * "CreateTime" => (integer) 创建时间(Unix时间戳)
  138. * "IsDefault" => (boolean) 是否为默认项目
  139. * "ResourceCount" => (integer) 项目下资源数量(已废弃,不建议使用)
  140. * "MemberCount" => (integer) 项目下成员数量
  141. * "ParentId" => (string) 父项目ID(已废弃)
  142. * "ParentName" => (string) 父项目名称(已废弃)
  143. * ]
  144. * ]
  145. * ]
  146. *
  147. * @return GetProjectListResponse
  148. * @throws UCloudException
  149. */
  150. public function getProjectList(GetProjectListRequest $request = null)
  151. {
  152. $resp = $this->invoke($request);
  153. return new GetProjectListResponse($resp->toArray(), $resp->getRequestId());
  154. }
  155. /**
  156. * GetRegion - 获取用户在各数据中心的权限等信息
  157. *
  158. * See also: https://docs.ucloud.cn/api/uaccount-api/get_region
  159. *
  160. * Arguments:
  161. *
  162. * $args = [
  163. * ]
  164. *
  165. * Outputs:
  166. *
  167. * $outputs = [
  168. * "Regions" => (array<object>) 各数据中心信息[
  169. * [
  170. * "RegionId" => (integer) 数据中心ID
  171. * "RegionName" => (string) 数据中心名称
  172. * "IsDefault" => (boolean) 是否用户当前默认数据中心
  173. * "BitMaps" => (string) 用户在此数据中心的权限位
  174. * "Region" => (string) 地域名字,如cn-bj
  175. * "Zone" => (string) 可用区名字,如cn-bj-01
  176. * ]
  177. * ]
  178. * ]
  179. *
  180. * @return GetRegionResponse
  181. * @throws UCloudException
  182. */
  183. public function getRegion(GetRegionRequest $request = null)
  184. {
  185. $resp = $this->invoke($request);
  186. return new GetRegionResponse($resp->toArray(), $resp->getRequestId());
  187. }
  188. /**
  189. * InviteSubaccount - 邀请子帐号成员
  190. *
  191. * See also: https://docs.ucloud.cn/api/uaccount-api/invite_subaccount
  192. *
  193. * Arguments:
  194. *
  195. * $args = [
  196. * "UserEmail" => (string) 受邀成员邮箱地址,不得重复
  197. * "UserPhone" => (string) 受邀成员手机号码
  198. * "UserName" => (string) 受邀成员姓名
  199. * "IsFinance" => (string) 是否有财务权限(true:是,false:否,默认为否)
  200. * ]
  201. *
  202. * Outputs:
  203. *
  204. * $outputs = [
  205. * ]
  206. *
  207. * @return InviteSubaccountResponse
  208. * @throws UCloudException
  209. */
  210. public function inviteSubaccount(InviteSubaccountRequest $request = null)
  211. {
  212. $resp = $this->invoke($request);
  213. return new InviteSubaccountResponse($resp->toArray(), $resp->getRequestId());
  214. }
  215. /**
  216. * RemoveMemberFromProject - 从项目中移除成员
  217. *
  218. * See also: https://docs.ucloud.cn/api/uaccount-api/remove_member_from_project
  219. *
  220. * Arguments:
  221. *
  222. * $args = [
  223. * "ProjectId" => (string) 项目ID,请参考[GetProjectList接口](../summary/get_project_list.html)的描述。不填写为默认项目,子帐号必须填写。
  224. * "MemberEmail" => (string) 需要被移除成员Email
  225. * ]
  226. *
  227. * Outputs:
  228. *
  229. * $outputs = [
  230. * ]
  231. *
  232. * @return RemoveMemberFromProjectResponse
  233. * @throws UCloudException
  234. */
  235. public function removeMemberFromProject(RemoveMemberFromProjectRequest $request = null)
  236. {
  237. $resp = $this->invoke($request);
  238. return new RemoveMemberFromProjectResponse($resp->toArray(), $resp->getRequestId());
  239. }
  240. /**
  241. * SetNetworkMask - 设置登录与API调用的网络掩码
  242. *
  243. * See also: https://docs.ucloud.cn/api/uaccount-api/set_network_mask
  244. *
  245. * Arguments:
  246. *
  247. * $args = [
  248. * "Code" => (string) 短信验证码
  249. * "APINetworkMask" => (string) API调用网络掩码,多个IP以英文逗号分隔。默认空字符串,不限制登录IP。
  250. * "LoginNetworkMask" => (string) 登录网络掩码,多个IP以英文逗号分隔。默认空字符串,不限制登录IP。
  251. * ]
  252. *
  253. * Outputs:
  254. *
  255. * $outputs = [
  256. * ]
  257. *
  258. * @return SetNetworkMaskResponse
  259. * @throws UCloudException
  260. */
  261. public function setNetworkMask(SetNetworkMaskRequest $request = null)
  262. {
  263. $resp = $this->invoke($request);
  264. return new SetNetworkMaskResponse($resp->toArray(), $resp->getRequestId());
  265. }
  266. }