Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat!: remove method with use_index reference #870

Merged
merged 2 commits into from
Dec 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 0 additions & 55 deletions Box.V2.Test/BoxMetadataManagerTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -613,61 +613,6 @@ public async Task ExecuteMetadataQuery_ValidResponse()
Assert.AreEqual(metadata["someTemplate"]["region"], "West");
}

[TestMethod]
public async Task ExecuteMetadataQueryWithFields_ValidResponse()
{
/*** Arrange ***/
IBoxRequest boxRequest = null;
Handler.Setup(h => h.ExecuteAsync<BoxCollectionMarkerBased<BoxItem>>(It.IsAny<IBoxRequest>()))
.Returns(Task.FromResult<IBoxResponse<BoxCollectionMarkerBased<BoxItem>>>(new BoxResponse<BoxCollectionMarkerBased<BoxItem>>()
{
Status = ResponseStatus.Success,
ContentString = LoadFixtureFromJson("Fixtures/BoxMetadata/ExecuteMetadataWithFieldsQuery200.json")
}))
.Callback<IBoxRequest>(r => boxRequest = r);

/*** Act ***/
var queryParams = new Dictionary<string, object>
{
{ "arg", "Bob Dylan" }
};
var fields = new List<string>
{
"id",
"name",
"sha1",
"metadata.enterprise_240748.catalogImages.photographer"
};
var marker = "q3f87oqf3qygou5t478g9gwrbul";
BoxCollectionMarkerBased<BoxItem> items = await _metadataManager.ExecuteMetadataQueryAsync(from: "enterprise_67890.catalogImages", query: "photographer = :arg", fields: fields, queryParameters: queryParams, ancestorFolderId: "0", marker: marker, autoPaginate: false);
/*** Assert ***/

// Request check
Assert.IsNotNull(boxRequest);
Assert.AreEqual(RequestMethod.Post, boxRequest.Method);
Assert.AreEqual(MetadataQueryUri, boxRequest.AbsoluteUri.AbsoluteUri);
var payload = JObject.Parse(boxRequest.Payload);
Assert.AreEqual("enterprise_67890.catalogImages", payload["from"]);
Assert.AreEqual("photographer = :arg", payload["query"]);
Assert.AreEqual("0", payload["ancestor_folder_id"]);
var payloadFields = JArray.Parse(payload["fields"].ToString());
Assert.AreEqual("id", payloadFields[0]);
Assert.AreEqual("name", payloadFields[1]);
Assert.AreEqual("sha1", payloadFields[2]);
Assert.AreEqual("metadata.enterprise_240748.catalogImages.photographer", payloadFields[3]);
Assert.AreEqual(marker, payload["marker"]);

// Response check
Assert.AreEqual(items.Entries[0].Type, "file");
Assert.AreEqual(items.Entries[0].Id, "1244738582");
Assert.AreEqual(items.Entries[0].Name, "Very Important.docx");
Assert.AreEqual(items.Entries[1].Type, "folder");
Assert.AreEqual(items.Entries[1].Id, "124242482");
Assert.AreEqual(items.Entries[1].Name, "Also Important.docx");
var file = (BoxFile)items.Entries[0];
Assert.AreEqual(file.Metadata["enterprise_67890"]["catalogImages"]["photographer"].Value, "Bob Dylan");
}

[TestMethod]
public async Task ExecuteMetadataQueryWithoutUseIndexWithFields_ValidResponse()
{
Expand Down
42 changes: 0 additions & 42 deletions Box.V2/Managers/BoxMetadataManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -350,48 +350,6 @@ public async Task<BoxCollectionMarkerBased<BoxMetadataQueryItem>> ExecuteMetadat
}
}

