11# coding: utf-8
22
3- # (C) Copyright IBM Corp. 2020 .
3+ # (C) Copyright IBM Corp. 2021 .
44#
55# Licensed under the Apache License, Version 2.0 (the "License");
66# you may not use this file except in compliance with the License.
1414# See the License for the specific language governing permissions and
1515# limitations under the License.
1616
17- # IBM OpenAPI SDK Code Generator Version: 3.12 .0-64fe8d3f-20200820-144050
17+ # IBM OpenAPI SDK Code Generator Version: 3.15 .0-45841b53-20201019-214802
1818
1919"""
20- The purpose is to provide an API to get Kubeconfig for IBM Cloud Code Engine Project
20+ The purpose is to provide an API to get Kubeconfig file for IBM Cloud Code Engine Project
2121"""
2222
2323from enum import Enum
@@ -81,20 +81,22 @@ def list_kubeconfig(self,
8181 ** kwargs
8282 ) -> DetailedResponse :
8383 """
84- Retrieve KUBECONFIG for a specified project.
84+ Deprecated soon: Retrieve KUBECONFIG for a specified project.
8585
86- Returns the KUBECONFIG, similar to the output of `kubectl config view
87- --minify=true`.
86+ **Deprecated soon**: This API will be deprecated soon. Use the [GET
87+ /project/{id}/config](#get-kubeconfig) API instead. Returns the KUBECONFIG file,
88+ similar to the output of `kubectl config view --minify=true`.
8889
8990 :param str refresh_token: The IAM Refresh token associated with the IBM
90- Cloud account.
91- :param str id: The id of the IBM Cloud Code Engine project.
92- :param str accept: (optional) The type of the response: application/json or
93- text/html. A character encoding can be specified by including a `charset`
94- parameter. For example, 'text/html;charset=utf-8'.
91+ Cloud account. To retrieve your IAM token, run `ibmcloud iam oauth-tokens`.
92+ :param str id: The id of the IBM Cloud Code Engine project. To retrieve
93+ your project ID, run `ibmcloud ce project get -n <PROJECT_NAME>`.
94+ :param str accept: (optional) The type of the response: text/plain or
95+ application/json. A character encoding can be specified by including a
96+ `charset` parameter. For example, 'text/plain;charset=utf-8'.
9597 :param dict headers: A `dict` containing the request headers
9698 :return: A `DetailedResponse` containing the result, headers and HTTP status code.
97- :rtype: DetailedResponse
99+ :rtype: DetailedResponse with `str` result
98100 """
99101
100102 if refresh_token is None :
@@ -113,8 +115,82 @@ def list_kubeconfig(self,
113115 if 'headers' in kwargs :
114116 headers .update (kwargs .get ('headers' ))
115117
116- url = '/namespaces/{0}/config' .format (
117- * self .encode_path_vars (id ))
118+ path_param_keys = ['id' ]
119+ path_param_values = self .encode_path_vars (id )
120+ path_param_dict = dict (zip (path_param_keys , path_param_values ))
121+ url = '/namespaces/{id}/config' .format (** path_param_dict )
122+ request = self .prepare_request (method = 'GET' ,
123+ url = url ,
124+ headers = headers )
125+
126+ response = self .send (request )
127+ return response
128+
129+
130+ def get_kubeconfig (self ,
131+ x_delegated_refresh_token : str ,
132+ id : str ,
133+ * ,
134+ accept : str = None ,
135+ ** kwargs
136+ ) -> DetailedResponse :
137+ """
138+ Retrieve KUBECONFIG for a specified project.
139+
140+ Returns the KUBECONFIG, similar to the output of `kubectl config view
141+ --minify=true`. There are 2 tokens in the Request Header and a query parameter
142+ that you must provide.
143+ These values can be generated as follows: 1. Auth Header Pass the generated IAM
144+ Token as the Authorization header from the CLI as `token=cat
145+ $HOME/.bluemix/config.json | jq .IAMToken -r`. Generate the token with the [Create
146+ an IAM access token for a user or service ID using an API
147+ key](https://cloud.ibm.com/apidocs/iam-identity-token-api#gettoken-apikey) API.
148+ 2. X-Delegated-Refresh-Token Header Generate an IAM Delegated Refresh Token for
149+ Code Engine with the [Create an IAM access token and delegated refresh token for a
150+ user or service
151+ ID](https://cloud.ibm.com/apidocs/iam-identity-token-api#gettoken-apikey-delegatedrefreshtoken)
152+ API. Specify the `receiver_client_ids` value to be `ce` and the
153+ `delegated_refresh_token_expiry` value to be `3600`.
154+ 3. Project ID In order to retrieve the Kubeconfig file for a specific Code Engine
155+ project, use the CLI to extract the ID
156+ `id=ibmcloud ce project get -n ${CE_PROJECT_NAME} -o jsonpath={.guid}` You must be
157+ logged into the account where the project was created to retrieve the ID.
158+
159+ :param str x_delegated_refresh_token: This IAM Delegated Refresh Token is
160+ specifically valid for Code Engine. Generate this token with the [Create an
161+ IAM access token and delegated refresh token for a user or service
162+ ID](https://cloud.ibm.com/apidocs/iam-identity-token-api#gettoken-apikey-delegatedrefreshtoken)
163+ API. Specify the `receiver_client_ids` value to be `ce` and the
164+ `delegated_refresh_token_expiry` value to be `3600`.
165+ :param str id: The id of the IBM Cloud Code Engine project.
166+ :param str accept: (optional) The type of the response: text/plain or
167+ application/json. A character encoding can be specified by including a
168+ `charset` parameter. For example, 'text/plain;charset=utf-8'.
169+ :param dict headers: A `dict` containing the request headers
170+ :return: A `DetailedResponse` containing the result, headers and HTTP status code.
171+ :rtype: DetailedResponse with `str` result
172+ """
173+
174+ if x_delegated_refresh_token is None :
175+ raise ValueError ('x_delegated_refresh_token must be provided' )
176+ if id is None :
177+ raise ValueError ('id must be provided' )
178+ headers = {
179+ 'X-Delegated-Refresh-Token' : x_delegated_refresh_token ,
180+ 'Accept' : accept
181+ }
182+ sdk_headers = get_sdk_headers (service_name = self .DEFAULT_SERVICE_NAME ,
183+ service_version = 'V1' ,
184+ operation_id = 'get_kubeconfig' )
185+ headers .update (sdk_headers )
186+
187+ if 'headers' in kwargs :
188+ headers .update (kwargs .get ('headers' ))
189+
190+ path_param_keys = ['id' ]
191+ path_param_values = self .encode_path_vars (id )
192+ path_param_dict = dict (zip (path_param_keys , path_param_values ))
193+ url = '/project/{id}/config' .format (** path_param_dict )
118194 request = self .prepare_request (method = 'GET' ,
119195 url = url ,
120196 headers = headers )
@@ -130,12 +206,27 @@ class ListKubeconfigEnums:
130206
131207 class Accept (str , Enum ):
132208 """
133- The type of the response: application/json or text/html. A character encoding can
209+ The type of the response: text/plain or application/json. A character encoding can
210+ be specified by including a `charset` parameter. For example,
211+ 'text/plain;charset=utf-8'.
212+ """
213+ TEXT_PLAIN = 'text/plain'
214+ APPLICATION_JSON = 'application/json'
215+
216+
217+ class GetKubeconfigEnums :
218+ """
219+ Enums for get_kubeconfig parameters.
220+ """
221+
222+ class Accept (str , Enum ):
223+ """
224+ The type of the response: text/plain or application/json. A character encoding can
134225 be specified by including a `charset` parameter. For example,
135- 'text/html ;charset=utf-8'.
226+ 'text/plain ;charset=utf-8'.
136227 """
228+ TEXT_PLAIN = 'text/plain'
137229 APPLICATION_JSON = 'application/json'
138- TEXT_HTML = 'text/html'
139230
140231
141232##############################################################################
0 commit comments