@@ -164,6 +164,26 @@ export class FusionAuthClient {
164
164
. go ( ) ;
165
165
}
166
166
167
+ /**
168
+ * Creates an API key. You can optionally specify a unique Id for the key, if not provided one will be generated.
169
+ * an API key can only be created with equal or lesser authority. An API key cannot create another API key unless it is granted
170
+ * to that API key.
171
+ *
172
+ * If an API key is locked to a tenant, it can only create API Keys for that same tenant.
173
+ *
174
+ * @param {UUID } keyId (Optional) The unique Id of the API key. If not provided a secure random Id will be generated.
175
+ * @param {APIKeyRequest } request The request object that contains all of the information needed to create the APIKey.
176
+ * @returns {Promise<ClientResponse<APIKeyResponse>> }
177
+ */
178
+ createAPIKey ( keyId : UUID , request : APIKeyRequest ) : Promise < ClientResponse < APIKeyResponse > > {
179
+ return this . start < APIKeyResponse , Errors > ( )
180
+ . withUri ( '/api/api-key' )
181
+ . withUriSegment ( keyId )
182
+ . withJSONBody ( request )
183
+ . withMethod ( "POST" )
184
+ . go ( ) ;
185
+ }
186
+
167
187
/**
168
188
* Creates an application. You can optionally specify an Id for the application, if not provided one will be generated.
169
189
*
@@ -661,6 +681,20 @@ export class FusionAuthClient {
661
681
. go ( ) ;
662
682
}
663
683
684
+ /**
685
+ * Deletes the API key for the given Id.
686
+ *
687
+ * @param {UUID } keyId The Id of the authentication API key to delete.
688
+ * @returns {Promise<ClientResponse<void>> }
689
+ */
690
+ deleteAPIKey ( keyId : UUID ) : Promise < ClientResponse < void > > {
691
+ return this . start < void , Errors > ( )
692
+ . withUri ( '/api/api-key' )
693
+ . withUriSegment ( keyId )
694
+ . withMethod ( "DELETE" )
695
+ . go ( ) ;
696
+ }
697
+
664
698
/**
665
699
* Hard deletes an application. This is a dangerous operation and should not be used in most circumstances. This will
666
700
* delete the application, any registrations for that application, metrics and reports for the application, all the
@@ -1575,6 +1609,22 @@ export class FusionAuthClient {
1575
1609
. go ( ) ;
1576
1610
}
1577
1611
1612
+ /**
1613
+ * Updates an authentication API key by given id
1614
+ *
1615
+ * @param {UUID } keyId The Id of the authentication key. If not provided a secure random api key will be generated.
1616
+ * @param {APIKeyRequest } request The request object that contains all of the information needed to create the APIKey.
1617
+ * @returns {Promise<ClientResponse<APIKeyResponse>> }
1618
+ */
1619
+ patchAPIKey ( keyId : UUID , request : APIKeyRequest ) : Promise < ClientResponse < APIKeyResponse > > {
1620
+ return this . start < APIKeyResponse , Errors > ( )
1621
+ . withUri ( '/api/api-key' )
1622
+ . withUriSegment ( keyId )
1623
+ . withJSONBody ( request )
1624
+ . withMethod ( "POST" )
1625
+ . go ( ) ;
1626
+ }
1627
+
1578
1628
/**
1579
1629
* Updates, via PATCH, the application with the given Id.
1580
1630
*
@@ -2078,6 +2128,20 @@ export class FusionAuthClient {
2078
2128
. go ( ) ;
2079
2129
}
2080
2130
2131
+ /**
2132
+ * Retrieves an authentication API key for the given id
2133
+ *
2134
+ * @param {UUID } keyId The Id of the API key to retrieve.
2135
+ * @returns {Promise<ClientResponse<APIKeyResponse>> }
2136
+ */
2137
+ retrieveAPIKey ( keyId : UUID ) : Promise < ClientResponse < APIKeyResponse > > {
2138
+ return this . start < APIKeyResponse , Errors > ( )
2139
+ . withUri ( '/api/api-key' )
2140
+ . withUriSegment ( keyId )
2141
+ . withMethod ( "GET" )
2142
+ . go ( ) ;
2143
+ }
2144
+
2081
2145
/**
2082
2146
* Retrieves a single action log (the log of a user action that was taken on a user previously) for the given Id.
2083
2147
*
@@ -3796,6 +3860,22 @@ export class FusionAuthClient {
3796
3860
. go ( ) ;
3797
3861
}
3798
3862
3863
+ /**
3864
+ * Updates an API key by given id
3865
+ *
3866
+ * @param {UUID } apiKeyId The Id of the API key to update.
3867
+ * @param {APIKeyRequest } request The request object that contains all of the information used to create the API Key.
3868
+ * @returns {Promise<ClientResponse<APIKeyResponse>> }
3869
+ */
3870
+ updateAPIKey ( apiKeyId : UUID , request : APIKeyRequest ) : Promise < ClientResponse < APIKeyResponse > > {
3871
+ return this . start < APIKeyResponse , Errors > ( )
3872
+ . withUri ( '/api/api-key' )
3873
+ . withUriSegment ( apiKeyId )
3874
+ . withJSONBody ( request )
3875
+ . withMethod ( "PUT" )
3876
+ . go ( ) ;
3877
+ }
3878
+
3799
3879
/**
3800
3880
* Updates the application with the given Id.
3801
3881
*
@@ -4398,6 +4478,49 @@ export enum Algorithm {
4398
4478
none = "none"
4399
4479
}
4400
4480
4481
+ /**
4482
+ * domain POJO to represent AuthenticationKey
4483
+ *
4484
+ * @author sanjay
4485
+ */
4486
+ export interface APIKey {
4487
+ id ?: UUID ;
4488
+ insertInstant ?: number ;
4489
+ key ?: string ;
4490
+ keyManager ?: boolean ;
4491
+ lastUpdateInstant ?: number ;
4492
+ metaData ?: APIKeyMetaData ;
4493
+ permissions ?: APIKeyPermissions ;
4494
+ tenantId ?: UUID ;
4495
+ }
4496
+
4497
+ export interface APIKeyMetaData {
4498
+ attributes ?: Record < string , string > ;
4499
+ }
4500
+
4501
+ export interface APIKeyPermissions {
4502
+ endpoints ?: Record < string , Array < string > > ;
4503
+ }
4504
+
4505
+ /**
4506
+ * Authentication key request object.
4507
+ *
4508
+ * @author Sanjay
4509
+ */
4510
+ export interface APIKeyRequest {
4511
+ apiKey ?: APIKey ;
4512
+ sourceKeyId ?: UUID ;
4513
+ }
4514
+
4515
+ /**
4516
+ * Authentication key response object.
4517
+ *
4518
+ * @author Sanjay
4519
+ */
4520
+ export interface APIKeyResponse {
4521
+ apiKey ?: APIKey ;
4522
+ }
4523
+
4401
4524
/**
4402
4525
* @author Daniel DeGroff
4403
4526
*/
0 commit comments