Search in sources :

Example 1 with Binding

use of com.google.api.services.cloudresourcemanager.model.Binding in project google-cloud-java by GoogleCloudPlatform.

the class PolicyMarshaller method toPb.

@Override
protected com.google.api.services.cloudresourcemanager.model.Policy toPb(Policy policy) {
    com.google.api.services.cloudresourcemanager.model.Policy policyPb = new com.google.api.services.cloudresourcemanager.model.Policy();
    List<Binding> bindingPbList = new LinkedList<>();
    for (Map.Entry<Role, Set<Identity>> binding : policy.getBindings().entrySet()) {
        Binding bindingPb = new Binding();
        bindingPb.setRole(binding.getKey().getValue());
        bindingPb.setMembers(Lists.transform(new ArrayList<>(binding.getValue()), new Function<Identity, String>() {

            @Override
            public String apply(Identity identity) {
                return IDENTITY_STR_VALUE_FUNCTION.apply(identity);
            }
        }));
        bindingPbList.add(bindingPb);
    }
    policyPb.setBindings(bindingPbList);
    policyPb.setEtag(policy.getEtag());
    policyPb.setVersion(policy.getVersion());
    return policyPb;
}
Also used : Policy(com.google.cloud.Policy) Binding(com.google.api.services.cloudresourcemanager.model.Binding) ImmutableSet(com.google.common.collect.ImmutableSet) Set(java.util.Set) ArrayList(java.util.ArrayList) LinkedList(java.util.LinkedList) Role(com.google.cloud.Role) Function(com.google.common.base.Function) Identity(com.google.cloud.Identity) HashMap(java.util.HashMap) Map(java.util.Map)

Aggregations

Binding (com.google.api.services.cloudresourcemanager.model.Binding)1 Identity (com.google.cloud.Identity)1 Policy (com.google.cloud.Policy)1 Role (com.google.cloud.Role)1 Function (com.google.common.base.Function)1 ImmutableSet (com.google.common.collect.ImmutableSet)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 LinkedList (java.util.LinkedList)1 Map (java.util.Map)1 Set (java.util.Set)1