All Projects → akamai → NetStorageKit-Python

akamai / NetStorageKit-Python

Licence: Apache-2.0 license
Akamai Netstorage API for Python

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to NetStorageKit-Python

NetStorageKit-Golang
Netstorage API for Golang
Stars: ✭ 17 (-22.73%)
Mutual labels:  akamai, akamai-open, netstorage, filestore, objectstore, akamai-netstorage, netstorage-api
AkamaiOPEN-edgegrid-ruby
This library implements the Akamai OPEN EdgeGrid Authentication scheme for the ruby net/http library.
Stars: ✭ 19 (-13.64%)
Mutual labels:  akamai
akamai-toolkit
A set of tools to work on Akamai v1 anti-bot solution. Current supported version: 1.70
Stars: ✭ 215 (+877.27%)
Mutual labels:  akamai
File-Sharing-Bot
Telegram Bot to store Posts and Documents and it can Access by Special Links.
Stars: ✭ 867 (+3840.91%)
Mutual labels:  filestore
detect-cloudflare-plus
True Sight Firefox extension.
Stars: ✭ 34 (+54.55%)
Mutual labels:  akamai
cli-sandbox
Akamai CLI for Sandbox
Stars: ✭ 14 (-36.36%)
Mutual labels:  akamai
SSSG-Ninja
All-in-one tool for site shield security group management
Stars: ✭ 16 (-27.27%)
Mutual labels:  akamai
Zee5
Just a simple shit but no one knows
Stars: ✭ 29 (+31.82%)
Mutual labels:  akamai
AkamaiOPEN-edgegrid-java
Java library for Akamai OPEN EdgeGrid Client Authentication
Stars: ✭ 37 (+68.18%)
Mutual labels:  akamai
cli-property-manager
Use this Property Manager CLI to automate Akamai property changes and deployments across many environments.
Stars: ✭ 22 (+0%)
Mutual labels:  akamai
cli-eaa
CLI for Enterprise Application Access (EAA)
Stars: ✭ 19 (-13.64%)
Mutual labels:  akamai
wp-akamai
No description or website provided.
Stars: ✭ 21 (-4.55%)
Mutual labels:  akamai
esi-test-server-docker
A dockerized version of Akamai's Edge Side Includes Test Server (ETS).
Stars: ✭ 30 (+36.36%)
Mutual labels:  akamai
terraform-provider-akamai
Terraform Akamai provider
Stars: ✭ 75 (+240.91%)
Mutual labels:  akamai
nvfuse
NVMe based File System in User-space
Stars: ✭ 81 (+268.18%)
Mutual labels:  objectstore
terraform-provider-akamai
An Akamai GTM Terraform provider
Stars: ✭ 14 (-36.36%)
Mutual labels:  akamai
flipper
Feature Flipper, Feature Flags, Rollout Flags, Feature Toggles for Crystal
Stars: ✭ 21 (-4.55%)
Mutual labels:  filestore
AkamaiOPEN-edgegrid-C-Sharp
No description or website provided.
Stars: ✭ 13 (-40.91%)
Mutual labels:  akamai
aem-akamai-replication-agent
How to create custom replication agents in AEM using Akamai as an example.
Stars: ✭ 33 (+50%)
Mutual labels:  akamai
AkamaiOPEN-edgegrid-php-client
PHP client library for Akamai {OPEN} EdgeGrid Authentication scheme (based on Guzzle)
Stars: ✭ 38 (+72.73%)
Mutual labels:  akamai

NetstorageAPI: Akamai Netstorage API for Python

https://travis-ci.org/akamai/NetStorageKit-Python.svg?branch=master

NetstorageAPI is Akamai Netstorage (File/Object Store) API for Python and uses requests. NetstorageAPI supports Python 2.6–2.7 & 3.3–3.6, and runs great on PyPy as requests.

Important

Akamai does not maintain or regulate this package. While it can be incorporated to assist you in API use, Akamai Technical Support will not offer assistance and Akamai cannot be held liable if issues arise from its use.

Installation

To install Netstorage API for Python:

$ pip install netstorageapi

Example

from akamai.netstorage import Netstorage, NetstorageError

NS_HOSTNAME = 'astin-nsu.akamaihd.net'
NS_KEYNAME = 'astinapi'
NS_KEY = 'xxxxxxxxxx' # Don't expose NS_KEY on public repository.
NS_CPCODE = '360949'

ns = Netstorage(NS_HOSTNAME, NS_KEYNAME, NS_KEY, ssl=False) # ssl is optional (default: False)
local_source = 'hello.txt'
netstorage_destination = '/{0}/hello.txt'.format(NS_CPCODE) # or '/{0}/'.format(NS_CPCODE) is same.
ok, response = ns.upload(local_source, netstorage_destination)
# "ok": True means 200 OK; If False, it's not 200 OK
# "response": <Response [200]> # Response object from requests.get|post|put
print(response.text)
# '<HTML>Request Processed</HTML>'

Methods

