Skip to content

feat: Add editorconfig and apply #20

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
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
10 changes: 10 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
root = true

[*]
end_of_line = lf
trim_trailing_whitespace = true
insert_final_newline = true

[*.{conf,py}]
indent_style = space
indent_size = 4
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ export SNIPE_APIKEY=snipe-api-key-here
**[appletv-api-mapping]**



### API Mapping

To get the database fields for Snipe-IT Custom Fields, go to Settings and then Custom Fields inside of your Snipe-IT instance, scroll down past Fieldsets to Custom Fields, click the column selection button and make sure the 'DB Field' checkbox is checked. Copy and paste the DB Field name for Snipe-IT under *platform*-api-mapping sections in your `settings.conf` file.
Expand Down
16 changes: 8 additions & 8 deletions kandji2snipe
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,9 @@ validarrays = [
"security_information"
]

# Define Functions
# Define Functions

# Find and validate the settings.conf file
# Find and validate the settings.conf file
def get_settings():
# Find a valid settings.conf file.
logging.info("Searching for a valid settings.conf file.")
Expand Down Expand Up @@ -184,7 +184,7 @@ def create_variables():
global snipeheaders
global defaultStatus
global apple_manufacturer_id

logging.info('Creating variables from settings.conf')

# Kandji Base URL
Expand All @@ -202,11 +202,11 @@ def create_variables():
# Snipe-IT base URL, API key, default status, and Apple manufacturer ID
snipe_base = config['snipe-it']['url']
logging.info("The Snipe-IT base url is: {}".format(snipe_base))

# Snipe API Key
snipe_apikey = os.environ.get("SNIPE_APIKEY",config['snipe-it']['apikey'])
logging.debug("The Snipe-IT API key is: {}".format(snipe_apikey))

defaultStatus = config['snipe-it']['defaultStatus']
logging.info("Status ID for new assets created in Snipe-IT: {}".format(defaultStatus))
apple_manufacturer_id = config['snipe-it']['manufacturer_id']
Expand Down Expand Up @@ -394,7 +394,7 @@ def kandji_api(method, endpoint, params=None, payload=None):

return data

# Function to get device records from Kandji
# Function to get device records from Kandji
def get_kandji_devices(platform):
count = 0
# dict placeholder for params passed to api requests
Expand Down Expand Up @@ -674,7 +674,7 @@ if user_args.users_no_search and not user_args.users:
logging.error("The -uns option requires the use of -u for user syncing.")
sys.exit(exit_error_message)

# Find and validate the settings.conf file
# Find and validate the settings.conf file
get_settings()

# Create variables based on setings.conf values
Expand Down Expand Up @@ -752,7 +752,7 @@ if user_args.dryrun and user_args.logfile:
elif user_args.dryrun:
logging.info('Dry Run: Complete')
sys.exit()

# From this point on, we're editing data.
logging.info('Starting to Update Inventory')
CurrentNumber = 0
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
requests
pytz
pytz
18 changes: 9 additions & 9 deletions settings.conf.example
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# For details on configuring your settings.conf file, please read the
# For details on configuring your settings.conf file, please read the
# README at https://github.com/grokability/kandji2snipe

[kandji]
Expand All @@ -9,19 +9,19 @@ apitoken = kandji-api-bearer-token-here
[snipe-it]
url = https://your_snipe_instance.com
apikey = snipe-api-key-here
# timezone should match APP_TIMEZONE="timezone" in your Snipe-IT .env file
# timezone should match APP_TIMEZONE="timezone" in your Snipe-IT .env file
timezone = America/Los_Angeles
manufacturer_id = 1
defaultStatus = 2
mac_model_category_id = 5
iphone_model_category_id = 6
ipad_model_category_id = 7
appletv_model_category_id = 8
# Custom fieldset values are not required unless mapping Kandji data to Snipe-IT custom fields
mac_custom_fieldset_id =
iphone_custom_fieldset_id =
ipad_custom_fieldset_id =
appletv_custom_fieldset_id =
# Custom fieldset values are not required unless mapping Kandji data to Snipe-IT custom fields
mac_custom_fieldset_id =
iphone_custom_fieldset_id =
ipad_custom_fieldset_id =
appletv_custom_fieldset_id =

[asset-tag]
# If an asset tag does not exist in Kandji and Snipe-IT, the script will create one
Expand All @@ -33,14 +33,14 @@ use_custom_pattern = no
# Patterns must contain a prefix and variable.
# Examples of Kandji device attribute variables:
# Serial Number = hardware_overview serial_number
# Device ID = general device_id
# Device ID = general device_id
# Device Name = general device_name
pattern_mac = MAC- hardware_overview serial_number
pattern_iphone = IPHONE- hardware_overview serial_number
pattern_ipad = IPAD- hardware_overview serial_number
pattern_appletv = ATV- hardware_overview serial_number

# API Mappings are not required unless mapping Kandji data to Snipe-IT custom fields
# API Mappings are not required unless mapping Kandji data to Snipe-IT custom fields

[mac-api-mapping]
_snipeit_mac_address_1 = network mac_address
Expand Down