|
14 | 14 | import com.cloudinary.strategies.AbstractApiStrategy; |
15 | 15 | import com.cloudinary.utils.ObjectUtils; |
16 | 16 | import org.cloudinary.json.JSONArray; |
| 17 | +import com.cloudinary.utils.StringUtils; |
17 | 18 |
|
18 | 19 | @SuppressWarnings({"rawtypes", "unchecked"}) |
19 | 20 | public class Api { |
@@ -78,6 +79,21 @@ public ApiResponse resourcesByTag(String tag, Map options) throws Exception { |
78 | 79 | return callApi(HttpMethod.GET, Arrays.asList("resources", resourceType, "tags", tag), ObjectUtils.only(options, "next_cursor", "direction", "max_results", "tags", "context", "moderations"), options); |
79 | 80 | } |
80 | 81 |
|
| 82 | + public ApiResponse resourcesByContext(String key, Map options) throws Exception { |
| 83 | + return resourcesByContext(key,null,options); |
| 84 | + } |
| 85 | + |
| 86 | + public ApiResponse resourcesByContext(String key,String value, Map options) throws Exception { |
| 87 | + if (options == null) options = ObjectUtils.emptyMap(); |
| 88 | + String resourceType = ObjectUtils.asString(options.get("resource_type"), "image"); |
| 89 | + Map params = ObjectUtils.only(options, "next_cursor", "direction", "max_results", "tags", "context", "moderations"); |
| 90 | + params.put("key",key); |
| 91 | + if (StringUtils.isNotBlank(value)) { |
| 92 | + params.put("value",value); |
| 93 | + } |
| 94 | + return callApi(HttpMethod.GET, Arrays.asList("resources", resourceType,"context"), params , options); |
| 95 | + } |
| 96 | + |
81 | 97 | public ApiResponse resourcesByIds(Iterable<String> publicIds, Map options) throws Exception { |
82 | 98 | if (options == null) options = ObjectUtils.emptyMap(); |
83 | 99 | String resourceType = ObjectUtils.asString(options.get("resource_type"), "image"); |
|
0 commit comments