当前位置: 首页>>代码示例>>PHP>>正文


PHP Exception::unexpectedResponseError方法代码示例

本文整理汇总了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);
     }
 }
开发者ID:keboola,项目名称:gooddata-php-client,代码行数:7,代码来源:Filters.php

示例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);
     }
 }
开发者ID:keboola,项目名称:gooddata-php-client,代码行数:9,代码来源:Users.php

示例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;
 }
开发者ID:keboola,项目名称:gooddata-php-client,代码行数:44,代码来源:ProjectModel.php

示例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);
     }
 }
开发者ID:keboola,项目名称:gooddata-php-client,代码行数:37,代码来源:Datasets.php

示例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;
         }
     }
 }
开发者ID:keboola,项目名称:gooddata-php-client,代码行数:21,代码来源:Projects.php


注:本文中的Exception::unexpectedResponseError方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。