@rest_initialiser(cluster_init_check=True, version_check=True)
def execute(self, opts):
    if (opts.regenerate is not None):
        try:
            open(opts.regenerate, 'a').close()
        except IOError:
            _exit_if_errors([f'Unable to create file at `{opts.regenerate}`'])
        (certificate, errors) = self.rest.regenerate_cluster_certificate()
        _exit_if_errors(errors)
        _exit_on_file_write_failure(opts.regenerate, certificate)
        _success(f'Certificate regenerate and copied to `{opts.regenerate}`')
    elif opts.cluster_cert:
        (certificate, errors) = self.rest.retrieve_cluster_certificate(opts.extended)
        _exit_if_errors(errors)
        if isinstance(certificate, dict):
            print(json.dumps(certificate, sort_keys=True, indent=2))
        else:
            print(certificate)
    elif opts.node_cert:
        host = urllib.parse.urlparse(opts.cluster).netloc
        (certificate, errors) = self.rest.retrieve_node_certificate(host)
        _exit_if_errors(errors)
        print(json.dumps(certificate, sort_keys=True, indent=2))
    elif opts.upload_cert:
        certificate = _exit_on_file_read_failure(opts.upload_cert)
        (_, errors) = self.rest.upload_cluster_certificate(certificate)
        _exit_if_errors(errors)
        _success(f'Uploaded cluster certificate to {opts.cluster}')
    elif opts.set_cert:
        (_, errors) = self.rest.set_node_certificate()
        _exit_if_errors(errors)
        _success('Node certificate set')
    elif opts.client_auth_path:
        data = _exit_on_file_read_failure(opts.client_auth_path)
        try:
            config = json.loads(data)
        except ValueError as e:
            _exit_if_errors([f'Client auth config does not contain valid json: {e}'])
        (_, errors) = self.rest.set_client_cert_auth(config)
        _exit_if_errors(errors)
        _success('SSL client auth updated')
    elif opts.show_client_auth:
        (result, errors) = self.rest.retrieve_client_cert_auth()
        _exit_if_errors(errors)
        print(json.dumps(result, sort_keys=True, indent=2))
    else:
        _exit_if_errors(['No options specified'])
@rest_initialiser(cluster_init_check=True, version_check=True)
def execute(self, opts):
    if (opts.regenerate is not None):
        try:
            open(opts.regenerate, 'a').close()
        except IOError:
            _exit_if_errors([f'Unable to create file at `{opts.regenerate}`'])
        (certificate, errors) = self.rest.regenerate_cluster_certificate()
        _exit_if_errors(errors)
        _exit_on_file_write_failure(opts.regenerate, certificate)
        _success(f'Certificate regenerate and copied to `{opts.regenerate}`')
    elif opts.cluster_cert:
        (certificate, errors) = self.rest.retrieve_cluster_certificate(opts.extended)
        _exit_if_errors(errors)
        if isinstance(certificate, dict):
            print(json.dumps(certificate, sort_keys=True, indent=2))
        else:
            print(certificate)
    elif opts.node_cert:
        host = urllib.parse.urlparse(opts.cluster).netloc
        (certificate, errors) = self.rest.retrieve_node_certificate(host)
        _exit_if_errors(errors)
        print(json.dumps(certificate, sort_keys=True, indent=2))
    elif opts.upload_cert:
        certificate = _exit_on_file_read_failure(opts.upload_cert)
        (_, errors) = self.rest.upload_cluster_certificate(certificate)
        _exit_if_errors(errors)
        _success(f'Uploaded cluster certificate to {opts.cluster}')
    elif opts.set_cert:
        (_, errors) = self.rest.set_node_certificate()
        _exit_if_errors(errors)
        _success('Node certificate set')
    elif opts.client_auth_path:
        data = _exit_on_file_read_failure(opts.client_auth_path)
        try:
            config = json.loads(data)
        except ValueError as e:
            _exit_if_errors([f'Client auth config does not contain valid json: {e}'])
        (_, errors) = self.rest.set_client_cert_auth(config)
        _exit_if_errors(errors)
        _success('SSL client auth updated')
    elif opts.show_client_auth:
        (result, errors) = self.rest.retrieve_client_cert_auth()
        _exit_if_errors(errors)
        print(json.dumps(result, sort_keys=True, indent=2))
    else:
        _exit_if_errors(['No options specified'])