Controller/Adminhtml/FastlyCdn/Blocking/UpdateBlocking.php
public function execute()
    {
        $result = $this->resultJson->create();
        try {
            $service = $this->api->checkServiceDetails();
            $currActiveVersion = $this->vcl->determineVersions($service->versions);

            $snippet = $this->config->getVclSnippets(
                Config::VCL_BLOCKING_PATH,
                Config::VCL_BLOCKING_SNIPPET
            );

            $country_codes = $this->prepareCountryCodes($this->request->getParam('countries'));
            $acls = $this->prepareAcls($this->request->getParam('acls'));

            $blockedItems = $country_codes . $acls;
            $strippedBlockedItems = substr($blockedItems, 0, strrpos($blockedItems, '||', -1));
            $blockingType = $this->request->getParam('blocking_type');

            $this->configWriter->save(
                Config::XML_FASTLY_BLOCKING_TYPE,
                $blockingType,
                'default',
                '0'
            );

            // Add blocking snippet
            foreach ($snippet as $key => $value) {
                if ($strippedBlockedItems === '') {
                    $value = '';
                } else {
                    $strippedBlockedItems = $this->config->processBlockedItems($strippedBlockedItems, $blockingType);
                    $value = str_replace('####BLOCKED_ITEMS####', $strippedBlockedItems, $value);
                }

                $snippetName = Config::FASTLY_MAGENTO_MODULE . '_blocking_' . $key;
                $snippetId = $this->api->getSnippet($currActiveVersion['active_version'], $snippetName)->id;
                $params = [
                    'name'      =>  $snippetId,
                    'content'   => $value
                ];

                $this->api->updateSnippet($params);
            }

            $this->cacheTypeList->cleanType('config');
            $this->systemConfig->clean();

            return $result->setData([
                'status' => true
            ]);
        } catch (\Exception $e) {
            return $result->setData([
                'status'    => false,
                'msg'       => $e->getMessage()
            ]);
        }
    }
public function execute()
    {
        $result = $this->resultJson->create();
        try {
            $service = $this->api->checkServiceDetails();
            $currActiveVersion = $this->vcl->determineVersions($service->versions);

            $snippet = $this->config->getVclSnippets(
                Config::VCL_BLOCKING_PATH,
                Config::VCL_BLOCKING_SNIPPET
            );

            $country_codes = $this->prepareCountryCodes($this->request->getParam('countries'));
            $acls = $this->prepareAcls($this->request->getParam('acls'));

            $blockedItems = $country_codes . $acls;
            $strippedBlockedItems = substr($blockedItems, 0, strrpos($blockedItems, '||', -1));
            $blockingType = $this->request->getParam('blocking_type');

            $this->configWriter->save(
                Config::XML_FASTLY_BLOCKING_TYPE,
                $blockingType,
                'default',
                '0'
            );

            // Add blocking snippet
            foreach ($snippet as $key => $value) {
                if ($strippedBlockedItems === '') {
                    $value = '';
                } else {
                    $strippedBlockedItems = $this->config->processBlockedItems($strippedBlockedItems, $blockingType);
                    $value = str_replace('####BLOCKED_ITEMS####', $strippedBlockedItems, $value);
                }

                $snippetName = Config::FASTLY_MAGENTO_MODULE . '_blocking_' . $key;
                $snippetId = $this->api->getSnippet($currActiveVersion['active_version'], $snippetName)->id;
                $params = [
                    'name'      =>  $snippetId,
                    'content'   => $value
                ];

                $this->api->updateSnippet($params);
            }

            $this->cacheTypeList->cleanType('config');
            $this->systemConfig->clean();

            return $result->setData([
                'status' => true
            ]);
        } catch (\Exception $e) {
            return $result->setData([
                'status'    => false,
                'msg'       => $e->getMessage()
            ]);
        }
    }
Upload Blocking snippets

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