Applying license changes to 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  * ONAP : APPC
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Copyright (C) 2017 Amdocs
8  * =============================================================================
9  * Licensed under the Apache License, Version 2.0 (the "License");
10  * you may not use this file except in compliance with the License.
11  * You may obtain a copy of the License at
12  * 
13  *      http://www.apache.org/licenses/LICENSE-2.0
14  * 
15  * Unless required by applicable law or agreed to in writing, software
16  * distributed under the License is distributed on an "AS IS" BASIS,
17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  * See the License for the specific language governing permissions and
19  * limitations under the License.
20  * 
21  * ECOMP is a trademark and service mark of AT&T Intellectual Property.
22  * ============LICENSE_END=========================================================
23  */
24
25 package org.openecomp.appc.adapter.chef.chefclient;
26 import org.apache.http.client.methods.*;
27 import org.openecomp.appc.adapter.chef.chefapi.*;
28
29 public class ChefApiClient {
30         private String endpoint;
31         private String userId;
32         private String pemPath;
33         private String organizations;
34
35         
36
37          
38         /**
39          *
40          * @param userId user name correspond to the pem key
41          * @param pemPath path of the auth key
42          * @param endpoint chef api server address
43          */
44         public ChefApiClient(String userId, String pemPath, String endpoint,String organizations){
45                 this.userId = userId;
46                 this.pemPath = pemPath;
47                 this.endpoint = endpoint;
48                 this.organizations=organizations;
49         }
50
51         /**
52          *
53          * @param path in the endpoint. e.g /clients
54          * @return
55          */
56         public Get get(String path){
57                 Get get = new Get(new HttpGet(endpoint+path));
58                 get.setPemPath(pemPath);
59                 get.setUserId(userId);
60                 get.setOrganizations(organizations);
61                 get.setChefPath(path);
62                 return get;
63         }
64
65         public Put put(String path){
66                 Put put = new Put(new HttpPut(endpoint+path));
67                 put.setPemPath(pemPath);
68                 put.setUserId(userId);
69                 put.setOrganizations(organizations);
70                 put.setChefPath(path);
71                 return put;
72    }
73         public Post post(String path){
74                 Post post = new Post(new HttpPost(endpoint+path));
75                 post.setPemPath(pemPath);
76                 post.setUserId(userId);
77                 post.setOrganizations(organizations);
78                 post.setChefPath(path);
79                 return post;
80         }
81         
82         public Delete delete(String path){
83             Delete del = new Delete(new HttpDelete(endpoint+path));
84             del.setPemPath(pemPath);
85             del.setUserId(userId);
86             del.setOrganizations(organizations);
87             del.setChefPath(path);
88             return del;
89         }
90
91         
92 }