-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(api): compatibility with powergate v2 (#55)
* feat(api): compatibility with powergate v2 * fix(format): codefactor fix * fix: bump docker container version * fix:debug actions * fix(test): add ipfs healthcheck * feat(test):added resource constraints * fix: add delay * fix(format): codefactor fixes
- Loading branch information
1 parent
a07213c
commit 45e9d93
Showing
20 changed files
with
645 additions
and
407 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import os | ||
from pathlib import Path | ||
from pygate_grpc.client import PowerGateClient | ||
|
||
|
||
if __name__ == "__main__": | ||
|
||
hostName = "127.0.0.1:5002" | ||
|
||
# Create client | ||
c = PowerGateClient(hostName, False) | ||
|
||
# Create user | ||
user = c.admin.users.create() | ||
print("User created:") | ||
print(user) | ||
|
||
# Stage file | ||
print("Staging 'testfile.txt' to IPFS storage...") | ||
path = Path(os.path.abspath(__file__)) | ||
staged_file = c.data.stage_file(path.parent / "testfile.txt", user.token) | ||
print("IPFS CID: " + staged_file.cid) | ||
|
||
# Apply the default storage config to the given file | ||
print("Applying Filecoin storage config to CID...") | ||
job = c.config.apply(staged_file.cid, override=False, token=user.token) | ||
|
||
# Report back the Job ID for the successful Filecoin storage job | ||
print("File successfully added to Filecoin storage.") | ||
print("Job ID: " + job.jobId) | ||
|
||
storage_infos = c.storage_info.list(cids=[staged_file.cid], token=user.token) | ||
print(storage_infos) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import os | ||
from pathlib import Path | ||
from pygate_grpc.client import PowerGateClient | ||
|
||
|
||
if __name__ == "__main__": | ||
|
||
hostName = "127.0.0.1:5002" | ||
|
||
# Create client | ||
c = PowerGateClient(hostName, False) | ||
|
||
# Create user | ||
user = c.admin.users.create() | ||
print("User created:") | ||
print(user) | ||
|
||
# Stage file | ||
print("Staging 'testfile.txt' to IPFS storage...") | ||
path = Path(os.path.abspath(__file__)) | ||
staged_file = c.data.stage_file(path.parent / "testfile.txt", user.token) | ||
print("IPFS CID: " + staged_file.cid) | ||
|
||
# Apply the default storage config to the given file | ||
print("Applying Filecoin storage config to CID...") | ||
job = c.config.apply(staged_file.cid, override=False, token=user.token) | ||
|
||
# Report back the Job ID for the successful Filecoin storage job | ||
print("File successfully added to Filecoin storage.") | ||
print("Job ID: " + job.jobId) | ||
|
||
storage_job = c.storage_jobs.storage_job(job.jobId, token=user.token) | ||
storage_config = c.storage_jobs.storage_config_for_job(job.jobId, token=user.token) | ||
jobs_list = c.storage_jobs.list(cid_filter=staged_file.cid, token=user.token) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
from typing import List | ||
|
||
from powergate.user.v1 import user_pb2, user_pb2_grpc | ||
|
||
from pygate_grpc.decorators import unmarshal_with | ||
from pygate_grpc.errors import ErrorHandlerMeta | ||
from pygate_grpc.types import StorageInfo | ||
|
||
|
||
class StorageInfoClient(object, metaclass=ErrorHandlerMeta): | ||
def __init__(self, channel, get_metadata): | ||
self.client = user_pb2_grpc.UserServiceStub(channel) | ||
self.get_metadata = get_metadata | ||
|
||
@unmarshal_with(StorageInfo) | ||
def get(self, cid: str, token: str = None) -> StorageInfo: | ||
req = user_pb2.StorageInfoRequest(cid=cid) | ||
return self.client.StorageInfo( | ||
req, metadata=self.get_metadata(token) | ||
).storage_info | ||
|
||
@unmarshal_with(StorageInfo, many=True) | ||
def list(self, cids: List[str], token: str = None) -> List[StorageInfo]: | ||
req = user_pb2.ListStorageInfoRequest(cids=cids) | ||
return self.client.ListStorageInfo( | ||
req, metadata=self.get_metadata(token) | ||
).storage_info |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.