/// <summary> /// Create content /// </summary> /// <param name="confluenceClient">IContentDomain to bind the extension method to</param> /// <param name="contentType">Type of content, usually page</param> /// <param name="title">Title for the content</param> /// <param name="spaceKey">Key of the space to add the content to</param> /// <param name="body">Body</param> /// <param name="ancestorId">Optional ID for the ancestor (parent)</param> /// <param name="cancellationToken">CancellationToken</param> /// <returns>Content</returns> public static Task <Content> CreateAsync(this IContentDomain confluenceClient, ContentTypes contentType, string title, string spaceKey, Body body, long?ancestorId = null, CancellationToken cancellationToken = default) { if (string.IsNullOrEmpty(title)) { throw new ArgumentNullException(nameof(title)); } if (string.IsNullOrEmpty(spaceKey)) { throw new ArgumentNullException(nameof(spaceKey)); } if (body == null) { throw new ArgumentNullException(nameof(body)); } var content = new Content { Type = contentType, Title = title, Space = new Space { Key = spaceKey }, Body = body, Ancestors = !ancestorId.HasValue ? null : new List <Content> { new Content { Id = ancestorId.Value } } }; return(confluenceClient.CreateAsync(content, cancellationToken)); }
/// <summary> /// Create content /// </summary> /// <param name="confluenceClient">IContentDomain to bind the extension method to</param> /// <param name="contentType">Type of content, usually page</param> /// <param name="title">Title for the content</param> /// <param name="spaceKey">Key of the space to add the content to</param> /// <param name="body">the complete body (HTML)</param> /// <param name="ancestorId">Optional ID for the ancestor (parent)</param> /// <param name="cancellationToken">CancellationToken</param> /// <returns>Content</returns> public static Task <Content> CreateAsync(this IContentDomain confluenceClient, ContentTypes contentType, string title, string spaceKey, string body, long?ancestorId = null, CancellationToken cancellationToken = default) { if (string.IsNullOrEmpty(title)) { throw new ArgumentNullException(nameof(title)); } if (string.IsNullOrEmpty(spaceKey)) { throw new ArgumentNullException(nameof(spaceKey)); } if (string.IsNullOrEmpty(body)) { throw new ArgumentNullException(nameof(body)); } var contentBody = new Body { Storage = new BodyContent { Value = body, Representation = "storage" } }; return(confluenceClient.CreateAsync(contentType, title, spaceKey, contentBody, ancestorId, cancellationToken)); }
/// <summary> /// Create content /// </summary> /// <param name="confluenceClient">IContentDomain to bind the extension method to</param> /// <param name="contentType">Type of content, usually page</param> /// <param name="title">Title for the content</param> /// <param name="spaceKey">Key of the space to add the content to</param> /// <param name="body">the complete body (HTML)</param> /// <param name="ancestorId">Optional ID for the ancestor (parent)</param> /// <param name="cancellationToken">CancellationToken</param> /// <returns>Content</returns> public static Task <Content> CreateAsync(this IContentDomain confluenceClient, ContentTypes contentType, string title, string spaceKey, string body, long?ancestorId = null, CancellationToken cancellationToken = default) { var contentBody = new Body { Storage = new BodyContent { Value = body, Representation = "storage" } }; return(confluenceClient.CreateAsync(contentType, title, spaceKey, contentBody, ancestorId, cancellationToken)); }
/// <summary> /// Create content /// </summary> /// <param name="confluenceClient">IContentDomain to bind the extension method to</param> /// <param name="contentType">Type of content, usually page</param> /// <param name="title">Title for the content</param> /// <param name="spaceKey">Key of the space to add the content to</param> /// <param name="body">Body</param> /// <param name="ancestorId">Optional ID for the ancestor (parent)</param> /// <param name="cancellationToken">CancellationToken</param> /// <returns>Content</returns> public static Task <Content> CreateAsync(this IContentDomain confluenceClient, ContentTypes contentType, string title, string spaceKey, Body body, long?ancestorId = null, CancellationToken cancellationToken = default) { var content = new Content { Type = contentType, Title = title, Space = new Space { Key = spaceKey }, Body = body, Ancestors = !ancestorId.HasValue ? null : new List <Content> { new Content { Id = ancestorId.Value } } }; return(confluenceClient.CreateAsync(content, cancellationToken)); }