当前位置: 首页>>代码示例>>Python>>正文


Python msrest.Configuration方法代码示例

本文整理汇总了Python中msrest.Configuration方法的典型用法代码示例。如果您正苦于以下问题:Python msrest.Configuration方法的具体用法?Python msrest.Configuration怎么用?Python msrest.Configuration使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在msrest的用法示例。


在下文中一共展示了msrest.Configuration方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: import msrest [as 别名]
# 或者: from msrest import Configuration [as 别名]
def __init__(self, base_url='https://{}.visualstudio.com', organization_name="", creds=None,
                 create_project_url='https://dev.azure.com'):
        """Inits Project as per BaseManager and adds relevant other needed fields"""
        super(ProjectManager, self).__init__(creds, organization_name=organization_name)
        base_url = base_url.format(organization_name)
        self._config = Configuration(base_url=base_url)
        self._client = ServiceClient(creds, self._config)
        self._credentials = creds
        # Need to make a secondary client for the creating project as it uses a different base url
        self._create_project_config = Configuration(base_url=create_project_url)
        self._create_project_client = ServiceClient(creds, self._create_project_config)
        client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)}
        self._deserialize = Deserializer(client_models)
        self._user_mgr = UserManager(creds=self._creds) 
开发者ID:Azure,项目名称:azure-functions-devops-build,代码行数:16,代码来源:project_manager.py

示例2: __init__

# 需要导入模块: import msrest [as 别名]
# 或者: from msrest import Configuration [as 别名]
def __init__(self, base_url='https://api.github.com', pat=None):
        """Inits UserManager as to be able to send the right requests"""
        self._pat = pat
        self._config = Configuration(base_url=base_url)
        self._client = ServiceClient(None, self._config) 
开发者ID:Azure,项目名称:azure-functions-devops-build,代码行数:7,代码来源:base_github_manager.py

示例3: __init__

# 需要导入模块: import msrest [as 别名]
# 或者: from msrest import Configuration [as 别名]
def __init__(self, base_url='https://{}.visualstudio.com', creds=None, organization_name="", project_name=""):
        """Inits PoolManager"""
        super(PoolManager, self).__init__(creds, organization_name=organization_name, project_name=project_name)
        base_url = base_url.format(organization_name)
        self._config = Configuration(base_url=base_url)
        self._client = ServiceClient(creds, self._config)
        client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)}
        self._deserialize = Deserializer(client_models)
        self._user_mgr = UserManager(creds=self._creds) 
开发者ID:Azure,项目名称:azure-functions-devops-build,代码行数:11,代码来源:pool_manager.py

示例4: __init__

# 需要导入模块: import msrest [as 别名]
# 或者: from msrest import Configuration [as 别名]
def __init__(self, organization_name="", project_name="", creds=None):
        base_url = 'https://dev.azure.com'
        self._config = Configuration(base_url=base_url)
        self._client = ServiceClient(creds, self._config)
        client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)}
        self._deserialize = Deserializer(client_models)
        super(RepositoryManager, self).__init__(creds, organization_name=organization_name, project_name=project_name) 
开发者ID:Azure,项目名称:azure-functions-devops-build,代码行数:9,代码来源:repository_manager.py

示例5: __init__

# 需要导入模块: import msrest [as 别名]
# 或者: from msrest import Configuration [as 别名]
def __init__(self, base_url='https://peprodscussu2.portalext.visualstudio.com', creds=None):
        """Inits UserManager as to be able to send the right requests"""
        self._config = Configuration(base_url=base_url)
        self._client = ServiceClient(creds, self._config)
        #create the deserializer for the models
        client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)}
        self._deserialize = Deserializer(client_models)

        # create cache for two user type
        self._cache_aad_user = None
        self._cache_msa_user = None 
开发者ID:Azure,项目名称:azure-functions-devops-build,代码行数:13,代码来源:user_manager.py

示例6: setUp

# 需要导入模块: import msrest [as 别名]
# 或者: from msrest import Configuration [as 别名]
def setUp(self):
        self.cfg = Configuration("https://my_endpoint.com")
        self.cfg.headers = {'Test': 'true'}
        self.creds = mock.create_autospec(OAuthTokenAuthentication)
        self.cfg.credentials = self.creds
        return super(TestServiceClient, self).setUp() 
开发者ID:Azure,项目名称:msrest-for-python,代码行数:8,代码来源:test_client.py

示例7: test_deprecated_creds

# 需要导入模块: import msrest [as 别名]
# 或者: from msrest import Configuration [as 别名]
def test_deprecated_creds(self):
        """Test that creds parameters gets populated correctly.

        https://github.com/Azure/msrest-for-python/issues/135
        """

        cfg = Configuration("http://127.0.0.1/")
        assert cfg.credentials is None

        creds = Authentication()

        client = SDKClient(creds, cfg)
        assert cfg.credentials is creds 
开发者ID:Azure,项目名称:msrest-for-python,代码行数:15,代码来源:test_client.py

示例8: test_sdk_context_manager

