Blindly sends user_object to SoftLayer_User_Customer::editObject

        :param int user_id: User to edit
        :param dictionary user_object: https://softlayer.github.io/reference/datatypes/SoftLayer_User_Customer/
14604
def edit_user(self, user_id, user_object):
        
        return self.user_service.editObject(user_object, id=user_id)
429437
def edit_shares(self, id, user_ids): # pylint: disable=invalid-name,redefined-builtin
        
        return self.service.edit_shares(self.base, id, user_ids)
474881
def im_open(self, *, user: str, **kwargs) -> SlackResponse:
        
        kwargs.update({"user": user})
        return self.api_call("im.open", json=kwargs)
1336129
def update_user(self, user, username=None, first_name=None, last_name=None):
		""""""
		
		if not isinstance(user, User):
			raise ValueError
		args = locals()
		url = api_url+'users/'+str(user.id)+'/'
		payload = {}
		for i in args:
			if args[i] is not None and i not in ['self', 'user']:
				payload[i] = args[i]
		r = requests.patch(url, data=json.dumps(payload), headers=self.headers)
		print(request_status(r))
		r.raise_for_status()
		return User(r.json())
25069
def create_user(self, user_object, password):
        
        LOGGER.warning("Creating User %s", user_object['username'])

        try:
            return self.user_service.createObject(user_object, password, None)
        except exceptions.SoftLayerAPIError as ex:
            if ex.faultCode == "SoftLayer_Exception_User_Customer_DelegateIamIdInvitationToPaas":
                raise exceptions.SoftLayerError("Your request for a new user was received, but it needs to be "
                                                "processed by the Platform Services API first. Barring any errors on "
                                                "the Platform Services side, your new user should be created shortly.")
            raise
1255027
def updated_by(self):
        
        if self.api and self.updated_by_id:
            return self.api._get_user(self.updated_by_id)
