1
+ import os
2
+
1
3
from office365 .runtime .client_result import ClientResult
2
4
from office365 .runtime .paths .resource_path import ResourcePath
3
5
from office365 .runtime .paths .service_operation import ServiceOperationPath
8
10
from office365 .sharepoint .marketplace .app_metadata_collection import (
9
11
CorporateCatalogAppMetadataCollection ,
10
12
)
13
+ from office365 .sharepoint .marketplace .corporatecuratedgallery .app_request_information import (
14
+ SPStoreAppRequestInformation ,
15
+ )
16
+ from office365 .sharepoint .marketplace .corporatecuratedgallery .app_response_information import (
17
+ SPStoreAppResponseInformation ,
18
+ )
11
19
from office365 .sharepoint .marketplace .corporatecuratedgallery .app_upgrade_availability import (
12
20
AppUpgradeAvailability ,
13
21
)
22
30
class TenantCorporateCatalogAccessor (Entity ):
23
31
"""Accessor for the tenant corporate catalog."""
24
32
25
- def add (self , content , overwrite , url ):
33
+ def add (self , content , overwrite , url = None ):
26
34
"""
27
35
Adds a file to the corporate catalog.
28
36
@@ -32,8 +40,27 @@ def add(self, content, overwrite, url):
32
40
:param str url: Specifies the URL of the file to be added.
33
41
"""
34
42
return_type = File (self .context )
35
- payload = {"Content" : content , "Overwrite" : overwrite , "Url" : url }
36
- qry = ServiceOperationQuery (self , "Add" , None , payload , None , return_type )
43
+ params = {"Overwrite" : overwrite , "Url" : url }
44
+ qry = ServiceOperationQuery (self , "Add" , params , content , None , return_type )
45
+ self .context .add_query (qry )
46
+ return return_type
47
+
48
+ def app_from_path (self , path , overwrite ):
49
+ """
50
+ Adds a file to the corporate catalog.
51
+ """
52
+ with open (path , "rb" ) as f :
53
+ content = f .read ()
54
+ url = os .path .basename (path )
55
+ return self .add (content = content , overwrite = overwrite , url = url )
56
+
57
+ def app_requests (self ):
58
+ """"""
59
+ return_type = ClientResult (self .context , SPStoreAppResponseInformation ())
60
+ payload = {"AppRequestInfo" : SPStoreAppRequestInformation ()}
61
+ qry = ServiceOperationQuery (
62
+ self , "AppRequests" , None , payload , None , return_type
63
+ )
37
64
self .context .add_query (qry )
38
65
return return_type
39
66
@@ -70,6 +97,17 @@ def is_app_upgrade_available(self, _id):
70
97
self .context .add_query (qry )
71
98
return return_type
72
99
100
+ def upload (self , content , overwrite , url , xor_hash = None ):
101
+ payload = {
102
+ "Content" : content ,
103
+ "Overwrite" : overwrite ,
104
+ "Url" : url ,
105
+ "XorHash" : xor_hash ,
106
+ }
107
+ qry = ServiceOperationQuery (self , "Upload" , None , payload )
108
+ self .context .add_query (qry )
109
+ return self
110
+
73
111
def send_app_request_status_notification_email (self , request_guid ):
74
112
"""
75
113
:param str request_guid:
0 commit comments