/// <summary>Snippet for ListFeeds</summary>
 public void ListFeedsRequestObject()
 {
     // Snippet: ListFeeds(ListFeedsRequest, CallSettings)
     // Create client
     AssetServiceClient assetServiceClient = AssetServiceClient.Create();
     // Initialize request argument(s)
     ListFeedsRequest request = new ListFeedsRequest { Parent = "", };
     // Make the request
     ListFeedsResponse response = assetServiceClient.ListFeeds(request);
     // End snippet
 }
Esempio n. 2
0
 /// <summary>Snippet for GetFeed</summary>
 public void GetFeed()
 {
     // Snippet: GetFeed(string,CallSettings)
     // Create client
     AssetServiceClient assetServiceClient = AssetServiceClient.Create();
     // Initialize request argument(s)
     string formattedName = new FeedName("[PROJECT]", "[FEED]").ToString();
     // Make the request
     Feed response = assetServiceClient.GetFeed(formattedName);
     // End snippet
 }
Esempio n. 3
0
 /// <summary>Snippet for CreateFeed</summary>
 public void CreateFeed()
 {
     // Snippet: CreateFeed(string, CallSettings)
     // Create client
     AssetServiceClient assetServiceClient = AssetServiceClient.Create();
     // Initialize request argument(s)
     string parent = "";
     // Make the request
     Feed response = assetServiceClient.CreateFeed(parent);
     // End snippet
 }
Esempio n. 4
0
 /// <summary>Snippet for BatchGetAssetsHistory</summary>
 public void BatchGetAssetsHistory()
 {
     // Snippet: BatchGetAssetsHistory(string,CallSettings)
     // Create client
     AssetServiceClient assetServiceClient = AssetServiceClient.Create();
     // Initialize request argument(s)
     string formattedParent = new Google.Api.Gax.ResourceNames.ProjectName("[PROJECT]").ToString();
     // Make the request
     BatchGetAssetsHistoryResponse response = assetServiceClient.BatchGetAssetsHistory(formattedParent);
     // End snippet
 }
        // [END add_smart_display_ad_4]

        /// <summary>
        /// Uploads the image asset.
        /// </summary>
        /// <param name="client">The Google Ads client.</param>
        /// <param name="customerId">The Google Ads customer ID for which the call is made.</param>
        /// <param name="imageUrl">The image URL.</param>
        /// <param name="width">The image width in pixels.</param>
        /// <param name="height">The image height in pixels.</param>
        /// <param name="imageName">Name of the image asset.</param>
        /// <returns>The resource name of the asset.</returns>
        // [START add_smart_display_ad_3]
        private static string UploadImageAsset(GoogleAdsClient client, long customerId,
                                               string imageUrl, long width, long height, string imageName)
        {
            // Get the AssetServiceClient.
            AssetServiceClient assetService =
                client.GetService(Services.V10.AssetService);

            // Creates an image content.
            byte[] imageContent = MediaUtilities.GetAssetDataFromUrl(imageUrl, client.Config);

            // Creates an image asset.
            ImageAsset imageAsset = new ImageAsset()
            {
                Data     = ByteString.CopyFrom(imageContent),
                FileSize = imageContent.Length,
                MimeType = MimeType.ImageJpeg,
                FullSize = new ImageDimension()
                {
                    HeightPixels = height,
                    WidthPixels  = width,
                    Url          = imageUrl
                }
            };

            // Creates an asset.
            Asset asset = new Asset()
            {
                // Optional: Provide a unique friendly name to identify your asset.
                // If you specify the name field, then both the asset name and the image being
                // uploaded should be unique, and should not match another ACTIVE asset in this
                // customer account.
                // Name = 'Jupiter Trip #' + ExampleUtilities.GetRandomString(),
                Type       = AssetType.Image,
                ImageAsset = imageAsset,
                Name       = imageName
            };

            // Creates an asset operation.
            AssetOperation operation = new AssetOperation()
            {
                Create = asset
            };

            // Issues a mutate request to add the asset.
            MutateAssetsResponse response =
                assetService.MutateAssets(customerId.ToString(), new[] { operation });

            string assetResourceName = response.Results.First().ResourceName;

            // Print out some information about the added asset.
            Console.WriteLine($"Added asset with resource name = '{assetResourceName}'.");

            return(assetResourceName);
        }
