Exemplo n.º 1
0
 def download_apiproducts_snapshot(self):
     self.snapshot_data.apiproducts = Apiproducts(
         self.auth, self.org_name, None
     ).list_api_products(prefix=self.prefix, format='dict')
     write_file(
         self.snapshot_data.apiproducts,
         self._gen_download_path(is_snapshot=True, subpaths=['apiproducts', 'apiproducts.json']),
         fs_write=self.fs_write,
         indent=2,
     )
     return self.snapshot_data.apiproducts
Exemplo n.º 2
0
 def download_apiproducts(self):
     for apiproduct in self.snapshot_data.apiproducts:
         try:
             write_file(
                 Apiproducts(self.auth, self.org_name, apiproduct).get_api_product().text,
                 Backups.generate_download_path(
                     self.org_path, subpaths=['apiproducts', f'{apiproduct}.json']
                 ),
                 fs_write=self.fs_write,
             )
         except HTTPError as e:
             Backups.log_error(e, append_msg=' for API Product ({apiproduct})')
         self._Backups__progress_callback(desc='API Products')
Exemplo n.º 3
0
 def download_apiproducts(self):
     for apiproduct in self.snapshot_data.apiproducts:
         try:
             write_file(
                 Apiproducts(self.auth, self.org_name, apiproduct).get_api_product().text,
                 self._gen_download_path(subpaths=['apiproducts', f'{apiproduct}.json']),
                 fs_write=self.fs_write,
             )
         except HTTPError as e:
             console.echo(
                 f'Ignoring {type(e).__name__} {e.response.status_code} error for API Product ({apiproduct})'
             )
         self._progress_callback(desc='API Products')
     return self.snapshot_data.apiproducts
Exemplo n.º 4
0
 def download_apiproducts_snapshot(self):
     self.snapshot_data.apiproducts = Apiproducts(
         self.auth, self.org_name, None
     ).list_api_products(prefix=self.prefix, format='dict')
     data = {
         'snapshot': self.snapshot_data.apiproducts,
         'target_path': self._gen_snapshot_path(subpaths=['apiproducts', 'apiproducts.json']),
         'fs_write': self.fs_write,
         'indent': 2,
     }
     write_file(
         data['snapshot'], data['target_path'], fs_write=data['fs_write'], indent=data['indent']
     )
     return self.snapshot_data.apiproducts
Exemplo n.º 5
0
def _list_api_products(username,
                       password,
                       mfa_secret,
                       token,
                       zonename,
                       org,
                       profile,
                       prefix=None,
                       expand=False,
                       count=1000,
                       startkey="",
                       **kwargs):
    return Apiproducts(
        gen_auth(username, password, mfa_secret, token, zonename), org,
        None).list_api_products(prefix=prefix,
                                expand=expand,
                                count=count,
                                startkey=startkey)
Exemplo n.º 6
0
def _get_api_product(username, password, mfa_secret, token, zonename, org,
                     profile, name, **kwargs):
    return (Apiproducts(
        gen_auth(username, password, mfa_secret, token, zonename), org,
        name).get_api_product().text)
Exemplo n.º 7
0
def _create_api_product(username, password, mfa_secret, token, zonename, org,
                        profile, name, body, **kwargs):
    return (Apiproducts(
        gen_auth(username, password, mfa_secret, token, zonename), org,
        name).create_api_product(body).text)
Exemplo n.º 8
0
def _push_apiproducts(username, password, mfa_secret, token, zonename, org,
                      profile, file, **kwargs):
    return Apiproducts(
        gen_auth(username, password, mfa_secret, token, zonename), org,
        None).push_apiproducts(file)