本文整理汇总了PHP中Exception::unexpectedResponseError方法的典型用法代码示例。如果您正苦于以下问题:PHP Exception::unexpectedResponseError方法的具体用法?PHP Exception::unexpectedResponseError怎么用?PHP Exception::unexpectedResponseError使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Exception
的用法示例。
在下文中一共展示了Exception::unexpectedResponseError方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: assignToUser
public function assignToUser($pid, $uid, $filters = [])
{
$result = $this->client->post("/gdc/md/{$pid}/userfilters", ['userFilters' => ['items' => [["user" => Users::getUriFromUid($uid), "userFilters" => $filters]]]]);
if (!isset($result['userFiltersUpdateResult']['successful']) || !count($result['userFiltersUpdateResult']['successful'])) {
throw Exception::unexpectedResponseError('Assign filters to user failed', 'POST', "/gdc/md/{$pid}/userfilters", $result);
}
}
示例2: createUser
public function createUser($login, $password, $domain, array $options = [])
{
$result = $this->client->post("/gdc/account/domains/{$domain}/users", ['accountSetting' => array_merge(['login' => strtolower($login), 'email' => strtolower($login), 'password' => $password, 'verifyPassword' => $password], $options)]);
if (isset($result['uri'])) {
return self::getUidFromUri($result['uri']);
} else {
throw Exception::unexpectedResponseError('Create user failed', 'POST', "/gdc/account/domains/{$domain}/users", $result);
}
}
示例3: diff
public function diff($pid, $model)
{
$uri = "/gdc/projects/{$pid}/model/diff?includeDeprecated=true&includeGrain=true";
$result = $this->client->post($uri, ['diffRequest' => ['targetModel' => $model]]);
if (isset($result['asyncTask']['link']['poll'])) {
$try = 1;
do {
sleep(10 * $try);
$taskResponse = $this->client->get($result['asyncTask']['link']['poll']);
if (!isset($taskResponse['asyncTask']['link']['poll'])) {
if (isset($taskResponse['projectModelDiff']['updateScripts'])) {
$lessDestructive = [];
$moreDestructive = [];
// Preserve data if possible
foreach ($taskResponse['projectModelDiff']['updateScripts'] as $updateScript) {
if ($updateScript['updateScript']['preserveData'] && !$updateScript['updateScript']['cascadeDrops']) {
$lessDestructive = $updateScript['updateScript']['maqlDdlChunks'];
}
if (!count($lessDestructive) && !$updateScript['updateScript']['preserveData'] && !$updateScript['updateScript']['cascadeDrops']) {
$lessDestructive = $updateScript['updateScript']['maqlDdlChunks'];
}
if (!$updateScript['updateScript']['preserveData'] && $updateScript['updateScript']['cascadeDrops']) {
$moreDestructive = $updateScript['updateScript']['maqlDdlChunks'];
}
if (!count($moreDestructive) && $updateScript['updateScript']['preserveData'] && $updateScript['updateScript']['cascadeDrops']) {
$moreDestructive = $updateScript['updateScript']['maqlDdlChunks'];
}
}
$description = [];
foreach ($taskResponse['projectModelDiff']['updateOperations'] as $o) {
$description[] = vsprintf($o['updateOperation']['description'], $o['updateOperation']['parameters']);
}
return ['moreDestructiveMaql' => $moreDestructive, 'lessDestructiveMaql' => $lessDestructive, 'description' => $description];
} else {
throw Exception::unexpectedResponseError('Polling of Model diff could not be finished', 'GET', $result['asyncTask']['link']['poll'], $taskResponse);
}
}
$try++;
} while (true);
} else {
throw Exception::unexpectedResponseError('Polling of Model diff could not be started', 'POST', $uri, $result);
}
return false;
}
示例4: loadData
public function loadData($pid, $dirName)
{
$uri = "/gdc/md/{$pid}/etl/pull2";
$result = $this->client->post($uri, ['pullIntegration' => $dirName]);
if (isset($result['pull2Task']['links']['poll'])) {
$try = 1;
do {
sleep(10 * $try);
$taskResponse = $this->client->get($result['pull2Task']['links']['poll']);
if (!isset($taskResponse['wTaskStatus']['status'])) {
throw Exception::unexpectedResponseError('ETL task could not be checked', 'GET', $result['pull2Task']['links']['poll'], $taskResponse);
}
$try++;
} while ($taskResponse['wTaskStatus']['status'] == 'RUNNING');
if ($taskResponse['wTaskStatus']['status'] == 'ERROR') {
$errors = [];
if (isset($taskResponse['messages'])) {
foreach ($taskResponse['messages'] as $m) {
if (isset($m['error'])) {
$errors[] = Exception::parseMessage($m['error']);
}
}
}
if (isset($taskResponse['wTaskStatus']['messages'])) {
foreach ($taskResponse['wTaskStatus']['messages'] as $m) {
if (isset($m['error'])) {
$errors[] = Exception::parseMessage($m['error']);
}
}
}
throw new Exception($errors);
}
return isset($taskResponse['messages']) ? $taskResponse['messages'] : [];
} else {
throw Exception::unexpectedResponseError('ETL task failed', 'POST', $uri, $result);
}
}
示例5: inviteUser
public function inviteUser($pid, $email, $role = Projects::ROLE_ADMIN, $filters = [])
{
$projectRoleUri = $this->getRoleUri($pid, $role);
try {
$result = $this->client->post("/gdc/projects/{$pid}/invitations", ['invitations' => [['invitation' => ['content' => ['email' => $email, 'role' => $projectRoleUri, 'userFilters' => $filters]]]]]);
if (isset($result['createdInvitations']['uri']) && count($result['createdInvitations']['uri'])) {
return current($result['createdInvitations']['uri']);
} else {
if (isset($result['createdInvitations']['loginsAlreadyInProject']) && count($result['createdInvitations']['loginsAlreadyInProject'])) {
return true;
}
throw Exception::unexpectedResponseError('Invitation to project failed', 'POST', "/gdc/projects/pid/invitations", $result);
}
} catch (Exception $e) {
if (isset($e->getData()['error']['message']) && strpos($e->getData()['error']['message'], 'is already member') !== false) {
return true;
} else {
throw $e;
}
}
}