Esempio n. 6
0
 /// <summary>Snippet for GetAsset</summary>
 public void GetAsset()
 {
     // Snippet: GetAsset(string, CallSettings)
     // Create client
     AssetServiceClient assetServiceClient = AssetServiceClient.Create();
     // Initialize request argument(s)
     string resourceName = "customers/[CUSTOMER_ID]/assets/[ASSET_ID]";
     // Make the request
     Asset response = assetServiceClient.GetAsset(resourceName);
     // End snippet
 }
Esempio n. 7
0
 /// <summary>Snippet for GetAsset</summary>
 public void GetAssetResourceNames()
 {
     // Snippet: GetAsset(AssetName, CallSettings)
     // Create client
     AssetServiceClient assetServiceClient = AssetServiceClient.Create();
     // Initialize request argument(s)
     AssetName resourceName = AssetName.FromCustomerAsset("[CUSTOMER_ID]", "[ASSET_ID]");
     // Make the request
     Asset response = assetServiceClient.GetAsset(resourceName);
     // End snippet
 }
 /// <summary>Snippet for UpdateFeed</summary>
 public void UpdateFeed()
 {
     // Snippet: UpdateFeed(Feed, CallSettings)
     // Create client
     AssetServiceClient assetServiceClient = AssetServiceClient.Create();
     // Initialize request argument(s)
     Feed feed = new Feed();
     // Make the request
     Feed response = assetServiceClient.UpdateFeed(feed);
     // End snippet
 }
Esempio n. 9
0
 /// <summary>Snippet for GetFeed</summary>
 public void GetFeed()
 {
     // Snippet: GetFeed(string, CallSettings)
     // Create client
     AssetServiceClient assetServiceClient = AssetServiceClient.Create();
     // Initialize request argument(s)
     string name = "projects/[PROJECT]/feeds/[FEED]";
     // Make the request
     Feed response = assetServiceClient.GetFeed(name);
     // End snippet
 }
