/// <summary>
        /// Run the code example.
        /// </summary>
        public void Run(AdManagerUser user)
        {
            using (CmsMetadataService cmsMetadataService = user.GetService <CmsMetadataService>())
            {
                string cmsMetadataKeyName = "INSERT_CMS_METADATA_KEY_NAME_HERE";

                // Create a statement to select CMS metadata values.
                int pageSize = StatementBuilder.SUGGESTED_PAGE_LIMIT;
                StatementBuilder statementBuilder = new StatementBuilder()
                                                    .Where("cmsKey = :cmsMetadataKeyName")
                                                    .OrderBy("id ASC")
                                                    .Limit(pageSize)
                                                    .AddValue("cmsKey", cmsMetadataKeyName);

                // Retrieve a small amount of CMS metadata values at a time, paging through until
                // all CMS metadata values have been retrieved.
                int totalResultSetSize = 0;
                do
                {
                    CmsMetadataValuePage page = cmsMetadataService.getCmsMetadataValuesByStatement(
                        statementBuilder.ToStatement());

                    // Print out some information for each CMS metadata value.
                    if (page.results != null)
                    {
                        totalResultSetSize = page.totalResultSetSize;
                        int i = page.startIndex;
                        foreach (CmsMetadataValue cmsMetadataValue in page.results)
                        {
                            Console.WriteLine(
                                "{0}) CMS metadata value with ID {1} and name \"{2}\" associated "
                                + " with key ID {3} and name {4} was found.",
                                i++,
                                cmsMetadataValue.cmsMetadataValueId,
                                cmsMetadataValue.valueName,
                                cmsMetadataValue.key.id,
                                cmsMetadataValue.key.name);
                        }
                    }

                    statementBuilder.IncreaseOffsetBy(pageSize);
                } while (statementBuilder.GetOffset() < totalResultSetSize);

                Console.WriteLine("Number of results found: {0}", totalResultSetSize);
            }
        }
        /// <summary>
        /// Run the code example.
        /// </summary>
        public void Run(AdManagerUser user)
        {
            using (CmsMetadataService cmsMetadataService = user.GetService <CmsMetadataService>())
            {
                // Create a statement to select CMS metadata keys.
                int pageSize = StatementBuilder.SUGGESTED_PAGE_LIMIT;
                StatementBuilder statementBuilder =
                    new StatementBuilder().OrderBy("id ASC").Limit(pageSize);

                // Retrieve a small amount of CMS metadata keys at a time, paging through until all
                // CMS metadata keys have been retrieved.
                int totalResultSetSize = 0;
                do
                {
                    CmsMetadataKeyPage page = cmsMetadataService.getCmsMetadataKeysByStatement(
                        statementBuilder.ToStatement());

                    // Print out some information for each CMS metadata key.
                    if (page.results != null)
                    {
                        totalResultSetSize = page.totalResultSetSize;
                        int i = page.startIndex;
                        foreach (CmsMetadataKey cmsMetadataKey in page.results)
                        {
                            Console.WriteLine(
                                "{0}) CMS metadata key with ID {1} and name \"{2}\" was found.",
                                i++, cmsMetadataKey.id, cmsMetadataKey.name);
                        }
                    }

                    statementBuilder.IncreaseOffsetBy(pageSize);
                } while (statementBuilder.GetOffset() < totalResultSetSize);

                Console.WriteLine("Number of results found: {0}", totalResultSetSize);
            }
        }
        /// <summary>
        /// Run the code example.
        /// </summary>
        public void Run(AdManagerUser user, long cmsMetadataKeyId)
        {
            using (CmsMetadataService cmsMetadataService = user.GetService <CmsMetadataService>())
            {
                // Create a statement to select CMS metadata values.
                int pageSize = StatementBuilder.SUGGESTED_PAGE_LIMIT;
                StatementBuilder statementBuilder = new StatementBuilder()
                                                    .Where("cmsKeyId = :cmsMetadataKeyId and status = :status")
                                                    .OrderBy("id ASC")
                                                    .Limit(pageSize)
                                                    .AddValue("cmsMetadataKeyId", cmsMetadataKeyId)
                                                    .AddValue("status", CmsMetadataValueStatus.INACTIVE.ToString());

                // Retrieve a small amount of CMS metadata values at a time, paging through until
                // all CMS metadata values have been retrieved.
                int totalResultSetSize = 0;

                do
                {
                    CmsMetadataValuePage page = cmsMetadataService.getCmsMetadataValuesByStatement(
                        statementBuilder.ToStatement());

                    if (page.results != null)
                    {
                        totalResultSetSize = page.totalResultSetSize;
                        int i = page.startIndex;
                        foreach (CmsMetadataValue cmsMetadataValue in page.results)
                        {
                            Console.WriteLine(
                                "{0}) CMS metadata value with ID {1} will be activated",
                                i++, cmsMetadataValue.cmsMetadataValueId);
                        }
                    }

                    statementBuilder.IncreaseOffsetBy(pageSize);
                } while (statementBuilder.GetOffset() < totalResultSetSize);

                Console.WriteLine("Number of CMS metadata values to be activated: {0}",
                                  totalResultSetSize);

                if (totalResultSetSize > 0)
                {
                    // Modify statement.
                    statementBuilder.RemoveLimitAndOffset();

                    // Create action.
                    Google.Api.Ads.AdManager.v202011.ActivateCmsMetadataValues action =
                        new Google.Api.Ads.AdManager.v202011.ActivateCmsMetadataValues();

                    // Perform action.
                    UpdateResult result = cmsMetadataService.performCmsMetadataValueAction(action,
                                                                                           statementBuilder.ToStatement());

                    // Display results.
                    if (result != null && result.numChanges > 0)
                    {
                        Console.WriteLine("Number of CMS metadata values activated: {0}",
                                          result.numChanges);
                    }
                    else
                    {
                        Console.WriteLine("No CMS metadata values were activated.");
                    }
                }
            }
        }