// PluginRemove indicates an expected call of PluginRemove
427634
func (mr *MockPluginAPIClientMockRecorder) PluginRemove(ctx, name, options interface{}) *gomock.Call {
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "PluginRemove", reflect.TypeOf((*MockPluginAPIClient)(nil).PluginRemove), ctx, name, options)
}
734729
func (d *driver) VolumeRemove(
	ctx types.Context,
	volumeID string,
	opts *types.VolumeRemoveOpts) error {

	var svc *awss3.S3

	{
		var err error
		if svc, err = d.getServiceForBucket(ctx, volumeID); err != nil {
			return err
		}
	}

	if opts.Force {

		{
			// delete objects
			res, err := svc.ListObjects(
				&awss3.ListObjectsInput{Bucket: &volumeID})
			if err != nil {
				ctx.WithField(
					"volumeID", volumeID).WithError(err).Error(
					"error listing objects")
				return goof.WithFieldE(
					"volumeID", volumeID,
					"error listing objects", err)
			}
			if res.Contents != nil {
				for {
					var key *string
					for _, obj := range res.Contents {
						if obj.Key == nil {
							continue
						}
						key = obj.Key
						_, err := svc.DeleteObject(&awss3.DeleteObjectInput{
							Bucket: &volumeID,
							Key:    key,
						})
						if err != nil {
							ctx.WithFields(map[string]interface{}{
								"volumeID": volumeID,
								"key":      key,
							}).WithError(err).Error("error deleting object")
							return goof.WithFieldsE(map[string]interface{}{
								"volumeID": volumeID,
								"key":      key,
							}, "error deleting object", err)
						}
					}

					if res.IsTruncated == nil || !*res.IsTruncated {
						break
					}

					var err error
					keyMarker := res.NextMarker
					if keyMarker == nil {
						keyMarker = key
					}
					res, err = svc.ListObjects(
						&awss3.ListObjectsInput{
							Bucket: &volumeID,
							Marker: keyMarker,
						})
					if err != nil {
						ctx.WithFields(map[string]interface{}{
							"volumeID":  volumeID,
							"keyMarker": keyMarker,
						}).WithError(err).Error("error listing next objects")
						return goof.WithFieldsE(map[string]interface{}{
							"volumeID":  volumeID,
							"keyMarker": keyMarker,
						}, "error listing next objects", err)
					}
				}
			}
		}

		{
			// delete versions
			res, err := svc.ListObjectVersions(
				&awss3.ListObjectVersionsInput{Bucket: &volumeID})
			if err != nil {
				ctx.WithField(
					"volumeID", volumeID).WithError(err).Error(
					"error listing object versions")
				return goof.WithFieldE(
					"volumeID", volumeID,
					"error listing object versions", err)
			}
			if res.Versions != nil {
				for {
					var key *string
					var ver *string
					for _, obj := range res.Versions {
						if obj.Key == nil {
							continue
						}
						if obj.VersionId == nil {
							continue
						}
						key = obj.Key
						ver = obj.VersionId
						_, err := svc.DeleteObject(&awss3.DeleteObjectInput{
							Bucket:    &volumeID,
							Key:       key,
							VersionId: ver,
						})
						if err != nil {
							ctx.WithFields(map[string]interface{}{
								"volumeID":  volumeID,
								"key":       key,
								"versionID": ver,
							}).WithError(err).Error("error deleting object ver")
							return goof.WithFieldsE(map[string]interface{}{
								"volumeID":  volumeID,
								"key":       key,
								"versionID": ver,
							}, "error deleting object ver", err)
						}
					}

					if res.IsTruncated == nil || !*res.IsTruncated {
						break
					}

					var err error
					keyMarker := res.NextKeyMarker
					verMarker := res.NextVersionIdMarker
					if keyMarker == nil {
						keyMarker = key
					}
					if verMarker == nil {
						verMarker = ver
					}
					res, err = svc.ListObjectVersions(
						&awss3.ListObjectVersionsInput{
							Bucket:          &volumeID,
							KeyMarker:       keyMarker,
							VersionIdMarker: verMarker,
						})
					if err != nil {
						ctx.WithFields(map[string]interface{}{
							"volumeID":  volumeID,
							"keyMarker": keyMarker,
							"verMarkre": verMarker,
						}).WithError(err).Error("error listing next objects")
						return goof.WithFieldsE(map[string]interface{}{
							"volumeID":  volumeID,
							"keyMarker": keyMarker,
							"verMarkre": verMarker,
						}, "error listing next objects", err)
					}
				}
			}
		}
	}

	_, err := svc.DeleteBucket(&awss3.DeleteBucketInput{Bucket: &volumeID})
	if err != nil {
		ctx.WithField(
			"volumeID", volumeID).WithError(err).Error(
			"error deleting s3 bucket")
		return goof.WithFieldE(
			"volumeID", volumeID, "error deleting s3 bucket", err)
	}

	return nil
}
482278
func (p *Plugin) Delete(name string) error {
	var updated []*Process
	for _, pr := range p.processes {
		if pr.name == name {
			if err := pr.deleteProcess(); err != nil {
				return err
			}
		} else {
			updated = append(updated, pr)
		}
	}

	p.processes = updated

	return nil
}
666876
func (_class VMClass) CallPlugin(sessionID SessionRef, vm VMRef, plugin string, fn string, args map[string]string) (_retval string, _err error) {
	_method := "VM.call_plugin"
	_sessionIDArg, _err := convertSessionRefToXen(fmt.Sprintf("%s(%s)", _method, "session_id"), sessionID)
	if _err != nil {
		return
	}
	_vmArg, _err := convertVMRefToXen(fmt.Sprintf("%s(%s)", _method, "vm"), vm)
	if _err != nil {
		return
	}
	_pluginArg, _err := convertStringToXen(fmt.Sprintf("%s(%s)", _method, "plugin"), plugin)
	if _err != nil {
		return
	}
	_fnArg, _err := convertStringToXen(fmt.Sprintf("%s(%s)", _method, "fn"), fn)
	if _err != nil {
		return
	}
	_argsArg, _err := convertStringToStringMapToXen(fmt.Sprintf("%s(%s)", _method, "args"), args)
	if _err != nil {
		return
	}
	_result, _err := _class.client.APICall(_method, _sessionIDArg, _vmArg, _pluginArg, _fnArg, _argsArg)
	if _err != nil {
		return
	}
	_retval, _err = convertStringToGo(_method + " -> ", _result.Value)
	return
}
51786
func (m *MockPluginAPIClient) PluginRemove(ctx context.Context, name string, options types.PluginRemoveOptions) error {
	ret := m.ctrl.Call(m, "PluginRemove", ctx, name, options)
	ret0, _ := ret[0].(error)
	return ret0
}
1151053
func (p *Plugin) Close() error {
	return safeclose.Close(p.hsClient, p.manClient, p.mux)
}
375923
func (p *pluginManager) UnloadPlugin(pl core.Plugin) (*loadedPlugin, serror.SnapError) {
	plugin, err := p.loadedPlugins.get(fmt.Sprintf("%s"+core.Separator+"%s"+core.Separator+"%d", pl.TypeName(), pl.Name(), pl.Version()))
	if err != nil {
		se := serror.New(ErrPluginNotFound, map[string]interface{}{
			"plugin-name":    pl.Name(),
			"plugin-version": pl.Version(),
			"plugin-type":    pl.TypeName(),
		})
		return nil, se
	}

	pmLogger.WithFields(log.Fields{
		"_block": "unload-plugin",
		"path":   plugin.Details.Exec,
	}).Info("plugin unload called")

	if plugin.State != LoadedState {
		se := serror.New(ErrPluginNotInLoadedState, map[string]interface{}{
			"plugin-name":    plugin.Name(),
			"plugin-version": plugin.Version(),
			"plugin-type":    pl.TypeName(),
		})
		return nil, se
	}

	pmLogger.WithFields(log.Fields{
		"plugin-type":    plugin.TypeName(),
		"plugin-name":    plugin.Name(),
		"plugin-version": plugin.Version(),
		"plugin-path":    plugin.Details.Path,
	}).Debugf("Removing plugin")

	// remove plugin binary from tempDirPath (do not apply for remote plugin)
	if strings.Contains(plugin.Details.Path, p.tempDirPath) {
		if err := os.RemoveAll(filepath.Dir(plugin.Details.Path)); err != nil {
			pmLogger.WithFields(log.Fields{
				"plugin-type":    plugin.TypeName(),
				"plugin-name":    plugin.Name(),
				"plugin-version": plugin.Version(),
				"plugin-path":    plugin.Details.Path,
			}).Error(err)
			se := serror.New(err)
			se.SetFields(map[string]interface{}{
				"plugin-type":    plugin.TypeName(),
				"plugin-name":    plugin.Name(),
				"plugin-version": plugin.Version(),
				"plugin-path":    plugin.Details.Path,
			})
			return nil, se
		}
	} else {
		pmLogger.WithFields(log.Fields{
			"plugin-type":    plugin.TypeName(),
			"plugin-name":    plugin.Name(),
			"plugin-version": plugin.Version(),
			"plugin-path":    plugin.Details.Path,
		}).Debug("Nothing to delete as temp path is empty")
	}

	// remove plugin key
	p.loadedPlugins.remove(plugin.Key())

	// remove any metrics from the catalog if this was a collector
	if plugin.TypeName() == core.CollectorPluginType.String() || plugin.TypeName() == core.StreamingCollectorPluginType.String() {
		p.metricCatalog.RmUnloadedPluginMetrics(plugin)
	}

	return plugin, nil
}
1297571
func (v *Stream) EventRemoveCallback() error {
	var err C.virError
	ret := C.virStreamEventRemoveCallbackWrapper(v.ptr, &err)
	if ret == -1 {
		return makeError(&err)
	}

	return nil
}
421581
func (cli *Client) VolumeRemove(ctx context.Context, volumeID string, force bool) error {
	query := url.Values{}
	if versions.GreaterThanOrEqualTo(cli.version, "1.25") {
		if force {
			query.Set("force", "1")
		}
	}
	resp, err := cli.delete(ctx, "/volumes/"+volumeID, query, nil)
	defer ensureReaderClosed(resp)
	return wrapResponseError(err, resp, "volume", volumeID)
}
768552
func ImageRemove(id string) error {
	return mgr.Do(func(ctx context.Context, cli *client.Client) (err error) {
		opts := types.ImageRemoveOptions{}
		_, err = cli.ImageRemove(ctx, id, opts)
		return
	})
}
1196979
func (m *MockContainerAPIClient) ContainerRemove(ctx context.Context, container string, options types.ContainerRemoveOptions) error {
	ret := m.ctrl.Call(m, "ContainerRemove", ctx, container, options)
	ret0, _ := ret[0].(error)
	return ret0
}
709732
func (m *Middleware) RemovePlugin(name string) {
	m.mu.Lock()
	defer m.mu.Unlock()
	plugins := m.plugins[:0]
	for _, authPlugin := range m.plugins {
		if authPlugin.Name() != name {
			plugins = append(plugins, authPlugin)
		}
	}
	m.plugins = plugins
}
1176320
func (_m *APIClient) ServiceRemove(ctx context.Context, serviceID string) error {
	ret := _m.Called(ctx, serviceID)

	var r0 error
	if rf, ok := ret.Get(0).(func(context.Context, string) error); ok {
		r0 = rf(ctx, serviceID)
	} else {
		r0 = ret.Error(0)
	}

	return r0
}
522810
func (m *MockCommonAPIClient) NetworkRemove(ctx context.Context, networkID string) error {
	ret := m.ctrl.Call(m, "NetworkRemove", ctx, networkID)
	ret0, _ := ret[0].(error)
	return ret0
}
1241749
func (cli *Client) NetworkRemove(ctx context.Context, networkID string) error {
	resp, err := cli.delete(ctx, "/networks/"+networkID, nil, nil)
	defer ensureReaderClosed(resp)
	return wrapResponseError(err, resp, "network", networkID)
}
31673
func (d *driver) VolumeRemove(
	ctx types.Context,
	volumeID string,
	opts *types.VolumeRemoveOpts) error {

	//TODO check if volume is attached? if so fail

	_, err := mustSession(ctx).blobClient.DeleteBlobIfExists(
		d.container, volumeID, nil)
	if err != nil {
		fields := map[string]interface{}{
			"volumeID": volumeID,
		}
		return goof.WithFieldsE(fields, "error removing volume", err)
	}
	return nil
}
1089176
func (d *driver) VolumeRemove(
	ctx types.Context,
	volumeID string,
	opts *types.VolumeRemoveOpts) error {

	zone, err := d.validZone(ctx)
	if err != nil {
		return err
	}

	if zone == nil || *zone == "" {
		return goof.New("Zone is required for VolumeRemove")
	}

	// TODO: check if disk is still attached first
	asyncOp, err := mustSession(ctx).Disks.Delete(
		*d.projectID, *zone, volumeID).Do()
	if err != nil {
		return goof.WithError("Failed to initiate disk deletion", err)
	}

	err = d.waitUntilOperationIsFinished(
		ctx, zone, asyncOp)
	if err != nil {
		return err
	}

	return nil
}