77class Jobs extends GenericResource
88{
99 /**
10+ * Retrieves a job. Useful to check its status.
11+ * Required scopes: "create:users" "read:users"
12+ *
13+ * @param string $id
14+ *
15+ * @throws \Exception Thrown by the HTTP client when there is a problem with the API call.
1016 *
11- * @param string $id
1217 * @return mixed
18+ *
19+ * @see https://auth0.com/docs/api/management/v2#!/Jobs/get_jobs_by_id
1320 */
1421 public function get ($ id )
1522 {
@@ -19,9 +26,16 @@ public function get($id)
1926 }
2027
2128 /**
29+ * Retrieve error details of a failed job.
30+ * Required scopes: "create:users" "read:users"
31+ *
32+ * @param string $id
33+ *
34+ * @throws \Exception Thrown by the HTTP client when there is a problem with the API call.
2235 *
23- * @param string $id
2436 * @return mixed
37+ *
38+ * @see https://auth0.com/docs/api/management/v2#!/Jobs/get_errors
2539 */
2640 public function getErrors ($ id )
2741 {
@@ -31,11 +45,18 @@ public function getErrors($id)
3145 }
3246
3347 /**
48+ * Import users from a formatted file into a connection via a long-running job.
49+ * Required scopes: "create:users" "read:users"
50+ *
51+ * @param string $file_path
52+ * @param string $connection_id
53+ * @param array $params
54+ *
55+ * @throws \Exception Thrown by the HTTP client when there is a problem with the API call.
3456 *
35- * @param string $file_path
36- * @param string $connection_id
37- * @param array $params
3857 * @return mixed
58+ *
59+ * @see https://auth0.com/docs/api/management/v2#!/Jobs/post_users_imports
3960 */
4061 public function importUsers ($ file_path , $ connection_id , $ params = [])
4162 {
@@ -59,6 +80,45 @@ public function importUsers($file_path, $connection_id, $params = [])
5980 return $ request ->call ();
6081 }
6182
83+
84+ /**
85+ * Export all users to a file via a long-running job.
86+ * Required scopes: "read:users"
87+ *
88+ * @param array $params
89+ *
90+ * @throws \Exception Thrown by the HTTP client when there is a problem with the API call.
91+ *
92+ * @return mixed
93+ *
94+ * @see https://auth0.com/docs/api/management/v2#!/Jobs/post_users_exports
95+ */
96+ public function exportUsers ($ params = [])
97+ {
98+ $ request = $ this ->apiClient ->method ('post ' )
99+ ->addPath ('jobs ' , 'users-exports ' );
100+
101+ $ body = [];
102+
103+ if (!empty ($ params ['connection_id ' ])) {
104+ $ body ['connection_id ' ] = $ params ['connection_id ' ];
105+ }
106+
107+ if (!empty ($ params ['format ' ]) && in_array ($ params ['format ' ], ['json ' , 'csv ' ])) {
108+ $ body ['format ' ] = $ params ['format ' ];
109+ }
110+
111+ if (!empty ($ params ['limit ' ]) && is_numeric ($ params ['limit ' ])) {
112+ $ body ['limit ' ] = $ params ['limit ' ];
113+ }
114+
115+ if (!empty ($ params ['fields ' ]) && is_array ($ params ['fields ' ])) {
116+ $ body ['fields ' ] = $ params ['fields ' ];
117+ }
118+
119+ return $ request ->withBody (json_encode ($ body ), JSON_FORCE_OBJECT )->call ();
120+ }
121+
62122 /**
63123 * Create a verification email job.
64124 * Required scope: "update:users"
0 commit comments