Esempio n. 10
0
 /// <summary>Snippet for GetFeed</summary>
 public void GetFeedResourceNames()
 {
     // Snippet: GetFeed(FeedName, CallSettings)
     // Create client
     AssetServiceClient assetServiceClient = AssetServiceClient.Create();
     // Initialize request argument(s)
     FeedName name = FeedName.FromProjectFeed("[PROJECT]", "[FEED]");
     // Make the request
     Feed response = assetServiceClient.GetFeed(name);
     // End snippet
 }
 /// <summary>Snippet for GetFeed</summary>
 /// <remarks>
 /// This snippet has been automatically generated for illustrative purposes only.
 /// It may require modifications to work in your environment.
 /// </remarks>
 public void GetFeedRequestObject()
 {
     // Create client
     AssetServiceClient assetServiceClient = AssetServiceClient.Create();
     // Initialize request argument(s)
     GetFeedRequest request = new GetFeedRequest
     {
         FeedName = FeedName.FromProjectFeed("[PROJECT]", "[FEED]"),
     };
     // Make the request
     Feed response = assetServiceClient.GetFeed(request);
 }
        /// <summary>Snippet for ListFeedsAsync</summary>
        /// <remarks>
        /// This snippet has been automatically generated for illustrative purposes only.
        /// It may require modifications to work in your environment.
        /// </remarks>
        public async Task ListFeedsRequestObjectAsync()
        {
            // Create client
            AssetServiceClient assetServiceClient = await AssetServiceClient.CreateAsync();

            // Initialize request argument(s)
            ListFeedsRequest request = new ListFeedsRequest {
                Parent = "",
            };
            // Make the request
            ListFeedsResponse response = await assetServiceClient.ListFeedsAsync(request);
        }
 /// <summary>Snippet for DeleteFeedAsync</summary>
 public async Task DeleteFeedResourceNamesAsync()
 {
     // Snippet: DeleteFeedAsync(FeedName, CallSettings)
     // Additional: DeleteFeedAsync(FeedName, CancellationToken)
     // Create client
     AssetServiceClient assetServiceClient = await AssetServiceClient.CreateAsync();
     // Initialize request argument(s)
     FeedName name = FeedName.FromProjectFeed("[PROJECT]", "[FEED]");
     // Make the request
     await assetServiceClient.DeleteFeedAsync(name);
     // End snippet
 }
 /// <summary>Snippet for DeleteFeedAsync</summary>
 public async Task DeleteFeedAsync()
 {
     // Snippet: DeleteFeedAsync(string, CallSettings)
     // Additional: DeleteFeedAsync(string, CancellationToken)
     // Create client
     AssetServiceClient assetServiceClient = await AssetServiceClient.CreateAsync();
     // Initialize request argument(s)
     string name = "projects/[PROJECT]/feeds/[FEED]";
     // Make the request
     await assetServiceClient.DeleteFeedAsync(name);
     // End snippet
 }
 /// <summary>Snippet for UpdateFeedAsync</summary>
 public async Task UpdateFeedAsync()
 {
     // Snippet: UpdateFeedAsync(Feed, CallSettings)
     // Additional: UpdateFeedAsync(Feed, CancellationToken)
     // Create client
     AssetServiceClient assetServiceClient = await AssetServiceClient.CreateAsync();
     // Initialize request argument(s)
     Feed feed = new Feed();
     // Make the request
     Feed response = await assetServiceClient.UpdateFeedAsync(feed);
     // End snippet
 }
 /// <summary>Snippet for ListFeedsAsync</summary>
 public async Task ListFeedsRequestObjectAsync()
 {
     // Snippet: ListFeedsAsync(ListFeedsRequest, CallSettings)
     // Additional: ListFeedsAsync(ListFeedsRequest, CancellationToken)
     // Create client
     AssetServiceClient assetServiceClient = await AssetServiceClient.CreateAsync();
     // Initialize request argument(s)
     ListFeedsRequest request = new ListFeedsRequest { Parent = "", };
     // Make the request
     ListFeedsResponse response = await assetServiceClient.ListFeedsAsync(request);
     // End snippet
 }
 /// <summary>Snippet for GetAsset</summary>
 /// <remarks>
 /// This snippet has been automatically generated for illustrative purposes only.
 /// It may require modifications to work in your environment.
 /// </remarks>
 public void GetAssetRequestObject()
 {
     // Create client
     AssetServiceClient assetServiceClient = AssetServiceClient.Create();
     // Initialize request argument(s)
     GetAssetRequest request = new GetAssetRequest
     {
         ResourceNameAsAssetName = AssetName.FromCustomerAsset("[CUSTOMER_ID]", "[ASSET_ID]"),
     };
     // Make the request
     Asset response = assetServiceClient.GetAsset(request);
 }
 /// <summary>Snippet for ListFeedsAsync</summary>
 public async Task ListFeedsAsync()
 {
     // Snippet: ListFeedsAsync(string, CallSettings)
     // Additional: ListFeedsAsync(string, CancellationToken)
     // Create client
     AssetServiceClient assetServiceClient = await AssetServiceClient.CreateAsync();
     // Initialize request argument(s)
     string parent = "";
     // Make the request
     ListFeedsResponse response = await assetServiceClient.ListFeedsAsync(parent);
     // End snippet
 }
        /// <summary>Snippet for GetAssetAsync</summary>
        /// <remarks>
        /// This snippet has been automatically generated for illustrative purposes only.
        /// It may require modifications to work in your environment.
        /// </remarks>
        public async Task GetAssetRequestObjectAsync()
        {
            // Create client
            AssetServiceClient assetServiceClient = await AssetServiceClient.CreateAsync();

            // Initialize request argument(s)
            GetAssetRequest request = new GetAssetRequest
            {
                ResourceNameAsAssetName = AssetName.FromCustomerAsset("[CUSTOMER]", "[ASSET]"),
            };
            // Make the request
            Asset response = await assetServiceClient.GetAssetAsync(request);
        }
 /// <summary>Snippet for AnalyzeIamPolicy</summary>
 /// <remarks>
 /// This snippet has been automatically generated for illustrative purposes only.
 /// It may require modifications to work in your environment.
 /// </remarks>
 public void AnalyzeIamPolicyRequestObject()
 {
     // Create client
     AssetServiceClient assetServiceClient = AssetServiceClient.Create();
     // Initialize request argument(s)
     AnalyzeIamPolicyRequest request = new AnalyzeIamPolicyRequest
     {
         AnalysisQuery    = new IamPolicyAnalysisQuery(),
         ExecutionTimeout = new Duration(),
     };
     // Make the request
     AnalyzeIamPolicyResponse response = assetServiceClient.AnalyzeIamPolicy(request);
 }
 /// <summary>Snippet for MutateAssets</summary>
 /// <remarks>
 /// This snippet has been automatically generated for illustrative purposes only.
 /// It may require modifications to work in your environment.
 /// </remarks>
 public void MutateAssets()
 {
     // Create client
     AssetServiceClient assetServiceClient = AssetServiceClient.Create();
     // Initialize request argument(s)
     string customerId = "";
     IEnumerable <AssetOperation> operations = new AssetOperation[]
     {
         new AssetOperation(),
     };
     // Make the request
     MutateAssetsResponse response = assetServiceClient.MutateAssets(customerId, operations);
 }
 /// <summary>Snippet for UpdateFeed</summary>
 /// <remarks>
 /// This snippet has been automatically generated for illustrative purposes only.
 /// It may require modifications to work in your environment.
 /// </remarks>
 public void UpdateFeedRequestObject()
 {
     // Create client
     AssetServiceClient assetServiceClient = AssetServiceClient.Create();
     // Initialize request argument(s)
     UpdateFeedRequest request = new UpdateFeedRequest
     {
         Feed       = new Feed(),
         UpdateMask = new FieldMask(),
     };
     // Make the request
     Feed response = assetServiceClient.UpdateFeed(request);
 }
