Skip to content

Large File Upload Task #530

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 32 commits into from
May 2, 2024
Merged
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
6ed2bfa
Intitialize Large file upload models'
shemogumbe Mar 5, 2024
da8660f
Implement model classes for large file upload
shemogumbe Mar 5, 2024
d5db8bd
Large file upload draft implementation
shemogumbe Mar 6, 2024
cd6ad7f
Large file upload-code customization
shemogumbe Mar 8, 2024
32b5c40
convert upload session to data class
shemogumbe Mar 25, 2024
533fc96
update parse node methods
shemogumbe Mar 25, 2024
0f98833
Update Large file upload create session
shemogumbe Mar 25, 2024
0d4aafc
test file upload
shemogumbe Mar 25, 2024
77c67e1
Tested upload session does an upload
shemogumbe Mar 25, 2024
d7cd14f
debug create upload sesion
shemogumbe Mar 27, 2024
06270a0
Fix Create large file upload session
shemogumbe Apr 20, 2024
b506460
Fix upload and cencellation
shemogumbe Apr 20, 2024
0d5d0d7
Merge branch 'main' into shem/large_file_upload
shemogumbe Apr 20, 2024
405ff07
fix code formating
shemogumbe Apr 20, 2024
93909f9
fix linting issues
shemogumbe Apr 20, 2024
1f396da
Fixed LFU making it possible to upload files to drive in chunks
shemogumbe Apr 21, 2024
00896f4
ignore type on async session
shemogumbe Apr 21, 2024
3b2441d
Fixed upload
shemogumbe Apr 22, 2024
4aed868
Fixed upload session and upload task
shemogumbe Apr 22, 2024
b1f3eee
Fix linting issues
shemogumbe Apr 22, 2024
8207762
clean up code
shemogumbe Apr 22, 2024
4a4ab93
Update changelong ad API Version
shemogumbe Apr 22, 2024
073e0a9
Update src/msgraph_core/tasks/large_file_upload.py
shemogumbe Apr 24, 2024
c7ad84d
remove unnecesary code
shemogumbe Apr 24, 2024
70b2477
Merge branch 'shem/large_file_upload' of github.com:microsoftgraph/ms…
shemogumbe Apr 24, 2024
3d4e11d
use generic request adapter
shemogumbe Apr 24, 2024
1271d90
implement upload result
shemogumbe Apr 24, 2024
ff2fd27
fix missing fieldsd in result type
shemogumbe Apr 24, 2024
f65b9f0
fix missing fieldsd in result type
shemogumbe Apr 24, 2024
69643db
allow custom Parsable in LFU construtor
shemogumbe Apr 24, 2024
221ede5
Fixed response for drive item
shemogumbe Apr 26, 2024
9754d1c
fixed response type for drive item
shemogumbe Apr 26, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -133,3 +133,4 @@ dmypy.json
.idea/

app*.py
app*
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [1.0.1] - 2024-04-22

### Added

### Changed
-Enabled Large File Upload and Page iterator support


## [1.0.0] - 2023-10-31

