// DeleteServiceProfile deletes the service-profile matching the given id.
353583
func DeleteServiceProfile(db sqlx.Execer, id uuid.UUID) error {
	res, err := db.Exec("delete from service_profile where service_profile_id = $1", id)
	if err != nil {
		return handlePSQLError(err, "delete error")
	}

	ra, err := res.RowsAffected()
	if err != nil {
		return handlePSQLError(err, "get rows affected error")
	}
	if ra == 0 {
		return ErrDoesNotExist
	}

	log.WithField("id", id).Info("service-profile deleted")
	return nil
}
1274444
func (k *kubernetesClient) DeleteService(appName string) (err error) {
	logger.Debugf("deleting application %s", appName)

	deploymentName := k.deploymentName(appName)
	if err := k.deleteService(deploymentName); err != nil {
		return errors.Trace(err)
	}
	if err := k.deleteStatefulSet(deploymentName); err != nil {
		return errors.Trace(err)
	}
	if err := k.deleteDeployment(deploymentName); err != nil {
		return errors.Trace(err)
	}
	secrets := k.client().CoreV1().Secrets(k.namespace)
	secretList, err := secrets.List(v1.ListOptions{
		LabelSelector: applicationSelector(appName),
	})
	if err != nil {
		return errors.Trace(err)
	}
	for _, s := range secretList.Items {
		if err := k.deleteSecret(s.Name); err != nil {
			return errors.Trace(err)
		}
	}
	return nil
}
1014603
func (b *BigIP) DeleteOneconnectProfile(name string) error {
	return b.delete(uriLtm, uriProfile, uriOneConnect, name)
}
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
}
660646
func CreateServiceProfile(db sqlx.Execer, sp *ServiceProfile) error {
	now := time.Now()

	if sp.ID == uuid.Nil {
		var err error
		sp.ID, err = uuid.NewV4()
		if err != nil {
			return errors.Wrap(err, "new uuid v4 error")
		}
	}

	sp.CreatedAt = now
	sp.UpdatedAt = now

	_, err := db.Exec(`
		insert into service_profile (
			created_at,
			updated_at,

			service_profile_id,
			ul_rate,
			ul_bucket_size,
			ul_rate_policy,
			dl_rate,
			dl_bucket_size,
			dl_rate_policy,
			add_gw_metadata,
			dev_status_req_freq,
			report_dev_status_battery,
			report_dev_status_margin,
			dr_min,
			dr_max,
			channel_mask,
			pr_allowed,
			hr_allowed,
			ra_allowed,
			nwk_geo_loc,
			target_per,
			min_gw_diversity
		) values ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18, $19, $20, $21, $22)`,
		sp.CreatedAt,
		sp.UpdatedAt,
		sp.ID,
		sp.ULRate,
		sp.ULBucketSize,
		sp.ULRatePolicy,
		sp.DLRate,
		sp.DLBucketSize,
		sp.DLRatePolicy,
		sp.AddGWMetadata,
		sp.DevStatusReqFreq,
		sp.ReportDevStatusBattery,
		sp.ReportDevStatusMargin,
		sp.DRMin,
		sp.DRMax,
		sp.ChannelMask,
		sp.PRAllowed,
		sp.HRAllowed,
		sp.RAAllowed,
		sp.NwkGeoLoc,
		sp.TargetPER,
		sp.MinGWDiversity,
	)
	if err != nil {
		return handlePSQLError(err, "insert error")
	}

	log.WithFields(log.Fields{
		"id": sp.ID,
	}).Info("service-profile created")

	return nil
}
149533
func (a *Agent) RemoveService(serviceID string, persist bool) error {
	a.stateLock.Lock()
	defer a.stateLock.Unlock()
	return a.removeServiceLocked(serviceID, persist)
}
273068
func DeleteServiceV2(svc loadbalancer.L3n4AddrID, releaseBackendID func(loadbalancer.BackendID)) error {
	var (
		backendKey BackendKey
		svcKey     ServiceKeyV2
	)

	mutex.Lock()
	defer mutex.Unlock()

	isIPv6 := svc.IsIPv6()

	log.WithField(logfields.ServiceName, svc).Debug("Deleting service")

	if isIPv6 {
		svcKey = NewService6KeyV2(svc.IP, svc.Port, u8proto.All, 0)
	} else {
		svcKey = NewService4KeyV2(svc.IP, svc.Port, u8proto.All, 0)
	}

	backendsToRemove, backendsCount, err := cache.removeServiceV2(svcKey)
	if err != nil {
		return err
	}

	for slot := 0; slot <= backendsCount; slot++ {
		svcKey.SetSlave(slot)
		if err := svcKey.MapDelete(); err != nil {
			return err
		}
	}

	if isIPv6 {
		backendKey = NewBackend6Key(0)
	} else {
		backendKey = NewBackend4Key(0)
	}

	for _, id := range backendsToRemove {
		backendKey.SetID(id)
		if err := deleteBackendLocked(backendKey); err != nil {
			return fmt.Errorf("Unable to delete backend with ID %d: %s", id, err)
		}
		releaseBackendID(id)
		log.WithField(logfields.BackendID, id).Debug("Deleted backend")
	}

	return nil
}
704631
func (r *rest) Delete(c *gin.Context) {
	if err := r.service.Remove(c.Param("profileId")); err != nil {
		c.JSON(apihelper.BuildResponseError(err))
	} else {
		c.JSON(http.StatusOK, gin.H{"message": "profile has been deleted successfully"})
	}
}
799763
func (r *RequestProcessor) DeleteService(c *CLIRequest) error {

	request := &common.EventInfo{
		PUType:      common.LinuxProcessPU,
		PUID:        c.ServiceName,
		EventType:   common.EventStop,
		HostService: c.HostPolicy,
	}

	if c.UIDPolicy {
		request.PUType = common.UIDLoginPU
	}

	// Send Stop request
	if err := sendRequest(r.address, request); err != nil {
		return err
	}

	// Send destroy request
	request.EventType = common.EventDestroy

	return sendRequest(r.address, request)
}
738241
func (cli *Client) ServiceRemove(ctx context.Context, serviceID string) error {
	resp, err := cli.delete(ctx, "/services/"+serviceID, nil, nil)
	ensureReaderClosed(resp)
	return err
}
1279625
func GetServiceProfileCache(p *redis.Pool, id uuid.UUID) (ServiceProfile, error) {
	var sp ServiceProfile
	key := fmt.Sprintf(ServiceProfileKeyTempl, id)

	c := p.Get()
	defer c.Close()

	val, err := redis.Bytes(c.Do("GET", key))
	if err != nil {
		if err == redis.ErrNil {
			return sp, ErrDoesNotExist
		}
		return sp, errors.Wrap(err, "get error")
	}

	err = gob.NewDecoder(bytes.NewReader(val)).Decode(&sp)
	if err != nil {
		return sp, errors.Wrap(err, "gob decode error")
	}

	return sp, nil
}
909567
func deleteService(e encoder, adapter PanamaxAdapter, params martini.Params) (int, string) {
	id := params["id"]

	err := adapter.DestroyService(id)
	if err != nil {
		return sanitizeErrorCode(err.Code), err.Message
	}

	return http.StatusNoContent, e.Encode("")
}
681995
func (c *Gcd) removeProfileDir() {
	if c.deleteProfile {
		// let chrome shutdown completely before deleting
		time.Sleep(1 * time.Second)
		if err := os.RemoveAll(c.profileDir); err != nil {
			log.Printf("error deleting profile directory: %s\n", err)
		}
	}
}
1039685
func (l *State) RemoveService(id string) error {
	l.Lock()
	defer l.Unlock()
	return l.removeServiceLocked(id)
}
453341
func (c *ContivClient) VolumeProfileDelete(tenantName string, volumeProfileName string) error {
	// build key and URL
	keyStr := tenantName + ":" + volumeProfileName
	url := c.baseURL + "/api/v1/volumeProfiles/" + keyStr + "/"

	// http get the object
	err := c.httpDelete(url)
	if err != nil {
		log.Debugf("Error deleting volumeProfile %s. Err: %v", keyStr, err)
		return err
	}

	return nil
}
379284
func (b *BigIP) DeleteServerSSLProfile(name string) error {
	return b.delete(uriLtm, uriProfile, uriServerSSL, name)
}
543018
func (c *Client) DeleteServiceOffering(p *DeleteServiceOfferingParameter) (*Result, error) {
	obj, err := c.Request("deleteServiceOffering", convertParamToMap(p))
	if err != nil {
		return nil, err
	}
	return obj.(*Result), err
}