1004288
public function edit(): void
    {
        $oUri   = Factory::service('Uri');
        $oInput = Factory::service('Input');

        if ($oUri->segment(5) != activeUser('id') && !userHasPermission('admin:auth:accounts:editOthers')) {
            unauthorised();
        }

        // --------------------------------------------------------------------------

        /**
         * Get the user's data; loaded early because it's required for the user_meta_cols
         * (we need to know the group of the user so we can pull up the correct cols/rules)
         */

        $oSession   = Factory::service('Session', 'nails/module-auth');
        $oUserModel = Factory::model('User', 'nails/module-auth');
        $oUser      = $oUserModel->getById($oUri->segment(5));

        if (!$oUser) {
            $oSession->setFlashData('error', lang('accounts_edit_error_unknown_id'));
            $this->returnToIndex();
        }

        //  Non-superusers editing superusers is not cool
        if (!$oUserModel->isSuperuser() && userHasPermission('superuser', $oUser)) {
            $oSession->setFlashData('error', lang('accounts_edit_error_noteditable'));
            $sReturnTo = $oInput->get('return_to') ? $oInput->get('return_to') : 'admin/dashboard';
            redirect($sReturnTo);
        }

        //  Is this user editing someone other than themselves? If so, do they have permission?
        if (activeUser('id') != $oUser->id && !userHasPermission('admin:auth:accounts:editOthers')) {
            $oSession->setFlashData('error', lang('accounts_edit_error_noteditable'));
            $sReturnTo = $oInput->get('return_to') ? $oInput->get('return_to') : 'admin/dashboard';
            redirect($sReturnTo);
        }

        // --------------------------------------------------------------------------

        /**
         * Load the user_meta_cols; loaded here because it's needed for both the view
         * and the form validation
         */

        $oDb           = Factory::service('Database');
        $oConfig       = Factory::service('Config');
        $aUserMetaCols = $oConfig->item('user_meta_cols');
        $iGroupId      = (int) $oInput->post('group_id') ?: $oUser->group_id;

        if (isset($aUserMetaCols[$iGroupId])) {
            $this->data['user_meta_cols'] = $aUserMetaCols[$oUser->group_id];
        } else {
            $this->data['user_meta_cols'] = null;
        }

        //  Set fields to ignore by default
        $this->data['ignored_fields'] = [
            'id',
            'user_id',
        ];

        /**
         * If no cols were found, DESCRIBE the user_meta_app table - where possible you
         * should manually set columns, including datatypes
         */

        if (is_null($this->data['user_meta_cols'])) {

            $aResult                      = $oDb->query('DESCRIBE `' . NAILS_DB_PREFIX . 'user_meta_app`')->result();
            $this->data['user_meta_cols'] = [];

            foreach ($aResult as $col) {

                //  Always ignore some fields
                if (array_search($col->Field, $this->data['ignored_fields']) !== false) {
                    continue;
                }

                // --------------------------------------------------------------------------

                //  Attempt to detect datatype
                $sDataType = 'string';
                $type      = 'text';

                switch (strtolower($col->Type)) {

                    case 'text':
                        $type = 'textarea';
                        break;

                    case 'date':
                        $sDataType = 'date';
                        break;

                    case 'tinyint(1) unsigned':
                        $sDataType = 'bool';
                        break;
                }

                // --------------------------------------------------------------------------

                $this->data['user_meta_cols'][$col->Field] = [
                    'datatype' => $sDataType,
                    'type'     => $type,
                    'label'    => ucwords(str_replace('_', ' ', $col->Field)),
                ];
            }
        }

        // --------------------------------------------------------------------------

        //  Validate if we're saving, otherwise get the data and display the edit form
        if ($oInput->post()) {

            //  Load validation library
            $oFormValidation = Factory::service('FormValidation');

            // --------------------------------------------------------------------------

            //  Define user table rules
            $oFormValidation->set_rules('first_name', '', 'trim|required');
            $oFormValidation->set_rules('last_name', '', 'trim|required');
            $oFormValidation->set_rules('gender', '', 'required');
            $oFormValidation->set_rules('dob', '', 'valid_date');
            $oFormValidation->set_rules('timezone', '', 'required');
            $oFormValidation->set_rules('datetime_format_date', '', 'required');
            $oFormValidation->set_rules('datetime_format_time', '', 'required');

            // --------------------------------------------------------------------------

            //  Define user_meta table rules
            foreach ($this->data['user_meta_cols'] as $col => $value) {

                $sDataType = isset($value['datatype']) ? $value['datatype'] : 'string';
                $label     = isset($value['label']) ? $value['label'] : ucwords(str_replace('_', ' ', $col));

                //  Some data types require different handling
                switch ($sDataType) {

                    case 'date':
                        //  Dates must validate
                        if (isset($value['validation'])) {
                            $oFormValidation->set_rules($col, $label, $value['validation'] . '|valid_date[' . $col . ']');
                        } else {
                            $oFormValidation->set_rules($col, $label, 'valid_date[' . $col . ']');
                        }
                        break;

                    // --------------------------------------------------------------------------

                    case 'file':
                    case 'upload':
                    case 'string':
                    default:
                        if (isset($value['validation'])) {
                            $oFormValidation->set_rules($col, $label, $value['validation']);
                        }
                        break;
                }
            }

            // --------------------------------------------------------------------------

            //  Set messages
            $oFormValidation->set_message('required', lang('fv_required'));
            $oFormValidation->set_message('min_length', lang('fv_min_length'));
            $oFormValidation->set_message('alpha_dash_period', lang('fv_alpha_dash_period'));
            $oFormValidation->set_message('is_natural_no_zero', lang('fv_required'));
            $oFormValidation->set_message('valid_date', lang('fv_valid_date'));
            $oFormValidation->set_message('valid_datetime', lang('fv_valid_datetime'));

            // --------------------------------------------------------------------------

            //  Data is valid; ALL GOOD :]
            if ($oFormValidation->run()) {

                //  Define the data var
                $aData = [];

                // --------------------------------------------------------------------------

                //  If we have a profile image, attempt to upload it
                if (isset($_FILES['profile_img']) && $_FILES['profile_img']['error'] != UPLOAD_ERR_NO_FILE) {

                    $oCdn   = Factory::service('Cdn', 'nails/module-cdn');
                    $object = $oCdn->objectReplace($oUser->profile_img, 'profile-images', 'profile_img');

                    if ($object) {

                        $aData['profile_img'] = $object->id;

                    } else {

                        $this->data['upload_error'] = $oCdn->getErrors();
                        $this->data['error']        = lang('accounts_edit_error_profile_img');
                    }
                }

                // --------------------------------------------------------------------------

                if (!isset($this->data['upload_error'])) {

                    //  Set basic data

                    $aData['temp_pw']              = stringToBoolean($oInput->post('temp_pw', true));
                    $aData['reset_mfa_question']   = stringToBoolean($oInput->post('reset_mfa_question', true));
                    $aData['reset_mfa_device']     = stringToBoolean($oInput->post('reset_mfa_device', true));
                    $aData['first_name']           = $oInput->post('first_name', true);
                    $aData['last_name']            = $oInput->post('last_name', true);
                    $aData['username']             = $oInput->post('username', true);
                    $aData['gender']               = $oInput->post('gender', true);
                    $aData['dob']                  = $oInput->post('dob', true);
                    $aData['dob']                  = !empty($aData['dob']) ? $aData['dob'] : null;
                    $aData['timezone']             = $oInput->post('timezone', true);
                    $aData['datetime_format_date'] = $oInput->post('datetime_format_date', true);
                    $aData['datetime_format_time'] = $oInput->post('datetime_format_time', true);

                    if ($oInput->post('password', true)) {
                        $aData['password'] = $oInput->post('password', true);
                    }

                    //  Set meta data
                    foreach ($this->data['user_meta_cols'] as $col => $value) {

                        $mValue = $oInput->post($col, true);

                        //  Should the field be made null on empty?
                        if (!empty($value['nullOnEmpty']) && empty($mValue)) {
                            $mValue = null;
                        }

                        switch ($value['datatype']) {

                            case 'bool':
                            case 'boolean':
                                //  Convert all to boolean from string
                                $aData[$col] = stringToBoolean($mValue);
                                break;

                            case 'file':
                            case 'upload':
                                //  File uploads should be an integer, or if empty, null
                                $aData[$col] = (int) $mValue ?: null;
                                break;

                            default:
                                $aData[$col] = $mValue;
                                break;
                        }
                    }

                    // --------------------------------------------------------------------------

                    //  Update account
                    if ($oUserModel->update($oInput->post('id'), $aData)) {

                        $name                  = $oInput->post('first_name', true) . ' ' . $oInput->post('last_name', true);
                        $this->data['success'] = lang('accounts_edit_ok', [title_case($name)]);
                        // --------------------------------------------------------------------------

                        //  Set Admin changelogs
                        $name = '#' . number_format($oInput->post('id'));

                        if ($aData['first_name']) {
                            $name .= ' ' . $aData['first_name'];
                        }

                        if ($aData['last_name']) {
                            $name .= ' ' . $aData['last_name'];
                        }

                        foreach ($aData as $field => $value) {
                            if (isset($oUser->$field)) {
                                $this->oChangeLogModel->add(
                                    'updated',
                                    'a',
                                    'user',
                                    $oInput->post('id'),
                                    $name,
                                    'admin/auth/accounts/edit/' . $oInput->post('id'),
                                    $field,
                                    $oUser->$field,
                                    $value,
                                    false
                                );
                            }
                        }

                        // --------------------------------------------------------------------------

                        //  refresh the user object
                        $oUser = $oUserModel->getById($oInput->post('id'));

                        //  The account failed to update, feedback to user
                    } else {

                        $this->data['error'] = lang(
                            'accounts_edit_fail',
                            implode(', ', $oUserModel->getErrors())
                        );
                    }
                }

                //  Update failed for another reason
            } else {

                $this->data['error'] = lang('fv_there_were_errors');
            }
        }
        //  End POST() check

        // --------------------------------------------------------------------------

        //  Get the user's meta data
        if ($this->data['user_meta_cols']) {

            $oDb->select(implode(',', array_keys($this->data['user_meta_cols'])));
            $oDb->where('user_id', $oUser->id);
            $aUserMeta = (array) $oDb->get(NAILS_DB_PREFIX . 'user_meta_app')->row();

        } else {
            $aUserMeta = [];
        }

        // --------------------------------------------------------------------------

        //  Get the user's email addresses
        $this->data['user_emails'] = $oUserModel->getEmailsForUser($oUser->id);

        // --------------------------------------------------------------------------

        $this->data['user_edit'] = $oUser;
        $this->data['user_meta'] = $aUserMeta;

        //  Page Title
        $this->data['page']->title = lang(
            'accounts_edit_title',
            title_case($oUser->first_name . ' ' . $oUser->last_name)
        );

        //  Get the groups, timezones and languages
        $oUserGroupModel      = Factory::model('UserGroup', 'nails/module-auth');
        $this->data['groups'] = $oUserGroupModel->getAll();

        $oLanguageService        = Factory::service('Language');
        $this->data['languages'] = $oLanguageService->getAllEnabledFlat();

        $oDateTimeService               = Factory::service('DateTime');
        $this->data['timezones']        = $oDateTimeService->getAllTimezone();
        $this->data['date_formats']     = $oDateTimeService->getAllDateFormat();
        $this->data['time_formats']     = $oDateTimeService->getAllTimeFormat();
        $this->data['default_timezone'] = $oDateTimeService->getTimezoneDefault();

        //  Fetch any user uploads
        if (Components::exists('nails/module-cdn')) {
            $oCdn                       = Factory::service('Cdn', 'nails/module-cdn');
            $this->data['user_uploads'] = $oCdn->getObjectsForUser($oUser->id);
        }

        // --------------------------------------------------------------------------

        if (activeUser('id') == $oUser->id) {

            switch (strtolower(activeUser('gender'))) {

                case 'male':
                    $this->data['notice'] = lang('accounts_edit_editing_self_m');
                    break;

                case 'female':
                    $this->data['notice'] = lang('accounts_edit_editing_self_f');
                    break;

                default:
                    $this->data['notice'] = lang('accounts_edit_editing_self_u');
                    break;
            }
        }

        $oUserPasswordModel          = Factory::model('UserPassword', 'nails/module-auth');
        $this->data['passwordRules'] = $oUserPasswordModel->getRulesAsString($oUser->group_id);

        // --------------------------------------------------------------------------

        //  Load views
        Helper::loadView('edit');
    }
