Java 类com.amazonaws.services.identitymanagement.model.DetachRolePolicyRequest 实例源码

项目:aws-doc-sdk-examples    文件:DetachRolePolicy.java   
public static void main(String[] args) {

        final String USAGE =
            "To run this example, supply a role name and policy arn\n" +
            "Ex: DetachRolePolicy <role-name> <policy-arn>>\n";

        if (args.length != 1) {
            System.out.println(USAGE);
            System.exit(1);
        }

        String role_name = args[0];
        String policy_arn = args[1];

        final AmazonIdentityManagement iam =
            AmazonIdentityManagementClientBuilder.defaultClient();

        DetachRolePolicyRequest request = new DetachRolePolicyRequest()
            .withRoleName(role_name)
            .withPolicyArn(policy_arn);

        DetachRolePolicyResult response = iam.detachRolePolicy(request);

        System.out.println("Successfully detached policy " + policy_arn +
                " from role " + role_name);
    }
项目:strongbox    文件:IAMPolicyManagerTest.java   
@Test
public void testDetachReadonlyRole() throws Exception {
    Principal principal = new Principal(PrincipalType.ROLE, "awesome-service");
    partiallyMockedPolicyManager.detachReadOnly(group, principal);

    // Just verifies that the attachRolePolicy method was called with the correct details.
    DetachRolePolicyRequest request = new DetachRolePolicyRequest()
            .withPolicyArn(READONLY_POLICY_ARN)
            .withRoleName(principal.name);
    verify(mockClient, times(1)).detachRolePolicy(request);
}