Skip to content

Commit

Permalink
Added last-updated information for the history.
Browse files Browse the repository at this point in the history
[release]
  • Loading branch information
Lakritzator committed Jul 26, 2016
1 parent 7ac43f0 commit 00a416d
Show file tree
Hide file tree
Showing 31 changed files with 852 additions and 643 deletions.
36 changes: 20 additions & 16 deletions Dapplo.Confluence.PCL/Properties/AssemblyInfo.cs
@@ -1,25 +1,29 @@
// Dapplo - building blocks for desktop applications
// Copyright (C) 2015-2016 Dapplo
#region Dapplo 2016 - GNU Lesser General Public License

// Dapplo - building blocks for .NET applications
// Copyright (C) 2016 Dapplo
//
// For more information see: http://dapplo.net/
// Dapplo repositories are hosted on GitHub: https://github.com/dapplo
// For more information see: http://dapplo.net/
// Dapplo repositories are hosted on GitHub: https://github.com/dapplo
//
// This file is part of Dapplo.Confluence
// This file is part of Dapplo.Confluence
//
// Dapplo.Confluence is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Dapplo.Confluence is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Dapplo.Confluence is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
// Dapplo.Confluence is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have a copy of the GNU Lesser General Public License
// along with Dapplo.Confluence. If not, see <http://www.gnu.org/licenses/lgpl.txt>.
// You should have a copy of the GNU Lesser General Public License
// along with Dapplo.Confluence. If not, see <http://www.gnu.org/licenses/lgpl.txt>.

#endregion

#region using
#region Usings

using System.Reflection;
using System.Resources;
Expand Down
121 changes: 67 additions & 54 deletions Dapplo.Confluence.Shared/ConfluenceApi.cs
@@ -1,25 +1,29 @@
// Dapplo - building blocks for desktop applications
// Copyright (C) 2015-2016 Dapplo
#region Dapplo 2016 - GNU Lesser General Public License

// Dapplo - building blocks for .NET applications
// Copyright (C) 2016 Dapplo
//
// For more information see: http://dapplo.net/
// Dapplo repositories are hosted on GitHub: https://github.com/dapplo
// For more information see: http://dapplo.net/
// Dapplo repositories are hosted on GitHub: https://github.com/dapplo
//
// This file is part of Dapplo.Confluence
// This file is part of Dapplo.Confluence
//
// Dapplo.Confluence is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Dapplo.Confluence is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Dapplo.Confluence is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
// Dapplo.Confluence is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have a copy of the GNU Lesser General Public License
// along with Dapplo.Confluence. If not, see <http://www.gnu.org/licenses/lgpl.txt>.
// You should have a copy of the GNU Lesser General Public License
// along with Dapplo.Confluence. If not, see <http://www.gnu.org/licenses/lgpl.txt>.

#endregion

#region using
#region Usings

using System;
using System.Collections.Generic;
Expand Down Expand Up @@ -77,6 +81,33 @@ public ConfluenceApi(Uri baseUri, IHttpSettings httpSettings = null)
};
}

#region Read

/// <summary>
/// Retrieve the picture for the supplied Picture entity
/// </summary>
/// <typeparam name="TResponse">the type to return the result into. e.g. Bitmap,BitmapSource or MemoryStream</typeparam>
/// <param name="picture">Picture from User, Space, History etc</param>
/// <param name="cancellationToken">CancellationToken</param>
/// <returns>Bitmap,BitmapSource or MemoryStream (etc) depending on TResponse</returns>
public async Task<TResponse> GetPictureAsync<TResponse>(Picture picture, CancellationToken cancellationToken = default(CancellationToken))
where TResponse : class
{
PromoteContext();
var pictureUriBuilder = new UriBuilder(ConfluenceApiBaseUri)
{
Path = picture.Path
};
var response = await pictureUriBuilder.Uri.GetAsAsync<HttpResponse<TResponse, string>>(cancellationToken).ConfigureAwait(false);
if (response.HasError)
{
throw new Exception(response.ErrorResponse);
}
return response.Response;
}

#endregion

#region Supporting

/// <summary>
Expand Down Expand Up @@ -167,14 +198,17 @@ public async Task<Result<Attachment>> GetAttachmentsAsync(string contentId, Canc
}

