Example #1
0
    def begin_initialize_code_gen_info(self, metadata_url, user_name='', password=''):
        self._reset_class_info()
        parser = None
        if user_name and password:
            options = odata_client_python.client_options()
            options.enable_client_credential(user_name, password)
            client = odata_client_python.odata_client(metadata_url, options)
        else:
            client = odata_client_python.odata_client(metadata_url)
        if client is None:
            return False

        self._model = client.get_model().get()
        if self._model is None:
            return False

        entity_container = self._model.find_container()
        if entity_container is None:
            print ("must have an entity container in model!")
            exit(-1)

        ns_entity_container = ''
        for schema in self._model.get_schema():
            if schema.find_container() is not None:
                ns_entity_container = schema.get_name()

        total = schema_info()
        for schema in self._model.get_schema():
            self._initialize_class_info(schema, total)
            self._initialize_property_info_of_class(schema, total)

        self._code_gen_map = {}
        self._code_gen_map[ns_entity_container] = total
    def begin_initialize_code_gen_info(self, metadata_url, user_name='', password=''):
        self._reset_class_info()
        parser = None
        if user_name and password:
            options = odata_client_python.client_options()
            options.enable_client_credential(user_name, password)
            client = odata_client_python.odata_client(metadata_url, options)
        else:
            client = odata_client_python.odata_client(metadata_url)
        if client is None:
            return False

        self._model = client.get_model().get()
        if self._model is None:
            return False

        entity_container = self._model.find_container()
        if entity_container is None:
            print ("must have an entity container in model!")
            exit(-1)

        ns_entity_container = ''
        for schema in self._model.get_schema():
            if schema.find_container() is not None:
                ns_entity_container = schema.get_name()

        for schema in self._model.get_schema():
            _schema_info = schema_info()
            self._initialize_class_info(schema, _schema_info)
            self._initialize_property_info_of_class(schema, _schema_info)
            self._code_gen_map[schema.get_name()] = _schema_info

        total = schema_info()
        for schema in self._code_gen_map:
            _schema_info = self._code_gen_map[schema]
            total.class_property_map.update(_schema_info.class_property_map)
            total.class_map.update(_schema_info.class_map)
            total.class_list += _schema_info.class_list
            total.derived_classes.update(_schema_info.derived_classes)
        self._code_gen_map = {}
        self._code_gen_map[ns_entity_container] = total
Example #3
0
 def __init__(self, base_address, options=odata_client_python.client_options()):
     self._client = odata_client_python.odata_client(base_address, options)
     self._model = None
# The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Software.

# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
# DEALINGS IN THE SOFTWARE.

import odata_client_python

path = r"http://odatae2etest.azurewebsites.net/cpptest/DefaultService"
client = odata_client_python.odata_client(path)

def query_entityset():
    print r"==query_entityset=="
    client.send_data_to_server(r"ResetDataSource").get()
    entity_set_name = r"Products"
    entity_set = client.get_entities(entity_set_name).get()
    print len(entity_set) == 5
    print entity_set[0].get_value_type().get_type_kind() == odata_client_python.Entity
    first_entity = entity_set[0]
    property_value = odata_client_python.odata_value()
    print first_entity.get_property_value(r"Name", property_value)
    print property_value.get_value_type().get_type_kind() == odata_client_python.Primitive
    primitive_value = odata_client_python.to_primitive_value(property_value)
    name = primitive_value.to_string()
    print name == r"Cheetos"
# The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Software.

# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
# DEALINGS IN THE SOFTWARE.

import odata_client_python

path = r"http://odatae2etest.azurewebsites.net/cpptest/DefaultService"
client = odata_client_python.odata_client(path)


def query_entityset():
    print r"==query_entityset=="
    client.send_data_to_server(r"ResetDataSource").get()
    entity_set_name = r"Products"
    entity_set = client.get_entities(entity_set_name).get()
    print len(entity_set) == 5
    print entity_set[0].get_value_type().get_type_kind(
    ) == odata_client_python.Entity
    first_entity = entity_set[0]
    property_value = odata_client_python.odata_value()
    print first_entity.get_property_value(r"Name", property_value)
    print property_value.get_value_type().get_type_kind(
    ) == odata_client_python.Primitive