420881
def attach_user(context, id, user_id):
    
    result = remoteci.add_user(context, id=id,
                               user_id=user_id)
    utils.format_output(result, context.format, ['remoteci_id', 'user_id'])
977228
def update_filter_dict(d, user, status):
    
    if user is not None:
        if not user.id:
            return None
        d['user'] = user
    if status is not None:
        d['status'] = status
302577
def update(self, id):
        """"""
        # url('LayerTemplates', id=ID)
        lt = meta.Session.query(LayerTemplate).get(id)
        # use following query for getting a layertemplate owned by current user
        #lt = self._get_lt_from_user_by_id(c.user, id)
        if lt is None:
            abort(404)
        content = request.environ['wsgi.input'].read(int(request.environ['CONTENT_LENGTH']))
        content = content.decode('utf8')
        content = simplejson.loads(content)        
        lt.name = content['name']
        lt.comment = content['comment']
        lt.json = content['json']
        meta.Session.commit()
        response.status = 201
812103
def upload_intercom_user(obj_id):
    """"""
    UserModel = get_user_model()
    intercom_user = False
    instance = UserModel.objects.get(pk=obj_id)
    data = instance.get_intercom_data()

    if not getattr(settings, "SKIP_INTERCOM", False):
        try:
            intercom_user = intercom.users.create(**data)
        except errors.ServiceUnavailableError:
            pass

    if intercom_user:
        UserModel.objects.filter(pk=obj_id).update(
            intercom_last_api_response=intercom_user.to_dict(),
            intercom_api_response_timestamp=make_aware(datetime.now(), pytz.UTC)
        )
