Skip to content

Commit 0f1d76e

Browse files
BRBussyclaude
andauthored
Upgrade IAM authentication API: Batch role operations and standardized role paths (#76)
* Fix IAM service proto field numbering and validation Corrects field numbering in user service requests (roles field 4→2), adds missing required validation to name fields, and updates documentation for consistency with plural role operations. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * Update IAM resource protos for role path format changes Updates APIUser and User resource definitions to use new role path format (groups/{id}/roles/{role_id}), adds required validation to roles fields, and enhances validation to support variable-length role IDs (7-8 digits). Also fixes protobuf syntax by removing trailing commas from buf.validate options. Breaking: User.roles field number changed from 6 to 5. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * Fix APIUser documentation capitalization Updates "api user" to "API user" in the roles field documentation for consistent capitalization throughout the file. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * Fix API user documentation capitalization consistency Standardizes capitalization across api_user.proto documentation: - "api user" → "API user" (3 instances) - "api key" → "API user" (display_name field - corrects incorrect reference) - "api keys" → "API keys" (2 instances in enum comments) No field numbers or validation logic modified. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * Fix sequential field numbering in api_user.proto Corrects field numbers to be sequential (1-6) removing gaps: - display_name: 4 → 3 - state: 5 → 4 - roles: 6 → 5 - api_key: 7 → 6 user.proto already has correct sequential numbering (1-4). 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * fix field numbering * allow empty role slice on user and api user * remove unused class file * Update Python SDK for new role format and batch operations Update role utilities to use 4-part format (groups/{id}/roles/{role}), update service interfaces for batch role assignment/revocation, and update all tests and validation. All 38 IAM tests passing. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * Add role path utility functions and tests to TypeScript SDK Implements utility functions for the new role path format (groups/{ULIDv2}/roles/{role_id}): - createRolePath: constructs valid role paths with ULID and role ID validation - isValidRolePath: validates role path format including Crockford base32 alphabet - extractRoleIdFromPath: extracts role ID from valid paths - extractGroupFromRolePath: extracts group resource name from paths Includes comprehensive test suite with 39 tests covering: - Valid 7 and 8 digit role IDs - ULID validation (Crockford base32, excludes I, L, O, U) - Old format rejection - Edge cases and boundary conditions All 362 tests passing. TypeScript build and lint successful. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * Update Go SDK for role path format and batch operations - Add /roles/ segment to role paths (groups/{id}/roles/{role_id}) - Change singular to plural operations (AssignRole→AssignRoles, RevokeRole→RevokeRoles) - Update field from Role string to Roles []string for batch operations - Add comprehensive RevokeRoles validation test suites - Update all test cases to new role path format (47-48 chars, pattern [1-9][0-9]{6,7}) - Regenerate protobuf files with updated message types and field numbering 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * Update documentation for batch role operations Remove old singular role assignment/revocation documentation and add new batch operations documentation for both API users and regular users. Changes: - Remove assign-role-to-a-p-i-user and revoke-role-from-a-p-i-user docs - Remove assign-role-to-user documentation - Add assign-roles-to-a-p-i-user and revoke-roles-from-a-p-i-user docs - Add assign-roles-to-user and revoke-roles-from-user docs - Update API user service index with new method names 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent 2267ca0 commit 0f1d76e

60 files changed

Lines changed: 2398 additions & 1206 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

docs/docs/api-reference/iam/api_user/v1/index.mdx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,11 @@ Deactivates an API user, disabling API key authentication. Use this to temporari
7272

7373
### Role Management
7474

75-
#### [AssignRoleToAPIUser](/docs/api-reference/iam/api_user/v1/service/assign-role-to-a-p-i-user)
76-
Assigns a role to an existing API user within the authenticated group context. The role assignment enables the API user to perform operations according to the permissions associated with that role. Use this to grant new capabilities to an API user.
75+
#### [AssignRolesToAPIUser](/docs/api-reference/iam/api_user/v1/service/assign-roles-to-a-p-i-user)
76+
Assigns roles to an existing API user within the authenticated group context. The role assignments enable the API user to perform operations according to the permissions associated with those roles. Use this to grant new capabilities to an API user.
7777

78-
#### [RevokeRoleFromAPIUser](/docs/api-reference/iam/api_user/v1/service/revoke-role-from-a-p-i-user)
79-
Revokes a role from an existing API user within the authenticated group context. The role revocation removes the permissions associated with that role from the API user. Use this to restrict API user capabilities or implement principle of least privilege.
78+
#### [RevokeRolesFromAPIUser](/docs/api-reference/iam/api_user/v1/service/revoke-roles-from-a-p-i-user)
79+
Revokes roles from an existing API user within the authenticated group context. The role revocations remove the permissions associated with those roles from the API user. Use this to restrict API user capabilities or implement principle of least privilege.
8080

8181
## Authentication & Authorization
8282

docs/docs/api-reference/iam/api_user/v1/service/assign-role-to-a-p-i-user/example.go

Lines changed: 0 additions & 40 deletions
This file was deleted.

docs/docs/api-reference/iam/api_user/v1/service/assign-role-to-a-p-i-user/example.java

Lines changed: 0 additions & 34 deletions
This file was deleted.

docs/docs/api-reference/iam/api_user/v1/service/assign-role-to-a-p-i-user/example.py

Lines changed: 0 additions & 33 deletions
This file was deleted.
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
package main
2+
3+
import (
4+
"context"
5+
"log"
6+
7+
api_userv1 "github.com/meshtrade/api/go/iam/api_user/v1"
8+
)
9+
10+
func main() {
11+
ctx := context.Background()
12+
13+
// Default configuration is used and credentials come from MESH_API_CREDENTIALS
14+
// environment variable or default discovery methods. Zero config required
15+
// unless you want custom configuration.
16+
service, err := api_userv1.NewApiUserService()
17+
if err != nil {
18+
log.Fatalf("Failed to create service: %v", err)
19+
}
20+
defer service.Close()
21+
22+
// Create request with service-specific parameters
23+
request := &api_userv1.AssignRolesToAPIUserRequest{
24+
// FIXME: Populate service-specific request fields
25+
}
26+
27+
// Call the AssignRolesToAPIUser method
28+
apiUser, err := service.AssignRolesToAPIUser(ctx, request)
29+
if err != nil {
30+
log.Fatalf("AssignRolesToAPIUser failed: %v", err)
31+
}
32+
33+
// FIXME: Add relevant response object usage
34+
log.Printf("AssignRolesToAPIUser successful: %+v", apiUser)
35+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import co.meshtrade.api.iam.api_user.v1.ApiUserService;
2+
import co.meshtrade.api.iam.api_user.v1.Service.AssignRolesToAPIUserRequest;
3+
import co.meshtrade.api.iam.api_user.v1.ApiUser.APIUser;
4+
5+
import java.util.Optional;
6+
7+
public class AssignRolesToAPIUserExample {
8+
public static void main(String[] args) {
9+
// Default configuration is used and credentials come from MESH_API_CREDENTIALS
10+
// environment variable or default discovery methods. Zero config required
11+
// unless you want custom configuration.
12+
try (ApiUserService service = new ApiUserService()) {
13+
// Create request with service-specific parameters
14+
AssignRolesToAPIUserRequest request = AssignRolesToAPIUserRequest.newBuilder()
15+
// FIXME: Populate service-specific request fields
16+
.build();
17+
18+
// Call the AssignRolesToAPIUser method
19+
APIUser apiUser = service.assignRolesToAPIUser(request, Optional.empty());
20+
21+
// FIXME: Add relevant response object usage
22+
System.out.println("AssignRolesToAPIUser successful: " + apiUser);
23+
} catch (Exception e) {
24+
System.err.println("AssignRolesToAPIUser failed: " + e.getMessage());
25+
e.printStackTrace();
26+
}
27+
}
28+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
from meshtrade.iam.api_user.v1 import (
2+
ApiUserService,
3+
AssignRolesToAPIUserRequest,
4+
)
5+
6+
7+
def main():
8+
# Default configuration is used and credentials come from MESH_API_CREDENTIALS
9+
# environment variable or default discovery methods. Zero config required
10+
# unless you want custom configuration.
11+
service = ApiUserService()
12+
13+
with service:
14+
# Create request with service-specific parameters
15+
request = AssignRolesToAPIUserRequest(
16+
# FIXME: Populate service-specific request fields
17+
)
18+
19+
# Call the AssignRolesToAPIUser method
20+
api_user = service.assign_roles_to_a_p_i_user(request)
21+
22+
# FIXME: Add relevant response object usage
23+
print("AssignRolesToAPIUser successful:", api_user)
24+
25+
26+
if __name__ == "__main__":
27+
main()
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# AssignRolesToAPIUser
2+
{/*
3+
Generated by protoc-gen-meshdoc. DO NOT EDIT.
4+
source: meshtrade/iam/api_user/v1/service.proto
5+
*/}
6+
7+
import CodeBlock from '@theme/CodeBlock';
8+
import Tabs from '@theme/Tabs';
9+
import TabItem from '@theme/TabItem';
10+
11+
import GoExample from '!!raw-loader!./example.go';
12+
import PythonExample from '!!raw-loader!./example.py';
13+
import JavaExample from '!!raw-loader!./example.java';
14+
import Proto from '!!raw-loader!../../../../../../../../proto/meshtrade/iam/api_user/v1/service.proto';
15+
16+
17+
18+
## Method Details
19+
20+
**Description:** Assign roles to an existing api user within the authenticated group context.
21+
22+
The role assignment enables the api user to perform operations according
23+
to the permissions associated with that role within the group hierarchy.
24+
25+
**Required Roles:** Check proto file for roles
26+
27+
**Parameters:**
28+
- `Name` (string) (required): Name of the API user to assign roles to in the format api_users/\{ULIDv2\}.
29+
- `Roles` (string): Roles to assign to the API user in the format groups/\{ULIDv2\}/roles/\{role_id\}.
30+
The role_id corresponds to a value from the meshtrade.iam.role.v1.Role enum.
31+
32+
**Returns:** APIUser
33+
34+
**Method Type:** Unknown
35+
36+
## Code Examples
37+
38+
<Tabs>
39+
<TabItem value="go" label="Go">
40+
<CodeBlock language="go">{GoExample}</CodeBlock>
41+
</TabItem>
42+
<TabItem value="python" label="Python">
43+
<CodeBlock language="python">{PythonExample}</CodeBlock>
44+
</TabItem>
45+
<TabItem value="java" label="Java">
46+
<CodeBlock language="java">{JavaExample}</CodeBlock>
47+
</TabItem>
48+
<TabItem value="protobuf" label="Protobuf">
49+
<CodeBlock language="protobuf">{Proto}</CodeBlock>
50+
</TabItem>
51+
</Tabs>
52+
53+
## Advanced Configuration
54+
55+
For advanced client configuration options (custom endpoints, TLS settings, timeouts), see the [SDK Configuration Guide](/docs/architecture/sdk-configuration).
56+
57+
## Other Methods
58+
59+
- **[Iam Api User v1 Method List](/docs/api-reference/iam/api_user/v1/service)** - For Other methods

docs/docs/api-reference/iam/api_user/v1/service/revoke-role-from-a-p-i-user/example.go

Lines changed: 0 additions & 40 deletions
This file was deleted.

docs/docs/api-reference/iam/api_user/v1/service/revoke-role-from-a-p-i-user/example.java

Lines changed: 0 additions & 34 deletions
This file was deleted.

0 commit comments

Comments
 (0)