{"modulePath":"github.com/codedellemc/libstorage","version":"v0.6.3","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package schema\n\n## Constants\n\n```go\nconst (\n\t// JSONSchema is the libStorage API JSON schema\n\tJSONSchema = `{\n    \"id\": \"https://github.com/codedellemc/libstorage\",\n    \"$schema\": \"http://json-schema.org/draft-04/schema#\",\n    \"title\": \"libStorage JSON Schema\",\n    \"definitions\": {\n\n\n        \"volume\": {\n            \"title\": \"Volume\",\n            \"description\": \"Volume provides information about a storage volume.\",\n            \"type\": \"object\",\n            \"properties\": {\n                \"id\": {\n                    \"type\": \"string\",\n                    \"description\": \"ID is a piece of information that uniquely identifies the volume on the storage platform to which the volume belongs. A volume ID is not guaranteed to be unique across multiple, configured services.\"\n                },\n                \"name\": {\n                    \"type\": \"string\",\n                    \"description\": \"The volume name.\"\n                },\n                \"type\": {\n                    \"type\": \"string\",\n                    \"description\": \"The volume type.\"\n                },\n                \"attachments\": {\n                    \"type\": \"array\",\n                    \"description\": \"The volume's attachments.\",\n                    \"items\": { \"$ref\": \"#/definitions/volumeAttachment\" }\n                },\n                \"attachmentState\": {\n                    \"type\": \"number\",\n                    \"description\": \"Indicates the volume's attachment state - 0=none,1=unknown,2=attached,3=available,4=unavailable. A volume is marked as attached if attached to the instance specified in the requesting API call. A volume that is attached but not to the requesting instance is marked as unavailable.\",\n                    \"minimum\": 0,\n                    \"maximum\": 4\n                },\n                \"availabilityZone\": {\n                    \"type\": \"string\",\n                    \"description\": \"The zone for which the volume is available.\"\n                },\n                \"encrypted\": {\n                    \"type\": \"boolean\",\n                    \"description\": \"A flag indicating whether or not the volume is encrypted.\"\n                },\n                \"iops\": {\n                    \"type\": \"number\",\n                    \"description\": \"The volume IOPs.\"\n                },\n                \"networkName\": {\n                    \"type\": \"string\",\n                    \"description\": \"The name of the network on which the volume resides.\"\n                },\n                \"size\": {\n                    \"type\": \"number\",\n                    \"description\": \"The volume size (GB).\"\n                },\n                \"status\": {\n                    \"type\": \"string\",\n                    \"description\": \"The volume status.\"\n                },\n                \"fields\": { \"$ref\": \"#/definitions/fields\" }\n            },\n            \"required\": [ \"id\", \"name\" ],\n            \"additionalProperties\": false\n        },\n\n\n        \"volumeAttachment\": {\n            \"title\": \"VolumeAttachment\",\n            \"description\": \" VolumeAttachment provides information about an object attached to a storage volume.\",\n            \"type\": \"object\",\n            \"properties\": {\n                \"instanceID\": { \"$ref\": \"#/definitions/instanceID\" },\n                \"deviceName\": {\n                    \"type\": \"string\",\n                    \"description\": \"The name of the device on to which the volume is mounted.\"\n                },\n                \"status\": {\n                    \"type\": \"string\",\n                    \"description\": \"The status of the attachment.\"\n                },\n                \"volumeID\": {\n                    \"type\": \"string\",\n                    \"description\": \"The ID of the volume to which the attachment belongs.\"\n                },\n                \"mountPoint\": {\n                    \"type\": \"string\",\n                    \"description\": \"The file system path to which the volume is mounted.\"\n                },\n                \"fields\": { \"$ref\": \"#/definitions/fields\" }\n            },\n            \"required\": [ \"instanceID\", \"deviceName\", \"volumeID\" ],\n            \"additionalProperties\": false\n        },\n\n\n        \"instanceID\": {\n            \"title\": \"InstanceID\",\n            \"description\": \"InstanceID identifies a host to a remote storage platform.\",\n            \"type\": \"object\",\n            \"properties\": {\n                \"id\": {\n                    \"type\": \"string\",\n                    \"description\": \"The instance ID.\"\n                },\n                \"driver\": {\n                    \"type\": \"string\",\n                    \"description\": \"The name of the driver that created the instance ID.\"\n                },\n                \"service\": {\n                    \"type\": \"string\",\n                    \"description\": \"The name of the service for which the instance ID is valid.\"\n                },\n                \"formatted\": {\n                    \"type\": \"boolean\",\n                    \"description\": \"A flag indicating whether or not the instance ID has been formatted by an instance inspection.\"\n                },\n                \"metadata\": {\n                    \"type\": \"object\",\n                    \"description\": \"Extra information about the instance ID.\"\n                }\n            },\n            \"required\": [ \"id\", \"driver\" ],\n            \"additionalProperties\": false\n        },\n\n\n        \"instance\": {\n            \"title\": \"Instance\",\n            \"description\": \"Instance is additional information about a host, generated using the InstanceID.\",\n            \"type\": \"object\",\n            \"properties\": {\n                \"instanceID\": { \"$ref\": \"#/definitions/instanceID\" },\n                \"name\": {\n                    \"type\": \"string\",\n                    \"description\": \"The name of the instance.\"\n                },\n                \"providerName\": {\n                    \"type\": \"string\",\n                    \"description\": \"The name of the provider that owns the object.\"\n                },\n                \"region\": {\n                    \"type\": \"string\",\n                    \"description\": \"The region from which the object originates.\"\n                },\n                \"fields\": { \"$ref\": \"#/definitions/fields\" }\n            },\n            \"required\": [ \"id\" ],\n            \"additionalProperties\": false\n        },\n\n\n        \"snapshot\": {\n            \"title\": \"Snapshot\",\n            \"description\": \"Snapshot provides information about a storage volume snapshot.\",\n            \"type\": \"object\",\n            \"properties\": {\n                \"id\": {\n                    \"type\": \"string\",\n                    \"description\": \"The snapshot's ID.\"\n                },\n                \"name\": {\n                    \"type\": \"string\",\n                    \"description\": \"The name of the snapshot.\"\n                },\n                \"description\": {\n                    \"type\": \"string\",\n                    \"description\": \"A description of the snapshot.\"\n                },\n                \"encrypted\": {\n                    \"type\": \"boolean\",\n                    \"description\": \"A flag indicating whether or not the snapshot is encrypted.\"\n\t\t},\n                \"startTime\": {\n                    \"type\": \"number\",\n                    \"description\": \"The time (epoch) at which the request to create the snapshot was submitted.\"\n                },\n                \"status\": {\n                    \"type\": \"string\",\n                    \"description\": \"The status of the snapshot.\"\n                },\n                \"volumeID\": {\n                    \"type\": \"string\",\n                    \"description\": \"The ID of the volume to which the snapshot belongs.\"\n                },\n                \"volumeSize\": {\n                    \"type\": \"number\",\n                    \"description\": \"The size of the volume to which the snapshot belongs.\"\n                },\n                \"fields\": { \"$ref\": \"#/definitions/fields\" }\n            },\n            \"required\": [ \"id\" ],\n            \"additionalProperties\": false\n        },\n\n\n        \"task\": {\n            \"type\": \"object\",\n            \"properties\": {\n                \"id\": {\n                    \"type\": \"number\",\n                    \"description\": \"The task's unique identifier.\"\n                },\n                \"name\": {\n                    \"type\": \"string\",\n                    \"description\": \"The name of the task.\"\n                },\n                \"user\": {\n                    \"type\": \"string\",\n                    \"description\": \"The name of the user that created the task.\"\n                },\n                \"completeTime\": {\n                    \"type\": \"number\",\n                    \"description\": \"The time stamp (epoch) when the task was completed.\"\n                },\n                \"queueTime\": {\n                    \"type\": \"number\",\n                    \"description\": \"The time stamp (epoch) when the task was created.\"\n                },\n                \"startTime\": {\n                    \"type\": \"number\",\n                    \"description\": \"The time stamp (epoch) when the task started running.\"\n                },\n                \"result\": {\n                    \"type\": \"object\",\n                    \"description\": \"The result of the operation.\"\n                },\n                \"error\": {\n                    \"type\": \"object\",\n                    \"description\": \"If the operation returned an error, this is it.\"\n                },\n                \"fields\": { \"$ref\": \"#/definitions/fields\" }\n            },\n            \"required\": [ \"id\", \"name\",  \"user\", \"queueTime\" ],\n            \"additionalProperties\": false\n        },\n\n\n        \"serviceInfo\": {\n            \"type\": \"object\",\n            \"properties\": {\n                \"name\": {\n                    \"type\": \"string\",\n                    \"description\": \"Name is the service's name.\"\n                },\n                \"instance\": { \"$ref\": \"#/definitions/instance\" },\n                \"driver\": { \"$ref\": \"#/definitions/driverInfo\" }\n            },\n            \"required\": [ \"name\", \"driver\" ],\n            \"additionalProperties\": false\n        },\n\n\n        \"driverInfo\": {\n            \"type\": \"object\",\n            \"properties\": {\n                \"name\": {\n                    \"type\": \"string\",\n                    \"description\": \"Ignore is a flag that indicates whether the client logic should invoke the GetNextAvailableDeviceName function prior to submitting an AttachVolume request to the server.\"\n                },\n                \"type\": {\n                    \"type\": \"string\",\n                    \"description\": \"Type is the type of storage the driver provides: block, nas, object.\"\n                },\n                \"nextDevice\": { \"$ref\": \"#/definitions/nextDeviceInfo\" }\n            },\n            \"required\": [ \"name\", \"type\" ],\n            \"additionalProperties\": false\n        },\n\n\n        \"nextDeviceInfo\": {\n            \"type\": \"object\",\n            \"properties\": {\n                \"ignore\": {\n                    \"type\": \"boolean\",\n                    \"description\": \"Ignore is a flag that indicates whether the client logic should invoke the GetNextAvailableDeviceName function prior to submitting an AttachVolume request to the server.\"\n                },\n                \"prefix\": {\n                    \"type\": \"string\",\n                    \"description\": \"Prefix is the first part of a device path's value after the \\\"/dev/\\\" portion. For example, the prefix in \\\"/dev/xvda\\\" is \\\"xvd\\\".\"\n                },\n                \"pattern\": {\n                    \"type\": \"string\",\n                    \"description\": \"Pattern is the regex to match the part of a device path after the prefix.\"\n                }\n            },\n            \"additionalProperties\": false\n        },\n\n\n        \"fields\": {\n            \"type\": \"object\",\n            \"description\": \"Fields are additional properties that can be defined for this type.\",\n            \"patternProperties\": {\n                \".+\": { \"type\": \"string\" }\n            },\n            \"additionalProperties\": true\n        },\n\n\n        \"volumeMap\": {\n            \"type\": \"object\",\n            \"patternProperties\": {\n                \"^.+$\": { \"$ref\": \"#/definitions/volume\" }\n            },\n            \"additionalProperties\": false\n        },\n\n\n        \"snapshotMap\": {\n            \"type\": \"object\",\n            \"patternProperties\": {\n                \"^.+$\": { \"$ref\": \"#/definitions/snapshot\" }\n            },\n            \"additionalProperties\": false\n        },\n\n\n        \"taskMap\": {\n            \"type\": \"object\",\n            \"patternProperties\": {\n                \"^.+$\": { \"$ref\": \"#/definitions/task\" }\n            },\n            \"additionalProperties\": false\n        },\n\n\n        \"serviceVolumeMap\": {\n            \"type\": \"object\",\n            \"patternProperties\": {\n                \"^.+$\": { \"$ref\": \"#/definitions/volumeMap\" }\n            },\n            \"additionalProperties\": false\n        },\n\n\n        \"serviceSnapshotMap\": {\n            \"type\": \"object\",\n            \"patternProperties\": {\n                \"^.+$\": { \"$ref\": \"#/definitions/snapshotMap\" }\n            },\n            \"additionalProperties\": false\n        },\n\n\n        \"serviceTaskMap\": {\n            \"type\": \"object\",\n            \"patternProperties\": {\n                \"^.+$\": { \"$ref\": \"#/definitions/taskMap\" }\n            },\n            \"additionalProperties\": false\n        },\n\n\n        \"serviceInfoMap\": {\n            \"type\": \"object\",\n            \"patternProperties\": {\n                \"^.+$\": { \"$ref\": \"#/definitions/serviceInfo\" }\n            },\n            \"additionalProperties\": false\n        },\n\n\n        \"driverInfoMap\": {\n            \"type\": \"object\",\n            \"patternProperties\": {\n                \"^.+$\": { \"$ref\": \"#/definitions/driverInfo\" }\n            },\n            \"additionalProperties\": false\n        },\n\n\n        \"opts\": {\n            \"type\": \"object\",\n            \"description\": \"Opts are additional properties that can be defined for POST requests.\",\n            \"patternProperties\": {\n                \"^.+$\": {\n                    \"anyOf\": [\n                        { \"type\": \"array\" },\n                        { \"type\": \"boolean\" },\n                        { \"type\": \"integer\" },\n                        { \"type\": \"number\" },\n                        { \"type\": \"null\" },\n                        { \"type\": \"string\" },\n                        { \"$ref\": \"#/definitions/opts\" }\n                    ]\n                }\n            },\n            \"additionalProperties\": true\n        },\n\n\n        \"volumeCreateRequest\": {\n            \"type\": \"object\",\n            \"properties\": {\n                \"name\": {\n                    \"type\": \"string\"\n                },\n                \"availabilityZone\": {\n                    \"type\": \"string\"\n                },\n                \"encrypted\": {\n                    \"type\": \"boolean\"\n                },\n                \"encryptionKey\": {\n                    \"type\": \"string\"\n                },\n                \"iops\": {\n                    \"type\": \"number\"\n                },\n                \"size\": {\n                    \"type\": \"number\"\n                },\n                \"type\": {\n                    \"type\": \"string\"\n                },\n                \"opts\": { \"$ref\" : \"#/definitions/opts\" }\n            },\n            \"required\": [ \"name\" ],\n            \"additionalProperties\": false\n        },\n\n\n        \"volumeCopyRequest\": {\n            \"type\": \"object\",\n            \"properties\": {\n                \"volumeName\": {\n                    \"type\": \"string\"\n                },\n                \"opts\": { \"$ref\" : \"#/definitions/opts\" }\n            },\n            \"required\": [ \"volumeName\" ],\n            \"additionalProperties\": false\n        },\n\n\n        \"volumeSnapshotRequest\": {\n            \"type\": \"object\",\n            \"properties\": {\n                \"snapshotName\": {\n                    \"type\": \"string\"\n                },\n                \"opts\": { \"$ref\" : \"#/definitions/opts\" }\n            },\n            \"required\": [ \"snapshotName\" ],\n            \"additionalProperties\": false\n        },\n\n\n        \"volumeAttachRequest\": {\n            \"type\": \"object\",\n            \"properties\": {\n                \"nextDeviceName\": {\n                    \"type\": \"string\"\n                },\n                \"force\": {\n                    \"type\": \"boolean\"\n                },\n                \"opts\": { \"$ref\" : \"#/definitions/opts\" }\n            },\n            \"additionalProperties\": false\n        },\n\n\n        \"volumeAttachResponse\": {\n            \"type\": \"object\",\n            \"properties\": {\n                \"volume\": { \"$ref\" : \"#/definitions/volume\" },\n                \"attachToken\" : { \"type\": \"string\" }\n            },\n            \"required\": [ \"volume\", \"attachToken\" ],\n            \"additionalProperties\": false\n        },\n\n\n        \"volumeDetachRequest\": {\n            \"type\": \"object\",\n            \"properties\": {\n                \"force\": {\n                    \"type\": \"boolean\"\n                },\n                \"opts\": { \"$ref\" : \"#/definitions/opts\" }\n            },\n            \"additionalProperties\": false\n        },\n\n\n        \"snapshotCopyRequest\": {\n            \"type\": \"object\",\n            \"properties\": {\n                \"snapshotName\": {\n                    \"type\": \"string\"\n                },\n                \"destinationID\": {\n                    \"type\": \"string\"\n                },\n                \"opts\": { \"$ref\" : \"#/definitions/opts\" }\n            },\n            \"required\": [ \"snapshotName\", \"destinationID\" ],\n            \"additionalProperties\": false\n        },\n\n\n        \"snapshotRemoveRequest\": {\n            \"type\": \"object\",\n            \"properties\": {\n                \"opts\": { \"$ref\" : \"#/definitions/opts\" }\n            },\n            \"additionalProperties\": false\n        },\n\n\n        \"error\": {\n            \"type\": \"object\",\n            \"properties\": {\n                \"message\": {\n                    \"type\": \"string\",\n                    \"pattern\": \"^.{10,}|.*[Ee]rror$\"\n                },\n                \"status\": {\n                    \"type\": \"number\",\n                    \"minimum\": 400,\n                    \"maximum\": 599\n                },\n                \"error\": {\n                    \"type\": \"object\",\n                    \"additionalProperties\": true\n                }\n            },\n            \"required\": [ \"message\", \"status\" ],\n            \"additionalProperties\": false\n        }\n    }\n}\n`\n)\n```\n\n## Variables\n\n```go\nvar (\n\n\t// VolumeSchema is the JSON schema for the Volume resource.\n\tVolumeSchema = buildSchemaVar(\"volume\")\n\n\t// VolumeAttachmentSchema is the JSON schema for the VolumeAttachment\n\t// resource.\n\tVolumeAttachmentSchema = buildSchemaVar(\"volumeAttachment\")\n\n\t// ServiceVolumeMapSchema is the JSON schema for the ServiceVolumeMap\n\t// resource.\n\tServiceVolumeMapSchema = buildSchemaVar(\"serviceVolumeMap\")\n\n\t// ServiceSnapshotMapSchema is the JSON schema for the ServiceSnapshotMap\n\t// resource.\n\tServiceSnapshotMapSchema = buildSchemaVar(\"serviceSnapshotMap\")\n\n\t// VolumeMapSchema is the JSON schema for the VolumeMap resource.\n\tVolumeMapSchema = buildSchemaVar(\"volumeMap\")\n\n\t// SnapshotMapSchema is the JSON schema for the SnapshotMap resource.\n\tSnapshotMapSchema = buildSchemaVar(\"snapshotMap\")\n\n\t// SnapshotSchema is the JSON schema for the Snapshot resource.\n\tSnapshotSchema = buildSchemaVar(\"snapshot\")\n\n\t// ServiceInfoSchema is the JSON schema for the ServiceInfo resource.\n\tServiceInfoSchema = buildSchemaVar(\"serviceInfo\")\n\n\t// ServiceInfoMapSchema is the JSON schemea for a map[string]*ServiceInfo.\n\tServiceInfoMapSchema = buildSchemaVar(\"serviceInfoMap\")\n\n\t// DriverInfoSchema is the JSON schema for the DriverInfo resource.\n\tDriverInfoSchema = buildSchemaVar(\"driverInfo\")\n\n\t// ExecutorInfoSchema is the JSON schema for the ExecutorInfo resource.\n\tExecutorInfoSchema = buildSchemaVar(\"executorInfo\")\n\n\t// VolumeCreateRequestSchema is the JSON schema for a Volume creation\n\t// request.\n\tVolumeCreateRequestSchema = buildSchemaVar(\"volumeCreateRequest\")\n\n\t// VolumeCopyRequestSchema is the JSON schema for a Volume copy\n\t// request.\n\tVolumeCopyRequestSchema = buildSchemaVar(\"volumeCopyRequest\")\n\n\t// VolumeSnapshotRequestSchema is the JSON schema for a Volume snapshot\n\t// request.\n\tVolumeSnapshotRequestSchema = buildSchemaVar(\"volumeSnapshotRequest\")\n\n\t// VolumeAttachRequestSchema is the JSON schema for a Volume attach\n\t// request.\n\tVolumeAttachRequestSchema = buildSchemaVar(\"volumeAttachRequest\")\n\n\t// VolumeAttachResponseSchema is the JSON schema for a Volume attach\n\t// response.\n\tVolumeAttachResponseSchema = buildSchemaVar(\"volumeAttachResponse\")\n\n\t// VolumeDetachRequestSchema is the JSON schema for a Volume detach\n\t// request.\n\tVolumeDetachRequestSchema = buildSchemaVar(\"volumeDetachRequest\")\n\n\t// SnapshotCopyRequestSchema is the JSON schema for a Snapshot copy\n\t// request.\n\tSnapshotCopyRequestSchema = buildSchemaVar(\"snapshotCopyRequest\")\n\n\t// VolumeCreateFromSnapshotRequestSchema is the JSON schema for a\n\t// Volume create from Snapshot request.\n\tVolumeCreateFromSnapshotRequestSchema = buildSchemaVar(\n\t\t\"volumeCreateFromSnapshotRequest\")\n)\n```\n\n## Functions\n\n```go\nfunc Validate(ctx types.Context, s, d []byte) error\n```\nValidate validates the provided data (d) against the provided schema (s).\n\n```go\nfunc ValidateObj(ctx types.Context, s []byte, i interface{}) error\n```\nValidateObj validates an object using a schema.\n\n```go\nfunc ValidateSnapshot(v *types.Snapshot) ([]byte, error)\n```\nValidateSnapshot validates a Snapshot object using the JSON schema. If the object is valid no error is returned. The first return value, the object marshaled to JSON, is returned whether or not the validation is successful.\n\n```go\nfunc ValidateVolume(v *types.Volume) ([]byte, error)\n```\nValidateVolume validates a Volume object using the JSON schema. If the object is valid no error is returned. The first return value, the object marshaled to JSON, is returned whether or not the validation is successful.\n\n```go\nfunc ValidateVolumeCreateRequest(\n\tv *types.VolumeCreateRequest) ([]byte, error)\n```\nValidateVolumeCreateRequest validates a VolumeCreateRequest object using the JSON schema. If the object is valid no error is returned. The first return value, the object marshaled to JSON, is returned whether or not the validation is successful.\n\n```go\nfunc ValidateVolumeSnapshotRequest(\n\tv *types.VolumeSnapshotRequest) ([]byte, error)\n```\nValidateVolumeSnapshotRequest validates a VolumeSnapshotRequest object using the JSON schema. If the object is valid no error is returned. The first return value, the object marshaled to JSON, is returned whether or not the validation is successful.\n\n","path":"github.com/codedellemc/libstorage/api/utils/schema","name":"schema","synopsis":"","isRedistributable":true}
