Examples of NeutronRestApi


Examples of org.apache.cloudstack.network.opendaylight.api.NeutronRestApi

            throw new NeutronRestApiException("Invalid credentials!", e);
        }

        NeutronRestFactory factory = NeutronRestFactory.getInstance();

        NeutronRestApi neutronRestApi = factory.getNeutronApi(GetMethod.class);
        GetMethod getMethod = (GetMethod) neutronRestApi.createMethod(url, uri);

        try {
            getMethod.setRequestHeader(CONTENT_TYPE, JSON_CONTENT_TYPE);

            String encodedCredentials = encodeCredentials();
            getMethod.setRequestHeader("Authorization", "Basic " + encodedCredentials);

            if (parameters != null && !parameters.isEmpty()) {
                List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(parameters.size());
                for (Entry<String, String> e : parameters.entrySet()) {
                    nameValuePairs.add(new NameValuePair(e.getKey(), e.getValue()));
                }
                getMethod.setQueryString(nameValuePairs.toArray(new NameValuePair[0]));
            }

            neutronRestApi.executeMethod(getMethod);

            if (getMethod.getStatusCode() != HttpStatus.SC_OK) {
                String errorMessage = responseToErrorMessage(getMethod);
                getMethod.releaseConnection();
                s_logger.error("Failed to retrieve object : " + errorMessage);
View Full Code Here

Examples of org.apache.cloudstack.network.opendaylight.api.NeutronRestApi

            throw new NeutronRestApiException("Invalid credentials!", e);
        }

        NeutronRestFactory factory = NeutronRestFactory.getInstance();

        NeutronRestApi neutronRestApi = factory.getNeutronApi(PostMethod.class);
        PostMethod postMethod = (PostMethod) neutronRestApi.createMethod(url, uri);

        try {
            postMethod.setRequestHeader(CONTENT_TYPE, JSON_CONTENT_TYPE);
            postMethod.setRequestEntity(entity);

            String encodedCredentials = encodeCredentials();
            postMethod.setRequestHeader("Authorization", "Basic " + encodedCredentials);

            neutronRestApi.executeMethod(postMethod);

            if (postMethod.getStatusCode() != HttpStatus.SC_CREATED) {
                String errorMessage = responseToErrorMessage(postMethod);
                postMethod.releaseConnection();
                s_logger.error("Failed to create object : " + errorMessage);
View Full Code Here

Examples of org.apache.cloudstack.network.opendaylight.api.NeutronRestApi

            throw new NeutronRestApiException("Invalid credentials!", e);
        }

        NeutronRestFactory factory = NeutronRestFactory.getInstance();

        NeutronRestApi neutronRestApi = factory.getNeutronApi(PutMethod.class);
        PutMethod putMethod = (PutMethod) neutronRestApi.createMethod(url, uri);

        try {
            putMethod.setRequestHeader(CONTENT_TYPE, JSON_CONTENT_TYPE);
            putMethod.setRequestEntity(entity);

            String encodedCredentials = encodeCredentials();
            putMethod.setRequestHeader("Authorization", "Basic " + encodedCredentials);

            neutronRestApi.executeMethod(putMethod);

            if (putMethod.getStatusCode() != HttpStatus.SC_OK) {
                String errorMessage = responseToErrorMessage(putMethod);
                putMethod.releaseConnection();
                s_logger.error("Failed to update object : " + errorMessage);
View Full Code Here

Examples of org.apache.cloudstack.network.opendaylight.api.NeutronRestApi

            throw new NeutronRestApiException("Invalid credentials!", e);
        }

        NeutronRestFactory factory = NeutronRestFactory.getInstance();

        NeutronRestApi neutronRestApi = factory.getNeutronApi(PutMethod.class);
        PutMethod putMethod = (PutMethod) neutronRestApi.createMethod(url, uri);

        try {
            String encodedCredentials = encodeCredentials();
            putMethod.setRequestHeader("Authorization", "Basic " + encodedCredentials);

            neutronRestApi.executeMethod(putMethod);

            if (putMethod.getStatusCode() != HttpStatus.SC_OK) {
                String errorMessage = responseToErrorMessage(putMethod);
                putMethod.releaseConnection();
                s_logger.error("Failed to update object : " + errorMessage);
View Full Code Here

Examples of org.apache.cloudstack.network.opendaylight.api.NeutronRestApi

            throw new NeutronRestApiException("Invalid credentials!", e);
        }

        NeutronRestFactory factory = NeutronRestFactory.getInstance();

        NeutronRestApi neutronRestApi = factory.getNeutronApi(DeleteMethod.class);
        DeleteMethod deleteMethod = (DeleteMethod) neutronRestApi.createMethod(url, uri);

        try {
            deleteMethod.setRequestHeader(CONTENT_TYPE, JSON_CONTENT_TYPE);

            String encodedCredentials = encodeCredentials();
            deleteMethod.setRequestHeader("Authorization", "Basic " + encodedCredentials);

            neutronRestApi.executeMethod(deleteMethod);

            if (deleteMethod.getStatusCode() != HttpStatus.SC_NO_CONTENT) {
                String errorMessage = responseToErrorMessage(deleteMethod);
                deleteMethod.releaseConnection();
                s_logger.error("Failed to update object : " + errorMessage);
View Full Code Here

Examples of org.apache.cloudstack.network.opendaylight.api.NeutronRestApi

    NeutronRestApi httpPut = factory.getNeutronApi(PutMethod.class);
    NeutronRestApi httpDelete = factory.getNeutronApi(DeleteMethod.class);

    @Test
    public void resourceHttpGetInstances() throws NeutronRestApiException {
        NeutronRestApi newHttpGet = factory.getNeutronApi(GetMethod.class);
        assertTrue(httpGet == newHttpGet);
    }
View Full Code Here

Examples of org.apache.cloudstack.network.opendaylight.api.NeutronRestApi

        assertTrue(httpGet == newHttpGet);
    }

    @Test
    public void resourceHttpPostInstances() throws NeutronRestApiException {
        NeutronRestApi newHttpPost = factory.getNeutronApi(PostMethod.class);
        assertTrue(httpPost == newHttpPost);
    }
View Full Code Here

Examples of org.apache.cloudstack.network.opendaylight.api.NeutronRestApi

        assertTrue(httpPost == newHttpPost);
    }

    @Test
    public void resourceHttpPutInstances() throws NeutronRestApiException {
        NeutronRestApi newHttpPut = factory.getNeutronApi(PutMethod.class);
        assertTrue(httpPut == newHttpPut);
    }
View Full Code Here

Examples of org.apache.cloudstack.network.opendaylight.api.NeutronRestApi

        assertTrue(httpPut == newHttpPut);
    }

    @Test
    public void resourceHttpDeleteInstances() throws NeutronRestApiException {
        NeutronRestApi newHttpDelete = factory.getNeutronApi(DeleteMethod.class);
        assertTrue(httpDelete == newHttpDelete);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.