| @@ 106-128 (lines=23) @@ | ||
| 103 | * |
|
| 104 | * @throws \RuntimeException if cannot create the container |
|
| 105 | */ |
|
| 106 | public function createContainer($containerName, CreateContainerOptions $options = null) |
|
| 107 | { |
|
| 108 | $this->init(); |
|
| 109 | ||
| 110 | if (null === $options) { |
|
| 111 | $options = $this->getCreateContainerOptions(); |
|
| 112 | } |
|
| 113 | ||
| 114 | try { |
|
| 115 | $this->blobProxy->createContainer($containerName, $options); |
|
| 116 | } catch (ServiceException $e) { |
|
| 117 | $errorCode = $this->getErrorCodeFromServiceException($e); |
|
| 118 | ||
| 119 | if ($errorCode !== self::ERROR_CONTAINER_ALREADY_EXISTS) { |
|
| 120 | throw new \RuntimeException(sprintf( |
|
| 121 | 'Failed to create the configured container "%s": %s (%s).', |
|
| 122 | $containerName, |
|
| 123 | $e->getErrorText(), |
|
| 124 | $errorCode |
|
| 125 | )); |
|
| 126 | } |
|
| 127 | } |
|
| 128 | } |
|
| 129 | ||
| 130 | /** |
|
| 131 | * Deletes a container. |
|
| @@ 138-156 (lines=19) @@ | ||
| 135 | * |
|
| 136 | * @throws \RuntimeException if cannot delete the container |
|
| 137 | */ |
|
| 138 | public function deleteContainer($containerName, DeleteContainerOptions $options = null) |
|
| 139 | { |
|
| 140 | $this->init(); |
|
| 141 | ||
| 142 | try { |
|
| 143 | $this->blobProxy->deleteContainer($containerName, $options); |
|
| 144 | } catch (ServiceException $e) { |
|
| 145 | $errorCode = $this->getErrorCodeFromServiceException($e); |
|
| 146 | ||
| 147 | if ($errorCode !== self::ERROR_CONTAINER_NOT_FOUND) { |
|
| 148 | throw new \RuntimeException(sprintf( |
|
| 149 | 'Failed to delete the configured container "%s": %s (%s).', |
|
| 150 | $containerName, |
|
| 151 | $e->getErrorText(), |
|
| 152 | $errorCode |
|
| 153 | ), $e->getCode()); |
|
| 154 | } |
|
| 155 | } |
|
| 156 | } |
|
| 157 | ||
| 158 | /** |
|
| 159 | * {@inheritdoc} |
|