Esempio n. 23
0
        /// <summary>Snippet for DeleteFeedAsync</summary>
        /// <remarks>
        /// This snippet has been automatically generated for illustrative purposes only.
        /// It may require modifications to work in your environment.
        /// </remarks>
        public async Task DeleteFeedRequestObjectAsync()
        {
            // Create client
            AssetServiceClient assetServiceClient = await AssetServiceClient.CreateAsync();

            // Initialize request argument(s)
            DeleteFeedRequest request = new DeleteFeedRequest
            {
                FeedName = FeedName.FromProjectFeed("[PROJECT]", "[FEED]"),
            };
            // Make the request
            await assetServiceClient.DeleteFeedAsync(request);
        }
Esempio n. 24
0
        /// <summary>Snippet for SearchAllResources</summary>
        public async Task SearchAllResourcesRequestObjectAsync()
        {
            // Snippet: SearchAllResourcesAsync(SearchAllResourcesRequest, CallSettings)
            // Create client
            AssetServiceClient assetServiceClient = await AssetServiceClient.CreateAsync();

            // Initialize request argument(s)
            SearchAllResourcesRequest request = new SearchAllResourcesRequest
            {
                Scope      = "",
                Query      = "",
                AssetTypes = { "", },
                OrderBy    = "",
            };
            // Make the request
            PagedAsyncEnumerable <SearchAllResourcesResponse, ResourceSearchResult> response = assetServiceClient.SearchAllResourcesAsync(request);

            // Iterate over all response items, lazily performing RPCs as required
            await response.ForEachAsync((ResourceSearchResult item) =>
            {
                // Do something with each item
                Console.WriteLine(item);
            });

            // Or iterate over pages (of server-defined size), performing one RPC per page
            await response.AsRawResponses().ForEachAsync((SearchAllResourcesResponse page) =>
            {
                // Do something with each page of items
                Console.WriteLine("A page of results:");
                foreach (ResourceSearchResult item in page)
                {
                    // Do something with each item
                    Console.WriteLine(item);
                }
            });

            // Or retrieve a single page of known size (unless it's the final page), performing as many RPCs as required
            int pageSize = 10;
            Page <ResourceSearchResult> singlePage = await response.ReadPageAsync(pageSize);

            // Do something with the page of items
            Console.WriteLine($"A page of {pageSize} results (unless it's the final page):");
            foreach (ResourceSearchResult item in singlePage)
            {
                // Do something with each item
                Console.WriteLine(item);
            }
            // Store the pageToken, for when the next page is required.
            string nextPageToken = singlePage.NextPageToken;
            // End snippet
        }
        // [START add_asset]
        /// <summary>
        /// Creates Assets to be used in a DSA page feed.
        /// </summary>
        /// <param name="client">The Google Ads client.</param>
        /// <param name="customerId">The Google Ads customer ID for which the call is made.</param>
        /// <param name="dsaPageUrlLabel">The DSA page URL label.</param>
        /// <returns>The list of asset resource names.</returns>
        private static List <string> CreateAssets(GoogleAdsClient client, long customerId,
                                                  string dsaPageUrlLabel)
        {
            AssetServiceClient assetService = client.GetService(Services.V10.AssetService);

            string[] urls = new[]
            {
                "http://www.example.com/discounts/rental-cars",
                "http://www.example.com/discounts/hotel-deals",
                "http://www.example.com/discounts/flight-deals"
            };

            // Creates one operation per URL.
            List <AssetOperation> assetOperations = new List <AssetOperation>();

            foreach (string url in urls)
            {
                PageFeedAsset pageFeedAsset = new PageFeedAsset()
                {
                    // Sets the URL of the page to include.
                    PageUrl = url,

                    // Recommended: adds labels to the asset. These labels can be used later in
                    // ad group targeting to restrict the set of pages that can serve.
                    Labels = { dsaPageUrlLabel }
                };

                assetOperations.Add(
                    new AssetOperation()
                {
                    Create = new Asset()
                    {
                        PageFeedAsset = pageFeedAsset
                    }
                });
            }

            // Adds the assets.
            MutateAssetsResponse response =
                assetService.MutateAssets(customerId.ToString(), assetOperations);

            // Prints some information about the result.
            List <string> resourceNames = response.Results.Select(
                assetResult => assetResult.ResourceName).ToList();

            foreach (string resourceName in resourceNames)
            {
                Console.Write($"Created asset with resource name {resourceName}.");
            }
            return(resourceNames);
        }
        /// <summary>Snippet for GetAssetAsync</summary>
        public async Task GetAssetAsync()
        {
            // Snippet: GetAssetAsync(string, CallSettings)
            // Additional: GetAssetAsync(string, CancellationToken)
            // Create client
            AssetServiceClient assetServiceClient = await AssetServiceClient.CreateAsync();

            // Initialize request argument(s)
            string resourceName = "customers/[CUSTOMER]/assets/[ASSET]";
            // Make the request
            Asset response = await assetServiceClient.GetAssetAsync(resourceName);

            // End snippet
        }
        /// <summary>Snippet for GetAssetAsync</summary>
        public async Task GetAssetResourceNamesAsync()
        {
            // Snippet: GetAssetAsync(AssetName, CallSettings)
            // Additional: GetAssetAsync(AssetName, CancellationToken)
            // Create client
            AssetServiceClient assetServiceClient = await AssetServiceClient.CreateAsync();

            // Initialize request argument(s)
            AssetName resourceName = AssetName.FromCustomerAsset("[CUSTOMER]", "[ASSET]");
            // Make the request
            Asset response = await assetServiceClient.GetAssetAsync(resourceName);

            // End snippet
        }
