Skip to content
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

Memory optimization, requests sessions, astra connector changes #93

Merged
merged 6 commits into from
May 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
12 changes: 6 additions & 6 deletions astraSDK/apiresources.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env python3
"""
Copyright 2023 NetApp, Inc
Copyright 2024 NetApp, Inc

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand All @@ -24,17 +24,18 @@


class getApiResources(SDKCommon):
def __init__(self, quiet=True, verbose=False, output="json"):
def __init__(self, quiet=True, verbose=False, output="json", config=None):
"""quiet: Will there be CLI output or just return (datastructure)
verbose: Print all of the ReST call info: URL, Method, Headers, Request Body
output: table: pretty print the data
json: (default) output in JSON
yaml: output in yaml"""
yaml: output in yaml
config: optionally provide a pre-populated common.getConfig().main() object"""
self.quiet = quiet
self.verbose = verbose
self.output = output
super().__init__()
self.clusters = getClusters(quiet=True, verbose=verbose).main()
super().__init__(config=config)
self.clusters = getClusters(quiet=True, verbose=verbose, config=config).main()

def main(self, cluster=None):
if self.clusters is False:
Expand Down Expand Up @@ -62,7 +63,6 @@ def main(self, cluster=None):
data,
self.headers,
params,
self.verifySSL,
quiet=self.quiet,
verbose=self.verbose,
)
Expand Down
50 changes: 25 additions & 25 deletions astraSDK/apps.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env python3
"""
Copyright 2023 NetApp, Inc
Copyright 2024 NetApp, Inc

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -35,16 +35,17 @@ class getApps(SDKCommon):
Therefore this class cannot list all of the managed and unmanaged apps.
"""

def __init__(self, quiet=True, verbose=False, output="json"):
def __init__(self, quiet=True, verbose=False, output="json", config=None):
"""quiet: Will there be CLI output or just return (datastructure)
verbose: Print all of the ReST call info: URL, Method, Headers, Request Body
output: table: pretty print the data
json: (default) output in JSON
yaml: output in yaml"""
yaml: output in yaml
config: optionally provide a pre-populated common.getConfig().main() object"""
self.quiet = quiet
self.verbose = verbose
self.output = output
super().__init__()
super().__init__(config=config)

def main(
self,
Expand All @@ -66,7 +67,6 @@ def main(
data,
self.headers,
params,
self.verifySSL,
quiet=self.quiet,
verbose=self.verbose,
)
Expand Down Expand Up @@ -194,12 +194,13 @@ class manageApp(SDKCommon):

There is no validation of this input, that instead is left to the calling method."""

def __init__(self, quiet=True, verbose=False):
def __init__(self, quiet=True, verbose=False, config=None):
"""quiet: Will there be CLI output or just return (datastructure)
verbose: Print all of the ReST call info: URL, Method, Headers, Request Body"""
verbose: Print all of the ReST call info: URL, Method, Headers, Request Body
config: optionally provide a pre-populated common.getConfig().main() object"""
self.quiet = quiet
self.verbose = verbose
super().__init__()
super().__init__(config=config)
self.headers["accept"] = "application/astra-app+json"
self.headers["Content-Type"] = "application/astra-app+json"

Expand Down Expand Up @@ -235,7 +236,6 @@ def main(
data,
self.headers,
params,
self.verifySSL,
quiet=self.quiet,
verbose=self.verbose,
)
Expand All @@ -254,12 +254,13 @@ def main(
class unmanageApp(SDKCommon):
"""This class undefines a managed application."""

def __init__(self, quiet=True, verbose=False):
def __init__(self, quiet=True, verbose=False, config=None):
"""quiet: Will there be CLI output or just return (datastructure)
verbose: Print all of the ReST call info: URL, Method, Headers, Request Body"""
verbose: Print all of the ReST call info: URL, Method, Headers, Request Body
config: optionally provide a pre-populated common.getConfig().main() object"""
self.quiet = quiet
self.verbose = verbose
super().__init__()
super().__init__(config=config)
self.headers["accept"] = "application/astra-app+json"
self.headers["Content-Type"] = "application/astra-app+json"

Expand All @@ -275,7 +276,6 @@ def main(self, appID):
data,
self.headers,
params,
self.verifySSL,
quiet=self.quiet,
verbose=self.verbose,
)
Expand Down Expand Up @@ -303,12 +303,13 @@ class cloneApp(SDKCommon):
for any parameters the clone operation will fail.
"""

def __init__(self, quiet=True, verbose=False):
def __init__(self, quiet=True, verbose=False, config=None):
"""quiet: Will there be CLI output or just return (datastructure)
verbose: Print all of the ReST call info: URL, Method, Headers, Request Body"""
verbose: Print all of the ReST call info: URL, Method, Headers, Request Body
config: optionally provide a pre-populated common.getConfig().main() object"""
self.quiet = quiet
self.verbose = verbose
super().__init__()
super().__init__(config=config)
self.headers["accept"] = "application/astra-app+json"
self.headers["Content-Type"] = "application/astra-app+json"

