def demiurge_create_cluster(cluster_name): """PUT /clusters/{cluster_name}""" return HttpClientFactory.get( BrokerConfigurationProvider.get(TapComponent.demiurge)).request( method=HttpMethod.PUT, path="clusters/{}".format(cluster_name), msg="DEMIURGE: create cluster")
def app_broker_bind_service_instance(instance_guid, application_guid): """PUT /v$/service_instances/:instanceId/service_bindings/:app_guid""" return HttpClientFactory.get(BrokerConfigurationProvider.get(TapComponent.application_broker)).request( method=HttpMethod.PUT, path="service_instances/{}/service_bindings/{}".format(instance_guid, application_guid), msg="APP BROKER: bind service instance to app", )
def demiurge_get_clusters(): """GET /clusters""" return HttpClientFactory.get( BrokerConfigurationProvider.get(TapComponent.demiurge)).request( method=HttpMethod.GET, path="clusters", msg="DEMIURGE: get list of clusters")
def app_broker_delete_service_instance(instance_guid): """DELETE /v$/service_instances/:instanceId""" return HttpClientFactory.get(BrokerConfigurationProvider.get(TapComponent.application_broker)).request( method=HttpMethod.DELETE, path="service_instances/{}".format(instance_guid), msg="APP BROKER: delete service instance", )
def app_broker_get_catalog(): """GET /v$/catalog""" return HttpClientFactory.get(BrokerConfigurationProvider.get(TapComponent.application_broker)).request( method=HttpMethod.GET, path="catalog", msg="APP BROKER: get catalog" )
def k8s_broker_get_catalog(): """GET /v$/catalog""" return HttpClientFactory.get( BrokerConfigurationProvider.get( TapComponent.kubernetes_broker)).request( method=HttpMethod.GET, path="catalog", msg="K8S BROKER: get catalog")
def k8s_broker_get_service_status(org_guid, service_id): """GET /v$/:org_id/service/:instance_id/status""" return HttpClientFactory.get( BrokerConfigurationProvider.get( TapComponent.kubernetes_broker)).request( method=HttpMethod.GET, path="{}/service/{}/status".format(org_guid, service_id), msg="K8S BROKER: get instance status")
def k8s_broker_delete_instance(instance_guid): """DELETE /v$/service_instances/:instanceId""" return HttpClientFactory.get( BrokerConfigurationProvider.get( TapComponent.kubernetes_broker)).request( method=HttpMethod.DELETE, path="service_instances/{instance_guid}", path_params={'instance_guid': instance_guid}, msg="K8S BROKER: delete instance")
def k8s_broker_delete_service(service_name=None): """DELETE /v$/dynamicservice""" body = {} if service_name is not None: body["dynamicService"] = {"serviceName": service_name} response = HttpClientFactory.get( BrokerConfigurationProvider.get( TapComponent.kubernetes_broker)).request( method=HttpMethod.DELETE, path="dynamicservice", body=body, msg="K8S BROKER: delete service offering") return response
def app_broker_new_service_instance(instance_guid, organization_guid, plan_id, service_id, space_guid, instance_name): """PUT /v$/service_instances/:instanceId""" query = { "organization_guid": organization_guid, "plan_id": plan_id, "service_id": service_id, "space_guid": space_guid, "parameters": {"name": instance_name} } return HttpClientFactory.get(BrokerConfigurationProvider.get(TapComponent.application_broker)).request( method=HttpMethod.PUT, path="service_instances/{}".format(instance_guid), body=query, msg="APP BROKER: create new service instance", )
def app_broker_create_service(app_guid, description, service_name): """POST /v$/catalog""" query = { "app": { "metadata": {"guid": app_guid} }, "description": description, "name": service_name } return HttpClientFactory.get(BrokerConfigurationProvider.get(TapComponent.application_broker)).request( method=HttpMethod.POST, path="catalog", body=query, msg="APP BROKER: create service in catalog", )
def k8s_broker_create_service_offering(org_guid, space_guid, service_name=None): """PUT /v$/dynamicservice""" body_cont_ports = [{"containerPort": 27017, "protocol": "TCP"}] body_cont_env = [{ "name": "MANAGED_BY", "value": "TAP" }, { "name": "MONGODB_PASSWORD", "value": "user" }, { "name": "MONGODB_USERNAME", "value": "password" }, { "name": "MONGODB_DBNAME", "value": "test" }] body_containers = [{ "name": "k-mongodb30", "image": "frodenas/mongodb:3.0", "ports": body_cont_ports, "env": body_cont_env, "resources": {}, "imagePullPolicy": "" }] body_ports = [{ "name": "", "protocol": "TCP", "port": 27017, "targetPort": 0, "nodePort": 0 }] body_credentials = { "dbname": "$env_MONGODB_DBNAME", "hostname": "$hostname", "password": "******", "port": "$port_27017", "ports": { "27017/tcp": "$port_27017" }, "uri": "mongodb://$env_MONGODB_USERNAME:$env_MONGODB_PASSWORD@$hostname:$port_27017/$env_MONGODB_DBNAME", "username": "******" } body_dynamic_service = { "serviceName": service_name, "planName": service_name, "isPlanFree": True, "containers": body_containers, "servicePorts": body_ports, "credentialsMappings": body_credentials } body = { "organization_guid": org_guid, "space_guid": space_guid, "updateBroker": True, "parameters": None, "dynamicService": body_dynamic_service } return HttpClientFactory.get( BrokerConfigurationProvider.get( TapComponent.kubernetes_broker)).request( method=HttpMethod.PUT, path="dynamicservice", body=body, msg="K8S BROKER: create service offering")