Add group/org/domain/role-to-customer or delete lookup entry.
171426
def cli(obj, customer, match, delete):
    """"""
    client = obj['client']
    if delete:
        client.delete_customer(delete)
    else:
        if not customer:
            raise click.UsageError('Missing option "--customer".')
        if not match:
            raise click.UsageError('Missing option "--org" / "--group" / "--domain" / "--role".')
        try:
            customer = client.create_customer(customer, match)
        except Exception as e:
            click.echo('ERROR: {}'.format(e))
            sys.exit(1)
        click.echo(customer.id)
169779
@Override
	public void removeByG_C_O(long groupId, long commerceAccountId,
		int orderStatus) {
		for (CommerceOrder commerceOrder : findByG_C_O(groupId,
				commerceAccountId, orderStatus, QueryUtil.ALL_POS,
				QueryUtil.ALL_POS, null)) {
			remove(commerceOrder);
		}
	}
717231
def roles_add(user, role):
    """"""
    user, role = _datastore._prepare_role_modify_args(user, role)
    if user is None:
        raise click.UsageError('Cannot find user.')
    if role is None:
        raise click.UsageError('Cannot find role.')
    if _datastore.add_role_to_user(user, role):
        click.secho('Role "{0}" added to user "{1}" '
                    'successfully.'.format(role, user), fg='green')
    else:
        raise click.UsageError('Cannot add role to user.')
1000561
protected function insertRoleServiceAccess()
    {
        $rolesInZip = $this->package->getResourceFromZip('system/role.json');
        $imported = false;

        if (!empty($rolesInZip)) {
            try {
                foreach ($rolesInZip as $riz) {
                    $rsa = $riz['role_service_access_by_role_id'];
                    $role = Role::whereName($riz['name'])->first();
                    if (!empty($role) && !empty($rsa)) {
                        $newRoleId = $role->id;
                        $cleanedRsa = [];
                        foreach ($rsa as $r) {
                            $originId = $r['id'];
                            $this->fixCommonFields($r);
                            $newServiceId = $this->getNewServiceId($r['service_id']);

                            if (empty($newServiceId) && !empty($r['service_id'])) {
                                $this->log(
                                    'warning',
                                    'Skipping relation role_service_access_by_role_id with id ' .
                                    $originId .
                                    ' for Role ' .
                                    $riz['name'] .
                                    '. Service not found for ' .
                                    $r['service_id']
                                );
                                continue;
                            }

                            $r['service_id'] = $newServiceId;
                            $r['role_id'] = $newRoleId;

                            if ($this->isDuplicateRoleServiceAccess($r)) {
                                $this->log(
                                    'notice',
                                    'Skipping duplicate role_service_access relation with id ' . $originId . '.'
                                );
                                continue;
                            }

                            $cleanedRsa[] = $r;
                        }

                        if (!empty($cleanedRsa)) {
                            $roleUpdate = ['role_service_access_by_role_id' => $cleanedRsa];
                            $result =
                                ServiceManager::handleRequest(
                                    'system', Verbs::PATCH, 'role/' . $newRoleId, [], [], $roleUpdate, null, true, true
                                );
                            if ($result->getStatusCode() >= 300) {
                                throw ResponseFactory::createExceptionFromResponse($result);
                            }
                            $imported = true;
                        }
                    } elseif (!empty($rsa) && empty($role)) {
                        $this->log(
                            'warning',
                            'Skipping all Role Service Access for ' . $riz['name'] . ' No imported role found.'
                        );
                        \Log::debug('Skipped Role Service Access.', $riz);
                    } else {
                        $this->log('notice', 'No Role Service Access for role ' . $riz['name']);
                    }
                }
            } catch (\Exception $e) {
//                if ($e->getCode() === HttpStatusCodes::HTTP_FORBIDDEN) {
//                    $this->log(
//                        'error',
//                        'Failed to insert role service access records for roles. ' .
//                        $this->getErrorDetails($e)
//                    );
//                }
//                throw new InternalServerErrorException(
//                    'Failed to insert role service access records for roles. ' .
//                    $this->getErrorDetails($e)
//                );
                $this->throwExceptions($e, 'Failed to insert role service access records for roles');
            }
        }

        return $imported;
    }
785975
def add_user_role(self, user, role):
        
        self.service.add_user_role(
            user, role,
            self.url_prefix, self.auth, self.session, self.session_send_opts)
1339243
def roles_remove(user, role):
    """"""
    user, role = _datastore._prepare_role_modify_args(user, role)
    if user is None:
        raise click.UsageError('Cannot find user.')
    if role is None:
        raise click.UsageError('Cannot find role.')
    if _datastore.remove_role_from_user(user, role):
        click.secho('Role "{0}" removed from user "{1}" '
                    'successfully.'.format(role, user), fg='green')
    else:
        raise click.UsageError('Cannot remove role from user.')