# 需要导入模块: import msrest [as 别名]
# 或者: from msrest import Configuration [as 别名]
def test_sdk_context_manager(self):
        cfg = Configuration("http://127.0.0.1/")

        class Creds(Authentication):
            def __init__(self):
                self.first_session = None
                self.called = 0

            def signed_session(self, session=None):
                self.called += 1
                assert session is not None
                if self.first_session:
                    assert self.first_session is session
                else:
                    self.first_session = session
        cfg.credentials = Creds()

        with SDKClient(None, cfg) as client:
            assert cfg.keep_alive

            req = client._client.get('/')
            try:
                # Will fail, I don't care, that's not the point of the test
                client._client.send(req, timeout=0)
            except Exception:
                pass

            try:
                # Will fail, I don't care, that's not the point of the test
                client._client.send(req, timeout=0)
            except Exception:
                pass

        assert not cfg.keep_alive
        assert cfg.credentials.called == 2 
开发者ID:Azure,项目名称:msrest-for-python,代码行数:37,代码来源:test_client.py

示例9: test_context_manager

# 需要导入模块: import msrest [as 别名]
# 或者: from msrest import Configuration [as 别名]
def test_context_manager(self):

        cfg = Configuration("http://127.0.0.1/")

        class Creds(Authentication):
            def __init__(self):
                self.first_session = None
                self.called = 0

            def signed_session(self, session=None):
                self.called += 1
                assert session is not None
                if self.first_session:
                    assert self.first_session is session
                else:
                    self.first_session = session
        cfg.credentials = Creds()

        with ServiceClient(None, cfg) as client:
            assert cfg.keep_alive

            req = client.get('/')
            try:
                # Will fail, I don't care, that's not the point of the test
                client.send(req, timeout=0)
            except Exception:
                pass

            try:
                # Will fail, I don't care, that's not the point of the test
                client.send(req, timeout=0)
            except Exception:
                pass

        assert not cfg.keep_alive
        assert cfg.credentials.called == 2 
开发者ID:Azure,项目名称:msrest-for-python,代码行数:38,代码来源:test_client.py

示例10: test_keep_alive

# 需要导入模块: import msrest [as 别名]
# 或者: from msrest import Configuration [as 别名]
def test_keep_alive(self):

        cfg = Configuration("http://127.0.0.1/")
        cfg.keep_alive = True

        class Creds(Authentication):
            def __init__(self):
                self.first_session = None
                self.called = 0

            def signed_session(self, session=None):
                self.called += 1
                assert session is not None
                if self.first_session:
                    assert self.first_session is session
                else:
                    self.first_session = session
        cfg.credentials = Creds()

        client = ServiceClient(None, cfg)
        req = client.get('/')
        try:
            # Will fail, I don't care, that's not the point of the test
            client.send(req, timeout=0)
        except Exception:
            pass

        try:
            # Will fail, I don't care, that's not the point of the test
            client.send(req, timeout=0)
        except Exception:
            pass

        assert cfg.credentials.called == 2
        # Manually close the client in "keep_alive" mode
        client.close() 
开发者ID:Azure,项目名称:msrest-for-python,代码行数:38,代码来源:test_client.py

示例11: setUp

# 需要导入模块: import msrest [as 别名]
# 或者: from msrest import Configuration [as 别名]
def setUp(self):
        self.cfg = Configuration("https://my_endpoint.com")
        self._d = Deserializer()
        self._d.dependencies = {
            'CloudErrorData': CloudErrorData,
            'TypedErrorInfo': TypedErrorInfo
        }
        return super(TestCloudException, self).setUp() 
开发者ID:Azure,项目名称:msrestazure-for-python,代码行数:10,代码来源:test_exceptions.py

示例12: executerun

# 需要导入模块: import msrest [as 别名]
# 或者: from msrest import Configuration [as 别名]
def executerun(
            self, details, custom_headers=None, raw=False, **operation_config):
        """Execute a differentially private module.

        Create a run of the specified module and return the results.

        :param details: Configuration for the module run.
        :type details: ~restclient.models.ProjectRunDetails
        :param dict custom_headers: headers that will be added to the request
        :param bool raw: returns the direct response alongside the
         deserialized response
        :param operation_config: :ref:`Operation configuration
         overrides<msrest:optionsforoperations>`.
        :return: ExecuterunOKResponse or ClientRawResponse if raw=true
        :rtype: ~restclient.models.ExecuterunOKResponse or
         ~msrest.pipeline.ClientRawResponse
        :raises:
         :class:`HttpOperationError<msrest.exceptions.HttpOperationError>`
        """
        # Construct URL
        url = self.executerun.metadata['url']

        # Construct parameters
        query_parameters = {}

        # Construct headers
        header_parameters = {}
        header_parameters['Content-Type'] = 'application/json; charset=utf-8'
        if custom_headers:
            header_parameters.update(custom_headers)

        # Construct body
        body_content = self._serialize.body(details, 'ProjectRunDetails')

        # Construct and send request
        request = self._client.post(url, query_parameters)
        response = self._client.send(
            request, header_parameters, body_content, stream=False, **operation_config)

        if response.status_code not in [200]:
            raise HttpOperationError(self._deserialize, response)

        deserialized = None

        if response.status_code == 200:
            deserialized = self._deserialize('ExecuterunOKResponse', response)

        if raw:
            client_raw_response = ClientRawResponse(deserialized, response)
            return client_raw_response

        return deserialized 
开发者ID:opendifferentialprivacy,项目名称:whitenoise-system,代码行数:54,代码来源:rest_client.py


注:本文中的msrest.Configuration方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。