>>> ns.delete(NETSTORAGE_PATH)
>>> dir_option = {
...  'max_entries': INTEGER,
...  'start': 'STRING',
...  'end': 'STRING',
...  'prefix': 'object-prefix',
...  'slash': 'both',
...  'encoding': 'utf-8'
... }
>>> ns.dir(NETSTORAGE_PATH, dir_option)
>>> ns.download(NETSTORAGE_SOURCE, LOCAL_DESTINATION)
>>> ns.du(NETSTORAGE_PATH)
>>> list_option = {
...  'max_entries': INTEGER,
...  'end': '/CPCODE/path',
...  'encoding': 'utf-8'
... }
>>> ns.list(NETSTORAGE_PATH, list_option)
>>> ns.mkdir(NETSTORAGE_PATH + DIRECTORY_NAME)
>>> ns.mtime(NETSTORAGE_PATH, TIME) # ex) TIME: int(time.time())
>>> ns.quick_delete(NETSTORAGE_DIR) # needs to be enabled on the CP Code
>>> ns.rename(NETSTORAGE_TARGET, NETSTORAGE_DESTINATION)
>>> ns.rmdir(NETSTORAGE_DIR)
>>> ns.stat(NETSTORAGE_PATH)
>>> ns.stream_download(NETSTORAGE_SOURCE)
>>> ns.stream_upload(DATA, NETSTORAGE_DESTINATION)
>>> ns.symlink(NETSTORAGE_TARGET, NETSTORAGE_DESTINATION)
>>> ns.upload(LOCAL_SOURCE_PATH, NETSTORAGE_DESTINATION, INDEX_ZIP=False)
>>>
>>>
>>> # INFO: Return (True/False, Response Object from requests.get|post|put)
>>> #       True means 200 OK.
>>> # INFO: Can "upload" Only a single file, not a directory.
>>> #       To use 'INDEX_ZIP=True',
>>> #       Must turn on index_zip on your Netstorage configuration
>>> # WARN: Can raise NetstorageError at all methods.
>>>

Test

You can test all above methods with unittest script (NOTE: You should input NS_HOSTNAME, NS_KEYNAME, NS_KEY and NS_CPCODE in the script):

$ python test/test_netstorage.py
[TEST] dir /360949 done
[TEST] mkdir /360949/78fab6cd-f3d8-4fde-a6bf-16dc9c6a22d0 done
[TEST] upload 2f58618a-cacd-4e03-b3a7-21cc92d1bfe9.txt to /360949/78fab6cd-f3d8-4fde-a6bf-16dc9c6a22d0/2f58618a-cacd-4e03-b3a7-21cc92d1bfe9.txt done
[TEST] stream_upload /360949/78fab6cd-f3d8-4fde-a6bf-16dc9c6a22d0/stream_2f58618a-cacd-4e03-b3a7-21cc92d1bfe9.txt done
[TEST] stream_download /360949/78fab6cd-f3d8-4fde-a6bf-16dc9c6a22d0/stream_2f58618a-cacd-4e03-b3a7-21cc92d1bfe9.txt done
[TEST] du done
[TEST] mtime /360949/78fab6cd-f3d8-4fde-a6bf-16dc9c6a22d0/2f58618a-cacd-4e03-b3a7-21cc92d1bfe9.txt to 1508482349 done
[TEST] stat done
[TEST] symlink /360949/78fab6cd-f3d8-4fde-a6bf-16dc9c6a22d0/2f58618a-cacd-4e03-b3a7-21cc92d1bfe9.txt to /360949/78fab6cd-f3d8-4fde-a6bf-16dc9c6a22d0/2f58618a-cacd-4e03-b3a7-21cc92d1bfe9.txt_lnk done
[TEST] rename /360949/78fab6cd-f3d8-4fde-a6bf-16dc9c6a22d0/2f58618a-cacd-4e03-b3a7-21cc92d1bfe9.txt to /360949/78fab6cd-f3d8-4fde-a6bf-16dc9c6a22d0/2f58618a-cacd-4e03-b3a7-21cc92d1bfe9.txt_rename done
[TEST] download /360949/78fab6cd-f3d8-4fde-a6bf-16dc9c6a22d0/2f58618a-cacd-4e03-b3a7-21cc92d1bfe9.txt_rename done
[TEST] delete /360949/78fab6cd-f3d8-4fde-a6bf-16dc9c6a22d0/stream_2f58618a-cacd-4e03-b3a7-21cc92d1bfe9.txt done
[TEST] delete /360949/78fab6cd-f3d8-4fde-a6bf-16dc9c6a22d0/2f58618a-cacd-4e03-b3a7-21cc92d1bfe9.txt_rename done
[TEST] delete /360949/78fab6cd-f3d8-4fde-a6bf-16dc9c6a22d0/2f58618a-cacd-4e03-b3a7-21cc92d1bfe9.txt_lnk done
[TEST] rmdir /360949/78fab6cd-f3d8-4fde-a6bf-16dc9c6a22d0 done
[TEARDOWN] remove 2f58618a-cacd-4e03-b3a7-21cc92d1bfe9.txt from local done
[TEARDOWN] remove 2f58618a-cacd-4e03-b3a7-21cc92d1bfe9.txt_rename from local done
.

[TEST] Invalid ns path NetstorageError test done
[TEST] Invalid local path NetstorageError test done
[TEST] Download directory path NetstorageError test done
.
----------------------------------------------------------------------
Ran 2 tests in x.xxxs

OK

Command

You can run the script with command line parameters.

$ python cms_netstorage.py -H astin-nsu.akamaihd.net -k astinapi -K xxxxxxxxxx -a dir /360949

Use -h or --help option for more detail.

Author

Astin Choi ([email protected])

License

Copyright 2016 Akamai Technologies, Inc. All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].