// VolumeInspect inspects a single volume.
437353
func (d *driver) VolumeInspect(
	ctx types.Context,
	volumeID string,
	opts *types.VolumeInspectOpts) (*types.Volume, error) {

	return d.getVolume(ctx, volumeID, opts.Attachments)
}
1136952
func (_m *APIClient) VolumeCreate(ctx context.Context, options volume.VolumeCreateBody) (types.Volume, error) {
	ret := _m.Called(ctx, options)

	var r0 types.Volume
	if rf, ok := ret.Get(0).(func(context.Context, volume.VolumeCreateBody) types.Volume); ok {
		r0 = rf(ctx, options)
	} else {
		r0 = ret.Get(0).(types.Volume)
	}

	var r1 error
	if rf, ok := ret.Get(1).(func(context.Context, volume.VolumeCreateBody) error); ok {
		r1 = rf(ctx, options)
	} else {
		r1 = ret.Error(1)
	}

	return r0, r1
}
1094480
func (v *volumeClient) Inspect(ids []string) ([]*api.Volume, error) {
	if len(ids) == 0 {
		return nil, nil
	}
	var volumes []*api.Volume
	request := v.c.Get().Resource(volumePath)
	for _, id := range ids {
		request.QueryOption(api.OptVolumeID, id)
	}
	if err := request.Do().Unmarshal(&volumes); err != nil {
		return nil, err
	}
	return volumes, nil
}
250193
func (m *MockVolumeAPIClient) VolumeInspectWithRaw(ctx context.Context, volumeID string) (types.Volume, []byte, error) {
	ret := m.ctrl.Call(m, "VolumeInspectWithRaw", ctx, volumeID)
	ret0, _ := ret[0].(types.Volume)
	ret1, _ := ret[1].([]byte)
	ret2, _ := ret[2].(error)
	return ret0, ret1, ret2
}
365769
func (m *MockContainerAPIClient) ContainerInspect(ctx context.Context, container string) (types.ContainerJSON, error) {
	ret := m.ctrl.Call(m, "ContainerInspect", ctx, container)
	ret0, _ := ret[0].(types.ContainerJSON)
	ret1, _ := ret[1].(error)
	return ret0, ret1
}
703869
func ContainerInspectRaw(id string) (container types.ContainerJSON, raw []byte, err error) {
	var (
		ctx context.Context
		cli *client.Client
	)
	if ctx, cli, err = mgr.Client(); err == nil {
		container, raw, err = cli.ContainerInspectWithRaw(ctx, id, true)
	}
	return
}
815623
func NodeInspect(id string) (node swarm.Node, raw []byte, err error) {
	var (
		ctx context.Context
		cli *client.Client
	)
	if ctx, cli, err = mgr.Client(); err == nil {
		return cli.NodeInspectWithRaw(ctx, id)
	}
	return
}
1039317
func (_m *APIClient) VolumeInspect(ctx context.Context, volumeID string) (types.Volume, error) {
	ret := _m.Called(ctx, volumeID)

	var r0 types.Volume
	if rf, ok := ret.Get(0).(func(context.Context, string) types.Volume); ok {
		r0 = rf(ctx, volumeID)
	} else {
		r0 = ret.Get(0).(types.Volume)
	}

	var r1 error
	if rf, ok := ret.Get(1).(func(context.Context, string) error); ok {
		r1 = rf(ctx, volumeID)
	} else {
		r1 = ret.Error(1)
	}

	return r0, r1
}
127716
func (d *driver) VolumeDetach(
	ctx types.Context,
	volumeID string,
	opts *types.VolumeDetachOpts) (*types.Volume, error) {
	// review volume with attachments to any host
	ec2vols, err := d.getVolume(ctx, volumeID, "")
	if err != nil {
		return nil, goof.WithError("error getting volume", err)
	}
	volumes, convErr := d.toTypesVolume(
		ctx, ec2vols, types.VolAttReqTrue)
	if convErr != nil {
		return nil, goof.WithError("error converting to types.Volume", convErr)
	}

	// no volumes to detach
	if len(volumes) == 0 {
		return nil, errNoVolReturned
	}

	// volume has no attachments
	if len(volumes[0].Attachments) == 0 {
		return nil, errVolAlreadyDetached
	}

	dvInput := &awsec2.DetachVolumeInput{
		VolumeId: &volumeID,
		Force:    &opts.Force,
	}

	// Detach volume using EC2 API call
	if _, err = mustSession(ctx).DetachVolume(dvInput); err != nil {
		return nil, goof.WithFieldsE(
			log.Fields{
				"provider": d.Name(),
				"volumeID": volumeID}, "error detaching volume", err)
	}

	if err = d.waitVolumeComplete(ctx, volumeID, waitVolumeDetach); err != nil {
		return nil, goof.WithError("error waiting for volume detach", err)
	}

	ctx.Info("detached volume", volumeID)

	// check if successful detach
	detachedVol, err := d.VolumeInspect(
		ctx, volumeID, &types.VolumeInspectOpts{
			Attachments: types.VolAttReqTrue,
			Opts:        opts.Opts,
		})
	if err != nil {
		return nil, goof.WithError("error getting volume", err)
	}

	return detachedVol, nil
}
223172
func (s *globalTaskService) TaskInspect(taskID int) *types.Task {
	s.RLock()
	defer s.RUnlock()
	if t, ok := s.tasks[taskID]; ok {
		return &t.Task
	}
	return nil
}
654870
func (in *VolumeSpec) DeepCopy() *VolumeSpec {
	if in == nil {
		return nil
	}
	out := new(VolumeSpec)
	in.DeepCopyInto(out)
	return out
}
730703
func (c *Client) InspectVolume(name string) (*Volume, error) {
	resp, err := c.do("GET", "/volumes/"+name, doOptions{})
	if err != nil {
		if e, ok := err.(*Error); ok && e.Status == http.StatusNotFound {
			return nil, ErrNoSuchVolume
		}
		return nil, err
	}
	defer resp.Body.Close()
	var volume Volume
	if err := json.NewDecoder(resp.Body).Decode(&volume); err != nil {
		return nil, err
	}
	return &volume, nil
}
476050
func NetworkInspect(name string) (network types.NetworkResource, err error) {
	var (
		ctx context.Context
		cli *client.Client
	)
	if ctx, cli, err = mgr.Client(); err == nil {
		network, err = cli.NetworkInspect(ctx, name, types.NetworkInspectOptions{})
	}
	return
}
1248423
func (d *driver) VolumeDetach(
	ctx types.Context,
	volumeID string,
	opts *types.VolumeDetachOpts) (*types.Volume, error) {

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

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

	// Check if volume is attached at all
	gceDisk, err := d.getDisk(ctx, zone, &volumeID)
	if err != nil {
		return nil, err
	}
	if gceDisk == nil {
		return nil, apiUtils.NewNotFoundError(volumeID)
	}

	if len(gceDisk.Users) == 0 {
		return nil, goof.New("Volume already detached")
	}

	err = d.detachVolume(ctx, gceDisk)
	if err != nil {
		return nil, goof.WithError("Error detaching disk", err)
	}

	vol, err := d.VolumeInspect(
		ctx, volumeID, &types.VolumeInspectOpts{
			Attachments: types.VolAttReq,
			Opts:        opts.Opts,
		},
	)
	if err != nil {
		return nil, goof.WithError("Error getting volume", err)
	}

	return vol, nil
}
305133
func TaskInspect(id string) (task swarm.Task, raw []byte, err error) {
	err = mgr.Do(func(ctx context.Context, cli *client.Client) (err error) {
		task, raw, err = cli.TaskInspectWithRaw(ctx, id)
		return
	})
	return
}
1301105
func (p *SdkPolicyManager) DefaultInspect(
	ctx context.Context,
	req *api.SdkOpenStoragePolicyDefaultInspectRequest,
) (*api.SdkOpenStoragePolicyDefaultInspectResponse, error) {
	var policyName string
	defaultPolicy := &api.SdkOpenStoragePolicyDefaultInspectResponse{}

	_, err := p.kv.GetVal(defaultPath, &policyName)
	// defaultPath key is not created
	if err == kvdb.ErrNotFound {
		return defaultPolicy, nil
	} else if err != nil {
		return nil, status.Errorf(codes.Internal, "Unable to retrive default policy details: %v", err)
	}

	// no default policy found
	if policyName == "" {
		return defaultPolicy, nil
	}

	// retrive default storage policy details
	inspResp, err := p.Inspect(context.Background(),
		&api.SdkOpenStoragePolicyInspectRequest{
			Name: policyName,
		},
	)
	if err != nil {
		return nil, err
	}

	return &api.SdkOpenStoragePolicyDefaultInspectResponse{
		StoragePolicy: inspResp.GetStoragePolicy(),
	}, nil
}
21467
func Convert_v1_VolumeAttachmentSpec_To_storage_VolumeAttachmentSpec(in *v1.VolumeAttachmentSpec, out *storage.VolumeAttachmentSpec, s conversion.Scope) error {
	return autoConvert_v1_VolumeAttachmentSpec_To_storage_VolumeAttachmentSpec(in, out, s)
}