/// <summary>
/// Delete attachment
/// Can't work yet, see <a href="https://jira.atlassian.com/browse/CONF-36015">CONF-36015</a>
/// Delete attachment
/// Can't work yet, see <a href="https://jira.atlassian.com/browse/CONF-36015">CONF-36015</a>
/// </summary>
/// <param name="attachment">Attachment which needs to be deleted</param>
/// <param name="cancellationToken">cancellationToken</param>
public async Task DeleteAttachmentAsync(Attachment attachment, CancellationToken cancellationToken = default(CancellationToken))
{
var contentUri = ConfluenceDownloadBaseUri.AppendSegments("json","removeattachmentversion.action").ExtendQuery("pageId",attachment.Container.Id).ExtendQuery("fileName",attachment.Title);
var contentUri =
ConfluenceDownloadBaseUri.AppendSegments("json", "removeattachmentversion.action")
.ExtendQuery("pageId", attachment.Container.Id)
.ExtendQuery("fileName", attachment.Title);
PromoteContext();

await contentUri.GetAsAsync<string>(cancellationToken).ConfigureAwait(false);
Expand Down Expand Up @@ -217,7 +251,8 @@ public async Task<TResponse> GetAttachmentContentAsync<TResponse>(Attachment att
/// <param name="isPrivate">true if the space needs to be private</param>
/// <param name="cancellationToken"></param>
/// <returns>created Space</returns>
public async Task<Space> CreateSpaceAsync(string key, string name, string description, bool isPrivate = false, CancellationToken cancellationToken = default(CancellationToken))
public async Task<Space> CreateSpaceAsync(string key, string name, string description, bool isPrivate = false,
CancellationToken cancellationToken = default(CancellationToken))
{
var space = new Space
{
Expand Down Expand Up @@ -339,33 +374,6 @@ public async Task<IList<Space>> GetSpacesAsync(CancellationToken cancellationTok

#endregion

#region Read

/// <summary>
/// Retrieve the picture for the supplied Picture entity
/// </summary>
/// <typeparam name="TResponse">the type to return the result into. e.g. Bitmap,BitmapSource or MemoryStream</typeparam>
/// <param name="picture">Picture from User, Space, History etc</param>
/// <param name="cancellationToken">CancellationToken</param>
/// <returns>Bitmap,BitmapSource or MemoryStream (etc) depending on TResponse</returns>
public async Task<TResponse> GetPictureAsync<TResponse>(Picture picture, CancellationToken cancellationToken = default(CancellationToken))
where TResponse : class
{
PromoteContext();
var pictureUriBuilder = new UriBuilder(ConfluenceApiBaseUri)
{
Path = picture.Path
};
var response = await pictureUriBuilder.Uri.GetAsAsync<HttpResponse<TResponse, string>>(cancellationToken).ConfigureAwait(false);
if (response.HasError)
{
throw new Exception(response.ErrorResponse);
}
return response.Response;
}

#endregion

#region Content

/// <summary>
Expand Down Expand Up @@ -400,7 +408,7 @@ public async Task<Content> GetContentAsync(string contentId, CancellationToken c
public async Task<History> GetContentHistoryAsync(string contentId, CancellationToken cancellationToken = default(CancellationToken))
{
var historyUri = ConfluenceApiBaseUri.AppendSegments("content", contentId, "history");

PromoteContext();

var response = await historyUri.GetAsAsync<HttpResponse<History, Error>>(cancellationToken).ConfigureAwait(false);
Expand All @@ -412,10 +420,13 @@ public async Task<History> GetContentHistoryAsync(string contentId, Cancellation
}

/// <summary>
/// Delete content (attachments are also content)
/// Delete content (attachments are also content)
/// </summary>
/// <param name="contentId">ID for the content which needs to be deleted</param>
/// <param name="isTrashed">If the content is trashable, you will need to call DeleteAsyc twice, second time with isTrashed = true</param>
/// <param name="isTrashed">
/// If the content is trashable, you will need to call DeleteAsyc twice, second time with isTrashed
/// = true
/// </param>
/// <param name="cancellationToken">cancellationToken</param>
public async Task DeleteContentAsync(string contentId, bool isTrashed = false, CancellationToken cancellationToken = default(CancellationToken))
{
Expand All @@ -434,7 +445,7 @@ public async Task DeleteContentAsync(string contentId, bool isTrashed = false, C
}

/// <summary>
/// Create content
/// Create content
/// </summary>
/// <param name="type">Type of content, usually page</param>
/// <param name="title">Title for the content</param>
Expand Down Expand Up @@ -464,7 +475,7 @@ public async Task<Content> CreateContentAsync(string type, string title, string
}
};
PromoteContext();
var response = await contentUri.PostAsync<HttpResponse<Content, Error>>(newPage,cancellationToken).ConfigureAwait(false);
var response = await contentUri.PostAsync<HttpResponse<Content, Error>>(newPage, cancellationToken).ConfigureAwait(false);
if (response.HasError)
{
throw new Exception(response.ErrorResponse.Message);
Expand Down Expand Up @@ -539,7 +550,8 @@ public async Task<Result<Content>> SearchAsync(string cql, string cqlContext = n
/// <param name="limit">Maximum number of results returned, default is 20</param>
/// <param name="cancellationToken">CancellationToken</param>
/// <returns>Results with content items</returns>
public async Task<Result<Content>> GetContentByTitleAsync(string spaceKey, string title, int start = 0, int limit = 20, CancellationToken cancellationToken = default(CancellationToken))
public async Task<Result<Content>> GetContentByTitleAsync(string spaceKey, string title, int start = 0, int limit = 20,
CancellationToken cancellationToken = default(CancellationToken))
{
PromoteContext();
var searchUri = ConfluenceApiBaseUri.AppendSegments("content").ExtendQuery(new Dictionary<string, object>
Expand Down Expand Up @@ -575,6 +587,7 @@ public async Task<Result<Content>> GetContentByTitleAsync(string spaceKey, strin
#endregion

#region User

/// <summary>
/// Get currrent user information, introduced with 6.6
/// See: https://docs.atlassian.com/confluence/REST/latest/#user-getCurrent
Expand Down Expand Up @@ -631,7 +644,7 @@ public async Task<User> GetUserAsync(string username, CancellationToken cancella
}

/// <summary>
/// Get the groups for a user
/// Get the groups for a user
/// </summary>
/// <param name="username">string with username</param>
/// <param name="cancellationToken">CancellationToken</param>
Expand Down
40 changes: 22 additions & 18 deletions Dapplo.Confluence.Shared/ConfluenceConfig.cs
@@ -1,23 +1,27 @@
// Dapplo - building blocks for desktop applications
// Copyright (C) 2015-2016 Dapplo
#region Dapplo 2016 - GNU Lesser General Public License

// Dapplo - building blocks for .NET applications
// Copyright (C) 2016 Dapplo
//
// For more information see: http://dapplo.net/
// Dapplo repositories are hosted on GitHub: https://github.com/dapplo
// For more information see: http://dapplo.net/
// Dapplo repositories are hosted on GitHub: https://github.com/dapplo
//
// This file is part of Dapplo.Confluence
// This file is part of Dapplo.Confluence
//
// Dapplo.Confluence is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Dapplo.Confluence is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Dapplo.Confluence is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
// Dapplo.Confluence is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have a copy of the GNU Lesser General Public License
// along with Dapplo.Confluence. If not, see <http://www.gnu.org/licenses/lgpl.txt>.
// You should have a copy of the GNU Lesser General Public License
// along with Dapplo.Confluence. If not, see <http://www.gnu.org/licenses/lgpl.txt>.

#endregion

namespace Dapplo.Confluence
{
Expand All @@ -39,7 +43,7 @@ public static class ConfluenceConfig
/// <summary>
/// The values that are expanded in the GetContent result
/// </summary>
public static string[] ExpandGetContent { get; set; } = {"body","body.view", "version"};
public static string[] ExpandGetContent { get; set; } = {"body", "body.view", "version"};

/// <summary>
/// The values that are expanded in the GetContentByTitle results
Expand All @@ -49,13 +53,13 @@ public static class ConfluenceConfig
/// <summary>
/// The values that are expanded in the GetSpace result
/// </summary>
public static string[] ExpandGetSpace { get; set; } = { "icon", "description.plain", "homepage" };
public static string[] ExpandGetSpace { get; set; } = {"icon", "description.plain", "homepage"};


/// <summary>
/// The values that are expanded in the GetSpaces results
/// </summary>
public static string[] ExpandGetSpaces { get; set; } = { "icon", "description.plain", "homepage" };
public static string[] ExpandGetSpaces { get; set; } = {"icon", "description.plain", "homepage"};

/// <summary>
/// The values that are expanded in the Search results
Expand Down
Expand Up @@ -13,6 +13,7 @@
<Compile Include="$(MSBuildThisFileDirectory)ConfluenceConfig.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Entities\Child.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Entities\Group.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Entities\LastUpdated.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Entities\Plain.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Entities\Error.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Entities\Description.cs" />
Expand Down

0 comments on commit 00a416d

Please sign in to comment.