651962
public function addMissingRoles()
    {
        if (!get_role('author')) {
            add_role(
                'author',
                'Author',
                array(
                    'upload_files'           => true,
                    'edit_posts'             => true,
                    'edit_published_posts'   => true,
                    'publish_posts'          => true,
                    'read'                   => true,
                    'level_2'                => true,
                    'level_1'                => true,
                    'level_0'                => true,
                    'delete_posts'           => true,
                    'delete_published_posts' => true
                )
            );

            delete_option('_author_role_bkp');
        }
    }
931705
def add(self, adgroup_id, keyword_prices, nick=None):
        ''''''
        request = TOPRequest('xxxxx.xxxxx.keywords.add')
        request['adgroup_id'] = adgroup_id
        request['keyword_prices'] = keyword_prices
        if nick!=None: request['nick'] = nick
        self.create(self.execute(request), models = {'result':Keyword})
        return self.result
442578
def remove_domain_user_role(request, user, role, domain=None):
    """"""
    manager = keystoneclient(request, admin=True).roles
    return manager.revoke(role, user=user, domain=domain)
298454
def role_delete(role_id, endpoint_id):
    
    client = get_client()
    res = client.delete_endpoint_role(endpoint_id, role_id)
    formatted_print(res, text_format=FORMAT_TEXT_RAW, response_key="message")
1343204
protected function addRole()
    {
        if (!$this->isError()) {
            $id = $this->role->add($this->getSubmitted());
            if (empty($id)) {
                $this->errorAndExit($this->text('Unexpected result'));
            }
            $this->line($id);
        }
    }
387914
@POST
    @Path("/{name}" + ServerAPI.GET_CORPORATE_GROUPIDS)
    public Response addCorporateGroupIdPrefix(@Auth final DbCredential credential, @PathParam("name") final String organizationId, final String corporateGroupId){
        LOG.info("Got an add a corporate groupId prefix request for organization " + organizationId +".");
        if(!credential.getRoles().contains(DbCredential.AvailableRoles.DATA_UPDATER)){
            throw new WebApplicationException(Response.status(Response.Status.UNAUTHORIZED).build());
        }

        if(corporateGroupId == null || corporateGroupId.isEmpty()){
            LOG.error("No corporate GroupId to add!");
            throw new WebApplicationException(Response.serverError().status(HttpStatus.BAD_REQUEST_400)
                    .entity("CorporateGroupId to add should be in the query content.").build());
        }

        getOrganizationHandler().addCorporateGroupId(organizationId, corporateGroupId);
        return Response.ok().status(HttpStatus.CREATED_201).build();
    }
686863
function ContactsGroupsAssignmentsAdd(options, contactId, groupId) {
    ActionAbstract.call(this, options);
    this._groupId = groupId;
    this._contactId = contactId;
}
73463
@Override
	public void deleteRole(String rolename) throws RolesException {
		if (role_list.containsKey(rolename)) {
			List<String> users_with_role = role_list.get(rolename);
			for (String user : users_with_role) {
				// Remove the role from this user
				List<String> roles_of_user = user_list.get(user);
				roles_of_user.remove(rolename);
				user_list.put(user, roles_of_user);

				// Update our file_store
				String roles = StringUtils.join(roles_of_user.toArray(new String[0]), ",");
				file_store.setProperty(user, roles);
			}
			// Remove the role entry
			role_list.remove(rolename);

			// And commit the file_store to disk
			try {
				saveRoles();
			} catch (IOException e) {
				throw new RolesException(e);
			}
		} else {
			throw new RolesException("Cannot find role '" + rolename + "'!");
		}
	}
53470
public boolean addRoleForUserInDomain(String user, String role, String domain) {
        return addGroupingPolicy(user, role, domain);
    }
718623
def put(self, user_id):
        """"""
        self.reqparse.add_argument('roles', type=str, action='append')
        args = self.reqparse.parse_args()
        auditlog(event='user.create', actor=session['user'].username, data=args)

        user = db.User.find_one(User.user_id == user_id)
        roles = db.Role.find(Role.name.in_(args['roles']))
        if not user:
            return self.make_response('No such user found: {}'.format(user_id), HTTP.NOT_FOUND)

        if user.username == 'admin' and user.auth_system == 'builtin':
            return self.make_response('You cannot modify the built-in admin user', HTTP.FORBIDDEN)

        user.roles = []
        for role in roles:
            if role in args['roles']:
                user.roles.append(role)

        db.session.add(user)
        db.session.commit()

        return self.make_response({'message': 'User roles updated'}, HTTP.OK)
874279
def delete_role(role_id)
      @roles.reject! { |r| r.id == role_id }
      @members.each do |_, member|
        new_roles = member.roles.reject { |r| r.id == role_id }
        member.update_roles(new_roles)
      end
      @channels.each do |channel|
        overwrites = channel.permission_overwrites.reject { |id, _| id == role_id }
        channel.update_overwrites(overwrites)
      end
    end