### Added
Expand Down
2 changes: 1 addition & 1 deletion src/msgraph_core/_constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@
"""
DEFAULT_REQUEST_TIMEOUT = 100
DEFAULT_CONNECTION_TIMEOUT = 30
SDK_VERSION = '1.0.0'
SDK_VERSION = '1.0.1'
MS_DEFAULT_SCOPE = 'https://graph.microsoft.com/.default'
4 changes: 3 additions & 1 deletion src/msgraph_core/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from .page_result import PageResult
from .large_file_upload_session import LargeFileUploadSession
from .large_file_upload_create_session_body import LargeFileUploadCreateSessionBody

__all__ = ['PageResult']
__all__ = ['PageResult', 'LargeFileUploadSession', 'LargeFileUploadCreateSessionBody']
33 changes: 33 additions & 0 deletions src/msgraph_core/models/large_file_upload_create_session_body.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
from kiota_abstractions.serialization.additional_data_holder import AdditionalDataHolder
from kiota_abstractions.serialization.parsable import Parsable
from kiota_abstractions.serialization.serialization_writer import SerializationWriter
from kiota_abstractions.store.backed_model import BackedModel
from kiota_abstractions.store.backing_store import BackingStore
from kiota_abstractions.store.backing_store_factory_singleton import BackingStoreFactorySingleton


class LargeFileUploadCreateSessionBody(Parsable, AdditionalDataHolder, BackedModel):

def __init__(self):
singleton = BackingStoreFactorySingleton.get_instance()
factory = singleton.backing_store_factory
self.backing_store = factory.create_backing_store(
) # throws error -AttributeError: type object
#'BackingStoreFactorySingleton' has no attribute
# '_BackingStoreFactorySingleton__instance'
self.set_additional_data([])

def get_additional_data(self):
return self.backing_store.get('additional_data')

def set_additional_data(self, value):
self.backing_store.set('additional_data', value)

def get_field_deserializers(self):
return {}

def serialize(self, writer: SerializationWriter):
writer.write_additional_data_value(self.get_additional_data())

def get_backing_store(self):
return self.backing_store
66 changes: 66 additions & 0 deletions src/msgraph_core/models/large_file_upload_session.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
from __future__ import annotations
from typing import Any, Callable, Dict, List, Optional, TYPE_CHECKING, Union
import datetime
from dataclasses import dataclass, field

from kiota_abstractions.serialization import (
AdditionalDataHolder, Parsable, ParseNode, SerializationWriter
)


@dataclass
class LargeFileUploadSession(AdditionalDataHolder, Parsable):

additional_data: Dict[str, Any] = field(default_factory=dict)
expiration_date_time: Optional[datetime.datetime] = None
next_expected_ranges: Optional[List[str]] = None
is_cancelled: Optional[bool] = False
odata_type: Optional[str] = None
# The URL endpoint that accepts PUT requests for byte ranges of the file.
upload_url: Optional[str] = None

@staticmethod
def create_from_discriminator_value(
parse_node: Optional[ParseNode] = None
) -> LargeFileUploadSession:
"""
Creates a new instance of the appropriate class based
on discriminator value param parse_node: The parse node
to use to read the discriminator value and create the object
Returns: UploadSession
"""
if not parse_node:
raise TypeError("parse_node cannot be null.")
return LargeFileUploadSession()

def get_field_deserializers(self, ) -> Dict[str, Callable[[ParseNode], None]]:
"""
The deserialization information for the current model
Returns: Dict[str, Callable[[ParseNode], None]]
"""
fields: Dict[str, Callable[[Any], None]] = {
"expirationDateTime":
lambda n: setattr(self, 'expiration_date_time', n.get_datetime_value()),
"nextExpectedRanges":
lambda n:
setattr(self, 'next_expected_ranges', n.get_collection_of_primitive_values(str)),
"@odata.type":
lambda n: setattr(self, 'odata_type', n.get_str_value()),
"uploadUrl":
lambda n: setattr(self, 'upload_url', n.get_str_value()),
}
return fields

def serialize(self, writer: SerializationWriter) -> None:
"""
Serializes information the current object
param writer: Serialization writer to use to serialize this model
Returns: None
"""
if not writer:
raise TypeError("writer cannot be null.")
writer.write_datetime_value("expirationDateTime", self.expiration_date_time)
writer.write_collection_of_primitive_values("nextExpectedRanges", self.next_expected_ranges)
writer.write_str_value("@odata.type", self.odata_type)
writer.write_str_value("uploadUrl", self.upload_url)
writer.write_additional_data_value(self.additional_data)
3 changes: 1 addition & 2 deletions src/msgraph_core/models/page_result.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,13 @@
PageResult: Represents a page of items in a paged response.
"""
from __future__ import annotations
from typing import List, Optional, Dict, Callable
from typing import List, Optional, Dict, Callable, TypeVar
from dataclasses import dataclass

from kiota_abstractions.serialization.parsable import Parsable
from kiota_abstractions.serialization.serialization_writer \
import SerializationWriter
from kiota_abstractions.serialization.parse_node import ParseNode
from typing import TypeVar, List, Optional

T = TypeVar('T')

Expand Down
3 changes: 3 additions & 0 deletions src/msgraph_core/tasks/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
from .page_iterator import PageIterator
from .large_file_upload import LargeFileUploadTask

__all__ = ['PageIterator', 'LargeFileUploadTask']
Loading