Creates wf instances.
        Args:
            roles (list): role list

        Returns:
            (list): wf instances
339800
def create_wf_instances(self, roles=None):
        

        # if roles specified then create an instance for each role
        # else create only one instance

        if roles:
            wf_instances = [
                WFInstance(
                    wf=self.wf,
                    current_actor=role,
                    task=self,
                    name=self.wf.name
                ) for role in roles
                ]
        else:
            wf_instances = [
                WFInstance(
                    wf=self.wf,
                    task=self,
                    name=self.wf.name
                )
            ]

        # if task type is not related with objects save instances immediately.
        if self.task_type in ["C", "D"]:
            return [wfi.save() for wfi in wf_instances]

        # if task type is related with its objects, save populate instances per object
        else:
            wf_obj_instances = []
            for wfi in wf_instances:
                role = wfi.current_actor if self.task_type == "A" else None
                keys = self.get_object_keys(role)
                wf_obj_instances.extend(
                    [WFInstance(
                        wf=self.wf,
                        current_actor=role,
                        task=self,
                        name=self.wf.name,
                        wf_object=key,
                        wf_object_type=self.object_type
                    ).save() for key in keys]
                )

            return wf_obj_instances
804501
def get_instances_in_role(self, role, state_filter=None):
    
    self._check_role_name(role)
    instances = []
    
    for instance in self._get_instances(self._group_name_for_role(role), 
                                       state_filter):            
      instances.append(Instance(instance.id, instance.dns_name, 
                                instance.private_dns_name, 
                                instance.private_ip_address))
      
    return instances
1079460
public void setRoles(java.util.Collection<Role> roles) {
        if (roles == null) {
            this.roles = null;
            return;
        }

        this.roles = new com.amazonaws.internal.SdkInternalList<Role>(roles);
    }
257153
def roles(self, clear_features=True, **field_roles):
        
        field_roles = dict((k, v.name if isinstance(v, SequenceExpr) else v)
                           for k, v in six.iteritems(field_roles))
        self._assert_ml_fields_valid(*list(six.itervalues(field_roles)))
        field_roles = dict((_get_field_name(f), MLField.translate_role_name(role))
                           for role, f in six.iteritems(field_roles))
        if field_roles:
            return _change_singleton_roles(self, field_roles, clear_features)
        else:
            return self
613923
private static Set<Role> distinctRoles(final Iterable<Assignment> assignments) {
        Set<Role> roles = new HashSet<>();
        for (Assignment assignment : assignments) {
            roles.add(assignment.getRole());
        }
        return roles;
    }
683735
def create_role(*_, **kwargs):
    
    click.echo(green('\nCreating new role:'))
    click.echo(green('-' * 40))

    with get_app().app_context():
        role = Role(**kwargs)
        result = role_service.save(role)
        if not isinstance(result, Role):
            print_validation_errors(result)

        click.echo(green('Created: ') + str(role) + '\n')
1166219
def update_roles(role_ids)
      @roles = []
      role_ids.each do |id|
        # It is posible for members to have roles that do not exist
        # on the server any longer. See https://github.com/meew0/discordrb/issues/371
        role = @server.role(id)
        @roles << role if role
      end
    end
1273235
def set_roles *roles
      roles = roles.flatten
      raise ArgumentError, "For a single role strategy you can only set one role, was: #{roles.flatten}" if roles.empty? || (roles.size > 1)
      set_role roles.first
    end
18669
def create_role(self, name):
        ''''''
        models = self.session.router
        return models.role.new(name=name, owner=self)
550212
def rolegroups_to_embed *rolegroups
      rolegroups.flatten.inject([]) do |res, role| 
        res << create_role(role)
        res
      end
    end
557902
def all
      @roles = Array.new
      @connection.deploys.all.each do |deploy|
        deploy.roles.each do |role|
          @roles << role
        end
      end
      @roles
    end
54429
def roles_required(*required_rolenames):
    
    def decorator(method):
        @functools.wraps(method)
        def wrapper(*args, **kwargs):
            role_set = set([str(n) for n in required_rolenames])
            _verify_and_add_jwt()
            try:
                MissingRoleError.require_condition(
                    current_rolenames().issuperset(role_set),
                    "This endpoint requires all the following roles: {}",
                    [', '.join(role_set)],
                )
                return method(*args, **kwargs)
            finally:
                remove_jwt_data_from_app_context()
        return wrapper
    return decorator
632713
def roles_accepted(*accepted_rolenames):
    
    def decorator(method):
        @functools.wraps(method)
        def wrapper(*args, **kwargs):
            role_set = set([str(n) for n in accepted_rolenames])
            _verify_and_add_jwt()
            try:
                MissingRoleError.require_condition(
                    not current_rolenames().isdisjoint(role_set),
                    "This endpoint requires one of the following roles: {}",
                    [', '.join(role_set)],
                )
                return method(*args, **kwargs)
            finally:
                remove_jwt_data_from_app_context()
        return wrapper
    return decorator
1335640
def policies(options = {})
      batches = Enumerator.new do |y|
        options = options.merge(role_name: @name)
        resp = @client.list_role_policies(options)
        resp.each_page do |page|
          batch = []
          page.data.policy_names.each do |p|
            batch << RolePolicy.new(
              role_name: @name,
              name: p,
              client: @client
            )
          end
          y.yield(batch)
        end
      end
      RolePolicy::Collection.new(batches)
    end
834266
def set_roles *roles
      roles = roles.to_symbols_uniq
      return clear! if roles.empty?
      set_ds_field bitmask.write(roles.to_symbols)
    end
160863
public Set<String> roles() {
		return frameworkInfo.hasRole() && !"*".equals(frameworkInfo.getRole()) ?
			Collections.singleton(frameworkInfo.getRole()) : Collections.emptySet();
	}
491838
def add_role(user, roles):
        
        def _add_role(role):
            user_role = UserRole()
            user_role.user_id = user.user_id
            user_role.role_id = role.role_id
            db.session.add(user_role)
            db.session.commit()
        [_add_role(role) for role in roles]