Expand Down Expand Up @@ -355,7 +356,6 @@ def main(
data,
self.headers,
params,
self.verifySSL,
quiet=self.quiet,
verbose=self.verbose,
)
Expand Down Expand Up @@ -383,12 +383,13 @@ class restoreApp(SDKCommon):
"restoring" to "running" or "failed".
"""

def __init__(self, quiet=True, verbose=False):
def __init__(self, quiet=True, verbose=False, config=None):
"""quiet: Will there be CLI output or just return True/False
verbose: Print all of the ReST call info: URL, Method, Headers, Request Body"""
verbose: Print all of the ReST call info: URL, Method, Headers, Request Body
config: optionally provide a pre-populated common.getConfig().main() object"""
self.quiet = quiet
self.verbose = verbose
super().__init__()
super().__init__(config=config)
self.headers["accept"] = "application/astra-app+json"
self.headers["Content-Type"] = "application/astra-app+json"
self.headers["ForceUpdate"] = "true"
Expand Down Expand Up @@ -422,7 +423,6 @@ def main(
data,
self.headers,
params,
self.verifySSL,
quiet=self.quiet,
verbose=self.verbose,
)
Expand All @@ -436,16 +436,17 @@ def main(


class getAppAssets(SDKCommon):
def __init__(self, quiet=True, verbose=False, output="json"):
def __init__(self, quiet=True, verbose=False, output="json", config=None):
"""quiet: Will there be CLI output or just return (datastructure)
verbose: Print all of the ReST call info: URL, Method, Headers, Request Body
output: table: pretty print the data
json: (default) output in JSON
yaml: output in yaml"""
yaml: output in yaml
config: optionally provide a pre-populated common.getConfig().main() object"""
self.quiet = quiet
self.verbose = verbose
self.output = output
super().__init__()
super().__init__(config=config)

def main(self, appID):
endpoint = f"k8s/v1/apps/{appID}/appAssets"
Expand All @@ -460,7 +461,6 @@ def main(self, appID):
data,
self.headers,
params,
self.verifySSL,
quiet=self.quiet,
verbose=self.verbose,
)
Expand Down
28 changes: 14 additions & 14 deletions astraSDK/backups.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env python3
"""
Copyright 2023 NetApp, Inc
Copyright 2024 NetApp, Inc

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -29,17 +29,18 @@ class getBackups(SDKCommon):
for that app.
"""

def __init__(self, quiet=True, verbose=False, output="json"):
def __init__(self, quiet=True, verbose=False, output="json", config=None):
"""quiet: Will there be CLI output or just return (datastructure)
verbose: Print all of the ReST call info: URL, Method, Headers, Request Body
output: table: pretty print the data
json: (default) output in JSON
yaml: output in yaml"""
yaml: output in yaml
config: optionally provide a pre-populated common.getConfig().main() object"""
self.quiet = quiet
self.verbose = verbose
self.output = output
super().__init__()
self.apps = getApps(quiet=True, verbose=verbose).main()
super().__init__(config=config)
self.apps = getApps(quiet=True, verbose=verbose, config=config).main()

def main(self, appFilter=None):
if self.apps is False:
Expand Down Expand Up @@ -80,7 +81,6 @@ def main(self, appFilter=None):
data,
self.headers,
params,
self.verifySSL,
quiet=self.quiet,
verbose=self.verbose,
)
Expand Down Expand Up @@ -136,12 +136,13 @@ class takeBackup(SDKCommon):
a bucketID and snpshotID are optional fields, and either the result JSON is
returned or the backupID of the newly created backup is returned."""

def __init__(self, quiet=True, verbose=False):
def __init__(self, quiet=True, verbose=False, config=None):
"""quiet: Will there be CLI output or just return (datastructure)
verbose: Print all of the ReST call info: URL, Method, Headers, Request Body"""
verbose: Print all of the ReST call info: URL, Method, Headers, Request Body
config: optionally provide a pre-populated common.getConfig().main() object"""
self.quiet = quiet
self.verbose = verbose
super().__init__()
super().__init__(config=config)
self.headers["accept"] = "application/astra-appBackup+json"
self.headers["Content-Type"] = "application/astra-appBackup+json"

Expand All @@ -165,7 +166,6 @@ def main(self, appID, backupName, bucketID=None, snapshotID=None):
data,
self.headers,
params,
self.verifySSL,
quiet=self.quiet,
verbose=self.verbose,
)
Expand All @@ -185,12 +185,13 @@ class destroyBackup(SDKCommon):
"""Given an appID and backupID destroy the backup. Note that this doesn't
unmanage a backup, it actively destroys it. There is no coming back from this."""

def __init__(self, quiet=True, verbose=False):
def __init__(self, quiet=True, verbose=False, config=None):
"""quiet: Will there be CLI output or just return (datastructure)
verbose: Print all of the ReST call info: URL, Method, Headers, Request Body"""
verbose: Print all of the ReST call info: URL, Method, Headers, Request Body
config: optionally provide a pre-populated common.getConfig().main() object"""
self.quiet = quiet
self.verbose = verbose
super().__init__()
super().__init__(config=config)
self.headers["accept"] = "application/astra-appBackup+json"
self.headers["Content-Type"] = "application/astra-appBackup+json"

Expand All @@ -209,7 +210,6 @@ def main(self, appID, backupID):
data,
self.headers,
params,
self.verifySSL,
quiet=self.quiet,
verbose=self.verbose,
)
Expand Down
Loading