mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-09-17 08:10:38 -04:00
feat(graph): add the driveItem versions API
Implements the MS Graph driveItemVersion operations on files:
- GET .../items/{id}/versions lists the versions, newest first
- GET .../versions/{version-id} returns one version, "current" describes the file itself
- GET .../versions/{version-id}/content redirects to a signed download url for the version
- POST .../versions/{version-id}/restoreVersion makes the version the current content
The operations map onto ListFileVersions and RestoreFileVersion of the
gateway. Version downloads point at the WebDAV meta endpoint, signed the
same way as the driveItem download url. The download url is only added
when requested via $select.
The driveItemVersion models are vendored from the regenerated client of
opencloud-eu/libre-graph-api#73 until that spec change is merged and the
dependency can be bumped.
This commit is contained in:
1 parent
5807eea186
commit
be8cd461b4
5 files changed
+1063
No files matched your search
Generated
Vendored
+126
@@ -0,0 +1,126 @@
|
||||
/*
|
||||
Libre Graph API
|
||||
|
||||
Libre Graph is a free API for cloud collaboration inspired by the MS Graph API.
|
||||
|
||||
API version: v1.0.8
|
||||
*/
|
||||
|
||||
// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
|
||||
|
||||
package libregraph
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
)
|
||||
|
||||
// checks if the CollectionOfDriveItemVersions type satisfies the MappedNullable interface at compile time
|
||||
var _ MappedNullable = &CollectionOfDriveItemVersions{}
|
||||
|
||||
// CollectionOfDriveItemVersions struct for CollectionOfDriveItemVersions
|
||||
type CollectionOfDriveItemVersions struct {
|
||||
Value []DriveItemVersion `json:"value,omitempty"`
|
||||
}
|
||||
|
||||
// NewCollectionOfDriveItemVersions instantiates a new CollectionOfDriveItemVersions object
|
||||
// This constructor will assign default values to properties that have it defined,
|
||||
// and makes sure properties required by API are set, but the set of arguments
|
||||
// will change when the set of required properties is changed
|
||||
func NewCollectionOfDriveItemVersions() *CollectionOfDriveItemVersions {
|
||||
this := CollectionOfDriveItemVersions{}
|
||||
return &this
|
||||
}
|
||||
|
||||
// NewCollectionOfDriveItemVersionsWithDefaults instantiates a new CollectionOfDriveItemVersions object
|
||||
// This constructor will only assign default values to properties that have it defined,
|
||||
// but it doesn't guarantee that properties required by API are set
|
||||
func NewCollectionOfDriveItemVersionsWithDefaults() *CollectionOfDriveItemVersions {
|
||||
this := CollectionOfDriveItemVersions{}
|
||||
return &this
|
||||
}
|
||||
|
||||
// GetValue returns the Value field value if set, zero value otherwise.
|
||||
func (o *CollectionOfDriveItemVersions) GetValue() []DriveItemVersion {
|
||||
if o == nil || IsNil(o.Value) {
|
||||
var ret []DriveItemVersion
|
||||
return ret
|
||||
}
|
||||
return o.Value
|
||||
}
|
||||
|
||||
// GetValueOk returns a tuple with the Value field value if set, nil otherwise
|
||||
// and a boolean to check if the value has been set.
|
||||
func (o *CollectionOfDriveItemVersions) GetValueOk() ([]DriveItemVersion, bool) {
|
||||
if o == nil || IsNil(o.Value) {
|
||||
return nil, false
|
||||
}
|
||||
return o.Value, true
|
||||
}
|
||||
|
||||
// HasValue returns a boolean if a field has been set.
|
||||
func (o *CollectionOfDriveItemVersions) HasValue() bool {
|
||||
if o != nil && !IsNil(o.Value) {
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
// SetValue gets a reference to the given []DriveItemVersion and assigns it to the Value field.
|
||||
func (o *CollectionOfDriveItemVersions) SetValue(v []DriveItemVersion) {
|
||||
o.Value = v
|
||||
}
|
||||
|
||||
func (o CollectionOfDriveItemVersions) MarshalJSON() ([]byte, error) {
|
||||
toSerialize,err := o.ToMap()
|
||||
if err != nil {
|
||||
return []byte{}, err
|
||||
}
|
||||
return json.Marshal(toSerialize)
|
||||
}
|
||||
|
||||
func (o CollectionOfDriveItemVersions) ToMap() (map[string]interface{}, error) {
|
||||
toSerialize := map[string]interface{}{}
|
||||
if !IsNil(o.Value) {
|
||||
toSerialize["value"] = o.Value
|
||||
}
|
||||
return toSerialize, nil
|
||||
}
|
||||
|
||||
type NullableCollectionOfDriveItemVersions struct {
|
||||
value *CollectionOfDriveItemVersions
|
||||
isSet bool
|
||||
}
|
||||
|
||||
func (v NullableCollectionOfDriveItemVersions) Get() *CollectionOfDriveItemVersions {
|
||||
return v.value
|
||||
}
|
||||
|
||||
func (v *NullableCollectionOfDriveItemVersions) Set(val *CollectionOfDriveItemVersions) {
|
||||
v.value = val
|
||||
v.isSet = true
|
||||
}
|
||||
|
||||
func (v NullableCollectionOfDriveItemVersions) IsSet() bool {
|
||||
return v.isSet
|
||||
}
|
||||
|
||||
func (v *NullableCollectionOfDriveItemVersions) Unset() {
|
||||
v.value = nil
|
||||
v.isSet = false
|
||||
}
|
||||
|
||||
func NewNullableCollectionOfDriveItemVersions(val *CollectionOfDriveItemVersions) *NullableCollectionOfDriveItemVersions {
|
||||
return &NullableCollectionOfDriveItemVersions{value: val, isSet: true}
|
||||
}
|
||||
|
||||
func (v NullableCollectionOfDriveItemVersions) MarshalJSON() ([]byte, error) {
|
||||
return json.Marshal(v.value)
|
||||
}
|
||||
|
||||
func (v *NullableCollectionOfDriveItemVersions) UnmarshalJSON(src []byte) error {
|
||||
v.isSet = true
|
||||
return json.Unmarshal(src, &v.value)
|
||||
}
|
||||
|
||||
|
||||
+312
@@ -0,0 +1,312 @@
|
||||
/*
|
||||
Libre Graph API
|
||||
|
||||
Libre Graph is a free API for cloud collaboration inspired by the MS Graph API.
|
||||
|
||||
API version: v1.0.8
|
||||
*/
|
||||
|
||||
// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
|
||||
|
||||
package libregraph
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"time"
|
||||
)
|
||||
|
||||
// checks if the DriveItemVersion type satisfies the MappedNullable interface at compile time
|
||||
var _ MappedNullable = &DriveItemVersion{}
|
||||
|
||||
// DriveItemVersion Represents a specific version of a driveItem. Read-only. Modeled on the MS Graph driveItemVersion resource (https://learn.microsoft.com/en-us/graph/api/resources/driveitemversion). The `publication` facet is not supported, OpenCloud has no checkout / publish workflow.
|
||||
type DriveItemVersion struct {
|
||||
// The ID of the version. Read-only.
|
||||
Id *string `json:"id,omitempty"`
|
||||
LastModifiedBy *IdentitySet `json:"lastModifiedBy,omitempty"`
|
||||
// Date and time the version was last modified. Read-only.
|
||||
LastModifiedDateTime *time.Time `json:"lastModifiedDateTime,omitempty" validate:"regexp=^[0-9]{4,}-(0[1-9]|1[012])-(0[1-9]|[12][0-9]|3[01])[Tt]([01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9]([.][0-9]{1,12})?([Zz]|[+-][0-9][0-9]:[0-9][0-9])$"`
|
||||
// Size of the version content in bytes. Read-only.
|
||||
Size *int64 `json:"size,omitempty"`
|
||||
// The content stream of this version. Use the `/content` endpoint of the version to download it.
|
||||
Content *string `json:"content,omitempty"`
|
||||
// A pre-authenticated URL that can be used to download the content of this version without providing an Authorization header. The URL is short-lived and cannot be cached. This annotation is only populated when explicitly requested via `$select`, matching the behaviour of the annotation on the driveItem.
|
||||
MicrosoftGraphDownloadUrl *string `json:"@microsoft.graph.downloadUrl,omitempty"`
|
||||
}
|
||||
|
||||
// NewDriveItemVersion instantiates a new DriveItemVersion object
|
||||
// This constructor will assign default values to properties that have it defined,
|
||||
// and makes sure properties required by API are set, but the set of arguments
|
||||
// will change when the set of required properties is changed
|
||||
func NewDriveItemVersion() *DriveItemVersion {
|
||||
this := DriveItemVersion{}
|
||||
return &this
|
||||
}
|
||||
|
||||
// NewDriveItemVersionWithDefaults instantiates a new DriveItemVersion object
|
||||
// This constructor will only assign default values to properties that have it defined,
|
||||
// but it doesn't guarantee that properties required by API are set
|
||||
func NewDriveItemVersionWithDefaults() *DriveItemVersion {
|
||||
this := DriveItemVersion{}
|
||||
return &this
|
||||
}
|
||||
|
||||
// GetId returns the Id field value if set, zero value otherwise.
|
||||
func (o *DriveItemVersion) GetId() string {
|
||||
if o == nil || IsNil(o.Id) {
|
||||
var ret string
|
||||
return ret
|
||||
}
|
||||
return *o.Id
|
||||
}
|
||||
|
||||
// GetIdOk returns a tuple with the Id field value if set, nil otherwise
|
||||
// and a boolean to check if the value has been set.
|
||||
func (o *DriveItemVersion) GetIdOk() (*string, bool) {
|
||||
if o == nil || IsNil(o.Id) {
|
||||
return nil, false
|
||||
}
|
||||
return o.Id, true
|
||||
}
|
||||
|
||||
// HasId returns a boolean if a field has been set.
|
||||
func (o *DriveItemVersion) HasId() bool {
|
||||
if o != nil && !IsNil(o.Id) {
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
// SetId gets a reference to the given string and assigns it to the Id field.
|
||||
func (o *DriveItemVersion) SetId(v string) {
|
||||
o.Id = &v
|
||||
}
|
||||
|
||||
// GetLastModifiedBy returns the LastModifiedBy field value if set, zero value otherwise.
|
||||
func (o *DriveItemVersion) GetLastModifiedBy() IdentitySet {
|
||||
if o == nil || IsNil(o.LastModifiedBy) {
|
||||
var ret IdentitySet
|
||||
return ret
|
||||
}
|
||||
return *o.LastModifiedBy
|
||||
}
|
||||
|
||||
// GetLastModifiedByOk returns a tuple with the LastModifiedBy field value if set, nil otherwise
|
||||
// and a boolean to check if the value has been set.
|
||||
func (o *DriveItemVersion) GetLastModifiedByOk() (*IdentitySet, bool) {
|
||||
if o == nil || IsNil(o.LastModifiedBy) {
|
||||
return nil, false
|
||||
}
|
||||
return o.LastModifiedBy, true
|
||||
}
|
||||
|
||||
// HasLastModifiedBy returns a boolean if a field has been set.
|
||||
func (o *DriveItemVersion) HasLastModifiedBy() bool {
|
||||
if o != nil && !IsNil(o.LastModifiedBy) {
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
// SetLastModifiedBy gets a reference to the given IdentitySet and assigns it to the LastModifiedBy field.
|
||||
func (o *DriveItemVersion) SetLastModifiedBy(v IdentitySet) {
|
||||
o.LastModifiedBy = &v
|
||||
}
|
||||
|
||||
// GetLastModifiedDateTime returns the LastModifiedDateTime field value if set, zero value otherwise.
|
||||
func (o *DriveItemVersion) GetLastModifiedDateTime() time.Time {
|
||||
if o == nil || IsNil(o.LastModifiedDateTime) {
|
||||
var ret time.Time
|
||||
return ret
|
||||
}
|
||||
return *o.LastModifiedDateTime
|
||||
}
|
||||
|
||||
// GetLastModifiedDateTimeOk returns a tuple with the LastModifiedDateTime field value if set, nil otherwise
|
||||
// and a boolean to check if the value has been set.
|
||||
func (o *DriveItemVersion) GetLastModifiedDateTimeOk() (*time.Time, bool) {
|
||||
if o == nil || IsNil(o.LastModifiedDateTime) {
|
||||
return nil, false
|
||||
}
|
||||
return o.LastModifiedDateTime, true
|
||||
}
|
||||
|
||||
// HasLastModifiedDateTime returns a boolean if a field has been set.
|
||||
func (o *DriveItemVersion) HasLastModifiedDateTime() bool {
|
||||
if o != nil && !IsNil(o.LastModifiedDateTime) {
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
// SetLastModifiedDateTime gets a reference to the given time.Time and assigns it to the LastModifiedDateTime field.
|
||||
func (o *DriveItemVersion) SetLastModifiedDateTime(v time.Time) {
|
||||
o.LastModifiedDateTime = &v
|
||||
}
|
||||
|
||||
// GetSize returns the Size field value if set, zero value otherwise.
|
||||
func (o *DriveItemVersion) GetSize() int64 {
|
||||
if o == nil || IsNil(o.Size) {
|
||||
var ret int64
|
||||
return ret
|
||||
}
|
||||
return *o.Size
|
||||
}
|
||||
|
||||
// GetSizeOk returns a tuple with the Size field value if set, nil otherwise
|
||||
// and a boolean to check if the value has been set.
|
||||
func (o *DriveItemVersion) GetSizeOk() (*int64, bool) {
|
||||
if o == nil || IsNil(o.Size) {
|
||||
return nil, false
|
||||
}
|
||||
return o.Size, true
|
||||
}
|
||||
|
||||
// HasSize returns a boolean if a field has been set.
|
||||
func (o *DriveItemVersion) HasSize() bool {
|
||||
if o != nil && !IsNil(o.Size) {
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
// SetSize gets a reference to the given int64 and assigns it to the Size field.
|
||||
func (o *DriveItemVersion) SetSize(v int64) {
|
||||
o.Size = &v
|
||||
}
|
||||
|
||||
// GetContent returns the Content field value if set, zero value otherwise.
|
||||
func (o *DriveItemVersion) GetContent() string {
|
||||
if o == nil || IsNil(o.Content) {
|
||||
var ret string
|
||||
return ret
|
||||
}
|
||||
return *o.Content
|
||||
}
|
||||
|
||||
// GetContentOk returns a tuple with the Content field value if set, nil otherwise
|
||||
// and a boolean to check if the value has been set.
|
||||
func (o *DriveItemVersion) GetContentOk() (*string, bool) {
|
||||
if o == nil || IsNil(o.Content) {
|
||||
return nil, false
|
||||
}
|
||||
return o.Content, true
|
||||
}
|
||||
|
||||
// HasContent returns a boolean if a field has been set.
|
||||
func (o *DriveItemVersion) HasContent() bool {
|
||||
if o != nil && !IsNil(o.Content) {
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
// SetContent gets a reference to the given string and assigns it to the Content field.
|
||||
func (o *DriveItemVersion) SetContent(v string) {
|
||||
o.Content = &v
|
||||
}
|
||||
|
||||
// GetMicrosoftGraphDownloadUrl returns the MicrosoftGraphDownloadUrl field value if set, zero value otherwise.
|
||||
func (o *DriveItemVersion) GetMicrosoftGraphDownloadUrl() string {
|
||||
if o == nil || IsNil(o.MicrosoftGraphDownloadUrl) {
|
||||
var ret string
|
||||
return ret
|
||||
}
|
||||
return *o.MicrosoftGraphDownloadUrl
|
||||
}
|
||||
|
||||
// GetMicrosoftGraphDownloadUrlOk returns a tuple with the MicrosoftGraphDownloadUrl field value if set, nil otherwise
|
||||
// and a boolean to check if the value has been set.
|
||||
func (o *DriveItemVersion) GetMicrosoftGraphDownloadUrlOk() (*string, bool) {
|
||||
if o == nil || IsNil(o.MicrosoftGraphDownloadUrl) {
|
||||
return nil, false
|
||||
}
|
||||
return o.MicrosoftGraphDownloadUrl, true
|
||||
}
|
||||
|
||||
// HasMicrosoftGraphDownloadUrl returns a boolean if a field has been set.
|
||||
func (o *DriveItemVersion) HasMicrosoftGraphDownloadUrl() bool {
|
||||
if o != nil && !IsNil(o.MicrosoftGraphDownloadUrl) {
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
// SetMicrosoftGraphDownloadUrl gets a reference to the given string and assigns it to the MicrosoftGraphDownloadUrl field.
|
||||
func (o *DriveItemVersion) SetMicrosoftGraphDownloadUrl(v string) {
|
||||
o.MicrosoftGraphDownloadUrl = &v
|
||||
}
|
||||
|
||||
func (o DriveItemVersion) MarshalJSON() ([]byte, error) {
|
||||
toSerialize,err := o.ToMap()
|
||||
if err != nil {
|
||||
return []byte{}, err
|
||||
}
|
||||
return json.Marshal(toSerialize)
|
||||
}
|
||||
|
||||
func (o DriveItemVersion) ToMap() (map[string]interface{}, error) {
|
||||
toSerialize := map[string]interface{}{}
|
||||
if !IsNil(o.Id) {
|
||||
toSerialize["id"] = o.Id
|
||||
}
|
||||
if !IsNil(o.LastModifiedBy) {
|
||||
toSerialize["lastModifiedBy"] = o.LastModifiedBy
|
||||
}
|
||||
if !IsNil(o.LastModifiedDateTime) {
|
||||
toSerialize["lastModifiedDateTime"] = o.LastModifiedDateTime
|
||||
}
|
||||
if !IsNil(o.Size) {
|
||||
toSerialize["size"] = o.Size
|
||||
}
|
||||
if !IsNil(o.Content) {
|
||||
toSerialize["content"] = o.Content
|
||||
}
|
||||
if !IsNil(o.MicrosoftGraphDownloadUrl) {
|
||||
toSerialize["@microsoft.graph.downloadUrl"] = o.MicrosoftGraphDownloadUrl
|
||||
}
|
||||
return toSerialize, nil
|
||||
}
|
||||
|
||||
type NullableDriveItemVersion struct {
|
||||
value *DriveItemVersion
|
||||
isSet bool
|
||||
}
|
||||
|
||||
func (v NullableDriveItemVersion) Get() *DriveItemVersion {
|
||||
return v.value
|
||||
}
|
||||
|
||||
func (v *NullableDriveItemVersion) Set(val *DriveItemVersion) {
|
||||
v.value = val
|
||||
v.isSet = true
|
||||
}
|
||||
|
||||
func (v NullableDriveItemVersion) IsSet() bool {
|
||||
return v.isSet
|
||||
}
|
||||
|
||||
func (v *NullableDriveItemVersion) Unset() {
|
||||
v.value = nil
|
||||
v.isSet = false
|
||||
}
|
||||
|
||||
func NewNullableDriveItemVersion(val *DriveItemVersion) *NullableDriveItemVersion {
|
||||
return &NullableDriveItemVersion{value: val, isSet: true}
|
||||
}
|
||||
|
||||
func (v NullableDriveItemVersion) MarshalJSON() ([]byte, error) {
|
||||
return json.Marshal(v.value)
|
||||
}
|
||||
|
||||
func (v *NullableDriveItemVersion) UnmarshalJSON(src []byte) error {
|
||||
v.isSet = true
|
||||
return json.Unmarshal(src, &v.value)
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user