@@ -14,8 +14,10 @@ public class Account {
14
14
private static final String CLOUDINARY_ACCOUNT_URL = "CLOUDINARY_ACCOUNT_URL" ;
15
15
public static final String PROVISIONING = "provisioning" ;
16
16
public static final String ACCOUNTS = "accounts" ;
17
+ public static final String SUB_ACCOUNTS = "sub_accounts" ;
17
18
public static final String USERS = "users" ;
18
19
public static final String USER_GROUPS = "user_groups" ;
20
+ public static final String ACCESS_KEYS = "access_keys" ;
19
21
20
22
private final AccountConfiguration configuration ;
21
23
private final String accountId ;
@@ -619,6 +621,60 @@ public ApiResponse userGroupUsers(String groupId, Map<String, Object> options) t
619
621
return callAccountApi (Api .HttpMethod .GET , uri , Collections .<String , Object >emptyMap (), options );
620
622
}
621
623
624
+ /**
625
+ * Lists the access keys belonging to this sub account id.
626
+ * @param subAccountId The id of the user group.
627
+ * @param options Generic advanced options map, see online documentation.
628
+ * @return The list of access keys in that sub account id.
629
+ * @throws Exception If the request fails.
630
+ */
631
+ public ApiResponse getAccessKeys (String subAccountId , Map <String , Object > options ) throws Exception {
632
+ List <String > uri = Arrays .asList (PROVISIONING , ACCOUNTS , accountId , SUB_ACCOUNTS , subAccountId );
633
+ return callAccountApi (Api .HttpMethod .GET , uri , Collections .<String , Object >emptyMap (), options );
634
+ }
635
+
636
+ /**
637
+ * Creates a new access key for this sub account id.
638
+ * @param subAccountId The id of the user group.
639
+ * @param name The name for the access key.
640
+ * @param enabled Access key's status (enabled or disabled).
641
+ * @param options Generic advanced options map, see online documentation.
642
+ * @return The created access key.
643
+ * @throws Exception If the request fails.
644
+ */
645
+ public ApiResponse createAccessKey (String subAccountId , String name , Boolean enabled , Map <String , Object > options ) throws Exception {
646
+ List <String > uri = Arrays .asList (PROVISIONING , ACCOUNTS , accountId , SUB_ACCOUNTS , subAccountId , ACCESS_KEYS );
647
+ return callAccountApi (Api .HttpMethod .POST , uri , ObjectUtils .asMap ("name" , name , "enabled" , enabled ), options );
648
+ }
649
+
650
+ /**
651
+ * Updates an existing access key for this sub account id.
652
+ * @param subAccountId The id of the user group.
653
+ * @param accessKey The key of the access key.
654
+ * @param name The name for the access key.
655
+ * @param enabled Access key's status (enabled or disabled).
656
+ * @param options Generic advanced options map, see online documentation.
657
+ * @return The updated access key.
658
+ * @throws Exception If the request fails.
659
+ */
660
+ public ApiResponse updateAccessKey (String subAccountId , String accessKey , String name , Boolean enabled , Map <String , Object > options ) throws Exception {
661
+ List <String > uri = Arrays .asList (PROVISIONING , ACCOUNTS , accountId , SUB_ACCOUNTS , subAccountId , ACCESS_KEYS , accessKey );
662
+ return callAccountApi (Api .HttpMethod .PUT , uri , ObjectUtils .asMap ("name" , name , "enabled" , enabled ), options );
663
+ }
664
+
665
+ /**
666
+ * Deletes an existing access key for this sub account id.
667
+ * @param subAccountId The id of the user group.
668
+ * @param accessKey The key of the access key.
669
+ * @param options Generic advanced options map, see online documentation.
670
+ * @return "message": "ok".
671
+ * @throws Exception If the request fails.
672
+ */
673
+ public ApiResponse deleteAccessKey (String subAccountId , String accessKey , Map <String , Object > options ) throws Exception {
674
+ List <String > uri = Arrays .asList (PROVISIONING , ACCOUNTS , accountId , SUB_ACCOUNTS , subAccountId , ACCESS_KEYS , accessKey );
675
+ return callAccountApi (Api .HttpMethod .DELETE , uri , Collections .<String , Object >emptyMap (), options );
676
+ }
677
+
622
678
/**
623
679
* Private helper method for users api calls
624
680
* @param method Http method
0 commit comments