Esempio n. 28
0
        /// <summary>Snippet for DeleteFeedAsync</summary>
        public async Task DeleteFeedAsync()
        {
            // Snippet: DeleteFeedAsync(string,CallSettings)
            // Additional: DeleteFeedAsync(string,CancellationToken)
            // Create client
            AssetServiceClient assetServiceClient = await AssetServiceClient.CreateAsync();

            // Initialize request argument(s)
            string formattedName = new FeedName("[PROJECT]", "[FEED]").ToString();
            // Make the request
            await assetServiceClient.DeleteFeedAsync(formattedName);

            // End snippet
        }
Esempio n. 29
0
 /// <summary>Snippet for GetFeed</summary>
 public void GetFeed_RequestObject()
 {
     // Snippet: GetFeed(GetFeedRequest,CallSettings)
     // Create client
     AssetServiceClient assetServiceClient = AssetServiceClient.Create();
     // Initialize request argument(s)
     GetFeedRequest request = new GetFeedRequest
     {
         Name = new FeedName("[PROJECT]", "[FEED]").ToString(),
     };
     // Make the request
     Feed response = assetServiceClient.GetFeed(request);
     // End snippet
 }
        /// <summary>Snippet for UpdateFeedAsync</summary>
        /// <remarks>
        /// This snippet has been automatically generated for illustrative purposes only.
        /// It may require modifications to work in your environment.
        /// </remarks>
        public async Task UpdateFeedRequestObjectAsync()
        {
            // Create client
            AssetServiceClient assetServiceClient = await AssetServiceClient.CreateAsync();

            // Initialize request argument(s)
            UpdateFeedRequest request = new UpdateFeedRequest
            {
                Feed       = new Feed(),
                UpdateMask = new FieldMask(),
            };
            // Make the request
            Feed response = await assetServiceClient.UpdateFeedAsync(request);
        }