diff --git a/Box.V2.Test/BoxMetadataManagerTest.cs b/Box.V2.Test/BoxMetadataManagerTest.cs index 94f224fa5..53cdd9ac7 100644 --- a/Box.V2.Test/BoxMetadataManagerTest.cs +++ b/Box.V2.Test/BoxMetadataManagerTest.cs @@ -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>(It.IsAny())) - .Returns(Task.FromResult>>(new BoxResponse>() - { - Status = ResponseStatus.Success, - ContentString = LoadFixtureFromJson("Fixtures/BoxMetadata/ExecuteMetadataWithFieldsQuery200.json") - })) - .Callback(r => boxRequest = r); - - /*** Act ***/ - var queryParams = new Dictionary - { - { "arg", "Bob Dylan" } - }; - var fields = new List - { - "id", - "name", - "sha1", - "metadata.enterprise_240748.catalogImages.photographer" - }; - var marker = "q3f87oqf3qygou5t478g9gwrbul"; - BoxCollectionMarkerBased 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() { diff --git a/Box.V2/Managers/BoxMetadataManager.cs b/Box.V2/Managers/BoxMetadataManager.cs index a1fc98309..ee0e44bb2 100644 --- a/Box.V2/Managers/BoxMetadataManager.cs +++ b/Box.V2/Managers/BoxMetadataManager.cs @@ -350,48 +350,6 @@ public async Task> ExecuteMetadat } } - /// - /// Allows you to query by metadata on Box items with fields passed in - /// - /// The template used in the query. Must be in the form scope.templateKey - /// The folder_id to which to restrain the query - /// Attribute(s) to include in the response - /// The logical expression of the query - /// Required if query present. The arguments for the query - /// The name of the Index to use - /// A list of BoxMetadataQueryOrderBy objects that contain field_key(s) to order on and the corresponding direction(s) - /// The maximum number of items to return in a page. The default is 100 and the max is 1000. - /// The marker to use for requesting the next page - /// Whether or not to auto-paginate to fetch all items; defaults to false. - /// A collection of items and their associated metadata - [Obsolete("This method no longer supports use_index. Use ExecuteMetadataQueryAsync(BoxMetadataQueryRequest queryRequest) instead.")] - public async Task> ExecuteMetadataQueryAsync(string from, string ancestorFolderId, IEnumerable fields, string query = null, Dictionary queryParameters = null, string indexName = null, List 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(request).ConfigureAwait(false); - } - else - { - IBoxResponse> response = await ToResponseAsync>(request).ConfigureAwait(false); - return response.ResponseObject; - } - } - /// /// Allows you to query by metadata on Box items with fields passed in /// diff --git a/Box.V2/Managers/IBoxMetadataManager.cs b/Box.V2/Managers/IBoxMetadataManager.cs index dc2c72fef..e921cc949 100644 --- a/Box.V2/Managers/IBoxMetadataManager.cs +++ b/Box.V2/Managers/IBoxMetadataManager.cs @@ -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> ExecuteMetadataQueryAsync(string from, string ancestorFolderId, string query = null, Dictionary queryParameters = null, string indexName = null, List orderBy = null, int limit = 100, string marker = null, bool autoPaginate = false); - /// - /// Allows you to query by metadata on Box items with fields passed in - /// - /// The template used in the query. Must be in the form scope.templateKey - /// The folder_id to which to restrain the query - /// Attribute(s) to include in the response - /// The logical expression of the query - /// Required if query present. The arguments for the query - /// The name of the Index to use - /// A list of BoxMetadataQueryOrderBy objects that contain field_key(s) to order on and the corresponding direction(s) - /// The maximum number of items to return in a page. The default is 100 and the max is 1000. - /// The marker to use for requesting the next page - /// Whether or not to auto-paginate to fetch all items; defaults to false. - /// A collection of items and their associated metadata - [Obsolete("This method no longer supports use_index. Use ExecuteMetadataQueryAsync(BoxMetadataQueryRequest queryRequest) instead.")] - Task> ExecuteMetadataQueryAsync(string from, string ancestorFolderId, IEnumerable fields, string query = null, Dictionary queryParameters = null, string indexName = null, List orderBy = null, int limit = 100, string marker = null, bool autoPaginate = false); - /// /// Allows you to query by metadata on Box items with fields passed in /// diff --git a/docs/upgrades/4.x.x to 5.x.x.md b/docs/upgrades/4.x.x to 5.x.x.md index aac855d4c..ab7d538a2 100644 --- a/docs/upgrades/4.x.x to 5.x.x.md +++ b/docs/upgrades/4.x.x to 5.x.x.md @@ -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 fields, string query, Dictionary queryParameters, string indexName, List orderBy, int limit, string marker, bool autoPaginate) +``` + +New +```c# +ExecuteMetadataQueryAsync(BoxMetadataQueryRequest queryRequest) +``` ## Box.V2