|
|
@ -44,12 +44,24 @@ namespace Squidex.Areas.Api.Controllers.Contents |
|
|
this.graphQl = graphQl; |
|
|
this.graphQl = graphQl; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// GraphQL endpoint.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="app">The name of the app.</param>
|
|
|
|
|
|
/// <param name="query">The graphql endpoint.</param>
|
|
|
|
|
|
/// <returns>
|
|
|
|
|
|
/// 200 => Contents retrieved or mutated.
|
|
|
|
|
|
/// 404 => Schema or app not found.
|
|
|
|
|
|
/// </returns>
|
|
|
|
|
|
/// <remarks>
|
|
|
|
|
|
/// You can read the generated documentation for your app at /api/content/{appName}/docs
|
|
|
|
|
|
/// </remarks>
|
|
|
[MustBeAppReader] |
|
|
[MustBeAppReader] |
|
|
[HttpGet] |
|
|
[HttpGet] |
|
|
[HttpPost] |
|
|
[HttpPost] |
|
|
[Route("content/{app}/graphql/")] |
|
|
[Route("content/{app}/graphql/")] |
|
|
[ApiCosts(2)] |
|
|
[ApiCosts(2)] |
|
|
public async Task<IActionResult> PostGraphQL([FromBody] GraphQLQuery query) |
|
|
public async Task<IActionResult> PostGraphQL(string app, [FromBody] GraphQLQuery query) |
|
|
{ |
|
|
{ |
|
|
var result = await graphQl.QueryAsync(App, User, query); |
|
|
var result = await graphQl.QueryAsync(App, User, query); |
|
|
|
|
|
|
|
|
@ -63,11 +75,25 @@ namespace Squidex.Areas.Api.Controllers.Contents |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Queries contents.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="app">The name of the app.</param>
|
|
|
|
|
|
/// <param name="name">The name of the schema.</param>
|
|
|
|
|
|
/// <param name="ids">The optional ids of the content to fetch.</param>
|
|
|
|
|
|
/// <param name="archived">Indicates whether to query content items from the archive.</param>
|
|
|
|
|
|
/// <returns>
|
|
|
|
|
|
/// 200 => Contents retrieved.
|
|
|
|
|
|
/// 404 => Schema or app not found.
|
|
|
|
|
|
/// </returns>
|
|
|
|
|
|
/// <remarks>
|
|
|
|
|
|
/// You can read the generated documentation for your app at /api/content/{appName}/docs
|
|
|
|
|
|
/// </remarks>
|
|
|
[MustBeAppReader] |
|
|
[MustBeAppReader] |
|
|
[HttpGet] |
|
|
[HttpGet] |
|
|
[Route("content/{app}/{name}/")] |
|
|
[Route("content/{app}/{name}/")] |
|
|
[ApiCosts(2)] |
|
|
[ApiCosts(2)] |
|
|
public async Task<IActionResult> GetContents(string name, [FromQuery] bool archived = false, [FromQuery] string ids = null) |
|
|
public async Task<IActionResult> GetContents(string app, string name, [FromQuery] bool archived = false, [FromQuery] string ids = null) |
|
|
{ |
|
|
{ |
|
|
HashSet<Guid> idsList = null; |
|
|
HashSet<Guid> idsList = null; |
|
|
|
|
|
|
|
|
@ -112,11 +138,24 @@ namespace Squidex.Areas.Api.Controllers.Contents |
|
|
return Ok(response); |
|
|
return Ok(response); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Get a content item.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="app">The name of the app.</param>
|
|
|
|
|
|
/// <param name="name">The name of the schema.</param>
|
|
|
|
|
|
/// <param name="id">The id of the content to fetch.</param>
|
|
|
|
|
|
/// <returns>
|
|
|
|
|
|
/// 200 => Content found.
|
|
|
|
|
|
/// 404 => Content, schema or app not found.
|
|
|
|
|
|
/// </returns>
|
|
|
|
|
|
/// <remarks>
|
|
|
|
|
|
/// You can read the generated documentation for your app at /api/content/{appName}/docs
|
|
|
|
|
|
/// </remarks>
|
|
|
[MustBeAppReader] |
|
|
[MustBeAppReader] |
|
|
[HttpGet] |
|
|
[HttpGet] |
|
|
[Route("content/{app}/{name}/{id}/")] |
|
|
[Route("content/{app}/{name}/{id}/")] |
|
|
[ApiCosts(1)] |
|
|
[ApiCosts(1)] |
|
|
public async Task<IActionResult> GetContent(string name, Guid id) |
|
|
public async Task<IActionResult> GetContent(string app, string name, Guid id) |
|
|
{ |
|
|
{ |
|
|
var (schema, entity) = await contentQuery.FindContentAsync(App, name, User, id); |
|
|
var (schema, entity) = await contentQuery.FindContentAsync(App, name, User, id); |
|
|
|
|
|
|
|
|
@ -135,11 +174,26 @@ namespace Squidex.Areas.Api.Controllers.Contents |
|
|
return Ok(response); |
|
|
return Ok(response); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Get a content item with a specific version.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="app">The name of the app.</param>
|
|
|
|
|
|
/// <param name="name">The name of the schema.</param>
|
|
|
|
|
|
/// <param name="id">The id of the content to fetch.</param>
|
|
|
|
|
|
/// <param name="version">The version fo the content to fetch.</param>
|
|
|
|
|
|
/// <returns>
|
|
|
|
|
|
/// 200 => Content found.
|
|
|
|
|
|
/// 404 => Content, schema or app not found.
|
|
|
|
|
|
/// 400 => Content data is not valid.
|
|
|
|
|
|
/// </returns>
|
|
|
|
|
|
/// <remarks>
|
|
|
|
|
|
/// You can read the generated documentation for your app at /api/content/{appName}/docs
|
|
|
|
|
|
/// </remarks>
|
|
|
[MustBeAppReader] |
|
|
[MustBeAppReader] |
|
|
[HttpGet] |
|
|
[HttpGet] |
|
|
[Route("content/{app}/{name}/{id}/{version}/")] |
|
|
[Route("content/{app}/{name}/{id}/{version}/")] |
|
|
[ApiCosts(1)] |
|
|
[ApiCosts(1)] |
|
|
public async Task<IActionResult> GetContentVersion(string name, Guid id, int version) |
|
|
public async Task<IActionResult> GetContentVersion(string app, string name, Guid id, int version) |
|
|
{ |
|
|
{ |
|
|
var content = await contentQuery.FindContentAsync(App, name, User, id, version); |
|
|
var content = await contentQuery.FindContentAsync(App, name, User, id, version); |
|
|
|
|
|
|
|
|
@ -157,11 +211,26 @@ namespace Squidex.Areas.Api.Controllers.Contents |
|
|
return Ok(response.Data); |
|
|
return Ok(response.Data); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Create a content item.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="app">The name of the app.</param>
|
|
|
|
|
|
/// <param name="name">The name of the schema.</param>
|
|
|
|
|
|
/// <param name="request">The full data for the content item.</param>
|
|
|
|
|
|
/// <param name="publish">Indicates whether the content should be published immediately.</param>
|
|
|
|
|
|
/// <returns>
|
|
|
|
|
|
/// 201 => Content created.
|
|
|
|
|
|
/// 404 => Content, schema or app not found.
|
|
|
|
|
|
/// 400 => Content data is not valid.
|
|
|
|
|
|
/// </returns>
|
|
|
|
|
|
/// <remarks>
|
|
|
|
|
|
/// You can read the generated documentation for your app at /api/content/{appName}/docs
|
|
|
|
|
|
/// </remarks>
|
|
|
[MustBeAppEditor] |
|
|
[MustBeAppEditor] |
|
|
[HttpPost] |
|
|
[HttpPost] |
|
|
[Route("content/{app}/{name}/")] |
|
|
[Route("content/{app}/{name}/")] |
|
|
[ApiCosts(1)] |
|
|
[ApiCosts(1)] |
|
|
public async Task<IActionResult> PostContent(string name, [FromBody] NamedContentData request, [FromQuery] bool publish = false) |
|
|
public async Task<IActionResult> PostContent(string app, string name, [FromBody] NamedContentData request, [FromQuery] bool publish = false) |
|
|
{ |
|
|
{ |
|
|
await contentQuery.FindSchemaAsync(App, name); |
|
|
await contentQuery.FindSchemaAsync(App, name); |
|
|
|
|
|
|
|
|
@ -175,11 +244,26 @@ namespace Squidex.Areas.Api.Controllers.Contents |
|
|
return CreatedAtAction(nameof(GetContent), new { id = command.ContentId }, response); |
|
|
return CreatedAtAction(nameof(GetContent), new { id = command.ContentId }, response); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Update a content item.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="app">The name of the app.</param>
|
|
|
|
|
|
/// <param name="name">The name of the schema.</param>
|
|
|
|
|
|
/// <param name="id">The id of the content item to update.</param>
|
|
|
|
|
|
/// <param name="request">The full data for the content item.</param>
|
|
|
|
|
|
/// <returns>
|
|
|
|
|
|
/// 200 => Content updated.
|
|
|
|
|
|
/// 404 => Content, schema or app not found.
|
|
|
|
|
|
/// 400 => Content data is not valid.
|
|
|
|
|
|
/// </returns>
|
|
|
|
|
|
/// <remarks>
|
|
|
|
|
|
/// You can read the generated documentation for your app at /api/content/{appName}/docs
|
|
|
|
|
|
/// </remarks>
|
|
|
[MustBeAppEditor] |
|
|
[MustBeAppEditor] |
|
|
[HttpPut] |
|
|
[HttpPut] |
|
|
[Route("content/{app}/{name}/{id}/")] |
|
|
[Route("content/{app}/{name}/{id}/")] |
|
|
[ApiCosts(1)] |
|
|
[ApiCosts(1)] |
|
|
public async Task<IActionResult> PutContent(string name, Guid id, [FromBody] NamedContentData request) |
|
|
public async Task<IActionResult> PutContent(string app, string name, Guid id, [FromBody] NamedContentData request) |
|
|
{ |
|
|
{ |
|
|
await contentQuery.FindSchemaAsync(App, name); |
|
|
await contentQuery.FindSchemaAsync(App, name); |
|
|
|
|
|
|
|
|
@ -193,11 +277,26 @@ namespace Squidex.Areas.Api.Controllers.Contents |
|
|
return Ok(response); |
|
|
return Ok(response); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Patchs a content item.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="app">The name of the app.</param>
|
|
|
|
|
|
/// <param name="name">The name of the schema.</param>
|
|
|
|
|
|
/// <param name="id">The id of the content item to patch.</param>
|
|
|
|
|
|
/// <param name="request">The patch for the content item.</param>
|
|
|
|
|
|
/// <returns>
|
|
|
|
|
|
/// 200 => Content patched.
|
|
|
|
|
|
/// 404 => Content, schema or app not found.
|
|
|
|
|
|
/// 400 => Content patch is not valid.
|
|
|
|
|
|
/// </returns>
|
|
|
|
|
|
/// <remarks>
|
|
|
|
|
|
/// You can read the generated documentation for your app at /api/content/{appName}/docs
|
|
|
|
|
|
/// </remarks>
|
|
|
[MustBeAppEditor] |
|
|
[MustBeAppEditor] |
|
|
[HttpPatch] |
|
|
[HttpPatch] |
|
|
[Route("content/{app}/{name}/{id}/")] |
|
|
[Route("content/{app}/{name}/{id}/")] |
|
|
[ApiCosts(1)] |
|
|
[ApiCosts(1)] |
|
|
public async Task<IActionResult> PatchContent(string name, Guid id, [FromBody] NamedContentData request) |
|
|
public async Task<IActionResult> PatchContent(string app, string name, Guid id, [FromBody] NamedContentData request) |
|
|
{ |
|
|
{ |
|
|
await contentQuery.FindSchemaAsync(App, name); |
|
|
await contentQuery.FindSchemaAsync(App, name); |
|
|
|
|
|
|
|
|
@ -211,11 +310,26 @@ namespace Squidex.Areas.Api.Controllers.Contents |
|
|
return Ok(response); |
|
|
return Ok(response); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Publish a content item.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="app">The name of the app.</param>
|
|
|
|
|
|
/// <param name="name">The name of the schema.</param>
|
|
|
|
|
|
/// <param name="id">The id of the content item to publish.</param>
|
|
|
|
|
|
/// <param name="dueTime">The date and time when the content should be published.</param>
|
|
|
|
|
|
/// <returns>
|
|
|
|
|
|
/// 204 => Content published.
|
|
|
|
|
|
/// 404 => Content, schema or app not found.
|
|
|
|
|
|
/// 400 => Content was already published.
|
|
|
|
|
|
/// </returns>
|
|
|
|
|
|
/// <remarks>
|
|
|
|
|
|
/// You can read the generated documentation for your app at /api/content/{appName}/docs
|
|
|
|
|
|
/// </remarks>
|
|
|
[MustBeAppEditor] |
|
|
[MustBeAppEditor] |
|
|
[HttpPut] |
|
|
[HttpPut] |
|
|
[Route("content/{app}/{name}/{id}/publish/")] |
|
|
[Route("content/{app}/{name}/{id}/publish/")] |
|
|
[ApiCosts(1)] |
|
|
[ApiCosts(1)] |
|
|
public async Task<IActionResult> PublishContent(string name, Guid id, string dueTime = null) |
|
|
public async Task<IActionResult> PublishContent(string app, string name, Guid id, string dueTime = null) |
|
|
{ |
|
|
{ |
|
|
await contentQuery.FindSchemaAsync(App, name); |
|
|
await contentQuery.FindSchemaAsync(App, name); |
|
|
|
|
|
|
|
|
@ -226,11 +340,26 @@ namespace Squidex.Areas.Api.Controllers.Contents |
|
|
return NoContent(); |
|
|
return NoContent(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Unpublish a content item.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="app">The name of the app.</param>
|
|
|
|
|
|
/// <param name="name">The name of the schema.</param>
|
|
|
|
|
|
/// <param name="id">The id of the content item to unpublish.</param>
|
|
|
|
|
|
/// <param name="dueTime">The date and time when the content should be unpublished.</param>
|
|
|
|
|
|
/// <returns>
|
|
|
|
|
|
/// 204 => Content unpublished.
|
|
|
|
|
|
/// 404 => Content, schema or app not found.
|
|
|
|
|
|
/// 400 => Content was not published.
|
|
|
|
|
|
/// </returns>
|
|
|
|
|
|
/// <remarks>
|
|
|
|
|
|
/// You can read the generated documentation for your app at /api/content/{appName}/docs
|
|
|
|
|
|
/// </remarks>
|
|
|
[MustBeAppEditor] |
|
|
[MustBeAppEditor] |
|
|
[HttpPut] |
|
|
[HttpPut] |
|
|
[Route("content/{app}/{name}/{id}/unpublish/")] |
|
|
[Route("content/{app}/{name}/{id}/unpublish/")] |
|
|
[ApiCosts(1)] |
|
|
[ApiCosts(1)] |
|
|
public async Task<IActionResult> UnpublishContent(string name, Guid id, string dueTime = null) |
|
|
public async Task<IActionResult> UnpublishContent(string app, string name, Guid id, string dueTime = null) |
|
|
{ |
|
|
{ |
|
|
await contentQuery.FindSchemaAsync(App, name); |
|
|
await contentQuery.FindSchemaAsync(App, name); |
|
|
|
|
|
|
|
|
@ -241,11 +370,26 @@ namespace Squidex.Areas.Api.Controllers.Contents |
|
|
return NoContent(); |
|
|
return NoContent(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Archive a content item.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="app">The name of the app.</param>
|
|
|
|
|
|
/// <param name="name">The name of the schema.</param>
|
|
|
|
|
|
/// <param name="id">The id of the content item to archive.</param>
|
|
|
|
|
|
/// <param name="dueTime">The date and time when the content should be archived.</param>
|
|
|
|
|
|
/// <returns>
|
|
|
|
|
|
/// 204 => Content archived.
|
|
|
|
|
|
/// 404 => Content, schema or app not found.
|
|
|
|
|
|
/// 400 => Content was already archived.
|
|
|
|
|
|
/// </returns>
|
|
|
|
|
|
/// <remarks>
|
|
|
|
|
|
/// You can read the generated documentation for your app at /api/content/{appName}/docs
|
|
|
|
|
|
/// </remarks>
|
|
|
[MustBeAppEditor] |
|
|
[MustBeAppEditor] |
|
|
[HttpPut] |
|
|
[HttpPut] |
|
|
[Route("content/{app}/{name}/{id}/archive/")] |
|
|
[Route("content/{app}/{name}/{id}/archive/")] |
|
|
[ApiCosts(1)] |
|
|
[ApiCosts(1)] |
|
|
public async Task<IActionResult> ArchiveContent(string name, Guid id, string dueTime = null) |
|
|
public async Task<IActionResult> ArchiveContent(string app, string name, Guid id, string dueTime = null) |
|
|
{ |
|
|
{ |
|
|
await contentQuery.FindSchemaAsync(App, name); |
|
|
await contentQuery.FindSchemaAsync(App, name); |
|
|
|
|
|
|
|
|
@ -256,11 +400,26 @@ namespace Squidex.Areas.Api.Controllers.Contents |
|
|
return NoContent(); |
|
|
return NoContent(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Restore a content item.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="app">The name of the app.</param>
|
|
|
|
|
|
/// <param name="name">The name of the schema.</param>
|
|
|
|
|
|
/// <param name="id">The id of the content item to restore.</param>
|
|
|
|
|
|
/// <param name="dueTime">The date and time when the content should be restored.</param>
|
|
|
|
|
|
/// <returns>
|
|
|
|
|
|
/// 204 => Content restored.
|
|
|
|
|
|
/// 404 => Content, schema or app not found.
|
|
|
|
|
|
/// 400 => Content was not archived.
|
|
|
|
|
|
/// </returns>
|
|
|
|
|
|
/// <remarks>
|
|
|
|
|
|
/// You can read the generated documentation for your app at /api/content/{appName}/docs
|
|
|
|
|
|
/// </remarks>
|
|
|
[MustBeAppEditor] |
|
|
[MustBeAppEditor] |
|
|
[HttpPut] |
|
|
[HttpPut] |
|
|
[Route("content/{app}/{name}/{id}/restore/")] |
|
|
[Route("content/{app}/{name}/{id}/restore/")] |
|
|
[ApiCosts(1)] |
|
|
[ApiCosts(1)] |
|
|
public async Task<IActionResult> RestoreContent(string name, Guid id, string dueTime = null) |
|
|
public async Task<IActionResult> RestoreContent(string app, string name, Guid id, string dueTime = null) |
|
|
{ |
|
|
{ |
|
|
await contentQuery.FindSchemaAsync(App, name); |
|
|
await contentQuery.FindSchemaAsync(App, name); |
|
|
|
|
|
|
|
|
@ -271,11 +430,24 @@ namespace Squidex.Areas.Api.Controllers.Contents |
|
|
return NoContent(); |
|
|
return NoContent(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Delete a content item.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="app">The name of the app.</param>
|
|
|
|
|
|
/// <param name="name">The name of the schema.</param>
|
|
|
|
|
|
/// <param name="id">The id of the content item to delete.</param>
|
|
|
|
|
|
/// <returns>
|
|
|
|
|
|
/// 204 => Content has been deleted.
|
|
|
|
|
|
/// 404 => Content, schema or app not found.
|
|
|
|
|
|
/// </returns>
|
|
|
|
|
|
/// <remarks>
|
|
|
|
|
|
/// You can create an generated documentation for your app at /api/content/{appName}/docs
|
|
|
|
|
|
/// </remarks>
|
|
|
[MustBeAppEditor] |
|
|
[MustBeAppEditor] |
|
|
[HttpDelete] |
|
|
[HttpDelete] |
|
|
[Route("content/{app}/{name}/{id}/")] |
|
|
[Route("content/{app}/{name}/{id}/")] |
|
|
[ApiCosts(1)] |
|
|
[ApiCosts(1)] |
|
|
public async Task<IActionResult> DeleteContent(string name, Guid id) |
|
|
public async Task<IActionResult> DeleteContent(string app, string name, Guid id) |
|
|
{ |
|
|
{ |
|
|
await contentQuery.FindSchemaAsync(App, name); |
|
|
await contentQuery.FindSchemaAsync(App, name); |
|
|
|
|
|
|
|
|
|