| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| - `API Documentation`_ | ||
|
|
||
| .. _Homepage: https://googlecloudplatform.github.io/google-cloud-python/ | ||
| .. _API Documentation: http://googlecloudplatform.github.io/google-cloud-python/ |
| The Google Cloud `RuntimeConfig`_ (`RuntimeConfig API docs`_) API enables | ||
| developers to dynamically configure and expose variables through Google Cloud | ||
| Platform. In addition, you can also set Watchers and Waiters (not yet supported | ||
| by this client library) that will watch for changes to your data and return |
| @@ -0,0 +1,20 @@ | |||
| # Copyright 2014 Google Inc. | |||
| # limitations under the License. | ||
|
|
||
| """Google Cloud Runtime Configurator API package.""" | ||
| from google.cloud.runtimeconfig.client import Client |
| """Extract the config name from a full resource name. | ||
|
|
||
| >>> _config_name_from_full_name('projects/my-proj/configs/my-config') | ||
| "my-config" |
| config_name = self._callFUT(PATH) | ||
| self.assertEqual(config_name, CONFIG_NAME) | ||
|
|
||
| class Test_variable_name_from_full_name(unittest.TestCase): |
| CONFIG_NAME = 'CONFIG_NAME' | ||
| PROJECT = 'my-project-1234' | ||
| PATH = 'projects/%s/configs/%s/variables/%s' % ( | ||
| PROJECT, CONFIG_NAME, VARIABLE_NAME) |
| CONFIG_NAME = 'CONFIG_NAME' | ||
| PROJECT = 'my-project-1234' | ||
| PATH = 'projects/%s/configs/%s/variables/%s' % ( | ||
| PROJECT, CONFIG_NAME, VARIABLE_NAME) |
|
|
||
| import httplib2 | ||
| import six | ||
| from six.moves.urllib.parse import quote |
| def test_ctor(self): | ||
| client = _Client(project=self.PROJECT) | ||
| config = self._makeOne(name=self.CONFIG_NAME, | ||
| client=client) |
|
Oops, looks like I mixed tabs and spaces and didn't reach 100% coverage on variable.py. Addressing now. |
Sorry, something went wrong.
|
Updated, please take a second look. |
Sorry, something went wrong.
|
I'm getting a lint error ************* Module google.cloud.runtimeconfig._helpers C: 52, 0: Line too long (89/80) (line-too-long) The line is 'projects/project-name/configs/config-name/variables/variable-name' I don't think there's anything I can do to shrink it down. |
Sorry, something went wrong.
|
Okay, I think I finally made the linter happy. I shrunk the problematic line down by changing the "names" project-name -> proj-name, config-name -> cfg-name |
Sorry, something went wrong.
|
|
||
| # Variables are hierarchical. Each node in the hierarchy is separated by a | ||
| # / character. | ||
| return '/'.join(parts[5:]) |
| :rtype: string | ||
| :returns: The full name based on project and config names. | ||
|
|
||
| :raises: :class:`ValueError` if the config is missing a name. |
| ``None`` if the property is not set locally. | ||
| """ | ||
| value = self._properties.get('updateTime') | ||
| if value: |
|
@tswast RE: a line with a string that's too long (like 'projects/project-name/configs/config-name/variables/variable-name') You can use an implicit strong concat in Python: my_var = ('the beginning of the string '
'and here is some more of it')RE: Mixing tabs and spaces, please get rid of all tabs. You can check for them via git grep -l $'\t'. If any files have tabs other than Makefile.bigtable_v2 Makefile.datastore docs/Makefile docs/_static/images/favicon.ico docs/_static/images/gcp-logo-32x32.png docs/_static/images/gcp-logo.png system_tests/data/CloudPlatform_128px_Retina.png system_tests/data/five-point-one-mb-file.zip system_tests/key.json.enc then you should find the offending lines via git grep -n $'\t' and get rid of the tabs |
Sorry, something went wrong.
| except NotFound: | ||
| return False | ||
|
|
||
| def reload(self, client=None, fields=None): |
| def test_ctor_w_no_name(self): | ||
| client = _Client(project=self.PROJECT) | ||
| config = self._makeOne(name=None, client=client) | ||
| self.assertRaises(ValueError, lambda: config.full_name) |
| client = _Client(project=self.PROJECT) | ||
| config = Config(name=self.CONFIG_NAME, client=client) | ||
| variable = self._makeOne(name=None, config=config) | ||
| self.assertRaises(ValueError, lambda: variable.full_name) |
| self.assertEqual(len(conn._requested), 1) | ||
| req = conn._requested[0] | ||
| self.assertEqual(req['method'], 'GET') | ||
| self.assertEqual(req['path'], '/%s' % self.CONFIG_PATH) |
|
Ping. Please take a second look. I believe I have addressed all open comments. |
Sorry, something went wrong.
|
@dhermes @jonparrott Please review. Is this ready to merge? I just rebased against the latest master. |
Sorry, something went wrong.
| See the ``google-cloud-python`` API `RuntimeConfig documentation`_ to learn | ||
| how to analyze images using this library. | ||
|
|
||
| .. _Vision documentation: https://google-cloud-python.readthedocs.io/en/stable/runtimeconfig-usage.html |
| This will not make an HTTP request; it simply instantiates | ||
| a config object owned by this client. | ||
|
|
||
| :type config_name: string |
| self._properties = {} | ||
|
|
||
| def __repr__(self): | ||
| return '<Config: %s>' % (self.name,) |
| :rtype: string | ||
| :returns: The URL path based on project and config names. | ||
| """ | ||
| return '/%s' % (self.full_name,) |
| This will not make an HTTP request; it simply instantiates | ||
| a variable object owned by this config. | ||
|
|
||
| :type variable_name: string |
| """ | ||
| if not self.name: | ||
| raise ValueError('Missing variable name.') | ||
| return '%s/variables/%s' % (self.config.full_name, self.name) |
| :rtype: string | ||
| :returns: The URL path based on config and variable names. | ||
| """ | ||
| return '/%s' % (self.full_name,) |
| def path(self): | ||
| """URL path for the variable's APIs. | ||
|
|
||
| :rtype: string |
| https://cloud.google.com/deployment-manager/runtime-configurator/reference/rest/v1beta1/projects.configs.variables#VariableState | ||
|
|
||
| :rtype: string or ``NoneType`` | ||
| :returns: If set, one of "UPDATED", "DELETED", or |
| "my-config" | ||
|
|
||
| :type full_name: string | ||
| :param full_name: the full resource name of a config. The full resource |
Used the command: ag -l 'rtype: string' | xargs sed -i .bak 's/rtype: string/rtype: str/g' Based on this comment: googleapis#2485 (comment) `str` is a type, `string` is a module.
To keep the initial review small, this includes only a minimal set of features. It supports listing and getting variables, but not the other methods of the API.
|
@jonparrott @dhermes Please take another look. I believe I have addressed all your comments.
Yes. I wanted to keep the initial PR as small as possible to start. Plus, dpebot and the other samples I want to create will just need read access, not write access to RuntimeConfig. After this goes in, we can add creates in, if only so that we can create system tests for this. Right now I'm running the following snippets manually to verify that it does what I want: $ gcloud config configurations activate kittenbot
export GOOGLE_CLOUD_PROJECT=my-project-name
$ python
from google.cloud import runtimeconfig
client = runtimeconfig.Client()
config = client.config('kittenbot')
iterator = config.list_variables()
iterator.update_page()
variables = list(iterator.page)
print(variables)
token = iterator.next_page_token
print(token)
v = config.get_variable('slack-token')
print(v)
|
Sorry, something went wrong.
Broken by simultaneous merges of googleapis#2594 and googleapis#2485.
Used the command: ag -l 'rtype: string' | xargs sed -i .bak 's/rtype: string/rtype: str/g' Based on this comment: googleapis#2485 (comment) `str` is a type, `string` is a module.
Add support for RuntimeConfig API.
Broken by simultaneous merges of googleapis#2594 and googleapis#2485.
Used the command: ag -l 'rtype: string' | xargs sed -i .bak 's/rtype: string/rtype: str/g' Based on this comment: googleapis/google-cloud-python#2485 (comment) `str` is a type, `string` is a module.
Used the command: ag -l 'rtype: string' | xargs sed -i .bak 's/rtype: string/rtype: str/g' Based on this comment: googleapis/google-cloud-python#2485 (comment) `str` is a type, `string` is a module.
Used the command: ag -l 'rtype: string' | xargs sed -i .bak 's/rtype: string/rtype: str/g' Based on this comment: googleapis/google-cloud-python#2485 (comment) `str` is a type, `string` is a module.
Used the command: ag -l 'rtype: string' | xargs sed -i .bak 's/rtype: string/rtype: str/g' Based on this comment: googleapis/google-cloud-python#2485 (comment) `str` is a type, `string` is a module.
Used the command: ag -l 'rtype: string' | xargs sed -i .bak 's/rtype: string/rtype: str/g' Based on this comment: googleapis/google-cloud-python#2485 (comment) `str` is a type, `string` is a module.
Used the command: ag -l 'rtype: string' | xargs sed -i .bak 's/rtype: string/rtype: str/g' Based on this comment: googleapis/google-cloud-python#2485 (comment) `str` is a type, `string` is a module.
Used the command: ag -l 'rtype: string' | xargs sed -i .bak 's/rtype: string/rtype: str/g' Based on this comment: googleapis/google-cloud-python#2485 (comment) `str` is a type, `string` is a module.
Used the command: ag -l 'rtype: string' | xargs sed -i .bak 's/rtype: string/rtype: str/g' Based on this comment: googleapis/google-cloud-python#2485 (comment) `str` is a type, `string` is a module.
Used the command: ag -l 'rtype: string' | xargs sed -i .bak 's/rtype: string/rtype: str/g' Based on this comment: googleapis/google-cloud-python#2485 (comment) `str` is a type, `string` is a module.
Used the command: ag -l 'rtype: string' | xargs sed -i .bak 's/rtype: string/rtype: str/g' Based on this comment: #2485 (comment) `str` is a type, `string` is a module.
Used the command: ag -l 'rtype: string' | xargs sed -i .bak 's/rtype: string/rtype: str/g' Based on this comment: #2485 (comment) `str` is a type, `string` is a module.
Used the command: ag -l 'rtype: string' | xargs sed -i .bak 's/rtype: string/rtype: str/g' Based on this comment: #2485 (comment) `str` is a type, `string` is a module.
Used the command: ag -l 'rtype: string' | xargs sed -i .bak 's/rtype: string/rtype: str/g' Based on this comment: #2485 (comment) `str` is a type, `string` is a module.
Used the command: ag -l 'rtype: string' | xargs sed -i .bak 's/rtype: string/rtype: str/g' Based on this comment: #2485 (comment) `str` is a type, `string` is a module.
Used the command: ag -l 'rtype: string' | xargs sed -i .bak 's/rtype: string/rtype: str/g' Based on this comment: #2485 (comment) `str` is a type, `string` is a module.
| Back | FazBrowse Home | New Git URL |
Supports listing and getting variables, but not the other methods of the RuntimeConfig API, since
I didn't need those, yet.
First step of #2476