// DeleteMacro implements the platform.MacroService interface
764135
func (s *Service) DeleteMacro(ctx context.Context, id platform.ID) error {
	op := OpPrefix + platform.OpDeleteMacro
	_, err := s.FindMacroByID(ctx, id)
	if err != nil {
		return &platform.Error{
			Op:   op,
			Code: platform.ENotFound,
			Msg:  "macro not found",
			Err:  err,
		}
	}

	s.macroKV.Delete(id.String())

	return nil
}
170778
func (d *namespacedResourcesDeleter) deleteNamespace(namespace *v1.Namespace) error {
	var opts *metav1.DeleteOptions
	uid := namespace.UID
	if len(uid) > 0 {
		opts = &metav1.DeleteOptions{Preconditions: &metav1.Preconditions{UID: &uid}}
	}
	err := d.nsClient.Delete(namespace.Name, opts)
	if err != nil && !errors.IsNotFound(err) {
		return err
	}
	return nil
}
978533
func (s *storage) DeleteMetadata(imageId string) error {
	deleteOperation := func(docId string) txn.Op {
		logger.Debugf("deleting metadata (ID=%v) for image (ID=%v)", docId, imageId)
		return txn.Op{
			C:      s.collection,
			Id:     docId,
			Assert: txn.DocExists,
			Remove: true,
		}
	}

	noOp := func() ([]txn.Op, error) {
		logger.Debugf("no metadata for image ID %v to delete", imageId)
		return nil, jujutxn.ErrNoOperations
	}

	buildTxn := func(attempt int) ([]txn.Op, error) {
		// find all metadata docs with given image id
		imageMetadata, err := s.metadataForImageId(imageId)
		if err != nil {
			if err == mgo.ErrNotFound {
				return noOp()
			}
			return nil, err
		}
		if len(imageMetadata) == 0 {
			return noOp()
		}

		allTxn := make([]txn.Op, len(imageMetadata))
		for i, doc := range imageMetadata {
			allTxn[i] = deleteOperation(doc.Id)
		}
		return allTxn, nil
	}

	err := s.store.RunTransaction(buildTxn)
	if err != nil {
		return errors.Annotatef(err, "cannot delete metadata for cloud image %v", imageId)
	}
	return nil
}
1122718
func (s *Service) OrganizationDelete(ctx context.Context, organizationIdentity string) (*Organization, error) {
	var organization Organization
	return &organization, s.Delete(ctx, &organization, fmt.Sprintf("/organizations/%v", organizationIdentity))
}
261139
func (api *Client) DeleteMediaFile(name string) error {
	_, _, err := api.makeRequest(http.MethodDelete, fmt.Sprintf("%s/%s", api.concatUserPath(mediaPath), url.QueryEscape(name)))
	return err
}
1248437
func (*Service) DeleteMachine(c context.Context, req *crimson.DeleteMachineRequest) (*empty.Empty, error) {
	if err := deleteMachine(c, req.Name); err != nil {
		return nil, err
	}
	return &empty.Empty{}, nil
}
481433
func (c *Client) FindMacros(ctx context.Context) ([]*platform.Macro, error) {
	op := getOp(platform.OpFindMacros)
	macros := []*platform.Macro{}
	err := c.db.View(func(tx *bolt.Tx) error {
		b := tx.Bucket(macroBucket)
		c := b.Cursor()

		for k, v := c.First(); k != nil; k, v = c.Next() {
			macro := platform.Macro{}

			err := json.Unmarshal(v, &macro)
			if err != nil {
				return &platform.Error{
					Err: err,
					Op:  op,
				}
			}

			macros = append(macros, &macro)
		}

		return nil
	})
	if err != nil {
		return nil, err
	}

	return macros, nil
}
870122
func (s *inmem) DeleteOrg(ctx context.Context, id platform.ID) error {
	return s.delete(ctx, id, getOrg)
}
471965
func (c *InstancesClient) DeleteMetadata(ctx context.Context, input *DeleteMetadataInput) error {
	if input.Key == "" {
		return fmt.Errorf("Missing metadata Key from input: %s", input.Key)
	}

	fullPath := path.Join("/", c.client.AccountName, "machines", input.ID, "metadata", input.Key)
	reqInputs := client.RequestInput{
		Method: http.MethodDelete,
		Path:   fullPath,
	}
	respReader, err := c.client.ExecuteRequest(ctx, reqInputs)
	if err != nil {
		return pkgerrors.Wrap(err, "unable to delete machine metadata")
	}
	if respReader != nil {
		defer respReader.Close()
	}

	return nil
}
1254627
func (s *Service) UpdateMacro(ctx context.Context, id platform.ID, update *platform.MacroUpdate) (*platform.Macro, error) {
	op := OpPrefix + platform.OpUpdateMacro
	macro, err := s.FindMacroByID(ctx, id)
	if err != nil {
		return nil, &platform.Error{
			Op:   op,
			Code: platform.ENotFound,
			Msg:  "macro not found",
			Err:  err,
		}
	}

	if err := update.Apply(macro); err != nil {
		return nil, &platform.Error{
			Op:  op,
			Err: err,
		}
	}

	if err := s.ReplaceMacro(ctx, macro); err != nil {
		return nil, &platform.Error{
			Op:  op,
			Err: err,
		}
	}

	return macro, nil
}
400239
func (f Firewall) DeleteMachineSecList(machineId string) error {
	listName := f.machineGroupName(machineId)
	globalListName := f.globalGroupName()
	err := f.maybeDeleteList(f.client.ComposeName(listName))
	if err != nil {
		return errors.Trace(err)
	}
	// check if we can delete the global list as well
	err = f.maybeDeleteList(f.client.ComposeName(globalListName))
	if err != nil {
		return errors.Trace(err)
	}
	return nil
}
1159631
func (menu *Menu) DeleteMenu() error {
	accessToken, err := menu.GetAccessToken()
	if err != nil {
		return err
	}
	uri := fmt.Sprintf("%s?access_token=%s", menuDeleteURL, accessToken)
	response, err := util.HTTPGet(uri)
	if err != nil {
		return err
	}

	return util.DecodeWithCommonError(response, "GetMenu")
}
328038
func parseMacro(p *parser, input string) (string, error) {
	m := newMacro(input)
	var err error
	for m.state = scanText; m.state != nil; {
		m.state, err = m.state(m, p)
		if err != nil {
			// log error
			return "", err
		}

	}
	return strings.Join(m.output, ""), nil
}
727298
func (s *Service) DeleteOrganization(ctx context.Context, id platform.ID) error {
	if _, err := s.FindOrganizationByID(ctx, id); err != nil {
		return &platform.Error{
			Err: err,
			Op:  OpPrefix + platform.OpDeleteOrganization,
		}
	}
	s.organizationKV.Delete(id.String())
	return nil
}
568243
func (s *Service) DeleteMachine(componentsmachineproviderrpcmessagescatalogmachinedeletionrequest *ComponentsMachineProviderRpcMessagesCatalogMachineDeletionRequest) *DeleteMachineCall {
	c := &DeleteMachineCall{s: s, urlParams_: make(gensupport.URLParams)}
	c.componentsmachineproviderrpcmessagescatalogmachinedeletionrequest = componentsmachineproviderrpcmessagescatalogmachinedeletionrequest
	return c
}
1353809
func (s *Service) ReplaceMacro(ctx context.Context, m *platform.Macro) error {
	s.macroKV.Store(m.ID.String(), m)
	return nil
}
1295718
func (d *namespacedResourcesDeleter) deleteEachItem(gvr schema.GroupVersionResource, namespace string) error {
	klog.V(5).Infof("namespace controller - deleteEachItem - namespace: %s, gvr: %v", namespace, gvr)

	unstructuredList, listSupported, err := d.listCollection(gvr, namespace)
	if err != nil {
		return err
	}
	if !listSupported {
		return nil
	}
	for _, item := range unstructuredList.Items {
		background := metav1.DeletePropagationBackground
		opts := &metav1.DeleteOptions{PropagationPolicy: &background}
		if err = d.dynamicClient.Resource(gvr).Namespace(namespace).Delete(item.GetName(), opts); err != nil && !errors.IsNotFound(err) && !errors.IsMethodNotSupported(err) {
			return err
		}
	}
	return nil
}