// Generated by protoc-gen-twirp_typescript. DO NOT EDIT
import {code} from './services.pb';
import {createTwirpAdapter} from 'pbjs-twirp';
import Axios from 'axios';

const getServiceMethodName = (fn: any): string => {
	if (fn === code.justin.tv.eventbus.controlplane.Services.prototype.list) {
		return 'List';
    }
	if (fn === code.justin.tv.eventbus.controlplane.Services.prototype.get) {
		return 'Get';
    }
	if (fn === code.justin.tv.eventbus.controlplane.Services.prototype.create) {
		return 'Create';
    }
	if (fn === code.justin.tv.eventbus.controlplane.Services.prototype.update) {
		return 'Update';
    }
	if (fn === code.justin.tv.eventbus.controlplane.Services.prototype.getAuthorizedFieldGrants) {
		return 'GetAuthorizedFieldGrants';
    }
	if (fn === code.justin.tv.eventbus.controlplane.Services.prototype.requestorLDAPGroups) {
		return 'RequestorLDAPGroups';
    }
	if (fn === code.justin.tv.eventbus.controlplane.Services.prototype.resolveLDAPGroupUsers) {
		return 'ResolveLDAPGroupUsers';
    }
	if (fn === code.justin.tv.eventbus.controlplane.Services.prototype.deleteIAMRole) {
		return 'DeleteIAMRole';
    }
	if (fn === code.justin.tv.eventbus.controlplane.Services.prototype.getServicesForEventStream) {
		return 'GetServicesForEventStream';
    }
	if (fn === code.justin.tv.eventbus.controlplane.Services.prototype.getCloudFormationVersion) {
		return 'GetCloudFormationVersion';
    }
	if (fn === code.justin.tv.eventbus.controlplane.Services.prototype.createIAMRole) {
		return 'CreateIAMRole';
    }
	if (fn === code.justin.tv.eventbus.controlplane.Services.prototype.updateIAMRoleLabel) {
		return 'UpdateIAMRoleLabel';
    }
	if (fn === code.justin.tv.eventbus.controlplane.Services.prototype.validateIAMRole) {
		return 'ValidateIAMRole';
    }

    throw new Error('Unknown Method');
};


export const ServicesPathPrefix = '/twirp/code.justin.tv.eventbus.controlplane.Services/';

export const createServices = (baseURL: string, options = {}): code.justin.tv.eventbus.controlplane.Services => {
    const defaultOpts = {
        baseURL: baseURL + ServicesPathPrefix,
        headers: {
          Accept: 'application/protobuf'
        }
    };
    const axiosOpts = { ...defaultOpts, ...options };
    
    const axios = Axios.create(axiosOpts);

    return code.justin.tv.eventbus.controlplane.Services.create(createTwirpAdapter(axios, getServiceMethodName));
};
