Updating licenses in all files
[appc.git] / appc-adapters / appc-chef-adapter / appc-chef-adapter-bundle / src / main / java / org / openecomp / appc / adapter / chef / chefclient / ChefApiClient.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * APPC
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6  * Copyright (C) 2017 Amdocs
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
11  * 
12  *      http://www.apache.org/licenses/LICENSE-2.0
13  * 
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=========================================================
20  * ECOMP is a trademark and service mark of AT&T Intellectual Property.
21  */
22
23 package org.openecomp.appc.adapter.chef.chefclient;
24 import org.apache.http.client.methods.*;
25 import org.openecomp.appc.adapter.chef.chefapi.*;
26
27 public class ChefApiClient {
28         private String endpoint;
29         private String userId;
30         private String pemPath;
31         private String organizations;
32
33         
34
35          
36         /**
37          *
38          * @param userId user name correspond to the pem key
39          * @param pemPath path of the auth key
40          * @param endpoint chef api server address
41          */
42         public ChefApiClient(String userId, String pemPath, String endpoint,String organizations){
43                 this.userId = userId;
44                 this.pemPath = pemPath;
45                 this.endpoint = endpoint;
46                 this.organizations=organizations;
47         }
48
49         /**
50          *
51          * @param path in the endpoint. e.g /clients
52          * @return
53          */
54         public Get get(String path){
55                 Get get = new Get(new HttpGet(endpoint+path));
56                 get.setPemPath(pemPath);
57                 get.setUserId(userId);
58                 get.setOrganizations(organizations);
59                 get.setChefPath(path);
60                 return get;
61         }
62
63         public Put put(String path){
64                 Put put = new Put(new HttpPut(endpoint+path));
65                 put.setPemPath(pemPath);
66                 put.setUserId(userId);
67                 put.setOrganizations(organizations);
68                 put.setChefPath(path);
69                 return put;
70    }
71         public Post post(String path){
72                 Post post = new Post(new HttpPost(endpoint+path));
73                 post.setPemPath(pemPath);
74                 post.setUserId(userId);
75                 post.setOrganizations(organizations);
76                 post.setChefPath(path);
77                 return post;
78         }
79         
80         public Delete delete(String path){
81             Delete del = new Delete(new HttpDelete(endpoint+path));
82             del.setPemPath(pemPath);
83             del.setUserId(userId);
84             del.setOrganizations(organizations);
85             del.setChefPath(path);
86             return del;
87         }
88
89         
90 /*      public Header[] buildHeaders(){
91
92             return null;
93         }
94 */
95 }