001package com.box.sdkgen.managers.search; 002 003import com.box.sdkgen.schemas.metadatafilter.MetadataFilter; 004import com.box.sdkgen.serialization.json.EnumWrapper; 005import com.box.sdkgen.serialization.json.Valuable; 006import com.fasterxml.jackson.core.JsonGenerator; 007import com.fasterxml.jackson.core.JsonParser; 008import com.fasterxml.jackson.databind.DeserializationContext; 009import com.fasterxml.jackson.databind.JsonDeserializer; 010import com.fasterxml.jackson.databind.JsonNode; 011import com.fasterxml.jackson.databind.JsonSerializer; 012import com.fasterxml.jackson.databind.SerializerProvider; 013import java.io.IOException; 014import java.util.ArrayList; 015import java.util.List; 016 017public class SearchForContentQueryParams { 018 019 /** 020 * The string to search for. This query is matched against item names, descriptions, text content 021 * of files, and various other fields of the different item types. 022 * 023 * <p>This parameter supports a variety of operators to further refine the results returns. 024 * 025 * <p>* `""` - by wrapping a query in double quotes only exact matches are returned by the API. 026 * Exact searches do not return search matches based on specific character sequences. Instead, 027 * they return matches based on phrases, that is, word sequences. For example: A search for 028 * `"Blue-Box"` may return search results including the sequence `"blue.box"`, `"Blue Box"`, and 029 * `"Blue-Box"`; any item containing the words `Blue` and `Box` consecutively, in the order 030 * specified. * `AND` - returns items that contain both the search terms. For example, a search 031 * for `marketing AND BoxWorks` returns items that have both `marketing` and `BoxWorks` within its 032 * text in any order. It does not return a result that only has `BoxWorks` in its text. * `OR` - 033 * returns items that contain either of the search terms. For example, a search for `marketing OR 034 * BoxWorks` returns a result that has either `marketing` or `BoxWorks` within its text. Using 035 * this operator is not necessary as we implicitly interpret multi-word queries as `OR` unless 036 * another supported boolean term is used. * `NOT` - returns items that do not contain the search 037 * term provided. For example, a search for `marketing AND NOT BoxWorks` returns a result that has 038 * only `marketing` within its text. Results containing `BoxWorks` are omitted. 039 * 040 * <p>We do not support lower case (that is, `and`, `or`, and `not`) or mixed case (that is, 041 * `And`, `Or`, and `Not`) operators. 042 * 043 * <p>This field is required unless the `mdfilters` parameter is defined. 044 */ 045 public String query; 046 047 /** 048 * Limits the search results to either the files that the user has access to, or to files 049 * available to the entire enterprise. 050 * 051 * <p>The scope defaults to `user_content`, which limits the search results to content that is 052 * available to the currently authenticated user. 053 * 054 * <p>The `enterprise_content` can be requested by an admin through our support channels. Once 055 * this scope has been enabled for a user, it will allow that use to query for content across the 056 * entire enterprise and not only the content that they have access to. 057 */ 058 public EnumWrapper<SearchForContentQueryParamsScopeField> scope; 059 060 /** 061 * Limits the search results to any files that match any of the provided file extensions. This 062 * list is a comma-separated list of file extensions without the dots. 063 */ 064 public List<String> fileExtensions; 065 066 /** 067 * Limits the search results to any items created within a given date range. 068 * 069 * <p>Date ranges are defined as comma separated RFC3339 timestamps. 070 * 071 * <p>If the start date is omitted (`,2014-05-17T13:35:01-07:00`) anything created before the end 072 * date will be returned. 073 * 074 * <p>If the end date is omitted (`2014-05-15T13:35:01-07:00,`) the current date will be used as 075 * the end date instead. 076 */ 077 public List<String> createdAtRange; 078 079 /** 080 * Limits the search results to any items updated within a given date range. 081 * 082 * <p>Date ranges are defined as comma separated RFC3339 timestamps. 083 * 084 * <p>If the start date is omitted (`,2014-05-17T13:35:01-07:00`) anything updated before the end 085 * date will be returned. 086 * 087 * <p>If the end date is omitted (`2014-05-15T13:35:01-07:00,`) the current date will be used as 088 * the end date instead. 089 */ 090 public List<String> updatedAtRange; 091 092 /** 093 * Limits the search results to any items with a size within a given file size range. This applied 094 * to files and folders. 095 * 096 * <p>Size ranges are defined as comma separated list of a lower and upper byte size limit 097 * (inclusive). 098 * 099 * <p>The upper and lower bound can be omitted to create open ranges. 100 */ 101 public List<Long> sizeRange; 102 103 /** 104 * Limits the search results to any items that are owned by the given list of owners, defined as a 105 * list of comma separated user IDs. 106 * 107 * <p>The items still need to be owned or shared with the currently authenticated user for them to 108 * show up in the search results. If the user does not have access to any files owned by any of 109 * the users an empty result set will be returned. 110 * 111 * <p>To search across an entire enterprise, we recommend using the `enterprise_content` scope 112 * parameter which can be requested with our support team. 113 */ 114 public List<String> ownerUserIds; 115 116 /** 117 * Limits the search results to any items that have been updated by the given list of users, 118 * defined as a list of comma separated user IDs. 119 * 120 * <p>The items still need to be owned or shared with the currently authenticated user for them to 121 * show up in the search results. If the user does not have access to any files owned by any of 122 * the users an empty result set will be returned. 123 * 124 * <p>This feature only searches back to the last 10 versions of an item. 125 */ 126 public List<String> recentUpdaterUserIds; 127 128 /** 129 * Limits the search results to items within the given list of folders, defined as a comma 130 * separated lists of folder IDs. 131 * 132 * <p>Search results will also include items within any subfolders of those ancestor folders. 133 * 134 * <p>The folders still need to be owned or shared with the currently authenticated user. If the 135 * folder is not accessible by this user, or it does not exist, a `HTTP 404` error code will be 136 * returned instead. 137 * 138 * <p>To search across an entire enterprise, we recommend using the `enterprise_content` scope 139 * parameter which can be requested with our support team. 140 */ 141 public List<String> ancestorFolderIds; 142 143 /** 144 * Limits the search results to any items that match the search query for a specific part of the 145 * file, for example the file description. 146 * 147 * <p>Content types are defined as a comma separated lists of Box recognized content types. The 148 * allowed content types are as follows. 149 * 150 * <p>* `name` - The name of the item, as defined by its `name` field. * `description` - The 151 * description of the item, as defined by its `description` field. * `file_content` - The actual 152 * content of the file. * `comments` - The content of any of the comments on a file or folder. * 153 * `tags` - Any tags that are applied to an item, as defined by its `tags` field. 154 */ 155 public List<EnumWrapper<SearchForContentQueryParamsContentTypesField>> contentTypes; 156 157 /** 158 * Limits the search results to any items of this type. This parameter only takes one value. By 159 * default the API returns items that match any of these types. 160 * 161 * <p>* `file` - Limits the search results to files, * `folder` - Limits the search results to 162 * folders, * `web_link` - Limits the search results to web links, also known as bookmarks. 163 */ 164 public EnumWrapper<SearchForContentQueryParamsTypeField> type; 165 166 /** 167 * Determines if the search should look in the trash for items. 168 * 169 * <p>By default, this API only returns search results for items not currently in the trash 170 * (`non_trashed_only`). 171 * 172 * <p>* `trashed_only` - Only searches for items currently in the trash * `non_trashed_only` - 173 * Only searches for items currently not in the trash * `all_items` - Searches for both trashed 174 * and non-trashed items. 175 */ 176 public EnumWrapper<SearchForContentQueryParamsTrashContentField> trashContent; 177 178 /** 179 * Limits the search results to any items for which the metadata matches the provided filter. This 180 * parameter is a list that specifies exactly **one** metadata template used to filter the search 181 * results. The parameter is required unless the `query` parameter is provided. 182 */ 183 public List<MetadataFilter> mdfilters; 184 185 /** 186 * Defines the order in which search results are returned. This API defaults to returning items by 187 * relevance unless this parameter is explicitly specified. 188 * 189 * <p>* `relevance` (default) returns the results sorted by relevance to the query search term. 190 * The relevance is based on the occurrence of the search term in the items name, description, 191 * content, and additional properties. * `modified_at` returns the results ordered in descending 192 * order by date at which the item was last modified. 193 */ 194 public EnumWrapper<SearchForContentQueryParamsSortField> sort; 195 196 /** 197 * Defines the direction in which search results are ordered. This API defaults to returning items 198 * in descending (`DESC`) order unless this parameter is explicitly specified. 199 * 200 * <p>When results are sorted by `relevance` the ordering is locked to returning items in 201 * descending order of relevance, and this parameter is ignored. 202 */ 203 public EnumWrapper<SearchForContentQueryParamsDirectionField> direction; 204 205 /** Defines the maximum number of items to return as part of a page of results. */ 206 public Long limit; 207 208 /** 209 * Defines whether the search results should include any items that the user recently accessed 210 * through a shared link. 211 * 212 * <p>When this parameter has been set to true, the format of the response of this API changes to 213 * return a list of [Search Results with Shared 214 * Links](https://developer.box.com/reference/resources/search-results-with-shared-links). 215 */ 216 public Boolean includeRecentSharedLinks; 217 218 /** 219 * A comma-separated list of attributes to include in the response. This can be used to request 220 * fields that are not normally returned in a standard response. 221 * 222 * <p>Be aware that specifying this parameter will have the effect that none of the standard 223 * fields are returned in the response unless explicitly specified, instead only fields for the 224 * mini representation are returned, additional to the fields requested. 225 */ 226 public List<String> fields; 227 228 /** 229 * The offset of the item at which to begin the response. 230 * 231 * <p>Queries with offset parameter value exceeding 10000 will be rejected with a 400 response. 232 */ 233 public Long offset; 234 235 /** 236 * Limits the search results to items that were deleted by the given list of users, defined as a 237 * list of comma separated user IDs. 238 * 239 * <p>The `trash_content` parameter needs to be set to `trashed_only`. 240 * 241 * <p>If searching in trash is not performed, an empty result set is returned. The items need to 242 * be owned or shared with the currently authenticated user for them to show up in the search 243 * results. 244 * 245 * <p>If the user does not have access to any files owned by any of the users, an empty result set 246 * is returned. 247 * 248 * <p>Data available from 2023-02-01 onwards. 249 */ 250 public List<String> deletedUserIds; 251 252 /** 253 * Limits the search results to any items deleted within a given date range. 254 * 255 * <p>Date ranges are defined as comma separated RFC3339 timestamps. 256 * 257 * <p>If the start date is omitted (`2014-05-17T13:35:01-07:00`), anything deleted before the end 258 * date will be returned. 259 * 260 * <p>If the end date is omitted (`2014-05-15T13:35:01-07:00`), the current date will be used as 261 * the end date instead. 262 * 263 * <p>The `trash_content` parameter needs to be set to `trashed_only`. 264 * 265 * <p>If searching in trash is not performed, then an empty result is returned. 266 * 267 * <p>Data available from 2023-02-01 onwards. 268 */ 269 public List<String> deletedAtRange; 270 271 public SearchForContentQueryParams() {} 272 273 protected SearchForContentQueryParams(Builder builder) { 274 this.query = builder.query; 275 this.scope = builder.scope; 276 this.fileExtensions = builder.fileExtensions; 277 this.createdAtRange = builder.createdAtRange; 278 this.updatedAtRange = builder.updatedAtRange; 279 this.sizeRange = builder.sizeRange; 280 this.ownerUserIds = builder.ownerUserIds; 281 this.recentUpdaterUserIds = builder.recentUpdaterUserIds; 282 this.ancestorFolderIds = builder.ancestorFolderIds; 283 this.contentTypes = builder.contentTypes; 284 this.type = builder.type; 285 this.trashContent = builder.trashContent; 286 this.mdfilters = builder.mdfilters; 287 this.sort = builder.sort; 288 this.direction = builder.direction; 289 this.limit = builder.limit; 290 this.includeRecentSharedLinks = builder.includeRecentSharedLinks; 291 this.fields = builder.fields; 292 this.offset = builder.offset; 293 this.deletedUserIds = builder.deletedUserIds; 294 this.deletedAtRange = builder.deletedAtRange; 295 } 296 297 public String getQuery() { 298 return query; 299 } 300 301 public EnumWrapper<SearchForContentQueryParamsScopeField> getScope() { 302 return scope; 303 } 304 305 public List<String> getFileExtensions() { 306 return fileExtensions; 307 } 308 309 public List<String> getCreatedAtRange() { 310 return createdAtRange; 311 } 312 313 public List<String> getUpdatedAtRange() { 314 return updatedAtRange; 315 } 316 317 public List<Long> getSizeRange() { 318 return sizeRange; 319 } 320 321 public List<String> getOwnerUserIds() { 322 return ownerUserIds; 323 } 324 325 public List<String> getRecentUpdaterUserIds() { 326 return recentUpdaterUserIds; 327 } 328 329 public List<String> getAncestorFolderIds() { 330 return ancestorFolderIds; 331 } 332 333 public List<EnumWrapper<SearchForContentQueryParamsContentTypesField>> getContentTypes() { 334 return contentTypes; 335 } 336 337 public EnumWrapper<SearchForContentQueryParamsTypeField> getType() { 338 return type; 339 } 340 341 public EnumWrapper<SearchForContentQueryParamsTrashContentField> getTrashContent() { 342 return trashContent; 343 } 344 345 public List<MetadataFilter> getMdfilters() { 346 return mdfilters; 347 } 348 349 public EnumWrapper<SearchForContentQueryParamsSortField> getSort() { 350 return sort; 351 } 352 353 public EnumWrapper<SearchForContentQueryParamsDirectionField> getDirection() { 354 return direction; 355 } 356 357 public Long getLimit() { 358 return limit; 359 } 360 361 public Boolean getIncludeRecentSharedLinks() { 362 return includeRecentSharedLinks; 363 } 364 365 public List<String> getFields() { 366 return fields; 367 } 368 369 public Long getOffset() { 370 return offset; 371 } 372 373 public List<String> getDeletedUserIds() { 374 return deletedUserIds; 375 } 376 377 public List<String> getDeletedAtRange() { 378 return deletedAtRange; 379 } 380 381 public static class Builder { 382 383 protected String query; 384 385 protected EnumWrapper<SearchForContentQueryParamsScopeField> scope; 386 387 protected List<String> fileExtensions; 388 389 protected List<String> createdAtRange; 390 391 protected List<String> updatedAtRange; 392 393 protected List<Long> sizeRange; 394 395 protected List<String> ownerUserIds; 396 397 protected List<String> recentUpdaterUserIds; 398 399 protected List<String> ancestorFolderIds; 400 401 protected List<EnumWrapper<SearchForContentQueryParamsContentTypesField>> contentTypes; 402 403 protected EnumWrapper<SearchForContentQueryParamsTypeField> type; 404 405 protected EnumWrapper<SearchForContentQueryParamsTrashContentField> trashContent; 406 407 protected List<MetadataFilter> mdfilters; 408 409 protected EnumWrapper<SearchForContentQueryParamsSortField> sort; 410 411 protected EnumWrapper<SearchForContentQueryParamsDirectionField> direction; 412 413 protected Long limit; 414 415 protected Boolean includeRecentSharedLinks; 416 417 protected List<String> fields; 418 419 protected Long offset; 420 421 protected List<String> deletedUserIds; 422 423 protected List<String> deletedAtRange; 424 425 public Builder query(String query) { 426 this.query = query; 427 return this; 428 } 429 430 public Builder scope(SearchForContentQueryParamsScopeField scope) { 431 this.scope = new EnumWrapper<SearchForContentQueryParamsScopeField>(scope); 432 return this; 433 } 434 435 public Builder scope(EnumWrapper<SearchForContentQueryParamsScopeField> scope) { 436 this.scope = scope; 437 return this; 438 } 439 440 public Builder fileExtensions(List<String> fileExtensions) { 441 this.fileExtensions = fileExtensions; 442 return this; 443 } 444 445 public Builder createdAtRange(List<String> createdAtRange) { 446 this.createdAtRange = createdAtRange; 447 return this; 448 } 449 450 public Builder updatedAtRange(List<String> updatedAtRange) { 451 this.updatedAtRange = updatedAtRange; 452 return this; 453 } 454 455 public Builder sizeRange(List<Long> sizeRange) { 456 this.sizeRange = sizeRange; 457 return this; 458 } 459 460 public Builder ownerUserIds(List<String> ownerUserIds) { 461 this.ownerUserIds = ownerUserIds; 462 return this; 463 } 464 465 public Builder recentUpdaterUserIds(List<String> recentUpdaterUserIds) { 466 this.recentUpdaterUserIds = recentUpdaterUserIds; 467 return this; 468 } 469 470 public Builder ancestorFolderIds(List<String> ancestorFolderIds) { 471 this.ancestorFolderIds = ancestorFolderIds; 472 return this; 473 } 474 475 public Builder contentTypes(List<? extends Valuable> contentTypes) { 476 this.contentTypes = 477 EnumWrapper.wrapValuableEnumList( 478 contentTypes, SearchForContentQueryParamsContentTypesField.class); 479 return this; 480 } 481 482 public Builder type(SearchForContentQueryParamsTypeField type) { 483 this.type = new EnumWrapper<SearchForContentQueryParamsTypeField>(type); 484 return this; 485 } 486 487 public Builder type(EnumWrapper<SearchForContentQueryParamsTypeField> type) { 488 this.type = type; 489 return this; 490 } 491 492 public Builder trashContent(SearchForContentQueryParamsTrashContentField trashContent) { 493 this.trashContent = 494 new EnumWrapper<SearchForContentQueryParamsTrashContentField>(trashContent); 495 return this; 496 } 497 498 public Builder trashContent( 499 EnumWrapper<SearchForContentQueryParamsTrashContentField> trashContent) { 500 this.trashContent = trashContent; 501 return this; 502 } 503 504 public Builder mdfilters(List<MetadataFilter> mdfilters) { 505 this.mdfilters = mdfilters; 506 return this; 507 } 508 509 public Builder sort(SearchForContentQueryParamsSortField sort) { 510 this.sort = new EnumWrapper<SearchForContentQueryParamsSortField>(sort); 511 return this; 512 } 513 514 public Builder sort(EnumWrapper<SearchForContentQueryParamsSortField> sort) { 515 this.sort = sort; 516 return this; 517 } 518 519 public Builder direction(SearchForContentQueryParamsDirectionField direction) { 520 this.direction = new EnumWrapper<SearchForContentQueryParamsDirectionField>(direction); 521 return this; 522 } 523 524 public Builder direction(EnumWrapper<SearchForContentQueryParamsDirectionField> direction) { 525 this.direction = direction; 526 return this; 527 } 528 529 public Builder limit(Long limit) { 530 this.limit = limit; 531 return this; 532 } 533 534 public Builder includeRecentSharedLinks(Boolean includeRecentSharedLinks) { 535 this.includeRecentSharedLinks = includeRecentSharedLinks; 536 return this; 537 } 538 539 public Builder fields(List<String> fields) { 540 this.fields = fields; 541 return this; 542 } 543 544 public Builder offset(Long offset) { 545 this.offset = offset; 546 return this; 547 } 548 549 public Builder deletedUserIds(List<String> deletedUserIds) { 550 this.deletedUserIds = deletedUserIds; 551 return this; 552 } 553 554 public Builder deletedAtRange(List<String> deletedAtRange) { 555 this.deletedAtRange = deletedAtRange; 556 return this; 557 } 558 559 public SearchForContentQueryParams build() { 560 return new SearchForContentQueryParams(this); 561 } 562 } 563 564 public static class ContentTypesDeserializer 565 extends JsonDeserializer<List<EnumWrapper<SearchForContentQueryParamsContentTypesField>>> { 566 567 public final JsonDeserializer<EnumWrapper<SearchForContentQueryParamsContentTypesField>> 568 elementDeserializer; 569 570 public ContentTypesDeserializer() { 571 super(); 572 this.elementDeserializer = 573 new SearchForContentQueryParamsContentTypesField 574 .SearchForContentQueryParamsContentTypesFieldDeserializer(); 575 } 576 577 @Override 578 public List<EnumWrapper<SearchForContentQueryParamsContentTypesField>> deserialize( 579 JsonParser p, DeserializationContext ctxt) throws IOException { 580 JsonNode node = p.getCodec().readTree(p); 581 List<EnumWrapper<SearchForContentQueryParamsContentTypesField>> elements = new ArrayList<>(); 582 for (JsonNode item : node) { 583 JsonParser pa = item.traverse(p.getCodec()); 584 pa.nextToken(); 585 elements.add(elementDeserializer.deserialize(pa, ctxt)); 586 } 587 return elements; 588 } 589 } 590 591 public static class ContentTypesSerializer 592 extends JsonSerializer<List<EnumWrapper<SearchForContentQueryParamsContentTypesField>>> { 593 594 public final JsonSerializer<EnumWrapper<SearchForContentQueryParamsContentTypesField>> 595 elementSerializer; 596 597 public ContentTypesSerializer() { 598 super(); 599 this.elementSerializer = 600 new SearchForContentQueryParamsContentTypesField 601 .SearchForContentQueryParamsContentTypesFieldSerializer(); 602 } 603 604 @Override 605 public void serialize( 606 List<EnumWrapper<SearchForContentQueryParamsContentTypesField>> value, 607 JsonGenerator gen, 608 SerializerProvider serializers) 609 throws IOException { 610 gen.writeStartArray(); 611 for (EnumWrapper<SearchForContentQueryParamsContentTypesField> item : value) { 612 elementSerializer.serialize(item, gen, serializers); 613 } 614 gen.writeEndArray(); 615 } 616 } 617}