Skip to main content

RevokeRoleFromAPIUser

Method Details​

Description: 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 within the group hierarchy. The API user will no longer be able to perform operations that require the revoked role.

Required Roles: Check proto file for roles

Parameters:

  • Name (string) (required): Name of the API user to revoke a role from. Format: api_users/{ULIDv2}
  • Role (string) (required): Role to revoke from the API user in the format groups/{ULIDv2}/{role_id}. The role_id corresponds to a value from the meshtrade.iam.role.v1.Role enum.

Returns: APIUser

Method Type: Unknown

Code Examples​

package main

import (
"context"
"log"

api_userv1 "github.com/meshtrade/api/go/iam/api_user/v1"
rolev1 "github.com/meshtrade/api/go/iam/role/v1"
)

func main() {
ctx := context.Background()

// Default configuration is used and credentials come from MESH_API_CREDENTIALS
// environment variable or default discovery methods. Zero config required
// unless you want custom configuration.
service, err := api_userv1.NewApiUserService()
if err != nil {
log.Fatalf("Failed to create service: %v", err)
}
defer service.Close()

// Revoke role from existing API user
request := &api_userv1.RevokeRoleFromAPIUserRequest{
Name: "api_users/01HN2ZXQJ8K9M0L1N3P2Q4R5T6", // API user to revoke role from
Role: rolev1.Role_ROLE_IAM_VIEWER.FullResourceNameFromGroupName(service.Group()),
}

// Call the RevokeRoleFromAPIUser method
apiUser, err := service.RevokeRoleFromAPIUser(ctx, request)
if err != nil {
log.Fatalf("RevokeRoleFromAPIUser failed: %v", err)
}

// Role has been successfully revoked
log.Printf("Role revoked successfully:")
log.Printf(" API User: %s", apiUser.Name)
log.Printf(" Display Name: %s", apiUser.DisplayName)
log.Printf(" Remaining Roles: %d", len(apiUser.Roles))
}

Advanced Configuration​

For advanced client configuration options (custom endpoints, TLS settings, timeouts), see the SDK Configuration Guide.

Other Methods​