Skip to content
Open
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
60 changes: 60 additions & 0 deletions cohesity_management_sdk/models/key_value_str_pair.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# -*- coding: utf-8 -*-
# Copyright 2023 Cohesity Inc.


class KeyValueStrPair(object):

"""Implementation of the 'KeyValueStrPair' model.

Generic structure to hold a string key value pair.


Attributes:

key (string): Specifies the name of the key.
value (Value): Specifies a value for the key.
"""


# Create a mapping from Model property names to API property names
_names = {
"key":'key',
"value":'value',
}
def __init__(self,
key=None,
value=None,
):

"""Constructor for the KeyValuePair class"""

# Initialize members of the class
self.key = key
self.value = value

@classmethod
def from_dictionary(cls,
dictionary):
"""Creates an instance of this model from a dictionary

Args:
dictionary (dictionary): A dictionary representation of the object as
obtained from the deserialization of the server's response. The keys
MUST match property names in the API description.

Returns:
object: An instance of this structure class.

"""
if dictionary is None:
return None

# Extract variables from the dictionary
key = dictionary.get('key')
value = dictionary.get('value')

# Return an object of this model
return cls(
key,
value
)
4 changes: 2 additions & 2 deletions cohesity_management_sdk/models/uda_connect_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Copyright 2023 Cohesity Inc.

import cohesity_management_sdk.models.credentials
import cohesity_management_sdk.models.key_value_pair
import cohesity_management_sdk.models.key_value_str_pair
import cohesity_management_sdk.models.uda_source_capabilities


Expand Down Expand Up @@ -119,7 +119,7 @@ def from_dictionary(cls,
if dictionary.get('sourceRegistrationArguments') != None:
source_registration_arguments = list()
for structure in dictionary.get('sourceRegistrationArguments'):
source_registration_arguments.append(cohesity_management_sdk.models.key_value_pair.KeyValuePair.from_dictionary(structure))
source_registration_arguments.append(cohesity_management_sdk.models.key_value_str_pair.KeyValueStrPair.from_dictionary(structure))
source_type = dictionary.get('sourceType')

# Return an object of this model
Expand Down
25 changes: 25 additions & 0 deletions samples/list_protection_sources/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
## Usage
```
python list_protection_sources.py
```

## Connect to the Cohesity Cluster
First make sure that you are connected to a Cohesity Cluster.
```
cohesity_client = CohesityClient(cluster_vip=CLUSTER_VIP,
username=CLUSTER_USERNAME,
password=CLUSTER_PASSWORD,
domain=DOMAIN)
```
Note: Alternatively, you can set the above parameters in cohesity_management_sdk/configuration.py

## Example
```
protection_sources = cohesity_client.protection_sources
sources_list = protection_sources.list_protection_sources()

```
## Example Output
```
list of Protection Sources
```
Empty file.
41 changes: 41 additions & 0 deletions samples/list_protection_sources/list_protection_sources.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Copyright 2019 Cohesity Inc.
#
# Python example to get a list Protection jobs.
#
# Usage: python list_protection_jobs.py

import datetime

from cohesity_management_sdk.cohesity_client import CohesityClient

CLUSTER_USERNAME = 'admin'
CLUSTER_PASSWORD = 'admin'
CLUSTER_VIP = '10.14.7.145'
DOMAIN = 'LOCAL'

class ProtectionSourcesList(object):

def list_protection_sources(self, cohesity_client):
"""
Method to display the list of ProtectionSources
:param cohesity_client(object): Cohesity client object.
:return:
"""
protection_sources = cohesity_client.protection_sources
srcs_list = protection_sources.list_protection_sources()
for srcs in srcs_list:
print(srcs)



def main():

cohesity_client = CohesityClient(cluster_vip=CLUSTER_VIP,
username=CLUSTER_USERNAME,
password=CLUSTER_PASSWORD,
domain=DOMAIN)
protection_srcs = ProtectionSourcesList()
protection_srcs.list_protection_sources(cohesity_client)

if __name__ == '__main__':
main()
Loading