private static function updateCampaignDsaSetting(
        AdWordsServices $adWordsServices,
        AdWordsSession $session,
        $campaignId,
        DSAFeedDetails $feedDetails
    ) {
        $campaignService = $adWordsServices->get($session, CampaignService::class);

        // Create selector.
        $selector = new Selector();
        $selector->setFields(['Id', 'Settings']);
        $selector->setPredicates(
            [new Predicate('CampaignId', PredicateOperator::IN, [$campaignId])]
        );

        $result = $campaignService->get($selector);
        if (empty($result->getEntries()) || $result->getTotalNumEntries() === 0) {
            throw new InvalidArgumentException(
                'No campaign found with ID: ' . $campaignId
            );
        }
        $campaign = $result->getEntries()[0];

        if ($campaign->getSettings() === null) {
            throw new InvalidArgumentException(
                'Campaign with ID ' . $campaignId . ' is not a DSA campaign.'
            );
        }

        $dsaSetting = null;
        foreach ($campaign->getSettings() as $setting) {
            if ($setting instanceof DynamicSearchAdsSetting) {
                $dsaSetting = $setting;
                break;
            }
        }

        if ($dsaSetting === null) {
            throw new InvalidArgumentException(
                'Campaign with ID ' . $campaignId . ' is not a DSA campaign.'
            );
        }

        // Use a page feed to specify precisely which URLs to use with your
        // Dynamic Search Ads.
        $pageFeed = new PageFeed();
        $pageFeed->setFeedIds([$feedDetails->feedId]);
        $dsaSetting->setPageFeed($pageFeed);

        // Optional: Specify whether only the supplied URLs should be used with your
        // Dynamic Search Ads.
        $dsaSetting->setUseSuppliedUrlsOnly(true);

        $updatedCampaign = new Campaign();
        $updatedCampaign->setId($campaignId);
        $updatedCampaign->setSettings($campaign->getSettings());

        $operation = new CampaignOperation();
        $operation->setOperand($updatedCampaign);
        $operation->setOperator(Operator::SET);

        // Update the campaign on the server and print out some information.
        $result = $campaignService->mutate([$operation]);
        $updatedCampaign = $result->getValue()[0];
        printf(
            "DSA page feed for campaign ID %d was updated with feed ID %d.\n",
            $updatedCampaign->getId(),
            $feedDetails->feedId
        );
    }