Controller/Adminhtml/FastlyCdn/Backend/ConfigureBackend.php
public function execute()
    {
        $result = $this->resultJson->create();
        try {
            $activate_flag = $this->getRequest()->getParam('activate_flag');
            $activeVersion = $this->getRequest()->getParam('active_version');
            $oldName = $this->getRequest()->getParam('name');
            $params = [
                'name'                  => $this->getRequest()->getParam('name'),
                'shield'                => $this->getRequest()->getParam('shield'),
                'connect_timeout'       => $this->getRequest()->getParam('connect_timeout'),
                'between_bytes_timeout' => $this->getRequest()->getParam('between_bytes_timeout'),
                'first_byte_timeout'    => $this->getRequest()->getParam('first_byte_timeout'),
            ];
            $service = $this->api->checkServiceDetails();
            $this->vcl->checkCurrentVersionActive($service->versions, $activeVersion);
            $currActiveVersion = $this->vcl->getCurrentVersion($service->versions);
            $clone = $this->api->cloneVersion($currActiveVersion);
            $configureBackend = $this->api->configureBackend($params, $clone->number, $oldName);

            if (!$configureBackend) {
                return $result->setData([
                    'status'    => false,
                    'msg'       => 'Failed to update Backend configuration.'
                ]);
            }

            $this->api->validateServiceVersion($clone->number);

            if ($activate_flag === 'true') {
                $this->api->activateVersion($clone->number);
            }
            if ($this->config->areWebHooksEnabled() && $this->config->canPublishConfigChanges()) {
                $this->api->sendWebHook(
                    '*Backend '
                    . $this->getRequest()->getParam('name')
                    . ' has been changed in Fastly version '
                    . $clone->number
                    . '*'
                );
            }

            $comment = ['comment' => 'Magento Module updated the "'.$oldName.'" Backend Configuration'];
            $this->api->addComment($clone->number, $comment);

            return $result->setData([
                'status'            => true,
                'active_version'    => $clone->number
            ]);
        } catch (\Exception $e) {
            return $result->setData([
                'status'    => false,
                'msg'       => $e->getMessage()
            ]);
        }
    }
public function execute()
    {
        $result = $this->resultJson->create();
        try {
            $activate_flag = $this->getRequest()->getParam('activate_flag');
            $activeVersion = $this->getRequest()->getParam('active_version');
            $oldName = $this->getRequest()->getParam('name');
            $params = [
                'name'                  => $this->getRequest()->getParam('name'),
                'shield'                => $this->getRequest()->getParam('shield'),
                'connect_timeout'       => $this->getRequest()->getParam('connect_timeout'),
                'between_bytes_timeout' => $this->getRequest()->getParam('between_bytes_timeout'),
                'first_byte_timeout'    => $this->getRequest()->getParam('first_byte_timeout'),
            ];
            $service = $this->api->checkServiceDetails();
            $this->vcl->checkCurrentVersionActive($service->versions, $activeVersion);
            $currActiveVersion = $this->vcl->getCurrentVersion($service->versions);
            $clone = $this->api->cloneVersion($currActiveVersion);
            $configureBackend = $this->api->configureBackend($params, $clone->number, $oldName);

            if (!$configureBackend) {
                return $result->setData([
                    'status'    => false,
                    'msg'       => 'Failed to update Backend configuration.'
                ]);
            }

            $this->api->validateServiceVersion($clone->number);

            if ($activate_flag === 'true') {
                $this->api->activateVersion($clone->number);
            }
            if ($this->config->areWebHooksEnabled() && $this->config->canPublishConfigChanges()) {
                $this->api->sendWebHook(
                    '*Backend '
                    . $this->getRequest()->getParam('name')
                    . ' has been changed in Fastly version '
                    . $clone->number
                    . '*'
                );
            }

            $comment = ['comment' => 'Magento Module updated the "'.$oldName.'" Backend Configuration'];
            $this->api->addComment($clone->number, $comment);

            return $result->setData([
                'status'            => true,
                'active_version'    => $clone->number
            ]);
        } catch (\Exception $e) {
            return $result->setData([
                'status'    => false,
                'msg'       => $e->getMessage()
            ]);
        }
    }
public function execute ( ) { $ result = $ this -> resultJson -> create ( ) ; try { $ activate_flag = $ this -> getRequest ( ) -> getParam ( 'activate_flag' ) ; $ activeVersion = $ this -> getRequest ( ) -> getParam ( 'active_version' ) ; $ oldName = $ this -> getRequest ( ) -> getParam ( 'name' ) ; $ params = [ 'name' => $ this -> getRequest ( ) -> getParam ( 'name' ) , 'shield' => $ this -> getRequest ( ) -> getParam ( 'shield' ) , 'connect_timeout' => $ this -> getRequest ( ) -> getParam ( 'connect_timeout' ) , 'between_bytes_timeout' => $ this -> getRequest ( ) -> getParam ( 'between_bytes_timeout' ) , 'first_byte_timeout' => $ this -> getRequest ( ) -> getParam ( 'first_byte_timeout' ) , ] ; $ service = $ this -> api -> checkServiceDetails ( ) ; $ this -> vcl -> checkCurrentVersionActive ( $ service -> versions , $ activeVersion ) ; $ currActiveVersion = $ this -> vcl -> getCurrentVersion ( $ service -> versions ) ; $ clone = $ this -> api -> cloneVersion ( $ currActiveVersion ) ; $ configureBackend = $ this -> api -> configureBackend ( $ params , $ clone -> number , $ oldName ) ; if ( ! $ configureBackend ) { return $ result -> setData ( [ 'status' => false , 'msg' => 'Failed to update Backend configuration.' ] ) ; } $ this -> api -> validateServiceVersion ( $ clone -> number ) ; if ( $ activate_flag === 'true' ) { $ this -> api -> activateVersion ( $ clone -> number ) ; } if ( $ this -> config -> areWebHooksEnabled ( ) && $ this -> config -> canPublishConfigChanges ( ) ) { $ this -> api -> sendWebHook ( '*Backend ' . $ this -> getRequest ( ) -> getParam ( 'name' ) . ' has been changed in Fastly version ' . $ clone -> number . '*' ) ; } $ comment = [ 'comment' => 'Magento Module updated the "' . $ oldName . '" Backend Configuration' ] ; $ this -> api -> addComment ( $ clone -> number , $ comment ) ; return $ result -> setData ( [ 'status' => true , 'active_version' => $ clone -> number ] ) ; } catch ( \ Exception $ e ) { return $ result -> setData ( [ 'status' => false , 'msg' => $ e -> getMessage ( ) ] ) ; } }
Upload VCL snippets

@return $this|\Magento\Framework\App\ResponseInterface|\Magento\Framework\Controller\ResultInterface
Upload VCL snippets