Skip to content

Commit

Permalink
Added excludeCharacters property to GeneratorRecipe class
Browse files Browse the repository at this point in the history
  • Loading branch information
davidtran001 committed Jan 8, 2024
1 parent 5f8ffd8 commit 5449bfa
Showing 1 changed file with 48 additions and 3 deletions.
51 changes: 48 additions & 3 deletions src/onepasswordconnectsdk/models/generator_recipe.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,25 +35,30 @@ class GeneratorRecipe(object):
"""
openapi_types = {
'length': 'int',
'character_sets': 'list[str]'
'character_sets': 'list[str]',
'exclude_characters': 'str'
}

attribute_map = {
'length': 'length',
'character_sets': 'characterSets'
'character_sets': 'characterSets',
'exclude_characters': 'excludeCharacters'
}

def __init__(self, length=32, character_sets=None, local_vars_configuration=None): # noqa: E501
def __init__(self, length=32, character_sets=None, exclude_characters=None, local_vars_configuration=None): # noqa: E501
"""GeneratorRecipe - a model defined in OpenAPI""" # noqa: E501

self._length = None
self._character_sets = None
self._exclude_characters = None
self.discriminator = None

if length is not None:
self.length = length
if character_sets is not None:
self.character_sets = character_sets
if exclude_characters is not None:
self.exclude_characters = exclude_characters

@property
def length(self):
Expand Down Expand Up @@ -110,6 +115,33 @@ def character_sets(self, character_sets):

self._character_sets = character_sets

@property
def exclude_characters(self):
"""Gets the exclude_characters of this GeneratorRecipe.
:return: The exclude_characters of this GeneratorRecipe.
:rtype: str
"""
return self._exclude_characters

@exclude_characters.setter
def exclude_characters(self, exclude_characters):
"""Sets the exclude_characters of this GeneratorRecipe.
:param exclude_characters: The exclude_characters of this GeneratorRecipe.
:type character_sets: str
"""
duplicates = self.find_duplicates(exclude_characters)
if duplicates:
raise ValueError(
"Invalid values for `exclude_characters` {0}, must not contain duplicate characters"
.format(", ".join(map(str, duplicates)))
)

self._exclude_characters = exclude_characters

def to_dict(self, serialize=False):
"""Returns the model properties as a dict"""
result = {}
Expand Down Expand Up @@ -163,3 +195,16 @@ def __ne__(self, other):
return True

return self.to_dict() != other.to_dict()

def find_duplicates(self, s):
char_count = {} # Dictionary to store count of each character
duplicates = set() # Set to store duplicate characters

for char in s:
char_count[char] = char_count.get(char, 0) + 1 # Increment count of char

for char, count in char_count.items():
if count > 1:
duplicates.add(char) # If count is more than 1, it's a duplicate

return duplicates

0 comments on commit 5449bfa

Please sign in to comment.