// NewPostUserLock handles the request and creates a new lock for the notification
// caused by the target user
772619
func NewPostUserLock() echo.HandlerFunc {

	// swagger:route POST /me/posts/{pid}/locks/{target} me post vote NewMeNewPostUserLock
	//
	// Locks the notification from the target user to the current logged user, on the specified post
	//
	// Consumes:
	// - application/json
	//
	//	Produces:
	//	- application/json
	//
	//	Security:
	//		oauth: profile_messages:write
	//
	//	Responses:
	//		default: MePostsPidLocks

	return func(c echo.Context) error {
		return user.NewPostUserLock()(c)
	}
}
1370848
func (adm AdminClient) newRequest(method string, reqData requestData) (req *http.Request, err error) {
	// If no method is supplied default to 'POST'.
	if method == "" {
		method = "POST"
	}

	// Default all requests to ""
	location := ""

	// Construct a new target URL.
	targetURL, err := adm.makeTargetURL(reqData)
	if err != nil {
		return nil, err
	}

	// Initialize a new HTTP request for the method.
	req, err = http.NewRequest(method, targetURL.String(), nil)
	if err != nil {
		return nil, err
	}

	adm.setUserAgent(req)
	for k, v := range reqData.customHeaders {
		req.Header.Set(k, v[0])
	}
	if length := len(reqData.content); length > 0 {
		req.ContentLength = int64(length)
	}
	req.Header.Set("X-Amz-Content-Sha256", hex.EncodeToString(sum256(reqData.content)))
	req.Body = ioutil.NopCloser(bytes.NewReader(reqData.content))

	req = s3signer.SignV4(*req, adm.accessKeyID, adm.secretAccessKey, "", location)
	return req, nil
}
591122
func NewUserPost(hpid uint64) (*UserPost, error) {
	return NewUserPostWhere(&UserPost{Post{Hpid: hpid}})
}
679209
func NewPostRequest(err error, req *httpdata.HTTPRequest,
	customData interface{}, u string, tags []string,
	version string, id string) *PostRequest {

	return &PostRequest{
		OccuredOn: time.Now().UTC().Format("2006-01-02T15:04:05Z"),
		Details:   newErrorDetails(err, req, customData, u, tags, version, id),
	}
}
1111129
func (r Notification_User_Subscriber_Preference) GetNotificationUserSubscriber() (resp datatypes.Notification_User_Subscriber, err error) {
	err = r.Session.DoRequest("SoftLayer_Notification_User_Subscriber_Preference", "getNotificationUserSubscriber", nil, &r.Options, &resp)
	return
}
865385
func (post *UserPost) Locks() *[]Lock {
	ret := []UserPostLock{}
	Db().Model(UserPostLock{}).Where(&UserPostLock{Hpid: post.ID()}).Scan(&ret)
	var retLockers []Lock
	for _, l := range ret {
		locker := l
		retLockers = append(retLockers, Lock(&locker))
	}

	return &retLockers
}
862043
func (s *UserService) UpdateUser(p *UpdateUserParams) (*UpdateUserResponse, error) {
	resp, err := s.cs.newRequest("updateUser", p.toURLValues())
	if err != nil {
		return nil, err
	}

	var r UpdateUserResponse
	if err := json.Unmarshal(resp, &r); err != nil {
		return nil, err
	}

	return &r, nil
}
820350
func (lock *ProjectPostLock) Sender() (user *User) {
	user, _ = NewUser(lock.User)
	return
}
614252
func (s *UsersService) CreateUser(body User, headers, queryParams map[string]interface{}) (*http.Response, error) {
	var err error

	resp, err := s.client.doReqWithBody("POST", s.client.BaseURI+"/users", &body, headers, queryParams)
	if err != nil {
		return nil, err
	}
	defer resp.Body.Close()

	return resp, err
}
1046940
func (s *Service) NewUser(w http.ResponseWriter, r *http.Request) {
	var req userRequest
	if err := json.NewDecoder(r.Body).Decode(&req); err != nil {
		invalidJSON(w, s.Logger)
		return
	}

	if err := req.ValidCreate(); err != nil {
		invalidData(w, err, s.Logger)
		return
	}

	ctx := r.Context()

	serverCtx := serverContext(ctx)
	cfg, err := s.Store.Config(serverCtx).Get(serverCtx)
	if err != nil {
		Error(w, http.StatusInternalServerError, err.Error(), s.Logger)
		return
	}

	if err := s.validRoles(serverCtx, req.Roles); err != nil {
		invalidData(w, err, s.Logger)
		return
	}

	user := &chronograf.User{
		Name:     req.Name,
		Provider: req.Provider,
		Scheme:   req.Scheme,
		Roles:    req.Roles,
	}

	if cfg.Auth.SuperAdminNewUsers {
		req.SuperAdmin = true
	}

	if err := setSuperAdmin(ctx, req, user); err != nil {
		Error(w, http.StatusUnauthorized, err.Error(), s.Logger)
		return
	}

	res, err := s.Store.Users(ctx).Add(ctx, user)
	if err != nil {
		Error(w, http.StatusBadRequest, err.Error(), s.Logger)
		return
	}

	orgID := httprouter.GetParamFromContext(ctx, "oid")
	cu := newUserResponse(res, orgID)
	location(w, cu.Links.Self)
	encodeJSON(w, http.StatusCreated, cu, s.Logger)
}
345799
func (s *UserService) NewGetUserParams(userapikey string) *GetUserParams {
	p := &GetUserParams{}
	p.p = make(map[string]interface{})
	p.p["userapikey"] = userapikey
	return p
}
231999
func (client *Client) CreateUser(uaaUserID string) (User, Warnings, error) {
	type userRequestBody struct {
		GUID string `json:"guid"`
	}

	bodyBytes, err := json.Marshal(userRequestBody{
		GUID: uaaUserID,
	})
	if err != nil {
		return User{}, nil, err
	}

	request, err := client.newHTTPRequest(requestOptions{
		RequestName: internal.PostUserRequest,
		Body:        bytes.NewReader(bodyBytes),
	})
	if err != nil {
		return User{}, nil, err
	}

	var user User
	response := cloudcontroller.Response{
		DecodeJSONResponseInto: &user,
	}

	err = client.connection.Make(request, &response)
	if err != nil {
		return User{}, response.Warnings, err
	}

	return user, response.Warnings, nil
}
795794
func (self *Notifications) Post(request *gottp.Request) {
	pending_item := new(db.PendingItem)
	request.ConvertArguments(pending_item)

	if request.GetArgument("topic") == nil {
		request.Raise(gottp.HttpError{
			http.StatusBadRequest,
			"Please provide topic for notification.",
		})

		return
	}

	if pending.Throttled(pending_item) {
		MSG := "Repeated Notifications are Blocked. Skipping."

		log.Println(MSG)
		request.Raise(gottp.HttpError{http.StatusBadRequest, MSG})
		return
	}

	pending_item.Topic = request.GetArgument("topic").(string)
	pending_item.IsRead = false

	pending_item.PrepareSave()

	if !utils.ValidateAndRaiseError(request, pending_item) {
		return
	}

	if !pending_item.IsValid() {
		request.Raise(gottp.HttpError{
			http.StatusBadRequest,
			"Context is required for sending notification.",
		})

		return
	}

	core.SendNotification(pending_item)
	request.Write(utils.R{StatusCode: http.StatusNoContent,
		Data: nil, Message: "true"})
	return
}
379431
func (n *nessusImpl) CreateUser(username, password, userType, permissions, name, email string) (*User, error) {
	if n.verbose {
		log.Println("Creating new user...")
	}
	data := createUserRequest{
		Username:    username,
		Password:    password,
		Permissions: permissions,
		Type:        userType,
	}
	if name != "" {
		data.Name = name
	}
	if email != "" {
		data.Email = email
	}

	resp, err := n.doRequest("POST", "/users", data, []int{http.StatusOK})
	if err != nil {
		return nil, err
	}
	defer resp.Body.Close()
	reply := &User{}
	if err = json.NewDecoder(resp.Body).Decode(&reply); err != nil {
		return nil, err
	}
	return reply, nil
}
1209350
func (cp *ConsulClient) NewLock(name string, myID string, ttl uint64) (LockInterface, error) {
	// Create a lock
	return &consulLock{
		name:      name,
		keyName:   "contiv.io/lock/" + name,
		myID:      myID,
		ttl:       fmt.Sprintf("%ds", ttl),
		eventChan: make(chan LockEvent, 1),
		stopChan:  make(chan struct{}, 1),
		mutex:     new(sync.Mutex),
		client:    cp.client,
	}, nil
}
1256564
func (lock *ProjectPostUserLock) Sender() (user *User) {
	user, _ = NewUser(lock.From)
	return
}
1219116
func NewUserPostComment(hcid uint64) (comment *UserPostComment, e error) {
	return NewUserPostCommentWhere(&UserPostComment{Hcid: hcid})
}