// delete Association with key of endpoint
961877
func (assocs *associations) delete(endpoint string) {
	assocs.Lock()
	defer assocs.Unlock()
	delete(assocs.store, strings.TrimRight(endpoint, "/"))
}
501242
func (kv *KV) Delete(key []byte) error {
	return kv.db.Erase(gkv.Btos(key))
}
206555
func (association *Association) Delete(values ...interface{}) *Association {
	if association.Error != nil {
		return association
	}

	var (
		relationship = association.field.Relationship
		scope        = association.scope
		field        = association.field.Field
		newDB        = scope.NewDB()
	)

	if len(values) == 0 {
		return association
	}

	var deletingResourcePrimaryFieldNames, deletingResourcePrimaryDBNames []string
	for _, field := range scope.New(reflect.New(field.Type()).Interface()).PrimaryFields() {
		deletingResourcePrimaryFieldNames = append(deletingResourcePrimaryFieldNames, field.Name)
		deletingResourcePrimaryDBNames = append(deletingResourcePrimaryDBNames, field.DBName)
	}

	deletingPrimaryKeys := scope.getColumnAsArray(deletingResourcePrimaryFieldNames, values...)

	if relationship.Kind == "many_to_many" {
		// source value's foreign keys
		for idx, foreignKey := range relationship.ForeignDBNames {
			if field, ok := scope.FieldByName(relationship.ForeignFieldNames[idx]); ok {
				newDB = newDB.Where(fmt.Sprintf("%v = ?", scope.Quote(foreignKey)), field.Field.Interface())
			}
		}

		// get association's foreign fields name
		var associationScope = scope.New(reflect.New(field.Type()).Interface())
		var associationForeignFieldNames []string
		for _, associationDBName := range relationship.AssociationForeignFieldNames {
			if field, ok := associationScope.FieldByName(associationDBName); ok {
				associationForeignFieldNames = append(associationForeignFieldNames, field.Name)
			}
		}

		// association value's foreign keys
		deletingPrimaryKeys := scope.getColumnAsArray(associationForeignFieldNames, values...)
		sql := fmt.Sprintf("%v IN (%v)", toQueryCondition(scope, relationship.AssociationForeignDBNames), toQueryMarks(deletingPrimaryKeys))
		newDB = newDB.Where(sql, toQueryValues(deletingPrimaryKeys)...)

		association.setErr(relationship.JoinTableHandler.Delete(relationship.JoinTableHandler, newDB))
	} else {
		var foreignKeyMap = map[string]interface{}{}
		for _, foreignKey := range relationship.ForeignDBNames {
			foreignKeyMap[foreignKey] = nil
		}

		if relationship.Kind == "belongs_to" {
			// find with deleting relation's foreign keys
			primaryKeys := scope.getColumnAsArray(relationship.AssociationForeignFieldNames, values...)
			newDB = newDB.Where(
				fmt.Sprintf("%v IN (%v)", toQueryCondition(scope, relationship.ForeignDBNames), toQueryMarks(primaryKeys)),
				toQueryValues(primaryKeys)...,
			)

			// set foreign key to be null if there are some records affected
			modelValue := reflect.New(scope.GetModelStruct().ModelType).Interface()
			if results := newDB.Model(modelValue).UpdateColumn(foreignKeyMap); results.Error == nil {
				if results.RowsAffected > 0 {
					scope.updatedAttrsWithValues(foreignKeyMap)
				}
			} else {
				association.setErr(results.Error)
			}
		} else if relationship.Kind == "has_one" || relationship.Kind == "has_many" {
			// find all relations
			primaryKeys := scope.getColumnAsArray(relationship.AssociationForeignFieldNames, scope.Value)
			newDB = newDB.Where(
				fmt.Sprintf("%v IN (%v)", toQueryCondition(scope, relationship.ForeignDBNames), toQueryMarks(primaryKeys)),
				toQueryValues(primaryKeys)...,
			)

			// only include those deleting relations
			newDB = newDB.Where(
				fmt.Sprintf("%v IN (%v)", toQueryCondition(scope, deletingResourcePrimaryDBNames), toQueryMarks(deletingPrimaryKeys)),
				toQueryValues(deletingPrimaryKeys)...,
			)

			// set matched relation's foreign key to be null
			fieldValue := reflect.New(association.field.Field.Type()).Interface()
			association.setErr(newDB.Model(fieldValue).UpdateColumn(foreignKeyMap).Error)
		}
	}

	// Remove deleted records from source's field
	if association.Error == nil {
		if field.Kind() == reflect.Slice {
			leftValues := reflect.Zero(field.Type())

			for i := 0; i < field.Len(); i++ {
				reflectValue := field.Index(i)
				primaryKey := scope.getColumnAsArray(deletingResourcePrimaryFieldNames, reflectValue.Interface())[0]
				var isDeleted = false
				for _, pk := range deletingPrimaryKeys {
					if equalAsString(primaryKey, pk) {
						isDeleted = true
						break
					}
				}
				if !isDeleted {
					leftValues = reflect.Append(leftValues, reflectValue)
				}
			}

			association.field.Set(leftValues)
		} else if field.Kind() == reflect.Struct {
			primaryKey := scope.getColumnAsArray(deletingResourcePrimaryFieldNames, field.Interface())[0]
			for _, pk := range deletingPrimaryKeys {
				if equalAsString(primaryKey, pk) {
					association.field.Set(reflect.Zero(field.Type()))
					break
				}
			}
		}
	}

	return association
}
409697
func (ng *etcdv2AutoCertCache) Delete(ctx context.Context, rawKey string) error {
	key := ng.normalized(rawKey)
	_, err := ng.kapi.Delete(ctx, key, &etcd.DeleteOptions{})
	return err
}
576623
func (c *FakeEndpoints) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error {
	action := testing.NewDeleteCollectionAction(endpointsResource, c.ns, listOptions)

	_, err := c.Fake.Invokes(action, &corev1.EndpointsList{})
	return err
}
93767
func (s *KeyManagementServer) DeleteKey(ctx context.Context, keyID *pb.KeyID) (*pb.Void, error) {
	logger := ctxu.GetLogger(ctx)
	// delete key ID from all services
	for _, service := range s.CryptoServices {
		if err := service.RemoveKey(keyID.ID); err != nil {
			logger.Errorf("Failed to delete key %s", keyID.ID)
			return nil, grpc.Errorf(codes.Internal, "Key deletion for KeyID %s failed", keyID.ID)
		}
	}

	return &pb.Void{}, nil
}
1298156
func (assocs *associations) get(endpoint string) (Association, bool) {
	ep := strings.TrimRight(endpoint, "/")
	assocs.RLock()
	assoc, ok := assocs.store[ep]
	assocs.RUnlock()

	// clear expired associate
	if assoc.Expires.Before(time.Now()) && ok {
		assoc = Association{}
		ok = false
		assocs.delete(ep)
	}

	return assoc, ok
}
266582
func (s *EventsService) Delete(e EventKey) (*http.Response, error) {
	return s.client.delete(e.URI(), nil)
}
99386
func (p *SessionStore) Delete(key string) error {
	p.Lock()
	defer p.Unlock()
	delete(p.values, key)
	return nil
}
826550
func DeleteEndpointGroup(key string) error {
	collections.endpointGroupMutex.Lock()
	obj := collections.endpointGroups[key]
	collections.endpointGroupMutex.Unlock()
	if obj == nil {
		log.Errorf("endpointGroup %s not found", key)
		return errors.New("endpointGroup not found")
	}

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

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

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

	// delete it from cache
	collections.endpointGroupMutex.Lock()
	delete(collections.endpointGroups, key)
	collections.endpointGroupMutex.Unlock()

	return nil
}
863386
func DeletePublicKey(c *context.APIContext) {
	if err := models.DeletePublicKey(c.User, c.ParamsInt64(":id")); err != nil {
		if models.IsErrKeyAccessDenied(err) {
			c.Error(403, "", "You do not have access to this key")
		} else {
			c.Error(500, "DeletePublicKey", err)
		}
		return
	}

	c.Status(204)
}
436523
func (cb *ConfigBackend) Delete(key string) error {
	_, err := cb.etcdlib.Delete(key, false)
	return err
}
739598
func Delete(req *http.Request, key interface{}) {
	crc := getContextReadCloser(req)
	delete(crc.Context(), key)
}
896059
func (r *MemoryTTL) Delete(key string) error {
	r.Lock()
	defer r.Unlock()

	r.delete(key)
	return nil
}
1262908
func (kv *KV) Delete(key []byte) error {
	return kv.db.Delete(key, nil)
}
592456
func (s *SwiftBackend) Delete(ctx context.Context, key string) error {
	defer metrics.MeasureSince([]string{"swift", "delete"}, time.Now())

	s.permitPool.Acquire()
	defer s.permitPool.Release()

	err := s.client.ObjectDelete(s.container, key)

	if err != nil && err != swift.ObjectNotFound {
		return err
	}

	return nil
}
775047
func (c *ShardedClient) Delete(key string) MutateResponse {
	return c.mutate(
		key,
		func(shardClient Client) MutateResponse {
			return shardClient.Delete(key)
		})
}