/// <summary>
/// Allows you to query by metadata on Box items with fields passed in
/// </summary>
/// <param name="from">The template used in the query. Must be in the form scope.templateKey</param>
/// <param name="ancestorFolderId">The folder_id to which to restrain the query</param>
/// <param name="fields">Attribute(s) to include in the response</param>
/// <param name="query">The logical expression of the query</param>
/// <param name="queryParameters">Required if query present. The arguments for the query</param>
/// <param name="indexName">The name of the Index to use</param>
/// <param name="orderBy">A list of BoxMetadataQueryOrderBy objects that contain field_key(s) to order on and the corresponding direction(s)</param>
/// <param name="limit">The maximum number of items to return in a page. The default is 100 and the max is 1000.</param>
/// <param name="marker">The marker to use for requesting the next page</param>
/// <param name="autoPaginate">Whether or not to auto-paginate to fetch all items; defaults to false.</param>
/// <returns>A collection of items and their associated metadata</returns>
[Obsolete("This method no longer supports use_index. Use ExecuteMetadataQueryAsync(BoxMetadataQueryRequest queryRequest) instead.")]
public async Task<BoxCollectionMarkerBased<BoxItem>> ExecuteMetadataQueryAsync(string from, string ancestorFolderId, IEnumerable<string> fields, string query = null, Dictionary<string, object> queryParameters = null, string indexName = null, List<BoxMetadataQueryOrderBy> orderBy = null, int limit = 100, string marker = null, bool autoPaginate = false)
{
from.ThrowIfNullOrWhiteSpace("from");
ancestorFolderId.ThrowIfNullOrWhiteSpace("ancestorFolderId");
if (fields == null)
{
throw new ArgumentException("Required field cannot be null", "fields");
}

JObject bodyObject = GetMetadataQueryBody(from, ancestorFolderId, query, queryParameters, orderBy, fields, limit, marker);

BoxRequest request = new BoxRequest(_config.MetadataQueryUri)
.Method(RequestMethod.Post)
.Payload(_converter.Serialize(bodyObject));
request.ContentType = Constants.RequestParameters.ContentTypeJson;

if (autoPaginate)
{
return await AutoPaginateMarkerMetadataQueryV2<BoxItem>(request).ConfigureAwait(false);
}
else
{
IBoxResponse<BoxCollectionMarkerBased<BoxItem>> response = await ToResponseAsync<BoxCollectionMarkerBased<BoxItem>>(request).ConfigureAwait(false);
return response.ResponseObject;
}
}

/// <summary>
/// Allows you to query by metadata on Box items with fields passed in
/// </summary>
Expand Down
17 changes: 0 additions & 17 deletions Box.V2/Managers/IBoxMetadataManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -183,23 +183,6 @@ public interface IBoxMetadataManager
[Obsolete("This method is deprecated in favor of ExecuteMetadataQueryAsync() that has a fields parameter. The API will eventually not support this method.")]
Task<BoxCollectionMarkerBased<BoxMetadataQueryItem>> ExecuteMetadataQueryAsync(string from, string ancestorFolderId, string query = null, Dictionary<string, object> queryParameters = null, string indexName = null, List<BoxMetadataQueryOrderBy> orderBy = null, int limit = 100, string marker = null, bool autoPaginate = false);

/// <summary>
/// Allows you to query by metadata on Box items with fields passed in
/// </summary>
/// <param name="from">The template used in the query. Must be in the form scope.templateKey</param>
/// <param name="ancestorFolderId">The folder_id to which to restrain the query</param>
/// <param name="fields">Attribute(s) to include in the response</param>
/// <param name="query">The logical expression of the query</param>
/// <param name="queryParameters">Required if query present. The arguments for the query</param>
/// <param name="indexName">The name of the Index to use</param>
/// <param name="orderBy">A list of BoxMetadataQueryOrderBy objects that contain field_key(s) to order on and the corresponding direction(s)</param>
/// <param name="limit">The maximum number of items to return in a page. The default is 100 and the max is 1000.</param>
/// <param name="marker">The marker to use for requesting the next page</param>
/// <param name="autoPaginate">Whether or not to auto-paginate to fetch all items; defaults to false.</param>
/// <returns>A collection of items and their associated metadata</returns>
[Obsolete("This method no longer supports use_index. Use ExecuteMetadataQueryAsync(BoxMetadataQueryRequest queryRequest) instead.")]
Task<BoxCollectionMarkerBased<BoxItem>> ExecuteMetadataQueryAsync(string from, string ancestorFolderId, IEnumerable<string> fields, string query = null, Dictionary<string, object> queryParameters = null, string indexName = null, List<BoxMetadataQueryOrderBy> orderBy = null, int limit = 100, string marker = null, bool autoPaginate = false);

/// <summary>
/// Allows you to query by metadata on Box items with fields passed in
/// </summary>
Expand Down
16 changes: 15 additions & 1 deletion docs/upgrades/4.x.x to 5.x.x.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,21 @@ Follow the [General changes](#general-changes) to see the changes that are packa

## General changes

No changes
### Removed deprecated methods

Some old, deprecated methods have been removed from version 5.x.x. Read this section further to see a new, alternative methods.

#### BoxMetadataManager

Old
```c#
ExecuteMetadataQueryAsync(string from, string ancestorFolderId, IEnumerable<string> fields, string query, Dictionary<string, object> queryParameters, string indexName, List<BoxMetadataQueryOrderBy> orderBy, int limit, string marker, bool autoPaginate)
```

New
```c#
ExecuteMetadataQueryAsync(BoxMetadataQueryRequest queryRequest)
```

## Box.V2

Expand Down