// DeleteRoutingProfile deletes the routing-profile matching the given id.
970598
func (n *NetworkServerAPI) DeleteRoutingProfile(ctx context.Context, req *ns.DeleteRoutingProfileRequest) (*empty.Empty, error) {
	var rpID uuid.UUID
	copy(rpID[:], req.Id)

	if err := storage.DeleteRoutingProfile(storage.DB(), rpID); err != nil {
		return nil, errToRPCError(err)
	}

	return &empty.Empty{}, nil
}
470287
func UnlinkCurrentProfile() error {
	return trace.Wrap(os.Remove(filepath.Join(FullProfilePath(""), CurrentProfileSymlink)))
}
522334
func (r *Registrar) DeleteRegistration() error {
	if r == nil || r.user == nil {
		return errors.New("acme: cannot unregister a nil client or user")
	}

	log.Infof("acme: Deleting account for %s", r.user.GetEmail())

	return r.core.Accounts.Deactivate(r.user.GetRegistration().URI)
}
1330616
func (s *User) SetRoutingProfileId(v string) *User {
	s.RoutingProfileId = &v
	return s
}
77824
func DeleteAppProfile(key string) error {
	collections.appProfileMutex.Lock()
	obj := collections.appProfiles[key]
	collections.appProfileMutex.Unlock()
	if obj == nil {
		log.Errorf("appProfile %s not found", key)
		return errors.New("appProfile not found")
	}

	// Check if we handle this object
	if objCallbackHandler.AppProfileCb == nil {
		log.Errorf("No callback registered for appProfile object")
		return errors.New("Invalid object type")
	}

	// Perform callback
	err := objCallbackHandler.AppProfileCb.AppProfileDelete(obj)
	if err != nil {
		log.Errorf("AppProfileDelete retruned error for: %+v. Err: %v", obj, err)
		return err
	}

	// delete it from modeldb
	collections.appProfileMutex.Lock()
	err = obj.Delete()
	collections.appProfileMutex.Unlock()
	if err != nil {
		log.Errorf("Error deleting appProfile %s. Err: %v", obj.Key, err)
	}

	// delete it from cache
	collections.appProfileMutex.Lock()
	delete(collections.appProfiles, key)
	collections.appProfileMutex.Unlock()

	return nil
}
329301
func deleteDeviceProfile(dp models.DeviceProfile, w http.ResponseWriter) error {
	// Check if the device profile is still in use by devices
	d, err := dbClient.GetDevicesByProfileId(dp.Id)

	// XXX ErrNotFound should always be returned but this is not consistent in the implementations
	if err == db.ErrNotFound {
		err = nil
		d = []models.Device{}
	} else if err != nil {
		http.Error(w, err.Error(), http.StatusServiceUnavailable)
		return err
	}
	if len(d) > 0 {
		err = errors.New("Can't delete device profile, the profile is still in use by a device")
		http.Error(w, err.Error(), http.StatusConflict)
		return err
	}

	// Check if the device profile is still in use by provision watchers
	pw, err := dbClient.GetProvisionWatchersByProfileId(dp.Id)
	if err != nil {
		http.Error(w, err.Error(), http.StatusServiceUnavailable)
		return err
	}
	if len(pw) > 0 {
		err = errors.New("Cant delete device profile, the profile is still in use by a provision watcher")
		http.Error(w, err.Error(), http.StatusConflict)
		return err
	}

	// Delete the profile
	if err := dbClient.DeleteDeviceProfileById(dp.Id); err != nil {
		http.Error(w, err.Error(), http.StatusServiceUnavailable)
		return err
	}

	return nil
}
512184
func (p *Profile) remapMappingIDs() {
	if len(p.Mapping) == 0 {
		return
	}

	// Some profile handlers will incorrectly set regions for the main
	// executable if its section is remapped. Fix them through heuristics.

	// Remove the initial mapping if named '/anon_hugepage' and has a
	// consecutive adjacent mapping.
	if m := p.Mapping[0]; strings.HasPrefix(m.File, "/anon_hugepage") {
		if len(p.Mapping) > 1 && m.Limit == p.Mapping[1].Start {
			p.Mapping = p.Mapping[1:]
		}
	}

	// Subtract the offset from the start of the main mapping if it
	// ends up at a recognizable start address.
	const expectedStart = 0x400000
	if m := p.Mapping[0]; m.Start-m.Offset == expectedStart {
		m.Start = expectedStart
		m.Offset = 0
	}

	for _, l := range p.Location {
		if a := l.Address; a != 0 {
			for _, m := range p.Mapping {
				if m.Start <= a && a < m.Limit {
					l.Mapping = m
					break
				}
			}
		}
	}

	// Reset all mapping IDs.
	for i, m := range p.Mapping {
		m.ID = uint64(i + 1)
	}
}
927123
func (az *Cloud) DeleteRouteWithName(routeName string) error {
	if az.Config.shouldOmitCloudProviderBackoff() {
		ctx, cancel := getContextWithCancel()
		defer cancel()

		resp, err := az.RoutesClient.Delete(ctx, az.RouteTableResourceGroup, az.RouteTableName, routeName)
		klog.V(10).Infof("RoutesClient.Delete(%s,%s): end", az.RouteTableName, routeName)
		return az.processHTTPResponse(nil, "", resp, err)
	}

	return az.deleteRouteWithRetry(routeName)
}
542940
func (g *Cloud) DeleteRegionForwardingRule(name, region string) error {
	ctx, cancel := cloud.ContextWithCallTimeout()
	defer cancel()

	mc := newForwardingRuleMetricContext("delete", region)
	return mc.Observe(g.c.ForwardingRules().Delete(ctx, meta.RegionalKey(name, region)))
}
580840
func (s *NATService) DeleteIpForwardingRule(p *DeleteIpForwardingRuleParams) (*DeleteIpForwardingRuleResponse, error) {
	resp, err := s.cs.newRequest("deleteIpForwardingRule", p.toURLValues())
	if err != nil {
		return nil, err
	}

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

	// If we have a async client, we need to wait for the async result
	if s.cs.async {
		b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout)
		if err != nil {
			if err == AsyncTimeoutErr {
				return &r, err
			}
			return nil, err
		}

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

	return &r, nil
}
319899
func (e *Enforcer) DeleteRoleForUser(user string, role string) bool {
	return e.RemoveGroupingPolicy(user, role)
}
879589
func restDeleteProfileByName(w http.ResponseWriter, r *http.Request) {
	vars := mux.Vars(r)
	n, err := url.QueryUnescape(vars[NAME])
	if err != nil {
		LoggingClient.Error(err.Error())
		http.Error(w, err.Error(), http.StatusBadRequest)
		return
	}

	// Check if the device profile exists
	dp, err := dbClient.GetDeviceProfileByName(n)
	if err != nil {
		if err == db.ErrNotFound {
			http.Error(w, err.Error(), http.StatusNotFound)
		} else {
			http.Error(w, err.Error(), http.StatusInternalServerError)
		}
		LoggingClient.Error(err.Error())
		return
	}

	// Delete the device profile
	if err = deleteDeviceProfile(dp, w); err != nil {
		LoggingClient.Error(err.Error())
		return
	}
	w.Header().Set("Content-Type", "application/json")
	w.WriteHeader(http.StatusOK)
	w.Write([]byte("true"))
}
989036
func (s *sandbox) deleteRoutes(netHandle *netlink.Handle) error {
	if netHandle == nil {
		return errNoHandle
	}

	initRouteList, err := netHandle.RouteList(nil, netlink.FAMILY_ALL)
	if err != nil {
		return err
	}
	for _, initRoute := range initRouteList {
		// don't delete routes associated with lo:
		link, _ := netHandle.LinkByIndex(initRoute.LinkIndex)
		if link.Attrs().Name == "lo" || link.Attrs().Name == "::1" {
			continue
		}

		err = netHandle.RouteDel(&initRoute)
		if err != nil {
			//If there was an error deleting some of the initial routes,
			//return the error and the current routes on the system via
			//the defer function
			return err
		}
	}

	return nil
}
856818
func ProfileHandler() gin.HandlerFunc {
	return func(ctx *gin.Context) {
		pprof.Profile(ctx.Writer, ctx.Request)
	}
}
554785
func (a *Account) EditProfile(profile Profile) error {
	var edits editProfileReq

	if profile.Username != "" {
		edits.Username = profile.Username
	}

	if profile.Email != "" {
		edits.Email = profile.Email
	}

	if profile.Name != nil {
		edits.Name = profile.Name
	}

	err := a.patch(a.auth, "/api/v2/users/me", edits, nil)
	if err != nil {
		return fmt.Errorf("Could not update profile: %s", err)
	}
	return err
}
776830
func (n *NetworkServerAPI) GetRoutingProfile(ctx context.Context, req *ns.GetRoutingProfileRequest) (*ns.GetRoutingProfileResponse, error) {
	var rpID uuid.UUID
	copy(rpID[:], req.Id)

	rp, err := storage.GetRoutingProfile(storage.DB(), rpID)
	if err != nil {
		return nil, errToRPCError(err)
	}

	resp := ns.GetRoutingProfileResponse{
		RoutingProfile: &ns.RoutingProfile{
			Id:      rp.ID.Bytes(),
			AsId:    rp.ASID,
			CaCert:  rp.CACert,
			TlsCert: rp.TLSCert,
		},
	}

	resp.CreatedAt, err = ptypes.TimestampProto(rp.CreatedAt)
	if err != nil {
		return nil, errToRPCError(err)
	}

	resp.UpdatedAt, err = ptypes.TimestampProto(rp.UpdatedAt)
	if err != nil {
		return nil, errToRPCError(err)
	}

	return &resp, nil
}
387508
func (c *Client) DeleteRegistrationById(id string) error {
	conn := c.Pool.Get()
	defer conn.Close()

	return deleteRegistration(conn, id)
}