256381
def cli(env, user, template):
    
    mgr = SoftLayer.UserManager(env.client)
    user_id = helpers.resolve_id(mgr.resolve_ids, user, 'username')

    user_template = {}
    if template is not None:
        try:
            template_object = json.loads(template)
            for key in template_object:
                user_template[key] = template_object[key]
        except ValueError as ex:
            raise exceptions.ArgumentError("Unable to parse --template. %s" % ex)

    result = mgr.edit_user(user_id, user_template)
    if result:
        click.secho("%s updated successfully" % (user), fg='green')
    else:
        click.secho("Failed to update %s" % (user), fg='red')
961345
def update_user(resource_root, user):
  
  return call(resource_root.put,
      '%s/%s' % (USERS_PATH, user.name), ApiUser, data=user)
1241689
def update_user_type(self):
        
        if self.rb_tutor.isChecked():
            self.user_type = 'tutor'
        elif self.rb_student.isChecked():
            self.user_type = 'student'
        self.accept()
1352324
def add_current_user_is_applied_representation(func):
  
  @wraps(func)
  def _impl(self, instance):
    # We pop current_user_is_applied field to avoid AttributeError on default Serializer.to_representation
    ret = func(self, instance)

    user = self.context["request"].user
    applied = False
    if not user.is_anonymous():
      try:
        applied = models.Apply.objects.filter(user=user, project=instance).count() > 0
      except:
        pass

    ret["current_user_is_applied"] = applied

    return ret
  return _impl
854360
def upload_not_registered_user_data(data):
    
    if type(data) != dict:
        raise NotImplementedError("Incorrect data type")

    if not data.get("email"):
        raise KeyError("user_id as user.intercom_id or email is required")

    if not getattr(settings, "SKIP_INTERCOM", False):
        intercom_data = {
            "email": data.get("email"),
            "name": data.get("name"),
            "last_request_at": now().strftime("%s"),
        }
        del(data["email"])
        if data.get("name"):
            del(data["name"])
        if data:
            intercom_data["custom_attributes"] = data
        try:
            intercom.users.create(**intercom_data)
        except errors.ServiceUnavailableError:
            pass
1302240
def user(self, user):
        
        if user is None:
            raise ValueError("Invalid value for `user`, must not be `None`")
        if user is not None and len(user) > 1024:
            raise ValueError("Invalid value for `user`, length must be less than or equal to `1024`")

        self._user = user