/// <summary> /// Run the code example. /// </summary> /// <param name="user">The DFP user object running the code example.</param> public override void Run(DfpUser user) { // Get the ContentMetadataKeyHierarchy service. ContentMetadataKeyHierarchyService contentMetadataKeyHierarchyService = (ContentMetadataKeyHierarchyService)user.GetService( DfpService.v201511.ContentMetadataKeyHierarchyService); // Set the ID of the content metadata key hierarchy to delete. long contentMetadataKeyHierarchyId = long.Parse(_T("INSERT_CONTENT_METADATA_KEY_HIERARCHY_ID_HERE")); // Create a statement to select a content metadata key hierarchy. StatementBuilder statementBuilder = new StatementBuilder() .Where("WHERE id = :id") .OrderBy("id ASC") .Limit(1) .AddValue("id", contentMetadataKeyHierarchyId); try { // Get content metadata key hierarchies by statement. ContentMetadataKeyHierarchyPage page = contentMetadataKeyHierarchyService .getContentMetadataKeyHierarchiesByStatement(statementBuilder.ToStatement()); ContentMetadataKeyHierarchy contentMetadataKeyHierarchy = page.results[0]; Console.WriteLine("Content metadata key hierarchy with ID \"{0}\" will be deleted.", contentMetadataKeyHierarchy.id); statementBuilder.RemoveLimitAndOffset(); // Create action. Google.Api.Ads.Dfp.v201511.DeleteContentMetadataKeyHierarchies action = new Google.Api.Ads.Dfp.v201511.DeleteContentMetadataKeyHierarchies(); // Perform action. UpdateResult result = contentMetadataKeyHierarchyService .performContentMetadataKeyHierarchyAction(action, statementBuilder.ToStatement()); Console.WriteLine("Number of content metadata key hierarchies deleted: {0}", result.numChanges); } catch (Exception e) { Console.WriteLine("Failed to delete content metadata key hierarchies. " + "Exception says \"{0}\"", e.Message); } }
/// <summary> /// Run the code example. /// </summary> /// <param name="user">The DFP user object running the code example.</param> public override void Run(DfpUser user) { // Get the ContentMetadataKeyHierarchy service. ContentMetadataKeyHierarchyService contentMetadataKeyHierarchyService = (ContentMetadataKeyHierarchyService) user.GetService( DfpService.v201511.ContentMetadataKeyHierarchyService); // Set the ID of the content metadata key hierarchy to delete. long contentMetadataKeyHierarchyId = long.Parse(_T("INSERT_CONTENT_METADATA_KEY_HIERARCHY_ID_HERE")); // Create a statement to select a content metadata key hierarchy. StatementBuilder statementBuilder = new StatementBuilder() .Where("WHERE id = :id") .OrderBy("id ASC") .Limit(1) .AddValue("id", contentMetadataKeyHierarchyId); try { // Get content metadata key hierarchies by statement. ContentMetadataKeyHierarchyPage page = contentMetadataKeyHierarchyService .getContentMetadataKeyHierarchiesByStatement(statementBuilder.ToStatement()); ContentMetadataKeyHierarchy contentMetadataKeyHierarchy = page.results[0]; Console.WriteLine("Content metadata key hierarchy with ID \"{0}\" will be deleted.", contentMetadataKeyHierarchy.id); statementBuilder.RemoveLimitAndOffset(); // Create action. Google.Api.Ads.Dfp.v201511.DeleteContentMetadataKeyHierarchies action = new Google.Api.Ads.Dfp.v201511.DeleteContentMetadataKeyHierarchies(); // Perform action. UpdateResult result = contentMetadataKeyHierarchyService .performContentMetadataKeyHierarchyAction(action, statementBuilder.ToStatement()); Console.WriteLine("Number of content metadata key hierarchies deleted: {0}", result.numChanges); } catch (Exception e) { Console.WriteLine("Failed to delete content metadata key hierarchies. " + "Exception says \"{0}\"", e.Message); } }