import json
import logging
import requests
import plugins.settings as settings

headers = {'accept': 'application/json'}


def get(config, path, data=None):
    request = requests.get(
        url=__format_url(config, path),
        params=data,
        headers=headers,
        auth=(config['username'], config['password']),
        verify=settings.servers.verify_ssl)

    logging.debug('GET %s - Response %s - Data %s'
                  % (request.url, request.status_code, data))

    return request


def delete(config, path, data):
    request = requests.delete(
        url=__format_url(config, path),
        data=json.dumps(data),
        headers={
            'Content-type': 'application/json',
            'Accept': 'application/json'
        },
        auth=(config['username'], config['password']),
        verify=settings.servers.verify_ssl)

    logging.debug('DELETE %s - Response %s - Data %s'
                  % (request.url, request.status_code, data))

    return request


def post(config, path, data=None):
    request = requests.post(
        url=__format_url(config, path),
        data=data,
        headers=headers,
        auth=(config['username'], config['password']),
        verify=settings.servers.verify_ssl)

    logging.debug('POST %s - Response %s - Data %s'
                  % (request.url, request.status_code, data))

    return request


def __format_url(config, path):
    return '{server}{path}'.format(server=config['host'], path=path)

import json
import requests
import plugins.settings as settings

headers = {'accept': 'application/json'}


def get(config, path, data=None):
    auth = None
    if 'username' in config and 'password' in config:
        auth = (config['username'], config['password'])

    request = requests.get(
        url=__format_url(config, path),
        params=data,
        headers=headers,
        auth=auth,
        verify=settings.servers.verify_ssl)

    return request


def delete(config, path, data):
    request = requests.delete(
        url=__format_url(config, path),
        data=json.dumps(data),
        headers={
            'Content-type': 'application/json',
            'Accept': 'application/json'
        },
        auth=(config['username'], config['password']),
        verify=settings.servers.verify_ssl)

    return request


def post(config, path, data=None):
    request = requests.post(
        url=__format_url(config, path),
        data=data,
        headers=headers,
        auth=(config['username'], config['password']),
        verify=settings.servers.verify_ssl)

    return request


def __format_url(config, path):
    return '{server}{path}'.format(server=config['host'], path=path)

Remove logging and allow anonymous access (for Crucible for example)
Remove logging and allow anonymous access (for Crucible for example)

  import json
- import logging
  import requests
  import plugins.settings as settings
  
  headers = {'accept': 'application/json'}
  
  
  def get(config, path, data=None):
+     auth = None
+     if 'username' in config and 'password' in config:
+         auth = (config['username'], config['password'])
+ 
      request = requests.get(
          url=__format_url(config, path),
          params=data,
          headers=headers,
-         auth=(config['username'], config['password']),
+         auth=auth,
          verify=settings.servers.verify_ssl)
- 
-     logging.debug('GET %s - Response %s - Data %s'
-                   % (request.url, request.status_code, data))
  
      return request
  
  
  def delete(config, path, data):
      request = requests.delete(
          url=__format_url(config, path),
          data=json.dumps(data),
          headers={
              'Content-type': 'application/json',
              'Accept': 'application/json'
          },
          auth=(config['username'], config['password']),
          verify=settings.servers.verify_ssl)
  
-     logging.debug('DELETE %s - Response %s - Data %s'
-                   % (request.url, request.status_code, data))
- 
      return request
  
  
  def post(config, path, data=None):
      request = requests.post(
          url=__format_url(config, path),
          data=data,
          headers=headers,
          auth=(config['username'], config['password']),
          verify=settings.servers.verify_ssl)
  
-     logging.debug('POST %s - Response %s - Data %s'
-                   % (request.url, request.status_code, data))
- 
      return request
  
  
  def __format_url(config, path):
      return '{server}{path}'.format(server=config['host'], path=path)
  
Remove logging and allow anonymous access (for Crucible for example)
## Code Before:
import json
import logging
import requests
import plugins.settings as settings

headers = {'accept': 'application/json'}


def get(config, path, data=None):
    request = requests.get(
        url=__format_url(config, path),
        params=data,
        headers=headers,
        auth=(config['username'], config['password']),
        verify=settings.servers.verify_ssl)

    logging.debug('GET %s - Response %s - Data %s'
                  % (request.url, request.status_code, data))

    return request


def delete(config, path, data):
    request = requests.delete(
        url=__format_url(config, path),
        data=json.dumps(data),
        headers={
            'Content-type': 'application/json',
            'Accept': 'application/json'
        },
        auth=(config['username'], config['password']),
        verify=settings.servers.verify_ssl)

    logging.debug('DELETE %s - Response %s - Data %s'
                  % (request.url, request.status_code, data))

    return request


def post(config, path, data=None):
    request = requests.post(
        url=__format_url(config, path),
        data=data,
        headers=headers,
        auth=(config['username'], config['password']),
        verify=settings.servers.verify_ssl)

    logging.debug('POST %s - Response %s - Data %s'
                  % (request.url, request.status_code, data))

    return request


def __format_url(config, path):
    return '{server}{path}'.format(server=config['host'], path=path)

## Instruction:
Remove logging and allow anonymous access (for Crucible for example)
## Code After:
import json
import requests
import plugins.settings as settings

headers = {'accept': 'application/json'}


def get(config, path, data=None):
    auth = None
    if 'username' in config and 'password' in config:
        auth = (config['username'], config['password'])

    request = requests.get(
        url=__format_url(config, path),
        params=data,
        headers=headers,
        auth=auth,
        verify=settings.servers.verify_ssl)

    return request


def delete(config, path, data):
    request = requests.delete(
        url=__format_url(config, path),
        data=json.dumps(data),
        headers={
            'Content-type': 'application/json',
            'Accept': 'application/json'
        },
        auth=(config['username'], config['password']),
        verify=settings.servers.verify_ssl)

    return request


def post(config, path, data=None):
    request = requests.post(
        url=__format_url(config, path),
        data=data,
        headers=headers,
        auth=(config['username'], config['password']),
        verify=settings.servers.verify_ssl)

    return request


def __format_url(config, path):
    return '{server}{path}'.format(server=config['host'], path=path)
