Skip to content
This repository was archived by the owner on Jun 30, 2025. It is now read-only.

Commit dc106a9

Browse files
author
Carter Shanklin
committed
Let user provide the namespace so we don't look it up (which requires
extra privileges)
1 parent 5e9fa9a commit dc106a9

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

scripts/plugins/sensors/oci_object_storage.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ def __init__(self,
3131
bucket_name = None,
3232
object_name = None,
3333
prefix = None,
34+
namespace_name = None,
3435
oci_conn_id = 'oci_default',
3536
verify = None,
3637
*args,
@@ -52,20 +53,22 @@ def __init__(self,
5253
self.bucket_name = bucket_name
5354
self.oci_conn_id = oci_conn_id
5455
self.verify = verify
56+
self.namespace_name = namespace_name
5557
self._oci_hook = None
5658

5759
def poke(self, context):
5860
raise Exception("Class did not implement poke method")
5961

6062
def list_objects(self, file, prefix_match=False):
6163
hook = self.get_oci_hook()
62-
namespace_name = hook.get_namespace(compartment_id=self.compartment_id)
64+
if not self.namespace_name:
65+
self.namespace_name = hook.get_namespace(compartment_id=self.compartment_id)
6366
object_store_client = hook.get_client(hook.oci_client)
6467
base_arguments = dict(
6568
bucket_name=self.bucket_name,
6669
fields="size",
6770
limit=100,
68-
namespace_name=namespace_name,
71+
namespace_name=self.namespace_name,
6972
prefix=file,
7073
)
7174
objectsummary = object_store_client.list_objects(**base_arguments)

0 commit comments

Comments
 (0)