From 27d37722972a3d00e69188ef3a4175a49533ed09 Mon Sep 17 00:00:00 2001 From: Victor Byrd Date: Wed, 10 Jul 2024 16:38:48 -0700 Subject: [PATCH] feat: Add editorconfig and apply --- .editorconfig | 10 ++++++++++ README.md | 2 +- kandji2snipe | 16 ++++++++-------- requirements.txt | 2 +- settings.conf.example | 18 +++++++++--------- 5 files changed, 29 insertions(+), 19 deletions(-) create mode 100644 .editorconfig diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..f4f98bd --- /dev/null +++ b/.editorconfig @@ -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 diff --git a/README.md b/README.md index afd49c0..dab9ab5 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/kandji2snipe b/kandji2snipe index bc34b96..4182b4f 100755 --- a/kandji2snipe +++ b/kandji2snipe @@ -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.") @@ -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 @@ -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'] @@ -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 @@ -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 @@ -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 diff --git a/requirements.txt b/requirements.txt index da780d5..c552f88 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,2 @@ requests -pytz \ No newline at end of file +pytz diff --git a/settings.conf.example b/settings.conf.example index 63de941..968090a 100644 --- a/settings.conf.example +++ b/settings.conf.example @@ -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] @@ -9,7 +9,7 @@ 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 @@ -17,11 +17,11 @@ 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 @@ -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