2  * ============LICENSE_START=======================================================
 
   4  * ================================================================================
 
   5  * Copyright (C) 2017 AT&T Intellectual Property. All rights
 
   7  * ================================================================================
 
   8  * Licensed under the Apache License, Version 2.0 (the "License");
 
   9  * you may not use this file except in compliance with the License.
 
  10  * You may obtain a copy of the License at
 
  12  *      http://www.apache.org/licenses/LICENSE-2.0
 
  14  * Unless required by applicable law or agreed to in writing, software
 
  15  * distributed under the License is distributed on an "AS IS" BASIS,
 
  16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 
  17  * See the License for the specific language governing permissions and
 
  18  * limitations under the License.
 
  19  * ============LICENSE_END=========================================================
 
  22 package org.openecomp.appc.adapter.chef.chefclient;
 
  23 import org.apache.http.client.methods.*;
 
  24 import org.openecomp.appc.adapter.chef.chefapi.*;
 
  26 public class ChefApiClient {
 
  27         private String endpoint;
 
  28         private String userId;
 
  29         private String pemPath;
 
  30         private String organizations;
 
  37          * @param userId user name correspond to the pem key
 
  38          * @param pemPath path of the auth key
 
  39          * @param endpoint chef api server address
 
  41         public ChefApiClient(String userId, String pemPath, String endpoint,String organizations){
 
  43                 this.pemPath = pemPath;
 
  44                 this.endpoint = endpoint;
 
  45                 this.organizations=organizations;
 
  50          * @param path in the endpoint. e.g /clients
 
  53         public Get get(String path){
 
  54                 Get get = new Get(new HttpGet(endpoint+path));
 
  55                 get.setPemPath(pemPath);
 
  56                 get.setUserId(userId);
 
  57                 get.setOrganizations(organizations);
 
  58                 get.setChefPath(path);
 
  62         public Put put(String path){
 
  63                 Put put = new Put(new HttpPut(endpoint+path));
 
  64                 put.setPemPath(pemPath);
 
  65                 put.setUserId(userId);
 
  66                 put.setOrganizations(organizations);
 
  67                 put.setChefPath(path);
 
  70 /*      public Post post(String path){
 
  71                 Post post = new Post(new PostMethod(endpoint+path));
 
  72                 post.setPemPath(pemPath);
 
  73                 post.setUserId(userId);
 
  77         public Delete delete(String path){
 
  78             Delete del = new Delete(new DeleteMethod(endpoint+path));
 
  79             del.setPemPath(pemPath);
 
  80             del.setUserId(userId);
 
  86 /*      public Header[] buildHeaders(){