from .base import Base
import requests

class Config(Base):
    """ Get basic nio info """

    def __init__(self, options, *args, **kwargs):
        super().__init__(options, *args, **kwargs)
        self._resource = 'services' if self.options['services'] else 'blocks'
        self._resource_name = \
            self.options['<service-name>'] if self.options['services'] else \
            self.options['<block-name>'] if self.options['blocks'] else \
            ""

    def run(self):
        response = requests.get(
            self._base_url.format(
                '{}/{}'.format(self._resource, self._resource_name)),
            auth=self._auth)
        try:
            config = response.json()
            print(requests.get(
                self._base_url.format(self._resource),
                json=config,
                auth=self._auth).json())
        except Exception as e:
            print(e)

from .base import Base
import requests

class Config(Base):
    """ Get basic nio info """

    def __init__(self, options, *args, **kwargs):
        super().__init__(options, *args, **kwargs)
        self._resource = 'services' if self.options['services'] else 'blocks'
        self._resource_name = \
            self.options['<service-name>'] if self.options['services'] else \
            self.options['<block-name>'] if self.options['blocks'] else \
            ""

    def run(self):
        response = requests.get(
            self._base_url.format(
                '{}/{}'.format(self._resource, self._resource_name)),
            auth=self._auth)
        try:
            config = response.json()
            print(config)
        except Exception as e:
            print(e)

Remove additional http get request
Remove additional http get request

  from .base import Base
  import requests
  
  class Config(Base):
      """ Get basic nio info """
  
      def __init__(self, options, *args, **kwargs):
          super().__init__(options, *args, **kwargs)
          self._resource = 'services' if self.options['services'] else 'blocks'
          self._resource_name = \
              self.options['<service-name>'] if self.options['services'] else \
              self.options['<block-name>'] if self.options['blocks'] else \
              ""
  
      def run(self):
          response = requests.get(
              self._base_url.format(
                  '{}/{}'.format(self._resource, self._resource_name)),
              auth=self._auth)
          try:
              config = response.json()
+             print(config)
-             print(requests.get(
-                 self._base_url.format(self._resource),
-                 json=config,
-                 auth=self._auth).json())
          except Exception as e:
              print(e)
  
Remove additional http get request
## Code Before:
from .base import Base
import requests

class Config(Base):
    """ Get basic nio info """

    def __init__(self, options, *args, **kwargs):
        super().__init__(options, *args, **kwargs)
        self._resource = 'services' if self.options['services'] else 'blocks'
        self._resource_name = \
            self.options['<service-name>'] if self.options['services'] else \
            self.options['<block-name>'] if self.options['blocks'] else \
            ""

    def run(self):
        response = requests.get(
            self._base_url.format(
                '{}/{}'.format(self._resource, self._resource_name)),
            auth=self._auth)
        try:
            config = response.json()
            print(requests.get(
                self._base_url.format(self._resource),
                json=config,
                auth=self._auth).json())
        except Exception as e:
            print(e)

## Instruction:
Remove additional http get request
## Code After:
from .base import Base
import requests

class Config(Base):
    """ Get basic nio info """

    def __init__(self, options, *args, **kwargs):
        super().__init__(options, *args, **kwargs)
        self._resource = 'services' if self.options['services'] else 'blocks'
        self._resource_name = \
            self.options['<service-name>'] if self.options['services'] else \
            self.options['<block-name>'] if self.options['blocks'] else \
            ""

    def run(self):
        response = requests.get(
            self._base_url.format(
                '{}/{}'.format(self._resource, self._resource_name)),
            auth=self._auth)
        try:
            config = response.json()
            print(config)
        except Exception as e:
            print(e)
